feature 1502: Allow to have configuration page for each theme.css.
About string for theme has to be saved in language theme directory (about.html) git-svn-id: http://piwigo.org/svn/trunk@5446 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
034e75f8ea
commit
29d36ffdc3
6 changed files with 113 additions and 35 deletions
31
about.php
31
about.php
|
@ -38,33 +38,16 @@ $title= l10n('About Piwigo');
|
|||
$page['body_id'] = 'theAboutPage';
|
||||
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
||||
|
||||
/**
|
||||
* set in ./local/language/en_UK.lang.php (maybe to create)
|
||||
* for example for clear theme:
|
||||
$lang['Theme: clear'] = 'This is the clear theme based on yoga template. '.
|
||||
' A standard template/theme of PhpWebgallery.';
|
||||
*
|
||||
* Don't forget php tags !!!
|
||||
*
|
||||
* Another way is to code it thru the theme itself in ./themeconf.inc.php
|
||||
*/
|
||||
@include(PHPWG_ROOT_PATH.'template/'.$user['template'].
|
||||
'/theme/'.$user['theme'].'/themeconf.inc.php');
|
||||
|
||||
$template->set_filenames(
|
||||
array(
|
||||
'about'=>'about.tpl',
|
||||
)
|
||||
);
|
||||
if ( isset($lang['Theme: '.$user['theme']]) )
|
||||
{
|
||||
$template->assign(
|
||||
'THEME_ABOUT',l10n('Theme: '.$user['theme'])
|
||||
);
|
||||
}
|
||||
$template->set_filename('about', 'about.tpl');
|
||||
|
||||
$template->assign('ABOUT_MESSAGE', load_language('about.html','', array('return'=>true)) );
|
||||
|
||||
$theme_about = load_language('about.html', PHPWG_THEMES_PATH.$user['theme'].'/', array('return' => true));
|
||||
if ( $theme_about !== false )
|
||||
{
|
||||
$template->assign('THEME_ABOUT', $theme_about);
|
||||
}
|
||||
|
||||
$template->pparse('about');
|
||||
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
||||
?>
|
||||
|
|
|
@ -70,6 +70,8 @@ class themes
|
|||
$crt_db_theme = $this->db_themes_by_id[$theme_id];
|
||||
}
|
||||
|
||||
$file_to_include = PHPWG_THEMES_PATH.'/'.$theme_id.'/admin/maintain.inc.php';
|
||||
|
||||
$errors = array();
|
||||
|
||||
switch ($action)
|
||||
|
@ -100,14 +102,26 @@ class themes
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
$query = "
|
||||
|
||||
if (file_exists($file_to_include))
|
||||
{
|
||||
include($file_to_include);
|
||||
if (function_exists('theme_activate'))
|
||||
{
|
||||
theme_activate($theme_id, $this->fs_themes[$theme_id]['version'], $errors);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errors))
|
||||
{
|
||||
$query = "
|
||||
INSERT INTO ".THEMES_TABLE."
|
||||
SET id = '".$theme_id."'
|
||||
, version = '".$this->fs_themes[$theme_id]['version']."'
|
||||
, name = '".$this->fs_themes[$theme_id]['name']."'
|
||||
;";
|
||||
pwg_query($query);
|
||||
pwg_query($query);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'deactivate':
|
||||
|
@ -150,7 +164,16 @@ SELECT
|
|||
|
||||
$this->set_default_theme($new_theme);
|
||||
}
|
||||
|
||||
|
||||
if (file_exists($file_to_include))
|
||||
{
|
||||
include($file_to_include);
|
||||
if (function_exists('theme_deactivate'))
|
||||
{
|
||||
theme_deactivate($theme_id);
|
||||
}
|
||||
}
|
||||
|
||||
$query = "
|
||||
DELETE
|
||||
FROM ".THEMES_TABLE."
|
||||
|
@ -374,7 +397,13 @@ SELECT
|
|||
.'/images/missing_screenshot.png'
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
$admin_file = $path.'/admin/admin.inc.php';
|
||||
if (file_exists($admin_file))
|
||||
{
|
||||
$theme['admin_uri'] = get_root_url().'admin.php?page=theme&theme='.$file;
|
||||
}
|
||||
|
||||
// IMPORTANT SECURITY !
|
||||
$theme = array_map('htmlspecialchars', $theme);
|
||||
$this->fs_themes[$file] = $theme;
|
||||
|
|
46
admin/theme.php
Normal file
46
admin/theme.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Piwigo - a PHP based picture gallery |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org |
|
||||
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 |
|
||||
// | |
|
||||
// | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if( !defined("PHPWG_ROOT_PATH") )
|
||||
{
|
||||
die ("Hacking attempt!");
|
||||
}
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
check_status(ACCESS_ADMINISTRATOR);
|
||||
|
||||
if (empty($_GET['theme']))
|
||||
{
|
||||
die('Invalid theme URL');
|
||||
}
|
||||
|
||||
$filename = PHPWG_THEMES_PATH.$_GET['theme'].'/admin/admin.inc.php';
|
||||
if (is_file($filename))
|
||||
{
|
||||
include_once($filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
die('Missing file '.$filename);
|
||||
}
|
||||
?>
|
|
@ -749,11 +749,12 @@ BODY#thePopuphelpPage {
|
|||
height: 4em; /* legend height (don't set auto to be Gecko friendly)*/
|
||||
}
|
||||
|
||||
.themeBox {display:inline-block; text-align:center; height:180px; background-color:#eee; margin:5px; -moz-border-radius:5px;}
|
||||
.themeBox {display:inline-table; text-align:center; height:192px; background-color:#eee; margin:5px; -moz-border-radius:5px; overflow:hidden; }
|
||||
|
||||
.themeBox IMG {border:1px solid white; margin:0 15px;}
|
||||
.themeName {font-size:1.1em; margin:5px 0;}
|
||||
.themeActions {margin:5px 0; font-size:12px;}
|
||||
.themeActions {display: table-row; font-size:12px; height: 43px; }
|
||||
.themeActions DIV {display: table-cell; vertical-align: middle; line-height:18px; }
|
||||
.themeActions A {}
|
||||
|
||||
#themesContent .themeBox IMG {width:150px; height:120px;}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<div class="themeName">{$theme.name}{if $theme.is_default} <em>({'default'|@translate})</em>{/if}</div>
|
||||
<div class="themeShot"><img src="{$theme.screenshot}"></div>
|
||||
<div class="themeActions">
|
||||
|
||||
<div>
|
||||
{if $theme.deactivable}
|
||||
<a href="{$deactivate_baseurl}{$theme.id}" title="{'Forbid this theme to users'|@translate}">{'Deactivate'|@translate}</a>
|
||||
{else}
|
||||
|
@ -23,6 +23,10 @@
|
|||
{if not $theme.is_default}
|
||||
| <a href="{$set_default_baseurl}{$theme.id}" title="{'Set as default theme for unregistered and new users'|@translate}">{'Default'|@translate}</a>
|
||||
{/if}
|
||||
{if isset($theme.admin_uri)}
|
||||
<br><a href="{$theme.admin_uri}" title="{'Configuration'|@translate}">{'Configuration'|@translate}</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div> <!-- themeActions -->
|
||||
</div>
|
||||
{/foreach}
|
||||
|
@ -39,7 +43,7 @@
|
|||
<div class="themeName">{$theme.name}</div>
|
||||
<div class="themeShot"><img src="{$theme.screenshot}"></div>
|
||||
<div class="themeActions">
|
||||
|
||||
<div>
|
||||
{if $theme.activable}
|
||||
<a href="{$activate_baseurl}{$theme.id}" title="{'Make this theme available to users'|@translate}">{'Activate'|@translate}</a>
|
||||
{else}
|
||||
|
@ -53,7 +57,7 @@
|
|||
{else}
|
||||
<span title="{$theme.delete_tooltip}">{'Delete'|@translate}</span>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -94,7 +94,7 @@ class Template {
|
|||
{
|
||||
$this->set_template_dir($root.'/'.$theme.'/'.$path);
|
||||
|
||||
include($root.'/'.$theme.'/themeconf.inc.php');
|
||||
$themeconf = $this->load_themeconf($root.'/'.$theme);
|
||||
|
||||
if (isset($themeconf['parent']) and $themeconf['parent'] != $theme)
|
||||
{
|
||||
|
@ -573,6 +573,21 @@ class Template {
|
|||
|
||||
return $source;
|
||||
}
|
||||
|
||||
function load_themeconf($dir)
|
||||
{
|
||||
global $themeconfs, $conf, $page;
|
||||
|
||||
$dir = realpath($dir);
|
||||
if (!isset($themeconfs[$dir]))
|
||||
{
|
||||
$themeconf = array();
|
||||
include($dir.'/themeconf.inc.php');
|
||||
// Put themeconf in cache
|
||||
$themeconfs[$dir] = $themeconf;
|
||||
}
|
||||
return $themeconfs[$dir];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue