- changes to template to accomodate nbm (solved issue when we had same template filename with different root dirs)

- started some changes in mail templates

git-svn-id: http://piwigo.org/svn/trunk@2278 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2008-03-13 01:43:45 +00:00
commit a6437b81e6
12 changed files with 132 additions and 117 deletions

View file

@ -106,8 +106,7 @@ DELETE
} }
case 'compiled-templates' : case 'compiled-templates' :
{ {
$template->smarty->clear_compiled_tpl(); $template->delete_compiled_templates();
file_put_contents($template->smarty->compile_dir.'/index.htm', '');
break; break;
} }
default : default :

View file

@ -170,14 +170,12 @@ function get_array_template_theme($args = array())
* o template: template to use [default get_default_template()] * o template: template to use [default get_default_template()]
* o theme: 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); $args = get_array_template_theme($args);
$mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$args['template'], $args['theme']); $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->set_template_dir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format);
$mail_template->smarty->template_dir = PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format;
return $mail_template; return $mail_template;
} }
@ -475,7 +473,7 @@ WHERE
$mail_template->set_filename($tpl_shortname, $mail_template->set_filename($tpl_shortname,
(empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl'); (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
$mail_template->assign_vars( $mail_template->assign(
trigger_event('mail_group_assign_vars', $assign_vars)); trigger_event('mail_group_assign_vars', $assign_vars));
$return = pwg_mail $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_header', 'header.tpl');
$mail_template->set_filename('mail_footer', 'footer.tpl'); $mail_template->set_filename('mail_footer', 'footer.tpl');
$mail_template->assign_vars( $mail_template->assign(
array( array(
//Header //Header
'BOUNDARY_KEY' => $conf_mail['boundary_key'], 'BOUNDARY_KEY' => $conf_mail['boundary_key'],
@ -654,29 +652,27 @@ function pwg_mail($to, $args = array())
if ($args['email_format'] == 'text/html') if ($args['email_format'] == 'text/html')
{ {
$old_root = $mail_template->root; if (is_file($mail_template->get_template_dir().'/global-mail-css.tpl'))
if (is_file($mail_template->root.'/global-mail-css.tpl'))
{ {
$mail_template->set_filename('global_mail_css', 'global-mail-css.tpl'); $mail_template->set_filename('css', 'global-mail-css.tpl');
$mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'global_mail_css'); $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');
} }
$mail_template->root = PHPWG_ROOT_PATH.'template/'.$args['template'].'/theme/'.$args['theme']; $root_abs_path = dirname(dirname(__FILE__));
if (is_file($mail_template->root.'/mail-css.tpl'))
$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->set_filename('css', $file);
$mail_template->assign_var_from_handle('MAIL_CSS', 'mail_css'); $mail_template->assign_var_from_handle('MAIL_CSS', 'css');
} }
$mail_template->root = PHPWG_ROOT_PATH.'template-common'; $file = $root_abs_path.'/template-common/local-mail-css.tpl';
if (is_file($mail_template->root.'/local-mail-css.tpl')) if (is_file($file))
{ {
$mail_template->set_filename('local_mail_css', 'local-mail-css.tpl'); $mail_template->set_filename('css', $file);
$mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'local_mail_css'); $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'css');
} }
$mail_template->root = $old_root;
} }
// what are displayed on the header of each mail ? // what are displayed on the header of each mail ?
@ -770,12 +766,13 @@ function pwg_send_mail($result, $to, $subject, $content, $headers)
} }
} }
/*Testing block /*Testing block*/
function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args) /*function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
{ {
global $user, $lang_info; global $conf, $user, $lang_info;
@mkdir(PHPWG_ROOT_PATH.'testmail'); $dir = $conf['local_data_dir'].'/tmp';
$filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme']; @mkdir( $dir );
$filename = $dir.'/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
if ($args['content_format'] == 'text/plain') if ($args['content_format'] == 'text/plain')
{ {
$filename .= '.txt'; $filename .= '.txt';
@ -785,14 +782,14 @@ function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
$filename .= '.html'; $filename .= '.html';
} }
$file = fopen($filename, 'w+'); $file = fopen($filename, 'w+');
fwrite($file, $to); fwrite($file, $to ."\n");
fwrite($file, $subject); fwrite($file, $subject ."\n");
fwrite($file, $headers); fwrite($file, $headers);
fwrite($file, $content); fwrite($file, $content);
fclose($file); 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); add_event_handler('send_mail', 'pwg_send_mail', EVENT_HANDLER_PRIORITY_NEUTRAL, 5);

View file

@ -78,7 +78,6 @@ class Template {
$this->smarty->compile_dir = $compile_dir; $this->smarty->compile_dir = $compile_dir;
$this->smarty->template_dir = $root;
$this->smarty->register_function( 'lang', array('Template', 'fn_l10n') ); $this->smarty->register_function( 'lang', array('Template', 'fn_l10n') );
$this->smarty->assign_by_ref( 'pwg', new PwgTemplateAdapter() ); $this->smarty->assign_by_ref( 'pwg', new PwgTemplateAdapter() );
@ -91,6 +90,41 @@ class Template {
} }
$this->_old = & new TemplateOld($root, $theme); $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 */ /** DEPRECATED */

27
nbm.php
View file

@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery | // | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | // | 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$ // | file : $Id$
// | last update : $Date$ // | last update : $Date$
@ -72,28 +72,15 @@ include(PHPWG_ROOT_PATH.'include/page_header.php');
$template->set_filenames(array('nbm'=>'nbm.tpl')); $template->set_filenames(array('nbm'=>'nbm.tpl'));
$template->assign_vars(array('U_HOME' => make_index_url()));
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | errors & infos | // | errors & infos |
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
if (count($page['errors']) != 0) $template->assign(
{ array(
$template->assign_block_vars('errors',array()); 'errors' => $page['errors'],
foreach ($page['errors'] as $error) 'infos' => $page['infos'],
{ )
$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));
}
}
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | html code display | // | html code display |

View file

@ -1,9 +1,9 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
<div id="cat_group_info"> <div id="cat_group_info">
<h2>{lang:Informations}</h2> <h2>{'Informations'|@translate}</h2>
<p>{IMG_URL}</p> <p>{$IMG_URL}</p>
<p>{lang:Hello,}</p> <p>{'Hello,'|@translate}</p>
<p>{lang:Come to discover the category:} <a href="{LINK}">{CAT_NAME}</a></p> <p>{'Come to discover the category:'|@translate} <a href="{$LINK}">{$CAT_NAME}</a></p>
<p>{CPL_CONTENT}</p> <p>{$CPL_CONTENT}</p>
<p>{lang:See you soon.}</p> <p>{'See you soon.'|@translate}</p>
</div> </div>

View file

@ -1,17 +1,17 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
</div> <!-- content --> </div> <!-- content -->
<div id="copyright"> <div id="copyright">
<HR> <hr/>
<!-- Please, do not remove this copyright. If you really want to, {* Please, do not remove this copyright. If you really want to,
contact us on http://phpwebgallery.net to find a solution on how contact us on http://phpwebgallery.net to find a solution on how
to show the origin of the script...--> to show the origin of the script...*}
{lang:powered_by} {'powered_by'|@translate}
<a href="http://www.phpwebgallery.net" class="PWG"> <a href="http://www.phpwebgallery.net" class="PWG">
<span class="P">Php</span><span class="W">Web</span><span class="G">Gallery</span></a> <span class="P">Php</span><span class="W">Web</span><span class="G">Gallery</span></a>
{VERSION} {$VERSION}
- {lang:send_mail} - {'send_mail'|@translate}
<a href="mailto:{MAIL}?subject={TITLE_MAIL}">{lang:Webmaster}</a> <a href="mailto:{$MAIL}?subject={$TITLE_MAIL}">{'Webmaster'|@translate}</a>
</div> <!-- copyright --> </div> <!-- copyright -->
</div> <!-- the_page --> </div> <!-- the_page -->

View file

@ -1,19 +1,18 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
/* $Id$ */
/* Global mail css */ /* Global mail css */
/* Including like css style on HTML mail */ /* Including like css style on HTML mail */
body{background-color:#fff;font-family: Univers, Helvetica, Optima;font-size:12px; margin:0px;padding:0px; color:#369;} body {ldelim}background-color:#fff;font-family: Univers, Helvetica, Optima;font-size:12px; margin:0px;padding:0px; color:#369;}
#the_page {background: #fff url({pwg_root}template/{themeconf:template}/mail/text/html/images/mailbody-bg.png) repeat-y scroll left top; #the_page {ldelim}background: #fff url({$ROOT_URL}template/{$themeconf.template}/mail/text/html/images/mailbody-bg.png) repeat-y scroll left top;
margin:0px;padding:0px;text-align: left;} margin:0px;padding:0px;text-align: left;}
#content {background: transparent url({pwg_root}template/{themeconf:template}/mail/text/html/images/header-bg.png) no-repeat scroll left top; #content {ldelim}background: transparent url({$ROOT_URL}template/{$themeconf.template}/mail/text/html/images/header-bg.png) no-repeat scroll left top;
margin:0px;padding:82px 0px 0px 62px; width:732px;} margin:0px;padding:82px 0px 0px 62px; width:732px;}
hr {width:632px;margin-left:0px;} hr {ldelim}width:632px;margin-left:0px;}
#copyright {background: transparent url({pwg_root}template/{themeconf:template}/mail/text/html/images/footer-bg.png) no-repeat scroll left bottom; #copyright {ldelim}background: transparent url({$ROOT_URL}template/{$themeconf.template}/mail/text/html/images/footer-bg.png) no-repeat scroll left bottom;
color: #69c;font-size:10px;margin:0px;padding:98px 0px 62px 62px;} color: #69c;font-size:10px;margin:0px;padding:98px 0px 62px 62px;}
.PWG {font-family: verdana, sans-serif !important; font-size: 0.9em; font-weight: normal; letter-spacing: 0px;} .PWG {ldelim}font-family: verdana, sans-serif !important; font-size: 0.9em; font-weight: normal; letter-spacing: 0px;}
h2 { background-color:#ddd;padding: 7px 15px; width:617px;font-weight:bold;} h2 {ldelim}background-color:#ddd;padding: 7px 15px; width:617px;font-weight:bold;}
img { margin: 16px; border: 16px solid #aaa; -moz-border-radius: 4px; border-radius: 4px 4px; } img {ldelim}margin: 16px; border: 16px solid #aaa; -moz-border-radius: 4px; border-radius: 4px 4px; }
img:hover { padding: 15px; border: 1px solid yellow; -moz-border-radius: 4px; border-radius: 4px 4px; } img:hover {ldelim}padding: 15px; border: 1px solid yellow; -moz-border-radius: 4px; border-radius: 4px 4px; }
a { color: #005e89; background: transparent; } a {ldelim}color: #005e89; background: transparent; }
a:hover { color: #858460; text-decoration: none;} a:hover {ldelim}color: #858460; text-decoration: none;}

View file

@ -1,17 +1,17 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
-----={BOUNDARY_KEY} -----={$BOUNDARY_KEY}
Content-Type: {CONTENT_TYPE}; charset="{CONTENT_ENCODING}"; Content-Type: {$CONTENT_TYPE}; charset="{$CONTENT_ENCODING}";
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="{LANG}" dir="{DIR}"> <html lang="{$LANG}" dir="{$DIR}">
<head> <head>
<title>PhpWebGallery Mail</title> <title>PhpWebGallery Mail</title>
<meta http-equiv="Content-Type" content="text/html; charset={CONTENT_ENCODING}"> <meta http-equiv="Content-Type" content="text/html; charset={$CONTENT_ENCODING}">
<style><!-- /* Mini style for mails */ <style><!-- /* Mini style for mails */
{GLOBAL_MAIL_CSS} {if isset($GLOBAL_MAIL_CSS)}{$GLOBAL_MAIL_CSS}{/if}
{MAIL_CSS} {if isset($MAIL_CSS)}{$MAIL_CSS}{/if}
{LOCAL_MAIL_CSS} {if isset($LOCAL_MAIL_CSS)}{$LOCAL_MAIL_CSS}{/if}
--></style> --></style>
</head> </head>
<body> <body>

View file

@ -1,9 +1,9 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
{lang:Hello,} {'Hello,'|@translate}
{lang:Come to discover the category:} {CAT_NAME} {'Come to discover the category:'|@translate} {$CAT_NAME}
{LINK} {$LINK}
{CPL_CONTENT} {$CPL_CONTENT}
{lang:See you soon.} {'See you soon.'|@translate}

View file

@ -1,4 +1,4 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
------------------------ ------------------------
PhpWebGallery {VERSION} PhpWebGallery {$VERSION}

View file

@ -1,4 +1,4 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
-----={BOUNDARY_KEY} -----={$BOUNDARY_KEY}
Content-Type: {CONTENT_TYPE}; charset="{CONTENT_ENCODING}"; Content-Type: {$CONTENT_TYPE}; charset="{$CONTENT_ENCODING}";
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit

View file

@ -1,32 +1,31 @@
<!-- DEV TAG: not smarty migrated --> {* $Id$ *}
<!-- $Id$ -->
<div id="content"> <div id="content">
<div class="titrePage"> <div class="titrePage">
<ul class="categoryActions"> <ul class="categoryActions">
<li><a href="{U_HOME}" title="{lang:Go through the gallery as a visitor}"><img src="{themeconf:icon_dir}/home.png" class="button" alt="{lang:home}"/></a></li> <li><a href="{$U_HOME}" title="{'Go through the gallery as a visitor'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'home'|@translate}"/></a></li>
</ul> </ul>
<h2>{lang:nbm_item_notification}</h2> <h2>{'nbm_item_notification'|@translate}</h2>
</div> </div>
<!-- BEGIN errors --> {if not empty($errors)}
<div class="errors"> <div class="errors">
<ul> <ul>
<!-- BEGIN error --> {foreach from=$errors item=error}
<li>{errors.error.ERROR}</li> <li>{$error}</li>
<!-- END error --> {/foreach}
</ul> </ul>
</div> </div>
<!-- END errors --> {/if}
<!-- BEGIN infos --> {if not empty($infos)}
<div class="infos"> <div class="infos">
<ul> <ul>
<!-- BEGIN info --> {foreach from=$infos item=info}
<li>{infos.info.INFO}</li> <li>{$info}</li>
<!-- END info --> {/foreach}
</ul> </ul>
</div> </div>
<!-- END infos --> {/if}
</div> </div>