当前位置: 首页>>代码示例>>PHP>>正文


PHP BBCode::getURLTargetable方法代码示例

本文整理汇总了PHP中BBCode::getURLTargetable方法的典型用法代码示例。如果您正苦于以下问题:PHP BBCode::getURLTargetable方法的具体用法?PHP BBCode::getURLTargetable怎么用?PHP BBCode::getURLTargetable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BBCode的用法示例。


在下文中一共展示了BBCode::getURLTargetable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doURL

 /**
  * Format a [url] tag by producing an <a>...</a> element.
  *
  * The URL only allows http, https, mailto, and ftp protocols for safety.
  *
  * @param BBCode $bbcode The {@link BBCode} object doing the parsing.
  * @param int $action The current action being performed on the tag.
  * @param string $name The name of the tag.
  * @param string $default The default value passed to the tag in the form: `[tag=default]`.
  * @param array $params All of the parameters passed to the tag.
  * @param string $content The content of the tag. Only available when {@link $action} is **BBCODE_OUTPUT**.
  * @return string Returns the full HTML url.
  */
 public function doURL(BBCode $bbcode, $action, $name, $default, $params, $content)
 {
     // We can't check this with BBCODE_CHECK because we may have no URL
     // before the content has been processed.
     if ($action == BBCode::BBCODE_CHECK) {
         return true;
     }
     $url = is_string($default) ? $default : $bbcode->unHTMLEncode(strip_tags($content));
     if ($bbcode->isValidURL($url)) {
         if ($bbcode->debug) {
             Debugger::debug('ISVALIDURL');
         }
         if ($bbcode->getURLTargetable() !== false && isset($params['target'])) {
             $target = ' target="' . htmlspecialchars($params['target']) . '"';
         } else {
             $target = '';
         }
         if ($bbcode->getURLTarget() !== false && empty($target)) {
             $target = ' target="' . htmlspecialchars($bbcode->getURLTarget()) . '"';
         }
         // If $detect_urls is on, it's possble the $content is already
         // enclosed in an <a href> tag. Remove that if that is the case.
         $content = preg_replace('/^\\<a [^\\>]*\\>(.*?)<\\/a>$/', "\\1", $content);
         return $bbcode->fillTemplate($bbcode->getURLTemplate(), array("url" => $url, "target" => $target, "content" => $content));
     } else {
         return htmlspecialchars($params['_tag']) . $content . htmlspecialchars($params['_endtag']);
     }
 }
开发者ID:vanilla,项目名称:nbbc,代码行数:41,代码来源:BBCodeLibrary.php


注:本文中的BBCode::getURLTargetable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。