X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fform%2FCalendar.class.php;h=447a45e02f5c6a1659dc6205713473b29ec99a47;hb=8a671525046655e057a15c6de9507834322b466d;hp=811a3fc5274af309b35f28942350b9673eb906b6;hpb=9a23a8c0a51b7ec38a96f525484134f3cb85dc7e;p=timetracker.git diff --git a/WEB-INF/lib/form/Calendar.class.php b/WEB-INF/lib/form/Calendar.class.php index 811a3fc5..447a45e0 100644 --- a/WEB-INF/lib/form/Calendar.class.php +++ b/WEB-INF/lib/form/Calendar.class.php @@ -44,36 +44,29 @@ class Calendar extends FormElement { var $controlName = ""; var $highlight = "time"; // Determines what type of active days to highlight ("time" or "expenses"). - // var $mAllDays = true; - var $cClassName = "Calendar"; - function Calendar($name) { - $this->controlName = $name; - $this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December'); - $this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa'); + function __construct($name) { + $this->class = 'Calendar'; + $this->controlName = $name; // TODO: why controlName? Other classes have "name". + $this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December'); + $this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa'); } - + function setHighlight($highlight) { if ($highlight && $highlight != 'time') $this->highlight = $highlight; } - function setLocalization($i18n) { + function localize() { global $user; + global $i18n; - FormElement::setLocalization($i18n); - $this->mMonthNames = $i18n->monthNames; + $this->mMonthNames = $i18n->monthNames; $this->mWeekDayShortNames = $i18n->weekdayShortNames; - if (is_array($i18n->holidays)) { - foreach ($i18n->holidays as $fday) { - $date_a = explode("/",$fday); // format mm/dd - $this->holidays[] = mktime(0,0,0, $date_a[0], $date_a[1], date("Y"));// + 7200; - } - } - $this->weekStartDay = $user->week_start; + $this->weekStartDay = $user->getWeekStart(); } - function setStyle($style) { $this->mStyle = $style; } + function setStyle($style) { $this->style = $style; } function setCellStyle($style) { $this->mCellStyle = $style; } function setACellStyle($style) { $this->mACellStyle = $style; } function setLinkStyle($style) { $this->mLinkStyle = $style; } @@ -90,11 +83,9 @@ class Calendar extends FormElement { function toString($date="") { global $i18n; - $indate = $this->mValue; + $indate = $this->value; if (!$indate) $indate = strftime(DB_DATEFORMAT); - if (!$this->isRenderable()) return ""; - //current year and month if ( strlen ( $indate ) > 0 ) { $indateObj = new DateAndTime(DB_DATEFORMAT, $indate); @@ -135,6 +126,8 @@ class Calendar extends FormElement { $str .= ""; + // TODO: refactor this entire class, as $weekend_start and $weekend_end + // are not what their names suggest (debug with non zero week start to see it). $weekend_start = 6 - $this->weekStartDay; // Saturday by default. $weekend_end = (7 - $this->weekStartDay) % 7; // Sunday by default. if (defined('WEEKEND_START_DAY')) { @@ -166,7 +159,7 @@ class Calendar extends FormElement { $stl_cell = ""; $stl_link = ""; - // weeekend + // weekend if ($j==$weekend_start || $j==$weekend_end) { $stl_cell = ' class="CalendarDayWeekend"'; $stl_link = ' class="CalendarLinkWeekend"'; @@ -174,14 +167,11 @@ class Calendar extends FormElement { $stl_cell = ' class="CalendarDay"'; } - // holidays - if ($this->showHolidays) { - foreach ($this->holidays as $day) { - if($day == $date) { - $stl_cell = ' class="CalendarDayHoliday"'; - $stl_link = ' class="CalendarLinkHoliday"'; - } - } + // holidays + $date_to_check = ttTimeHelper::dateInDatabaseFormat($thisyear, $thismonth, $start_date+$j); + if (ttTimeHelper::isHoliday($date_to_check)) { + $stl_cell = ' class="CalendarDayHoliday"'; + $stl_link = ' class="CalendarLinkHoliday"'; } // selected day @@ -208,7 +198,7 @@ class Calendar extends FormElement { $str .= "\n"; } - $str .= "controlName."=".strftime(DB_DATEFORMAT)."\" tabindex=\"-1\">".$i18n->getKey('label.today')."\n"; + $str .= "controlName."=".strftime(DB_DATEFORMAT)."\" tabindex=\"-1\">".$i18n->get('label.today')."\n"; $str .= "\n"; $str .= "controlName\" value=\"$indate\">\n"; @@ -225,7 +215,7 @@ class Calendar extends FormElement { return $str; } - function toStringControl() { + function getHtml() { return $this->toString(); } @@ -261,7 +251,7 @@ class Calendar extends FormElement { function _getActiveDates($start, $end) { global $user; - $user_id = $user->getActiveUser(); + $user_id = $user->getUser(); $table = ($this->highlight == 'expenses') ? 'tt_expense_items' : 'tt_log'; @@ -281,4 +271,3 @@ class Calendar extends FormElement { return false; } } -?> \ No newline at end of file