protected function _actionApply(KCommandContext $context)
 {
     $data = $context->caller->execute('edit', $context);
     $url = clone KRequest::url();
     $this->setRedirect($url);
     return $data;
 }
示例#2
0
 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
0
 /**
  * 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
0
 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
0
 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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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;
 }
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 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
0
 /**
  * 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 . '" />');
     }
 }
示例#16
0
 protected function _actionDispatch(KCommandContext $context)
 {
     if (KRequest::method() == KHttpRequest::GET) {
         $view = KRequest::get('get.view', 'cmd', $this->_controller);
         if ($view == 'modules' && !KRequest::has('get.application')) {
             $url = clone KRequest::url();
             $url->query['application'] = 'site';
             JFactory::getApplication()->redirect($url);
         }
     }
     return parent::_actionDispatch($context);
 }
示例#17
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  *
  * @return void
  */
 protected function _initialize(KConfig $config)
 {
     if (!$config->base_url) {
         $base = clone KRequest::base();
         foreach (array('host', 'scheme', 'port', 'user', 'pass') as $part) {
             $base->{$part} = KRequest::url()->{$part};
         }
         $config->base_url = $base;
     }
     $config->append(array('enable_rewrite' => false, 'url' => clone KService::get('koowa:http.url')));
     parent::_initialize($config);
 }
示例#18
0
 public function __construct(KConfig $options)
 {
     $this->setMethod('edit');
     parent::__construct($options);
     $this->attribs->class .= ' invalid';
     $url = clone KRequest::url();
     $query = $url->getQuery(1);
     if (empty($query['view'])) {
         return;
     }
     $query['view'] = KInflector::singularize($query['view']);
     $url->setQuery($query);
     $this->attribs->href = (string) $url;
 }
示例#19
0
 /**
  * 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['option'] = 'com_'.$this->getIdentifier()->package;
         $url->query['view']   = $this->getController()->getView()->getName();
        
         KFactory::get('joomla:application')->redirect($url);
     }
    
     return parent::_actionDispatch($context);
 }
示例#20
0
 protected function _actionAdd(KCommandContext $context)
 {
     $result = parent::_actionAdd($context);
     $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
     $filter = KFactory::tmp('lib.koowa.filter.int');
     $params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams();
     $app = KFactory::get('lib.joomla.application');
     $root = KRequest::url()->get(KHttpUri::PART_BASE ^ KHttpUri::PART_PATH);
     //@TODO Should link to the message directly
     $link = $root . JRoute::_('index.php?option=com_ninjaboard&view=messages');
     $sitename = $app->getCfg('sitename');
     $mailfrom = $app->getCfg('mailfrom');
     $fromname = $app->getCfg('fromname');
     if (!$mailfrom || !$fromname) {
         $fromname = $me->display_name;
         $mailfrom = $me->email;
     }
     $subject = sprintf(JText::_('%s sent you a message on %s'), $me->display_name, $sitename);
     $subject = html_entity_decode($subject, ENT_QUOTES);
     $text = KFactory::get('admin::com.ninja.helper.bbcode')->parse(array('text' => $result->text));
     $recipients = explode(',', $result->to);
     foreach ($recipients as $tmp) {
         $recipient = $filter->sanitize($tmp);
         if ($recipient != $tmp) {
             continue;
         }
         //Can't be the current user
         if ($recipient == $me->id) {
             continue;
         }
         $model = KFactory::tmp('admin::com.ninjaboard.model.message_recipients');
         $model->getItem()->setData(array('ninjaboard_message_id' => $result->id, 'user_id' => $recipient))->save();
         if ($params->messaging_settings->enable_messaging) {
             $person = KFactory::tmp('admin::com.ninjaboard.model.people')->id($recipient)->getItem();
             if (!$person->notify_on_private_message) {
                 continue;
             }
             $notification = str_replace('/n', "\n", JText::_('NOTIFY_PM'));
             if ($notification == 'NOTIFY_PM') {
                 $notification = "%s\n\n\n\nTo manage all your messages, go to %s\n\n- %s";
             }
             $notification = sprintf($notification, $text, $link, $fromname);
             $notification = html_entity_decode($notification, ENT_QUOTES);
             //The last parameter sets the JMail $mode to HTML instead of the default plaintext
             JUtility::sendMail($mailfrom, $fromname, $person->email, $subject, $notification, true);
         }
     }
     return $result;
 }
示例#21
0
 public function getLink()
 {
     $option = $this->_options['option'];
     $view = KInflector::singularize(KRequest::get('get.view', 'cmd'));
     //return 'index.php?option='.$option.'&view=plugins&layout=default';
     // modify url
     $url = clone KRequest::url();
     $query = $url->getquery(1);
     //$query['view']	= KInflector::singularize(KRequest::get('get.view', 'cmd'));
     $query['view'] = 'dashboard';
     $query['tmpl'] = 'component';
     $url->setQuery($query);
     // render html
     return $url;
 }
 protected function _link($page, $title)
 {
     $url = clone KRequest::url();
     $query = $url->getQuery(true);
     //For compatibility with Joomla use limitstart instead of offset
     $query['limit'] = $page->limit;
     $query['limitstart'] = $page->offset;
     $url->setQuery($query);
     $class = $page->current ? 'class="active"' : '';
     if ($page->active && !$page->current) {
         $html = '<a href="' . $url . '" ' . $class . '>' . $this->translate($title) . '</a>';
     } else {
         $html = '<span ' . $class . '>' . $this->translate($title) . '</span>';
     }
     return $html;
 }
示例#23
0
 protected function _initialize(KConfig $config)
 {
     $config->append(array('og' => false, 'properties' => array('title' => 'title', 'description' => 'description', 'keywords' => '', 'og:title' => 'title'), 'values' => array('og:type' => 'article', 'og:url' => KRequest::url(), 'og:site_name' => JFactory::getConfig()->get('sitename'))));
     $this->properties = new KConfig($config->properties);
     $this->values = new KConfig($config->values);
     $this->og = $config->og;
     // Remove properties which are already set in the values:
     foreach ($this->values as $value) {
         foreach ($this->properties as $property) {
             if ($value == $property) {
                 unset($this->properties[$value]);
             }
         }
     }
     parent::_initialize($config);
 }
示例#24
0
 protected function _link($page, $title)
 {
     $url = clone KRequest::url();
     $query = $url->getQuery(true);
     $query['limit'] = $page->limit;
     $query['offset'] = $page->offset;
     $url->setQuery($query);
     if (!$page->active && $page->current) {
         $html = '<li class="active"><a href="#">' . JText::_($title) . '</a></li>';
     } elseif (!$page->active && !$page->current) {
         $html = '<li class="disabled"><a href="#">' . JText::_($title) . '</a></li>';
     } else {
         $html = '<li><a href="' . $url . '">' . JText::_($title) . '</a></li>';
     }
     return $html;
 }
示例#25
0
	protected function _actionDispatch(KCommandContext $context)
	{
		$view = KRequest::get('get.view', 'cmd', $this->_controller);

		if($view == 'pages' && !KRequest::has('get.menu'))
		{
			$page = KFactory::get('com://admin/pages.model.pages')->home(1)->getList()->top();
			
			$url = clone(KRequest::url());
            $url->query['view']   = $view;
            $url->query['menu']  = $page->pages_menu_id;
           
            KFactory::get('joomla:application')->redirect($url);
		}
	
		return parent::_actionDispatch($context);
	}
示例#26
0
 /**
  * Email notifications
  */
 public function _actionNotify(KCommandContext $context)
 {
     $post = $context->result;
     $recipients = KFactory::get($this->getModel())->topic($post->ninjaboard_topic_id)->getRecipients();
     $topic = KFactory::tmp('admin::com.ninjaboard.model.topics')->id($post->ninjaboard_topic_id)->getItem();
     $forum = KFactory::tmp('site::com.ninjaboard.model.forums')->id($topic->forum_id)->getItem();
     $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
     $app = KFactory::get('lib.joomla.application');
     $params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams();
     $root = KRequest::url()->get(KHttpUri::PART_BASE ^ KHttpUri::PART_PATH);
     $link = $root . JRoute::_('index.php?option=com_ninjaboard&view=topic&id=' . $post->ninjaboard_topic_id . '&post=' . $post->id) . '#p' . $post->id;
     $watches = $root . JRoute::_('index.php?option=com_ninjaboard&view=watches');
     $sitename = $app->getCfg('sitename');
     $mailfrom = $app->getCfg('mailfrom');
     $fromname = $app->getCfg('fromname');
     if (!$mailfrom || !$fromname) {
         $fromname = $me->display_name;
         $mailfrom = $me->email;
     }
     // Send notification to all administrators
     //$subject = sprintf ( JText::_( 'New post by %s in "%s"' ), $me->display_name, $topic->subject);
     $subject = $topic->subject . ' [' . $forum->title . ']';
     $subject = html_entity_decode($subject, ENT_QUOTES);
     $text = KFactory::get('admin::com.ninja.helper.bbcode')->parse(array('text' => $post->text));
     foreach ($recipients as $row) {
         if ($params->email_notification_settings->include_post == 'yes') {
             $message = str_replace('/n', "\n", JText::_('NOTIFY_USER_INCLUDING_POST'));
             if ($message == 'NOTIFY_USER_INCLUDING_POST') {
                 $message = "Hello %s,\n\nA new message was posted in the thread \"%s\" by %s:\n\n<%s>\n\nMessage:\n%s\n\n\nTo edit your Email Updates, go to %s\n\n- %s";
             }
             $message = sprintf($message, $row->name, $topic->subject, $me->display_name, $link, KFactory::get('lib.koowa.filter.string')->sanitize($text), $watches, $fromname);
             $message = html_entity_decode($message, ENT_QUOTES);
             JUtility::sendMail($mailfrom, $fromname, $row->email, $subject, $message);
         } else {
             $message = str_replace('/n', "\n", JText::_('NOTIFY_USER'));
             if ($message == 'NOTIFY_USER') {
                 $message = "Hello %s,\n\nA new message was posted in the thread \"%s\" by %s:\n\n<%s>\n\n\n\nTo edit your Email Updates, go to %s\n\n- %s";
             }
             $message = sprintf($message, $row->name, $topic->subject, $me->display_name, $link, $watches, $fromname);
             $message = html_entity_decode($message, ENT_QUOTES);
             JUtility::sendMail($mailfrom, $fromname, $row->email, $subject, $message);
         }
     }
 }
示例#27
0
 /**
  * Intercept a get method to check whether to show the comments only or not
  *
  * @param  KCommandContext $context
  * @return boolean
  */
 protected function _beforeControllerGet(KCommandContext $context)
 {
     if ($this->cid) {
         $context->response->content = $this->getCommentController()->id($this->cid)->display();
         return false;
     } elseif ($this->permalink && !$context->request->isAjax()) {
         $cid = (int) preg_replace('/[^\\d]+/', '', $this->permalink);
         $offset = $this->getItem()->getCommentOffset($cid);
         $start = (int) ($offset / $this->limit) * $this->limit;
         $url = KRequest::url();
         $query = $url->getQuery(true);
         if ($this->start != $start) {
             $query = array_merge($query, array('start' => $start));
         }
         unset($query['permalink']);
         $url->setQuery($query);
         $context->response->setRedirect($url . '#scroll=' . $this->permalink);
         return false;
     }
 }
function FilemanParseRoute($segments)
{
    $vars = array();
    // This is here so that we don't get problems with utf-8 characters in file names
    $url = KRequest::url();
    $path = $url->get(KHttpUrl::PATH | KHttpUrl::FORMAT);
    $query = $url->getQuery(true);
    $site = JFactory::getApplication()->getName();
    $path = str_replace($site, '', $path);
    $item = JFactory::getApplication()->getMenu()->getActive();
    $path = substr($path, strpos($path, '/' . $item->route) + strlen($item->route) + 2);
    $type = JFactory::getDocument()->getType();
    $config = new JConfig();
    if ($config->sef_suffix) {
        $path = substr($path, 0, strrpos($path, '.'));
    }
    $segments = explode('/', $path);
    // Circumvent Joomla's auto encoding
    foreach ($segments as &$segment) {
        $segment = urldecode($segment);
        $pos = strpos($segment, ':');
        if ($pos !== false) {
            $segment[$pos] = '-';
        }
    }
    $item = JFactory::getApplication()->getMenu()->getActive();
    if ($segments[0] === 'file') {
        // file view
        $vars['view'] = array_shift($segments);
        $vars['name'] = FilemanRouterDecode(array_pop($segments));
        $vars['folder'] = $item->query['folder'] ? $item->query['folder'] . '/' : '';
        $vars['folder'] .= implode('/', $segments);
    } else {
        // folder view
        $vars['view'] = 'folder';
        $vars['layout'] = $item->query['layout'];
        $vars['folder'] = $item->query['folder'] . '/' . implode('/', $segments);
    }
    $vars['folder'] = str_replace('%2E', '.', $vars['folder']);
    return $vars;
}
示例#29
0
 protected function _actionRemind(KCommandContext $context)
 {
     $email = KRequest::get('post.email', 'email');
     if (!$this->getService('koowa:filter.email')->validate($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) {
         $this->setRedirect(KRequest::referrer(), JText::_('COULD_NOT_FIND_EMAIL'), 'error');
         return false;
     }
     $config = JFactory::getConfig();
     $site_url = KRequest::url()->get(KHttpUrl::SCHEME | KHttpUrl::HOST | KHttpUrl::PORT);
     $url = $site_url . JRoute::_('index.php?option=com_users&view=login');
     $details = array('from_email' => $config->getValue('mailfrom'), 'from_name' => $config->getValue('fromname'), 'subject' => JText::sprintf('USERNAME_REMINDER_EMAIL_TITLE', $config->getValue('sitename')), 'body' => JText::sprintf('USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $user->username, $url));
     if (!JUtility::sendMail($details['from_email'], $details['from_name'], $email, $details['subject'], $details['body'])) {
         $this->setRedirect(KRequest::referrer(), JText::_('ERROR_SENDING_REMINDER_EMAIL'), 'error');
         return false;
     }
 }
示例#30
0
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     $lang =& JFactory::getLanguage();
     $orphans = $lang->getOrphans();
     if ($orphans) {
         ksort($orphans, SORT_STRING);
         $guesses = array();
         foreach ($orphans as $key => $occurance) {
             if (is_array($occurance) and isset($occurance[0])) {
                 $info =& $occurance[0];
                 $file = @$info['step']['file'];
                 $guess = str_replace('_', ' ', $info['string']);
                 // Integers isn't translatable
                 if (is_numeric($key) || strpos($key, '??') === 0 || strpos($guess, '&bull;') === 0) {
                     continue;
                 }
                 $guesses[] = array('file' => $file, 'keys' => strtoupper($key) . '=' . $guess);
             }
         }
         $append = false;
         foreach ($guesses as $guess) {
             if (!$guess['file'] || strpos($guess['file'], '/components/' . $config->option . '/') === false && strpos($guess['file'], '/components/com_ninja/') === false) {
                 continue;
             }
             $append .= "\n" . $guess['keys'];
         }
         if (!$append) {
             return;
         }
         $langfile = key($lang->getPaths($config->option));
         $readfile = JFile::read($langfile);
         $text = $readfile . "\n\n# " . KInflector::humanize(KRequest::get('get.view', 'cmd')) . "\n# @file     " . $guess['file'] . "\n# @url      " . KRequest::url() . "\n# @referrer " . KRequest::referrer() . "\n" . $append;
         JFile::write($langfile, $text);
         //echo $readfile;
         //die('<pre>'.var_export($langfile, true).'</pre>');
     }
     //die('<script type="text/javascript">console.log('.json_encode($orphans).')</script>');
 }