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


PHP Requirements::get_combined_files_enabled方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     // @todo fix controller stack problems and re-activate
     //$this->autoFollowRedirection = false;
     CMSMenu::populate_menu();
     $this->backupCss = Config::inst()->get('LeftAndMain', 'extra_requirements_css');
     $this->backupJs = Config::inst()->get('LeftAndMain', 'extra_requirements_javascript');
     $this->backupCombined = Requirements::get_combined_files_enabled();
     Config::inst()->update('LeftAndMain', 'extra_requirements_css', array(FRAMEWORK_DIR . '/tests/assets/LeftAndMainTest.css'));
     Config::inst()->update('LeftAndMain', 'extra_requirements_javascript', array(FRAMEWORK_DIR . '/tests/assets/LeftAndMainTest.js'));
     Requirements::set_combined_files_enabled(false);
 }
开发者ID:nickbooties,项目名称:silverstripe-framework,代码行数:13,代码来源:LeftAndMainTest.php

示例2: process_combined_files

 /**
  * See {@link combine_files()}
  *
  */
 function process_combined_files()
 {
     if (Director::isDev() && !SapphireTest::is_running_test() || !Requirements::get_combined_files_enabled()) {
         return;
     }
     // Make a map of files that could be potentially combined
     $combinerCheck = array();
     foreach ($this->combine_files as $combinedFile => $sourceItems) {
         foreach ($sourceItems as $sourceItem) {
             if (isset($combinerCheck[$sourceItem]) && $combinerCheck[$sourceItem] != $combinedFile) {
                 user_error("Requirements::process_combined_files - file '{$sourceItem}' appears in two combined files:" . " '{$combinerCheck[$sourceItem]}' and '{$combinedFile}'", E_USER_WARNING);
             }
             $combinerCheck[$sourceItem] = $combinedFile;
         }
     }
     // Figure out which ones apply to this pageview
     $combinedFiles = array();
     $newJSRequirements = array();
     $newCSSRequirements = array();
     foreach ($this->javascript as $file => $dummy) {
         if (isset($combinerCheck[$file])) {
             $newJSRequirements[$combinerCheck[$file]] = true;
             $combinedFiles[$combinerCheck[$file]] = true;
         } else {
             $newJSRequirements[$file] = true;
         }
     }
     foreach ($this->css as $file => $params) {
         if (isset($combinerCheck[$file])) {
             $newCSSRequirements[$combinerCheck[$file]] = true;
             $combinedFiles[$combinerCheck[$file]] = true;
         } else {
             $newCSSRequirements[$file] = $params;
         }
     }
     // Process the combined files
     $base = Director::baseFolder() . '/';
     foreach (array_diff_key($combinedFiles, $this->blocked) as $combinedFile => $dummy) {
         $fileList = $this->combine_files[$combinedFile];
         // Determine if we need to build the combined include
         if (file_exists($base . $combinedFile) && !isset($_GET['flush'])) {
             // file exists, check modification date of every contained file
             $srcLastMod = 0;
             foreach ($fileList as $file) {
                 $srcLastMod = max(filemtime($base . $file), $srcLastMod);
             }
             $refresh = $srcLastMod > filemtime($base . $combinedFile);
         } else {
             // file doesn't exist, or refresh was explicitly required
             $refresh = true;
         }
         if (!$refresh) {
             continue;
         }
         $combinedData = "";
         foreach (array_diff($fileList, $this->blocked) as $file) {
             $fileContent = file_get_contents($base . $file);
             // if we have a javascript file and jsmin is enabled, minify the content
             $isJS = stripos($file, '.js');
             if ($isJS && $this->combine_js_with_jsmin) {
                 require_once 'thirdparty/jsmin/JSMin.php';
                 increase_time_limit_to();
                 $fileContent = JSMin::minify($fileContent);
             }
             // write a header comment for each file for easier identification and debugging
             // also the semicolon between each file is required for jQuery to be combinable properly
             $combinedData .= "/****** FILE: {$file} *****/\n" . $fileContent . "\n" . ($isJS ? ';' : '') . "\n";
         }
         if (!file_exists(dirname($base . $combinedFile))) {
             Filesystem::makeFolder(dirname($base . $combinedFile));
         }
         $successfulWrite = false;
         $fh = fopen($base . $combinedFile, 'w');
         if ($fh) {
             if (fwrite($fh, $combinedData) == strlen($combinedData)) {
                 $successfulWrite = true;
             }
             fclose($fh);
             unset($fh);
         }
         // Unsuccessful write - just include the regular JS files, rather than the combined one
         if (!$successfulWrite) {
             user_error("Requirements_Backend::process_combined_files(): Couldn't create '{$base}{$combinedFile}'", E_USER_WARNING);
             return;
         }
     }
     // @todo Alters the original information, which means you can't call this
     // method repeatedly - it will behave different on the second call!
     $this->javascript = $newJSRequirements;
     $this->css = $newCSSRequirements;
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:95,代码来源:Requirements.php


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