SimplePhpPageBuilder::startElement PHP Method

startElement() public method

Start of element event. Opens a new tag.
public startElement ( string $name, hash $attributes ) : boolean
$name string Element name.
$attributes hash Attributes without content are marked as true.
return boolean False on parse error.
    public function startElement($name, $attributes)
    {
        $factory = new SimpleTagBuilder();
        $tag = $factory->createTag($name, $attributes);
        if (!$tag) {
            return true;
        }
        if ($tag->getTagName() === 'label') {
            $this->acceptLabelStart($tag);
            $this->openTag($tag);
            return true;
        }
        if ($tag->getTagName() === 'form') {
            $this->acceptFormStart($tag);
            return true;
        }
        if ($tag->getTagName() === 'frameset') {
            $this->acceptFramesetStart($tag);
            return true;
        }
        if ($tag->getTagName() === 'frame') {
            $this->acceptFrame($tag);
            return true;
        }
        if ($tag->isPrivateContent() && !isset($this->private_content_tag)) {
            $this->private_content_tag = $tag;
        }
        if ($tag->expectEndTag()) {
            $this->openTag($tag);
            return true;
        }
        $this->acceptTag($tag);
        return true;
    }

Usage Example

コード例 #1
0
 /**
  *    Accepts a token from the tag mode. If the
  *    starting element completes then the element
  *    is dispatched and the current attributes
  *    set back to empty. The element or attribute
  *    name is converted to lower case.
  *    @param string $token     Incoming characters.
  *    @param integer $event    Lexer event type.
  *    @return boolean          False if parse error.
  *    @access public
  */
 function acceptStartToken($token, $event)
 {
     if ($event == LEXER_ENTER) {
         $this->tag = strtolower(substr($token, 1));
         return true;
     }
     if ($event == LEXER_EXIT) {
         $success = $this->listener->startElement($this->tag, $this->attributes);
         $this->tag = '';
         $this->attributes = array();
         return $success;
     }
     if ($token != '=') {
         $this->current_attribute = strtolower(html_entity_decode($token, ENT_QUOTES));
         $this->attributes[$this->current_attribute] = '';
     }
     return true;
 }