Source for file jResponseRedirect.class.php

Documentation is available at jResponseRedirect.class.php

  1. <?php
  2. /**
  3. @package     jelix
  4. @subpackage  core_response
  5. @author      Laurent Jouanneau
  6. @contributor Aubanel Monnier (patch for anchor)
  7. @contributor Loic Mathaud (fix bug)
  8. @contributor Afroxav (bug fix)
  9. @copyright   2005-2009 Laurent Jouanneau,  2007 Loic Mathaud
  10. @link        http://www.jelix.org
  11. @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  12. */
  13.  
  14. /**
  15. * Response To redirect to an action
  16. @package  jelix
  17. @subpackage core_response
  18. @see jResponse
  19. */
  20.  
  21. final class jResponseRedirect extends jResponse {
  22.     /**
  23.     * @var string 
  24.     */
  25.     protected $_type = 'redirect';
  26.  
  27.     /**
  28.      * selector of the action where you want to redirect.
  29.      * jUrl will be used to get the real url
  30.      * @var string 
  31.      */
  32.     public $action = '';
  33.  
  34.     /**
  35.      * the anchor you want to add to the final url. leave blank if you don't one.
  36.      * @since 1.0b2
  37.      */
  38.     public $anchor ='';
  39.  
  40.     /**
  41.      * parameters for the action/url
  42.      */
  43.     public $params = array();
  44.  
  45.     /**
  46.      * true if it is a temporary redirection
  47.      * @var boolean 
  48.      */
  49.     public $temporary = true;
  50.  
  51.     public function output(){
  52.         if($this->hasErrors()) return false;
  53.         if($this->temporary)
  54.             $this->setHttpStatus(303'See Other');
  55.         else
  56.             $this->setHttpStatus(301'Moved Permanently');
  57.         $this->sendHttpHeaders();
  58.         header ('Location: '.jUrl::get($this->action$this->params).($this->anchor!='' '#'.$this->anchor:''));
  59.         return true;
  60.     }
  61.  
  62.     public function outputErrors(){
  63.          include_once(JELIX_LIB_CORE_PATH.'response/jResponseHtml.class.php');
  64.          $resp new jResponseHtml();
  65.          $resp->outputErrors();
  66.     }
  67.  
  68. }

Documentation generated on Thu, 19 Sep 2013 00:06:49 +0200 by phpDocumentor 1.4.3