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


PHP Parser::argSubstitution方法代码示例

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


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

示例1: expand

 /**
  * @throws MWException
  * @param string|PPNode $root
  * @param int $flags
  * @return string
  */
 public function expand($root, $flags = 0)
 {
     static $expansionDepth = 0;
     if (is_string($root)) {
         return $root;
     }
     if (++$this->parser->mPPNodeCount > $this->parser->mOptions->getMaxPPNodeCount()) {
         $this->parser->limitationWarn('node-count-exceeded', $this->parser->mPPNodeCount, $this->parser->mOptions->getMaxPPNodeCount());
         return '<span class="error">Node-count limit exceeded</span>';
     }
     if ($expansionDepth > $this->parser->mOptions->getMaxPPExpandDepth()) {
         $this->parser->limitationWarn('expansion-depth-exceeded', $expansionDepth, $this->parser->mOptions->getMaxPPExpandDepth());
         return '<span class="error">Expansion depth limit exceeded</span>';
     }
     ++$expansionDepth;
     if ($expansionDepth > $this->parser->mHighestExpansionDepth) {
         $this->parser->mHighestExpansionDepth = $expansionDepth;
     }
     $outStack = array('', '');
     $iteratorStack = array(false, $root);
     $indexStack = array(0, 0);
     while (count($iteratorStack) > 1) {
         $level = count($outStack) - 1;
         $iteratorNode =& $iteratorStack[$level];
         $out =& $outStack[$level];
         $index =& $indexStack[$level];
         if (is_array($iteratorNode)) {
             if ($index >= count($iteratorNode)) {
                 // All done with this iterator
                 $iteratorStack[$level] = false;
                 $contextNode = false;
             } else {
                 $contextNode = $iteratorNode[$index];
                 $index++;
             }
         } elseif ($iteratorNode instanceof PPNode_Hash_Array) {
             if ($index >= $iteratorNode->getLength()) {
                 // All done with this iterator
                 $iteratorStack[$level] = false;
                 $contextNode = false;
             } else {
                 $contextNode = $iteratorNode->item($index);
                 $index++;
             }
         } else {
             // Copy to $contextNode and then delete from iterator stack,
             // because this is not an iterator but we do have to execute it once
             $contextNode = $iteratorStack[$level];
             $iteratorStack[$level] = false;
         }
         $newIterator = false;
         if ($contextNode === false) {
             // nothing to do
         } elseif (is_string($contextNode)) {
             $out .= $contextNode;
         } elseif (is_array($contextNode) || $contextNode instanceof PPNode_Hash_Array) {
             $newIterator = $contextNode;
         } elseif ($contextNode instanceof PPNode_Hash_Attr) {
             // No output
         } elseif ($contextNode instanceof PPNode_Hash_Text) {
             $out .= $contextNode->value;
         } elseif ($contextNode instanceof PPNode_Hash_Tree) {
             if ($contextNode->name == 'template') {
                 # Double-brace expansion
                 $bits = $contextNode->splitTemplate();
                 if ($flags & PPFrame::NO_TEMPLATES) {
                     $newIterator = $this->virtualBracketedImplode('{{', '|', '}}', $bits['title'], $bits['parts']);
                 } else {
                     $ret = $this->parser->braceSubstitution($bits, $this);
                     if (isset($ret['object'])) {
                         $newIterator = $ret['object'];
                     } else {
                         $out .= $ret['text'];
                     }
                 }
             } elseif ($contextNode->name == 'tplarg') {
                 # Triple-brace expansion
                 $bits = $contextNode->splitTemplate();
                 if ($flags & PPFrame::NO_ARGS) {
                     $newIterator = $this->virtualBracketedImplode('{{{', '|', '}}}', $bits['title'], $bits['parts']);
                 } else {
                     $ret = $this->parser->argSubstitution($bits, $this);
                     if (isset($ret['object'])) {
                         $newIterator = $ret['object'];
                     } else {
                         $out .= $ret['text'];
                     }
                 }
             } elseif ($contextNode->name == 'comment') {
                 # HTML-style comment
                 # Remove it in HTML, pre+remove and STRIP_COMMENTS modes
                 # Not in RECOVER_COMMENTS mode (msgnw) though.
                 if (($this->parser->ot['html'] || $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() || $flags & PPFrame::STRIP_COMMENTS) && !($flags & PPFrame::RECOVER_COMMENTS)) {
                     $out .= '';
//.........这里部分代码省略.........
开发者ID:mb720,项目名称:mediawiki,代码行数:101,代码来源:Preprocessor_Hash.php

示例2: expand


//.........这里部分代码省略.........
         } elseif (is_array($contextNode) || $contextNode instanceof DOMNodeList) {
             $newIterator = $contextNode;
         } elseif ($contextNode instanceof DOMNode) {
             if ($contextNode->nodeType == XML_TEXT_NODE) {
                 $out .= $contextNode->nodeValue;
             } elseif ($contextNode->nodeName == 'template') {
                 # Double-brace expansion
                 $xpath = new DOMXPath($contextNode->ownerDocument);
                 $titles = $xpath->query('title', $contextNode);
                 $title = $titles->item(0);
                 $parts = $xpath->query('part', $contextNode);
                 if ($flags & PPFrame::NO_TEMPLATES) {
                     $newIterator = $this->virtualBracketedImplode('{{', '|', '}}', $title, $parts);
                 } else {
                     $lineStart = $contextNode->getAttribute('lineStart');
                     $params = array('title' => new PPNode_DOM($title), 'parts' => new PPNode_DOM($parts), 'lineStart' => $lineStart);
                     $ret = $this->parser->braceSubstitution($params, $this);
                     if (isset($ret['object'])) {
                         $newIterator = $ret['object'];
                     } else {
                         $out .= $ret['text'];
                     }
                 }
             } elseif ($contextNode->nodeName == 'tplarg') {
                 # Triple-brace expansion
                 $xpath = new DOMXPath($contextNode->ownerDocument);
                 $titles = $xpath->query('title', $contextNode);
                 $title = $titles->item(0);
                 $parts = $xpath->query('part', $contextNode);
                 if ($flags & PPFrame::NO_ARGS) {
                     $newIterator = $this->virtualBracketedImplode('{{{', '|', '}}}', $title, $parts);
                 } else {
                     $params = array('title' => new PPNode_DOM($title), 'parts' => new PPNode_DOM($parts));
                     $ret = $this->parser->argSubstitution($params, $this);
                     if (isset($ret['object'])) {
                         $newIterator = $ret['object'];
                     } else {
                         $out .= $ret['text'];
                     }
                 }
             } elseif ($contextNode->nodeName == 'comment') {
                 # HTML-style comment
                 # Remove it in HTML, pre+remove and STRIP_COMMENTS modes
                 # Not in RECOVER_COMMENTS mode (msgnw) though.
                 if (($this->parser->ot['html'] || $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() || $flags & PPFrame::STRIP_COMMENTS) && !($flags & PPFrame::RECOVER_COMMENTS)) {
                     $out .= '';
                 } elseif ($this->parser->ot['wiki'] && !($flags & PPFrame::RECOVER_COMMENTS)) {
                     # Add a strip marker in PST mode so that pstPass2() can
                     # run some old-fashioned regexes on the result.
                     # Not in RECOVER_COMMENTS mode (extractSections) though.
                     $out .= $this->parser->insertStripItem($contextNode->textContent);
                 } else {
                     # Recover the literal comment in RECOVER_COMMENTS and pre+no-remove
                     $out .= $contextNode->textContent;
                 }
             } elseif ($contextNode->nodeName == 'ignore') {
                 # Output suppression used by <includeonly> etc.
                 # OT_WIKI will only respect <ignore> in substed templates.
                 # The other output types respect it unless NO_IGNORE is set.
                 # extractSections() sets NO_IGNORE and so never respects it.
                 if (!isset($this->parent) && $this->parser->ot['wiki'] || $flags & PPFrame::NO_IGNORE) {
                     $out .= $contextNode->textContent;
                 } else {
                     $out .= '';
                 }
             } elseif ($contextNode->nodeName == 'ext') {
开发者ID:mb720,项目名称:mediawiki,代码行数:67,代码来源:Preprocessor_DOM.php

示例3: expand


//.........这里部分代码省略.........
                 } else {
                     if ($flags & PPFrame::NO_TEMPLATES) {
                         $newIterator = $this->virtualBracketedImplode('{{', '|', '}}', $title, $parts);
                     } else {
                         $lineStart = $contextNode->getAttribute('lineStart');
                         $params = array('title' => new PPNode_DOM($title), 'parts' => new PPNode_DOM($parts), 'lineStart' => $lineStart);
                         $ret = $this->parser->braceSubstitution($params, $this);
                         if (isset($ret['object'])) {
                             $newIterator = $ret['object'];
                         } else {
                             $out .= $ret['text'];
                         }
                     }
                 }
                 # RTE - end
             } elseif ($contextNode->nodeName == 'tplarg') {
                 # Triple-brace expansion
                 $xpath = new DOMXPath($contextNode->ownerDocument);
                 $titles = $xpath->query('title', $contextNode);
                 $title = $titles->item(0);
                 $parts = $xpath->query('part', $contextNode);
                 # RTE (Rich Text Editor) - begin
                 # @author: Wladyslaw Bodzek
                 global $wgRTEParserEnabled;
                 if (!empty($wgRTEParserEnabled)) {
                     //var_dump($contextNode->getAttribute('_rte_wikitextidx'));
                     $dataIdx = RTEData::put('placeholder', array('type' => 'tplarg', 'wikitextIdx' => $contextNode->getAttribute('_rte_wikitextidx'), 'lineStart' => $contextNode->getAttribute('lineStart'), 'title' => $title->textContent));
                     $out .= RTEMarker::generate(RTEMarker::PLACEHOLDER, $dataIdx);
                 } else {
                     if ($flags & PPFrame::NO_ARGS) {
                         $newIterator = $this->virtualBracketedImplode('{{{', '|', '}}}', $title, $parts);
                     } else {
                         $params = array('title' => new PPNode_DOM($title), 'parts' => new PPNode_DOM($parts));
                         $ret = $this->parser->argSubstitution($params, $this);
                         if (isset($ret['object'])) {
                             $newIterator = $ret['object'];
                         } else {
                             $out .= $ret['text'];
                         }
                     }
                 }
                 # RTE - end
             } elseif ($contextNode->nodeName == 'comment') {
                 # HTML-style comment
                 # Remove it in HTML, pre+remove and STRIP_COMMENTS modes
                 if ($this->parser->ot['html'] || $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() || $flags & PPFrame::STRIP_COMMENTS) {
                     # RTE (Rich Text Editor) - begin
                     # @author: Inez Korczyński
                     global $wgRTEParserEnabled;
                     if (!empty($wgRTEParserEnabled)) {
                         if (strlen($out) === 0 || substr($out, -1) == "\n") {
                             if (substr($contextNode->textContent, -1) == "\n") {
                                 $add = "\n";
                                 $text = substr($contextNode->textContent, 0, -1);
                             } else {
                                 $add = "";
                                 $text = $contextNode->textContent;
                             }
                             $dataIdx = RTEData::put('placeholder', array('type' => 'comment', 'wikitext' => $text));
                             $out .= RTEMarker::generate(RTEMarker::PLACEHOLDER, $dataIdx) . $add;
                         } else {
                             RTE::$edgeCases[] = 'COMMENT';
                             $out .= '';
                         }
                     } else {
                         $out .= '';
开发者ID:schwarer2006,项目名称:wikia,代码行数:67,代码来源:Preprocessor_DOM.php


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