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


PHP DOMElement::getLineNo方法代碼示例

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


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

示例1: getTemplateKeys

 /**
  * @param DOMElement $wtElement <w:t> element in the document xml,
  * this method should be called sequentially for all the <w:t> elements in the order they appear in the document xml
  *
  */
 private function getTemplateKeys(DOMElement $wtElement)
 {
     if (strtoupper($wtElement->tagName) != "W:T") {
         $this->log(LOG_ALERT, "Invalid element for finding template keys : Line " . $wtElement->getLineNo());
         return false;
     }
     $keys = array();
     $textContent = $wtElement->textContent;
     $incompleteText = '';
     if (count($this->incompleteKeyNodes) > 0) {
         // incomplete keys are from different <p> elements , then discard the old incomplete elements
         $firstIncompleteKey = $this->incompleteKeyNodes[0];
         if ($firstIncompleteKey->element()->parentNode->parentNode !== $wtElement->parentNode->parentNode) {
             $this->log(LOG_WARNING, "incomplete keys in paragraph : Line " . $firstIncompleteKey->element()->parentNode->parentNode->getLineNo());
             $this->incompleteKeyNodes = array();
         }
         foreach ($this->incompleteKeyNodes as $incompleteKeyNode) {
             //$incompleteKeyNode will be an instance of KeyNode class
             $incompleteText .= $incompleteKeyNode->key();
         }
     }
     $textContent = $incompleteText . $textContent;
     $textChars = str_split($textContent);
     $key = null;
     $nonKey = "";
     for ($i = 0; $i < count($textChars); $i++) {
         if ($textChars[$i] === $this->keyStartChar || $textChars[$i] === $this->keyEndChar) {
             // found keyStartChar/keyEndChar check the \ character behind the keyStartChar/keyEndChar
             $j = $i - 1;
             for (; $j >= 0; $j--) {
                 if ($textChars[$j] != "\\") {
                     break;
                 }
             }
             if (($i - $j) % 2) {
                 // if i-j is odd ,
                 // then there are even numbers of \ chars behind found keyStartChar/keyEndChar
                 // so keyStartChar/keyEndChar is not escaped and hence valid
                 if ($textChars[$i] === $this->keyStartChar) {
                     //found keyStartChar
                     if ($nonKey !== "") {
                         $keyNode = new KeyNode($nonKey, false, true, $wtElement);
                         $keys[] = $keyNode;
                     }
                     if ($key != null) {
                         $keyNode = new KeyNode($key, false, true, $wtElement);
                         $keys[] = $keyNode;
                     }
                     $key = $textChars[$i];
                     $nonKey = "";
                 } else {
                     //found keyEndChar
                     if ($key !== null) {
                         $key = $key . $textChars[$i];
                         $keyNode = new KeyNode($key, true, true, $wtElement);
                         $keys[] = $keyNode;
                         $key = null;
                         $nonKey = "";
                     } else {
                         $nonKey = $nonKey . $textChars[$i];
                     }
                 }
                 continue;
             }
         }
         //neither keyStartChar nor keyEndChar
         if ($key !== null) {
             // if a key is started, append to it
             $key = $key . $textChars[$i];
         } else {
             $nonKey = $nonKey . $textChars[$i];
         }
     }
     if ($key !== null) {
         $openKey = new KeyNode($key, true, false, $wtElement);
     }
     if ($nonKey !== "") {
         $openText = new KeyNode($nonKey, false, true, $wtElement);
     }
     $incompleteKeys = false;
     if (count($this->incompleteKeyNodes) > 0) {
         $incompleteKeys = true;
     }
     if ($incompleteKeys && (!isset($openKey) || isset($openKey) && count($keys) > 0)) {
         // if there were incomplete keys and found one or more complete keys in current textContent
         // copy the incomplete keys content to current w:t element
         for ($i = count($this->incompleteKeyNodes) - 1; $i >= 0; $i--) {
             $incompleteKeyNode = $this->incompleteKeyNodes[$i];
             $incompleteKeyElement = $incompleteKeyNode->element();
             $incompleteKey = $incompleteKeyNode->key();
             //delete content from the incompleteKeyElement
             $incompleteKeyElementContent = $incompleteKeyElement->textContent;
             $incompleteKeyElementContent = substr($incompleteKeyElementContent, 0, strlen($incompleteKeyElementContent) - strlen($incompleteKey));
             if ($this->endsWith($incompleteKeyElementContent, " ")) {
                 $incompleteKeyElement->setAttribute("xml:space", "preserve");
//.........這裏部分代碼省略.........
開發者ID:steinhoff1989,項目名稱:docxTemplateInPHP,代碼行數:101,代碼來源:DocxTemplate.php

示例2: getModifiedComponent

 /**
  * @param \DOMElement $description
  * @param Component   $component
  *
  * @return mixed
  * @throws \MWException
  */
 protected function getModifiedComponent(\DOMElement $description, Component $component)
 {
     if (!$description->hasAttribute('type')) {
         throw new \MWException(sprintf('%s (line %d): Modification element missing an attribute: type.', $this->getLayoutFile(), $description->getLineNo()));
     }
     $className = 'Skins\\Chameleon\\Components\\Modifications\\' . $description->getAttribute('type');
     if (!class_exists($className) || !is_subclass_of($className, 'Skins\\Chameleon\\Components\\Modifications\\Modification')) {
         throw new \MWException(sprintf('%s (line %d): Invalid modification type: %s.', $this->getLayoutFile(), $description->getLineNo(), $description->getAttribute('type')));
     }
     return new $className($component, $description);
 }
開發者ID:eadpucv,項目名稱:mediawiki-skins-chameleon,代碼行數:18,代碼來源:ComponentFactory.php

示例3: getFormNodeId

 /**
  * Returns form node unique identifier.
  *
  * @param \DOMElement $form
  *
  * @return string
  */
 private function getFormNodeId(\DOMElement $form)
 {
     return md5($form->getLineNo() . $form->getNodePath() . $form->nodeValue);
 }
開發者ID:penguinclub,項目名稱:penguinweb_drupal8,代碼行數:11,代碼來源:BrowserKitDriver.php


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