| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: |
|
| 10: |
|
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: | class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase
|
| 18: | {
|
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: |
|
| 25: | public $optional_attributes = array('assign');
|
| 26: |
|
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: |
|
| 33: | public $option_flags = array('nocache', 'nofilter');
|
| 34: |
|
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: |
|
| 45: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
| 46: | {
|
| 47: |
|
| 48: | $_attr = $this->getAttributes($compiler, $args);
|
| 49: | $output = $parameter[ 'value' ];
|
| 50: |
|
| 51: | if (!empty($parameter[ 'modifierlist' ])) {
|
| 52: | $output = $compiler->compileTag(
|
| 53: | 'private_modifier',
|
| 54: | array(),
|
| 55: | array(
|
| 56: | 'modifierlist' => $parameter[ 'modifierlist' ],
|
| 57: | 'value' => $output
|
| 58: | )
|
| 59: | );
|
| 60: | }
|
| 61: | if (isset($_attr[ 'assign' ])) {
|
| 62: |
|
| 63: | return "<?php \$_smarty_tpl->assign({$_attr['assign']},{$output});?>";
|
| 64: | } else {
|
| 65: |
|
| 66: | if (!$_attr[ 'nofilter' ]) {
|
| 67: |
|
| 68: | if (!empty($compiler->smarty->default_modifiers)) {
|
| 69: | if (empty($compiler->default_modifier_list)) {
|
| 70: | $modifierlist = array();
|
| 71: | foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
| 72: | preg_match_all(
|
| 73: | '/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/',
|
| 74: | $single_default_modifier,
|
| 75: | $mod_array
|
| 76: | );
|
| 77: | for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i++) {
|
| 78: | if ($mod_array[ 0 ][ $i ] !== ':') {
|
| 79: | $modifierlist[ $key ][] = $mod_array[ 0 ][ $i ];
|
| 80: | }
|
| 81: | }
|
| 82: | }
|
| 83: | $compiler->default_modifier_list = $modifierlist;
|
| 84: | }
|
| 85: | $output = $compiler->compileTag(
|
| 86: | 'private_modifier',
|
| 87: | array(),
|
| 88: | array(
|
| 89: | 'modifierlist' => $compiler->default_modifier_list,
|
| 90: | 'value' => $output
|
| 91: | )
|
| 92: | );
|
| 93: | }
|
| 94: |
|
| 95: | if ($compiler->template->smarty->escape_html) {
|
| 96: | $output = "htmlspecialchars({$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')";
|
| 97: | }
|
| 98: |
|
| 99: | if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) {
|
| 100: | foreach ($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ] as $key =>
|
| 101: | $function) {
|
| 102: | if (!is_array($function)) {
|
| 103: | $output = "{$function}({$output},\$_smarty_tpl)";
|
| 104: | } elseif (is_object($function[ 0 ])) {
|
| 105: | $output =
|
| 106: | "\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)";
|
| 107: | } else {
|
| 108: | $output = "{$function[0]}::{$function[1]}({$output},\$_smarty_tpl)";
|
| 109: | }
|
| 110: | }
|
| 111: | }
|
| 112: |
|
| 113: | if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) {
|
| 114: | foreach ((array)$compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name) {
|
| 115: | $result = $this->compile_variable_filter($compiler, $name, $output);
|
| 116: | if ($result !== false) {
|
| 117: | $output = $result;
|
| 118: | } else {
|
| 119: |
|
| 120: | throw new SmartyException("Unable to load variable filter '{$name}'");
|
| 121: | }
|
| 122: | }
|
| 123: | }
|
| 124: | foreach ($compiler->variable_filters as $filter) {
|
| 125: | if (count($filter) === 1
|
| 126: | && ($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false
|
| 127: | ) {
|
| 128: | $output = $result;
|
| 129: | } else {
|
| 130: | $output = $compiler->compileTag(
|
| 131: | 'private_modifier',
|
| 132: | array(),
|
| 133: | array('modifierlist' => array($filter), 'value' => $output)
|
| 134: | );
|
| 135: | }
|
| 136: | }
|
| 137: | }
|
| 138: | $output = "<?php echo {$output};?>\n";
|
| 139: | }
|
| 140: | return $output;
|
| 141: | }
|
| 142: |
|
| 143: | |
| 144: | |
| 145: | |
| 146: | |
| 147: | |
| 148: | |
| 149: | |
| 150: |
|
| 151: | private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
|
| 152: | {
|
| 153: | $function = $compiler->getPlugin($name, 'variablefilter');
|
| 154: | if ($function) {
|
| 155: | return "{$function}({$output},\$_smarty_tpl)";
|
| 156: | } else {
|
| 157: |
|
| 158: | return false;
|
| 159: | }
|
| 160: | }
|
| 161: | }
|
| 162: | |