mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 16:59:55 +09:00
merge from 1.5.3 (~r10943)
git-svn-id: http://xe-core.googlecode.com/svn/trunk@10951 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7aa4798373
commit
54e3a72065
334 changed files with 13011 additions and 5561 deletions
|
|
@ -1,18 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* @class FrontEndFileHandler
|
||||
* Handle front end files
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
|
||||
class FrontEndFileHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* Map for css
|
||||
* @var array
|
||||
*/
|
||||
var $cssMap = array();
|
||||
|
||||
/**
|
||||
* Map for Javascript at head
|
||||
* @var array
|
||||
*/
|
||||
var $jsHeadMap = array();
|
||||
|
||||
/**
|
||||
* Map for Javascript at body
|
||||
* @var array
|
||||
*/
|
||||
var $jsBodyMap = array();
|
||||
|
||||
/**
|
||||
* Index for css
|
||||
* @var array
|
||||
*/
|
||||
var $cssMapIndex = array();
|
||||
|
||||
/**
|
||||
* Index for javascript at head
|
||||
* @var array
|
||||
*/
|
||||
var $jsHeadMapIndex = array();
|
||||
|
||||
/**
|
||||
* Index for javascript at body
|
||||
* @var array
|
||||
*/
|
||||
var $jsBodyMapIndex = array();
|
||||
|
||||
/**
|
||||
* Check SSL
|
||||
*
|
||||
* @return bool If using ssl returns true, otherwise returns false.
|
||||
*/
|
||||
function isSsl()
|
||||
{
|
||||
if ($GLOBAL['__XE_IS_SSL__']) return $GLOBAL['__XE_IS_SSL__'];
|
||||
|
|
@ -27,8 +60,11 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief load front end file
|
||||
* @params $args array
|
||||
* Load front end file
|
||||
*
|
||||
* The $args is use as below. File type(js, css) is detected by file extension.
|
||||
*
|
||||
* <pre>
|
||||
* case js
|
||||
* $args[0]: file name
|
||||
* $args[1]: type (head | body)
|
||||
|
|
@ -39,6 +75,22 @@
|
|||
* $args[1]: media
|
||||
* $args[2]: target IE
|
||||
* $args[3]: index
|
||||
* </pre>
|
||||
*
|
||||
* If $useCdn set true, use CDN instead local file.
|
||||
* CDN path = $cdnPrefix . $cdnVersion . $args[0]<br />
|
||||
*<br />
|
||||
* i.e.<br />
|
||||
* $cdnPrefix = 'http://static.xpressengine.com/core/';<br />
|
||||
* $cdnVersion = 'ardent1';<br />
|
||||
* $args[0] = './common/js/xe.js';<br />
|
||||
* The CDN path is http://static.xprssengine.com/core/ardent1/common/js/xe.js.<br />
|
||||
*
|
||||
* @param array $args Arguments
|
||||
* @param bool $useCdn If set true, use cdn instead local file
|
||||
* @param string $cdnPrefix CDN url prefix. (http://static.xpressengine.com/core/)
|
||||
* @param string $cdnVersion CDN version string (ardent1)
|
||||
* @return void
|
||||
**/
|
||||
function loadFile($args, $useCdn = false, $cdnPrefix = '', $cdnVersion = '')
|
||||
{
|
||||
|
|
@ -57,8 +109,8 @@
|
|||
$file->cdnVersion = $cdnVersion;
|
||||
}
|
||||
|
||||
$availableExtension = array('css', 'js');
|
||||
if (!in_array($file->fileExtension, $availableExtension)) return;
|
||||
$availableExtension = array('css'=>1, 'js'=>1);
|
||||
if (!isset($availableExtension[$file->fileExtension])) return;
|
||||
|
||||
$file->targetIe = $args[2];
|
||||
$file->index = (int)$args[3];
|
||||
|
|
@ -70,6 +122,8 @@
|
|||
$map = &$this->cssMap;
|
||||
$mapIndex = &$this->cssMapIndex;
|
||||
$key = $file->filePath . $file->fileName . "\t" . $file->targetIe . "\t" . $file->media;
|
||||
|
||||
$this->_arrangeCssIndex($pathInfo['dirname'], $file);
|
||||
}
|
||||
else if ($file->fileExtension == 'js')
|
||||
{
|
||||
|
|
@ -95,6 +149,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload front end file
|
||||
*
|
||||
* @param string $fileName The file name to unload
|
||||
* @param string $targetIe Target IE of file to unload
|
||||
* @param string $media Media of file to unload. Only use when file is css.
|
||||
* @return void
|
||||
*/
|
||||
function unloadFile($fileName, $targetIe = '', $media = 'all')
|
||||
{
|
||||
$pathInfo = pathinfo($fileName);
|
||||
|
|
@ -105,6 +167,11 @@
|
|||
|
||||
if ($fileExtension == 'css')
|
||||
{
|
||||
if(empty($media))
|
||||
{
|
||||
$media = 'all';
|
||||
}
|
||||
|
||||
$key .= "\t" . $media;
|
||||
if (isset($this->cssMapIndex[$key]))
|
||||
{
|
||||
|
|
@ -130,6 +197,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload all front end file
|
||||
*
|
||||
* @param string $type Type to unload. all, css, js
|
||||
* @return void
|
||||
*/
|
||||
function unloadAllFiles($type = 'all')
|
||||
{
|
||||
if ($type == 'css' || $type == 'all')
|
||||
|
|
@ -147,6 +220,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get css file list
|
||||
*
|
||||
* @return array Returns css file list. Array contains file, media, targetie.
|
||||
*/
|
||||
function getCssFileList()
|
||||
{
|
||||
$map = &$this->cssMap;
|
||||
|
|
@ -177,6 +255,12 @@
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get javascript file list
|
||||
*
|
||||
* @param string $type Type of javascript. head, body
|
||||
* @return array Returns javascript file list. Array contains file, targetie.
|
||||
*/
|
||||
function getJsFileList($type = 'head')
|
||||
{
|
||||
if ($type == 'head')
|
||||
|
|
@ -216,11 +300,24 @@
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort a map
|
||||
*
|
||||
* @param array $map Array to sort
|
||||
* @param array $index Not used
|
||||
* @return void
|
||||
*/
|
||||
function _sortMap(&$map, &$index)
|
||||
{
|
||||
ksort($map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize File path
|
||||
*
|
||||
* @param string $path Path to normalize
|
||||
* @return string Normalized path
|
||||
*/
|
||||
function _normalizeFilePath($path)
|
||||
{
|
||||
if (strpos($path, '://') === false && $path{0} != '/' && $path{0} != '.')
|
||||
|
|
@ -238,6 +335,12 @@
|
|||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get absolute file url
|
||||
*
|
||||
* @param string $path Path to get absolute url
|
||||
* @return string Absolute url
|
||||
*/
|
||||
function _getAbsFileUrl($path)
|
||||
{
|
||||
$path = $this->_normalizeFilePath($path);
|
||||
|
|
@ -260,4 +363,28 @@
|
|||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arrage css index
|
||||
*
|
||||
* @param string $dirName First directory name of css path
|
||||
* @param array $file file info.
|
||||
* @return void
|
||||
*/
|
||||
function _arrangeCssIndex($dirName, &$file)
|
||||
{
|
||||
if($file->index !== 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$dirName = str_replace('./', '', $dirName);
|
||||
$tmp = explode('/', $dirName);
|
||||
|
||||
$cssSortList = array('common'=>-100000, 'layouts'=>-90000, 'modules'=>-80000, 'widgets'=>-70000, 'addons'=>-60000);
|
||||
$file->index = $cssSortList[$tmp[0]];
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file FrontEndFileHandler.class.php */
|
||||
/* Location: ./classes/frontendfile/FrontEndFileHandler.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue