Advertisement
Guest User

vladimir

a guest
Feb 9th, 2010
2,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.11 KB | None | 0 0
  1. <?php
  2. class ZendY_Controller_Action_Helper_LastDecline
  3.     extends Zend_Controller_Action_Helper_Abstract
  4. {
  5.     /**
  6.      * Enter description here...
  7.      *
  8.      * @var string
  9.      */
  10.     protected $_namespace = __CLASS__;
  11.  
  12.     /**
  13.      * Enter description here...
  14.      *
  15.      * @var Zend_Session_Namespace
  16.      */
  17.     protected $_session = null;
  18.  
  19.     /**
  20.      * Enter description here...
  21.      *
  22.      * @param string $namespace
  23.      * @return ZendY_Controller_Action_Helper_LastDecline
  24.      */
  25.     public function setNamespace($namespace)
  26.     {
  27.         $this->_namespace = $namespace;
  28.         return $this;
  29.     }
  30.  
  31.     /**
  32.      * Enter description here...
  33.      *
  34.      * @return string
  35.      */
  36.     public function getNamespace()
  37.     {
  38.         return $this->_namespace;
  39.     }
  40.  
  41.     /**
  42.      * Enter description here...
  43.      *
  44.      * @param Zend_Session_Namespace $session
  45.      * @return ZendY_Controller_Action_Helper_LastDecline
  46.      */
  47.     public function setSession($session)
  48.     {
  49.         $this->_session = $session;
  50.         return $this;
  51.     }
  52.  
  53.     /**
  54.      * Enter description here...
  55.      *
  56.      * @return Zend_Session_Namespace
  57.      */
  58.     public function getSession()
  59.     {
  60.         if (null === $this->_session) {
  61.             $this->_session = new Zend_Session_Namespace($this->getNamespace());
  62.         }
  63.         return $this->_session;
  64.     }
  65.  
  66.     /**
  67.      * Enter description here...
  68.      *
  69.      * @return Zend_Controller_Action_Helper_Redirector
  70.      */
  71.     protected function _getRedirector()
  72.     {
  73.         return Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
  74.     }
  75.  
  76.     /**
  77.      * Enter description here...
  78.      *
  79.      * @param string $requestUri
  80.      * @return ZendY_Controller_Action_Helper_LastDecline
  81.      */
  82.     public function saveRequestUri($requestUri = '')
  83.     {
  84.         if ('' === $requestUri) {
  85.             $requestUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
  86.         }
  87.         $this->getSession()->lastRequestUri = $requestUri;
  88.  
  89.         return $this;
  90.     }
  91.  
  92.     /**
  93.      *
  94.      * @return bool
  95.      */
  96.     public function hasRequestUri()
  97.     {
  98.         $session = $this->getSession();
  99.         return isset($session->lastRequestUri);
  100.     }
  101.  
  102.     /**
  103.      * Enter description here...
  104.      *
  105.      * @return string|null
  106.      */
  107.     public function getRequestUri()
  108.     {
  109.         $session = $this->getSession();
  110.         if ($this->hasRequestUri()) {
  111.             $lastRequestUri = $session->lastRequestUri;
  112.             unset($session->lastRequestUri);
  113.             return $lastRequestUri;
  114.         } else {
  115.             return null;
  116.         }
  117.     }
  118.  
  119.     /**
  120.      * Enter description here...
  121.      *
  122.      */
  123.     public function redirect()
  124.     {
  125.         if (null === ($lastRequestUri = $this->getRequestUri())) {
  126.             $this->_getRedirector()->gotoUrl('/');
  127.         } else {
  128.             $this->_getRedirector()->gotoUrl($lastRequestUri);
  129.         }
  130.     }
  131.  
  132.     /**
  133.      * Enter description here...
  134.      *
  135.      */
  136.     public function direct()
  137.     {
  138.         $this->redirect();
  139.     }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement