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-05-27 16:15:00 -07:00
|
|
|
$theme_name = module::get_var("gallery", "active_site_theme");
|
2009-03-20 18:19:27 +00:00
|
|
|
if (!file_exists("themes/$theme_name")) {
|
2009-05-27 16:15:00 -07:00
|
|
|
module::set_var("gallery", "active_site_theme", "admin_default");
|
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-01-11 00:19:00 +00:00
|
|
|
if (user::active()->admin) {
|
|
|
|
|
$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);
|
|
|
|
|
$this->set_global("user", user::active());
|
2008-12-15 01:49:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-28 13:47:22 -07:00
|
|
|
public function admin_menu($menu=null) {
|
|
|
|
|
if (!$menu) {
|
|
|
|
|
$menu = Menu::factory("root");
|
2008-12-18 07:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-28 13:47:22 -07:00
|
|
|
$menu
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("dashboard")
|
|
|
|
|
->label(t("Dashboard"))
|
|
|
|
|
->url(url::site("admin")))
|
|
|
|
|
->append(Menu::factory("submenu")
|
|
|
|
|
->id("settings_menu")
|
|
|
|
|
->label(t("Settings"))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("graphics_toolkits")
|
|
|
|
|
->label(t("Graphics"))
|
|
|
|
|
->url(url::site("admin/graphics")))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("languages")
|
|
|
|
|
->label(t("Languages"))
|
|
|
|
|
->url(url::site("admin/languages")))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("l10n_mode")
|
|
|
|
|
->label(Session::instance()->get("l10n_mode", false)
|
|
|
|
|
? t("Stop translating") : t("Start translating"))
|
|
|
|
|
->url(url::site("l10n_client/toggle_l10n_mode?csrf=" .
|
|
|
|
|
access::csrf_token())))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("advanced")
|
|
|
|
|
->label(t("Advanced"))
|
|
|
|
|
->url(url::site("admin/advanced_settings"))))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("modules")
|
|
|
|
|
->label(t("Modules"))
|
|
|
|
|
->url(url::site("admin/modules")))
|
|
|
|
|
->append(Menu::factory("submenu")
|
|
|
|
|
->id("content_menu")
|
|
|
|
|
->label(t("Content")))
|
|
|
|
|
->append(Menu::factory("submenu")
|
|
|
|
|
->id("appearance_menu")
|
|
|
|
|
->label(t("Appearance"))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("themes")
|
|
|
|
|
->label(t("Theme Choice"))
|
|
|
|
|
->url(url::site("admin/themes")))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("theme_options")
|
|
|
|
|
->label(t("Theme Options"))
|
|
|
|
|
->url(url::site("admin/theme_options"))))
|
|
|
|
|
->append(Menu::factory("submenu")
|
|
|
|
|
->id("statistics_menu")
|
|
|
|
|
->label(t("Statistics")))
|
|
|
|
|
->append(Menu::factory("link")
|
|
|
|
|
->id("maintenance")
|
|
|
|
|
->label(t("Maintenance"))
|
|
|
|
|
->url(url::site("admin/maintenance")));
|
|
|
|
|
|
|
|
|
|
module::event("admin_menu", $menu, $this);
|
2009-06-17 13:34:18 -07:00
|
|
|
$menu->compact();
|
2009-07-28 13:47:22 -07:00
|
|
|
return $menu;
|
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":
|
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(
|
|
|
|
|
$blocks, "<div class=\"gAnnotatedThemeBlock gAnnotatedThemeBlock_$function\">" .
|
|
|
|
|
"<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
|
|
|
}
|