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: /**
  4:  * Smarty Internal Plugin Compile Insert
  5:  * Compiles the {insert} tag
  6:  *
  7:  * @package    Smarty
  8:  * @subpackage Compiler
  9:  * @author     Uwe Tews
 10:  */
 11: 
 12: /**
 13:  * Smarty Internal Plugin Compile Insert Class
 14:  *
 15:  * @package    Smarty
 16:  * @subpackage Compiler
 17:  */
 18: class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
 19: {
 20:     /**
 21:      * Attribute definition: Overwrites base class.
 22:      *
 23:      * @var array
 24:      * @see Smarty_Internal_CompileBase
 25:      */
 26:     public $required_attributes = array('name');
 27:     /**
 28:      * Attribute definition: Overwrites base class.
 29:      *
 30:      * @var array
 31:      * @see Smarty_Internal_CompileBase
 32:      */
 33:     public $shorttag_order = array('name');
 34:     /**
 35:      * Attribute definition: Overwrites base class.
 36:      *
 37:      * @var array
 38:      * @see Smarty_Internal_CompileBase
 39:      */
 40:     public $optional_attributes = array('_any');
 41: 
 42:     /**
 43:      * Compiles code for the {insert} tag
 44:      *
 45:      * @param  array  $args     array with attributes from parser
 46:      * @param  object $compiler compiler object
 47:      *
 48:      * @return string compiled code
 49:      */
 50:     public function compile($args, $compiler)
 51:     {
 52:         // check and get attributes
 53:         $_attr = $this->getAttributes($compiler, $args);
 54:         // never compile as nocache code
 55:         $compiler->suppressNocacheProcessing = true;
 56:         $compiler->tag_nocache = true;
 57:         $_smarty_tpl = $compiler->template;
 58:         $_name = null;
 59:         $_script = null;
 60: 
 61:         $_output = '<?php ';
 62:         // save possible attributes
 63:         eval('$_name = ' . $_attr['name'] . ';');
 64:         if (isset($_attr['assign'])) {
 65:             // output will be stored in a smarty variable instead of being displayed
 66:             $_assign = $_attr['assign'];
 67:             // create variable to make sure that the compiler knows about its nocache status
 68:             $compiler->template->tpl_vars[trim($_attr['assign'], "'")] = new Smarty_Variable(null, true);
 69:         }
 70:         if (isset($_attr['script'])) {
 71:             // script which must be included
 72:             $_function = "smarty_insert_{$_name}";
 73:             $_smarty_tpl = $compiler->template;
 74:             $_filepath = false;
 75:             eval('$_script = ' . $_attr['script'] . ';');
 76:             if (!isset($compiler->smarty->security_policy) && file_exists($_script)) {
 77:                 $_filepath = $_script;
 78:             } else {
 79:                 if (isset($compiler->smarty->security_policy)) {
 80:                     $_dir = $compiler->smarty->security_policy->trusted_dir;
 81:                 } else {
 82:                     $_dir = $compiler->smarty->trusted_dir;
 83:                 }
 84:                 if (!empty($_dir)) {
 85:                     foreach ((array) $_dir as $_script_dir) {
 86:                         $_script_dir = rtrim($_script_dir, '/\\') . DS;
 87:                         if (file_exists($_script_dir . $_script)) {
 88:                             $_filepath = $_script_dir . $_script;
 89:                             break;
 90:                         }
 91:                     }
 92:                 }
 93:             }
 94:             if ($_filepath == false) {
 95:                 $compiler->trigger_template_error("{insert} missing script file '{$_script}'", $compiler->lex->taglineno);
 96:             }
 97:             // code for script file loading
 98:             $_output .= "require_once '{$_filepath}' ;";
 99:             require_once $_filepath;
100:             if (!is_callable($_function)) {
101:                 $compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'", $compiler->lex->taglineno);
102:             }
103:         } else {
104:             $_filepath = 'null';
105:             $_function = "insert_{$_name}";
106:             // function in PHP script ?
107:             if (!is_callable($_function)) {
108:                 // try plugin
109:                 if (!$_function = $compiler->getPlugin($_name, 'insert')) {
110:                     $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", $compiler->lex->taglineno);
111:                 }
112:             }
113:         }
114:         // delete {insert} standard attributes
115:         unset($_attr['name'], $_attr['assign'], $_attr['script'], $_attr['nocache']);
116:         // convert attributes into parameter array string
117:         $_paramsArray = array();
118:         foreach ($_attr as $_key => $_value) {
119:             $_paramsArray[] = "'$_key' => $_value";
120:         }
121:         $_params = 'array(' . implode(", ", $_paramsArray) . ')';
122:         // call insert
123:         if (isset($_assign)) {
124:             if ($_smarty_tpl->caching) {
125:                 $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>";
126:             } else {
127:                 $_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl), true);?>";
128:             }
129:         } else {
130:             $compiler->has_output = true;
131:             if ($_smarty_tpl->caching) {
132:                 $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>";
133:             } else {
134:                 $_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>";
135:             }
136:         }
137: 
138:         return $_output;
139:     }
140: }
141: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen