コード例 #1
0
 /**
  * Reset MVC state
  *
  * Creates new request/response objects, resets the front controller
  * instance, and resets the action helper broker.
  *
  * @todo   Need to update Zend_Layout to add a resetInstance() method
  * @return void
  */
 public function reset()
 {
     $_SESSION = array();
     $_GET = array();
     $_POST = array();
     $_COOKIE = array();
     $this->resetRequest();
     $this->resetResponse();
     Zend_Layout::resetMvcInstance();
     Zend_Controller_Action_HelperBroker::resetHelpers();
     $this->frontController->resetInstance();
     Zend_Session::$_unitTestEnabled = true;
 }
コード例 #2
0
 /**
  * Ajax return function for round selection
  */
 public function roundselectAction()
 {
     \Zend_Layout::resetMvcInstance();
     $trackId = $this->getRequest()->getParam('sourceValue');
     $rounds = $this->db->fetchPairs($this->roundDescriptionQuery, $trackId);
     echo json_encode($rounds);
 }
コード例 #3
0
ファイル: ZF1.php プロジェクト: namnv609/Codeception
 public function _after(\Codeception\TestCase $test)
 {
     $_SESSION = [];
     $_GET = [];
     $_POST = [];
     $_COOKIE = [];
     if ($this->bootstrap) {
         $fc = $this->bootstrap->getBootstrap()->getResource('frontcontroller');
         if ($fc) {
             $fc->resetInstance();
         }
     }
     \Zend_Layout::resetMvcInstance();
     \Zend_Controller_Action_HelperBroker::resetHelpers();
     \Zend_Session::$_unitTestEnabled = true;
     $this->queries = 0;
     $this->time = 0;
 }
コード例 #4
0
 /**
  * Tears down the fixture, for example, close a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 public function tearDown()
 {
     Zend_Layout::resetMvcInstance();
 }
コード例 #5
0
ファイル: LayoutTest.php プロジェクト: hjr3/zf2
 public function testResettingMvcInstanceRemovesMvcSingleton()
 {
     $this->testGetMvcInstanceReturnsLayoutInstanceWhenStartMvcHasBeenCalled();
     Zend_Layout::resetMvcInstance();
     $this->assertNull(Zend_Layout::getMvcInstance());
 }
コード例 #6
0
ファイル: Service.php プロジェクト: Gerhard13/pimcore
 /**
  * static function to render a document outside of a view
  *
  * @static
  * @param Document $document
  * @param array $params
  * @param bool $useLayout
  * @return string
  */
 public static function render(Document $document, $params = array(), $useLayout = false)
 {
     $layout = null;
     $existingActionHelper = null;
     if (\Zend_Controller_Action_HelperBroker::hasHelper("layout")) {
         $existingActionHelper = \Zend_Controller_Action_HelperBroker::getExistingHelper("layout");
     }
     $layoutInCurrentAction = \Zend_Layout::getMvcInstance() instanceof \Zend_Layout ? \Zend_Layout::getMvcInstance()->getLayout() : false;
     $viewHelper = \Zend_Controller_Action_HelperBroker::getExistingHelper("ViewRenderer");
     if ($viewHelper) {
         if ($viewHelper->view === null) {
             $viewHelper->initView(PIMCORE_WEBSITE_PATH . "/views");
         }
         $view = $viewHelper->view;
     } else {
         $view = new \Pimcore\View();
     }
     // add the view script path from the website module to the view, because otherwise it's not possible to call
     // this method out of other modules to render documents, eg. sending e-mails out of an plugin with Pimcore_Mail
     $moduleDirectory = \Zend_Controller_Front::getInstance()->getModuleDirectory($document->getModule());
     if (!empty($moduleDirectory)) {
         $view->addScriptPath($moduleDirectory . "/views/layouts");
         $view->addScriptPath($moduleDirectory . "/views/scripts");
     } else {
         $view->addScriptPath(PIMCORE_FRONTEND_MODULE . "/views/layouts");
         $view->addScriptPath(PIMCORE_FRONTEND_MODULE . "/views/scripts");
     }
     $documentBackup = null;
     if ($view->document) {
         $documentBackup = $view->document;
     }
     $view->document = $document;
     if ($useLayout) {
         if (!($layout = \Zend_Layout::getMvcInstance())) {
             $layout = \Zend_Layout::startMvc();
             $layout->setViewSuffix(View::getViewScriptSuffix());
             if ($layoutHelper = $view->getHelper("layout")) {
                 $layoutHelper->setLayout($layout);
             }
         }
         $layout->setLayout("--modification-indicator--");
     }
     $params["document"] = $document;
     foreach ($params as $key => $value) {
         if (!$view->{$key}) {
             $view->{$key} = $value;
         }
     }
     $content = $view->action($document->getAction(), $document->getController(), $document->getModule(), $params);
     //has to be called after $view->action so we can determine if a layout is enabled in $view->action()
     if ($useLayout) {
         if ($layout instanceof \Zend_Layout) {
             $layout->{$layout->getContentKey()} = $content;
             if (is_array($params)) {
                 foreach ($params as $key => $value) {
                     $layout->getView()->{$key} = $value;
                 }
             }
             // when using Document\Service::render() you have to set a layout in the view ($this->layout()->setLayout("mylayout"))
             if ($layout->getLayout() != "--modification-indicator--") {
                 $content = $layout->render();
             }
             //deactivate the layout if it was not activated in the called action
             //otherwise we would activate the layout in the called action
             \Zend_Layout::resetMvcInstance();
             if (!$layoutInCurrentAction) {
                 $layout->disableLayout();
             } else {
                 $layout = \Zend_Layout::startMvc();
                 $layout->setViewSuffix(View::getViewScriptSuffix());
                 // set pimcore specifiy view suffix
                 $layout->setLayout($layoutInCurrentAction);
                 $view->getHelper("Layout")->setLayout($layout);
                 if ($existingActionHelper) {
                     \Zend_Controller_Action_HelperBroker::removeHelper("layout");
                     \Zend_Controller_Action_HelperBroker::addHelper($existingActionHelper);
                     $pluginClass = $layout->getPluginClass();
                     $front = $existingActionHelper->getFrontController();
                     if ($front->hasPlugin($pluginClass)) {
                         $plugin = $front->getPlugin($pluginClass);
                         $plugin->setLayoutActionHelper($existingActionHelper);
                     }
                 }
             }
             $layout->{$layout->getContentKey()} = null;
             //reset content
         }
     }
     if ($documentBackup) {
         $view->document = $documentBackup;
     }
     if (\Pimcore\Config::getSystemConfig()->outputfilters->less) {
         $content = \Pimcore\Tool\Less::processHtml($content);
     }
     return $content;
 }
コード例 #7
0
 private function configureView($csvArray, $ceId, $filename)
 {
     if ($this->getRequest()->getParam('as') == 'csv') {
         $csvString = '';
         foreach ($csvArray as $singleArray) {
             foreach ($csvArray[0] as $alias => $head) {
                 $csvString .= $singleArray[$alias] . ',';
             }
             $csvString .= "\n";
         }
         $this->view->csvString = $csvString;
         $this->view->filename = $filename;
         // generate the download file
         Zend_Layout::resetMvcInstance();
         $this->render('csvstring');
     } else {
         $this->view->csvArray = $csvArray;
         $this->view->Action = $this->getRequest()->getActionName();
         $this->view->ceId = $ceId;
         $this->render('csvarray');
     }
 }
コード例 #8
0
 /**
  * Used in unit tests
  */
 public static function cleanUp()
 {
     Zend_Registry::_unsetInstance();
     Zend_Layout::resetMvcInstance();
     Zend_Controller_Action_HelperBroker::resetHelpers();
 }
コード例 #9
0
ファイル: SocialEngine.php プロジェクト: BatVane/Codeception
 public function _after(\Codeception\TestCase $test)
 {
     $_SESSION = array();
     $_GET = array();
     $_POST = array();
     $_COOKIE = array();
     $this->front = $this->bootstrap->getBootstrap()->getContainer()->frontcontroller->resetInstance();
     \Zend_Layout::resetMvcInstance();
     \Zend_Controller_Action_HelperBroker::resetHelpers();
     \Zend_Session::$_unitTestEnabled = true;
     $this->queries = 0;
     $this->time = 0;
 }
コード例 #10
0
ファイル: Service.php プロジェクト: shanky0110/pimcore-custom
 /**
  * static function to render a document outside of a view
  *
  * @static
  * @param Document $document
  * @param array $params
  * @param bool $useLayout
  * @return string
  */
 public static function render(Document $document, $params = array(), $useLayout = false)
 {
     $layoutEnabledInCurrentAction = Zend_Layout::getMvcInstance() instanceof Zend_Layout ? true : false;
     $viewHelper = Zend_Controller_Action_HelperBroker::getExistingHelper("ViewRenderer");
     if ($viewHelper) {
         if ($viewHelper->view === null) {
             $viewHelper->initView(PIMCORE_WEBSITE_PATH . "/views");
         }
         $view = $viewHelper->view;
     } else {
         $view = new Pimcore_View();
     }
     // add the view script path from the website module to the view, because otherwise it's not possible to call
     // this method out of other modules to render documents, eg. sending e-mails out of an plugin with Pimcore_Mail
     $view->addScriptPath(PIMCORE_FRONTEND_MODULE . "/views/layouts");
     $view->addScriptPath(PIMCORE_FRONTEND_MODULE . "/views/scripts");
     $documentBackup = null;
     if ($view->document) {
         $documentBackup = $view->document;
     }
     $view->document = $document;
     if ($useLayout) {
         if (!($layout = Zend_Layout::getMvcInstance())) {
             $layout = Zend_Layout::startMvc();
             if ($layoutHelper = $view->getHelper("layout")) {
                 $layoutHelper->setLayout($layout);
             }
         }
         $layout->setLayout("--modification-indicator--");
     }
     $params["document"] = $document;
     foreach ($params as $key => $value) {
         if (!$view->{$key}) {
             $view->{$key} = $value;
         }
     }
     $content = $view->action($document->getAction(), $document->getController(), $document->getModule(), $params);
     //has to be called after $view->action so we can determine if a layout is enabled in $view->action()
     if ($useLayout) {
         if ($layout instanceof Zend_Layout) {
             $layout->{$layout->getContentKey()} = $content;
             if (is_array($params)) {
                 foreach ($params as $key => $value) {
                     if (!$layout->getView()->{$key}) {
                         //otherwise we could overwrite e.g. controller, content...
                         $layout->getView()->{$key} = $value;
                     }
                 }
             }
             // when using Document_Service::render() you have to set a layout in the view ($this->layout()->setLayout("mylayout"))
             if ($layout->getLayout() != "--modification-indicator--") {
                 $content = $layout->render();
             }
             //deactivate the layout if it was not activated in the called action
             //otherwise we would activate the layout in the called action
             Zend_Layout::resetMvcInstance();
             if (!$layoutEnabledInCurrentAction) {
                 $layout->disableLayout();
             } else {
                 $layout = Zend_Layout::startMvc();
                 $layout->setViewSuffix(Pimcore_View::getViewScriptSuffix());
                 // set pimcore specifiy view suffix
                 $view->getHelper("Layout")->setLayout($layout);
             }
             $layout->{$layout->getContentKey()} = null;
             //reset content
         }
     }
     if ($documentBackup) {
         $view->document = $documentBackup;
     }
     return $content;
 }
コード例 #11
0
 /**
  * The automatically filtered result
  *
  * @param $resetMvc When true only the filtered resulsts
  */
 public function autofilterAction($resetMvc = true)
 {
     // \MUtil_Model::$verbose = true;
     // We do not need to return the layout, just the above table
     if ($resetMvc) {
         // Make sure all links are generated as if the current request was index.
         $this->aliasAction('index');
         \Zend_Layout::resetMvcInstance();
     }
     if ($this->autofilterSnippets) {
         $params = $this->_processParameters($this->autofilterParameters + $this->_defaultAutofilterParameters);
         $this->addSnippets($this->autofilterSnippets, $params);
     }
     if ($resetMvc) {
         // Lazy call here, because any echo calls in the snippets have not yet been
         // performed. so they will appear only in the next call when not lazy.
         $this->html->raw(\MUtil_Lazy::call(array('MUtil_Echo', 'out')));
     }
 }
コード例 #12
0
 public function createattributecsvAction()
 {
     $csvString = '';
     // prepare the header
     $fishBaseAttr = array(Fish::COL_SAMPLE_CODE);
     $imageBaseAttr = array(Image::COL_ORIGINAL_FILENAME, Image::COL_RATIO_EXTERNAL);
     $meta = new Default_MetaData();
     $attribRowset = array_merge($fishBaseAttr, $meta->getAttributesBasic('FISH'), $imageBaseAttr, $meta->getAttributesBasic('IMAGE'));
     /*handle last item differently
      * credit:grobemo
      * 24-Apr-2009 08:13
      * http://de3.php.net/manual/en/control-structures.foreach.php
      */
     $last_item = end($attribRowset);
     foreach ($attribRowset as $attr) {
         if ($attr == $last_item) {
             if (is_array($attr) && array_key_exists(AttributeDescriptor::COL_NAME, $attr)) {
                 $csvString .= $attr[AttributeDescriptor::COL_NAME];
             } else {
                 $csvString .= $attr;
             }
         } else {
             if (is_array($attr) && array_key_exists(AttributeDescriptor::COL_NAME, $attr)) {
                 $csvString .= $attr[AttributeDescriptor::COL_NAME] . ',';
             } else {
                 $csvString .= $attr . ',';
             }
         }
     }
     $csvString .= "\n";
     $this->view->csvString = $csvString;
     // generate the download file
     Zend_Layout::resetMvcInstance();
     $this->render('csvstring');
 }