Esempio n. 1
0
 /**
  * The post-filter for controller actions.
  * This method is invoked after the currently requested controller action and all its filters
  * are executed. If you override this method, make sure you call the parent implementation at the end.
  * @param CController $controller the controller
  * @param CAction $action the action
  */
 public function afterControllerAction($controller, $action)
 {
     if (($parent = $this->getParentModule()) === null) {
         $parent = Gateway::app();
     }
     $parent->afterControllerAction($controller, $action);
 }
Esempio n. 2
0
 public function xSendFile($filePath, $options = array())
 {
     if (!isset($options['forceDownload']) || $options['forceDownload']) {
         $disposition = 'attachment';
     } else {
         $disposition = 'inline';
     }
     if (!isset($options['saveName'])) {
         $options['saveName'] = basename($filePath);
     }
     if (!isset($options['mimeType'])) {
         if (($options['mimeType'] = CFileHelper::getMimeTypeByExtension($filePath)) === null) {
             $options['mimeType'] = 'text/plain';
         }
     }
     if (!isset($options['xHeader'])) {
         $options['xHeader'] = 'X-Sendfile';
     }
     if ($options['mimeType'] !== null) {
         header('Content-Type: ' . $options['mimeType']);
     }
     header('Content-Disposition: ' . $disposition . '; filename="' . $options['saveName'] . '"');
     if (isset($options['addHeaders'])) {
         foreach ($options['addHeaders'] as $header => $value) {
             header($header . ': ' . $value);
         }
     }
     header(trim($options['xHeader']) . ': ' . $filePath);
     if (!isset($options['terminate']) || $options['terminate']) {
         Gateway::app()->end();
     }
 }