Ignore:
Timestamp:
Mar 20, 2008, 1:35:36 AM (17 years ago)
Author:
rvelices
Message:
  • admin/notification_by_mail goes smarty - THE LAST ONE :-) :-)
  • get rid of user_list warnings
  • some code reorganisation in template class + explode modifier
  • minor template and language changes in search.tpl and cat_modify.tpl
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/template.class.php

    r2285 r2286  
    7979    $this->smarty->compile_dir = $compile_dir;
    8080
    81     $this->smarty->register_function( 'lang', array('Template', 'fn_l10n') );
    82 
    8381    $this->smarty->assign_by_ref( 'pwg', new PwgTemplateAdapter() );
    8482    $this->smarty->register_modifier( 'translate', array('Template', 'mod_translate') );
     83    $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
    8584
    8685    if ( !empty($theme) )
     
    128127  }
    129128
    130   /** DEPRECATED */
    131129  function get_themeconf($val)
    132130  {
     
    182180    $this->assign( $varname, $varval );
    183181  }
    184 
    185   /**
    186    * Inserts the uncompiled code for $handle as the value of $varname in the
    187    * root-level. This can be used to effectively include a template in the
    188    * middle of another template.
    189    * This is equivalent to assign($varname, $this->parse($handle, true))
    190    */
    191   function assign_var_from_handle($varname, $handle)
    192     {
    193       $this->assign($varname, $this->parse($handle, true));
    194       return true;
    195     }
    196182
    197183  /**
     
    254240  }
    255241
     242  /** see smarty assign http://www.smarty.net/manual/en/api.assign.php */
     243  function assign($tpl_var, $value = null)
     244  {
     245    $this->smarty->assign( $tpl_var, $value );
     246
     247    if ( is_array($tpl_var) )
     248      $this->_old->assign_vars( $tpl_var );
     249    else
     250      $this->_old->assign_var( $tpl_var, $value );
     251  }
     252 
     253  /**
     254   * Inserts the uncompiled code for $handle as the value of $varname in the
     255   * root-level. This can be used to effectively include a template in the
     256   * middle of another template.
     257   * This is equivalent to assign($varname, $this->parse($handle, true))
     258   */
     259  function assign_var_from_handle($varname, $handle)
     260  {
     261    $this->assign($varname, $this->parse($handle, true));
     262    return true;
     263  }
     264
     265  /** see smarty append http://www.smarty.net/manual/en/api.append.php */
     266  function append($tpl_var, $value=null, $merge=false)
     267  {
     268    $this->smarty->append( $tpl_var, $value, $merge );
     269  }
     270
     271  /**
     272   * Root-level variable concatenation. Appends a  string to an existing
     273   * variable assignment with the same name.
     274   */
     275  function concat($tpl_var, $value)
     276  {
     277    $old_val = & $this->smarty->get_template_vars($tpl_var);
     278    if ( isset($old_val) )
     279    {
     280      $old_val .= $value;
     281      $this->_old->concat_var( $tpl_var, $value );
     282    }
     283    else
     284    {
     285      $this->assign($tpl_var, $value);
     286    }
     287  }
     288
     289  /** see smarty append http://www.smarty.net/manual/en/api.clear_assign.php */
     290  function clear_assign($tpl_var)
     291  {
     292    $this->smarty->clear_assign( $tpl_var );
     293  }
     294
     295  /** see smarty get_template_vars http://www.smarty.net/manual/en/api.get_template_vars.php */
     296  function &get_template_vars($name=null)
     297  {
     298    return $this->smarty->get_template_vars( $name );
     299  }
     300
     301
    256302  /**
    257303   * Load the file for the handle, eventually compile the file and run the compiled
     
    331377
    332378  /**
    333    * Root-level variable concatenation. Appends a  string to an existing
    334    * variable assignment with the same name.
    335    */
    336   function concat_var($tpl_var, $value)
    337   {
    338     $old_val = & $this->smarty->get_template_vars($tpl_var);
    339     if ( isset($old_val) )
    340     {
    341       $old_val .= $value;
    342       $this->_old->concat_var( $tpl_var, $value );
    343     }
    344     else
    345     {
    346       $this->assign($tpl_var, $value);
    347     }
    348   }
    349 
    350   /** see smarty assign http://www.smarty.net/manual/en/api.assign.php */
    351   function assign($tpl_var, $value = null)
    352   {
    353     $this->smarty->assign( $tpl_var, $value );
    354 
    355     if ( is_array($tpl_var) )
    356       $this->_old->assign_vars( $tpl_var );
    357     else
    358       $this->_old->assign_var( $tpl_var, $value );
    359   }
    360 
    361   /** see smarty append http://www.smarty.net/manual/en/api.append.php */
    362   function append($tpl_var, $value=null, $merge=false)
    363   {
    364     $this->smarty->append( $tpl_var, $value, $merge );
    365   }
    366 
    367   /** see smarty get_template_vars http://www.smarty.net/manual/en/api.get_template_vars.php */
    368   function &get_template_vars($name=null)
    369   {
    370     return $this->smarty->get_template_vars( $name );
    371   }
    372 
    373   /** see smarty append http://www.smarty.net/manual/en/api.clear_assign.php */
    374   function clear_assign($tpl_var)
    375   {
    376     $this->smarty->clear_assign( $tpl_var );
    377   }
    378 
    379   /*static*/ function fn_l10n($params, &$smarty)
    380   {
    381     return l10n($params['t']);
    382   }
    383 
    384   /**
    385    * translate variable modifiers - translates a text to the currently loaded
     379   * translate variable modifier - translates a text to the currently loaded
    386380   * language
    387381   */
     
    389383  {
    390384    return l10n($text);
     385  }
     386
     387  /**
     388   * explode variable modifier - similar to php explode
     389   * 'Yes;No'|@explode:';' -> array('Yes', 'No')   
     390   */
     391  /*static*/ function mod_explode($text, $delimiter=',')
     392  {
     393    return explode($delimiter, $text);
    391394  }
    392395}
Note: See TracChangeset for help on using the changeset viewer.