-
-
-
- {errors.error.ERROR} - + {foreach from=$errors item=error} +
- {$error} + {/foreach}
-
-
-
- {infos.info.INFO} - + {foreach from=$infos item=info} +
- {$info} + {/foreach}
diff --git a/admin/maintenance.php b/admin/maintenance.php index eb71adda9..1325e4928 100644 --- a/admin/maintenance.php +++ b/admin/maintenance.php @@ -106,8 +106,7 @@ DELETE } case 'compiled-templates' : { - $template->smarty->clear_compiled_tpl(); - file_put_contents($template->smarty->compile_dir.'/index.htm', ''); + $template->delete_compiled_templates(); break; } default : diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php index 74e8f3218..dae9b4bfc 100644 --- a/include/functions_mail.inc.php +++ b/include/functions_mail.inc.php @@ -170,14 +170,12 @@ function get_array_template_theme($args = array()) * o template: template to use [default get_default_template()] * o theme: template to use [default get_default_template()] */ -function get_mail_template($email_format, $args = array()) +function & get_mail_template($email_format, $args = array()) { $args = get_array_template_theme($args); $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$args['template'], $args['theme']); - $mail_template->_old->set_rootdir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format); - $mail_template->smarty->template_dir = PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format; - + $mail_template->set_template_dir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format); return $mail_template; } @@ -297,7 +295,7 @@ function switch_lang_back() function pwg_mail_notification_admins($keyargs_subject, $keyargs_content) { // Check arguments - if + if ( empty($keyargs_subject) or empty($keyargs_content) @@ -391,7 +389,7 @@ function pwg_mail_group( $assign_vars = array(), $language_selected = '') { // Check arguments - if + if ( empty($group_id) or empty($email_format) or @@ -475,7 +473,7 @@ WHERE $mail_template->set_filename($tpl_shortname, (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl'); - $mail_template->assign_vars( + $mail_template->assign( trigger_event('mail_group_assign_vars', $assign_vars)); $return = pwg_mail @@ -629,7 +627,7 @@ function pwg_mail($to, $args = array()) $mail_template->set_filename('mail_header', 'header.tpl'); $mail_template->set_filename('mail_footer', 'footer.tpl'); - $mail_template->assign_vars( + $mail_template->assign( array( //Header 'BOUNDARY_KEY' => $conf_mail['boundary_key'], @@ -654,29 +652,27 @@ function pwg_mail($to, $args = array()) if ($args['email_format'] == 'text/html') { - $old_root = $mail_template->root; - - if (is_file($mail_template->root.'/global-mail-css.tpl')) + if (is_file($mail_template->get_template_dir().'/global-mail-css.tpl')) { - $mail_template->set_filename('global_mail_css', 'global-mail-css.tpl'); - $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'global_mail_css'); + $mail_template->set_filename('css', 'global-mail-css.tpl'); + $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css'); } - $mail_template->root = PHPWG_ROOT_PATH.'template/'.$args['template'].'/theme/'.$args['theme']; - if (is_file($mail_template->root.'/mail-css.tpl')) + $root_abs_path = dirname(dirname(__FILE__)); + + $file = $root_abs_path.'/template/'.$args['template'].'/theme/'.$args['theme'].'/mail-css.tpl'; + if (is_file($file)) { - $mail_template->set_filename('mail_css', 'mail-css.tpl'); - $mail_template->assign_var_from_handle('MAIL_CSS', 'mail_css'); + $mail_template->set_filename('css', $file); + $mail_template->assign_var_from_handle('MAIL_CSS', 'css'); } - $mail_template->root = PHPWG_ROOT_PATH.'template-common'; - if (is_file($mail_template->root.'/local-mail-css.tpl')) + $file = $root_abs_path.'/template-common/local-mail-css.tpl'; + if (is_file($file)) { - $mail_template->set_filename('local_mail_css', 'local-mail-css.tpl'); - $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'local_mail_css'); + $mail_template->set_filename('css', $file); + $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'css'); } - - $mail_template->root = $old_root; } // what are displayed on the header of each mail ? @@ -770,12 +766,13 @@ function pwg_send_mail($result, $to, $subject, $content, $headers) } } -/*Testing block -function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args) +/*Testing block*/ +/*function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args) { - global $user, $lang_info; - @mkdir(PHPWG_ROOT_PATH.'testmail'); - $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme']; + global $conf, $user, $lang_info; + $dir = $conf['local_data_dir'].'/tmp'; + @mkdir( $dir ); + $filename = $dir.'/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme']; if ($args['content_format'] == 'text/plain') { $filename .= '.txt'; @@ -785,14 +782,14 @@ function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args) $filename .= '.html'; } $file = fopen($filename, 'w+'); - fwrite($file, $to); - fwrite($file, $subject); + fwrite($file, $to ."\n"); + fwrite($file, $subject ."\n"); fwrite($file, $headers); fwrite($file, $content); fclose($file); - return true; + return $result; } -add_event_handler('send_mail', 'pwg_send_mail_test', 0, 6);*/ +add_event_handler('send_mail', 'pwg_send_mail_test', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 6);*/ add_event_handler('send_mail', 'pwg_send_mail', EVENT_HANDLER_PRIORITY_NEUTRAL, 5); diff --git a/include/template.class.php b/include/template.class.php index 77b6df5f0..f5faa7d94 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -78,7 +78,6 @@ class Template { $this->smarty->compile_dir = $compile_dir; - $this->smarty->template_dir = $root; $this->smarty->register_function( 'lang', array('Template', 'fn_l10n') ); $this->smarty->assign_by_ref( 'pwg', new PwgTemplateAdapter() ); @@ -91,6 +90,41 @@ class Template { } $this->_old = & new TemplateOld($root, $theme); + + $this->set_template_dir($root); + } + + /** + * Sets the template root directory for this Template object. + */ + function set_template_dir($dir) + { + $this->_old->set_rootdir($dir); + $this->smarty->template_dir = $dir; + + $real_dir = realpath($dir); + $compile_id = crc32( $real_dir===false ? $dir : $real_dir); + $this->smarty->compile_id = sprintf('%08X', $compile_id ); + } + + /** + * Gets the template root directory for this Template object. + */ + function get_template_dir() + { + return $this->smarty->template_dir; + } + + /** + * Deletes all compiled templates. + */ + function delete_compiled_templates() + { + $save_compile_id = $this->smarty->compile_id; + $this->smarty->compile_id = null; + $this->smarty->clear_compiled_tpl(); + $this->smarty->compile_id = $save_compile_id; + file_put_contents($this->smarty->compile_dir.'/index.htm', ''); } /** DEPRECATED */ diff --git a/nbm.php b/nbm.php index c96bbc252..b672ee724 100644 --- a/nbm.php +++ b/nbm.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | file : $Id$ // | last update : $Date$ @@ -72,32 +72,19 @@ include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames(array('nbm'=>'nbm.tpl')); -$template->assign_vars(array('U_HOME' => make_index_url())); - // +-----------------------------------------------------------------------+ // | errors & infos | // +-----------------------------------------------------------------------+ -if (count($page['errors']) != 0) -{ - $template->assign_block_vars('errors',array()); - foreach ($page['errors'] as $error) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$error)); - } -} - -if (count($page['infos']) != 0) -{ - $template->assign_block_vars('infos',array()); - foreach ($page['infos'] as $info) - { - $template->assign_block_vars('infos.info',array('INFO'=>$info)); - } -} +$template->assign( + array( + 'errors' => $page['errors'], + 'infos' => $page['infos'], + ) + ); // +-----------------------------------------------------------------------+ // | html code display | // +-----------------------------------------------------------------------+ $template->parse('nbm'); include(PHPWG_ROOT_PATH.'include/page_tail.php'); -?> \ No newline at end of file +?> diff --git a/template/yoga/mail/text/html/admin/cat_group_info.tpl b/template/yoga/mail/text/html/admin/cat_group_info.tpl index 8d744746c..2c8c45d6a 100644 --- a/template/yoga/mail/text/html/admin/cat_group_info.tpl +++ b/template/yoga/mail/text/html/admin/cat_group_info.tpl @@ -1,9 +1,9 @@ - +{* $Id$ *}
{IMG_URL}
-{lang:Hello,}
-{lang:Come to discover the category:} {CAT_NAME}
-{CPL_CONTENT}
-{lang:See you soon.}
+{$IMG_URL}
+{'Hello,'|@translate}
+{'Come to discover the category:'|@translate} {$CAT_NAME}
+{$CPL_CONTENT}
+{'See you soon.'|@translate}