本文整理汇总了PHP中Horde_Url::setScheme方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Url::setScheme方法的具体用法?PHP Horde_Url::setScheme怎么用?PHP Horde_Url::setScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Url
的用法示例。
在下文中一共展示了Horde_Url::setScheme方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUrlMissingScheme
public function testUrlMissingScheme()
{
$url = new Horde_Url('example.com/test?foo=1&bar=2');
$url->setScheme();
$this->assertEquals('/test?foo=1&bar=2', $url->toString(true, false));
$this->assertEquals('http://example.com/test?foo=1&bar=2', $url->toString(true, true));
}
示例2: _node
/**
*/
protected function _node($doc, $node)
{
parent::_node($doc, $node);
if (empty($this->_imptmp) || !$node instanceof DOMElement) {
if ($node instanceof DOMText && $node->length > 1) {
/* Filter bad language. */
$text = IMP::filterText($node->data);
if ($node->data != $text) {
$node->replaceData(0, $node->length, $text);
}
}
return;
}
$tag = Horde_String::lower($node->tagName);
/* Remove 'height' styles from HTML messages, because it can break
* sizing of IFRAME. */
foreach ($node->attributes as $key => $val) {
if ($key == 'style') {
/* Do simplistic style parsing here. */
$parts = array_filter(explode(';', $val->value));
foreach ($parts as $k2 => $v2) {
if (preg_match("/^\\s*height:\\s*/i", $v2)) {
unset($parts[$k2]);
}
}
$val->value = implode(';', $parts);
}
}
switch ($tag) {
case 'a':
case 'area':
/* Convert links to open in new windows. Ignore mailto: links and
* links that already have a target. */
if ($node->hasAttribute('href')) {
$url = parse_url($node->getAttribute('href'));
if (isset($url['scheme']) && $url['scheme'] == 'mailto') {
/* We don't include HordePopup in IFRAME, so need to use
* 'simple' links. */
$clink = new IMP_Compose_Link($node->getAttribute('href'));
$node->setAttribute('href', $clink->link(true));
$node->removeAttribute('target');
} elseif (!empty($this->_imptmp['inline']) && isset($url['fragment']) && empty($url['path']) && $GLOBALS['browser']->isBrowser('mozilla')) {
/* See Bug #8695: internal anchors are broken in
* Mozilla. */
$node->removeAttribute('href');
} elseif (empty($url)) {
/* Empty URL - remove href/target so the link is not
* clickable. */
$node->removeAttribute('href');
$node->removeAttribute('target');
} else {
$node->setAttribute('target', strval(new Horde_Support_Randomid()));
}
}
break;
case 'body':
$style = $node->hasAttribute('style') ? rtrim($node->getAttribute('style'), ';') . ';' : '';
$node->setAttribute('style', $style . 'width:auto !important');
break;
case 'img':
case 'input':
if ($node->hasAttribute('src')) {
$val = $node->getAttribute('src');
/* Multipart/related. */
if ($tag == 'img' && ($id = $this->_cidSearch($val))) {
$val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', array('params' => array('ctype' => 'image/*', 'id' => $id, 'imp_img_view' => 'data')));
}
/* Block images.*/
if ($this->_imgBlock()) {
if (Horde_Url_Data::isData($val)) {
$url = new Horde_Url_Data($val);
} else {
/* Check for relative URLs. These won't be loaded and
* will cause unnecessary 404 hits to the local web
* server. */
$parsed_url = parse_url($val);
if (isset($parsed_url['host'])) {
$url = new Horde_Url($val);
$url->setScheme();
} else {
$url = null;
}
}
if ($url) {
$node->setAttribute(self::IMGBLOCK, $url);
$node->setAttribute('src', $this->_imgBlockImg());
$this->_imptmp['imgblock'] = true;
} else {
$node->parentNode->removeChild($node);
$this->_imptmp['imgbroken'] = true;
}
} else {
$node->removeAttribute('src');
$node->setAttribute('data-src', $val);
}
}
/* IMG only */
if ($tag == 'img' && $this->_imgBlock() && $node->hasAttribute('srcset')) {
//.........这里部分代码省略.........