2424
2525require_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
3728class 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 );
0 commit comments