mirror of
https://github.com/mrclay/minify.git
synced 2025-08-09 15:46:34 +02:00
Avoid NOTICE errors in _getCommonCharAtPos
This commit is contained in:
@@ -15,10 +15,10 @@ class Minify_HTML_Helper {
|
|||||||
public $minAppUri = '/min';
|
public $minAppUri = '/min';
|
||||||
public $groupsConfigFile = '';
|
public $groupsConfigFile = '';
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Get an HTML-escaped Minify URI for a group or set of files
|
* Get an HTML-escaped Minify URI for a group or set of files
|
||||||
*
|
*
|
||||||
* @param mixed $keyOrFiles a group key or array of filepaths/URIs
|
* @param string|array $keyOrFiles a group key or array of filepaths/URIs
|
||||||
* @param array $opts options:
|
* @param array $opts options:
|
||||||
* 'farExpires' : (default true) append a modified timestamp for cache revving
|
* 'farExpires' : (default true) append a modified timestamp for cache revving
|
||||||
* 'debug' : (default false) append debug flag
|
* 'debug' : (default false) append debug flag
|
||||||
@@ -51,8 +51,12 @@ class Minify_HTML_Helper {
|
|||||||
return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']);
|
return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Get non-HTML-escaped URI to minify the specified files
|
* Get non-HTML-escaped URI to minify the specified files
|
||||||
|
*
|
||||||
|
* @param bool $farExpires
|
||||||
|
* @param bool $debug
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRawUri($farExpires = true, $debug = false)
|
public function getRawUri($farExpires = true, $debug = false)
|
||||||
{
|
{
|
||||||
@@ -74,6 +78,12 @@ class Minify_HTML_Helper {
|
|||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the files that will comprise the URI we're building
|
||||||
|
*
|
||||||
|
* @param array $files
|
||||||
|
* @param bool $checkLastModified
|
||||||
|
*/
|
||||||
public function setFiles($files, $checkLastModified = true)
|
public function setFiles($files, $checkLastModified = true)
|
||||||
{
|
{
|
||||||
$this->_groupKey = null;
|
$this->_groupKey = null;
|
||||||
@@ -94,6 +104,12 @@ class Minify_HTML_Helper {
|
|||||||
$this->_filePaths = $files;
|
$this->_filePaths = $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the group of files that will comprise the URI we're building
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param bool $checkLastModified
|
||||||
|
*/
|
||||||
public function setGroup($key, $checkLastModified = true)
|
public function setGroup($key, $checkLastModified = true)
|
||||||
{
|
{
|
||||||
$this->_groupKey = $key;
|
$this->_groupKey = $key;
|
||||||
@@ -109,7 +125,14 @@ class Minify_HTML_Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the max(lastModified) of all files
|
||||||
|
*
|
||||||
|
* @param array|string $sources
|
||||||
|
* @param int $lastModified
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public static function getLastModified($sources, $lastModified = 0)
|
public static function getLastModified($sources, $lastModified = 0)
|
||||||
{
|
{
|
||||||
$max = $lastModified;
|
$max = $lastModified;
|
||||||
@@ -142,13 +165,19 @@ class Minify_HTML_Helper {
|
|||||||
* @return mixed a common char or '' if any do not match
|
* @return mixed a common char or '' if any do not match
|
||||||
*/
|
*/
|
||||||
protected static function _getCommonCharAtPos($arr, $pos) {
|
protected static function _getCommonCharAtPos($arr, $pos) {
|
||||||
$l = count($arr);
|
if (!isset($arr[0][$pos])) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
$c = $arr[0][$pos];
|
$c = $arr[0][$pos];
|
||||||
if ($c === '' || $l === 1)
|
$l = count($arr);
|
||||||
|
if ($l === 1) {
|
||||||
return $c;
|
return $c;
|
||||||
for ($i = 1; $i < $l; ++$i)
|
}
|
||||||
if ($arr[$i][$pos] !== $c)
|
for ($i = 1; $i < $l; ++$i) {
|
||||||
|
if ($arr[$i][$pos] !== $c) {
|
||||||
return '';
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,11 +186,11 @@ class Minify_HTML_Helper {
|
|||||||
*
|
*
|
||||||
* @param array $paths root-relative URIs of files
|
* @param array $paths root-relative URIs of files
|
||||||
* @param string $minRoot root-relative URI of the "min" application
|
* @param string $minRoot root-relative URI of the "min" application
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected static function _getShortestUri($paths, $minRoot = '/min/') {
|
protected static function _getShortestUri($paths, $minRoot = '/min/') {
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
$base = '';
|
$base = '';
|
||||||
$c;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
$c = self::_getCommonCharAtPos($paths, $pos);
|
$c = self::_getCommonCharAtPos($paths, $pos);
|
||||||
if ($c === '') {
|
if ($c === '') {
|
||||||
|
Reference in New Issue
Block a user