当前位置: 首页>>代码示例>>PHP>>正文


PHP Smarty::loadPlugin方法代码示例

本文整理汇总了PHP中Smarty::loadPlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::loadPlugin方法的具体用法?PHP Smarty::loadPlugin怎么用?PHP Smarty::loadPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Smarty的用法示例。


在下文中一共展示了Smarty::loadPlugin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadCompiler

 /**
  * Load compiler object
  *
  * @throws \SmartyException
  */
 public function loadCompiler()
 {
     if (!class_exists($this->source->handler->compiler_class)) {
         $this->smarty->loadPlugin($this->source->handler->compiler_class);
     }
     $this->compiler = new $this->source->handler->compiler_class($this->source->handler->template_lexer_class, $this->source->handler->template_parser_class, $this->smarty);
 }
开发者ID:xuanhoang90,项目名称:XHFramework_2016,代码行数:12,代码来源:smarty_internal_template.php

示例2: load

 public static function load(Smarty $smarty, $type = null)
 {
     if (!isset($type)) {
         $type = $smarty->caching_type;
     }
     if (isset($smarty->_cacheresource_handlers[$type])) {
         return $smarty->_cacheresource_handlers[$type];
     }
     if (isset($smarty->registered_cache_resources[$type])) {
         return $smarty->_cacheresource_handlers[$type] = $smarty->registered_cache_resources[$type];
     }
     if (isset(self::$sysplugins[$type])) {
         if (!isset(self::$resources[$type])) {
             $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
             self::$resources[$type] = new $cache_resource_class();
         }
         return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
     }
     $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
     if ($smarty->loadPlugin($cache_resource_class)) {
         if (!isset(self::$resources[$type])) {
             self::$resources[$type] = new $cache_resource_class();
         }
         return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
     }
     throw new SmartyException("Unable to load cache resource '{$type}'");
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:27,代码来源:smarty_cacheresource.php

示例3: load

 /**
  * Load Cache Resource Handler
  *
  * @param Smarty $smarty Smarty object
  * @param string $type name of the cache resource
  * @return Smarty_CacheResource Cache Resource Handler
  */
 public static function load(Smarty $smarty, $type = null)
 {
     if (!isset($type)) {
         $type = $smarty->caching_type;
     }
     // try smarty's cache
     if (isset($smarty->_cacheresource_handlers[$type])) {
         return $smarty->_cacheresource_handlers[$type];
     }
     // try registered resource
     if (isset($smarty->registered_cache_resources[$type])) {
         // do not cache these instances as they may vary from instance to instance
         return $smarty->_cacheresource_handlers[$type] = $smarty->registered_cache_resources[$type];
     }
     // try sysplugins dir
     if (isset(self::$sysplugins[$type])) {
         if (!isset(self::$resources[$type])) {
             $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
             self::$resources[$type] = new $cache_resource_class();
         }
         return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
     }
     // try plugins dir
     $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
     if ($smarty->loadPlugin($cache_resource_class)) {
         if (!isset(self::$resources[$type])) {
             self::$resources[$type] = new $cache_resource_class();
         }
         return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
     }
     // give up
     throw new SmartyException("Unable to load cache resource '{$type}'");
 }
开发者ID:Aaron-zh,项目名称:ThinkPHPFull,代码行数:40,代码来源:smarty_cacheresource.php

示例4: __get

    /**
     * get Smarty property in template context
     *
     * @param string $property_name property name
     */
    public function __get($property_name)
    {
        switch ($property_name) {
            case 'source':
                if (strlen($this->template_resource) == 0) {
                    throw new SmartyException('Missing template name');
                }
                $this->source = Smarty_Resource::source($this);
                // cache template object under a unique ID
                // do not cache eval resources
                if ($this->source->type != 'eval') {
                    if ($this->smarty->allow_ambiguous_resources) {
                        $_templateId = $this->source->unique_resource . $this->cache_id . $this->compile_id;
                    } else {
                        $_templateId = $this->smarty->joined_template_dir . '#' . $this->template_resource . $this->cache_id . $this->compile_id;
                    }

                    if (isset($_templateId[150])) {
                        $_templateId = sha1($_templateId);
                    }
                    $this->smarty->template_objects[$_templateId] = $this;
                }

                return $this->source;

            case 'compiled':
                $this->compiled = $this->source->getCompiled($this);

                return $this->compiled;

            case 'cached':
                if (!class_exists('Smarty_Template_Cached')) {
                    include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
                }
                $this->cached = new Smarty_Template_Cached($this);

                return $this->cached;

            case 'compiler':
                $this->smarty->loadPlugin($this->source->compiler_class);
                $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);

                return $this->compiler;

            // FIXME: routing of template -> smarty attributes
            default:
                if (property_exists($this->smarty, $property_name)) {
                    return $this->smarty->$property_name;
                }
        }

        throw new SmartyException("template property '$property_name' does not exist.");
    }
开发者ID:eltonsarmento,项目名称:CursosIAG,代码行数:58,代码来源:smarty_internal_template.php

示例5: loadPlugin

 /**
  * Smarty loadPlugin method wrapper, allows to load smarty classes outside default directory
  * @param  string $plugin_name class plugin name to load
  * @param  bool   $check       check if already loaded
  * @return string |boolean filepath of loaded file or false
  */
 public function loadPlugin($plugin_name, $check = true)
 {
     if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
         return true;
     }
     $_name_parts = explode('_', $plugin_name, 3);
     if (strtolower($_name_parts[1]) == 'internal') {
         $file = Registry::get('config.dir.functions') . 'smarty_plugins/' . strtolower($plugin_name) . '.php';
         if (file_exists($file)) {
             require_once $file;
             return $file;
         }
     }
     return parent::loadPlugin($plugin_name, $check);
 }
开发者ID:askzap,项目名称:ultimate,代码行数:21,代码来源:Core.php

示例6: loadFilter

 /**
  * load a filter of specified type and name
  *
  * @param  string $type filter type
  * @param  string $name filter name
  *
  * @throws SmartyException if filter could not be loaded
  */
 public function loadFilter($type, $name)
 {
     $_plugin = "smarty_{$type}filter_{$name}";
     $_filter_name = $_plugin;
     if ($this->smarty->loadPlugin($_plugin)) {
         if (class_exists($_plugin, false)) {
             $_plugin = array($_plugin, 'execute');
         }
         if (is_callable($_plugin)) {
             $this->smarty->registered_filters[$type][$_filter_name] = $_plugin;
             return true;
         }
     }
     throw new SmartyException("{$type}filter \"{$name}\" not callable");
 }
开发者ID:Tramp1357,项目名称:wood,代码行数:23,代码来源:smarty_internal_templatebase.php

示例7: getPlugin

 /**
  * Check for plugins and return function name
  *
  * @param         $plugin_name
  * @param  string $plugin_type type of plugin
  *
  * @return string call name of function
  */
 public function getPlugin($plugin_name, $plugin_type)
 {
     $function = null;
     if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
         if (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
             $function = $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
         } elseif (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
             $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type] = $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type];
             $function = $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
         }
     } else {
         if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
             $function = $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
         } elseif (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
             $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type] = $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type];
             $function = $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
         }
     }
     if (isset($function)) {
         if ($plugin_type == 'modifier') {
             $this->modifier_plugins[$plugin_name] = true;
         }
         return $function;
     }
     // loop through plugin dirs and find the plugin
     $function = 'smarty_' . $plugin_type . '_' . $plugin_name;
     $file = $this->smarty->loadPlugin($function, false);
     if (is_string($file)) {
         if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
             $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['file'] = $file;
             $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'] = $function;
         } else {
             $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['file'] = $file;
             $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'] = $function;
         }
         if ($plugin_type == 'modifier') {
             $this->modifier_plugins[$plugin_name] = true;
         }
         return $function;
     }
     if (is_callable($function)) {
         // plugin function is defined in the script
         return $function;
     }
     return false;
 }
开发者ID:elusiveity,项目名称:secretchan,代码行数:54,代码来源:smarty_internal_templatecompilerbase.php

示例8: __get

 /**
  * get Smarty property in template context
  *
  * @param string $property_name property name
  */
 public function __get($property_name)
 {
     switch ($property_name) {
         case 'source':
             if (empty($this->template_resource)) {
                 throw new SmartyException("Unable to parse resource name \"{$this->template_resource}\"");
             }
             $this->source = Smarty_Resource::source($this);
             // cache template object under a unique ID
             // do not cache eval resources
             if ($this->source->type != 'eval') {
                 $_templateId = sha1($this->source->unique_resource . $this->cache_id . $this->compile_id);
                 $this->smarty->template_objects[$_templateId] = $this;
             }
             return $this->source;
         case 'compiled':
             $this->compiled = $this->source->getCompiled($this);
             return $this->compiled;
         case 'cached':
             if (!class_exists('Smarty_Template_Cached')) {
                 include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
             }
             $this->cached = new Smarty_Template_Cached($this);
             return $this->cached;
         case 'compiler':
             $this->smarty->loadPlugin($this->source->compiler_class);
             $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
             return $this->compiler;
             // FIXME: routing of template -> smarty attributes
         // FIXME: routing of template -> smarty attributes
         default:
             if (property_exists($this->smarty, $property_name)) {
                 return $this->smarty->{$property_name};
             }
     }
     throw new SmartyException("template property '{$property_name}' does not exist.");
 }
开发者ID:Jayriq,项目名称:mmslides,代码行数:42,代码来源:smarty_internal_template.php

示例9: load

 /**
  * Load Resource Handler
  *
  * @param Smarty $smarty    smarty object
  * @param string $type      name of the resource
  * @return Smarty_Resource Resource Handler
  */
 public static function load(Smarty $smarty, $type)
 {
     // try smarty's cache
     if (isset($smarty->_resource_handlers[$type])) {
         return $smarty->_resource_handlers[$type];
     }
     // try registered resource
     if (isset($smarty->registered_resources[$type])) {
         if ($smarty->registered_resources[$type] instanceof Smarty_Resource) {
             $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type];
             // note registered to smarty is not kept unique!
             return $smarty->_resource_handlers[$type];
         }
         if (!isset(self::$resources['registered'])) {
             self::$resources['registered'] = new Smarty_Internal_Resource_Registered();
         }
         if (!isset($smarty->_resource_handlers[$type])) {
             $smarty->_resource_handlers[$type] = self::$resources['registered'];
         }
         return $smarty->_resource_handlers[$type];
     }
     // try sysplugins dir
     if (isset(self::$sysplugins[$type])) {
         if (!isset(self::$resources[$type])) {
             $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
             self::$resources[$type] = new $_resource_class();
         }
         return $smarty->_resource_handlers[$type] = self::$resources[$type];
     }
     // try plugins dir
     $_resource_class = 'Smarty_Resource_' . ucfirst($type);
     if ($smarty->loadPlugin($_resource_class)) {
         if (isset(self::$resources[$type])) {
             return $smarty->_resource_handlers[$type] = self::$resources[$type];
         }
         if (class_exists($_resource_class, false)) {
             self::$resources[$type] = new $_resource_class();
             return $smarty->_resource_handlers[$type] = self::$resources[$type];
         } else {
             $smarty->registerResource($type, array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp", "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted"));
             // give it another try, now that the resource is registered properly
             return self::load($smarty, $type);
         }
     }
     // try streams
     $_known_stream = stream_get_wrappers();
     if (in_array($type, $_known_stream)) {
         // is known stream
         if (is_object($smarty->security_policy)) {
             $smarty->security_policy->isTrustedStream($type);
         }
         if (!isset(self::$resources['stream'])) {
             self::$resources['stream'] = new Smarty_Internal_Resource_Stream();
         }
         return $smarty->_resource_handlers[$type] = self::$resources['stream'];
     }
     // TODO: try default_(template|config)_handler
     // give up
     throw new SmartyException("Unkown resource type '{$type}'");
 }
开发者ID:shaoyi88,项目名称:admin_template,代码行数:67,代码来源:smarty_resource.php

示例10: loadCompiler

 /**
  * Load compiler object
  *
  * @throws \SmartyException
  */
 public function loadCompiler()
 {
     $this->smarty->loadPlugin($this->source->compiler_class);
     $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
 }
开发者ID:hejxing,项目名称:jt,代码行数:10,代码来源:smarty_internal_template.php

示例11: load

 public static function load(Smarty $smarty, $type)
 {
     if (isset($smarty->_resource_handlers[$type])) {
         return $smarty->_resource_handlers[$type];
     }
     if (isset($smarty->registered_resources[$type])) {
         if ($smarty->registered_resources[$type] instanceof Smarty_Resource) {
             $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type];
             return $smarty->_resource_handlers[$type];
         }
         if (!isset(self::$resources['registered'])) {
             self::$resources['registered'] = new Smarty_Internal_Resource_Registered();
         }
         if (!isset($smarty->_resource_handlers[$type])) {
             $smarty->_resource_handlers[$type] = self::$resources['registered'];
         }
         return $smarty->_resource_handlers[$type];
     }
     if (isset(self::$sysplugins[$type])) {
         if (!isset(self::$resources[$type])) {
             $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
             self::$resources[$type] = new $_resource_class();
         }
         return $smarty->_resource_handlers[$type] = self::$resources[$type];
     }
     $_resource_class = 'Smarty_Resource_' . ucfirst($type);
     if ($smarty->loadPlugin($_resource_class)) {
         if (isset(self::$resources[$type])) {
             return $smarty->_resource_handlers[$type] = self::$resources[$type];
         }
         if (class_exists($_resource_class, false)) {
             self::$resources[$type] = new $_resource_class();
             return $smarty->_resource_handlers[$type] = self::$resources[$type];
         } else {
             $smarty->registerResource($type, array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp", "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted"));
             return self::load($smarty, $type);
         }
     }
     $_known_stream = stream_get_wrappers();
     if (in_array($type, $_known_stream)) {
         if (is_object($smarty->security_policy)) {
             $smarty->security_policy->isTrustedStream($type);
         }
         if (!isset(self::$resources['stream'])) {
             self::$resources['stream'] = new Smarty_Internal_Resource_Stream();
         }
         return $smarty->_resource_handlers[$type] = self::$resources['stream'];
     }
     throw new SmartyException("Unkown resource type '{$type}'");
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:50,代码来源:smarty_resource.php

示例12: __get

 /**
  * get Smarty property in template context
  *
  * @param string $property_name property name
  *
  * @return mixed
  * @throws SmartyException
  */
 public function __get($property_name)
 {
     switch ($property_name) {
         case 'source':
             $this->loadSource();
             return $this->source;
         case 'compiled':
             $this->compiled = Smarty_Template_Compiled::load($this);
             return $this->compiled;
         case 'cached':
             $this->cached = Smarty_Template_Cached::load($this);
             return $this->cached;
         case 'compiler':
             $this->smarty->loadPlugin($this->source->compiler_class);
             $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
             return $this->compiler;
             // FIXME: routing of template -> smarty attributes
         // FIXME: routing of template -> smarty attributes
         default:
             if (property_exists($this->smarty, $property_name)) {
                 return $this->smarty->{$property_name};
             }
             throw new SmartyException("template property '{$property_name}' does not exist.");
     }
 }
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:33,代码来源:smarty_internal_template.php

示例13: load

 /**
  * Load Resource Handler
  *
  * @param Smarty $smarty        smarty object
  * @param string $resource_type name of the resource
  * @return Smarty_Resource Resource Handler
  */
 public static function load(Smarty $smarty, $resource_type)
 {
     // try the instance cache
     if (isset(self::$resources[$resource_type])) {
         return self::$resources[$resource_type];
     }
     // try registered resource
     if (isset($smarty->registered_resources[$resource_type])) {
         if ($smarty->registered_resources[$resource_type] instanceof Smarty_Resource) {
             return self::$resources[$resource_type] = $smarty->registered_resources[$resource_type];
         }
         if (!isset(self::$resources['registered'])) {
             self::$resources['registered'] = new Smarty_Internal_Resource_Registered();
         }
         return self::$resources['registered'];
     }
     // try sysplugins dir
     if (isset(self::$sysplugins[$resource_type])) {
         $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($resource_type);
         return self::$resources[$resource_type] = new $_resource_class();
     }
     // try plugins dir
     $_resource_class = 'Smarty_Resource_' . ucfirst($resource_type);
     if ($smarty->loadPlugin($_resource_class)) {
         if (class_exists($_resource_class, false)) {
             return self::$resources[$resource_type] = new $_resource_class();
         } else {
             $smarty->registerResource($resource_type, array("smarty_resource_{$resource_type}_source", "smarty_resource_{$resource_type}_timestamp", "smarty_resource_{$resource_type}_secure", "smarty_resource_{$resource_type}_trusted"));
             // give it another try, now that the resource is registered properly
             return self::load($smarty, $resource_type);
         }
     }
     // try streams
     $_known_stream = stream_get_wrappers();
     if (in_array($resource_type, $_known_stream)) {
         // is known stream
         if (is_object($smarty->security_policy)) {
             $smarty->security_policy->isTrustedStream($resource_type);
         }
         if (!isset(self::$resources['stream'])) {
             self::$resources['stream'] = new Smarty_Internal_Resource_Stream();
         }
         return self::$resources['stream'];
     }
     // give up
     throw new SmartyException('Unkown resource type \'' . $resource_type . '\'');
 }
开发者ID:iLoiLohas,项目名称:pinchshopper,代码行数:54,代码来源:smarty_resource.php

示例14: loadPlugin

 /**
  * Takes unknown classes and loads plugin files for them
  * class name format: Smarty_PluginType_PluginName
  * plugin filename format: plugintype.pluginname.php
  *
  * @param  string $plugin_name class plugin name to load
  * @param  bool   $check       check if already loaded
  * @return string |boolean filepath of loaded file or false
  */
 public function loadPlugin($plugin_name, $check = true)
 {
     return $this->smarty->loadPlugin($plugin_name, $check);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:13,代码来源:SmartyAdapter.php


注:本文中的Smarty::loadPlugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。