public static externalUrl ( string $url, boolean $tag = false ) : string | ||
$url | string | The external URL to link to. |
$tag | boolean | If true, a complete tag is returned, only the url otherwise. |
리턴 | string | The link to the dereferrer script. |
public static function externalUrl($url, $tag = false)
{
if (!isset($_GET[session_name()]) || Horde_String::substr($url, 0, 1) == '#' || Horde_String::substr($url, 0, 7) == 'mailto:') {
$ext = $url;
} else {
$ext = self::signQueryString($GLOBALS['registry']->getServiceLink('go', 'horde')->add('url', $url));
}
if ($tag) {
$ext = self::link($ext, $url, '', '_blank');
}
return $ext;
}
/** * Renders a token into text matching the requested format. * * @param array $options The "options" portion of the token (second * element). * * @return string The text rendered from the token options. */ public function token($options) { if (!isset($options['attr']['alt'])) { $options['attr']['alt'] = $options['src']; } if (strpos($options['src'], '://') === false) { if ($options['src'][0] != '/') { if (strpos($options['src'], ':')) { list($page, $options['src']) = explode(':', $options['src'], 2); } else { $page = Horde_Util::getFormData('page'); if ($page == 'EditPage') { $page = Horde_Util::getFormData('referrer'); } if (empty($page)) { $page = 'Wiki/Home'; } } $params = array('page' => $page, 'mime' => '1', 'file' => $options['src']); $options['src'] = $GLOBALS['registry']->downloadUrl($options['src'], $params)->setRaw(true); } } else { $options['src'] = new Horde_Url(Horde::externalUrl($options['src'])); $options['src']->setRaw(true); } // Send external links through Horde::externalUrl(). if (isset($options['attr']['link']) && strpos($options['attr']['link'], '://')) { $href = htmlspecialchars($options['attr']['link']); unset($options['attr']['link']); return Horde::link(Horde::externalUrl($href), $href) . $this->_token($options) . '</a>'; } else { return $this->_token($options); } }