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


PHP Dwoo_Compiler::setPointer方法代码示例

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


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

示例1: compile

 public static function compile(Dwoo_Compiler $compiler, $file)
 {
     list($l, $r) = $compiler->getDelimiters();
     self::$l = preg_quote($l, '/');
     self::$r = preg_quote($r, '/');
     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+(?:file=)?\\s*(\\S+?|(["\']).+?\\2)' . self::$r . '/i', $parent->getSource(), $match)) {
             $curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
             $file = substr($match[1], 0, 1) !== '"' && substr($match[1], 0, 1) !== '"' ? '"' . str_replace('"', '\\"', $match[1]) . '"' : $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'];
         }
         $newSource = preg_replace_callback('/' . self::$l . 'block (["\']?)(.+?)\\1' . self::$r . '(?:\\r?\\n?)(.*?)(?:\\r?\\n?)' . self::$l . '\\/block' . self::$r . '/is', array('Dwoo_Plugin_extends', 'replaceBlock'), $newSource);
         $newSource = $l . 'do extendsCheck("' . $parent['resource'] . ':' . $parent['identifier'] . '" "' . str_replace('"', '\\"', $parent['uid']) . '")' . $r . $newSource;
         if (self::$lastReplacement) {
             break;
         }
     }
     $compiler->setTemplateSource($newSource);
     $compiler->setPointer(0);
 }
开发者ID:nan0desu,项目名称:xyntach,代码行数:68,代码来源:extends.php

示例2: testTemplateSourceGetSet

 public function testTemplateSourceGetSet()
 {
     $cmp = new Dwoo_Compiler();
     $this->assertEquals(null, $cmp->getTemplateSource());
     $cmp->setTemplateSource("foobar");
     $cmp->setPointer(3);
     $this->assertEquals('foobar', $cmp->getTemplateSource());
     $this->assertEquals('bar', $cmp->getTemplateSource(true));
     $this->assertEquals('r', $cmp->getTemplateSource(5));
     $cmp->setTemplateSource("baz", true);
     $this->assertEquals('foobaz', $cmp->getTemplateSource());
     $this->assertEquals('baz', $cmp->getTemplateSource(true));
     $this->assertEquals('z', $cmp->getTemplateSource(5));
     $cmp->setTemplateSource("baz");
     $this->assertEquals('baz', $cmp->getTemplateSource());
     $this->assertEquals('', $cmp->getTemplateSource(true));
     $this->assertEquals('az', $cmp->getTemplateSource(1));
 }
开发者ID:robinduckett,项目名称:Dwoo,代码行数:18,代码来源:CompilerTests.php


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