本文整理汇总了PHP中JApplicationWeb::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationWeb::redirect方法的具体用法?PHP JApplicationWeb::redirect怎么用?PHP JApplicationWeb::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationWeb
的用法示例。
在下文中一共展示了JApplicationWeb::redirect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirect
/**
* Redirect to another URL.
*
* If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently"
* or "303 See Other" code in the header pointing to the new location. If the headers have already been
* sent this will be accomplished using a JavaScript statement.
*
* @param string $url The URL to redirect to. Can only be http/https URL
* @param boolean $moved True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed.
*
* @return void
*
* @since 3.2
*/
public function redirect($url, $moved = false)
{
// Handle B/C by checking if a message was passed to the method, will be removed at 4.0
if (func_num_args() > 1) {
$args = func_get_args();
/*
* Do some checks on the $args array, values below correspond to legacy redirect() method
*
* $args[0] = $url
* $args[1] = Message to enqueue
* $args[2] = Message type
* $args[3] = $moved
*/
if (isset($args[1]) && !empty($args[1]) && !is_bool($args[1])) {
// Log that passing the message to the function is deprecated
JLog::add('Passing a message and message type to JFactory::getApplication()->redirect() is deprecated. ' . 'Please set your message via JFactory::getApplication()->enqueueMessage() prior to calling redirect().', JLog::WARNING, 'deprecated');
$message = $args[1];
// Set the message type if present
if (isset($args[2]) && !empty($args[2])) {
$type = $args[2];
} else {
$type = 'message';
}
// Enqueue the message
$this->enqueueMessage($message, $type);
// Reset the $moved variable
$moved = isset($args[3]) ? (bool) $args[3] : false;
}
}
// Persist messages if they exist.
if (count($this->_messageQueue)) {
$session = JFactory::getSession();
$session->set('application.queue', $this->_messageQueue);
}
// Hand over processing to the parent now
parent::redirect($url, $moved);
}
示例2: redirect
/**
* Redirect to another URL.
*
* If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently"
* or "303 See Other" code in the header pointing to the new location. If the headers have already been
* sent this will be accomplished using a JavaScript statement.
*
* @param string $url The URL to redirect to. Can only be http/https URL
* @param integer $status The HTTP 1.1 status code to be provided. 303 is assumed by default.
*
* @return void
*
* @since 3.2
*/
public function redirect($url, $status = 303)
{
// Handle B/C by checking if a message was passed to the method, will be removed at 4.0
if (func_num_args() > 1) {
$args = func_get_args();
/*
* Do some checks on the $args array, values below correspond to legacy redirect() method
*
* $args[0] = $url
* $args[1] = Message to enqueue
* $args[2] = Message type
* $args[3] = $status (previously moved)
*/
if (isset($args[1]) && !empty($args[1]) && (!is_bool($args[1]) && !is_int($args[1]))) {
// Log that passing the message to the function is deprecated
$this->getLogger()->warning('Passing a message and message type to ' . __METHOD__ . '() is deprecated. ' . 'Please set your message via ' . __CLASS__ . '::enqueueMessage() prior to calling ' . __CLASS__ . '::redirect().', array('category' => 'deprecated'));
$message = $args[1];
// Set the message type if present
if (isset($args[2]) && !empty($args[2])) {
$type = $args[2];
} else {
$type = 'message';
}
// Enqueue the message
$this->enqueueMessage($message, $type);
// Reset the $moved variable
$status = isset($args[3]) ? (bool) $args[3] : false;
}
}
// Persist messages if they exist.
if (count($this->messageQueue)) {
$this->getSession()->set('application.queue', $this->messageQueue);
}
// Hand over processing to the parent now
parent::redirect($url, $status);
}