本文整理汇总了PHP中Requirements::process_combined_files方法的典型用法代码示例。如果您正苦于以下问题:PHP Requirements::process_combined_files方法的具体用法?PHP Requirements::process_combined_files怎么用?PHP Requirements::process_combined_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requirements
的用法示例。
在下文中一共展示了Requirements::process_combined_files方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadStyles
public function loadStyles()
{
$config = Config::inst();
$_path = 'themes/' . $config->get("SSViewer", 'theme') . '/';
$_isCustomCSSSpecified = count($this->_css);
$_isCustomJSSpecified = count($this->_js);
Requirements::clear();
$jsItems = array(THIRDPARTY_DIR . '/jquery/jquery.js', THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', $_path . 'javascript/jquery.pubsub.js', $_path . 'javascript/getParameterByName.js', $_path . 'javascript/URLEncode.js', $_path . 'javascript/forCrappyBrowsers.js', $_path . 'javascript/ga.js', $_path . 'javascript/SocialScripts.js');
$jsItemsCustom = array();
if ($_isCustomJSSpecified) {
foreach ($this->_js as $jsFileName) {
array_push($jsItemsCustom, $_path . 'javascript/' . $jsFileName . '.js');
}
}
$cssItems = array($_path . 'css/layout.css');
$cssItemsCustom = array();
if ($_isCustomCSSSpecified) {
foreach ($this->_css as $cssFileName) {
array_push($cssItemsCustom, $_path . 'css/' . $cssFileName . '.css');
}
}
foreach ($jsItems as $item) {
Requirements::javascript($item);
}
foreach ($cssItems as $item) {
Requirements::css($item);
}
foreach ($jsItemsCustom as $item) {
Requirements::javascript($item);
}
foreach ($cssItemsCustom as $item) {
Requirements::css($item);
}
/*
Combine the files, append the custom file name if specified to avoid conflict
*/
Requirements::combine_files('assets/cache/css/cssmin.css', $cssItems);
if ($_isCustomCSSSpecified) {
Requirements::combine_files('assets/cache/css/cssmin_' . str_replace('/', '_', $this->Link()) . '.css', $cssItemsCustom);
}
Requirements::combine_files('assets/cache/javascript/jsmin.js', $jsItems);
if ($_isCustomJSSpecified) {
Requirements::combine_files('assets/cache/javascript/jsmin_' . str_replace('/', '_', $this->Link()) . '.js', $jsItemsCustom);
}
// Now do the combine
Requirements::process_combined_files();
if ($pos = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
$version = substr($_SERVER['HTTP_USER_AGENT'], $pos + 5, 3);
if ($version <= 7) {
Requirements::css($_path . 'css/iesucks.css');
}
Requirements::javascript($_path . 'javascript/ie-placeholder.js');
}
}
示例2: setupRequirements
public static function setupRequirements($cssArray = array(), $jsArray = array())
{
$siteConfig = SiteConfig::current_site_config();
// Don't combine files if in admin to prevent error on "login as someone else" screen
$inAdmin = is_subclass_of(Controller::curr(), "LeftAndMain");
// Setup requirements
if (isset(Page_Controller::$themeFolderAndSubfolder) && Page_Controller::$themeFolderAndSubfolder) {
self::$themeFolderAndSubfolder = Page_Controller::$themeFolderAndSubfolder;
} else {
$currentTheme = SSViewer::current_theme();
self::$themeFolderAndSubfolder = 'themes/' . $currentTheme;
}
//Set a custom combined folder under themes so relative paths to images within CSS and JavaScript files don't break
Requirements::set_combined_files_folder(self::$themeFolderAndSubfolder . '/combined');
// CSS array
if (count($cssArray)) {
foreach ($cssArray as $css) {
Requirements::css($css);
}
if (!$inAdmin) {
Requirements::combine_files("combined-" . $siteConfig->ID . ".css", $cssArray);
}
}
// Javascript array
if (count($jsArray)) {
foreach ($jsArray as $js) {
Requirements::javascript($js);
}
if (!$inAdmin) {
Requirements::combine_files("combined-" . $siteConfig->ID . ".js", $jsArray);
}
}
if (!$inAdmin) {
Requirements::process_combined_files();
}
// Google analytics
if (!Director::isDev()) {
if (isset($siteConfig->GoogleAnalyticsCode)) {
Requirements::insertHeadTags($siteConfig->GoogleAnalyticsCode);
}
}
// End Google analytics
}
示例3: testRequirementsCombine
public function testRequirementsCombine()
{
$oldBackend = Requirements::backend();
$testBackend = new Requirements_Backend();
Requirements::set_backend($testBackend);
$combinedTestFilePath = BASE_PATH . '/' . $testBackend->getCombinedFilesFolder() . '/testRequirementsCombine.js';
$jsFile = FRAMEWORK_DIR . '/tests/view/themes/javascript/bad.js';
$jsFileContents = file_get_contents(BASE_PATH . '/' . $jsFile);
Requirements::combine_files('testRequirementsCombine.js', array($jsFile));
require_once 'thirdparty/jsmin/jsmin.php';
// first make sure that our test js file causes an exception to be thrown
try {
$content = JSMin::minify($content);
Requirements::set_backend($oldBackend);
$this->fail('JSMin did not throw exception on minify bad file: ');
} catch (Exception $e) {
// exception thrown... good
}
// secondly, make sure that requirements combine throws the correct warning, and only that warning
@unlink($combinedTestFilePath);
try {
Requirements::process_combined_files();
} catch (PHPUnit_Framework_Error_Warning $e) {
if (strstr($e->getMessage(), 'Failed to minify') === false) {
Requirements::set_backend($oldBackend);
$this->fail('Requirements::process_combined_files raised a warning, which is good, but this is not the expected warning ("Failed to minify..."): ' . $e);
}
} catch (Exception $e) {
Requirements::set_backend($oldBackend);
$this->fail('Requirements::process_combined_files did not catch exception caused by minifying bad js file: ' . $e);
}
// and make sure the combined content matches the input content, i.e. no loss of functionality
if (!file_exists($combinedTestFilePath)) {
Requirements::set_backend($oldBackend);
$this->fail('No combined file was created at expected path: ' . $combinedTestFilePath);
}
$combinedTestFileContents = file_get_contents($combinedTestFilePath);
$this->assertContains($jsFileContents, $combinedTestFileContents);
// reset
Requirements::set_backend($oldBackend);
}
示例4: array
}
//jpeg quality
Config::inst()->update('GDBackend', 'default_quality', 80);
// block the default page build
SiteTree::set_create_default_pages(false);
Config::inst()->update('SiteTree', 'create_default_pages', false);
// --------------------------------- //
// Assets
// --------------------------------- //
Requirements::set_write_js_to_body(true);
Requirements::set_combined_files_enabled(true);
// HTML5 Shims
// -----------
$shimRequirements = array('thirdparty/selectivizr/index.js', 'thirdparty/respond/dest/respond.min.js', 'thirdparty/modernizr/modernizr.js');
Requirements::combine_files('lte-ie8-shims.js', $shimRequirements);
Requirements::process_combined_files();
// forces ss to generate the file regardless of blocking
// CSS
// ---
$cssRequirements = array('themes/project/css/main.css', 'themes/project/css/typography.css');
Requirements::combine_files('application.css', $cssRequirements);
// Primary JS
// ----------
$jsRequirements = array('thirdparty/jquery/dist/jquery.min.js', 'project/javascript/main.js', 'project/javascript/forms.js');
Requirements::combine_files('application.js', $jsRequirements);
// Asset loading
// -------------
// block jquery
// block the combined shims + component files so we can lead them manually
RequirementsHelper::require_block(array_merge(array('assets/_combinedfiles/lte-ie8-shims.js', 'framework/thirdparty/jquery/jquery.js'), $shimRequirements));
// dump this into a conditional
示例5: flushCombined
/**
* Rebuilds the cache for combined CSS and JS files.
*/
public function flushCombined()
{
// Split any the combined files.
Requirements::process_combined_files();
}
示例6: httpError
/**
* Returns the HTTP error response.
*
* @param string $code Error code
* @param string $message Error message
*
* @return void
*
* @throws SS_HTTPResponse_Exception
* @author Sebastian Diel <sdiel@pixeltricks.de>
* @since 07.05.2015
*/
public function httpError($code, $message = null)
{
$combined_files = Requirements::get_combine_files();
try {
$response = parent::httpError($code, $message);
} catch (SS_HTTPResponse_Exception $e) {
$originalResponse = $e->getResponse();
Requirements::restore();
foreach ($combined_files as $combinedFileName => $files) {
Requirements::combine_files($combinedFileName, $files);
Requirements::process_combined_files();
}
$response = $this->request->isMedia() ? null : self::error_response_for($code);
throw new SS_HTTPResponse_Exception($response ? $response : ($originalResponse ? $originalResponse : $message), $code);
}
}