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


PHP BBCode::isValidURL方法代碼示例

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


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

示例1: doQuote

 /**
  * Format a [quote] tag.
  *
  * This tag can come in a variety of flavors:
  *
  * ```
  * [quote]...[/quote]
  * [quote=Tom]...[/quote]
  * [quote name="Tom"]...[/quote]
  * ```
  *
  * In the third form, you can also add a date="" parameter to display the date
  * on which Tom wrote it, and you can add a url="" parameter to turn the author's
  * name into a link.  A full example might be:
  *
  * ```
  * [quote name="Tom" date="July 4, 1776 3:48 PM" url="http://www.constitution.gov"]...[/quote]
  * ```
  *
  * The URL only allows http, https, mailto, gopher, ftp, and feed 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 bool|string Returns the quote HTML or **true** if {@link $action} is **BBCode::BBCODE_CHECK**.
  */
 public function doQuote(BBCode $bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == BBCode::BBCODE_CHECK) {
         return true;
     }
     if (isset($params['name'])) {
         $title = htmlspecialchars(trim($params['name'])) . " wrote";
         if (isset($params['date'])) {
             $title .= " on " . htmlspecialchars(trim($params['date']));
         }
         $title .= ":";
         if (isset($params['url'])) {
             $url = trim($params['url']);
             if ($bbcode->isValidURL($url)) {
                 $title = "<a href=\"" . htmlspecialchars($params['url']) . "\">" . $title . "</a>";
             }
         }
     } elseif (!is_string($default)) {
         $title = "Quote:";
     } else {
         $title = htmlspecialchars(trim($default)) . " wrote:";
     }
     return $bbcode->fillTemplate($bbcode->getQuoteTemplate(), array("title" => $title, "content" => $content));
 }
開發者ID:vanilla,項目名稱:nbbc,代碼行數:53,代碼來源:BBCodeLibrary.php


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