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


PHP Minify::isDocRootSet方法代码示例

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


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

示例1: action_index

 public function action_index()
 {
     $group = $this->request->param('group');
     if (!empty($group)) {
         $_GET['g'] = $group;
     }
     $config = Kohana::$config->load('minify');
     Minify::$uploaderHoursBehind = $config['uploaderHoursBehind'];
     Minify::setCache(isset($config['cachePath']) ? $config['cachePath'] : '', $config['cacheFileLocking']);
     if ($config['documentRoot']) {
         $_SERVER['DOCUMENT_ROOT'] = $config['documentRoot'];
         Minify::$isDocRootSet = TRUE;
     }
     $serve_options = $config['serveOptions'];
     $serve_options['minifierOptions']['text/css']['symlinks'] = $config['symlinks'];
     foreach ($config['symlinks'] as $uri => $target) {
         $serve_options['minApp']['allowDirs'][] = $target;
     }
     if ($config['allowDebugFlag']) {
         $serve_options['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
     }
     if ($config['errorLogger']) {
         if (TRUE === $config['errorLogger']) {
             Minify_Logger::setLogger(FirePHP::getInstance(true));
         } else {
             Minify_Logger::setLogger($config['errorLogger']);
         }
     }
     // Check for URI versioning
     if (preg_match('/&\\d/', Arr::get($_SERVER, 'QUERY_STRING'))) {
         $serve_options['maxAge'] = 31536000;
     }
     if (isset($_GET['g'])) {
         // well need groups config
         $serve_options['minApp']['groups'] = $config['groupsConfig'];
     }
     if (isset($_GET['f']) or isset($_GET['g'])) {
         $response = Minify::serve(new Minify_Controller_MinApp(), array('quiet' => TRUE) + $serve_options);
         $this->response->headers($response['headers'])->status($response['statusCode'])->body($response['content']);
     }
 }
开发者ID:pdt256,项目名称:kohana-minify,代码行数:41,代码来源:Minify.php

示例2: action_index

 public function action_index()
 {
     extract(Kohana::$config->load('minify')->as_array(), EXTR_SKIP);
     if ($this->request->param('group')) {
         $_GET['g'] = $this->request->param('group');
     }
     Minify::$uploaderHoursBehind = $uploaderHoursBehind;
     Minify::setCache(isset($cachePath) ? $cachePath : '', $cacheFileLocking);
     if ($documentRoot) {
         $_SERVER['DOCUMENT_ROOT'] = $documentRoot;
         Minify::$isDocRootSet = TRUE;
     }
     $serveOptions['minifierOptions']['text/css']['symlinks'] = $symlinks;
     $serveOptions['minApp']['allowDirs'] += array_values($symlinks);
     if ($allowDebugFlag) {
         $serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
     }
     if ($errorLogger) {
         if (TRUE === $errorLogger) {
             $errorLogger = FirePHP::getInstance(TRUE);
         }
         Minify_Logger::setLogger($errorLogger);
     }
     // Check for URI versioning
     if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
         $serveOptions['maxAge'] = 31536000;
     }
     if (isset($_GET['g'])) {
         // Well need groups config
         $serveOptions['minApp']['groups'] = $groupsConfig;
     }
     if (isset($_GET['f']) or isset($_GET['g'])) {
         set_time_limit(0);
         // Serve!
         $response = Minify::serve(new Minify_Controller_MinApp(), array('quiet' => TRUE) + $serveOptions);
         $this->response->headers($response['headers'])->body($response['content'])->status($response['statusCode']);
     }
 }
开发者ID:anhtata,项目名称:minify-kohana,代码行数:38,代码来源:Index.php

示例3: setDocRoot

 /**
  * Set $_SERVER['DOCUMENT_ROOT']. On IIS, the value is created from SCRIPT_FILENAME and SCRIPT_NAME.
  * 
  * @param string $docRoot value to use for DOCUMENT_ROOT
  */
 public static function setDocRoot($docRoot = '')
 {
     self::$isDocRootSet = true;
     if ($docRoot) {
         $_SERVER['DOCUMENT_ROOT'] = $docRoot;
     } elseif (isset($_SERVER['SERVER_SOFTWARE']) && 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')) {
         $_SERVER['DOCUMENT_ROOT'] = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - strlen($_SERVER['SCRIPT_NAME']));
         $_SERVER['DOCUMENT_ROOT'] = rtrim($_SERVER['DOCUMENT_ROOT'], '\\');
     }
 }
开发者ID:mover5,项目名称:imobackup,代码行数:15,代码来源:Minify.php

示例4: dirname

 * 
 * @package Minify
 */
define('MINIFY_MIN_DIR', dirname(__FILE__));
// load config
require MINIFY_MIN_DIR . '/config.php';
if (isset($_GET['test'])) {
    include MINIFY_MIN_DIR . '/config-test.php';
}
require "{$min_libPath}/Minify/Loader.php";
Minify_Loader::register();
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
Minify::setCache(isset($min_cachePath) ? $min_cachePath : '', $min_cacheFileLocking);
if ($min_documentRoot) {
    $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
    Minify::$isDocRootSet = true;
}
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
// auto-add targets to allowDirs
foreach ($min_symlinks as $uri => $target) {
    $min_serveOptions['minApp']['allowDirs'][] = $target;
}
if ($min_allowDebugFlag) {
    $min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
}
if ($min_errorLogger) {
    if (true === $min_errorLogger) {
        $min_errorLogger = FirePHP::getInstance(true);
    }
    Minify_Logger::setLogger($min_errorLogger);
}
开发者ID:jonca44,项目名称:pdf-mailmerge,代码行数:31,代码来源:index.php

示例5: serve

 /**
  * Serves friendly minify url with minified contents
  *
  * This actually does a remote get from Minify's dir with appropriate `?f`
  * query variable built from persistently stored detected enqueued files.
  * All minified contents as well as headers should be preserved.
  *
  * Serving friendly minify urls like this cause a lot of overheads, but is
  * safer to use than server rewrite rules.
  *
  * @uses wp_remote_get()
  * @return void
  */
 public function serve($query)
 {
     $group_handle = isset($_GET['min_group']) ? $this->_sanitize_request($_GET['min_group']) : '';
     $type = isset($_GET['min_type']) && in_array($_GET['min_type'], array('js', 'css')) ? $_GET['min_type'] : '';
     $bid = isset($_GET['blog']) ? (int) $_GET['blog'] : 0;
     if (empty($group_handle) || empty($type) || empty($bid)) {
         // if missing any important data, do not proceed
         return;
     }
     global $blog_id;
     if ($bid != $blog_id) {
         // if not on the correct blog, do not proceed
         return;
     }
     $group = $this->_detector->get_group($group_handle);
     if (false == $group) {
         // this should not happen, but just in case it does
         echo sprintf(__('Minify group %s not found.', $this->_domain), $group_handle);
         exit;
     }
     // load Minify class based on default or custom Minify directory
     $min_dir = $this->_main->get_min_dir();
     if (empty($min_dir) || !file_exists($min_dir . 'config.php')) {
         // if Minify directory is not valid or Minify library is not found
         // we can not continue
         _e('Invalid Minify directory, please check Minify settings.', $this->_domain);
         exit;
     }
     // prepare input for Minify to handle
     $_GET['f'] = $group['string'];
     if ($this->_options['enable_debug'] == 'yes') {
         // add debug flag if needed
         $_GET['debug'] = 1;
     } else {
         // minified contents are often served compressed so it's best to turn off
         // error reporting to avoid content encoding error, unless debug is
         // enabled. This is useful when Minify doesn't catch all the notices
         // (for example when the cache directory is not writable).
         error_reporting(0);
     }
     // load Minify classes
     define('MINIFY_MIN_DIR', $min_dir);
     require_once MINIFY_MIN_DIR . '/config.php';
     require_once $min_libPath . '/Minify/Loader.php';
     Minify_Loader::register();
     // set some optional for the Minify application based on current settings
     Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
     // set cache file name (id) and cache path if needed
     Minify::setCacheId('minify-b' . $blog_id . '-' . $group_handle . '.' . $type);
     Minify::setCache(isset($min_cachePath) ? $min_cachePath : '', $min_cacheFileLocking);
     if ($min_documentRoot) {
         $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
         Minify::$isDocRootSet = true;
     }
     // set serve options for each file type if needed
     $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
     foreach ($min_symlinks as $uri => $target) {
         $min_serveOptions['minApp']['allowDirs'][] = $target;
     }
     if ($min_allowDebugFlag) {
         // allow debugging Minify application
         $min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
     }
     if ($min_errorLogger) {
         // log Minify error if allowed
         if (true === $min_errorLogger) {
             $min_errorLogger = FirePHP::getInstance(true);
         }
         Minify_Logger::setLogger($min_errorLogger);
     }
     // serve minified contents, on the fly or from cache
     $min_serveController = new Minify_Controller_MinApp();
     Minify::serve($min_serveController, $min_serveOptions);
     // for a proper response headers
     exit;
 }
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:89,代码来源:class-bwp-minify-fetcher.php

示例6: connect

 public function connect(Application $app)
 {
     $app['controller.minifier'] = $this;
     $controllers = $app['controllers_factory'];
     $controllers->get('/', function (Application $app, Request $request) {
         // cache directory path
         $min_cachePath = $app['root.path'] . '/tmp/cache_minify';
         /**
          * Cache file locking. Set to false if filesystem is NFS. On at least one
          * NFS system flock-ing attempts stalled PHP for 30 seconds!
          */
         $min_cacheFileLocking = true;
         /**
          * Combining multiple CSS files can place @import declarations after rules, which
          * is invalid. Minify will attempt to detect when this happens and place a
          * warning comment at the top of the CSS output. To resolve this you can either
          * move the @imports within your CSS files, or enable this option, which will
          * move all @imports to the top of the output. Note that moving @imports could
          * affect CSS values (which is why this option is disabled by default).
          */
         $min_serveOptions['bubbleCssImports'] = false;
         if ($app['debug']) {
             // may cause js errors
             $min_serveOptions['debug'] = false;
             // disallow minification instead
             $min_serveOptions['minApp']['noMinPattern'] = '#\\.(?:js|css)$#i';
             $min_serveOptions['maxAge'] = 0;
         } else {
             $min_serveOptions['debug'] = false;
             $min_serveOptions['maxAge'] = 1800;
         }
         /**
          * Set to true to disable the "f" GET parameter for specifying files.
          * Only the "g" parameter will be considered.
          */
         $min_serveOptions['minApp']['groupsOnly'] = false;
         /**
          * Maximum # of files that can be specified in the "f" GET parameter
          */
         $min_serveOptions['minApp']['maxFiles'] = 10;
         /**
          * If you minify CSS files stored in symlink-ed directories, the URI rewriting
          * algorithm can fail. To prevent this, provide an array of link paths to
          * target paths, where the link paths are within the document root.
          *
          * Because paths need to be normalized for this to work, use "//" to substitute
          * the doc root in the link paths (the array keys). E.g.:
          * <code>
          * array('//symlink' => '/real/target/path') // unix
          * array('//static' => 'D:\\staticStorage')  // Windows
          * </code>
          */
         $min_symlinks = [];
         /**
          * If you upload files from Windows to a non-Windows server, Windows may report
          * incorrect mtimes for the files. This may cause Minify to keep serving stale
          * cache files when source file changes are made too frequently (e.g. more than
          * once an hour).
          *
          * Immediately after modifying and uploading a file, use the touch command to
          * update the mtime on the server. If the mtime jumps ahead by a number of hours,
          * set this variable to that number. If the mtime moves back, this should not be
          * needed.
          *
          * In the Windows SFTP client WinSCP, there's an option that may fix this
          * issue without changing the variable below. Under login > environment,
          * select the option "Adjust remote timestamp with DST".
          * @link http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time
          */
         $min_uploaderHoursBehind = 0;
         // return an array instead of echoing output
         $min_serveOptions['quiet'] = true;
         \Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
         \Minify::setCache(isset($min_cachePath) ? $min_cachePath : '', $min_cacheFileLocking);
         // required to work well :(
         $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../../www/';
         \Minify::$isDocRootSet = true;
         $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
         // auto-add targets to allowDirs
         foreach ($min_symlinks as $uri => $target) {
             $min_serveOptions['minApp']['allowDirs'][] = $target;
         }
         if (null !== $request->query->get('g')) {
             // well need groups config
             $min_serveOptions['minApp']['groups'] = (require __DIR__ . '/../../../conf.d/minifyGroupsConfig.php');
         }
         if (null === $request->query->get('f') && null === $request->query->get('g')) {
             throw new HttpException(400, 'Please provide an argument');
         }
         $ret = \Minify::serve(new \Minify_Controller_MinApp(), $min_serveOptions);
         if (!$ret['success']) {
             throw new HttpException(500, 'Unable to generate data');
         }
         $response = new Response($ret['content'], $ret['statusCode']);
         $response->setMaxAge($min_serveOptions['maxAge']);
         foreach ($ret['headers'] as $key => $value) {
             $response->headers->set($key, $value);
         }
         return $response;
     })->bind('minifier');
//.........这里部分代码省略.........
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:101,代码来源:Minifier.php

示例7: setDocRoot

 /**
  * On IIS, create $_SERVER['DOCUMENT_ROOT']
  * 
  * @param bool $unsetPathInfo (default false) if true, $_SERVER['PATH_INFO']
  * will be unset (it is inconsistent with Apache's setting)
  * 
  * @return null
  */
 public static function setDocRoot($unsetPathInfo = false)
 {
     if (isset($_SERVER['SERVER_SOFTWARE']) && 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')) {
         $_SERVER['DOCUMENT_ROOT'] = rtrim(substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - strlen($_SERVER['SCRIPT_NAME'])), '\\');
         if ($unsetPathInfo) {
             unset($_SERVER['PATH_INFO']);
         }
         require_once 'Minify/Logger.php';
         Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\"");
     }
     self::$isDocRootSet = true;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:20,代码来源:Minify.php


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