本文整理汇总了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");
//.........这里部分代码省略.........
示例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);
}
示例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);
}