當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Markup_Token::addAttribute方法代碼示例

本文整理匯總了PHP中Zend_Markup_Token::addAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Markup_Token::addAttribute方法的具體用法?PHP Zend_Markup_Token::addAttribute怎麽用?PHP Zend_Markup_Token::addAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Markup_Token的用法示例。


在下文中一共展示了Zend_Markup_Token::addAttribute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _createTree

 /**
  * Create a tree from the tokenized text
  *
  * @return void
  */
 protected function _createTree()
 {
     $inside = true;
     foreach ($this->_tokens as $key => $token) {
         // first check if the token is a stopper
         if ($this->_isStopper($token, $this->_current)) {
             if ($this->_current->getName() == 'li') {
                 // list items are handled differently
                 if (isset($this->_tokens[$key + 1]) && $this->_tokens[$key + 1]['type'] == Zend_Markup_Token::TYPE_TAG && $this->_tokens[$key + 1]['name'] == 'list') {
                     // the next item is a correct tag
                     $this->_current->setStopper($token['tag']);
                     $this->_current = $this->_current->getParent();
                 } else {
                     // close the list
                     $this->_current->setStopper($token['tag']);
                     $this->_current = $this->_current->getParent()->getParent();
                     // go up in the tree until we found the end
                     while ($this->_isStopper($token, $this->_current)) {
                         $this->_current->setStopper($token['tag']);
                         $this->_current = $this->_current->getParent();
                     }
                 }
             } else {
                 // go up in the tree until we found the end of stoppers
                 while ($this->_isStopper($token, $this->_current)) {
                     $this->_current->setStopper($token['tag']);
                     if (!empty($token['attributes'])) {
                         foreach ($token['attributes'] as $name => $value) {
                             $this->_current->addAttribute($name, $value);
                         }
                     }
                     $this->_current = $this->_current->getParent();
                 }
             }
             $inside = true;
         } elseif ($token['type'] == Zend_Markup_Token::TYPE_TAG && $inside) {
             if ($token['name'] == 'break') {
                 // add the newline and continue parsing
                 $this->_current->addChild(new Zend_Markup_Token($token['tag'], Zend_Markup_Token::TYPE_NONE, '', array(), $this->_current));
             } else {
                 // handle a list item
                 if ($token['name'] == 'list') {
                     $attributes = array();
                     if (isset($token['attributes']['list'])) {
                         $attributes['list'] = $token['attributes']['list'];
                         unset($token['attributes']['list']);
                     }
                     if ($this->_current->getName() != 'list') {
                         // the list isn't started yet, create it
                         $child = new Zend_Markup_Token('', Zend_Markup_Token::TYPE_TAG, 'list', $attributes, $this->_current);
                         $this->_current->addChild($child);
                         $this->_current = $child;
                     }
                     $token['name'] = 'li';
                 } elseif ($token['name'] == 'img' || $token['name'] == 'url') {
                     $inside = false;
                 }
                 // add the token
                 $child = new Zend_Markup_Token($token['tag'], Zend_Markup_Token::TYPE_TAG, $token['name'], $token['attributes'], $this->_current);
                 $this->_current->addChild($child);
                 $this->_current = $child;
             }
         } else {
             // simply add the token as text
             $this->_current->addChild(new Zend_Markup_Token($token['tag'], Zend_Markup_Token::TYPE_NONE, '', array(), $this->_current));
         }
     }
 }
開發者ID:sepano,項目名稱:open-social-media-monitoring,代碼行數:73,代碼來源:Textile.php


注:本文中的Zend_Markup_Token::addAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。