Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * Smarty Internal Plugin Compile Function
  4:  * Compiles the {function} {/function} tags
  5:  *
  6:  * @package    Smarty
  7:  * @subpackage Compiler
  8:  * @author     Uwe Tews
  9:  */
 10: 
 11: /**
 12:  * Smarty Internal Plugin Compile Function Class
 13:  *
 14:  * @package    Smarty
 15:  * @subpackage Compiler
 16:  */
 17: class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
 18: {
 19:     /**
 20:      * Attribute definition: Overwrites base class.
 21:      *
 22:      * @var array
 23:      * @see Smarty_Internal_CompileBase
 24:      */
 25:     public $required_attributes = array('name');
 26:     /**
 27:      * Attribute definition: Overwrites base class.
 28:      *
 29:      * @var array
 30:      * @see Smarty_Internal_CompileBase
 31:      */
 32:     public $shorttag_order = array('name');
 33:     /**
 34:      * Attribute definition: Overwrites base class.
 35:      *
 36:      * @var array
 37:      * @see Smarty_Internal_CompileBase
 38:      */
 39:     public $optional_attributes = array('_any');
 40: 
 41:     /**
 42:      * Compiles code for the {function} tag
 43:      *
 44:      * @param  array  $args      array with attributes from parser
 45:      * @param  object $compiler  compiler object
 46:      * @param  array  $parameter array with compilation parameter
 47:      *
 48:      * @return boolean true
 49:      */
 50:     public function compile($args, $compiler, $parameter)
 51:     {
 52:         // check and get attributes
 53:         $_attr = $this->getAttributes($compiler, $args);
 54: 
 55:         if ($_attr['nocache'] === true) {
 56:             $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
 57:         }
 58:         unset($_attr['nocache']);
 59:         $save = array($_attr, $compiler->parser->current_buffer,
 60:                       $compiler->template->has_nocache_code, $compiler->template->required_plugins);
 61:         $this->openTag($compiler, 'function', $save);
 62:         $_name = trim($_attr['name'], "'\"");
 63:         unset($_attr['name']);
 64:         // set flag that we are compiling a template function
 65:         $compiler->compiles_template_function = true;
 66:         $compiler->template->properties['function'][$_name]['parameter'] = array();
 67:         /** @var Smarty_Internal_Template $_smarty_tpl
 68:          * used in evaluated code
 69:          */
 70:         $_smarty_tpl = $compiler->template;
 71:         foreach ($_attr as $_key => $_data) {
 72:             eval ('$tmp=' . $_data . ';');
 73:             $compiler->template->properties['function'][$_name]['parameter'][$_key] = $tmp;
 74:         }
 75:         $compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter'];
 76:         if ($compiler->template->caching) {
 77:             $output = '';
 78:         } else {
 79:             $output = "<?php if (!function_exists('smarty_template_function_{$_name}')) {
 80:     function smarty_template_function_{$_name}(\$_smarty_tpl,\$params) {
 81:     \$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
 82:     foreach (\$_smarty_tpl->smarty->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);};
 83:     foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
 84:         }
 85:         // Init temporary context
 86:         $compiler->template->required_plugins = array('compiled' => array(), 'nocache' => array());
 87:         $compiler->parser->current_buffer = new _smarty_template_buffer($compiler->parser);
 88:         $compiler->parser->current_buffer->append_subtree(new _smarty_tag($compiler->parser, $output));
 89:         $compiler->template->has_nocache_code = false;
 90:         $compiler->has_code = false;
 91:         $compiler->template->properties['function'][$_name]['compiled'] = '';
 92:         return true;
 93:     }
 94: }
 95: 
 96: /**
 97:  * Smarty Internal Plugin Compile Functionclose Class
 98:  *
 99:  * @package    Smarty
100:  * @subpackage Compiler
101:  */
102: class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
103: {
104:     /**
105:      * Compiles code for the {/function} tag
106:      *
107:      * @param  array  $args      array with attributes from parser
108:      * @param  object $compiler  compiler object
109:      * @param  array  $parameter array with compilation parameter
110:      *
111:      * @return boolean true
112:      */
113:     public function compile($args, $compiler, $parameter)
114:     {
115:         $_attr = $this->getAttributes($compiler, $args);
116:         $saved_data = $this->closeTag($compiler, array('function'));
117:         $_name = trim($saved_data[0]['name'], "'\"");
118:         // build plugin include code
119:         $plugins_string = '';
120:         if (!empty($compiler->template->required_plugins['compiled'])) {
121:             $plugins_string = '<?php ';
122:             foreach ($compiler->template->required_plugins['compiled'] as $tmp) {
123:                 foreach ($tmp as $data) {
124:                     $plugins_string .= "if (!is_callable('{$data['function']}')) include '{$data['file']}';\n";
125:                 }
126:             }
127:             $plugins_string .= '?>';
128:         }
129:         if (!empty($compiler->template->required_plugins['nocache'])) {
130:             $plugins_string .= "<?php echo '/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php ";
131:             foreach ($compiler->template->required_plugins['nocache'] as $tmp) {
132:                 foreach ($tmp as $data) {
133:                     $plugins_string .= "if (!is_callable(\'{$data['function']}\')) include \'{$data['file']}\';\n";
134:                 }
135:             }
136:             $plugins_string .= "?>/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/';?>\n";
137:         }
138:          // if caching save template function for possible nocache call
139:         if ($compiler->template->caching) {
140:             $compiler->template->properties['function'][$_name]['compiled'] .= $plugins_string
141:                 . $compiler->parser->current_buffer->to_smarty_php();
142:             $compiler->template->properties['function'][$_name]['nocache_hash'] = $compiler->template->properties['nocache_hash'];
143:             $compiler->template->properties['function'][$_name]['has_nocache_code'] = $compiler->template->has_nocache_code;
144:             $compiler->template->properties['function'][$_name]['called_functions'] = $compiler->called_functions;
145:             $compiler->called_functions = array();
146:             $compiler->smarty->template_functions[$_name] = $compiler->template->properties['function'][$_name];
147:             $compiler->has_code = false;
148:             $output = true;
149:         } else {
150:             $output = $plugins_string . $compiler->parser->current_buffer->to_smarty_php() . "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;
151: foreach (Smarty::\$global_tpl_vars as \$key => \$value) if(!isset(\$_smarty_tpl->tpl_vars[\$key])) \$_smarty_tpl->tpl_vars[\$key] = \$value;}}?>\n";
152:         }
153:         // reset flag that we are compiling a template function
154:         $compiler->compiles_template_function = false;
155:         // restore old compiler status
156:         $compiler->parser->current_buffer = $saved_data[1];
157:         $compiler->template->has_nocache_code = $compiler->template->has_nocache_code | $saved_data[2];
158:         $compiler->template->required_plugins = $saved_data[3];
159: 
160:         return $output;
161:     }
162: }
163: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen