2008-12-15 01:49:25 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
2009-05-13 20:04:58 +00:00
|
|
|
* Copyright (C) 2000-2009 Bharat Mediratta
|
2008-12-15 01:49:25 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2009-06-28 19:45:11 -07:00
|
|
|
class Admin_View_Core extends Gallery_View {
|
2008-12-15 01:49:25 +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
|
|
|
|
|
* @param string $theme_name view name
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2008-12-24 04:22:22 +00:00
|
|
|
public function __construct($name) {
|
2009-09-24 15:06:40 -07:00
|
|
|
$theme_name = module::get_var("gallery", "active_admin_theme");
|
|
|
|
|
if (!file_exists(THEMEPATH . $theme_name)) {
|
|
|
|
|
module::set_var("gallery", "active_admin_theme", "admin_wind");
|
2009-03-20 18:19:27 +00:00
|
|
|
theme::load_themes();
|
|
|
|
|
Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme.");
|
|
|
|
|
}
|
2008-12-15 01:49:25 +00:00
|
|
|
parent::__construct($name);
|
2008-12-24 04:22:22 +00:00
|
|
|
|
2009-05-27 16:15:00 -07:00
|
|
|
$this->theme_name = module::get_var("gallery", "active_admin_theme");
|
2009-10-22 13:09:20 -07:00
|
|
|
if (identity::active_user()->admin) {
|
2009-01-11 00:19:00 +00:00
|
|
|
$this->theme_name = Input::instance()->get("theme", $this->theme_name);
|
2009-03-16 07:59:28 +00:00
|
|
|
}
|
|
|
|
|
$this->sidebar = "";
|
2009-03-26 06:56:29 +00:00
|
|
|
$this->set_global("theme", $this);
|
2009-10-22 13:09:20 -07:00
|
|
|
$this->set_global("user", identity::active_user());
|
2008-12-15 01:49:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-28 20:32:11 -07:00
|
|
|
public function admin_menu() {
|
|
|
|
|
$menu = Menu::factory("root");
|
2009-07-28 13:47:22 -07:00
|
|
|
module::event("admin_menu", $menu, $this);
|
2009-10-27 13:46:24 -07:00
|
|
|
return $menu->compact()->render();
|
2008-12-18 07:32:34 +00:00
|
|
|
}
|
2008-12-20 00:52:20 +00:00
|
|
|
|
2008-12-29 00:35:31 +00:00
|
|
|
/**
|
2008-12-30 04:14:57 +00:00
|
|
|
* Print out any site wide status information.
|
2008-12-29 00:35:31 +00:00
|
|
|
*/
|
|
|
|
|
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-12-20 00:52:20 +00:00
|
|
|
/**
|
|
|
|
|
* Handle all theme functions that insert module content.
|
|
|
|
|
*/
|
|
|
|
|
public function __call($function, $args) {
|
|
|
|
|
switch ($function) {
|
2008-12-29 00:35:31 +00:00
|
|
|
case "admin_credits";
|
2008-12-22 03:53:36 +00:00
|
|
|
case "admin_footer":
|
2008-12-29 00:35:31 +00:00
|
|
|
case "admin_header_top":
|
|
|
|
|
case "admin_header_bottom":
|
2008-12-22 03:53:36 +00:00
|
|
|
case "admin_page_bottom":
|
|
|
|
|
case "admin_page_top":
|
2008-12-25 20:59:33 +00:00
|
|
|
case "admin_head":
|
2009-07-29 17:25:53 -07:00
|
|
|
case "body_attributes":
|
2008-12-20 00:52:20 +00:00
|
|
|
$blocks = array();
|
2009-05-26 05:28:59 +00:00
|
|
|
foreach (module::active() as $module) {
|
2009-01-18 05:01:00 +00:00
|
|
|
$helper_class = "{$module->name}_theme";
|
2008-12-20 00:52:20 +00:00
|
|
|
if (method_exists($helper_class, $function)) {
|
|
|
|
|
$blocks[] = call_user_func_array(
|
|
|
|
|
array($helper_class, $function),
|
|
|
|
|
array_merge(array($this), $args));
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-01 00:16:08 +00:00
|
|
|
|
2009-06-29 20:08:35 -07:00
|
|
|
if ($function == "admin_head") {
|
2009-06-29 18:12:53 -07:00
|
|
|
array_unshift($blocks, $this->combine_files($this->css, "css"));
|
2009-06-29 19:11:59 -07:00
|
|
|
array_unshift($blocks, $this->combine_files($this->scripts, "javascript"));
|
2009-06-28 19:45:11 -07:00
|
|
|
}
|
|
|
|
|
|
2009-01-01 00:16:08 +00:00
|
|
|
if (Session::instance()->get("debug")) {
|
|
|
|
|
if ($function != "admin_head") {
|
|
|
|
|
array_unshift(
|
2009-10-04 00:27:22 -06:00
|
|
|
$blocks, "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function\">" .
|
2009-01-01 00:16:08 +00:00
|
|
|
"<div class=\"title\">$function</div>");
|
|
|
|
|
$blocks[] = "</div>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-20 00:52:20 +00:00
|
|
|
return implode("\n", $blocks);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new Exception("@todo UNKNOWN_THEME_FUNCTION: $function");
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-15 01:49:25 +00:00
|
|
|
}
|