当前位置: 首页>>代码示例>>PHP>>正文


PHP SpoonHTTP::setHeaders方法代码示例

本文整理汇总了PHP中SpoonHTTP::setHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonHTTP::setHeaders方法的具体用法?PHP SpoonHTTP::setHeaders怎么用?PHP SpoonHTTP::setHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpoonHTTP的用法示例。


在下文中一共展示了SpoonHTTP::setHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     // if the application wasn't defined before we will define it
     if (!defined('NAMED_APPLICATION')) {
         define('NAMED_APPLICATION', 'frontend');
     }
     // set the module
     $this->setModule(SpoonFilter::getGetValue('module', null, ''));
     // set the requested file
     $this->setFile(SpoonFilter::getGetValue('file', null, ''));
     // set the language
     $this->setLanguage(SpoonFilter::getGetValue('language', FrontendLanguage::getActiveLanguages(), SITE_DEFAULT_LANGUAGE));
     // create a new template instance (this will handle all stuff for us)
     $tpl = new FrontendTemplate();
     // enable addslashes on each locale
     $tpl->setAddSlashes(true);
     // set correct headers
     SpoonHTTP::setHeaders('content-type: application/javascript');
     // fetch the template path
     if ($this->module == 'core') {
         $file = FRONTEND_CORE_PATH . '/js/' . $this->getFile();
     } else {
         $file = FRONTEND_MODULES_PATH . '/' . $this->getModule() . '/js/' . $this->getFile();
     }
     // output the template
     $tpl->display(FrontendTheme::getPath($file), true);
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:27,代码来源:javascript.php

示例2: outputCSV

 /**
  * Output a CSV-file as a download
  *
  * @param string $filename					The name of the file.
  * @param array $array						The array to convert.
  * @param array[optional] $columns			The column names you want to use.
  * @param array[optional] $excludeColumns	The columns you want to exclude.
  */
 public static function outputCSV($filename, array $array, array $columns = null, array $excludeColumns = null)
 {
     // get settings
     $splitCharacter = BackendAuthentication::getUser()->getSetting('csv_split_character');
     $lineEnding = BackendAuthentication::getUser()->getSetting('csv_line_ending');
     // reformat
     if ($lineEnding == '\\n') {
         $lineEnding = "\n";
     }
     if ($lineEnding == '\\r\\n') {
         $lineEnding = "\r\n";
     }
     // convert into CSV
     $csv = SpoonFileCSV::arrayToString($array, $columns, $excludeColumns, $splitCharacter, '"', $lineEnding);
     // set headers for download
     $headers[] = 'Content-type: application/csv; charset=' . SPOON_CHARSET;
     $headers[] = 'Content-Disposition: attachment; filename="' . $filename;
     $headers[] = 'Content-Length: ' . strlen($csv);
     $headers[] = 'Pragma: no-cache';
     // overwrite the headers
     SpoonHTTP::setHeaders($headers);
     // ouput the CSV
     echo $csv;
     exit;
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:33,代码来源:csv.php

示例3: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // init vars
     $templates = array();
     $theme = BackendModel::getModuleSetting('core', 'theme');
     $files[] = BACKEND_PATH . '/core/layout/editor_templates/templates.js';
     $themePath = FRONTEND_PATH . '/themes/' . $theme . '/core/layout/editor_templates/templates.js';
     if (SpoonFile::exists($themePath)) {
         $files[] = $themePath;
     }
     // loop all files
     foreach ($files as $file) {
         // process file
         $templates = array_merge($templates, $this->processFile($file));
     }
     // set headers
     SpoonHTTP::setHeaders('Content-type: text/javascript');
     // output the templates
     if (!empty($templates)) {
         echo 'CKEDITOR.addTemplates(\'default\', { imagesPath: \'/\', templates:' . "\n";
         echo json_encode($templates) . "\n";
         echo '});';
     }
     exit;
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:30,代码来源:templates.php

示例4: __construct

 public function __construct()
 {
     // define the Named Application
     if (!defined('NAMED_APPLICATION')) {
         define('NAMED_APPLICATION', 'backend');
     }
     // set the module
     $this->setModule(SpoonFilter::getGetValue('module', null, ''));
     // set the requested file
     $this->setFile(SpoonFilter::getGetValue('file', null, ''));
     // set the language
     $this->setLanguage(SpoonFilter::getGetValue('language', array_keys(BackendLanguage::getWorkingLanguages()), SITE_DEFAULT_LANGUAGE));
     // build the path
     if ($this->module == 'core') {
         $path = BACKEND_CORE_PATH . '/js/' . $this->getFile();
     } else {
         $path = BACKEND_MODULES_PATH . '/' . $this->getModule() . '/js/' . $this->getFile();
     }
     // set correct headers
     SpoonHTTP::setHeaders('content-type: application/javascript');
     // create a new template instance (this will handle all stuff for us)
     $tpl = new BackendTemplate();
     // enable addslashes on each locale
     $tpl->setAddSlashes(true);
     // display
     $tpl->display($path, true);
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:27,代码来源:javascript.php

示例5: parse

 /**
  * Parse the ical and output into the browser.
  *
  * @param bool[optional] $headers Should the headers be set? (Use false if you're debugging).
  */
 public function parse($headers = true)
 {
     // set headers
     if ((bool) $headers) {
         SpoonHTTP::setHeaders('Content-Disposition: inline; filename=' . SpoonFilter::urlise($this->getTitle()) . '.ics');
     }
     // call the parent
     parent::parse($headers);
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:14,代码来源:ical.php

示例6: parse

 /**
  * Parse the iCal and output into the browser.
  *
  * @param bool $headers Should the headers be set? (Use false if you're debugging).
  */
 public function parse($headers = true)
 {
     // set headers
     if ((bool) $headers) {
         \SpoonHTTP::setHeaders('Content-Disposition: inline; filename=' . CommonUri::getUrl($this->getTitle()) . '.ics');
     }
     // call the parent
     parent::parse($headers);
 }
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:14,代码来源:Ical.php

示例7: parse

 /**
  * Export the templates as XML.
  */
 protected function parse()
 {
     $xml = Model::createTemplateXmlForExport($this->selectedTheme);
     $filename = 'templates_' . BackendModel::getUTCDate('d-m-Y') . '.xml';
     $headers = array('Content-type: text/xml', 'Content-disposition: attachment; filename="' . $filename . '"');
     \SpoonHTTP::setHeaders($headers);
     echo $xml;
     exit;
 }
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:12,代码来源:ExportThemeTemplates.php

示例8: display

 /**
  * Output the template into the browser
  * Will also assign the interfacelabels and all user-defined constants.
  *
  * @param string $template The path for the template.
  * @param bool[optional] $customHeaders Are there custom headers set?
  */
 public function display($template, $customHeaders = false)
 {
     $this->parseConstants();
     $this->parseAuthenticatedUser();
     $this->parseDebug();
     $this->parseLabels();
     $this->parseLocale();
     $this->parseVars();
     // parse headers
     if (!$customHeaders) {
         SpoonHTTP::setHeaders('Content-type: text/html;charset=' . SPOON_CHARSET);
     }
     parent::display($template);
 }
开发者ID:richsage,项目名称:forkcms,代码行数:21,代码来源:template.php

示例9: createXML

 /**
  * Create the XML based on the locale items.
  *
  * @return	void
  */
 private function createXML()
 {
     // create XML
     $xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
     // xml headers
     $headers[] = 'Content-Disposition: attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"';
     $headers[] = 'Content-Type: application/octet-stream;charset=utf-8';
     $headers[] = 'Content-Length: ' . strlen($xmlOutput);
     // set headers
     SpoonHTTP::setHeaders($headers);
     // output XML
     echo $xmlOutput;
     // stop script
     exit;
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:20,代码来源:export_analyse.php

示例10: createXML

 /**
  * Create the XML based on the locale items.
  */
 private function createXML()
 {
     $charset = BackendModel::getContainer()->getParameter('kernel.charset');
     // create XML
     $xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
     // xml headers
     $headers[] = 'Content-Disposition: attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"';
     $headers[] = 'Content-Type: application/octet-stream;charset=' . $charset;
     $headers[] = 'Content-Length: ' . strlen($xmlOutput);
     // set headers
     \SpoonHTTP::setHeaders($headers);
     // output XML
     echo $xmlOutput;
     exit;
 }
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:18,代码来源:ExportAnalyse.php

示例11: createCsv

 /**
  * Create the CSV.
  *
  * @return	void
  */
 private function createCsv()
 {
     // create csv
     $csv = SpoonFileCSV::arrayToString($this->rows, $this->columnHeaders);
     // set headers for download
     $headers[] = 'Content-type: application/csv; charset=utf-8';
     $headers[] = 'Content-Disposition: attachment; filename="' . date('Ymd_His') . '.csv"';
     $headers[] = 'Content-Length: ' . strlen($csv);
     $headers[] = 'Pragma: no-cache';
     // overwrite the headers
     SpoonHTTP::setHeaders($headers);
     // output
     echo $csv;
     // exit here
     exit;
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:21,代码来源:export_data.php

示例12: downloadCSV

 /**
  * Sets the headers so we may download the CSV file in question
  *
  * @param string $path The full path to the CSV file you wish to download.
  * @return array
  */
 private function downloadCSV($path)
 {
     // check if the file exists
     if (!SpoonFile::exists($path)) {
         throw new SpoonFileException('The file ' . $path . ' doesn\'t exist.');
     }
     // fetch the filename from the path string
     $explodedFilename = explode('/', $path);
     $filename = end($explodedFilename);
     // set headers for download
     $headers[] = 'Content-type: application/csv; charset=' . SPOON_CHARSET;
     $headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
     $headers[] = 'Pragma: no-cache';
     // overwrite the headers
     SpoonHTTP::setHeaders($headers);
     // get the file contents
     $content = SpoonFile::getContent($path);
     // output the file contents
     echo $content;
     exit;
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:27,代码来源:addresses.php

示例13: display

 /**
  * Output the template into the browser
  * Will also assign the interfacelabels and all user-defined constants.
  *
  * @return	void
  * @param	string $template				The path for the template.
  * @param	bool[optional] $customHeaders	Are there custom headers set?
  */
 public function display($template, $customHeaders = false)
 {
     // parse constants
     $this->parseConstants();
     // parse authenticated user
     $this->parseAuthenticatedUser();
     // check debug
     $this->parseDebug();
     // parse the label
     $this->parseLabels();
     // parse locale
     $this->parseLocale();
     // parse some vars
     $this->parseVars();
     // parse headers
     if (!$customHeaders) {
         SpoonHTTP::setHeaders('Content-type: text/html;charset=utf-8');
     }
     // call the parent
     parent::display($template);
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:29,代码来源:template.php

示例14: exceptionAJAXHandler

 /**
  * This method will be called by the Spoon Exception handler and is specific for exceptions thrown in AJAX-actions
  *
  * @param object $exception The exception that was thrown.
  * @param string $output    The output that should be mailed.
  */
 public static function exceptionAJAXHandler($exception, $output)
 {
     \SpoonHTTP::setHeaders('content-type: application/json');
     $response = array('code' => $exception->getCode() != 0 ? $exception->getCode() : 500, 'message' => $exception->getMessage());
     echo json_encode($response);
     exit;
 }
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:13,代码来源:Init.php

示例15: outputXML

 /**
  * Output as XML
  *
  * @param int   $statusCode The status code.
  * @param array $data       The data to return.
  */
 private static function outputXML($statusCode, array $data = null)
 {
     // redefine
     $statusCode = (int) $statusCode;
     // init vars
     $charset = BackendModel::getContainer()->getParameter('kernel.charset');
     $pathChunks = explode(DIRECTORY_SEPARATOR, trim(dirname(__FILE__), DIRECTORY_SEPARATOR));
     $version = $pathChunks[count($pathChunks) - 2];
     $version = strtolower($version);
     // init XML
     $XML = new \DOMDocument('1.0', $charset);
     // set some properties
     $XML->preserveWhiteSpace = false;
     $XML->formatOutput = true;
     // create root element
     $root = $XML->createElement('fork');
     // add attributes
     $root->setAttribute('status_code', $statusCode);
     $root->setAttribute('status', $statusCode == 200 ? 'ok' : 'error');
     $root->setAttribute('version', FORK_VERSION);
     $root->setAttribute('endpoint', SITE_URL . '/api/' . $version);
     // append
     $XML->appendChild($root);
     // build XML
     array_walk($data, array(__CLASS__, 'arrayToXML'), $root);
     // set correct headers
     \SpoonHTTP::setHeadersByCode($statusCode);
     \SpoonHTTP::setHeaders('content-type: text/xml;charset=' . $charset);
     // output XML
     self::$content = $XML->saveXML();
 }
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:37,代码来源:Api.php


注:本文中的SpoonHTTP::setHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。