示例#1
0
 /**
  * Overloaded to comply with FancyUpload.
  * It doesn't let us pass AJAX headers so this is needed.
  */
 public function _actionForward(KCommandContext $context)
 {
     if (KRequest::type() == 'FLASH' || KRequest::format() == 'json') {
         $context->result = $this->getController()->execute('display', $context);
     } else {
         parent::_actionForward($context);
     }
     return $context->result;
 }
示例#2
0
    /**
     * Initializes the options for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param 	object 	An optional KConfig object with configuration options.
     * @return 	void
     */
    protected function _initialize(KConfig $config)
    {
    	$config->append(array(
        	'controller'			=> $this->_identifier->package,
    		'request'				=> KRequest::get('get', 'string'),
        ))->append(array(
            'request' 				=> array('format' => KRequest::format() ? KRequest::format() : 'html')
        ));

        parent::_initialize($config);
    }
示例#3
0
 public function onAfterRender()
 {
     $application = JFactory::getApplication();
     $format = KRequest::format();
     // If the format is NULL, nooku defaults back to html, so there is a separate check for html and raw.
     if (is_null($format) || $format == 'html' || $format == 'raw') {
         if ($application->isSite()) {
             $body = JResponse::getBody();
             while (preg_match($this->params->regex_link, $body, $regs, PREG_OFFSET_CAPTURE)) {
                 $mail = str_replace('&', '&', $regs[2][0]);
                 $protected = $this->_protectEmail($mail, $regs[5][0], $regs[1][0], $regs[4][0]);
                 $body = substr_replace($body, $protected, $regs[0][1], strlen($regs[0][0]));
             }
             while (preg_match($this->params->regex, $body, $regs, PREG_OFFSET_CAPTURE)) {
                 $protected = $this->_protectEmail('', $regs[1][0]);
                 $body = substr_replace($body, $protected, $regs[1][1], strlen($regs[1][0]));
             }
             JResponse::setBody($body);
         }
     }
 }
 /**
  * Method to set a view object attached to the controller
  *
  * @param	mixed	An object that implements KObjectServiceable, KServiceIdentifier object 
  * 					or valid identifier string
  * @throws	KDatabaseRowsetException	If the identifier is not a view identifier
  * @return	KControllerAbstract
  */
 public function setView($view)
 {
     if (!$view instanceof KViewAbstract) {
         if (is_string($view) && strpos($view, '.') === false) {
             $identifier = clone $this->getIdentifier();
             $identifier->path = array('view', $view);
             $identifier->name = KRequest::format() ? KRequest::format() : 'html';
         } else {
             $identifier = $this->getIdentifier($view);
         }
         if ($identifier->path[0] != 'view') {
             throw new KTemplateException('Identifier: ' . $identifier . ' is not a view identifier');
         }
         $view = $identifier;
     }
     $this->_view = $view;
     return $this;
 }
示例#5
0
 /**
  * Remebers handling.
  */
 public function onAfterInitialise()
 {
     global $mainframe;
     $viewer = get_viewer();
     if (!$viewer->guest() && !$viewer->enabled) {
         KService::get('com://site/people.helper.person')->logout();
     }
     // No remember me for admin
     if ($mainframe->isAdmin()) {
         return;
     }
     jimport('joomla.utilities.utility');
     jimport('joomla.utilities.simplecrypt');
     $user = array();
     $remember = JUtility::getHash('JLOGIN_REMEMBER');
     // for json requests obtain the username and password from the $_SERVER array
     // else if the remember me cookie exists, decrypt and obtain the username and password from it
     if ($viewer->guest() && KRequest::has('server.PHP_AUTH_USER') && KRequest::has('server.PHP_AUTH_PW') && KRequest::format() == 'json') {
         $user['username'] = KRequest::get('server.PHP_AUTH_USER', 'raw');
         $user['password'] = KRequest::get('server.PHP_AUTH_PW', 'raw');
     } elseif ($viewer->guest() && isset($_COOKIE[$remember]) && $_COOKIE[$remember] != '') {
         $key = JUtility::getHash(KRequest::get('server.HTTP_USER_AGENT', 'raw'));
         if ($key) {
             $crypt = new JSimpleCrypt($key);
             $cookie = $crypt->decrypt($_COOKIE[$remember]);
             $user = (array) @unserialize($cookie);
         }
     } else {
         return;
     }
     if ($viewer->guest() && count($user)) {
         try {
             jimport('joomla.user.authentication');
             $authentication =& JAuthentication::getInstance();
             $authResponse = $authentication->authenticate($user, array());
             if ($authResponse->status == JAUTHENTICATE_STATUS_SUCCESS) {
                 KService::get('com://site/people.helper.person')->login($user, true);
             }
         } catch (RuntimeException $e) {
             //only throws exception if we are using JSON format
             //otherwise let the current app handle it
             if (KRequest::format() == 'json') {
                 throw $e;
             }
         }
     }
     return;
 }
 /**
  * On after route event handler
  *
  * @return void
  */
 public function onAfterRoute()
 {
     /*
      * Special handling for AJAX requests
      *
      * If the format is AJAX and the format is 'html' or the tmpl is empty we re-create
      * a 'raw' document rendered and force it's type to the active format
      */
     if (KRequest::type() == 'AJAX') {
         if (KRequest::get('get.format', 'cmd', 'html') != 'html' || KRequest::get('get.tmpl', 'cmd') === '') {
             $format = JRequest::getWord('format', 'html');
             JRequest::setVar('format', 'raw');
             //force format to raw
             @($document =& JFactory::getDocument());
             $document = null;
             JFactory::getDocument()->setType($format);
             JRequest::setVar('format', $format);
             //revert format to original
         }
     }
     //Set the request format
     if (!KRequest::has('request.format')) {
         KRequest::set('request.format', KRequest::format());
     }
 }
示例#7
0
 /**
  * Get the identifier for the view with the same name
  *
  * @return	KIdentifierInterface
  */
 public function getView()
 {
     if (!$this->_view) {
         if (!isset($this->_request->view)) {
             $name = $this->_identifier->name;
             if ($this->getModel()->getState()->isUnique()) {
                 $this->_request->view = $name;
             } else {
                 $this->_request->view = KInflector::pluralize($name);
             }
         }
         $identifier = clone $this->_identifier;
         $identifier->path = array('view', $this->_request->view);
         $identifier->name = KRequest::format() ? KRequest::format() : 'html';
         $config = array('auto_filter' => $this->isDispatched());
         $this->_view = KFactory::get($identifier, $config);
     }
     return $this->_view;
 }
示例#8
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.
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('enabled' => KRequest::format() == 'html' && $config->mixer->isDispatched()));
     parent::_initialize($config);
 }
示例#9
0
 /**
  * Fixes the url path
  * 
  * @param KHttpUrl $url
  * 
  * @return void
  */
 protected function _fixUrlForParsing($url)
 {
     $path = $url->path;
     //bug in request
     if ($url->format == 'php') {
         $path .= '.php';
         $url->format = null;
     }
     $path = substr_replace($path, '', 0, strlen($this->_base_url->path));
     $path = preg_replace('/index\\/?.php/', '', $path);
     $path = trim($path, '/');
     $url->path = $path;
     $url->format = $url->format ? $url->format : pick(KRequest::format(), 'html');
     if (!empty($url->format)) {
         $url->query['format'] = $url->format;
     }
 }