2008-11-03 05:55:34 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
|
|
|
|
* Copyright (C) 2000-2008 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.
|
|
|
|
|
*/
|
2008-11-19 00:12:25 +00:00
|
|
|
class Albums_Controller extends Items_Controller {
|
2008-11-11 06:18:45 +00:00
|
|
|
|
2008-11-16 07:14:12 +00:00
|
|
|
/**
|
2008-11-19 04:20:35 +00:00
|
|
|
* @see Rest_Controller::_show($resource)
|
2008-11-16 07:14:12 +00:00
|
|
|
*/
|
2008-11-19 04:20:35 +00:00
|
|
|
public function _show($item) {
|
2008-12-10 07:05:49 +00:00
|
|
|
if (!access::can("view", $item)) {
|
2008-12-17 22:39:33 +00:00
|
|
|
Kohana::show_404();
|
2008-12-09 10:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-12 19:39:38 +00:00
|
|
|
$theme_name = module::get_var("core", "active_theme", "default");
|
2008-12-16 04:52:16 +00:00
|
|
|
$page_size = module::get_var("core", "page_size", 9);
|
2008-11-07 07:33:43 +00:00
|
|
|
$page = $this->input->get("page", "1");
|
2008-12-17 22:39:33 +00:00
|
|
|
$children_count = $item->viewable()->children_count();
|
|
|
|
|
$offset = ($page-1) * $page_size;
|
2008-11-29 17:08:42 +00:00
|
|
|
|
|
|
|
|
// Make sure that the page references a valid offset
|
2008-12-17 22:39:33 +00:00
|
|
|
if ($page < 1 || $page > ceil($children_count / $page_size)) {
|
|
|
|
|
Kohana::show_404();
|
2008-11-29 17:08:42 +00:00
|
|
|
}
|
2008-12-17 22:39:33 +00:00
|
|
|
|
|
|
|
|
$template = new Theme_View("page.html", "album", $theme_name);
|
|
|
|
|
$template->set_global("page_size", $page_size);
|
|
|
|
|
$template->set_global("item", $item);
|
|
|
|
|
$template->set_global("children", $item->viewable()->children($page_size, $offset));
|
|
|
|
|
$template->set_global("children_count", $children_count);
|
|
|
|
|
$template->set_global("parents", $item->parents());
|
2008-11-09 19:20:23 +00:00
|
|
|
$template->content = new View("album.html");
|
2008-11-05 05:20:20 +00:00
|
|
|
|
2008-11-16 19:12:01 +00:00
|
|
|
print $template;
|
2008-11-03 05:55:34 +00:00
|
|
|
}
|
2008-12-02 21:25:15 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see Rest_Controller::_form_add($parameters)
|
|
|
|
|
*/
|
|
|
|
|
public function _form_add($parent_id) {
|
|
|
|
|
$parent = ORM::factory("item", $parent_id);
|
|
|
|
|
|
|
|
|
|
print album::get_add_form($parent)->render();
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-03 05:55:34 +00:00
|
|
|
}
|