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


PHP header::type方法代码示例

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


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

示例1: header

 /**
  * Sends the correct header for the response
  *
  * @param boolean $send If set to false, the header will be returned
  * @return mixed
  */
 public function header($send = true)
 {
     $status = header::status($this->code, false);
     $type = header::type($this->format, 'utf-8', false);
     if (!$send) {
         return $status . PHP_EOL . $type;
     }
     header($status);
     header($type);
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:16,代码来源:response.php

示例2: header

 /**
  * Sends an appropriate header for the asset
  *
  * @param boolean $send
  * @return mixed
  */
 public function header($send = true)
 {
     return header::type($this->mime(), false, $send);
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:10,代码来源:media.php

示例3: launch

 /**
  * Starts the router, renders the page and returns the response
  *
  * @return mixed
  */
 public function launch()
 {
     // this will trigger the configuration
     $site = $this->site();
     // force secure connections if enabled
     if ($this->option('ssl') and !r::secure()) {
         // rebuild the current url with https
         go(url::build(array('scheme' => 'https')));
     }
     // set the timezone for all date functions
     date_default_timezone_set($this->options['timezone']);
     // load all extensions
     $this->extensions();
     // load all plugins
     $this->plugins();
     // load all models
     $this->models();
     // start the router
     $this->router = new Router($this->routes());
     $this->route = $this->router->run($this->path());
     // check for a valid route
     if (is_null($this->route)) {
         header::status('500');
         header::type('json');
         die(json_encode(array('status' => 'error', 'message' => 'Invalid route or request method')));
     }
     // call the router action with all arguments from the pattern
     $response = call($this->route->action(), $this->route->arguments());
     // load all language variables
     // this can only be loaded once the router action has been called
     // otherwise the current language is not yet available
     $this->localize();
     // build the response
     $this->response = $this->component('response')->make($response);
     // store the current language in the session
     if ($this->site()->multilang() && ($language = $this->site()->language())) {
         s::set('language', $language->code());
     }
     return $this->response;
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:45,代码来源:kirby.php

示例4: show

 /**
  * Read and send the file with the correct headers
  *
  * @param string $file
  */
 public static function show($file)
 {
     // stop the download if the file does not exist or is not readable
     if (!is_file($file) or !is_readable($file)) {
         return false;
     }
     // send the browser headers
     header::type(f::mime($file));
     // send the file
     die(f::read($file));
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:16,代码来源:f.php

示例5: function

 */
Pages::$methods['feed'] = function ($pages, $params = array()) {
    // set all default values
    $defaults = array('url' => url(), 'title' => 'Blog Feed', 'description' => 'Latest articles from the blog', 'link' => url(), 'datefield' => 'modified', 'textfield' => 'text', 'modified' => time(), 'excerpt' => false, 'generator' => kirby()->option('feed.generator', 'Kirby'), 'header' => true, 'snippet' => false);
    // merge them with the user input
    $options = array_merge($defaults, $params);
    // sort by date
    $items = $pages->sortBy($options['datefield'], 'desc');
    // add the items
    $options['items'] = $items;
    $options['link'] = url($options['link']);
    // fetch the modification date
    if ($options['datefield'] == 'modified') {
        $options['modified'] = $items->first()->modified();
    } else {
        $options['modified'] = $items->first()->date(false, $options['datefield']);
    }
    // send the xml header
    if ($options['header']) {
        header::type('text/xml');
    }
    // echo the doctype
    $html = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
    // custom snippet
    if ($options['snippet']) {
        $html .= snippet($options['snippet'], $options, true);
    } else {
        $html .= tpl::load(__DIR__ . DS . 'template.php', $options);
    }
    return $html;
};
开发者ID:hemorej,项目名称:kirby-foundation,代码行数:31,代码来源:feed.php

示例6: response

 public function response()
 {
     // this will trigger the configuration
     $site = $this->site();
     $router = new Router($this->routes());
     $route = $router->run($this->path());
     // check for a valid route
     if (is_null($route)) {
         header::status('500');
         header::type('json');
         die(json_encode(array('status' => 'error', 'message' => 'Invalid route or request method')));
     }
     $response = call($route->action(), $route->arguments());
     if (is_string($response)) {
         $this->response = static::render(page($response));
     } else {
         if (is_array($response)) {
             $this->response = static::render(page($response[0]), $response[1]);
         } else {
             if (is_a($response, 'Response')) {
                 $this->response = $response;
             } else {
                 if (is_a($response, 'Page')) {
                     $this->response = static::render($response);
                 } else {
                     $this->response = null;
                 }
             }
         }
     }
     return $this->response;
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:32,代码来源:kirby.php

示例7: substr

 if ($page && ($image = $page->file($filename . $extension))) {
     $modified = substr(md5($image->modified()), 0, 12);
     if ($modified === $hash) {
         // thumb root
         $path = str_replace('/', DS, $page->id());
         $root = kirby()->roots()->index() . DS . 'thumbs' . DS . $path;
         // create directories if necessary
         if (!f::exists($root)) {
             dir::make($root, true);
         }
         // thumb url
         $url = kirby()->urls()->index() . '/thumbs/' . $page->id();
         // create thumb
         $thumb = thumb($image, array('destination' => true, 'width' => $width, 'filename' => '{safeName}-{width}-' . $modified . '.{extension}', 'root' => $root, 'url' => $url));
         // send headers
         header::type($image->mime());
         header('Cache-control: max-age=' . 60 * 60 * 24 * 365);
         header('Expires: ' . gmdate(DATE_RFC1123, time() + 60 * 60 * 24 * 365));
         // read file
         function readFileChunked($filename, $retbytes = true)
         {
             $chunkSize = 8192;
             $buffer = '';
             $cnt = 0;
             $handle = fopen($filename, 'rb');
             if ($handle === false) {
                 return false;
             }
             while (!feof($handle)) {
                 $buffer = fread($handle, $chunkSize);
                 echo $buffer;
开发者ID:aoimedia,项目名称:kirby-resize-on-demand-plugin,代码行数:31,代码来源:resizeOnDemand.php


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