/** * Parses the text for an image bbcode node. * * @param ImgBbcodeNode $node * @return ImgBbcodeNode */ protected function parseImgBbcodeNode(ImgBbcodeNode $node) { $first_rbracket_pos = strpos($this->_string, ']', $this->_pos - 1); if ($first_rbracket_pos !== false) { $equal_pos = strpos($this->_string, '=', $this->_pos - 1); if ($equal_pos !== false && $equal_pos < $first_rbracket_pos) { // form [img=widthxheight]///[/img] $dimensions = substr($this->_string, $equal_pos + 1, $first_rbracket_pos - $equal_pos - 1); if (preg_match('#^(\\d+)x(\\d+)$#', $dimensions, $matches)) { $node->setDimensions((int) $matches[1], (int) $matches[2]); } } // else form [img]///[/img] $end = stripos($this->_string, '[/img]', $this->_pos); 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(); }
public function test_isEmpty2() { $nnode = new ImgBbcodeNode(); $this->assertTrue($nnode->isEmpty()); }