コード例 #1
0
ファイル: controller.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Method to display a view.
  *
  * @access	public
  * @param	boolean	$cachable	If true, the view output will be cached.
  * @param	array	$urlparams	An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}..
  * @return	void
  *
  * @since	Cook 1.0
  */
 public function display($cachable = false, $urlparams = false)
 {
     $jinput = JFactory::getApplication()->input;
     $this->_parentDisplay();
     //If page is called through POST, reconstruct the url
     if ($jinput->getMethod(null, null) == 'POST') {
         //Kill the post and rebuild the url
         $this->setRedirect(RtiprintHelper::urlRequest());
         return;
     }
     return $this;
 }
コード例 #2
0
ファイル: item.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Customize the redirection depending on result.
  * (proposed by Cook Self Service).
  *
  * @access	protected
  * @param	mixed	$result	bool or integer. The result from  the task operation
  * @param	array	$redirections	The redirections (option.view.layout) ordered by task result [0,1,...]
  * @param	array	$vars	Eventual added vars to the redirection.
  *
  * @return	void	
  * @return	void
  */
 protected function applyRedirection($result, $redirections, $vars = array())
 {
     if ($result === null) {
         $result = 1;
     } else {
         $result = (int) $result;
     }
     if (!$this->_result) {
         $this->_result = $result;
     }
     if (!isset($redirections[$result])) {
         return;
     }
     //Keep the default redirection
     //Get the selected redirection depending on result
     $redirection = $redirections[$result];
     switch ($redirection) {
         //Stay on the same page
         case 'stay':
             $this->setRedirect(RtiprintHelper::urlRequest());
             return;
             break;
             //Return to the previous page in navigation history
         //Return to the previous page in navigation history
         case 'previous':
             //TODO
             break;
     }
     $url = explode(".", $redirection);
     //Get from given url parts (empty string will keep the current value)
     if (isset($url[0])) {
         $values['option'] = !empty($url[0]) ? $url[0] : $this->option;
     }
     if (isset($url[1])) {
         $values['view'] = !empty($url[1]) ? $url[1] : $this->view_list;
     }
     if (isset($url[2])) {
         $values['layout'] = !empty($url[2]) ? $url[2] : $this->getLayout(true);
     }
     $jinput = JFactory::getApplication()->input;
     //Followers : If value is defined in the current form, it will be added in the request
     $followers = array('cid' => 'ARRAY', 'tmpl' => 'CMD', 'Itemid' => 'CMD', 'lang' => 'CMD');
     //Filters followers
     $model = CkJModel::getInstance($this->view_list, 'RtiprintModel');
     if ($model) {
         $filters = $model->get('filter_vars');
         foreach ($filters as $filterName => $type) {
             $type = 'STRING';
             //When filter is empty, don't follow, so FILTER is not used.
             $filterVar = 'filter_' . $filterName;
             //Adds a filter follower
             $followers[$filterVar] = $type;
         }
     }
     //Apply the followers values
     foreach ($followers as $varName => $varType) {
         if ($pos = strpos($varType, ":")) {
             $varType = substr($varType, 0, $pos);
         }
         $value = $jinput->get($varName, '', strtoupper($varType));
         if ($varType == 'ARRAY' && !empty($value)) {
             $value = implode(",", $value);
             $varName .= "[]";
         }
         if ($value != '') {
             $values[$varName] = $value;
         }
     }
     //Override with vars in params
     foreach ($vars as $key => $value) {
         $values[$key] = $value;
     }
     //Prepare the url
     foreach ($values as $key => $value) {
         if ($value !== null) {
             $parts[] = $key . '=' . $value;
         }
     }
     //Apply redirection
     $this->setRedirect(JRoute::_("index.php?" . implode("&", $parts), false));
 }