Skip to content

Commit 4f80b60

Browse files
author
rvelices
committed
- allow template class to be instantiated with an empty theme (in plugins for example)
- local_head must now be defined in the themeconf.inc.php otherwise not taken into account (avoid several calls to file_exists) - renamed themeconf['theme'] to themeconf['name'] (this is what it is themeconf[theme] is confusing) git-svn-id: http://piwigo.org/svn/trunk@5177 68402e56-0260-453c-a942-63ccdbb3a9ee
1 parent 15fdea6 commit 4f80b60

8 files changed

Lines changed: 22 additions & 26 deletions

File tree

admin/themes/clear/themeconf.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
$themeconf = array(
3-
'theme' => 'clear',
3+
'name' => 'clear',
44
'parent' => 'default',
55
'admin_icon_dir' => 'admin/themes/clear/icon',
66
);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22
$themeconf = array(
3-
'theme' => 'default',
3+
'name' => 'default',
44
'icon_dir' => 'themes/default/icon',
55
'admin_icon_dir' => 'admin/themes/default/icon',
66
'mime_icon_dir' => 'themes/default/icon/mimetypes/',
7+
'local_head' => 'local_head.tpl',
78
);
89
?>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
$themeconf = array(
3-
'theme' => 'roma',
3+
'name' => 'roma',
44
'parent' => 'default',
55
);
66
?>

include/template.class.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@
2424

2525
require_once(PHPWG_ROOT_PATH.'include/smarty/libs/Smarty.class.php');
2626

27-
// migrate lang:XXX
28-
// sed "s/{lang:\([^}]\+\)}/{\'\1\'|@translate}/g" my_template.tpl
29-
// migrate change root level vars {XXX}
30-
// sed "s/{pwg_root}/{ROOT_URL}/g" my_template.tpl
31-
// migrate change root level vars {XXX}
32-
// sed "s/{\([a-zA-Z_]\+\)}/{$\1}/g" my_template.tpl
33-
// migrate all
34-
// cat my_template.tpl | sed "s/{lang:\([^}]\+\)}/{\'\1\'|@translate}/g" | sed "s/{pwg_root}/{ROOT_URL}/g" | sed "s/{\([a-zA-Z_]\+\)}/{$\1}/g"
35-
3627

3728
class Template {
3829

@@ -48,7 +39,7 @@ class Template {
4839

4940
// Templates prefilter from external sources (plugins)
5041
var $external_filters = array();
51-
42+
5243
// used by html_head smarty block to add content before </head>
5344
var $html_head_elements = array();
5445

@@ -78,7 +69,10 @@ function Template($root = ".", $theme= "", $path = "template")
7869
}
7970

8071
$this->smarty->template_dir = array();
81-
$this->set_theme($root, $theme, $path);
72+
if ( !empty($theme) )
73+
$this->set_theme($root, $theme, $path);
74+
else
75+
$this->set_template_dir($root);
8276

8377
$this->smarty->assign('lang_info', $lang_info);
8478

@@ -103,10 +97,10 @@ function set_theme($root, $theme, $path)
10397
$this->set_theme($root, $themeconf['parent'], $path);
10498
}
10599

106-
$tpl_var = array('name' => $themeconf['theme']);
107-
if (file_exists($root.'/'.$theme.'/local_head.tpl'))
100+
$tpl_var = array('name' => $themeconf['name']);
101+
if (!empty($themeconf['local_head']) )
108102
{
109-
$tpl_var['local_head'] = realpath($root.'/'.$theme.'/local_head.tpl');
103+
$tpl_var['local_head'] = realpath($root.'/'.$theme.'/'.$themeconf['local_head'] );
110104
}
111105
$this->smarty->append('themes', $tpl_var);
112106
$this->smarty->append('themeconf', $themeconf, true);
@@ -468,7 +462,7 @@ function set_outputfilter($handle, $callback, $weight=50)
468462
$this->external_filters[$handle][$weight][] = array('outputfilter', $callback);
469463
ksort($this->external_filters[$handle]);
470464
}
471-
465+
472466
/**
473467
* This function actually triggers the filters on the tpl files.
474468
* Called in the parse method.
@@ -479,9 +473,9 @@ function load_external_filters($handle)
479473
if (isset($this->external_filters[$handle]))
480474
{
481475
$compile_id = '';
482-
foreach ($this->external_filters[$handle] as $filters)
476+
foreach ($this->external_filters[$handle] as $filters)
483477
{
484-
foreach ($filters as $filter)
478+
foreach ($filters as $filter)
485479
{
486480
list($type, $callback) = $filter;
487481
$compile_id .= $type.( is_array($callback) ? implode('', $callback) : $callback );
@@ -496,9 +490,9 @@ function unload_external_filters($handle)
496490
{
497491
if (isset($this->external_filters[$handle]))
498492
{
499-
foreach ($this->external_filters[$handle] as $filters)
493+
foreach ($this->external_filters[$handle] as $filters)
500494
{
501-
foreach ($filters as $filter)
495+
foreach ($filters as $filter)
502496
{
503497
list($type, $callback) = $filter;
504498
call_user_func(array($this->smarty, 'unregister_'.$type), $callback);

themes/Sylvia/themeconf.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
$themeconf = array(
3-
'theme' => 'Sylvia',
3+
'name' => 'Sylvia',
44
'parent' => 'default',
55
'icon_dir' => 'themes/Sylvia/icon',
66
'mime_icon_dir' => 'themes/Sylvia/icon/mimetypes/',

themes/clear/themeconf.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
$themeconf = array(
3-
'theme' => 'clear',
3+
'name' => 'clear',
44
'parent' => 'default',
55
);
66
?>

themes/dark/themeconf.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
$themeconf = array(
3-
'theme' => 'dark',
3+
'name' => 'dark',
44
'parent' => 'default',
55
);
66
?>

themes/default/themeconf.inc.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22
$themeconf = array(
3-
'theme' => 'default',
3+
'name' => 'default',
44
'icon_dir' => 'themes/default/icon',
55
'mime_icon_dir' => 'themes/default/icon/mimetypes/',
6+
'local_head' => 'local_head.tpl',
67
);
78
?>

0 commit comments

Comments
 (0)