Merge branch 'master' of git://github.com/rWatcher/gallery3-contrib
This commit is contained in:
commit
ac627af7b5
178
modules/calendarview/controllers/calendarview.php
Normal file
178
modules/calendarview/controllers/calendarview.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class CalendarView_Controller extends Controller {
|
||||
public function calendar($display_year, $display_user) {
|
||||
// Draw a calendar for the year specified by $display_year.
|
||||
|
||||
// Make sure the function parameters aren't null,
|
||||
// give them default values if they are.
|
||||
if ($display_year == "") {
|
||||
$display_year = date('Y');
|
||||
}
|
||||
if ($display_user == "") {
|
||||
$display_user = "-1";
|
||||
}
|
||||
|
||||
// Draw the page.
|
||||
$template = new Theme_View("page.html", "CalendarView");
|
||||
$template->page_title = t("Gallery :: Calendar");
|
||||
$template->content = new View("calendarview_year.html");
|
||||
$template->content->calendar_year = $display_year;
|
||||
$template->content->calendar_user = $display_user;
|
||||
$template->content->calendar_user_year_form = $this->_get_calenderprefs_form($display_year, $display_user);
|
||||
print $template;
|
||||
}
|
||||
|
||||
public function day($display_year, $display_user, $display_month, $display_day) {
|
||||
// Display all images for the specified day.
|
||||
|
||||
// Figure out the total number of photos to display.
|
||||
if ($display_user == "-1") {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
|
||||
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
|
||||
->find_all()
|
||||
->count();
|
||||
} else {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $display_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
|
||||
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
|
||||
->find_all()
|
||||
->count();
|
||||
}
|
||||
|
||||
// Figure out paging stuff.
|
||||
$page_size = module::get_var("gallery", "page_size", 9);
|
||||
$page = $this->input->get("page", "1");
|
||||
$offset = ($page-1) * $page_size;
|
||||
$max_pages = ceil($day_count / $page_size);
|
||||
|
||||
// Make sure that the page references a valid offset
|
||||
if ($page < 1 || ($day_count && $page > ceil($day_count / $page_size))) {
|
||||
Kohana::show_404();
|
||||
}
|
||||
|
||||
// Set up the page.
|
||||
$template = new Theme_View("page.html", "CalendarDayView");
|
||||
$template->page_title = t("Gallery :: Calendar");
|
||||
$template->set_global("page_size", $page_size);
|
||||
|
||||
// Figure out which photos go on this page.
|
||||
if ($display_user == "-1") {
|
||||
$template->set_global("children", ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
|
||||
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
|
||||
->orderby("captured", "ASC")
|
||||
->find_all($page_size, $offset));
|
||||
} else {
|
||||
$template->set_global("children", ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $display_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
|
||||
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
|
||||
->orderby("captured", "ASC")
|
||||
->find_all($page_size, $offset));
|
||||
}
|
||||
|
||||
// Finish setting up and then display the page.
|
||||
$template->set_global("children_count", $day_count);
|
||||
$template->content = new View("dynamic.html");
|
||||
$template->content->title = t("Photos From ") . date("d F Y", mktime(0, 0, 0, $display_month, $display_day, $display_year));
|
||||
print $template;
|
||||
}
|
||||
|
||||
private function _get_calenderprefs_form($display_year, $display_user) {
|
||||
// Generate a form to allow the visitor to select a year and a gallery photo owner.
|
||||
$form = new Forge("calendarview/setprefs", "", "post",
|
||||
array("id" => "g-view-calendar-form"));
|
||||
|
||||
// Generate a list of all Gallery users who have uploaded photos.
|
||||
$valid_users[-1] = "(All Users)";
|
||||
$gallery_users = ORM::factory("user")->find_all();
|
||||
foreach ($gallery_users as $one_user) {
|
||||
$count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $one_user->id)
|
||||
->where("type !=", "album")
|
||||
->where("captured !=", "")
|
||||
->find_all()
|
||||
->count();
|
||||
if ($count > 0) {
|
||||
$valid_users[$one_user->id] = $one_user->full_name;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate a list of years, starting with the year the earliest photo was
|
||||
// taken, and ending with the year of the most recent photo.
|
||||
$valid_years = Array();
|
||||
$all_photos = ORM::factory("item")
|
||||
->viewable()
|
||||
//->where("owner_id", $one_user->id)
|
||||
->where("type !=", "album")
|
||||
->where("captured !=", "")
|
||||
->orderby("captured", "DESC")
|
||||
->find_all();
|
||||
$counter = date('Y', $all_photos[count($all_photos)-1]->captured);
|
||||
while ($counter <= date('Y', $all_photos[0]->captured)) {
|
||||
$valid_years[$counter] = $counter;
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Create the form.
|
||||
$calendar_group = $form->group("CalendarPrefs");
|
||||
$calendar_group->dropdown('cal_user')
|
||||
->label(t("Display Photos From User: "))
|
||||
->options($valid_users)
|
||||
->selected($display_user);
|
||||
$calendar_group->dropdown('cal_year')
|
||||
->label(t("For Year: "))
|
||||
->options($valid_years)
|
||||
->selected($display_year);
|
||||
|
||||
// Add a save button to the form.
|
||||
$calendar_group->submit("SaveSettings")->value(t("Go"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function setprefs() {
|
||||
// Change the calendar year and / or user.
|
||||
|
||||
// Prevent Cross Site Request Forgery
|
||||
access::verify_csrf();
|
||||
|
||||
// Get user specified settings.
|
||||
$str_user_id = Input::instance()->post("cal_user");
|
||||
$str_year_id = Input::instance()->post("cal_year");
|
||||
|
||||
// redirect to the currect page.
|
||||
url::redirect(url::site("calendarview/calendar/" . $str_year_id . "/" . $str_user_id));
|
||||
|
||||
}
|
||||
}
|
3
modules/calendarview/css/calendarview_menu.css
Normal file
3
modules/calendarview/css/calendarview_menu.css
Normal file
@ -0,0 +1,3 @@
|
||||
#g-view-menu #g-calendarview-link {
|
||||
background-image: url('../images/ico-view-calendarview.png');
|
||||
}
|
44
modules/calendarview/helpers/calendarview_event.php
Normal file
44
modules/calendarview/helpers/calendarview_event.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class calendarview_event_Core {
|
||||
static function photo_menu($menu, $theme) {
|
||||
$menu->append(Menu::factory("link")
|
||||
->id("calendarview")
|
||||
->label(t("View Calendar"))
|
||||
->url(url::site("calendarview/calendar/"))
|
||||
->css_id("g-calendarview-link"));
|
||||
}
|
||||
|
||||
static function movie_menu($menu, $theme) {
|
||||
$menu->append(Menu::factory("link")
|
||||
->id("calendarview")
|
||||
->label(t("View Calendar"))
|
||||
->url(url::site("calendarview/calendar/"))
|
||||
->css_id("g-calendarview-link"));
|
||||
}
|
||||
|
||||
static function album_menu($menu, $theme) {
|
||||
$menu->append(Menu::factory("link")
|
||||
->id("calendarview")
|
||||
->label(t("View Calendar"))
|
||||
->url(url::site("calendarview/calendar/"))
|
||||
->css_id("g-calendarview-link"));
|
||||
}
|
||||
}
|
@ -17,23 +17,9 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class latestupdates_theme_Core {
|
||||
class calendarview_theme_Core {
|
||||
|
||||
static function sidebar_blocks($theme) {
|
||||
if (!$theme->item()) {
|
||||
return;
|
||||
}
|
||||
$albumID = $theme->item->is_album() ? $theme->item->id : $theme->item->parent_id;
|
||||
|
||||
$block = new Block();
|
||||
$block->css_id = "g-updates-block";
|
||||
$block->title = t("Updates");
|
||||
$block->content = new View("latestupdates_block.html");
|
||||
$block->content->update_links = array(
|
||||
"Entire Gallery" => url::site("latestupdates/updates"),
|
||||
"This Album" => url::site("latestupdates/albums/$albumID")
|
||||
);
|
||||
|
||||
return $block;
|
||||
static function head($theme) {
|
||||
$theme->css("calendarview_menu.css");
|
||||
}
|
||||
}
|
BIN
modules/calendarview/images/ico-view-calendarview.png
Normal file
BIN
modules/calendarview/images/ico-view-calendarview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
362
modules/calendarview/libraries/Calendar.php
Normal file
362
modules/calendarview/libraries/Calendar.php
Normal file
@ -0,0 +1,362 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
/**
|
||||
* Calendar creation library.
|
||||
*
|
||||
* $Id: Calendar.php 3769 2008-12-15 00:48:56Z zombor $
|
||||
*
|
||||
* @package Calendar
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2007-2008 Kohana Team
|
||||
* @license http://kohanaphp.com/license.html
|
||||
*/
|
||||
class Calendar_Core extends Event_Subject {
|
||||
|
||||
// Start the calendar on Sunday by default
|
||||
public static $start_monday = FALSE;
|
||||
|
||||
// Month and year to use for calendaring
|
||||
protected $month;
|
||||
protected $year;
|
||||
|
||||
// Week starts on Sunday
|
||||
protected $week_start = 0;
|
||||
|
||||
// Observed data
|
||||
protected $observed_data;
|
||||
|
||||
/**
|
||||
* Returns an array of the names of the days, using the current locale.
|
||||
*
|
||||
* @param integer left of day names
|
||||
* @return array
|
||||
*/
|
||||
public static function days($length = TRUE)
|
||||
{
|
||||
// strftime day format
|
||||
$format = ($length > 3) ? '%A' : '%a';
|
||||
|
||||
// Days of the week
|
||||
$days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
|
||||
|
||||
if (Calendar::$start_monday === TRUE)
|
||||
{
|
||||
// Push Sunday to the end of the days
|
||||
array_push($days, array_shift($days));
|
||||
}
|
||||
|
||||
if (strpos(Kohana::config('locale.language.0'), 'en') !== 0)
|
||||
{
|
||||
// This is a bit awkward, but it works properly and is reliable
|
||||
foreach ($days as $i => $day)
|
||||
{
|
||||
// Convert the English names to i18n names
|
||||
$days[$i] = strftime($format, strtotime($day));
|
||||
}
|
||||
}
|
||||
|
||||
if (is_int($length) OR ctype_digit($length))
|
||||
{
|
||||
foreach ($days as $i => $day)
|
||||
{
|
||||
// Shorten the days to the expected length
|
||||
$days[$i] = utf8::substr($day, 0, $length);
|
||||
}
|
||||
}
|
||||
|
||||
return $days;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Calendar instance. A month and year can be specified.
|
||||
* By default, the current month and year are used.
|
||||
*
|
||||
* @param integer month number
|
||||
* @param integer year number
|
||||
* @return object
|
||||
*/
|
||||
public static function factory($month = NULL, $year = NULL)
|
||||
{
|
||||
return new Calendar($month, $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Calendar instance. A month and year can be specified.
|
||||
* By default, the current month and year are used.
|
||||
*
|
||||
* @param integer month number
|
||||
* @param integer year number
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($month = NULL, $year = 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;
|
||||
|
||||
if (Calendar::$start_monday === TRUE)
|
||||
{
|
||||
// Week starts on Monday
|
||||
$this->week_start = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows fetching the current month and year.
|
||||
*
|
||||
* @param string key to get
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if ($key === 'month' OR $key === 'year')
|
||||
{
|
||||
return $this->$key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calendar_Event factory method.
|
||||
*
|
||||
* @param string unique name for the event
|
||||
* @return object Calendar_Event
|
||||
*/
|
||||
public function event($name = NULL)
|
||||
{
|
||||
return new Calendar_Event($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calendar_Event factory method.
|
||||
*
|
||||
* @chainable
|
||||
* @param string standard event type
|
||||
* @return object
|
||||
*/
|
||||
public function standard($name)
|
||||
{
|
||||
switch ($name)
|
||||
{
|
||||
case 'today':
|
||||
// Add an event for the current day
|
||||
$this->attach($this->event()->condition('timestamp', strtotime('today'))->add_class('today'));
|
||||
break;
|
||||
case 'prev-next':
|
||||
// Add an event for padding days
|
||||
$this->attach($this->event()->condition('current', FALSE)->add_class('prev-next'));
|
||||
break;
|
||||
case 'holidays':
|
||||
// Base event
|
||||
$event = $this->event()->condition('current', TRUE)->add_class('holiday');
|
||||
|
||||
// Attach New Years
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 1)->condition('day', 1));
|
||||
|
||||
// Attach Valentine's Day
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 2)->condition('day', 14));
|
||||
|
||||
// Attach St. Patrick's Day
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 3)->condition('day', 17));
|
||||
|
||||
// Attach Easter
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('easter', TRUE));
|
||||
|
||||
// Attach Memorial Day
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 5)->condition('day_of_week', 1)->condition('last_occurrence', TRUE));
|
||||
|
||||
// Attach Independance Day
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 7)->condition('day', 4));
|
||||
|
||||
// Attach Labor Day
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 9)->condition('day_of_week', 1)->condition('occurrence', 1));
|
||||
|
||||
// Attach Halloween
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 10)->condition('day', 31));
|
||||
|
||||
// Attach Thanksgiving
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 11)->condition('day_of_week', 4)->condition('occurrence', 4));
|
||||
|
||||
// Attach Christmas
|
||||
$holiday = clone $event;
|
||||
$this->attach($holiday->condition('month', 12)->condition('day', 25));
|
||||
break;
|
||||
case 'weekends':
|
||||
// Weekend events
|
||||
$this->attach($this->event()->condition('weekend', TRUE)->add_class('weekend'));
|
||||
break;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array for use with a view. The array contains an array for
|
||||
* each week. Each week contains 7 arrays, with a day number and status:
|
||||
* TRUE if the day is in the month, FALSE if it is padding.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function weeks()
|
||||
{
|
||||
// First day of the month as a timestamp
|
||||
$first = mktime(1, 0, 0, $this->month, 1, $this->year);
|
||||
|
||||
// Total number of days in this month
|
||||
$total = (int) date('t', $first);
|
||||
|
||||
// Last day of the month as a timestamp
|
||||
$last = mktime(1, 0, 0, $this->month, $total, $this->year);
|
||||
|
||||
// Make the month and week empty arrays
|
||||
$month = $week = array();
|
||||
|
||||
// Number of days added. When this reaches 7, start a new week
|
||||
$days = 0;
|
||||
$week_number = 1;
|
||||
|
||||
if (($w = (int) date('w', $first) - $this->week_start) < 0)
|
||||
{
|
||||
$w = 6;
|
||||
}
|
||||
|
||||
if ($w > 0)
|
||||
{
|
||||
// Number of days in the previous month
|
||||
$n = (int) date('t', mktime(1, 0, 0, $this->month - 1, 1, $this->year));
|
||||
|
||||
// i = number of day, t = number of days to pad
|
||||
for ($i = $n - $w + 1, $t = $w; $t > 0; $t--, $i++)
|
||||
{
|
||||
// Notify the listeners
|
||||
$this->notify(array($this->month - 1, $i, $this->year, $week_number, FALSE));
|
||||
|
||||
// Add previous month padding days
|
||||
$week[] = array($i, FALSE, $this->observed_data);
|
||||
$days++;
|
||||
}
|
||||
}
|
||||
|
||||
// i = number of day
|
||||
for ($i = 1; $i <= $total; $i++)
|
||||
{
|
||||
if ($days % 7 === 0)
|
||||
{
|
||||
// Start a new week
|
||||
$month[] = $week;
|
||||
$week = array();
|
||||
|
||||
$week_number++;
|
||||
}
|
||||
|
||||
// Notify the listeners
|
||||
$this->notify(array($this->month, $i, $this->year, $week_number, TRUE));
|
||||
|
||||
// Add days to this month
|
||||
$week[] = array($i, TRUE, $this->observed_data);
|
||||
$days++;
|
||||
}
|
||||
|
||||
if (($w = (int) date('w', $last) - $this->week_start) < 0)
|
||||
{
|
||||
$w = 6;
|
||||
}
|
||||
|
||||
if ($w >= 0)
|
||||
{
|
||||
// i = number of day, t = number of days to pad
|
||||
for ($i = 1, $t = 6 - $w; $t > 0; $t--, $i++)
|
||||
{
|
||||
// Notify the listeners
|
||||
$this->notify(array($this->month + 1, $i, $this->year, $week_number, FALSE));
|
||||
|
||||
// Add next month padding days
|
||||
$week[] = array($i, FALSE, $this->observed_data);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty($week))
|
||||
{
|
||||
// Append the remaining days
|
||||
$month[] = $week;
|
||||
}
|
||||
|
||||
return $month;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new data from an observer. All event data contains and array of CSS
|
||||
* classes and an array of output messages.
|
||||
*
|
||||
* @param array observer data.
|
||||
* @return void
|
||||
*/
|
||||
public function add_data(array $data)
|
||||
{
|
||||
// Add new classes
|
||||
$this->observed_data['classes'] += $data['classes'];
|
||||
|
||||
if ( ! empty($data['output']))
|
||||
{
|
||||
// Only add output if it's not empty
|
||||
$this->observed_data['output'][] = $data['output'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the observed data and sends a notify to all attached events.
|
||||
*
|
||||
* @param array UNIX timestamp
|
||||
* @return void
|
||||
*/
|
||||
public function notify($data)
|
||||
{
|
||||
// Reset observed data
|
||||
$this->observed_data = array
|
||||
(
|
||||
'classes' => array(),
|
||||
'output' => array(),
|
||||
);
|
||||
|
||||
// Send a notify
|
||||
parent::notify($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the calendar to HTML using the kohana_calendar view.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$view = new View('kohana_calendar', array
|
||||
(
|
||||
'month' => $this->month,
|
||||
'year' => $this->year,
|
||||
'weeks' => $this->weeks(),
|
||||
));
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magically convert this object to a string, the rendered calendar.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
} // End Calendar
|
307
modules/calendarview/libraries/Calendar_Event.php
Normal file
307
modules/calendarview/libraries/Calendar_Event.php
Normal file
@ -0,0 +1,307 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
/**
|
||||
* Calendar event observer class.
|
||||
*
|
||||
* $Id: Calendar_Event.php 4129 2009-03-27 17:47:03Z zombor $
|
||||
*
|
||||
* @package Calendar
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2007-2008 Kohana Team
|
||||
* @license http://kohanaphp.com/license.html
|
||||
*/
|
||||
class Calendar_Event_Core extends Event_Observer {
|
||||
|
||||
// Boolean conditions
|
||||
protected $booleans = array
|
||||
(
|
||||
'current',
|
||||
'weekend',
|
||||
'first_day',
|
||||
'last_day',
|
||||
'last_occurrence',
|
||||
'easter',
|
||||
);
|
||||
|
||||
// Rendering conditions
|
||||
protected $conditions = array();
|
||||
|
||||
// Cell classes
|
||||
protected $classes = array();
|
||||
|
||||
// Cell output
|
||||
protected $output = '';
|
||||
|
||||
/**
|
||||
* Adds a condition to the event. The condition can be one of the following:
|
||||
*
|
||||
* timestamp - UNIX timestamp
|
||||
* day - day number (1-31)
|
||||
* week - week number (1-5)
|
||||
* month - month number (1-12)
|
||||
* year - year number (4 digits)
|
||||
* day_of_week - day of week (1-7)
|
||||
* current - active month (boolean) (only show data for the month being rendered)
|
||||
* weekend - weekend day (boolean)
|
||||
* first_day - first day of month (boolean)
|
||||
* last_day - last day of month (boolean)
|
||||
* occurrence - occurrence of the week day (1-5) (use with "day_of_week")
|
||||
* last_occurrence - last occurrence of week day (boolean) (use with "day_of_week")
|
||||
* easter - Easter day (boolean)
|
||||
* callback - callback test (boolean)
|
||||
*
|
||||
* To unset a condition, call condition with a value of NULL.
|
||||
*
|
||||
* @chainable
|
||||
* @param string condition key
|
||||
* @param mixed condition value
|
||||
* @return object
|
||||
*/
|
||||
public function condition($key, $value)
|
||||
{
|
||||
if ($value === NULL)
|
||||
{
|
||||
unset($this->conditions[$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($key === 'callback')
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
elseif (in_array($key, $this->booleans))
|
||||
{
|
||||
// Make the value boolean
|
||||
$value = (bool) $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make the value an int
|
||||
$value = (int) $value;
|
||||
}
|
||||
|
||||
$this->conditions[$key] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a CSS class for this event. This can be called multiple times.
|
||||
*
|
||||
* @chainable
|
||||
* @param string CSS class name
|
||||
* @return object
|
||||
*/
|
||||
public function add_class($class)
|
||||
{
|
||||
$this->classes[$class] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a CSS class for this event. This can be called multiple times.
|
||||
*
|
||||
* @chainable
|
||||
* @param string CSS class name
|
||||
* @return object
|
||||
*/
|
||||
public function remove_class($class)
|
||||
{
|
||||
unset($this->classes[$class]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set HTML output for this event.
|
||||
*
|
||||
* @chainable
|
||||
* @param string HTML output
|
||||
* @return object
|
||||
*/
|
||||
public function output($str)
|
||||
{
|
||||
$this->output = $str;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a CSS class for this event. This can be called multiple times.
|
||||
*
|
||||
* @chainable
|
||||
* @param string CSS class name
|
||||
* @return object
|
||||
*/
|
||||
public function notify($data)
|
||||
{
|
||||
// Split the date and current status
|
||||
list ($month, $day, $year, $week, $current) = $data;
|
||||
|
||||
// Get a timestamp for the day
|
||||
$timestamp = mktime(0, 0, 0, $month, $day, $year);
|
||||
|
||||
// Date conditionals
|
||||
$condition = array
|
||||
(
|
||||
'timestamp' => (int) $timestamp,
|
||||
'day' => (int) date('j', $timestamp),
|
||||
'week' => (int) $week,
|
||||
'month' => (int) date('n', $timestamp),
|
||||
'year' => (int) date('Y', $timestamp),
|
||||
'day_of_week' => (int) date('w', $timestamp),
|
||||
'current' => (bool) $current,
|
||||
);
|
||||
|
||||
// Tested conditions
|
||||
$tested = array();
|
||||
|
||||
foreach ($condition as $key => $value)
|
||||
{
|
||||
// Timestamps need to be handled carefully
|
||||
if($key === 'timestamp' AND isset($this->conditions['timestamp']))
|
||||
{
|
||||
// This adds 23 hours, 59 minutes and 59 seconds to today's timestamp, as 24 hours
|
||||
// is classed as a new day
|
||||
$next_day = $timestamp + 86399;
|
||||
|
||||
if($this->conditions['timestamp'] < $timestamp OR $this->conditions['timestamp'] > $next_day)
|
||||
return FALSE;
|
||||
}
|
||||
// Test basic conditions first
|
||||
elseif (isset($this->conditions[$key]) AND $this->conditions[$key] !== $value)
|
||||
return FALSE;
|
||||
|
||||
// Condition has been tested
|
||||
$tested[$key] = TRUE;
|
||||
}
|
||||
|
||||
if (isset($this->conditions['weekend']))
|
||||
{
|
||||
// Weekday vs Weekend
|
||||
$condition['weekend'] = ($condition['day_of_week'] === 0 OR $condition['day_of_week'] === 6);
|
||||
}
|
||||
|
||||
if (isset($this->conditions['first_day']))
|
||||
{
|
||||
// First day of month
|
||||
$condition['first_day'] = ($condition['day'] === 1);
|
||||
}
|
||||
|
||||
if (isset($this->conditions['last_day']))
|
||||
{
|
||||
// Last day of month
|
||||
$condition['last_day'] = ($condition['day'] === (int) date('t', $timestamp));
|
||||
}
|
||||
|
||||
if (isset($this->conditions['occurrence']))
|
||||
{
|
||||
// Get the occurance of the current day
|
||||
$condition['occurrence'] = $this->day_occurrence($timestamp);
|
||||
}
|
||||
|
||||
if (isset($this->conditions['last_occurrence']))
|
||||
{
|
||||
// Test if the next occurance of this date is next month
|
||||
$condition['last_occurrence'] = ((int) date('n', $timestamp + 604800) !== $condition['month']);
|
||||
}
|
||||
|
||||
if (isset($this->conditions['easter']))
|
||||
{
|
||||
if ($condition['month'] === 3 OR $condition['month'] === 4)
|
||||
{
|
||||
// This algorithm is from Practical Astronomy With Your Calculator, 2nd Edition by Peter
|
||||
// Duffett-Smith. It was originally from Butcher's Ecclesiastical Calendar, published in
|
||||
// 1876. This algorithm has also been published in the 1922 book General Astronomy by
|
||||
// Spencer Jones; in The Journal of the British Astronomical Association (Vol.88, page
|
||||
// 91, December 1977); and in Astronomical Algorithms (1991) by Jean Meeus.
|
||||
|
||||
$a = $condition['year'] % 19;
|
||||
$b = (int) ($condition['year'] / 100);
|
||||
$c = $condition['year'] % 100;
|
||||
$d = (int) ($b / 4);
|
||||
$e = $b % 4;
|
||||
$f = (int) (($b + 8) / 25);
|
||||
$g = (int) (($b - $f + 1) / 3);
|
||||
$h = (19 * $a + $b - $d - $g + 15) % 30;
|
||||
$i = (int) ($c / 4);
|
||||
$k = $c % 4;
|
||||
$l = (32 + 2 * $e + 2 * $i - $h - $k) % 7;
|
||||
$m = (int) (($a + 11 * $h + 22 * $l) / 451);
|
||||
$p = ($h + $l - 7 * $m + 114) % 31;
|
||||
|
||||
$month = (int) (($h + $l - 7 * $m + 114) / 31);
|
||||
$day = $p + 1;
|
||||
|
||||
$condition['easter'] = ($condition['month'] === $month AND $condition['day'] === $day);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Easter can only happen in March or April
|
||||
$condition['easter'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->conditions['callback']))
|
||||
{
|
||||
// Use a callback to determine validity
|
||||
$condition['callback'] = call_user_func($this->conditions['callback'], $condition, $this);
|
||||
}
|
||||
|
||||
$conditions = array_diff_key($this->conditions, $tested);
|
||||
|
||||
foreach ($conditions as $key => $value)
|
||||
{
|
||||
if ($key === 'callback')
|
||||
{
|
||||
// Callbacks are tested on a TRUE/FALSE basis
|
||||
$value = TRUE;
|
||||
}
|
||||
|
||||
// Test advanced conditions
|
||||
if ($condition[$key] !== $value)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->caller->add_data(array
|
||||
(
|
||||
'classes' => $this->classes,
|
||||
'output' => $this->output,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the week day occurrence for a specific timestamp. The occurrence is
|
||||
* relative to the current month. For example, the second Saturday of any
|
||||
* given month will return "2" as the occurrence. This is used in combination
|
||||
* with the "occurrence" condition.
|
||||
*
|
||||
* @param integer UNIX timestamp
|
||||
* @return integer
|
||||
*/
|
||||
protected function day_occurrence($timestamp)
|
||||
{
|
||||
// Get the current month for the timestamp
|
||||
$month = date('m', $timestamp);
|
||||
|
||||
// Default occurrence is one
|
||||
$occurrence = 1;
|
||||
|
||||
// Reduce the timestamp by one week for each loop. This has the added
|
||||
// benefit of preventing an infinite loop.
|
||||
while ($timestamp -= 604800)
|
||||
{
|
||||
if (date('m', $timestamp) !== $month)
|
||||
{
|
||||
// Once the timestamp has gone into the previous month, the
|
||||
// proper occurrence has been found.
|
||||
return $occurrence;
|
||||
}
|
||||
|
||||
// Increment the occurrence
|
||||
$occurrence++;
|
||||
}
|
||||
}
|
||||
|
||||
} // End Calendar Event
|
3
modules/calendarview/module.info
Normal file
3
modules/calendarview/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "CalendarView"
|
||||
description = "View your photos by the date they were taken."
|
||||
version = 1
|
195
modules/calendarview/views/calendarview_year.html.php
Normal file
195
modules/calendarview/views/calendarview_year.html.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<style type="text/css">
|
||||
table.calendar { text-align: center; width:100px; }
|
||||
table.calendar caption { font-size: 1.5em; padding: 0.2em; }
|
||||
table.calendar th, table.calendar td { padding: 0.2em; background: #fff; border: 0; }
|
||||
table.calendar td:hover { background: #ddf; }
|
||||
table.calendar td.prev-next { background: #ccc; color: #999; }
|
||||
table.calendar td.today { color: #800; }
|
||||
select, li {
|
||||
display: inline;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h1 align="center"><?=$calendar_year ?></h1>
|
||||
<?= $calendar_user_year_form ?>
|
||||
|
||||
<?
|
||||
print "<table><tr>";
|
||||
$counter_months = 1;
|
||||
// Loop through each month in the current year.
|
||||
while ($counter_months <12) {
|
||||
print "<td>";
|
||||
$calendar = new Calendar($counter_months, $calendar_year);
|
||||
|
||||
// Figure out if any photos were taken for the current month.
|
||||
if ($calendar_user == "-1") {
|
||||
$month_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
} else {
|
||||
$month_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $calendar_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
}
|
||||
|
||||
// If there are photos, loop through each day in the month and display links on the correct dates.
|
||||
if ($month_count > 0) {
|
||||
$curr_day = 1;
|
||||
$MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year));
|
||||
while ($curr_day < $MAX_DAYS) {
|
||||
if ($calendar_user == "-1") {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
} else {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $calendar_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
}
|
||||
if ($day_count > 0) {
|
||||
$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)));
|
||||
}
|
||||
$curr_day++;
|
||||
}
|
||||
|
||||
// Do the last day of the month seperately, because the mktime code is different.
|
||||
if ($calendar_user == "-1") {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
} else {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $calendar_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
}
|
||||
if ($day_count > 0) {
|
||||
$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();
|
||||
print "</td>";
|
||||
if (($counter_months == 3) || ($counter_months == 6) || ($counter_months == 9)) {
|
||||
print "</tr><tr>";
|
||||
}
|
||||
$counter_months++;
|
||||
}
|
||||
|
||||
// Do December seperately, because the mktime code is different.
|
||||
print "<td>";
|
||||
$calendar = new Calendar($counter_months, $calendar_year);
|
||||
if ($calendar_user == "-1") {
|
||||
$month_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
||||
->find_all()
|
||||
->count();
|
||||
} else {
|
||||
$month_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $calendar_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
||||
->find_all()
|
||||
->count();
|
||||
}
|
||||
if ($month_count > 0) {
|
||||
$curr_day = 1;
|
||||
$MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year));
|
||||
while ($curr_day < $MAX_DAYS) {
|
||||
if ($calendar_user == "-1") {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
} else {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $calendar_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
||||
->find_all()
|
||||
->count();
|
||||
}
|
||||
if ($day_count > 0) {
|
||||
$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)));
|
||||
}
|
||||
$curr_day++;
|
||||
}
|
||||
if ($calendar_user == "-1") {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, 1, 1, $calendar_year+1))
|
||||
->find_all()
|
||||
->count();
|
||||
} else {
|
||||
$day_count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("owner_id", $calendar_user)
|
||||
->where("type !=", "album")
|
||||
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
||||
->where("captured <", mktime(0, 0, 0, 1, 1, $calendar_year+1))
|
||||
->find_all()
|
||||
->count();
|
||||
}
|
||||
if ($day_count > 0) {
|
||||
$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)));
|
||||
|
||||
}
|
||||
}
|
||||
$counter_months++;
|
||||
echo $calendar->render();
|
||||
print "</td></tr></table>";
|
||||
?>
|
50
modules/calendarview/views/kohana_calendar.php
Normal file
50
modules/calendarview/views/kohana_calendar.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
// Get the day names
|
||||
$days = Calendar::days(2);
|
||||
|
||||
// Previous and next month timestamps
|
||||
$next = mktime(0, 0, 0, $month + 1, 1, $year);
|
||||
$prev = mktime(0, 0, 0, $month - 1, 1, $year);
|
||||
|
||||
// Import the GET query array locally and remove the day
|
||||
$qs = $_GET;
|
||||
unset($qs['day']);
|
||||
|
||||
// Previous and next month query URIs
|
||||
$prev = Router::$current_uri.'?'.http_build_query(array_merge($qs, array('month' => date('n', $prev), 'year' => date('Y', $prev))));
|
||||
$next = Router::$current_uri.'?'.http_build_query(array_merge($qs, array('month' => date('n', $next), 'year' => date('Y', $next))));
|
||||
|
||||
?>
|
||||
<table class="calendar">
|
||||
<tr class="controls">
|
||||
<td class="title" colspan="7" align="center"><?php echo strftime('%B %Y', mktime(0, 0, 0, $month, 1, $year)) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($days as $day): ?>
|
||||
<th><?php echo $day ?></th>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<?php foreach ($weeks as $week): ?>
|
||||
<tr>
|
||||
<?php foreach ($week as $day):
|
||||
|
||||
list ($number, $current, $data) = $day;
|
||||
|
||||
if (is_array($data))
|
||||
{
|
||||
$classes = $data['classes'];
|
||||
$output = empty($data['output']) ? '' : '<ul class="output"><li>'.implode('</li><li>', $data['output']).'</li></ul>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$classes = array();
|
||||
$output = '';
|
||||
}
|
||||
|
||||
?>
|
||||
<td class="<?php echo implode(' ', $classes) ?>"><span class="day"><?php echo $day[0] ?></span><?php echo $output ?></td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
@ -31,7 +31,8 @@ class ContactOwner_Controller extends Controller {
|
||||
array("id" => "g-contact-owner-send-form"));
|
||||
$sendmail_fields = $form->group("contactOwner");
|
||||
$sendmail_fields->input("email_to")->label(t("To:"))->value(module::get_var("contactowner", "contact_owner_name"));
|
||||
$sendmail_fields->input("email_from")->label(t("From:"))->value(user::active()->email);
|
||||
$sendmail_fields->input("email_from")->label(t("From:"))->value(identity::active_user()->email);
|
||||
|
||||
$sendmail_fields->input("email_subject")->label(t("Subject:"))->value("");
|
||||
$sendmail_fields->textarea("email_body")->label(t("Message:"))->value("");
|
||||
$sendmail_fields->hidden("email_to_id")->value("-1");
|
||||
@ -65,7 +66,7 @@ class ContactOwner_Controller extends Controller {
|
||||
array("id" => "g-contact-owner-send-form"));
|
||||
$sendmail_fields = $form->group("contactOwner");
|
||||
$sendmail_fields->input("email_to")->label(t("To:"))->value($userDetails[0]->name);
|
||||
$sendmail_fields->input("email_from")->label(t("From:"))->value(user::active()->email);
|
||||
$sendmail_fields->input("email_from")->label(t("From:"))->value(identity::active_user()->email);
|
||||
$sendmail_fields->input("email_subject")->label(t("Subject:"))->value("");
|
||||
$sendmail_fields->textarea("email_body")->label(t("Message:"))->value("");
|
||||
$sendmail_fields->hidden("email_to_id")->value($user_id);
|
||||
|
@ -70,12 +70,13 @@ class latestupdates_Controller extends Controller {
|
||||
}
|
||||
|
||||
// Set up and display the actual page.
|
||||
$template = new Theme_View("page.html", "updates");
|
||||
$template = new Theme_View("page.html", "LatestUpdates");
|
||||
$template->page_title = t("Gallery :: Latest Updates");
|
||||
$template->set_global("page_size", $itemsPerPage);
|
||||
$template->set_global("children", $children);
|
||||
$template->set_global("children_count", $count);
|
||||
$template->content = new View("updates.html");
|
||||
$template->content->items = $children;
|
||||
$template->content->q = count($children);
|
||||
$template->content = new View("dynamic.html");
|
||||
$template->content->title = t("Latest Updates");
|
||||
print $template;
|
||||
}
|
||||
|
||||
@ -127,12 +128,13 @@ class latestupdates_Controller extends Controller {
|
||||
}
|
||||
|
||||
// Set up and display the actual page.
|
||||
$template = new Theme_View("page.html", "updates");
|
||||
$template = new Theme_View("page.html", "LatestUpdates");
|
||||
$template->page_title = t("Gallery :: Latest Updates");
|
||||
$template->set_global("page_size", $itemsPerPage);
|
||||
$template->set_global("children", $items);
|
||||
$template->set_global("children_count", $count);
|
||||
$template->content = new View("updates.html");
|
||||
$template->content->items = $items;
|
||||
$template->content->q = count($items);
|
||||
$template->content = new View ("dynamic.html");
|
||||
$template->content->title = t("Latest Updates");
|
||||
print $template;
|
||||
}
|
||||
|
||||
|
47
modules/latestupdates/helpers/latestupdates_block.php
Normal file
47
modules/latestupdates/helpers/latestupdates_block.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class latestupdates_block_Core {
|
||||
static function get_site_list() {
|
||||
return array("latestupdates" => t("Latest Updates"));
|
||||
}
|
||||
|
||||
static function get($block_id, $theme) {
|
||||
$block = "";
|
||||
|
||||
switch ($block_id) {
|
||||
case "latestupdates":
|
||||
// Determine the ID# of the current album.
|
||||
$albumID = $theme->item->is_album() ? $theme->item->id : $theme->item->parent_id;
|
||||
|
||||
// Make a new sidebar block.
|
||||
$block = new Block();
|
||||
$block->css_id = "g-latest-updates";
|
||||
$block->title = t("Latest Updates");
|
||||
$block->content = new View("latestupdates_block.html");
|
||||
$block->content->batch_tag_form = $form;
|
||||
$block->content->update_links = array(
|
||||
"Entire Gallery" => url::site("latestupdates/updates"),
|
||||
"This Album" => url::site("latestupdates/albums/$albumID")
|
||||
);
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
name = LatestUpdates
|
||||
description = Display recently uploaded photos and videos.
|
||||
name = "LatestUpdates"
|
||||
description = "Display recently uploaded photos and videos."
|
||||
version = 1
|
||||
|
@ -1,33 +0,0 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<? // @todo Set hover on AlbumGrid list items ?>
|
||||
|
||||
<div id="g-latest-updates">
|
||||
<h1><?= t("Latest Updates") ?></h1>
|
||||
<? array("term" => html::clean($q)) ?>
|
||||
<? if (count($items)): ?>
|
||||
<ul id="g-album-grid">
|
||||
<? foreach ($items as $item): ?>
|
||||
<? $item_class = "g-photo"; ?>
|
||||
<? if ($item->is_album()): ?>
|
||||
<? $item_class = "g-album"; ?>
|
||||
<? endif ?>
|
||||
<li class="g-item <?= $item_class ?>">
|
||||
<a href="<?= url::site("items/$item->id") ?>">
|
||||
<?= $item->thumb_img() ?>
|
||||
<p>
|
||||
<?= html::clean($item->title) ?>
|
||||
</p>
|
||||
<div>
|
||||
<?= html::clean($item->description) ?>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
</ul>
|
||||
<?= $theme->pager() ?>
|
||||
|
||||
<? else: ?>
|
||||
<p><?= t("There are no items to display.") ?></p>
|
||||
|
||||
<? endif; ?>
|
||||
</div>
|
3
modules/tagsmap/css/tagsmap_menu.css
Normal file
3
modules/tagsmap/css/tagsmap_menu.css
Normal file
@ -0,0 +1,3 @@
|
||||
#g-view-menu #g-tagsmap-link {
|
||||
background-image: url('../images/ico-view-tagsmap.png');
|
||||
}
|
BIN
modules/tagsmap/images/ico-view-tagsmap.png
Normal file
BIN
modules/tagsmap/images/ico-view-tagsmap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Reference in New Issue
Block a user