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


PHP ezcTemplateCursor::findPosition方法代码示例

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


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

示例1: parseCurrent

 /**
  * Parses the comment by looking for the end marker * + }.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     $cursor->advance();
     if ($cursor->atEnd()) {
         return false;
     }
     $checkInlineComment = false;
     // Check for a slash after the asterix, this typically means a typo for an inline comment
     // Better give an error for this to warn the user.
     if ($cursor->current() == '/') {
         $checkInlineComment = true;
     }
     $endPosition = $cursor->findPosition('*}');
     if ($endPosition === false) {
         return false;
     }
     // If we found an end for an inline comment we need to check if there
     // is an end for an inline comment
     if ($checkInlineComment) {
         $commentCursor = $cursor->cursorAt($cursor->position, $endPosition);
         $commentCursor->advance();
         $inlineCommentPosition = $commentCursor->findPosition('*/');
         // We found the end of the inline comment, this is most likely a user error
         if ($inlineCommentPosition !== false) {
             $cursor->gotoPosition($inlineCommentPosition);
             return false;
         }
     }
     // reached end of comment
     $cursor->gotoPosition($endPosition + 2);
     $commentBlock = new ezcTemplateDocCommentTstNode($this->parser->source, clone $this->startCursor, clone $cursor);
     $commentBlock->commentText = substr($commentBlock->text(), 2, -2);
     $this->appendElement($commentBlock);
     return true;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:41,代码来源:doc_comment.php

示例2: parseCurrent

 /**
  * Parses the code by looking for start of expression blocks and then
  * passing control to the block parser (ezcTemplateBlockSourceToTstParser). The
  * text which is not covered by the block parser will be added as
  * text elements.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     $this->program = new ezcTemplateProgramTstNode($this->parser->source, $this->startCursor, $cursor);
     $this->lastBlock = $this->program;
     while (!$cursor->atEnd()) {
         // Find the first block
         $bracePosition = $cursor->findPosition("{", true);
         if ($bracePosition === false) {
             $cursor->gotoEnd();
             // This will cause handleSuccessfulResult() to be called
             return true;
         }
         // Reached a block {...}
         $cursor->gotoPosition($bracePosition);
         $blockCursor = clone $cursor;
         $cursor->advance(1);
         if ($this->lastCursor->length($blockCursor) > 0) {
             $textElement = new ezcTemplateTextBlockTstNode($this->parser->source, clone $this->lastCursor, clone $blockCursor);
             $this->handleElements(array($textElement));
             unset($textElement);
         }
         $this->startCursor->copy($blockCursor);
         $this->lastCursor->copy($cursor);
         if (!$this->parseRequiredType('Block', $this->startCursor, false)) {
             return false;
         }
         $this->startCursor->copy($cursor);
         $elements = $this->lastParser->elements;
         // Sanity checking to make sure element list does not contain duplicates,
         // this avoids having infinite recursions
         $count = count($elements);
         if ($count > 0) {
             $offset = 0;
             while ($offset < $count) {
                 $element = $elements[$offset];
                 for ($i = $offset + 1; $i < $count; ++$i) {
                     if ($element === $elements[$i]) {
                         throw new ezcTemplateInternalException("Received element list with duplicate objects from parser " . get_class($this->lastParser));
                     }
                 }
                 ++$offset;
             }
         }
         $this->handleElements($elements);
     }
     // This will cause handleSuccessfulResult() to be called
     return true;
 }
开发者ID:zetacomponents,项目名称:template,代码行数:57,代码来源:program.php

示例3: parseCurrent

 /**
  * Parses the comment by looking for the end marker * + /.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     if (!$cursor->atEnd()) {
         $cursor->advance(2);
         $tagPos = $cursor->findPosition('*/');
         if ($tagPos !== false) {
             // reached end of comment
             $cursor->gotoPosition($tagPos + 2);
             $commentBlock = new ezcTemplateBlockCommentTstNode($this->parser->source, $this->startCursor, clone $cursor);
             $commentBlock->commentText = substr($commentBlock->text(), 2, -2);
             $this->appendElement($commentBlock);
             return true;
         }
     }
     return false;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:22,代码来源:block_comment.php

示例4: parseCurrent

 /**
  * Parses the literal by using the ezcTemplateLiteralParser class.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     // $cursor will be update as the parser continues
     $this->block = new ezcTemplateLiteralBlockTstNode($this->parser->source, clone $this->startCursor, $cursor);
     // skip whitespace and comments
     if (!$this->findNextElement()) {
         return false;
     }
     $hasClosingMarker = $cursor->current() == '/';
     if ($hasClosingMarker) {
         $closingCursor = clone $cursor;
         $cursor->advance();
         $this->findNextElement();
     }
     $matches = $cursor->pregMatchComplete("#^(literal)(?:[^a-zA-Z0-9_])#");
     if ($matches === false) {
         return false;
     }
     $cursor->advance(strlen($matches[1][0]));
     // skip whitespace and comments
     if (!$this->findNextElement()) {
         return false;
     }
     // Assume end of first {literal} block
     if (!$cursor->match("}")) {
         throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $cursor, ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_CURLY_BRACKET_CLOSE);
     }
     if ($hasClosingMarker) {
         throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $cursor, "Found closing block {/literal} without an opening block.");
     }
     $literalTextCursor = clone $cursor;
     // Start searching for ending literal block.
     while (!$cursor->atEnd()) {
         // Find the next block
         $tagPos = $cursor->findPosition("{");
         if ($tagPos === false) {
             return false;
         }
         $tagCursor = clone $cursor;
         $tagCursor->gotoPosition($tagPos - 1);
         if ($tagCursor->current() == "\\") {
             // This means the tag is escaped and should be treated as text.
             $cursor->copy($tagCursor);
             $cursor->advance(2);
             unset($tagCursor);
             continue;
         }
         // Reached a block {...}
         $cursor->gotoPosition($tagPos);
         $literalTextEndCursor = clone $cursor;
         $cursor->advance();
         $continue = false;
         while (!$cursor->atEnd()) {
             // skip whitespace and comments
             if (!$this->findNextElement()) {
                 return false;
             }
             // Check for end, if not continue search
             if (!$cursor->match('/literal')) {
                 $continue = true;
                 break;
             }
             // skip whitespace and comments
             if (!$this->findNextElement()) {
                 return false;
             }
             if ($cursor->current() == '}') {
                 $this->block->textStartCursor = $literalTextCursor;
                 $this->block->textEndCursor = $literalTextEndCursor;
                 $cursor->advance();
                 $this->block->endCursor = clone $cursor;
                 // Make sure the text is extracted now that the cursor are correct
                 $this->block->storeText();
                 $this->appendElement($this->block);
                 return true;
             }
         }
         if ($continue) {
             continue;
         }
     }
     return false;
 }
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:89,代码来源:literal_block.php


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