[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/Smarty/libs/sysplugins/ -> smarty_internal_compile_private_special_variable.php (source)

   1  <?php
   2  /**
   3   * Smarty Internal Plugin Compile Special Smarty Variable
   4   *
   5   * Compiles the special $smarty variables
   6   *
   7   * @package Smarty
   8   * @subpackage Compiler
   9   * @author Uwe Tews
  10   */
  11  
  12  /**
  13   * Smarty Internal Plugin Compile special Smarty Variable Class
  14   *
  15   * @package Smarty
  16   * @subpackage Compiler
  17   */
  18  class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase {
  19  
  20      /**
  21       * Compiles code for the speical $smarty variables
  22       *
  23       * @param array  $args     array with attributes from parser
  24       * @param object $compiler compiler object
  25       * @return string compiled code
  26       */
  27      public function compile($args, $compiler, $parameter)
  28      {
  29          $_index = preg_split("/\]\[/",substr($parameter, 1, strlen($parameter)-2));
  30          $compiled_ref = ' ';
  31          $variable = trim($_index[0], "'");
  32          switch ($variable) {
  33              case 'foreach':
  34                  return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
  35              case 'section':
  36                  return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
  37              case 'capture':
  38                  return "Smarty::\$_smarty_vars$parameter";
  39              case 'now':
  40                  return 'time()';
  41              case 'cookies':
  42                  if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
  43                      $compiler->trigger_template_error("(secure mode) super globals not permitted");
  44                      break;
  45                  }
  46                  $compiled_ref = '$_COOKIE';
  47                  break;
  48  
  49              case 'get':
  50              case 'post':
  51              case 'env':
  52              case 'server':
  53              case 'session':
  54              case 'request':
  55                  if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
  56                      $compiler->trigger_template_error("(secure mode) super globals not permitted");
  57                      break;
  58                  }
  59                  $compiled_ref = '$_'.strtoupper($variable);
  60                  break;
  61  
  62              case 'template':
  63                  return 'basename($_smarty_tpl->source->filepath)';
  64  
  65              case 'current_dir':
  66                  return 'dirname($_smarty_tpl->source->filepath)';
  67  
  68              case 'version':
  69                  $_version = Smarty::SMARTY_VERSION;
  70                  return "'$_version'";
  71  
  72              case 'const':
  73                  if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
  74                      $compiler->trigger_template_error("(secure mode) constants not permitted");
  75                      break;
  76                  }
  77                  return '@' . trim($_index[1], "'");
  78  
  79              case 'config':
  80                  return "\$_smarty_tpl->getConfigVariable($_index[1])";
  81              case 'ldelim':
  82                  $_ldelim = $compiler->smarty->left_delimiter;
  83                  return "'$_ldelim'";
  84  
  85              case 'rdelim':
  86                  $_rdelim = $compiler->smarty->right_delimiter;
  87                  return "'$_rdelim'";
  88  
  89              default:
  90                  $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
  91                  break;
  92          }
  93          if (isset($_index[1])) {
  94              array_shift($_index);
  95              foreach ($_index as $_ind) {
  96                  $compiled_ref = $compiled_ref . "[$_ind]";
  97              }
  98          }
  99          return $compiled_ref;
 100      }
 101  
 102  }
 103  
 104  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1