2009-01-09 23:31:46 +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
|
2009-01-09 23:31:46 +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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the API for handling themes.
|
|
|
|
|
*
|
|
|
|
|
* Note: by design, this class does not do any permission checking.
|
|
|
|
|
*/
|
|
|
|
|
class theme_Core {
|
2009-11-18 14:37:49 -08:00
|
|
|
public static $site;
|
|
|
|
|
public static $admin;
|
|
|
|
|
|
2009-01-09 23:31:46 +00:00
|
|
|
/**
|
|
|
|
|
* Load the active theme. This is called at bootstrap time. We will only ever have one theme
|
|
|
|
|
* active for any given request.
|
|
|
|
|
*/
|
2009-10-24 10:37:12 -07:00
|
|
|
static function load_themes() {
|
2009-11-03 14:03:36 -08:00
|
|
|
$input = Input::instance();
|
2009-11-18 08:38:11 -08:00
|
|
|
$path = $input->server("PATH_INFO");
|
2009-10-24 10:37:12 -07:00
|
|
|
if (empty($path)) {
|
2009-11-03 14:03:36 -08:00
|
|
|
$path = "/" . $input->get("kohana_uri");
|
2009-10-04 10:04:35 -07:00
|
|
|
}
|
2009-10-24 10:37:12 -07:00
|
|
|
|
2009-11-18 14:37:49 -08:00
|
|
|
self::$site = module::get_var("gallery", "active_site_theme");
|
|
|
|
|
self::$admin = module::get_var("gallery", "active_admin_theme");
|
2009-11-03 14:03:36 -08:00
|
|
|
if (!(identity::active_user()->admin && $theme_name = $input->get("theme"))) {
|
2009-11-18 14:37:49 -08:00
|
|
|
$theme_name = $path == "/admin" || !strncmp($path, "/admin/", 7) ? self::$admin : self::$site;
|
2009-11-03 14:03:36 -08:00
|
|
|
}
|
2009-10-24 10:37:12 -07:00
|
|
|
$modules = Kohana::config("core.modules");
|
|
|
|
|
array_unshift($modules, THEMEPATH . $theme_name);
|
2009-01-27 07:30:28 +00:00
|
|
|
Kohana::config_set("core.modules", $modules);
|
2009-01-09 23:31:46 +00:00
|
|
|
}
|
2009-01-12 07:50:04 +00:00
|
|
|
|
2009-11-18 08:38:11 -08:00
|
|
|
static function get_info($theme_name) {
|
|
|
|
|
$theme_name = preg_replace("/[^\w]/", "", $theme_name);
|
|
|
|
|
$file = THEMEPATH . "$theme_name/theme.info";
|
|
|
|
|
$theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
|
|
|
|
|
$theme_info->description = t($theme_info->description);
|
|
|
|
|
$theme_info->name = t($theme_info->name);
|
|
|
|
|
|
|
|
|
|
return $theme_info;
|
|
|
|
|
}
|
2009-01-09 23:31:46 +00:00
|
|
|
}
|