2008-11-03 05:52:13 +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-27 16:19:07 +00:00
|
|
|
class Theme_View_Core extends View {
|
2008-11-04 05:02:37 +00:00
|
|
|
private $theme_name = null;
|
2008-11-03 05:52:13 +00:00
|
|
|
|
2008-11-27 16:19:07 +00:00
|
|
|
/**
|
|
|
|
|
* Attempts to load a view and pre-load view data.
|
|
|
|
|
*
|
|
|
|
|
* @throws Kohana_Exception if the requested view cannot be found
|
|
|
|
|
* @param string $name view name
|
2008-12-15 01:48:34 +00:00
|
|
|
* @param string $page_type page type: album, photo, tags, etc
|
2008-11-27 16:19:07 +00:00
|
|
|
* @param string $theme_name view name
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2008-12-24 04:22:22 +00:00
|
|
|
public function __construct($name, $page_type) {
|
2009-03-20 18:19:27 +00:00
|
|
|
$theme_name = module::get_var("core", "active_site_theme");
|
|
|
|
|
if (!file_exists("themes/$theme_name")) {
|
|
|
|
|
module::set_var("core", "active_site_theme", "default");
|
|
|
|
|
theme::load_themes();
|
|
|
|
|
Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme.");
|
|
|
|
|
}
|
2008-11-27 16:19:07 +00:00
|
|
|
parent::__construct($name);
|
2008-12-24 04:22:22 +00:00
|
|
|
|
2009-01-13 10:53:06 +00:00
|
|
|
$this->theme_name = module::get_var("core", "active_site_theme");
|
2009-01-11 00:19:00 +00:00
|
|
|
if (user::active()->admin) {
|
|
|
|
|
$this->theme_name = Input::instance()->get("theme", $this->theme_name);
|
|
|
|
|
}
|
2009-03-16 11:17:27 +00:00
|
|
|
$this->item = null;
|
|
|
|
|
$this->tag = null;
|
2009-03-16 04:33:45 +00:00
|
|
|
$this->set_global("theme", $this);
|
|
|
|
|
$this->set_global("user", user::active());
|
2008-11-27 16:19:07 +00:00
|
|
|
$this->set_global("page_type", $page_type);
|
2009-03-05 00:32:33 +00:00
|
|
|
|
|
|
|
|
$maintenance_mode = Kohana::config("core.maintenance_mode", false, false);
|
2009-03-16 04:33:45 +00:00
|
|
|
if ($maintenance_mode) {
|
|
|
|
|
message::warning(t("This site is currently in maintenance mode"));
|
2009-03-05 00:32:33 +00:00
|
|
|
}
|
2008-11-04 05:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-10 06:18:35 +00:00
|
|
|
public function url($path, $absolute_url=false) {
|
|
|
|
|
$arg = "themes/{$this->theme_name}/$path";
|
|
|
|
|
return $absolute_url ? url::abs_file($arg) : url::file($arg);
|
2008-11-04 05:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-05 05:20:20 +00:00
|
|
|
public function item() {
|
2008-11-27 16:19:07 +00:00
|
|
|
return $this->item;
|
2008-11-05 05:20:20 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-28 01:18:45 +00:00
|
|
|
public function tag() {
|
|
|
|
|
return $this->tag;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-27 04:58:38 +00:00
|
|
|
public function page_type() {
|
2008-11-27 16:19:07 +00:00
|
|
|
return $this->page_type;
|
2008-11-27 04:58:38 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-04 05:02:37 +00:00
|
|
|
public function display($page_name, $view_class="View") {
|
|
|
|
|
return new $view_class($page_name);
|
2008-11-03 05:52:13 +00:00
|
|
|
}
|
2008-11-05 05:20:20 +00:00
|
|
|
|
2008-12-18 07:32:34 +00:00
|
|
|
public function site_menu() {
|
2009-01-07 09:07:45 +00:00
|
|
|
$menu = Menu::factory("root");
|
2009-03-12 03:54:17 +00:00
|
|
|
if ($this->page_type != "login") {
|
|
|
|
|
core_menu::site($menu, $this);
|
|
|
|
|
|
|
|
|
|
foreach (module::installed() as $module) {
|
|
|
|
|
if ($module->name == "core") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$class = "{$module->name}_menu";
|
|
|
|
|
if (method_exists($class, "site")) {
|
|
|
|
|
call_user_func_array(array($class, "site"), array(&$menu, $this));
|
|
|
|
|
}
|
2008-12-08 06:14:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print $menu;
|
2008-12-07 19:45:46 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-04 03:43:12 +00:00
|
|
|
public function album_menu() {
|
2009-01-07 09:07:45 +00:00
|
|
|
$menu = Menu::factory("root");
|
2009-01-04 03:43:12 +00:00
|
|
|
core_menu::album($menu, $this);
|
|
|
|
|
|
2009-01-04 07:40:37 +00:00
|
|
|
foreach (module::installed() as $module) {
|
|
|
|
|
if ($module->name == "core") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$class = "{$module->name}_menu";
|
|
|
|
|
if (method_exists($class, "album")) {
|
|
|
|
|
call_user_func_array(array($class, "album"), array(&$menu, $this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-04 03:43:12 +00:00
|
|
|
print $menu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function photo_menu() {
|
2009-01-07 09:07:45 +00:00
|
|
|
$menu = Menu::factory("root");
|
2009-01-04 03:43:12 +00:00
|
|
|
core_menu::photo($menu, $this);
|
|
|
|
|
|
2009-01-04 07:40:37 +00:00
|
|
|
foreach (module::installed() as $module) {
|
|
|
|
|
if ($module->name == "core") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$class = "{$module->name}_menu";
|
|
|
|
|
if (method_exists($class, "photo")) {
|
|
|
|
|
call_user_func_array(array($class, "photo"), array(&$menu, $this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-04 03:43:12 +00:00
|
|
|
print $menu;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-07 07:33:43 +00:00
|
|
|
public function pager() {
|
2009-03-08 03:57:02 +00:00
|
|
|
if ($this->children_count) {
|
|
|
|
|
$this->pagination = new Pagination();
|
|
|
|
|
$this->pagination->initialize(
|
|
|
|
|
array('query_string' => 'page',
|
|
|
|
|
'total_items' => $this->children_count,
|
|
|
|
|
'items_per_page' => $this->page_size,
|
|
|
|
|
'style' => 'classic'));
|
|
|
|
|
return $this->pagination->render();
|
|
|
|
|
}
|
2008-11-07 07:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-30 04:13:31 +00:00
|
|
|
/**
|
|
|
|
|
* Print out any site wide status information.
|
|
|
|
|
*/
|
|
|
|
|
public function site_status() {
|
|
|
|
|
return site_status::get();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-22 06:50:20 +00:00
|
|
|
/**
|
|
|
|
|
* Print out any messages waiting for this user.
|
|
|
|
|
*/
|
|
|
|
|
public function messages() {
|
|
|
|
|
return message::get();
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-22 21:46:34 +00:00
|
|
|
/**
|
|
|
|
|
* Handle all theme functions that insert module content.
|
|
|
|
|
*/
|
|
|
|
|
public function __call($function, $args) {
|
|
|
|
|
switch ($function) {
|
2008-11-27 11:33:45 +00:00
|
|
|
case "album_blocks":
|
|
|
|
|
case "album_bottom":
|
|
|
|
|
case "album_top":
|
2008-11-28 09:46:29 +00:00
|
|
|
case "credits";
|
2009-03-12 15:40:08 +00:00
|
|
|
case "dynamic_bottom":
|
|
|
|
|
case "dynamic_top":
|
2008-12-22 03:53:36 +00:00
|
|
|
case "footer":
|
2008-11-22 21:46:34 +00:00
|
|
|
case "head":
|
|
|
|
|
case "header_bottom":
|
2008-11-27 11:33:45 +00:00
|
|
|
case "header_top":
|
|
|
|
|
case "page_bottom":
|
|
|
|
|
case "page_top":
|
|
|
|
|
case "photo_blocks":
|
2009-03-12 15:40:08 +00:00
|
|
|
case "photo_bottom":
|
2008-11-27 11:33:45 +00:00
|
|
|
case "photo_top":
|
2009-03-31 05:14:40 +00:00
|
|
|
case "resize_bottom":
|
|
|
|
|
case "resize_top":
|
2008-11-22 21:46:34 +00:00
|
|
|
case "sidebar_blocks":
|
|
|
|
|
case "sidebar_bottom":
|
2008-11-27 11:33:45 +00:00
|
|
|
case "sidebar_top":
|
2008-12-17 04:45:35 +00:00
|
|
|
case "thumb_bottom":
|
|
|
|
|
case "thumb_info":
|
|
|
|
|
case "thumb_top":
|
2008-11-22 21:50:39 +00:00
|
|
|
$blocks = array();
|
2008-11-28 18:39:18 +00:00
|
|
|
foreach (module::installed() as $module) {
|
2009-01-18 05:01:00 +00:00
|
|
|
$helper_class = "{$module->name}_theme";
|
2008-11-25 02:17:53 +00:00
|
|
|
if (method_exists($helper_class, $function)) {
|
2008-11-22 21:50:39 +00:00
|
|
|
$blocks[] = call_user_func_array(
|
|
|
|
|
array($helper_class, $function),
|
|
|
|
|
array_merge(array($this), $args));
|
2008-11-22 21:46:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-01-01 00:16:08 +00:00
|
|
|
if (Session::instance()->get("debug")) {
|
2008-11-25 02:17:53 +00:00
|
|
|
if ($function != "head") {
|
|
|
|
|
array_unshift(
|
2008-11-25 02:27:00 +00:00
|
|
|
$blocks, "<div class=\"gAnnotatedThemeBlock gAnnotatedThemeBlock_$function gClearFix\">" .
|
2008-11-25 02:17:53 +00:00
|
|
|
"<div class=\"title\">$function</div>");
|
|
|
|
|
$blocks[] = "</div>";
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-11-22 21:50:39 +00:00
|
|
|
return implode("\n", $blocks);
|
2008-11-22 21:46:34 +00:00
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new Exception("@todo UNKNOWN_THEME_FUNCTION: $function");
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-11-27 16:19:07 +00:00
|
|
|
}
|