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


PHP Zend_Markup_Token::getAttribute方法代碼示例

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


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

示例1: convert

    /**
     * Convert the token
     *
     * @param Zend_Markup_Token $token
     * @param string $text
     *
     * @return string
     */
    public function convert(Zend_Markup_Token $token, $text)
    {
        $type = null;
        if ($token->hasAttribute('list')) {
            // because '01' == '1'
            if ($token->getAttribute('list') === '01') {
                $type = 'decimal-leading-zero';
            } else {
                switch ($token->getAttribute('list')) {
                    case '1':
                        $type = 'decimal';
                        break;
                    case 'i':
                        $type = 'lower-roman';
                        break;
                    case 'I':
                        $type = 'upper-roman';
                        break;
                    case 'a':
                        $type = 'lower-alpha';
                        break;
                    case 'A':
                        $type = 'upper-alpha';
                        break;

                    // the following type is unsupported by IE (including IE8)
                    case 'alpha':
                        $type = 'lower-greek';
                        break;

                    // the CSS names itself
                    case 'armenian': // unsupported by IE (including IE8)
                    case 'decimal':
                    case 'decimal-leading-zero': // unsupported by IE (including IE8)
                    case 'georgian': // unsupported by IE (including IE8)
                    case 'lower-alpha':
                    case 'lower-greek': // unsupported by IE (including IE8)
                    case 'lower-latin': // unsupported by IE (including IE8)
                    case 'lower-roman':
                    case 'upper-alpha':
                    case 'upper-latin': // unsupported by IE (including IE8)
                    case 'upper-roman':
                        $type = $token->getAttribute('list');
                        break;
                }
            }
        }

        if (null !== $type) {
            return "<ol style=\"list-style-type: {$type}\">{$text}</ol>";
        } else {
            return "<ul>{$text}</ul>";
        }
    }
開發者ID:nhp,項目名稱:shopware-4,代碼行數:62,代碼來源:List.php

示例2: convert

 /**
  * Convert the token
  *
  * @param Zend_Markup_Token $token
  * @param string $text
  *
  * @return string
  */
 public function convert(Zend_Markup_Token $token, $text)
 {
     $uri = $text;
     if (!preg_match('/^([a-z][a-z+\\-.]*):/i', $uri)) {
         $uri = 'http://' . $uri;
     }
     // check if the URL is valid
     if (!Zend_Markup_Renderer_Html::isValidUri($uri)) {
         return $text;
     }
     if ($token->hasAttribute('alt')) {
         $alt = $token->getAttribute('alt');
     } else {
         // try to get the alternative from the URL
         $alt = rtrim($text, '/');
         $alt = strrchr($alt, '/');
         if (false !== strpos($alt, '.')) {
             $alt = substr($alt, 1, strpos($alt, '.') - 1);
         }
     }
     // run the URI and alt through htmlentities
     $uri = htmlentities($uri, ENT_QUOTES, Zend_Markup_Renderer_Html::getEncoding());
     $alt = htmlentities($alt, ENT_QUOTES, Zend_Markup_Renderer_Html::getEncoding());
     return "<img src=\"{$uri}\" alt=\"{$alt}\"" . Zend_Markup_Renderer_Html::renderAttributes($token) . " />";
 }
開發者ID:be-dmitry,項目名稱:zf1,代碼行數:33,代碼來源:Img.php

示例3: convert

 /**
  * Convert the token
  *
  * @param Zend_Markup_Token $token
  * @param string $text
  *
  * @return string
  */
 public function convert(Zend_Markup_Token $token, $text)
 {
     $bar = $token->getAttribute('bar');
     if (!empty($bar)) {
         $bar = '=' . $bar;
     }
     return "[foo{$bar}]" . $text . '[/foo]';
 }
開發者ID:sasezaki,項目名稱:mirror-zf1-tests,代碼行數:16,代碼來源:Bar.php

示例4: convert

 /**
  * Convert the token
  *
  * @param Zend_Markup_Token $token
  * @param string $text
  *
  * @return string
  */
 public function convert(Zend_Markup_Token $token, $text)
 {
     if ($token->hasAttribute('url')) {
         $url = $token->getAttribute('url');
     } else {
         $url = $text;
     }
     //if (subs)
     // check if the URL is valid
     if (!Zend_Uri::check($url)) {
         return $text;
     }
     $attributes = Zend_Markup_Renderer_Html::renderAttributes($token);
     return "<a href=\"{$url}\"{$attributes}>{$text}</a>";
 }
開發者ID:kdambekalns,項目名稱:framework-benchs,代碼行數:23,代碼來源:Url.php

示例5: convert

 public function convert(Zend_Markup_Token $token, $text)
 {
     $user = '';
     if ($token->hasAttribute(self::ATTRIBUTE_USER)) {
         $user = $token->getAttribute(self::ATTRIBUTE_USER);
         $wrote = $this->_token_wrote[self::TOKEN_WROTE];
         if (Zend_Registry::isRegistered('Zend_Translate')) {
             $translator = Zend_Registry::get('Zend_Translate');
             if ($translator->isTranslated(self::TOKEN_WROTE)) {
                 $wrote = $translator->translate(self::TOKEN_WROTE);
             } else {
                 $wrote = $translator->translate($wrote);
             }
         }
         $user = '<div class="quote_author">' . $user . ' ' . $wrote . ':</div>';
     }
     return "<blockquote>{$user}{$text}</blockquote>";
 }
開發者ID:BGCX262,項目名稱:zweer-gdr-svn-to-git,代碼行數:18,代碼來源:Quote.php

示例6: convert

 /**
  * Convert the token
  *
  * @param Zend_Markup_Token $token
  * @param string $text
  *
  * @return string
  */
 public function convert(Zend_Markup_Token $token, $text)
 {
     if ($token->hasAttribute('url')) {
         $uri = $token->getAttribute('url');
     } else {
         $uri = $text;
     }
     if (!preg_match('/^([a-z][a-z+\\-.]*):/i', $uri)) {
         $uri = 'http://' . $uri;
     }
     // check if the URL is valid
     if (!Zend_Markup_Renderer_Html::isValidUri($uri)) {
         return $text;
     }
     $attributes = Zend_Markup_Renderer_Html::renderAttributes($token);
     // run the URI through htmlentities
     $uri = htmlentities($uri, ENT_QUOTES, Zend_Markup_Renderer_Html::getEncoding());
     return "<a href=\"{$uri}\"{$attributes}>{$text}</a>";
 }
開發者ID:par-orillonsoft,項目名稱:Magento,代碼行數:27,代碼來源:Url.php

示例7: convert

 /**
  * Convert the token
  *
  * @param Zend_Markup_Token $token
  * @param string $text
  *
  * @return string
  */
 public function convert(Zend_Markup_Token $token, $text)
 {
     $url = $text;
     // check if the URL is valid
     if (!Zend_Uri::check($url)) {
         return $text;
     }
     if ($token->hasAttribute('alt')) {
         $alt = $token->getAttribute('alt');
     } else {
         // try to get the alternative from the URL
         $alt = rtrim($text, '/');
         $alt = strrchr($alt, '/');
         if (false !== strpos($alt, '.')) {
             $alt = substr($alt, 1, strpos($alt, '.') - 1);
         }
     }
     return "<img src=\"{$url}\" alt=\"{$alt}\"" . Zend_Markup_Renderer_Html::renderAttributes($token) . " />";
 }
開發者ID:kdambekalns,項目名稱:framework-benchs,代碼行數:27,代碼來源:Img.php


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