mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 20:12:14 +09:00
issue 2961. fixed a bug. duplicate load, abnormal sorting.
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12751 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f0b55ee599
commit
94da6058e7
1 changed files with 81 additions and 62 deletions
|
|
@ -108,7 +108,68 @@ class FrontEndFileHandler extends Handler
|
||||||
$args = array($args);
|
$args = array($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathInfo = pathinfo($args[0]);
|
$file = $this->getFileInfo($args[0], $args[2], $args[1]);
|
||||||
|
|
||||||
|
$availableExtension = array('css' => 1, 'js' => 1);
|
||||||
|
if(!isset($availableExtension[$file->fileExtension]))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file->useCdn = $useCdn;
|
||||||
|
$file->cdnPrefix = $cdnPrefix;
|
||||||
|
$file->cdnVersion = $cdnVersion;
|
||||||
|
$file->index = (int) $args[3];
|
||||||
|
|
||||||
|
if($file->fileExtension == 'css')
|
||||||
|
{
|
||||||
|
$map = &$this->cssMap;
|
||||||
|
$mapIndex = &$this->cssMapIndex;
|
||||||
|
|
||||||
|
$this->_arrangeCssIndex($pathInfo['dirname'], $file);
|
||||||
|
}
|
||||||
|
else if($file->fileExtension == 'js')
|
||||||
|
{
|
||||||
|
$type = $args[1];
|
||||||
|
if($type == 'body')
|
||||||
|
{
|
||||||
|
$map = &$this->jsBodyMap;
|
||||||
|
$mapIndex = &$this->jsBodyMapIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$map = &$this->jsHeadMap;
|
||||||
|
$mapIndex = &$this->jsHeadMapIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(is_null($file->index)) ? $file->index = 0 : $file->index = $file->index;
|
||||||
|
if(!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index)
|
||||||
|
{
|
||||||
|
$this->unloadFile($args[0], $args[2], $args[1]);
|
||||||
|
$map[$file->index][$file->key] = $file;
|
||||||
|
$mapIndex[$file->key] = $file->index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get file information
|
||||||
|
*
|
||||||
|
* @param string $fileName The file name
|
||||||
|
* @param string $targetIe Target IE of file
|
||||||
|
* @param string $media Media of file
|
||||||
|
* @return stdClass The file information
|
||||||
|
*/
|
||||||
|
private function getFileInfo($fileName, $targetIe = '', $media = 'all')
|
||||||
|
{
|
||||||
|
static $existsInfo = array();
|
||||||
|
|
||||||
|
if(isset($existsInfo[$existsKey]))
|
||||||
|
{
|
||||||
|
return $existsInfo[$existsKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
$pathInfo = pathinfo($fileName);
|
||||||
$file = new stdClass();
|
$file = new stdClass();
|
||||||
$file->fileName = $pathInfo['basename'];
|
$file->fileName = $pathInfo['basename'];
|
||||||
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
|
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
|
||||||
|
|
@ -116,6 +177,7 @@ class FrontEndFileHandler extends Handler
|
||||||
$file->fileExtension = strtolower($pathInfo['extension']);
|
$file->fileExtension = strtolower($pathInfo['extension']);
|
||||||
$file->fileNameNoExt = preg_replace('/\.min$/', '', $pathInfo['filename']);
|
$file->fileNameNoExt = preg_replace('/\.min$/', '', $pathInfo['filename']);
|
||||||
$file->keyName = implode('.', array($file->fileNameNoExt, $file->fileExtension));
|
$file->keyName = implode('.', array($file->fileNameNoExt, $file->fileExtension));
|
||||||
|
$file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']);
|
||||||
|
|
||||||
if(strpos($file->filePath, '://') === FALSE)
|
if(strpos($file->filePath, '://') === FALSE)
|
||||||
{
|
{
|
||||||
|
|
@ -137,58 +199,25 @@ class FrontEndFileHandler extends Handler
|
||||||
$file->fileName = $file->keyName;
|
$file->fileName = $file->keyName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$file->useCdn = $useCdn;
|
|
||||||
$file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']);
|
|
||||||
$file->cdnPrefix = $cdnPrefix;
|
|
||||||
$file->cdnVersion = $cdnVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$availableExtension = array('css' => 1, 'js' => 1);
|
$file->targetIe = $targetIe;
|
||||||
if(!isset($availableExtension[$file->fileExtension]))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$file->targetIe = $args[2];
|
|
||||||
$file->index = (int) $args[3];
|
|
||||||
|
|
||||||
if($file->fileExtension == 'css')
|
if($file->fileExtension == 'css')
|
||||||
{
|
{
|
||||||
$file->media = $args[1];
|
$file->media = $media;
|
||||||
if(!$file->media)
|
if(!$file->media)
|
||||||
{
|
{
|
||||||
$file->media = 'all';
|
$file->media = 'all';
|
||||||
}
|
}
|
||||||
$map = &$this->cssMap;
|
$file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media;
|
||||||
$mapIndex = &$this->cssMapIndex;
|
|
||||||
$key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media;
|
|
||||||
|
|
||||||
$this->_arrangeCssIndex($pathInfo['dirname'], $file);
|
|
||||||
}
|
}
|
||||||
else if($file->fileExtension == 'js')
|
else if($file->fileExtension == 'js')
|
||||||
{
|
{
|
||||||
$type = $args[1];
|
$file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe;
|
||||||
if($type == 'body')
|
|
||||||
{
|
|
||||||
$map = &$this->jsBodyMap;
|
|
||||||
$mapIndex = &$this->jsBodyMapIndex;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$map = &$this->jsHeadMap;
|
|
||||||
$mapIndex = &$this->jsHeadMapIndex;
|
|
||||||
}
|
|
||||||
$key = $file->filePath . $file->keyName . "\t" . $file->targetIe;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(is_null($file->index)) ? $file->index = 0 : $file->index = $file->index;
|
return $file;
|
||||||
if(!isset($map[$file->index][$key]) || $mapIndex[$key] > $file->index)
|
|
||||||
{
|
|
||||||
$this->unloadFile($args[0], $args[2], $args[1]);
|
|
||||||
$map[$file->index][$key] = $file;
|
|
||||||
$mapIndex[$key] = $file->index;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -201,40 +230,30 @@ class FrontEndFileHandler extends Handler
|
||||||
*/
|
*/
|
||||||
function unloadFile($fileName, $targetIe = '', $media = 'all')
|
function unloadFile($fileName, $targetIe = '', $media = 'all')
|
||||||
{
|
{
|
||||||
$pathInfo = pathinfo($fileName);
|
$file = $this->getFileInfo($fileName, $targetIe, $media);
|
||||||
$fileName = $pathInfo['basename'];
|
|
||||||
$filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
|
|
||||||
$fileExtension = strtolower($pathInfo['extension']);
|
|
||||||
$key = $filePath . $fileName . "\t" . $targetIe;
|
|
||||||
|
|
||||||
if($fileExtension == 'css')
|
if($fileExtension == 'css')
|
||||||
{
|
{
|
||||||
if(empty($media))
|
if(isset($this->cssMapIndex[$file->key]))
|
||||||
{
|
{
|
||||||
$media = 'all';
|
$index = $this->cssMapIndex[$file->key];
|
||||||
}
|
unset($this->cssMap[$index][$file->key]);
|
||||||
|
unset($this->cssMapIndex[$file->key]);
|
||||||
$key .= "\t" . $media;
|
|
||||||
if(isset($this->cssMapIndex[$key]))
|
|
||||||
{
|
|
||||||
$index = $this->cssMapIndex[$key];
|
|
||||||
unset($this->cssMap[$index][$key]);
|
|
||||||
unset($this->cssMapIndex[$key]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(isset($this->jsHeadMapIndex[$key]))
|
if(isset($this->jsHeadMapIndex[$file->key]))
|
||||||
{
|
{
|
||||||
$index = $this->jsHeadMapIndex[$key];
|
$index = $this->jsHeadMapIndex[$file->key];
|
||||||
unset($this->jsHeadMap[$index][$key]);
|
unset($this->jsHeadMap[$index][$file->key]);
|
||||||
unset($this->jsHeadMapIndex[$key]);
|
unset($this->jsHeadMapIndex[$file->key]);
|
||||||
}
|
}
|
||||||
if(isset($this->jsBodyMapIndex[$key]))
|
if(isset($this->jsBodyMapIndex[$file->key]))
|
||||||
{
|
{
|
||||||
$index = $this->jsBodyMapIndex[$key];
|
$index = $this->jsBodyMapIndex[$file->key];
|
||||||
unset($this->jsBodyMap[$index][$key]);
|
unset($this->jsBodyMap[$index][$file->key]);
|
||||||
unset($this->jsBodyMapIndex[$key]);
|
unset($this->jsBodyMapIndex[$file->key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue