Changeset 2278


Ignore:
Timestamp:
Mar 13, 2008, 2:43:45 AM (16 years ago)
Author:
rvelices
Message:
  • changes to template to accomodate nbm (solved issue when we had same template filename with different root dirs)
  • started some changes in mail templates
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/maintenance.php

    r2251 r2278  
    107107  case 'compiled-templates' :
    108108  {
    109     $template->smarty->clear_compiled_tpl();
    110     file_put_contents($template->smarty->compile_dir.'/index.htm', '');
     109    $template->delete_compiled_templates();
    111110    break;
    112111  }
  • trunk/include/functions_mail.inc.php

    r2262 r2278  
    171171 *       o theme: template to use [default get_default_template()]
    172172 */
    173 function get_mail_template($email_format, $args = array())
     173function & get_mail_template($email_format, $args = array())
    174174{
    175175  $args = get_array_template_theme($args);
    176176
    177177  $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$args['template'], $args['theme']);
    178   $mail_template->_old->set_rootdir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format);
    179   $mail_template->smarty->template_dir = PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format;
    180  
     178  $mail_template->set_template_dir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format);
    181179  return $mail_template;
    182180}
     
    298296{
    299297  // Check arguments
    300   if 
     298  if
    301299    (
    302300      empty($keyargs_subject) or
     
    392390{
    393391  // Check arguments
    394   if 
     392  if
    395393    (
    396394      empty($group_id) or
     
    476474            (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
    477475
    478           $mail_template->assign_vars(
     476          $mail_template->assign(
    479477            trigger_event('mail_group_assign_vars', $assign_vars));
    480478
     
    630628    $mail_template->set_filename('mail_footer', 'footer.tpl');
    631629
    632     $mail_template->assign_vars(
     630    $mail_template->assign(
    633631      array(
    634632        //Header
     
    655653    if ($args['email_format'] == 'text/html')
    656654    {
    657       $old_root = $mail_template->root;
    658 
    659       if (is_file($mail_template->root.'/global-mail-css.tpl'))
     655      if (is_file($mail_template->get_template_dir().'/global-mail-css.tpl'))
    660656      {
    661         $mail_template->set_filename('global_mail_css', 'global-mail-css.tpl');
    662         $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'global_mail_css');
     657        $mail_template->set_filename('css', 'global-mail-css.tpl');
     658        $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');
    663659      }
    664660
    665       $mail_template->root = PHPWG_ROOT_PATH.'template/'.$args['template'].'/theme/'.$args['theme'];
    666       if (is_file($mail_template->root.'/mail-css.tpl'))
     661      $root_abs_path = dirname(dirname(__FILE__));
     662
     663      $file = $root_abs_path.'/template/'.$args['template'].'/theme/'.$args['theme'].'/mail-css.tpl';
     664      if (is_file($file))
    667665      {
    668         $mail_template->set_filename('mail_css', 'mail-css.tpl');
    669         $mail_template->assign_var_from_handle('MAIL_CSS', 'mail_css');
     666        $mail_template->set_filename('css', $file);
     667        $mail_template->assign_var_from_handle('MAIL_CSS', 'css');
    670668      }
    671669
    672       $mail_template->root = PHPWG_ROOT_PATH.'template-common';
    673       if (is_file($mail_template->root.'/local-mail-css.tpl'))
     670      $file = $root_abs_path.'/template-common/local-mail-css.tpl';
     671      if (is_file($file))
    674672      {
    675         $mail_template->set_filename('local_mail_css', 'local-mail-css.tpl');
    676         $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'local_mail_css');
     673        $mail_template->set_filename('css', $file);
     674        $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'css');
    677675      }
    678 
    679       $mail_template->root = $old_root;
    680676    }
    681677
     
    771767}
    772768
    773 /*Testing block
    774 function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
    775 {
    776     global $user, $lang_info;
    777     @mkdir(PHPWG_ROOT_PATH.'testmail');
    778     $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
     769/*Testing block*/
     770/*function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
     771{
     772    global $conf, $user, $lang_info;
     773    $dir = $conf['local_data_dir'].'/tmp';
     774    @mkdir( $dir );
     775    $filename = $dir.'/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
    779776    if ($args['content_format'] == 'text/plain')
    780777    {
     
    786783    }
    787784    $file = fopen($filename, 'w+');
    788     fwrite($file, $to);
    789     fwrite($file, $subject);
     785    fwrite($file, $to ."\n");
     786    fwrite($file, $subject ."\n");
    790787    fwrite($file, $headers);
    791788    fwrite($file, $content);
    792789    fclose($file);
    793     return true;
    794 }
    795 add_event_handler('send_mail', 'pwg_send_mail_test', 0, 6);*/
     790    return $result;
     791}
     792add_event_handler('send_mail', 'pwg_send_mail_test', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 6);*/
    796793
    797794
  • trunk/include/template.class.php

    r2254 r2278  
    7979    $this->smarty->compile_dir = $compile_dir;
    8080
    81     $this->smarty->template_dir = $root;
    8281    $this->smarty->register_function( 'lang', array('Template', 'fn_l10n') );
    8382
     
    9291
    9392    $this->_old = & new TemplateOld($root, $theme);
     93
     94    $this->set_template_dir($root);
     95  }
     96
     97  /**
     98   * Sets the template root directory for this Template object.
     99   */
     100  function set_template_dir($dir)
     101  {
     102    $this->_old->set_rootdir($dir);
     103    $this->smarty->template_dir = $dir;
     104
     105    $real_dir = realpath($dir);
     106    $compile_id = crc32( $real_dir===false ? $dir : $real_dir);
     107    $this->smarty->compile_id = sprintf('%08X', $compile_id );
     108  }
     109
     110  /**
     111   * Gets the template root directory for this Template object.
     112   */
     113  function get_template_dir()
     114  {
     115    return $this->smarty->template_dir;
     116  }
     117
     118  /**
     119   * Deletes all compiled templates.
     120   */
     121  function delete_compiled_templates()
     122  {
     123      $save_compile_id = $this->smarty->compile_id;
     124      $this->smarty->compile_id = null;
     125      $this->smarty->clear_compiled_tpl();
     126      $this->smarty->compile_id = $save_compile_id;
     127      file_put_contents($this->smarty->compile_dir.'/index.htm', '');
    94128  }
    95129
  • trunk/nbm.php

    r2126 r2278  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | file          : $Id$
     
    7373$template->set_filenames(array('nbm'=>'nbm.tpl'));
    7474
    75 $template->assign_vars(array('U_HOME' => make_index_url()));
    76 
    7775// +-----------------------------------------------------------------------+
    7876// | errors & infos                                                        |
    7977// +-----------------------------------------------------------------------+
    80 if (count($page['errors']) != 0)
    81 {
    82   $template->assign_block_vars('errors',array());
    83   foreach ($page['errors'] as $error)
    84   {
    85     $template->assign_block_vars('errors.error',array('ERROR'=>$error));
    86   }
    87 }
    88 
    89 if (count($page['infos']) != 0)
    90 {
    91   $template->assign_block_vars('infos',array());
    92   foreach ($page['infos'] as $info)
    93   {
    94     $template->assign_block_vars('infos.info',array('INFO'=>$info));
    95   }
    96 }
     78$template->assign(
     79    array(
     80      'errors' => $page['errors'],
     81      'infos' => $page['infos'],
     82    )
     83  );
    9784
    9885// +-----------------------------------------------------------------------+
  • trunk/template/yoga/mail/text/html/admin/cat_group_info.tpl

    r2222 r2278  
    1 <!-- DEV TAG: not smarty migrated -->
     1{* $Id$ *}
    22<div id="cat_group_info">
    3 <h2>{lang:Informations}</h2>
    4 <p>{IMG_URL}</p>
    5 <p>{lang:Hello,}</p>
    6 <p>{lang:Come to discover the category:} <a href="{LINK}">{CAT_NAME}</a></p>
    7 <p>{CPL_CONTENT}</p>
    8 <p>{lang:See you soon.}</p>
     3<h2>{'Informations'|@translate}</h2>
     4<p>{$IMG_URL}</p>
     5<p>{'Hello,'|@translate}</p>
     6<p>{'Come to discover the category:'|@translate} <a href="{$LINK}">{$CAT_NAME}</a></p>
     7<p>{$CPL_CONTENT}</p>
     8<p>{'See you soon.'|@translate}</p>
    99</div>
  • trunk/template/yoga/mail/text/html/footer.tpl

    r2222 r2278  
    1 <!-- DEV TAG: not smarty migrated -->
     1{* $Id$ *}
    22</div> <!-- content -->
    33<div id="copyright">
    4 <HR>
    5  <!-- Please, do not remove this copyright. If you really want to,
     4<hr/>
     5 {* Please, do not remove this copyright. If you really want to,
    66      contact us on http://phpwebgallery.net to find a solution on how
    7       to show the origin of the script...-->
     7      to show the origin of the script...*}
    88
    9   {lang:powered_by}
     9  {'powered_by'|@translate}
    1010  <a href="http://www.phpwebgallery.net" class="PWG">
    1111  <span class="P">Php</span><span class="W">Web</span><span class="G">Gallery</span></a>
    12   {VERSION}
    13   - {lang:send_mail}
    14   <a href="mailto:{MAIL}?subject={TITLE_MAIL}">{lang:Webmaster}</a>
     12  {$VERSION}
     13  - {'send_mail'|@translate}
     14  <a href="mailto:{$MAIL}?subject={$TITLE_MAIL}">{'Webmaster'|@translate}</a>
    1515
    1616</div> <!-- copyright -->
  • trunk/template/yoga/mail/text/html/global-mail-css.tpl

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

    r2222 r2278  
    1 <!-- DEV TAG: not smarty migrated -->
    2 -----={BOUNDARY_KEY}
    3 Content-Type: {CONTENT_TYPE}; charset="{CONTENT_ENCODING}";
     1{* $Id$ *}
     2-----={$BOUNDARY_KEY}
     3Content-Type: {$CONTENT_TYPE}; charset="{$CONTENT_ENCODING}";
    44Content-Transfer-Encoding: 8bit
    55
    66<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    7 <html lang="{LANG}" dir="{DIR}">
     7<html lang="{$LANG}" dir="{$DIR}">
    88<head>
    99<title>PhpWebGallery Mail</title>
    10 <meta http-equiv="Content-Type" content="text/html; charset={CONTENT_ENCODING}">
     10<meta http-equiv="Content-Type" content="text/html; charset={$CONTENT_ENCODING}">
    1111<style><!-- /* Mini style for mails */
    12 {GLOBAL_MAIL_CSS}
    13 {MAIL_CSS}
    14 {LOCAL_MAIL_CSS}
     12{if isset($GLOBAL_MAIL_CSS)}{$GLOBAL_MAIL_CSS}{/if}
     13{if isset($MAIL_CSS)}{$MAIL_CSS}{/if}
     14{if isset($LOCAL_MAIL_CSS)}{$LOCAL_MAIL_CSS}{/if}
    1515--></style>
    1616</head>
  • trunk/template/yoga/mail/text/plain/admin/cat_group_info.tpl

    r2222 r2278  
    1 <!-- DEV TAG: not smarty migrated -->
    2 {lang:Hello,}
     1{* $Id$ *}
     2{'Hello,'|@translate}
    33
    4 {lang:Come to discover the category:} {CAT_NAME}
    5 {LINK}
     4{'Come to discover the category:'|@translate} {$CAT_NAME}
     5{$LINK}
    66
    7 {CPL_CONTENT}
     7{$CPL_CONTENT}
    88
    9 {lang:See you soon.}
     9{'See you soon.'|@translate}
  • trunk/template/yoga/mail/text/plain/footer.tpl

    r2222 r2278  
    1 <!-- DEV TAG: not smarty migrated -->
     1{* $Id$ *}
    22
    33------------------------
    4 PhpWebGallery {VERSION}
     4PhpWebGallery {$VERSION}
  • trunk/template/yoga/mail/text/plain/header.tpl

    r2222 r2278  
    1 <!-- DEV TAG: not smarty migrated -->
    2 -----={BOUNDARY_KEY}
    3 Content-Type: {CONTENT_TYPE}; charset="{CONTENT_ENCODING}";
     1{* $Id$ *}
     2-----={$BOUNDARY_KEY}
     3Content-Type: {$CONTENT_TYPE}; charset="{$CONTENT_ENCODING}";
    44Content-Transfer-Encoding: 8bit
  • trunk/template/yoga/nbm.tpl

    r2222 r2278  
    1 <!-- DEV TAG: not smarty migrated -->
    2 <!-- $Id$ -->
     1{* $Id$ *}
    32
    43<div id="content">
    54  <div class="titrePage">
    65    <ul class="categoryActions">
    7       <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>
     6      <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>
    87    </ul>
    9     <h2>{lang:nbm_item_notification}</h2>
     8    <h2>{'nbm_item_notification'|@translate}</h2>
    109  </div>
    1110
    12   <!-- BEGIN errors -->
     11  {if not empty($errors)}
    1312  <div class="errors">
    1413    <ul>
    15       <!-- BEGIN error -->
    16       <li>{errors.error.ERROR}</li>
    17       <!-- END error -->
     14      {foreach from=$errors item=error}
     15      <li>{$error}</li>
     16      {/foreach}
    1817    </ul>
    1918  </div>
    20   <!-- END errors -->
     19  {/if}
    2120
    22   <!-- BEGIN infos -->
     21  {if not empty($infos)}
    2322  <div class="infos">
    2423    <ul>
    25       <!-- BEGIN info -->
    26       <li>{infos.info.INFO}</li>
    27       <!-- END info -->
     24      {foreach from=$infos item=info}
     25      <li>{$info}</li>
     26      {/foreach}
    2827    </ul>
    2928  </div>
    30   <!-- END infos -->
     29  {/if}
    3130
    3231</div>
Note: See TracChangeset for help on using the changeset viewer.