mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-02-01 17:49:58 +09:00
Add phpass and update composer libraries
This commit is contained in:
parent
9d6284faad
commit
69c5147888
25 changed files with 1039 additions and 161 deletions
78
vendor/matthiasmullie/minify/src/CSS.php
vendored
78
vendor/matthiasmullie/minify/src/CSS.php
vendored
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MatthiasMullie\Minify;
|
||||
|
||||
use MatthiasMullie\Minify\Exceptions\FileImportException;
|
||||
use MatthiasMullie\PathConverter\Converter;
|
||||
|
||||
/**
|
||||
|
|
@ -68,7 +69,7 @@ class CSS extends Minify
|
|||
/**
|
||||
* Move any import statements to the top.
|
||||
*
|
||||
* @param $content string Nearly finished CSS content
|
||||
* @param string $content Nearly finished CSS content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -94,12 +95,15 @@ class CSS extends Minify
|
|||
* @import's will be loaded and their content merged into the original file,
|
||||
* to save HTTP requests.
|
||||
*
|
||||
* @param string $source The file to combine imports for.
|
||||
* @param string $content The CSS content to combine imports for.
|
||||
* @param string $source The file to combine imports for.
|
||||
* @param string $content The CSS content to combine imports for.
|
||||
* @param string[] $parents Parent paths, for circular reference checks.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FileImportException
|
||||
*/
|
||||
protected function combineImports($source, $content)
|
||||
protected function combineImports($source, $content, $parents)
|
||||
{
|
||||
$importRegexes = array(
|
||||
// @import url(xxx)
|
||||
|
|
@ -208,14 +212,20 @@ class CSS extends Minify
|
|||
|
||||
// only replace the import with the content if we can grab the
|
||||
// content of the file
|
||||
if (strlen($importPath) < PHP_MAXPATHLEN && file_exists($importPath) && is_file($importPath)) {
|
||||
if ($this->canImportFile($importPath)) {
|
||||
// check if current file was not imported previously in the same
|
||||
// import chain.
|
||||
if (in_array($importPath, $parents)) {
|
||||
throw new FileImportException('Failed to import file "'.$importPath.'": circular reference detected.');
|
||||
}
|
||||
|
||||
// grab referenced file & minify it (which may include importing
|
||||
// yet other @import statements recursively)
|
||||
$minifier = new static($importPath);
|
||||
$importContent = $minifier->execute($source);
|
||||
$importContent = $minifier->execute($source, $parents);
|
||||
|
||||
// check if this is only valid for certain media
|
||||
if ($match['media']) {
|
||||
if (!empty($match['media'])) {
|
||||
$importContent = '@media '.$match['media'].'{'.$importContent.'}';
|
||||
}
|
||||
|
||||
|
|
@ -259,20 +269,15 @@ class CSS extends Minify
|
|||
|
||||
// only replace the import with the content if we're able to get
|
||||
// the content of the file, and it's relatively small
|
||||
$import = file_exists($path);
|
||||
$import = $import && is_file($path);
|
||||
$import = $import && filesize($path) <= $this->maxImportSize * 1024;
|
||||
if (!$import) {
|
||||
continue;
|
||||
if ($this->canImportFile($path) && $this->canImportBySize($path)) {
|
||||
// grab content && base64-ize
|
||||
$importContent = $this->load($path);
|
||||
$importContent = base64_encode($importContent);
|
||||
|
||||
// build replacement
|
||||
$search[] = $match[0];
|
||||
$replace[] = 'url('.$this->importExtensions[$extension].';base64,'.$importContent.')';
|
||||
}
|
||||
|
||||
// grab content && base64-ize
|
||||
$importContent = $this->load($path);
|
||||
$importContent = base64_encode($importContent);
|
||||
|
||||
// build replacement
|
||||
$search[] = $match[0];
|
||||
$replace[] = 'url('.$this->importExtensions[$extension].';base64,'.$importContent.')';
|
||||
}
|
||||
|
||||
// replace the import statements
|
||||
|
|
@ -286,15 +291,16 @@ class CSS extends Minify
|
|||
* Minify the data.
|
||||
* Perform CSS optimizations.
|
||||
*
|
||||
* @param string[optional] $path Path to write the data to.
|
||||
* @param string[optional] $path Path to write the data to.
|
||||
* @param string[] $parents Parent paths, for circular reference checks.
|
||||
*
|
||||
* @return string The minified data.
|
||||
*/
|
||||
public function execute($path = null)
|
||||
public function execute($path = null, $parents = array())
|
||||
{
|
||||
$content = '';
|
||||
|
||||
// loop files
|
||||
// loop css data (raw data and files)
|
||||
foreach ($this->data as $source => $css) {
|
||||
/*
|
||||
* Let's first take out strings & comments, since we can't just remove
|
||||
|
|
@ -314,8 +320,9 @@ class CSS extends Minify
|
|||
// restore the string we've extracted earlier
|
||||
$css = $this->restoreExtractedData($css);
|
||||
|
||||
$source = $source ?: '';
|
||||
$css = $this->combineImports($source, $css);
|
||||
$source = is_int($source) ? '' : $source;
|
||||
$parents = $source ? array_merge($parents, array($source)) : $parents;
|
||||
$css = $this->combineImports($source, $css, $parents);
|
||||
$css = $this->importFiles($source, $css);
|
||||
|
||||
/*
|
||||
|
|
@ -443,8 +450,15 @@ class CSS extends Minify
|
|||
// determine if it's a url() or an @import match
|
||||
$type = (strpos($match[0], '@import') === 0 ? 'import' : 'url');
|
||||
|
||||
// attempting to interpret GET-params makes no sense, so let's discard them for awhile
|
||||
$params = strrchr($match['path'], '?');
|
||||
$url = $params ? substr($match['path'], 0, -strlen($params)) : $match['path'];
|
||||
|
||||
// fix relative url
|
||||
$url = $converter->convert($match['path']);
|
||||
$url = $converter->convert($url);
|
||||
|
||||
// now that the path has been converted, re-apply GET-params
|
||||
$url .= $params;
|
||||
|
||||
// build replacement
|
||||
$search[] = $match[0];
|
||||
|
|
@ -569,4 +583,16 @@ class CSS extends Minify
|
|||
|
||||
return trim($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file is small enough to be imported.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function canImportBySize($path)
|
||||
{
|
||||
return ($size = @filesize($path)) && $size <= $this->maxImportSize * 1024;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue