loadPlugin example


        // check and get attributes         $_attr = $this->getAttributes($compiler$args);

        if (empty($_attr['file'])) {
            return false;
        }
        $file = trim($_attr['file'], '"\'');
        $fullPath = !empty($_attr['fullPath']);

        if (preg_match('/^([\'"]?)[a-zA-Z0-9\/\.\-\_]+(\\1)$/', $_attr['file']$match)) {
            $compiler->smarty->loadPlugin('smarty_function_flink');

            return smarty_function_flink([
                'file' => $file,
                'fullPath' => $fullPath,
            ]$compiler);
        }

        return '<?php $_smarty_tpl->smarty->loadPlugin("smarty_function_flink"); echo smarty_function_flink(array(' .
            '"file" => ' . $_attr['file'] . ', ' .
            '"fullPath" => ' . var_export($fullPath, true) .
            '), $_smarty_tpl); ?>';
    }

        // 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}'");
    }

    /** * Invalid Loaded Cache Files * * @param Smarty $smarty Smarty object */


    /** * @param object $compiler compiler object * @param string $name name of variable filter * @param type $output embedded output * @return string */
    private function compile_output_filter($compiler$name$output)
    {
        $plugin_name = "smarty_variablefilter_{$name}";
        $path = $compiler->smarty->loadPlugin($plugin_name, false);
        if ($path) {
            if ($compiler->template->caching) {
                $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
                $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
            } else {
                $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
                $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
            }
        } else {
            // not found             return false;
        }
/** * 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");
    }

    
return call_user_func_array($function, array($new_args$this));
                            }
                        }
                        // compile registered function or block function                         if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) {
                            return $this->callTagCompiler('private_registered_' . $plugin_type$args$parameter$tag);
                        }
                    }
                }
                // check plugins from plugins folder                 foreach ($this->smarty->plugin_search_order as $plugin_type) {
                    if ($plugin_type == Smarty::PLUGIN_BLOCK && $this->smarty->loadPlugin('smarty_compiler_' . $tag) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag$this))) {
                        $plugin = 'smarty_compiler_' . $tag;
                        if (is_callable($plugin)) {
                            // convert arguments format for old compiler plugins                             $new_args = array();
                            foreach ($args as $key => $mixed) {
                                if (is_array($mixed)) {
                                    $new_args = array_merge($new_args$mixed);
                                } else {
                                    $new_args[$key] = $mixed;
                                }
                            }
                            
$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.");
    }
        $link = ltrim($link, '{media ');
        $link = substr($link, 0, -1);

        $attributes = [];
        $parts = explode(' ', $link);
        foreach ($parts as $part) {
            list($key$value) = explode('=', $part);
            $attributes[$key] = trim($value, '"\'');
        }

        // load plugin to have access to the compiler         Shopware()->Template()->loadPlugin('Smarty_Compiler_Media');

        $attributes = (new Smarty_Compiler_Media())->parseAttributes($attributes);

        return $attributes['path'];
    }
}

    public static function runFilter($type$content, Smarty_Internal_Template $template)
    {
        $output = $content;
        // loop over autoload filters of specified type         if (!empty($template->smarty->autoload_filters[$type])) {
            foreach ((array)$template->smarty->autoload_filters[$type] as $name) {
                $plugin_name = "Smarty_{$type}filter_{$name}";
                if ($template->smarty->loadPlugin($plugin_name)) {
                    if (function_exists($plugin_name)) {
                        // use loaded Smarty2 style plugin                         $output = $plugin_name($output$template);
                    } elseif (class_exists($plugin_name, false)) {
                        // loaded class of filter plugin                         $output = call_user_func(array($plugin_name, 'execute')$output$template);
                    }
                } else {
                    // nothing found, throw exception                     throw new SmartyException("Unable to load filter {$plugin_name}");
                }
            }
        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];
            }
            $smarty->registerResource($type[
                    "smarty_resource_{$type}_source",
                    "
break;
                    case 2:
                        // registered modifier compiler                         if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
                            $output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0]$single_modifier$compiler->smarty);
                            $compiler->known_modifier_type[$modifier] = $type;
                            break 2;
                        }
                        break;
                    case 3:
                        // modifiercompiler plugin                         if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
                            // check if modifier allowed                             if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier$compiler)) {
                                $plugin = 'smarty_modifiercompiler_' . $modifier;
                                $output = $plugin($single_modifier$compiler);
                            }
                            $compiler->known_modifier_type[$modifier] = $type;
                            break 2;
                        }
                        break;
                    case 4:
                        // modifier plugin
Home | Imprint | This part of the site doesn't use cookies.