當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dwoo_Compiler::getDwoo方法代碼示例

本文整理匯總了PHP中Dwoo_Compiler::getDwoo方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dwoo_Compiler::getDwoo方法的具體用法?PHP Dwoo_Compiler::getDwoo怎麽用?PHP Dwoo_Compiler::getDwoo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dwoo_Compiler的用法示例。


在下文中一共展示了Dwoo_Compiler::getDwoo方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Dwoo_Plugin_extendsCheck_compile

/**
 * Checks whether an extended file has been modified, and if so recompiles the current template. This is for internal use only, do not use.
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the use of this software.
 *
 * @author     Jordi Boggiano <j.boggiano@seld.be>
 * @copyright  Copyright (c) 2008, Jordi Boggiano
 * @license    http://dwoo.org/LICENSE   Modified BSD License
 * @link       http://dwoo.org/
 * @version    1.1.0
 * @date       2009-07-18
 * @package    Dwoo
 */
function Dwoo_Plugin_extendsCheck_compile(Dwoo_Compiler $compiler, $file)
{
    preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
    $resource = $m[1];
    $identifier = $m[2];
    $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
    if ($tpl === null) {
        throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
    } elseif ($tpl === false) {
        throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.');
    }
    $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
    $modCheck = $tpl->getIsModifiedCode();
    if ($modCheck) {
        $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
    } else {
        $out .= 'try {
	$tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '");
} catch (Dwoo_Exception $e) {
	$this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING);
}
if ($tpl === null)
	$this->triggerError(\'Load Templates : Resource "' . $resource . ':' . $identifier . '" was not found.\', E_USER_WARNING);
elseif ($tpl === false)
	$this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING);
if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }';
    }
    return $out;
}
開發者ID:huayuxian,項目名稱:FUEL-CMS,代碼行數:43,代碼來源:extendsCheck.php

示例2: preProcessing

 public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
 {
     $params = $compiler->getCompiledParams($params);
     $func = $params['__funcname'];
     $pluginType = $params['__functype'];
     $params = $params['*'];
     if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
         $customPlugins = $compiler->getDwoo()->getCustomPlugins();
         $callback = $customPlugins[$func]['callback'];
         if (is_array($callback)) {
             if (is_object($callback[0])) {
                 $callback = '$this->customPlugins[\'' . $func . '\'][0]->' . $callback[1] . '(';
             } else {
                 $callback = '' . $callback[0] . '::' . $callback[1] . '(';
             }
         } else {
             $callback = $callback . '(';
         }
     } else {
         $callback = 'smarty_block_' . $func . '(';
     }
     $paramsOut = '';
     foreach ($params as $i => $p) {
         $paramsOut .= var_export($i, true) . ' => ' . $p . ',';
     }
     $curBlock =& $compiler->getCurrentBlock();
     $curBlock['params']['postOut'] = Dwoo_Compiler::PHP_OPEN . ' $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $callback . '$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);' . Dwoo_Compiler::PHP_CLOSE;
     return Dwoo_Compiler::PHP_OPEN . $prepend . ' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array(' . $paramsOut . '); $_block_repeat=true; ' . $callback . '$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();' . Dwoo_Compiler::PHP_CLOSE;
 }
開發者ID:nbey,項目名稱:Emergence-Skeleton,代碼行數:29,代碼來源:smartyinterface.php

示例3: Dwoo_Plugin_load_templates_compile

/**
 * Loads sub-templates contained in an external file
 * <pre>
 *  * file : the resource name of the file to load
 * </pre>
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the use of this software.
 *
 * @author     Jordi Boggiano <j.boggiano@seld.be>
 * @copyright  Copyright (c) 2008, Jordi Boggiano
 * @license    http://dwoo.org/LICENSE   Modified BSD License
 * @link       http://dwoo.org/
 * @version    1.1.0
 * @date       2009-07-18
 * @package    Dwoo
 */
function Dwoo_Plugin_load_templates_compile(Dwoo_Compiler $compiler, $file)
{
    $file = substr($file, 1, -1);
    if ($file === '') {
        return;
    }
    if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
        // resource:identifier given, extract them
        $resource = $m[1];
        $identifier = $m[2];
    } else {
        // get the current template's resource
        $resource = $compiler->getDwoo()->getTemplate()->getResourceName();
        $identifier = $file;
    }
    $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
    if ($tpl === null) {
        throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
    } elseif ($tpl === false) {
        throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.');
    }
    $cmp = clone $compiler;
    $cmp->compile($compiler->getDwoo(), $tpl);
    foreach ($cmp->getTemplatePlugins() as $template => $args) {
        $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']);
    }
    foreach ($cmp->getUsedPlugins() as $plugin => $type) {
        $compiler->addUsedPlugin($plugin, $type);
    }
    $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
    $modCheck = $tpl->getIsModifiedCode();
    if ($modCheck) {
        $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
    } else {
        $out .= 'try {
	$tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '");
} catch (Dwoo_Exception $e) {
	$this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING);
}
if ($tpl === null)
	$this->triggerError(\'Load Templates : Resource "' . $resource . ':' . $identifier . '" was not found.\', E_USER_WARNING);
elseif ($tpl === false)
	$this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING);
if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }';
    }
    return $out;
}
開發者ID:netfreak,項目名稱:pyrocms,代碼行數:63,代碼來源:load_templates.php

示例4: Dwoo_Plugin_tif_compile

/**
 * Ternary if operation
 *
 * It evaluates the first argument and returns the second if it's true, or the third if it's false
 * <pre>
 *  * rest : you can not use named parameters to call this, use it either with three arguments in the correct order (expression, true result, false result) or write it as in php (expression ? true result : false result)
 * </pre>
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the use of this software.
 *
 * @author     Jordi Boggiano <j.boggiano@seld.be>
 * @copyright  Copyright (c) 2008, Jordi Boggiano
 * @license    http://dwoo.org/LICENSE   Modified BSD License
 * @link       http://dwoo.org/
 * @version    1.0.0
 * @date       2008-10-23
 * @package    Dwoo
 */
function Dwoo_Plugin_tif_compile(Dwoo_Compiler $compiler, array $rest)
{
    // load if plugin
    if (!class_exists('Dwoo_Plugin_if', false)) {
        try {
            $compiler->getDwoo()->getLoader()->loadPlugin('if');
        } catch (Exception $e) {
            throw new Dwoo_Compilation_Exception($compiler, 'Tif: the if plugin is required to use Tif');
        }
    }
    if (count($rest) == 1) {
        return $rest[0];
    }
    // fetch false result and remove the ":" if it was present
    $falseResult = array_pop($rest);
    if (trim(end($rest), '"\'') === ':') {
        // remove the ':' if present
        array_pop($rest);
    } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
        if ($falseResult === '?' || $falseResult === ':') {
            throw new Dwoo_Compilation_Exception($compiler, 'Tif: incomplete tif statement, value missing after ' . $falseResult);
        }
        // there was in fact no false result provided, so we move it to be the true result instead
        $trueResult = $falseResult;
        $falseResult = "''";
    }
    // fetch true result if needed
    if (!isset($trueResult)) {
        $trueResult = array_pop($rest);
        // no true result provided so we use the expression arg
        if ($trueResult === '?') {
            $trueResult = true;
        }
    }
    // remove the '?' if present
    if (trim(end($rest), '"\'') === '?') {
        array_pop($rest);
    }
    // check params were correctly provided
    if (empty($rest) || $trueResult === null || $falseResult === null) {
        throw new Dwoo_Compilation_Exception($compiler, 'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
    }
    // parse condition
    $condition = Dwoo_Plugin_if::replaceKeywords($rest, $compiler);
    return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ', $condition) : $trueResult) . ' : ' . $falseResult . ')';
}
開發者ID:ircoco,項目名稱:BlackCatCMS,代碼行數:64,代碼來源:tif.php

示例5: compile

 public static function compile(Dwoo_Compiler $compiler, $file)
 {
     list(self::$lraw, self::$rraw) = $compiler->getDelimiters();
     self::$l = preg_quote(self::$lraw, '/');
     self::$r = preg_quote(self::$rraw, '/');
     if ($compiler->getLooseOpeningHandling()) {
         self::$l .= '\\s*';
         self::$r = '\\s*' . self::$r;
     }
     $inheritanceTree = array(array('source' => $compiler->getTemplateSource()));
     $curPath = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
     $curTpl = $compiler->getDwoo()->getTemplate();
     while (!empty($file)) {
         if ($file === '""' || $file === "''" || substr($file, 0, 1) !== '"' && substr($file, 0, 1) !== '\'') {
             throw new Dwoo_Compilation_Exception($compiler, 'Extends : The file name must be a non-empty string');
             return;
         }
         if (preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m)) {
             // resource:identifier given, extract them
             $resource = $m[1];
             $identifier = $m[2];
         } else {
             // get the current template's resource
             $resource = $curTpl->getResourceName();
             $identifier = substr($file, 1, -1);
         }
         try {
             $parent = $compiler->getDwoo()->templateFactory($resource, $identifier, null, null, null, $curTpl);
         } catch (Dwoo_Security_Exception $e) {
             throw new Dwoo_Compilation_Exception($compiler, 'Extends : Security restriction : ' . $e->getMessage());
         } catch (Dwoo_Exception $e) {
             throw new Dwoo_Compilation_Exception($compiler, 'Extends : ' . $e->getMessage());
         }
         if ($parent === null) {
             throw new Dwoo_Compilation_Exception($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.');
         } elseif ($parent === false) {
             throw new Dwoo_Compilation_Exception($compiler, 'Extends : Resource "' . $resource . '" does not support extends.');
         }
         $curTpl = $parent;
         $newParent = array('source' => $parent->getSource(), 'resource' => $resource, 'identifier' => $parent->getResourceIdentifier(), 'uid' => $parent->getUid());
         if (array_search($newParent, $inheritanceTree, true) !== false) {
             throw new Dwoo_Compilation_Exception($compiler, 'Extends : Recursive template inheritance detected');
         }
         $inheritanceTree[] = $newParent;
         if (preg_match('/^' . self::$l . 'extends(?:\\(?\\s*|\\s+)(?:file=)?\\s*((["\']).+?\\2|\\S+?)\\s*\\)?\\s*?' . self::$r . '/i', $parent->getSource(), $match)) {
             $curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
             if (isset($match[2]) && $match[2] == '"') {
                 $file = '"' . str_replace('"', '\\"', substr($match[1], 1, -1)) . '"';
             } elseif (isset($match[2]) && $match[2] == "'") {
                 $file = '"' . substr($match[1], 1, -1) . '"';
             } else {
                 $file = '"' . $match[1] . '"';
             }
         } else {
             $file = false;
         }
     }
     while (true) {
         $parent = array_pop($inheritanceTree);
         $child = end($inheritanceTree);
         self::$childSource = $child['source'];
         self::$lastReplacement = count($inheritanceTree) === 1;
         if (!isset($newSource)) {
             $newSource = $parent['source'];
         }
         // TODO parse blocks tree for child source and new source
         // TODO replace blocks that are found in the child and in the parent recursively
         $firstL = preg_quote(self::$lraw[0], '/');
         $restL = preg_quote(substr(self::$lraw, 1), '/');
         $newSource = preg_replace_callback('/' . self::$l . 'block (["\']?)(.+?)\\1' . self::$r . '(?:\\r?\\n?)((?:[^' . $firstL . ']*|' . $firstL . '(?!' . $restL . '\\/block' . self::$r . '))*)' . self::$l . '\\/block' . self::$r . '/is', array('Dwoo_Plugin_extends', 'replaceBlock'), $newSource);
         $newSource = self::$lraw . 'do extendsCheck("' . $parent['resource'] . ':' . $parent['identifier'] . '")' . self::$rraw . $newSource;
         if (self::$lastReplacement) {
             break;
         }
     }
     $compiler->setTemplateSource($newSource);
     $compiler->recompile();
 }
開發者ID:randombrad,項目名稱:FUEL-CMS,代碼行數:78,代碼來源:extends.php

示例6: __construct

 public function __construct(Dwoo_Compiler $compiler, $message)
 {
     $this->compiler = $compiler;
     $this->template = $compiler->getDwoo()->getTemplate();
     parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message);
 }
開發者ID:netfreak,項目名稱:pyrocms,代碼行數:6,代碼來源:Exception.php


注:本文中的Dwoo_Compiler::getDwoo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。