mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-05-05 20:49:09 -04:00
Theme Administration v. 2. Doesn't distinguish between regular and admin themes yet
This commit is contained in:
@@ -21,12 +21,27 @@ class Admin_Themes_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_themes.html");
|
||||
$themes = scandir(THEMEPATH);
|
||||
$view->content->themes = array_diff($themes, array(".", "..", ".svn"));
|
||||
$themeDir = scandir(THEMEPATH);
|
||||
$themes = array();
|
||||
foreach ($themeDir as $theme_name) {
|
||||
if (substr($theme_name, 0, 1) == ".") continue;
|
||||
$file = THEMEPATH . $theme_name . "/theme.info";
|
||||
$theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
|
||||
$details = theme::get_edit_form_admin($theme_info);
|
||||
$theme_info['details'] = $details;
|
||||
$themes[$theme_name] = $theme_info;
|
||||
}
|
||||
$view->content->themes = $themes;
|
||||
$view->content->active = module::get_var("core", "active_theme");
|
||||
print $view;
|
||||
}
|
||||
|
||||
public function edit($theme_name) {
|
||||
$file = THEMEPATH . $theme_name . "/theme.info";
|
||||
$theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
|
||||
print theme::get_edit_form_admin($theme_info);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
access::verify_csrf();
|
||||
$theme = $this->input->post("theme");
|
||||
|
||||
@@ -112,6 +112,14 @@ class core_installer {
|
||||
UNIQUE KEY(`name`))
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
||||
|
||||
$db->query("CREATE TABLE `themes` (
|
||||
`id` int(9) NOT NULL auto_increment,
|
||||
`name` varchar(64) default NULL,
|
||||
`version` int(9) default NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY(`name`))
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
||||
|
||||
$db->query("CREATE TABLE `permissions` (
|
||||
`id` int(9) NOT NULL auto_increment,
|
||||
`name` varchar(64) default NULL,
|
||||
@@ -216,6 +224,15 @@ class core_installer {
|
||||
"missing_graphics_toolkit");
|
||||
}
|
||||
|
||||
// Instantiate default themes (regular and admin)
|
||||
foreach (array("default", "admin_default") as $theme_name) {
|
||||
$theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"),
|
||||
ArrayObject::ARRAY_AS_PROPS);
|
||||
$theme = ORM::factory("theme");
|
||||
$theme->name = $theme_name;
|
||||
$theme->version = $theme_info->version;
|
||||
$theme->save();
|
||||
}
|
||||
module::set_version("core", 1);
|
||||
}
|
||||
}
|
||||
@@ -229,6 +246,7 @@ class core_installer {
|
||||
$db->query("DROP TABLE IF EXISTS `logs`;");
|
||||
$db->query("DROP TABLE IF EXISTS `messages`;");
|
||||
$db->query("DROP TABLE IF EXISTS `modules`;");
|
||||
$db->query("DROP TABLE IF EXISTS `themes`;");
|
||||
$db->query("DROP TABLE IF EXISTS `translations_incoming`;");
|
||||
$db->query("DROP TABLE IF EXISTS `permissions`;");
|
||||
$db->query("DROP TABLE IF EXISTS `sessions`;");
|
||||
|
||||
@@ -183,20 +183,6 @@ class module_Core {
|
||||
}
|
||||
public static function dummy_error_handler() { }
|
||||
|
||||
/**
|
||||
* Load the active theme. This is called at bootstrap time. We will only ever have one theme
|
||||
* active for any given request.
|
||||
*/
|
||||
public static function load_themes() {
|
||||
$modules = Kohana::config('core.modules');
|
||||
if (Router::$controller == "admin") {
|
||||
array_unshift($modules, THEMEPATH . 'admin_default');
|
||||
} else {
|
||||
array_unshift($modules, THEMEPATH . 'default');
|
||||
}
|
||||
Kohana::config_set('core.modules', $modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a specific event on all active modules.
|
||||
* @param string $name the event name
|
||||
|
||||
55
core/helpers/theme.php
Normal file
55
core/helpers/theme.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is the API for handling themes.
|
||||
*
|
||||
* Note: by design, this class does not do any permission checking.
|
||||
*/
|
||||
class theme_Core {
|
||||
/**
|
||||
* Load the active theme. This is called at bootstrap time. We will only ever have one theme
|
||||
* active for any given request.
|
||||
*/
|
||||
public static function load_themes() {
|
||||
$modules = Kohana::config('core.modules');
|
||||
if (Router::$controller == "admin") {
|
||||
array_unshift($modules, THEMEPATH . 'admin_default');
|
||||
} else {
|
||||
array_unshift($modules, THEMEPATH . 'default');
|
||||
}
|
||||
Kohana::config_set('core.modules', $modules);
|
||||
}
|
||||
|
||||
public static function get_edit_form_admin($theme) {
|
||||
$form = new Forge("admin/themes/edit/$theme->name", "Theme Parameters", "GET");
|
||||
// array("id" => "gThemeDetails"));
|
||||
$group = $form->group("edit_theme")->label($theme->description);
|
||||
$group->input("name")->label(t("Name"))->id("gName")->value($theme->name);
|
||||
$group->submit(t("Modify Theme"));
|
||||
return $form;
|
||||
}
|
||||
|
||||
public static function get_edit_form_content($theme_name) {
|
||||
$file = THEMEPATH . $theme_name . "/theme.info";
|
||||
$theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
*/
|
||||
|
||||
Event::add("system.ready", array("module", "load_modules"));
|
||||
Event::add("system.post_routing", array("module", "load_themes"));
|
||||
|
||||
|
||||
21
core/hooks/load_themes.php
Normal file
21
core/hooks/load_themes.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
Event::add("system.post_routing", array("theme", "load_themes"));
|
||||
21
core/models/theme.php
Normal file
21
core/models/theme.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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.
|
||||
*/
|
||||
class Theme_Model extends ORM {
|
||||
}
|
||||
@@ -1,17 +1,30 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="gThemes">
|
||||
<h1><?= t("Theme Administration") ?></h1>
|
||||
<p>
|
||||
<?= t("These are the themes in your system") ?>
|
||||
</p>
|
||||
<form method="post" action="<?= url::site("admin/themes/save") ?>">
|
||||
<form method="post" id="gThemeAdmin" action="<?= url::site("admin/themes/save") ?>">
|
||||
<?= access::csrf_form_field() ?>
|
||||
<? foreach ($themes as $theme): ?>
|
||||
<input type="radio" name="theme" value="<?= $theme ?>"
|
||||
<? if ($theme == $active): ?> checked="checked" <? endif ?>
|
||||
/>
|
||||
<?= $theme ?>
|
||||
<table><tbody><tr><td>
|
||||
<?= t("Current theme") ?><br />
|
||||
<a href="#">
|
||||
<img src="<?= url::file("themes/{$active}/thumbnail.png") ?>" alt="<?= $themes[$active]->name ?>" />
|
||||
</a><br />
|
||||
<?= $themes[$active]->description ?><br />
|
||||
<input type="radio" name="themes" value="<?= $active ?>" checked="checked">
|
||||
<?= $themes[$active]->name ?>
|
||||
</td>
|
||||
<? foreach ($themes as $id => $theme): ?>
|
||||
<? if ($id == $active) continue; ?>
|
||||
<td>
|
||||
<a href="#">
|
||||
<img src="<?= url::file("themes/{$id}/thumbnail.png") ?>" alt="<?= $theme->name ?>" />
|
||||
</a><br />
|
||||
<?= $theme->description ?><br />
|
||||
<input type="radio" name="themes" value="<?= $id ?>"> <?= $theme->name ?>
|
||||
</td>
|
||||
<? endforeach ?>
|
||||
</tr></tbody></table>
|
||||
<input type="submit" value="<?= t("Save") ?>"/>
|
||||
</form>
|
||||
<div id="gThemeDetails"></div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -22,4 +22,11 @@ $(document).ready(function(){
|
||||
for (var i=0; i < dialogLinks.length; i++) {
|
||||
$(dialogLinks[i]).bind("click", {element: dialogLinks[i]}, handleDialogEvent);
|
||||
};
|
||||
|
||||
$("#gThemeAdmin :radio").click(function(event) {
|
||||
console.log("clicked radio " + event.target.value);
|
||||
$("#gThemeDetails").load("themes/edit/" + event.target.value);
|
||||
});
|
||||
|
||||
$("#gThemeDetails").load("themes/edit/default");
|
||||
});
|
||||
|
||||
4
themes/admin_default/theme.info
Normal file
4
themes/admin_default/theme.info
Normal file
@@ -0,0 +1,4 @@
|
||||
name = Default Admin
|
||||
description = Default Gallery theme to administer
|
||||
version = 1
|
||||
author = Gallery Team
|
||||
BIN
themes/admin_default/thumbnail.png
Normal file
BIN
themes/admin_default/thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
4
themes/default/theme.info
Normal file
4
themes/default/theme.info
Normal file
@@ -0,0 +1,4 @@
|
||||
name = Default
|
||||
description = Default Gallery theme to view photos and albums
|
||||
version = 1
|
||||
author = Gallery Team
|
||||
Reference in New Issue
Block a user