本文整理汇总了PHP中Zend_Markup_Token类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Markup_Token类的具体用法?PHP Zend_Markup_Token怎么用?PHP Zend_Markup_Token使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Markup_Token类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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
示例3: 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
示例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
示例8: _isStopper
/**
* Check if a tag is a stopper
*
* @param array $token
* @param Zend_Markup_Token $current
*
* @return bool
*/
protected function _isStopper(array $token, Zend_Markup_Token $current)
{
switch ($current->getName()) {
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
case 'list':
case 'li':
if ($token['type'] == Zend_Markup_Token::TYPE_TAG && ($token['name'] == 'break' || $token['name'] == 'p')) {
return true;
}
break;
case 'break':
return false;
break;
default:
if ($token['type'] == Zend_Markup_Token::TYPE_TAG && $token['name'] == $current->getName()) {
return true;
}
break;
}
return false;
}
开发者ID:sepano,项目名称:open-social-media-monitoring,代码行数:34,代码来源:Textile.php
示例9: _getMarkupName
/**
* Get the markup name
*
* @param Zend_Markup_Token
*
* @return string
*/
protected function _getMarkupName(Zend_Markup_Token $token)
{
$name = $token->getName();
if (empty($name)) {
return false;
}
return $this->_resolveMarkupName($name);
}
开发者ID:fredcido,项目名称:simuweb,代码行数:15,代码来源:RendererAbstract.php
示例10: _removeFromSearchedStoppers
/**
* Remove from searched stoppers
*
* @param Zend_Markup_Token $token
* @return void
*/
protected function _removeFromSearchedStoppers(Zend_Markup_Token $token)
{
$this->_checkTagDeclaration($token->getName());
foreach ($this->_tags[$token->getName()]['stoppers'] as $stopper) {
--$this->_searchedStoppers[$stopper];
}
}
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:13,代码来源:Bbcode.php
示例11: renderAttributes
/**
* Render some attributes
*
* @param Zend_Markup_Token $token
* @param array $attributes
* @return string
*/
public static function renderAttributes(Zend_Markup_Token $token, array $attributes = array())
{
$attributes = array_merge(self::$_defaultAttributes, $attributes);
$return = '';
$tokenAttributes = $token->getAttributes();
// correct style attribute
if (isset($tokenAttributes['style'])) {
$tokenAttributes['style'] = trim($tokenAttributes['style']);
if ($tokenAttributes['style'][strlen($tokenAttributes['style']) - 1] != ';') {
$tokenAttributes['style'] .= ';';
}
} else {
$tokenAttributes['style'] = '';
}
// special treathment for 'align' and 'color' attribute
if (isset($tokenAttributes['align'])) {
$tokenAttributes['style'] .= 'text-align: ' . $tokenAttributes['align'] . ';';
unset($tokenAttributes['align']);
}
if (isset($tokenAttributes['color']) && self::checkColor($tokenAttributes['color'])) {
$tokenAttributes['style'] .= 'color: ' . $tokenAttributes['color'] . ';';
unset($tokenAttributes['color']);
}
/*
* loop through all the available attributes, and check if there is
* a value defined by the token
* if there is no value defined by the token, use the default value or
* don't set the attribute
*/
foreach ($attributes as $attribute => $value) {
if (isset($tokenAttributes[$attribute]) && !empty($tokenAttributes[$attribute])) {
$return .= ' ' . $attribute . '="' . htmlentities($tokenAttributes[$attribute], ENT_QUOTES, self::getEncoding()) . '"';
} elseif (!empty($value)) {
$return .= ' ' . $attribute . '="' . htmlentities($value, ENT_QUOTES, self::getEncoding()) . '"';
}
}
return $return;
}
开发者ID:sepano,项目名称:open-social-media-monitoring,代码行数:45,代码来源:Html.php
注:本文中的Zend_Markup_Token类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论