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


PHP Minify::_controller方法代码示例

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


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

示例1: serve


//.........这里部分代码省略.........
  * @return mixed null, or, if the 'quiet' option is set to true, an array
  * with keys "success" (bool), "statusCode" (int), "content" (string), and
  * "headers" (array).
  */
 public static function serve($controller, $options = array())
 {
     if (!self::$isDocRootSet && 0 === stripos(PHP_OS, 'win')) {
         self::setDocRoot();
     }
     if (is_string($controller)) {
         // make $controller into object
         $class = 'Minify_Controller_' . $controller;
         if (!class_exists($class, false)) {
             require_once "Minify/Controller/" . str_replace('_', '/', $controller) . ".php";
         }
         $controller = new $class();
         /* @var Minify_Controller_Base $controller */
     }
     // set up controller sources and mix remaining options with
     // controller defaults
     $options = $controller->setupSources($options);
     $options = $controller->analyzeSources($options);
     self::$_options = $controller->mixInDefaultOptions($options);
     // check request validity
     if (!$controller->sources) {
         // invalid request!
         if (!self::$_options['quiet']) {
             self::_errorExit(self::$_options['badRequestHeader'], self::URL_DEBUG);
         } else {
             list(, $statusCode) = explode(' ', self::$_options['badRequestHeader']);
             return array('success' => false, 'statusCode' => (int) $statusCode, 'content' => '', 'headers' => array());
         }
     }
     self::$_controller = $controller;
     if (self::$_options['debug']) {
         self::_setupDebug($controller->sources);
         self::$_options['maxAge'] = 0;
     }
     // determine encoding
     if (self::$_options['encodeOutput']) {
         $sendVary = true;
         if (self::$_options['encodeMethod'] !== null) {
             // controller specifically requested this
             $contentEncoding = self::$_options['encodeMethod'];
         } else {
             // sniff request header
             require_once 'HTTP/Encoder.php';
             // depending on what the client accepts, $contentEncoding may be
             // 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
             // getAcceptedEncoding(false, false) leaves out compress and deflate as options.
             list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(false, false);
             $sendVary = !HTTP_Encoder::isBuggyIe();
         }
     } else {
         self::$_options['encodeMethod'] = '';
         // identity (no encoding)
     }
     // check client cache
     require_once 'HTTP/ConditionalGet.php';
     $cgOptions = array('lastModifiedTime' => self::$_options['lastModifiedTime'], 'isPublic' => self::$_options['isPublic'], 'encoding' => self::$_options['encodeMethod']);
     if (self::$_options['maxAge'] > 0) {
         $cgOptions['maxAge'] = self::$_options['maxAge'];
     } elseif (self::$_options['debug']) {
         $cgOptions['invalidate'] = true;
     }
     $cg = new HTTP_ConditionalGet($cgOptions);
开发者ID:mover5,项目名称:imobackup,代码行数:67,代码来源:Minify.php

示例2: serve


//.........这里部分代码省略.........
  * @param array $options controller/serve options
  *
  * @return mixed null, or, if the 'quiet' option is set to true, an array
  * with keys "success" (bool), "statusCode" (int), "content" (string), and
  * "headers" (array).
  */
 public static function serve($controller, $options = array())
 {
     if (is_string($controller)) {
         // make $controller into object
         $class = 'Minify_Controller_' . $controller;
         if (!class_exists($class, false)) {
             require_once W3TC_LIB_MINIFY_DIR . "/Minify/Controller/" . str_replace('_', '/', $controller) . ".php";
         }
         $controller = new $class();
     }
     // set up controller sources and mix remaining options with
     // controller defaults
     $options = $controller->setupSources($options);
     $options = $controller->analyzeSources($options);
     self::$_options = $controller->mixInDefaultOptions($options);
     // check request validity
     if (!$controller->sources) {
         // invalid request!
         if (!self::$_options['quiet']) {
             header(self::$_options['badRequestHeader']);
             echo self::$_options['badRequestHeader'];
             return;
         } else {
             list(, $statusCode) = explode(' ', self::$_options['badRequestHeader']);
             return array('success' => false, 'statusCode' => (int) $statusCode, 'content' => '', 'headers' => array());
         }
     }
     self::$_controller = $controller;
     if (self::$_options['debug']) {
         self::_setupDebug($controller->sources);
         self::$_options['maxAge'] = 0;
     }
     // determine encoding
     if (self::$_options['encodeOutput']) {
         if (self::$_options['encodeMethod'] !== null) {
             // controller specifically requested this
             $contentEncoding = self::$_options['encodeMethod'];
         } else {
             // sniff request header
             require_once W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php';
             // depending on what the client accepts, $contentEncoding may be
             // 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
             // getAcceptedEncoding(false, false) leaves out compress and deflate as options.
             list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(self::$_options['encodeOutput']);
         }
     } else {
         self::$_options['encodeMethod'] = '';
         // identity (no encoding)
     }
     // check client cache
     require_once W3TC_LIB_MINIFY_DIR . '/HTTP/ConditionalGet.php';
     $cgOptions = array('cacheHeaders' => self::$_options['cacheHeaders'], 'lastModifiedTime' => self::$_options['lastModifiedTime'], 'isPublic' => self::$_options['isPublic'], 'encoding' => self::$_options['encodeMethod']);
     if (self::$_options['maxAge'] > 0) {
         $cgOptions['maxAge'] = self::$_options['maxAge'];
     }
     $cg = new HTTP_ConditionalGet($cgOptions);
     if ($cg->cacheIsValid) {
         // client's cache is valid
         if (!self::$_options['quiet']) {
             $cg->sendHeaders();
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:67,代码来源:Minify.php


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