コード例 #1
0
ファイル: class.bbcode.php プロジェクト: vanilla/vanilla
 /**
  * Perform formatting against a string for the img tag.
  *
  * @param Nbbc $bbcode Instance of Nbbc doing the parsing.
  * @param int $action Value of one of NBBC's defined constants.  Typically, this will be BBCODE_CHECK.
  * @param string $name Name of the tag.
  * @param string $default Value of the _default parameter, from the $params array.
  * @param array $params A standard set parameters related to the tag.
  * @param string $content Value between the open and close tags, if any.
  * @return bool|string Formatted value.
  */
 function doImage($bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == Nbbc::BBCODE_CHECK) {
         return true;
     }
     $content = trim($bbcode->unHtmlEncode(strip_tags($content)));
     if (!$content && $default) {
         $content = $default;
     }
     if ($bbcode->isValidUrl($content, false)) {
         return "<img src=\"" . htmlspecialchars($content) . "\" alt=\"" . htmlspecialchars(basename($content)) . "\" class=\"bbcode_img\" />";
     }
     return htmlspecialchars($params['_tag']) . htmlspecialchars($content) . htmlspecialchars($params['_endtag']);
 }