public function test_toHtml() { $this->assertEquals('<a href="http://my.super.website.com/path/to/resource.htm">http://my.super.website.com/path/to/resource.htm</a>', $this->_node->toHtml()); }
/** * Parses the text inside a new url bbcode node. * * @param UrlBbcodeNode $node * @return UrlBbcodeNode */ protected function parseUrlBbcodeNode(UrlBbcodeNode $node) { $equals_sign_pos = strpos($this->_string, '=', $this->_pos - 1); $first_rbracket_pos = strpos($this->_string, ']', $this->_pos - 1); if ($first_rbracket_pos !== false) { if ($equals_sign_pos !== false && $equals_sign_pos < $first_rbracket_pos) { // composite url with [url=///]zzz[/url] syntax $url = substr($this->_string, $equals_sign_pos + 1, $first_rbracket_pos - $equals_sign_pos - 1); $node->setUrl($url); $this->_pos = $first_rbracket_pos + 1; $this->parseContent(); return $node; } else { $end = stripos($this->_string, '[/url]', $this->_pos); // simple [url]///[/url] syntax if ($end !== false) { $url = substr($this->_string, $first_rbracket_pos + 1, $end - $first_rbracket_pos - 1); $node->setUrl($url); $this->_pos = $end + 6; } else { // no end tag found: treat as text } } } else { // no end bracket found: treat as text } return $this->_stack->pop(); }