Code cleanup.
This commit is contained in:
parent
97b4ac60ac
commit
01aae41d74
|
@ -109,7 +109,7 @@ class CalendarView_Controller extends Controller {
|
|||
$calendar_breadcrumbs[1] = new Calendar_Breadcrumb($display_year, url::site("calendarview/calendar/" . $display_year . "/" . $display_user));
|
||||
$calendar_breadcrumbs[2] = new Calendar_Breadcrumb(t(date("F", mktime(0, 0, 0, $display_month, $display_day, $display_year))), url::site("calendarview/month/" . $display_year . "/" . $display_user . "/" . $display_month));
|
||||
$calendar_breadcrumbs[3] = new Calendar_Breadcrumb($display_day, "");
|
||||
$template->set_global("breadcrumbs", $calendar_breadcrumbs);
|
||||
$template->set_global("breadcrumbs", $calendar_breadcrumbs);
|
||||
|
||||
// Finish setting up and then display the page.
|
||||
$template->set_global("children_count", $day_count);
|
||||
|
@ -181,10 +181,10 @@ class CalendarView_Controller extends Controller {
|
|||
}
|
||||
|
||||
// Set up breadcrumbs
|
||||
$calendar_breadcrumbs[0] = new Calendar_Breadcrumb(item::root()->title, item::root()->url());
|
||||
$calendar_breadcrumbs[0] = new Calendar_Breadcrumb(item::root()->title, item::root()->url());
|
||||
$calendar_breadcrumbs[1] = new Calendar_Breadcrumb($display_year, url::site("calendarview/calendar/" . $display_year . "/" . $display_user));
|
||||
$calendar_breadcrumbs[2] = new Calendar_Breadcrumb(t(date("F", mktime(0, 0, 0, $display_month, 1, $display_year))), "");
|
||||
$template->set_global("breadcrumbs", $calendar_breadcrumbs);
|
||||
$template->set_global("breadcrumbs", $calendar_breadcrumbs);
|
||||
|
||||
// Finish setting up and then display the page.
|
||||
$template->set_global("children_count", $day_count);
|
||||
|
|
|
@ -1,88 +1,89 @@
|
|||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
class PHPCalendar_Core {
|
||||
// Month and year to use for calendaring
|
||||
protected $month;
|
||||
protected $year;
|
||||
protected $month_url;
|
||||
// Month and year to use for calendaring
|
||||
protected $month;
|
||||
protected $year;
|
||||
protected $month_url;
|
||||
|
||||
// First Day of the Week (0 = Sunday, 1 = Monday, etc.).
|
||||
protected $week_start = 1;
|
||||
// First Day of the Week (0 = Sunday, 1 = Monday, etc.).
|
||||
protected $week_start = 1;
|
||||
|
||||
// Events for the current month.
|
||||
protected $event_data = Array();
|
||||
// Events for the current month.
|
||||
protected $event_data = Array();
|
||||
|
||||
public function __construct($month = NULL, $year = NULL, $url = NULL)
|
||||
{
|
||||
empty($month) and $month = date('n'); // Current month
|
||||
empty($year) and $year = date('Y'); // Current year
|
||||
public function __construct($month = NULL, $year = NULL, $url = NULL)
|
||||
{
|
||||
empty($month) and $month = date('n'); // Current month
|
||||
empty($year) and $year = date('Y'); // Current year
|
||||
|
||||
// Set the month and year
|
||||
$this->month = (int) $month;
|
||||
$this->year = (int) $year;
|
||||
$this->month_url = $url;
|
||||
// Set the month and year
|
||||
$this->month = (int) $month;
|
||||
$this->year = (int) $year;
|
||||
$this->month_url = $url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function event($day_of_the_week, $event_url = NULL, $css_id = NULL, $custom_text = NULL) {
|
||||
$this->event_data += Array($day_of_the_week => Array($event_url, $css_id, $custom_text));
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return $this->generate_calendar($this->year, $this->month, $this->event_data, 2, $this->month_url, $this->week_start, NULL);
|
||||
}
|
||||
public function event($day_of_the_week, $event_url = NULL, $css_id = NULL, $custom_text = NULL)
|
||||
{
|
||||
$this->event_data += Array($day_of_the_week => Array($event_url, $css_id, $custom_text));
|
||||
}
|
||||
|
||||
# PHP Calendar (version 2.3), written by Keith Devens
|
||||
# http://keithdevens.com/software/php_calendar
|
||||
# see example at http://keithdevens.com/weblog
|
||||
# License: http://keithdevens.com/software/license
|
||||
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
|
||||
$first_of_month = gmmktime(0,0,0,$month,1,$year);
|
||||
#remember that mktime will automatically correct if invalid dates are entered
|
||||
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
|
||||
# this provides a built in "rounding" feature to generate_calendar()
|
||||
public function render()
|
||||
{
|
||||
return $this->generate_calendar($this->year, $this->month, $this->event_data, 2, $this->month_url, $this->week_start, NULL);
|
||||
}
|
||||
|
||||
$day_names = array(); #generate all the day names according to the current locale
|
||||
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
|
||||
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
|
||||
# PHP Calendar (version 2.3), written by Keith Devens
|
||||
# http://keithdevens.com/software/php_calendar
|
||||
# see example at http://keithdevens.com/weblog
|
||||
# License: http://keithdevens.com/software/license
|
||||
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array())
|
||||
{
|
||||
$first_of_month = gmmktime(0,0,0,$month,1,$year);
|
||||
#remember that mktime will automatically correct if invalid dates are entered
|
||||
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
|
||||
# this provides a built in "rounding" feature to generate_calendar()
|
||||
|
||||
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
|
||||
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
|
||||
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
|
||||
$day_names = array(); #generate all the day names according to the current locale
|
||||
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
|
||||
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
|
||||
|
||||
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
|
||||
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
|
||||
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
|
||||
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
|
||||
$calendar = '<table class="calendar">'."\n".
|
||||
'<td class="title" colspan="7" align="center">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</td></tr>\n<tr>";
|
||||
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
|
||||
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
|
||||
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
|
||||
|
||||
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
|
||||
#if day_name_length is >3, the full name of the day will be printed
|
||||
foreach($day_names as $d)
|
||||
$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
|
||||
$calendar .= "</tr>\n<tr>";
|
||||
}
|
||||
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
|
||||
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
|
||||
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
|
||||
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
|
||||
$calendar = '<table class="calendar">'."\n".
|
||||
'<td class="title" colspan="7" align="center">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</td></tr>\n<tr>";
|
||||
|
||||
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
|
||||
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
|
||||
if($weekday == 7){
|
||||
$weekday = 0; #start a new week
|
||||
$calendar .= "</tr>\n<tr>";
|
||||
}
|
||||
if(isset($days[$day]) and is_array($days[$day])){
|
||||
@list($link, $classes, $content) = $days[$day];
|
||||
if(is_null($content)) $content = $day;
|
||||
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
|
||||
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
|
||||
}
|
||||
else $calendar .= "<td class=\"day\">$day</td>";
|
||||
}
|
||||
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
|
||||
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
|
||||
#if day_name_length is >3, the full name of the day will be printed
|
||||
foreach($day_names as $d)
|
||||
$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
|
||||
$calendar .= "</tr>\n<tr>";
|
||||
}
|
||||
|
||||
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
|
||||
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
|
||||
if($weekday == 7){
|
||||
$weekday = 0; #start a new week
|
||||
$calendar .= "</tr>\n<tr>";
|
||||
}
|
||||
if(isset($days[$day]) and is_array($days[$day])){
|
||||
@list($link, $classes, $content) = $days[$day];
|
||||
if(is_null($content)) $content = $day;
|
||||
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
|
||||
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
|
||||
}
|
||||
else $calendar .= "<td class=\"day\">$day</td>";
|
||||
}
|
||||
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
|
||||
|
||||
return $calendar."</tr>\n</table>\n";
|
||||
}
|
||||
|
||||
return $calendar."</tr>\n</table>\n";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -10,7 +10,7 @@
|
|||
while ($counter_months <12) {
|
||||
print "<td>";
|
||||
|
||||
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
||||
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
||||
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
||||
|
||||
// Figure out if any photos were taken for the current month.
|
||||
|
@ -57,14 +57,7 @@
|
|||
->count();
|
||||
}
|
||||
if ($day_count > 0) {
|
||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
||||
/*
|
||||
$calendar -> attach($calendar -> event()
|
||||
-> condition('year', $calendar_year)
|
||||
-> condition('month', $counter_months)
|
||||
-> condition('day', $curr_day)
|
||||
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day), $day_count)));
|
||||
*/
|
||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
||||
}
|
||||
$curr_day++;
|
||||
}
|
||||
|
@ -90,13 +83,6 @@
|
|||
}
|
||||
if ($day_count > 0) {
|
||||
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
||||
/*
|
||||
$calendar -> attach($calendar -> event()
|
||||
-> condition('year', $calendar_year)
|
||||
-> condition('month', $counter_months)
|
||||
-> condition('day', $MAX_DAYS)
|
||||
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS), $day_count)));
|
||||
*/
|
||||
}
|
||||
}
|
||||
echo $calendar->render();
|
||||
|
@ -152,14 +138,7 @@
|
|||
->count();
|
||||
}
|
||||
if ($day_count > 0) {
|
||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
||||
/*
|
||||
$calendar -> attach($calendar -> event()
|
||||
-> condition('year', $calendar_year)
|
||||
-> condition('month', $counter_months)
|
||||
-> condition('day', $curr_day)
|
||||
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day), $day_count)));
|
||||
*/
|
||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
||||
}
|
||||
$curr_day++;
|
||||
}
|
||||
|
@ -182,14 +161,7 @@
|
|||
->count();
|
||||
}
|
||||
if ($day_count > 0) {
|
||||
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
||||
/*
|
||||
$calendar -> attach($calendar -> event()
|
||||
-> condition('year', $calendar_year)
|
||||
-> condition('month', $counter_months)
|
||||
-> condition('day', $MAX_DAYS)
|
||||
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS), $day_count)));
|
||||
*/
|
||||
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
||||
}
|
||||
}
|
||||
$counter_months++;
|
||||
|
|
|
@ -96,9 +96,9 @@
|
|||
<?= $theme->header_bottom() ?>
|
||||
</div>
|
||||
|
||||
<? // The following code was modifed to allow module-defined breadcrumbs.
|
||||
// Everything else in this file is a copy of the default page.html.php file.
|
||||
?>
|
||||
<? // The following code was modifed to allow module-defined breadcrumbs.
|
||||
// Everything else in this file is a copy of the default page.html.php file.
|
||||
?>
|
||||
<? if (!empty($breadcrumbs)): ?>
|
||||
<ul class="g-breadcrumbs">
|
||||
<? $i = 0 ?>
|
||||
|
@ -108,18 +108,18 @@
|
|||
containing that photo. For now, we just do it for
|
||||
the immediate parent so that when you go back up a
|
||||
level you're on the right page. -->
|
||||
<? if ($breadcrumb->url) : ?>
|
||||
<? if ($breadcrumb->url) : ?>
|
||||
<a href="<?= $breadcrumb->url ?>"><?= html::purify($breadcrumb->title) ?></a>
|
||||
<? else : ?>
|
||||
<? else : ?>
|
||||
<?= html::purify($breadcrumb->title) ?>
|
||||
<? endif ?>
|
||||
<? endif ?>
|
||||
</li>
|
||||
<? $i++ ?>
|
||||
<? endforeach ?>
|
||||
</ul>
|
||||
<? endif ?>
|
||||
<? // End modified code ?>
|
||||
|
||||
<? // End modified code ?>
|
||||
|
||||
</div>
|
||||
<div id="bd">
|
||||
<div id="yui-main">
|
||||
|
|
Reference in New Issue
Block a user