Source for file jResponseRedirectUrl.class.php

Documentation is available at jResponseRedirectUrl.class.php

  1. <?php
  2. /**
  3. @package     jelix
  4. @subpackage  core_response
  5. @author      Laurent Jouanneau
  6. @contributor Loic Mathaud (fix bug)
  7. @copyright   2005-2007 Laurent Jouanneau, 2007 Loic Mathaud
  8. @link        http://www.jelix.org
  9. @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  10. */
  11.  
  12. /**
  13. * Response To redirect to an URL
  14. @package  jelix
  15. @subpackage core_response
  16. @see jResponse
  17. */
  18.  
  19. final class jResponseRedirectUrl extends jResponse {
  20.     protected $_type = 'redirectUrl';
  21.  
  22.     /**
  23.      * full url to redirect
  24.      * @var string 
  25.      */
  26.     public $url = '';
  27.  
  28.     /**
  29.      * set the url with the referer URL
  30.      * @return boolean true if there is a referer URL
  31.      * @since 1.0
  32.      */
  33.     public function toReferer($defaultUrl=''{
  34.         if(isset($_SERVER['HTTP_REFERER']&& $_SERVER['HTTP_REFERER'!= ''{
  35.             $this->url = $_SERVER['HTTP_REFERER'];
  36.             return true;
  37.         }
  38.         else {
  39.             $this->url = $defaultUrl;
  40.             return false;
  41.         }
  42.     }
  43.  
  44.  
  45.     public function output(){
  46.         if ($this->url =='')
  47.             throw new jException('jelix~errors.repredirect.empty.url');
  48.         if($this->hasErrors())
  49.             return false;
  50.         $this->sendHttpHeaders();
  51.         header ('Location: '.$this->url);
  52.         return true;
  53.     }
  54.  
  55.     public function outputErrors(){
  56.          include_once(JELIX_LIB_RESPONSE_PATH.'jResponseHtml.class.php');
  57.          $resp new jResponseHtml();
  58.          $resp->outputErrors();
  59.     }
  60. }
  61.  
  62. ?>

Documentation generated on Wed, 07 Sep 2011 13:47:47 +0200 by phpDocumentor 1.4.3