/[drupal]/contributions/theme-engines/smarty/smarty.engine
ViewVC logotype

Diff of /contributions/theme-engines/smarty/smarty.engine

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.15, Fri Oct 19 17:44:34 2007 UTC revision 1.16, Sat Oct 20 04:15:24 2007 UTC
# Line 154  function &_smarty_get_object() { Line 154  function &_smarty_get_object() {
154      $smarty->compile_dir  = variable_get('smarty_compile_dir', drupal_get_path('theme_engine', 'smarty').'/templates_c');      $smarty->compile_dir  = variable_get('smarty_compile_dir', drupal_get_path('theme_engine', 'smarty').'/templates_c');
155      $smarty->compile_check = variable_get('smarty_compile_check', TRUE);      $smarty->compile_check = variable_get('smarty_compile_check', TRUE);
156      $smarty->config_dir   = path_to_theme().'/configs';      $smarty->config_dir   = path_to_theme().'/configs';
157      $smarty->plugins_dir  = array(drupal_get_path('theme_engine', 'smarty') . '/libs/plugins', drupal_get_path('theme_engine', 'smarty').'/plugins', path_to_theme().'/plugins'); // TODO add theme directory      // allow overloading of plugin file so look in the lowest level first
158        $smarty->plugins_dir  = array(
159          path_to_theme().'/plugins',
160          drupal_get_path('theme_engine', 'smarty').'/plugins',
161          drupal_get_path('theme_engine', 'smarty') . '/libs/plugins',
162          );
163    
164      // build list of standard plugins      // build list of standard plugins
165      $plugins = array(      $plugins = array(
166        'functions' => array(        'functions' => array(
167          'theme'       => 'smartyPlugin_function_theme',          'drupal'      => '_smarty_plugin_function_drupal',
168          'theme_links' => 'smartyPlugin_function_theme_links',          'global'      => '_smarty_plugin_function_global',
         'global'      => 'smartyPlugin_function_global',  
         'l'           => 'smartyPlugin_function_l',  
         't'           => 'smartyPlugin_function_t',  
         'url'         => 'smartyPlugin_function_url',  
         'variable_get'=> 'smartyPlugin_function_get',  
169        ),        ),
170        'modifiers' => array(        'modifiers' => array(
171          't'           => 'smartyPlugin_modifier_t',          't'           => 'smartyPlugin_modifier_t',
# Line 201  function &_smarty_get_object() { Line 201  function &_smarty_get_object() {
201   * Smarty plugins to implement calls to the equivalent drupal functions within   * Smarty plugins to implement calls to the equivalent drupal functions within
202   * Smarty templates.   * Smarty templates.
203   */   */
 function smartyPlugin_function_l($params) {  
   return call_user_func_array('l', $params);  
 }  
 function smartyPlugin_function_t($params) {  
   return call_user_func_array('t', $params);  
 }  
 function smartyPlugin_function_url($params) {  
   return call_user_func_array('url', $params);  
 }  
 function smartyPlugin_function_variable_get($params) {  
   return call_user_func_array('variable_get', $params);  
 }  
204  function smartyPlugin_modifier_t($params) {  function smartyPlugin_modifier_t($params) {
205    return call_user_func_array('t', $params);    return call_user_func_array('t', $params);
206  }  }
207    
208  /**  /**
209   * @function smartyPlugin_function_theme   * @function smartyPlugin_function_drupal
210   *   *
211   * Smarty plugin to implement a call to the Drupal theme() function within a   * Smarty plugin to implement a call to the Drupal theme() function within a
212   * Smarty template.   * Smarty template.
213   */   */
214  function smartyPlugin_function_theme($params, &$smarty) {  function _smarty_plugin_function_drupal($params, &$smarty) {
215    $function = array_shift($params);    // TODO move the declarations into _smarty_init_plugins or whatever
216    if ($func = theme_get_function($function)) {    $callback_functions = array(
217          'links'       => '_smarty_drupal_callback_links',
218        );
219      $array_callback_functions = array(
220          'theme'       => 1,
221          't'           => 1,
222          'l'           => 1,
223          'url'         => 1,
224          'variable_get'=> 1,
225          'format_date' => 1,
226        );
227      $function = key($params);
228      if ( isset($callback_functions[$function]) ) {
229        if ( $callback_functions[$function]===1 ) {
230          $func = $function;
231        } else {
232          $func = $callback_functions[$function];
233        }
234        return call_user_func($func, $params);
235      }
236      if ( isset($array_callback_functions[$function]) ) {
237        if ( $array_callback_functions[$function]===1 ) {
238          $func = $function;
239        } else {
240          $func = $array_callback_functions[$function];
241        }
242      return call_user_func_array($func, $params);      return call_user_func_array($func, $params);
243    }    }
244  }  }
# Line 235  function smartyPlugin_function_theme($pa Line 248  function smartyPlugin_function_theme($pa
248   *   *
249   * Smarty plugin to return themed HTML for links.   * Smarty plugin to return themed HTML for links.
250   */   */
251  function smartyPlugin_function_theme_links($params, &$smarty) {  function _smarty_drupal_callback_links($params) {
252    if ( isset($params['links']) ) {    if ( isset($params['links']) ) {
253      if ( !isset($params['class']) ) {      if ( !isset($params['class']) ) {
254        $params['class'] = 'links';        $params['class'] = 'links';
# Line 245  function smartyPlugin_function_theme_lin Line 258  function smartyPlugin_function_theme_lin
258      } else {      } else {
259        $attribs = array('class' =>$params['class']);        $attribs = array('class' =>$params['class']);
260      }      }
     // $params['links'] is now a pointer to the variable containing the links  
261      return theme('links', $params['links'], $attribs);      return theme('links', $params['links'], $attribs);
262    } else {    } else {
263      return '';      return '';
# Line 257  function smartyPlugin_function_theme_lin Line 269  function smartyPlugin_function_theme_lin
269   *   *
270   * Smarty plugin to implement global template variables.   * Smarty plugin to implement global template variables.
271   */   */
272  function smartyPlugin_function_global($params, &$smarty) {  function _smarty_plugin_function_global($params, &$smarty) {
273    if ( isset($params['var']) ) {    if ( isset($params['var']) ) {
274      if ( isset($params['value']) ) {      if ( isset($params['value']) ) {
275        $smarty->_tpl_vars['globals'][$params['var']] = $params['value'];        $smarty->_tpl_vars['globals'][$params['var']] = $params['value'];

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.2