mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 19:29:58 +03:00
- Add known_template function (maybe we can change function name).
- Template extensions are working with menubar blocks templates. git-svn-id: http://piwigo.org/svn/trunk@2712 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
9d88e93a99
commit
4fbe0ef666
4 changed files with 66 additions and 25 deletions
|
@ -73,29 +73,35 @@ $relevant_parameters = array_merge($relevant_parameters, $permalinks);
|
||||||
|
|
||||||
/* Link all supported templates to their respective handle */
|
/* Link all supported templates to their respective handle */
|
||||||
$eligible_templates = array(
|
$eligible_templates = array(
|
||||||
'----------' => 'N/A',
|
'----------' => 'N/A',
|
||||||
'about.tpl' => 'about',
|
'about.tpl' => 'about',
|
||||||
'identification.tpl' => 'identification',
|
'identification.tpl' => 'identification',
|
||||||
'mainpage_categories.tpl' => 'index_category_thumbnails',
|
'mainpage_categories.tpl' => 'index_category_thumbnails',
|
||||||
'thumbnails.tpl' => 'index_thumbnails',
|
'thumbnails.tpl' => 'index_thumbnails',
|
||||||
'redirect.tpl' => 'redirect',
|
'redirect.tpl' => 'redirect',
|
||||||
// 'menubar.tpl' => 'menubar', // TODO by blocks
|
'menubar.tpl' => 'menubar',
|
||||||
'header.tpl' => 'header',
|
'menubar_categories.tpl' => 'mbCategories',
|
||||||
'footer.tpl' => 'tail',
|
'menubar_identification.tpl' => 'mbIdentification',
|
||||||
'index.tpl' => 'index',
|
'menubar_links.tpl' => 'mbLinks',
|
||||||
'nbm.tpl' => 'nbm',
|
'menubar_menu.tpl' => 'mbMenu',
|
||||||
'notification.tpl' => 'notification',
|
'menubar_specials.tpl' => 'mbSpecials',
|
||||||
'picture_content.tpl' => 'default_content',
|
'menubar_tags.tpl' => 'mbTags',
|
||||||
'picture.tpl' => 'picture',
|
'header.tpl' => 'header',
|
||||||
'popuphelp.tpl' => 'popuphelp',
|
'footer.tpl' => 'tail',
|
||||||
'profile.tpl' => 'profile',
|
'index.tpl' => 'index',
|
||||||
'profile_content.tpl' => 'profile_content',
|
'nbm.tpl' => 'nbm',
|
||||||
'register.tpl' => 'register',
|
'notification.tpl' => 'notification',
|
||||||
'search.tpl' => 'search',
|
'picture_content.tpl' => 'default_content',
|
||||||
'search_rules.tpl' => 'search_rules',
|
'picture.tpl' => 'picture',
|
||||||
'slideshow.tpl' => 'slideshow',
|
'popuphelp.tpl' => 'popuphelp',
|
||||||
'tags.tpl' => 'tags',
|
'profile.tpl' => 'profile',
|
||||||
'upload.tpl' => 'upload',);
|
'profile_content.tpl' => 'profile_content',
|
||||||
|
'register.tpl' => 'register',
|
||||||
|
'search.tpl' => 'search',
|
||||||
|
'search_rules.tpl' => 'search_rules',
|
||||||
|
'slideshow.tpl' => 'slideshow',
|
||||||
|
'tags.tpl' => 'tags',
|
||||||
|
'upload.tpl' => 'upload',);
|
||||||
$flip_templates = array_flip($eligible_templates);
|
$flip_templates = array_flip($eligible_templates);
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | selected templates |
|
// | selected templates |
|
||||||
|
|
|
@ -66,6 +66,7 @@ class Template {
|
||||||
$this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
|
$this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
|
||||||
$this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
|
$this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
|
||||||
$this->smarty->register_function('known_script', array(&$this, 'func_known_script') );
|
$this->smarty->register_function('known_script', array(&$this, 'func_known_script') );
|
||||||
|
$this->smarty->register_function('known_template', array(&$this, 'func_known_template') );
|
||||||
$this->smarty->register_prefilter( array('Template', 'prefilter_white_space') );
|
$this->smarty->register_prefilter( array('Template', 'prefilter_white_space') );
|
||||||
if ( $conf['compiled_template_cache_language'] )
|
if ( $conf['compiled_template_cache_language'] )
|
||||||
{
|
{
|
||||||
|
@ -408,6 +409,34 @@ class Template {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This smarty "known_template" functions allows to include template
|
||||||
|
* If extent[$params['id']] exists, include template extension
|
||||||
|
* else include $params[$file]
|
||||||
|
*/
|
||||||
|
function func_known_template($params, &$smarty )
|
||||||
|
{
|
||||||
|
if (!isset($params['file']))
|
||||||
|
{
|
||||||
|
$smarty->trigger_error("known_template: missing 'file' parameter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['id']) and isset($this->extents[$params['id']]))
|
||||||
|
{
|
||||||
|
$file = $this->extents[$params['id']];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$file = $params['file'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $smarty->_smarty_include(array(
|
||||||
|
'smarty_include_tpl_file' => $file,
|
||||||
|
'smarty_include_vars' => array()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
static function prefilter_white_space($source, &$smarty)
|
static function prefilter_white_space($source, &$smarty)
|
||||||
{
|
{
|
||||||
$ld = $smarty->left_delimiter;
|
$ld = $smarty->left_delimiter;
|
||||||
|
|
|
@ -184,7 +184,13 @@ switch ($page['tab'])
|
||||||
'mainpage_categories.tpl',
|
'mainpage_categories.tpl',
|
||||||
'thumbnails.tpl',
|
'thumbnails.tpl',
|
||||||
'redirect.tpl',
|
'redirect.tpl',
|
||||||
// 'menubar.tpl'
|
'menubar.tpl',
|
||||||
|
'menubar_categories.tpl',
|
||||||
|
'menubar_identification.tpl',
|
||||||
|
'menubar_links.tpl',
|
||||||
|
'menubar_menu.tpl',
|
||||||
|
'menubar_specials.tpl',
|
||||||
|
'menubar_tags.tpl',
|
||||||
'header.tpl',
|
'header.tpl',
|
||||||
'footer.tpl',
|
'footer.tpl',
|
||||||
'index.tpl',
|
'index.tpl',
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{if ( not empty($block->template) or not empty($block->raw_content) )}
|
{if ( not empty($block->template) or not empty($block->raw_content) )}
|
||||||
<dl id="{$id}">
|
<dl id="{$id}">
|
||||||
{if not empty($block->template)}
|
{if not empty($block->template)}
|
||||||
{include file=$block->template }
|
{known_template id=$id file=$block->template }
|
||||||
{else}
|
{else}
|
||||||
{$block->raw_content|@default}
|
{$block->raw_content|@default}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue