X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Fcalendar%2Fcalendar.php;h=e6ed9e7d5b07f00a21e042c8f6161f9923d2dea3;hp=013215bf028b5eace641f94ff63d90ea5ddf3a17;hb=353d074afac6827c90f4bb03e846c5e453d3b5b1;hpb=88cb1b4d2ebd3e74fcee1d756df4e420da8bdf09 diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 013215bf..e6ed9e7d 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1,29 +1,43 @@ - * Licensed under the GNU GPL. For full terms see the file COPYING. - * - * Displays the main calendar page (month view). + +/** + * Displays the main calendar page (month view). * - * $Id$ + * @copyright 2002-2018 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage calendar */ -require_once('calendar_data.php'); -require_once('functions.php'); -chdir('..'); -require_once('../src/validate.php'); -require_once('../functions/strings.php'); -require_once('../functions/date.php'); -require_once('../config/config.php'); -require_once('../functions/page_header.php'); -require_once('../src/load_prefs.php'); - -//display upper part of month calendar view +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); + +/* load date_intl() */ +include_once(SM_PATH . 'functions/date.php'); + +/* Calendar plugin required files. */ +include_once(SM_PATH . 'plugins/calendar/calendar_data.php'); +include_once(SM_PATH . 'plugins/calendar/functions.php'); + +/* get globals */ +if (! sqgetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) { + unset($month); +} +if (! sqgetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) { + unset($year); +} +/* got 'em */ + +/** + * display upper part of month calendar view + * @return void + * @access private + */ function startcalendar() { - global $year, $month, $day, $color; + global $year, $month, $color; $prev_date = mktime(0, 0, 0, $month - 1, 1, $year); $act_date = mktime(0, 0, 0, $month, 1, $year); @@ -34,86 +48,111 @@ function startcalendar() { $next_year = date( 'Y', $next_date ); $self = 'calendar.php'; - echo "" . - "" . - ''. - "\n". - "\n". - "\n" . - "". - "". - ''. - "'. - "'. - "'. - "'. - "'. - "'. - "'. - ''; - + echo html_tag( 'tr', "\n". + html_tag( 'td', "\n". + html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) . + html_tag( 'tr', "\n". + html_tag( 'th', + "<< ".($year-1)."" + ) . "\n". + html_tag( 'th', + "< " . + date_intl( 'M', $prev_date). "" + ) . "\n". + html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') . + html_tag( 'th', + "" . + date_intl( 'M', $next_date) . " >" + ) . "\n". + html_tag( 'th', + "".($year+1)." >>" + ) + ) . "\n". + html_tag( 'tr', + html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . + html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . + html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . + html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . + html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . + html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . + html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n" + ) + ) , + '', $color[0] ) ."\n"; } -//main logic for month view of calendar +/** + * main logic for month view of calendar + * @return void + * @access private + */ function drawmonthview() { - global $year, $month, $day, $color, $calendardata, $todayis; + global $year, $month, $color, $calendardata, $todayis; $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year)); $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year)); while ($aday <= $days_in_month) { - echo ''; + echo html_tag( 'tr' ); for ($j=1; $j<=7; $j++) { $cdate="$month"; ($aday<10)?$cdate=$cdate."0$aday":$cdate=$cdate."$aday"; $cdate=$cdate."$year"; if ( $aday <= $days_in_month && $aday > 0){ - echo "\n"; + echo "\n\n"; $aday++; } echo ''; } } -//end of monthly view and form to jump to any month and year +/** + * end of monthly view and form to jump to any month and year + * @return void + * @access private + */ function endcalendar() { - global $year, $month, $day, $color; + global $year, $month; - echo " \n". - "
<< ".($year-1)."< " . - date_intl( 'M', $prev_date). "" . - date_intl( 'F Y', $act_date ) . "" . - date_intl( 'M', $next_date) . " >".($year+1)." >>
" . _("Sunday") . '" . _("Monday") . '" . _("Tuesday") . '" . _("Wednesday") . '" . _("Thursday") . '" . _("Friday") . '" . _("Saturday") . '
\n" . - "
"; - echo(($cdate==$todayis) ? "[ " . _("TODAY") . " ] " : ""); - echo "[ ' . _("TODAY") . " ] " : ''); + echo "$aday
"; } else { - echo "
\n". + echo html_tag( 'td', '', 'left', $color[0]) ."\n". " "; } if (isset($calendardata[$cdate])){ $i=0; while ($calfoo = each($calendardata[$cdate])) { $calbar = $calendardata[$cdate][$calfoo['key']]; - echo ($calbar['priority']==1) ? "$calbar[title]
\n" : "$calbar[title]
\n"; + // FIXME: how to display multiline task + $title = '['. $calfoo['key']. '] ' . + str_replace(array("\r","\n"),array(' ',' '),sm_encode_html_special_chars($calbar['message'])); + // FIXME: link to nowhere + echo "".sm_encode_html_special_chars($calbar['title'])."
\n"; $i=$i+1; if($i==2){ break; } } } - echo "\n
\n". - "
\n". - " \n"; select_option_year($year); - echo " \n". - " \n". + " \n". - ' \n". - "
\n". - "
\n"; + echo " \n". + ' \n". + " \n". + " \n". + "\n"; } @@ -130,7 +169,7 @@ if( !isset($day) || $day <= 0){ $todayis = date( 'mdY' ); $calself=basename($PHP_SELF); -displayPageHeader($color, 'None'); +displayPageHeader($color); calendar_header(); readcalendardata(); startcalendar(); @@ -138,4 +177,4 @@ drawmonthview(); endcalendar(); ?> - \ No newline at end of file +