import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
* @package Zend_View
|
||||
* @subpackage Helper
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @version $Id: Action.php 16222 2009-06-21 19:55:20Z thomas $
|
||||
* @version $Id: Action.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
@ -31,7 +31,7 @@ require_once 'Zend/View/Helper/Abstract.php';
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_View_Helper_Action extends Zend_View_Helper_Abstract
|
||||
class Zend_View_Helper_Action extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -52,25 +52,25 @@ class Zend_View_Helper_Action extends Zend_View_Helper_Abstract
|
||||
* @var Zend_Controller_Response_Abstract
|
||||
*/
|
||||
public $response;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Grab local copies of various MVC objects
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$front = Zend_Controller_Front::getInstance();
|
||||
$front = Zend_Controller_Front::getInstance();
|
||||
$modules = $front->getControllerDirectory();
|
||||
if (empty($modules)) {
|
||||
require_once 'Zend/View/Exception.php';
|
||||
throw new Zend_View_Exception('Action helper depends on valid front controller instance');
|
||||
}
|
||||
|
||||
$request = $front->getRequest();
|
||||
$response = $front->getResponse();
|
||||
$request = $front->getRequest();
|
||||
$response = $front->getResponse();
|
||||
|
||||
if (empty($request) || empty($response)) {
|
||||
require_once 'Zend/View/Exception.php';
|
||||
@ -79,73 +79,73 @@ class Zend_View_Helper_Action extends Zend_View_Helper_Abstract
|
||||
|
||||
$this->request = clone $request;
|
||||
$this->response = clone $response;
|
||||
$this->dispatcher = clone $front->getDispatcher();
|
||||
$this->dispatcher = clone $front->getDispatcher();
|
||||
$this->defaultModule = $front->getDefaultModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset object states
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetObjects()
|
||||
{
|
||||
$params = $this->request->getUserParams();
|
||||
foreach (array_keys($params) as $key) {
|
||||
$this->request->setParam($key, null);
|
||||
}
|
||||
|
||||
public function resetObjects()
|
||||
{
|
||||
$params = $this->request->getUserParams();
|
||||
foreach (array_keys($params) as $key) {
|
||||
$this->request->setParam($key, null);
|
||||
}
|
||||
|
||||
$this->response->clearBody();
|
||||
$this->response->clearHeaders()
|
||||
->clearRawHeaders();
|
||||
$this->response->clearHeaders()
|
||||
->clearRawHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve rendered contents of a controller action
|
||||
*
|
||||
* If the action results in a forward or redirect, returns empty string.
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $controller
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $controller
|
||||
* @param string $module Defaults to default module
|
||||
* @param array $params
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public function action($action, $controller, $module = null, array $params = array())
|
||||
{
|
||||
$this->resetObjects();
|
||||
if (null === $module) {
|
||||
$module = $this->defaultModule;
|
||||
}
|
||||
$this->resetObjects();
|
||||
if (null === $module) {
|
||||
$module = $this->defaultModule;
|
||||
}
|
||||
|
||||
// clone the view object to prevent over-writing of view variables
|
||||
$viewRendererObj = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
|
||||
Zend_Controller_Action_HelperBroker::addHelper(clone $viewRendererObj);
|
||||
|
||||
$this->request->setParams($params)
|
||||
->setModuleName($module)
|
||||
->setControllerName($controller)
|
||||
->setActionName($action)
|
||||
->setDispatched(true);
|
||||
|
||||
$this->dispatcher->dispatch($this->request, $this->response);
|
||||
|
||||
Zend_Controller_Action_HelperBroker::addHelper(clone $viewRendererObj);
|
||||
|
||||
$this->request->setParams($params)
|
||||
->setModuleName($module)
|
||||
->setControllerName($controller)
|
||||
->setActionName($action)
|
||||
->setDispatched(true);
|
||||
|
||||
$this->dispatcher->dispatch($this->request, $this->response);
|
||||
|
||||
// reset the viewRenderer object to it's original state
|
||||
Zend_Controller_Action_HelperBroker::addHelper($viewRendererObj);
|
||||
|
||||
|
||||
if (!$this->request->isDispatched()
|
||||
|| $this->response->isRedirect())
|
||||
{
|
||||
// forwards and redirects render nothing
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
if (!$this->request->isDispatched()
|
||||
|| $this->response->isRedirect())
|
||||
{
|
||||
// forwards and redirects render nothing
|
||||
return '';
|
||||
}
|
||||
|
||||
$return = $this->response->getBody();
|
||||
$this->resetObjects();
|
||||
$this->resetObjects();
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the current View
|
||||
*
|
||||
|
Reference in New Issue
Block a user