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-2010 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->temporary)
  53.             $this->setHttpStatus(303'See Other');
  54.         else
  55.             $this->setHttpStatus(301'Moved Permanently');
  56.         $this->sendHttpHeaders();
  57.         header ('Location: '.jUrl::get($this->action$this->params).($this->anchor!='' '#'.$this->anchor:''));
  58.         return true;
  59.     }
  60.  
  61. }

Documentation generated on Wed, 24 Sep 2014 22:01:34 +0200 by phpDocumentor 1.4.3