public function getSourceAt($token) { return Mana_Core_Model_Html_Token::getSourceAt($this->_source, $token, $this->_tabWidth); }
public function parseElement($parentContent = null) { $result = $this->_beforeParsingElement($parentContent); $this->_read(Mana_Core_Model_Html_State::INITIAL, Mana_Core_Model_Html_Token::NAME, false); $elementName = $this->_token['text']; array_push($this->_openedElements, $elementName); $void = Mana_Core_Model_Html_Token::isVoid($elementName); $rawText = Mana_Core_Model_Html_Token::isRawText($elementName); $this->_processElementName($parentContent, $result, $this->_token, $elementName, $void, $rawText); while ($this->_read(Mana_Core_Model_Html_State::INITIAL) == Mana_Core_Model_Html_Token::NAME || $this->_token['type'] == Mana_Core_Model_Html_Token::EQ) { if ($this->_token['type'] != Mana_Core_Model_Html_Token::EQ) { $attributeName = $this->_token['text']; $this->_processAttributeName($parentContent, $result, $this->_token, $attributeName); } else { $this->_processAttributeEq($parentContent, $result, $this->_token); $this->_read(Mana_Core_Model_Html_State::INITIAL_VALUE, Mana_Core_Model_Html_Token::VALUE, true); $attributeValue = $this->_token['text']; $this->_processAttributeValue($parentContent, $result, $this->_token, $attributeValue); } } switch ($this->_token['type']) { case Mana_Core_Model_Html_Token::TAG_SELF_CLOSE: $this->_processElementClose($parentContent, $result, $this->_token); array_pop($this->_openedElements); break; case Mana_Core_Model_Html_Token::TAG_CLOSE: $this->_processElementClose($parentContent, $result, $this->_token); if (!$void) { $this->_read($rawText ? $elementName : Mana_Core_Model_Html_State::INITIAL_TEXT); $this->_afterParsingChildContent($parentContent, $result, $this->parseContent($this->_beforeParsingChildContent($parentContent, $result))); if ($this->_token['type'] != Mana_Core_Model_Html_Token::TAG_END) { throw new Exception(Mage::helper('mana_core')->__('HTML parser error %s: %s expected%s', Mana_Core_Model_Html_Token::getPosition($this->_token), Mana_Core_Model_Html_Token::getName(Mana_Core_Model_Html_Token::TAG_END), $this->getReader()->getSourceAt($this->_token))); } $this->_read(Mana_Core_Model_Html_State::INITIAL, Mana_Core_Model_Html_Token::NAME, false); array_pop($this->_openedElements); if ($this->_token['text'] != $elementName) { if (in_array($this->_token['text'], $this->_openedElements)) { $this->getReader()->move(-3 - mb_strlen($this->_token['text'])); $this->_processElementEnd($parentContent, $result, $this->_token, $elementName); } else { throw new Exception(Mage::helper('mana_core')->__('HTML parser error %s: closing tag for %s expected%s', Mana_Core_Model_Html_Token::getPosition($this->_token), $elementName, $this->getReader()->getSourceAt($this->_token))); } } else { $this->_read(Mana_Core_Model_Html_State::INITIAL, Mana_Core_Model_Html_Token::TAG_CLOSE, false); $this->_processElementEnd($parentContent, $result, $this->_token, $elementName); } } else { array_pop($this->_openedElements); } break; default: throw new Exception(Mage::helper('mana_core')->__('HTML parser error %s: %s or %s expected%s', Mana_Core_Model_Html_Token::getPosition($this->_token), Mana_Core_Model_Html_Token::getName(Mana_Core_Model_Html_Token::TAG_SELF_CLOSE), Mana_Core_Model_Html_Token::getName(Mana_Core_Model_Html_Token::TAG_CLOSE), $this->getReader()->getSourceAt($this->_token))); } $this->_read(Mana_Core_Model_Html_State::INITIAL_TEXT); return $this->_afterParsingElement($parentContent, $result); }