本文整理汇总了PHP中JUri::setFragment方法的典型用法代码示例。如果您正苦于以下问题:PHP JUri::setFragment方法的具体用法?PHP JUri::setFragment怎么用?PHP JUri::setFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUri
的用法示例。
在下文中一共展示了JUri::setFragment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReferrer
/**
* Get the referrer page.
*
* If there's no referrer or it's external, Kunena will return default page.
* Also referrers back to tasks are removed.
*
* @param string $default Default page to return into.
* @param string $anchor Anchor (location in the page).
*
* @return string
*/
public static function getReferrer($default = null, $anchor = null)
{
$app = JFactory::getApplication();
$referrer = $app->input->server->getString('HTTP_REFERER');
if ($referrer)
{
$uri = new JUri($referrer);
// Make sure we do not return into a task -- or if task is SEF encoded, make sure it fails.
$uri->delVar('task');
$uri->delVar(JSession::getFormToken());
// Check that referrer was from the same domain and came from the Joomla frontend or backend.
$base = $uri->toString(array('scheme', 'host', 'port', 'path'));
$host = $uri->toString(array('scheme', 'host', 'port'));
// Referrer should always have host set and it should come from the same base address.
if (empty($host) || stripos($base, JUri::base()) !== 0)
{
$uri = null;
}
}
if (!isset($uri))
{
if ($default == null)
{
$default = $app->isSite() ? 'index.php?option=com_kunena' : 'administrator/index.php?option=com_kunena';
}
$default = self::_($default);
$uri = new JUri($default);
}
if ($anchor)
{
$uri->setFragment($anchor);
}
return $uri->toString(array('path', 'query', 'fragment'));
}
示例2: testSetFragment
/**
* Test the setFragment method.
*
* @return void
*
* @since 11.1
* @covers JUri::setFragment
*/
public function testSetFragment()
{
$this->object->setFragment('someFragment');
$this->assertThat($this->object->getFragment(), $this->equalTo('someFragment'));
}