本文整理汇总了PHP中KRequest::url方法的典型用法代码示例。如果您正苦于以下问题:PHP KRequest::url方法的具体用法?PHP KRequest::url怎么用?PHP KRequest::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KRequest
的用法示例。
在下文中一共展示了KRequest::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _actionApply
protected function _actionApply(KCommandContext $context)
{
$data = $context->caller->execute('edit', $context);
$url = clone KRequest::url();
$this->setRedirect($url);
return $data;
}
示例2: _actionRequest
protected function _actionRequest(KCommandContext $context)
{
if (!($email = KRequest::get('post.email', 'email'))) {
$this->setRedirect(KRequest::referrer(), JText::_('INVALID_EMAIL_ADDRESS'), 'error');
return false;
}
$user = $this->getService('com://site/users.model.users')->set('email', $email)->getItem();
if (!$user->id || $user->block) {
$this->setRedirect(KRequest::referrer(), JText::_('COULD_NOT_FIND_USER'), 'error');
return false;
}
$helper = $this->getService('com://site/users.helper.password');
$token = $helper->getHash($helper->getRandom());
$salt = $helper->getSalt($token);
$user->activation = md5($token . $salt) . ':' . $salt;
$user->save();
$configuration = JFactory::getConfig();
$site_name = $configuration->getValue('sitename');
$site_url = KRequest::url()->get(KHttpUrl::SCHEME | KHttpUrl::HOST | KHttpUrl::PORT);
$url = $site_url . JRoute::_('index.php?option=com_users&view=reset&layout=confirm');
$from_email = $configuration->getValue('mailfrom');
$from_name = $configuration->getValue('fromname');
$subject = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TITLE', $site_name);
$body = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TEXT', $site_name, $token, $url);
if (!JUtility::sendMail($from_email, $from_name, $email, $subject, $body)) {
$this->setRedirect(KRequest::referrer(), JText::_('ERROR_SENDING_CONFIRMATION_EMAIL'), 'error');
return false;
} else {
$this->_redirect = 'index.php?option=com_users&view=reset&layout=confirm';
}
}
示例3: sort
/**
* Render a sorting header
* more language string suckyneess
*
* @param array An optional array with configuration options
* @return string Html
*/
public function sort($config = array())
{
$config = new KConfig($config);
$config->append(array('title' => '', 'column' => '', 'direction' => 'asc', 'sort' => ''));
//Set the title
if (empty($config->title)) {
$config->title = ucfirst($config->column);
}
//Set the direction
$direction = strtolower($config->direction);
$direction = in_array($direction, array('asc', 'desc')) ? $direction : 'asc';
//Set the class
$class = '';
if ($config->column == $config->sort) {
$direction = $direction == 'desc' ? 'asc' : 'desc';
// toggle
$class = 'class="-koowa-' . $direction . '"';
}
$url = clone KRequest::url();
$query = $url->getQuery(1);
$query['sort'] = $config->column;
$query['direction'] = $direction;
$url->setQuery($query);
$html = '<a href="' . $url . '" title="' . JText::_('COM_PORTFOLIO_CLICK_TO_SORT') . '" ' . $class . '>';
$html .= JText::_($config->title);
$html .= '</a>';
return $html;
}
示例4: display
public function display()
{
$category = $this->getService('com://site/weblinks.model.categories')->getItem();
$items = $this->getService('com://site/weblinks.model.weblinks')->catid(KRequest::get('get.id', 'int'))->getList();
$xml = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
$xml .= '<rss version="2.0">' . PHP_EOL;
$xml .= '<channel>' . PHP_EOL;
$xml .= ' <title>' . $category->title . '</title>' . PHP_EOL;
$xml .= ' <description><![CDATA[' . $category->description . ']]></description>' . PHP_EOL;
$xml .= ' <link>' . KRequest::url() . '</link>' . PHP_EOL;
$xml .= ' <lastBuildDate>' . date('r') . '</lastBuildDate>' . PHP_EOL;
$xml .= ' <generator>' . JURI::base() . '</generator>' . PHP_EOL;
$xml .= ' <language>' . JFactory::getLanguage()->getTag() . '</language>' . PHP_EOL;
foreach ($items as $item) {
$xml .= ' <item>' . PHP_EOL;
$xml .= ' <title>' . htmlspecialchars($item->title) . '</title>' . PHP_EOL;
$xml .= ' <link>' . JURI::base() . JRoute::_('index.php?option=com_weblinks&view=weblink&id=' . $item->id) . '</link>' . PHP_EOL;
$xml .= ' <guid>' . JURI::base() . JRoute::_('index.php?option=com_weblinks&view=weblink&id=' . $item->id) . '</guid>' . PHP_EOL;
$xml .= ' <description><![CDATA[' . htmlspecialchars($item->description) . ']]></description>' . PHP_EOL;
$xml .= ' <category>' . $category->title . '</category>' . PHP_EOL;
$xml .= ' <pubDate>' . date('r', strtotime($item->date)) . '</pubDate>' . PHP_EOL;
$xml .= ' </item>' . PHP_EOL;
}
$xml .= '</channel>' . PHP_EOL;
$xml .= '</rss>';
$this->output = $xml;
return parent::display();
}
示例5: display
public function display()
{
$items = $this->getModel()->getList();
$root = KRequest::url()->get(KHttpUri::PART_BASE ^ KHttpUri::PART_PATH);
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
$xml .= '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom">';
$xml .= '<channel>';
$xml .= '<title>Posts RSS feed</title>';
$xml .= '<description>RSS description</description>';
$xml .= '<generator>' . JURI::base() . '</generator>';
foreach ($items as $item) {
$xml .= '<item>';
$xml .= '<title>' . htmlspecialchars($item->title) . '</title>';
$xml .= '<link>' . $root . JRoute::_('index.php?option=com_ninjaboard&view=topic&id=' . $item->ninjaboard_topic_id . '&post=' . $item->id . '#p' . $item->id) . '</link>';
$xml .= '<description>' . htmlspecialchars(KFactory::get('admin::com.ninja.helper.bbcode')->parse(array('text' => $item->text))) . '</description>';
$xml .= '<guid isPermaLink="false">' . $item->uuid . '</guid>';
$xml .= '<media:title>' . htmlspecialchars($item->title) . '</media:title> ';
$xml .= '<media:content url="' . $root . JRoute::_('index.php?option=com_ninjaboard&view=avatar&id=' . $item->created_by . '&format=file') . '"/>';
$xml .= '</item>';
}
$xml .= '</channel>';
$xml .= '</rss>';
$this->output = $xml;
return parent::display();
}
示例6: onBeforeDispatcherDispatch
public function onBeforeDispatcherDispatch(KEvent $event)
{
$application = JFactory::getApplication();
if ($application->getName() != 'site') {
return;
}
//var_dump($_SERVER); exit();
// check if SSO header is set
$personnumber = KRequest::get('server.HTTP_P_SSO_IDENTIFIER', 'alnum');
if (empty($personnumber) || !preg_match('/P\\d+/is', $personnumber)) {
// TODO set proper http response
throw new KException('Access not allowed');
}
// check if user is already logged in
$user = JFactory::getUser();
// make sure personnumber is still the same
if (!$user->guest && $user->username != $personnumber) {
$application->logout();
$application->redirect(KRequest::url());
}
if ($user->guest) {
$credentials = array('username' => $personnumber, 'password' => $personnumber);
$result = $application->login($credentials, array());
if (JError::isError($result)) {
// TODO set proper http response
throw new KException($result->getError());
} else {
$application->redirect('index.php');
}
}
}
示例7: redirectHttps
/**
* Redirects to HTTPs
*
* @param KCommandContext $context
*
* @return void
*/
public function redirectHttps(KCommandContext $context)
{
if (KRequest::url()->scheme == 'http') {
$url = clone KRequest::url();
$url->scheme = 'https';
$context->response->setRedirect($url);
return false;
}
}
示例8: _actionDispatch
/**
* Dispatch the controller and redirect
*
* This function divert the standard behavior and will redirect if no view
* information can be found in the request.
*
* @param string The view to dispatch. If null, it will default to
* retrieve the controller information from the request or
* default to the component name if no controller info can
* be found.
*
* @return KDispatcherDefault
*/
protected function _actionDispatch(KCommandContext $context)
{
//Redirect if no view information can be found in the request
if (!KRequest::has('get.view')) {
$url = clone KRequest::url();
$url->query['view'] = $this->getController()->getView()->getName();
JFactory::getApplication()->redirect($url);
}
return parent::_actionDispatch($context);
}
示例9: _validate
/**
* Validate a value
*
* @param scalar Value to be validated
* @return bool True when the variable is valid
*/
protected function _validate($value)
{
if (!is_string($value)) {
return false;
}
if (stripos($value, (string) dirname(KRequest::url()->get(KHttpUrl::BASE))) !== 0) {
return false;
}
return true;
}
示例10: _validate
/**
* Validate a value
*
* @param scalar Value to be validated
* @return bool True when the variable is valid
*/
protected function _validate($value)
{
if (!is_string($value)) {
return false;
}
if (stripos($value, (string) KRequest::url()->get(KHttpUrl::AUTHORITY)) !== 0) {
return false;
}
return true;
}
示例11: setCanonical
/**
* Set the canonical meta info to eliminate duplicate content
*/
public function setCanonical(KCommandContext $context)
{
$document = KFactory::get('lib.joomla.document');
$root = KRequest::url()->get(KHttpUri::PART_BASE ^ KHttpUri::PART_PATH);
$base = 'index.php?option=com_ninjaboard&view=forum';
//@TODO figure out a way to get the states from the posts model
$canonical = $root . JRoute::_($base . '&id=' . $context->result->id);
if (method_exists($document, 'addCustomTag')) {
$document->addCustomTag('<link rel="canonical" href="' . $canonical . '" />');
}
}
示例12: _actionDispatch
/**
* Dispatch the controller and redirect
*
* This function divert the standard behavior and will redirect if no view
* information can be found in the request.
*
* @param string The view to dispatch. If null, it will default to
* retrieve the controller information from the request or
* default to the component name if no controller info can
* be found.
*
* @return KDispatcherDefault
*/
protected function _actionDispatch(KCommandContext $context)
{
//Redirect if no view information can be found in the request
if (!KRequest::has('get.view')) {
$view = count($context->data) ? $context->data : $this->_controller_default;
$url = clone KRequest::url();
$url->query['view'] = $view;
KFactory::get('lib.joomla.application')->redirect($url);
}
return parent::_actionDispatch($context);
}
示例13: _actionPurge
protected function _actionPurge(KCommandContext $context)
{
//Purge the cache
if (JFactory::getCache('')->gc()) {
$this->_redirect_message = JText::_('Expired items have been purged');
} else {
$this->_redirect_message = JText::_('Error purging expired items');
}
$this->_redirect = KRequest::url();
return true;
}
示例14: getLink
public function getLink()
{
// Unset limit and offset
$url = clone KRequest::url();
$query = parse_str($url->getQuery(), $vars);
unset($vars['limit']);
unset($vars['offset']);
$vars['format'] = 'csv';
$url->setQuery(http_build_query($vars));
return (string) $url;
}
示例15: setCanonical
/**
* Set the canonical meta info to eliminate duplicate content
*/
public function setCanonical(KCommandContext $context)
{
$document = KFactory::get('lib.joomla.document');
$root = KRequest::url()->get(KHttpUri::PART_BASE ^ KHttpUri::PART_PATH);
$base = 'index.php?option=com_ninjaboard&view=topic';
$append = $this->getRequest()->layout != 'default' ? '&layout=' . $this->getRequest()->layout : '';
$state = $this->getModel()->getState();
$canonical = $root . JRoute::_($base . '&id=' . $context->id . '&limit=' . $state->limit . '&offset=' . $state->offset . $append);
if (method_exists($document, 'addCustomTag')) {
$document->addCustomTag('<link rel="canonical" href="' . $canonical . '" />');
}
}