/**
  * Executes the execute method of an action.
  *
  * @param sfAction $actionInstance An sfAction instance
  *
  * @return string The view type
  */
 protected function executeAction($actionInstance)
 {
     $response = $actionInstance->getResponse();
     // Set X-Frame-Options by default. Can be overridden by actions
     $response->setHttpHeader("X-Frame-Options", "DENY");
     // execute the action
     $viewName = parent::executeAction($actionInstance);
     // Add form js and stylesheets to response
     if ($viewName != sfView::NONE) {
         $response->setHttpHeader('Expires', '0');
         $response->setHttpHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0, max-age=0");
         $response->setHttpHeader("Cache-Control", "private", false);
         $actionVars = $actionInstance->getVarHolder()->getAll();
         foreach ($actionVars as $var) {
             if ($var instanceof sfForm) {
                 foreach ($var->getStylesheets() as $file => $media) {
                     $response->addStylesheet($file, '', array('media' => $media));
                 }
                 foreach ($var->getJavascripts() as $file) {
                     $response->addJavascript($file);
                 }
             }
         }
     }
     return $viewName;
 }
 /**
  * Answer whether $action has an error response.
  *
  * @param  sfAction $action The action to test.
  *
  * @return bool Whether the response is an error.
  */
 private function isError(sfAction $action)
 {
   return $action->getResponse()->getStatusCode() != '200';
 }
Ejemplo n.º 3
0
 public static function setPageEnvironment(sfAction $action, aPage $page)
 {
     // Title is pre-escaped as valid HTML
     $prefix = aTools::getOptionI18n('title_prefix');
     $action->getResponse()->setTitle($prefix . $page->getTitle(), false);
     // Necessary to allow the use of
     // aTools::getCurrentPage() in the layout.
     // In Symfony 1.1+, you can't see $action->page from
     // the layout.
     aTools::setCurrentPage($page);
     // Borrowed from sfSimpleCMS
     if (sfConfig::get('app_a_use_bundled_layout', true)) {
         $action->setLayout(sfContext::getInstance()->getConfiguration()->getTemplateDir('a', 'layout.php') . '/layout');
     }
     // Loading the a helper at this point guarantees not only
     // helper functions but also necessary JavaScript and CSS
     sfContext::getInstance()->getConfiguration()->loadHelpers('a');
 }