57 if(!is_null(self::$isSSL))
63 self::$isSSL = ($url_info[
'scheme'] ==
'https');
97 $availableExtension = array(
'css' => 1,
'js' => 1);
98 if(!isset($availableExtension[$file->fileExtension]))
103 $file->index = (int)
$args[3];
105 if($file->fileExtension ==
'css')
112 else if($file->fileExtension ==
'js')
114 if(
$args[1] ==
'body')
126 (is_null($file->index)) ? $file->index = 0 : $file->index = $file->index;
127 if(!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index)
130 $map[$file->index][$file->key] = $file;
131 $mapIndex[$file->key] = $file->index;
143 private function getFileInfo($fileName, $targetIe =
'', $media =
'all')
145 static $existsInfo = array();
147 if(isset($existsInfo[$existsKey]))
149 return $existsInfo[$existsKey];
152 $fileName = preg_replace(
'/(?:[\/]{3,})(.*)/',
'//$1', $fileName);
153 $url_info = parse_url($fileName);
154 $pathInfo = pathinfo(str_replace(
'?' . $url_info[
'query'],
'', $fileName));
156 $file =
new stdClass();
157 $file->fileName = basename($url_info[
'path']);
160 $file->fileExtension = strtolower($pathInfo[
'extension']);
161 $file->fileNameNoExt = preg_replace(
'/\.min$/',
'', $pathInfo[
'filename']);
162 $file->query = $url_info[
'query'];
163 $file->external = !!$url_info[
'host'];
164 $file->keyName = implode(
'.', array($file->fileNameNoExt, $file->fileExtension));
172 $minifiedFileName = implode(
'.', array($file->fileNameNoExt,
'min', $file->fileExtension));
173 $minifiedRealPath = implode(
'/', array($file->fileRealPath, $minifiedFileName));
174 if(file_exists($minifiedRealPath))
176 $file->fileName = $minifiedFileName;
182 if(file_exists(implode(
'/', array($file->fileRealPath, $file->keyName))))
184 $file->fileName = $file->keyName;
189 $file->targetIe = $targetIe;
191 if($file->fileExtension ==
'css')
193 $file->media = $media;
196 $file->media =
'all';
198 $file->key = $file->filePath . $file->keyName .
"\t" . $file->targetIe .
"\t" . $file->media;
200 else if($file->fileExtension ==
'js')
202 $file->key = $file->filePath . $file->keyName .
"\t" . $file->targetIe;
216 function unloadFile($fileName, $targetIe =
'', $media =
'all')
218 $file = $this->getFileInfo($fileName, $targetIe, $media);
220 if($file->fileExtension ==
'css')
222 if(isset($this->cssMapIndex[$file->key]))
224 $index = $this->cssMapIndex[$file->key];
225 unset($this->cssMap[$index][$file->key], $this->cssMapIndex[$file->key]);
230 if(isset($this->jsHeadMapIndex[$file->key]))
232 $index = $this->jsHeadMapIndex[$file->key];
233 unset($this->jsHeadMap[$index][$file->key], $this->jsHeadMapIndex[$file->key]);
235 if(isset($this->jsBodyMapIndex[$file->key]))
237 $index = $this->jsBodyMapIndex[$file->key];
238 unset($this->jsBodyMap[$index][$file->key], $this->jsBodyMapIndex[$file->key]);
251 if($type ==
'css' || $type ==
'all')
253 $this->cssMap = array();
254 $this->cssMapIndex = array();
257 if($type ==
'js' || $type ==
'all')
259 $this->jsHeadMap = array();
260 $this->jsBodyMap = array();
261 $this->jsHeadMapIndex = array();
262 $this->jsBodyMapIndex = array();
279 foreach($map as $indexedMap)
281 foreach($indexedMap as $file)
284 if(!$file->external && is_readable($file->cdnPath .
'/' . $file->fileName))
286 $query = date(
'YmdHis', filemtime($file->cdnPath .
'/' . $file->fileName));
290 if($query) $query .=
'&';
291 $query .= $file->query;
293 $query = ($query) ?
'?' . $query :
'';
295 $fullFilePath = $file->filePath .
'/' . $file->fileName . $query;
297 'file' => $fullFilePath,
298 'media' => $file->media,
299 'targetie' => $file->targetIe
315 $ignore = array(
'modernizr.js',
'common.js',
'js_app.js',
'xml2json.js',
'xml_handler.js',
'xml_js_filter.js');
332 foreach($map as $indexedMap)
334 foreach($indexedMap as $file)
338 if(in_array($file->fileName, $ignore))
345 if(!$file->external && is_readable($file->cdnPath .
'/' . $file->fileName))
347 $query = date(
'YmdHis', filemtime($file->cdnPath .
'/' . $file->fileName));
351 if($query) $query .=
'&';
352 $query .= $file->query;
354 $query = ($query) ?
'?' . $query :
'';
356 $fullFilePath = $file->filePath .
'/' . $file->fileName . $query;
358 'file' => $fullFilePath,
359 'targetie' => $file->targetIe
387 if(strpos($path,
'://') === FALSE && $path{0} !=
'/' && $path{0} !=
'.')
389 $path =
'./' . $path;
391 elseif(!strncmp($path,
'//', 2))
393 return preg_replace(
'#^//+#',
'//', $path);
396 $path = preg_replace(
'@/\./|(?<!:)\/\/@',
'/', $path);
398 while(strpos($path,
'/../'))
400 $path = preg_replace(
'/\/([^\/]+)\/\.\.\//s',
'/', $path, 1);
417 if(strpos($path,
'./') === 0)
419 if($script_path ==
'/' || $script_path ==
'\\')
421 $path =
'/' . substr($path, 2);
425 $path = $script_path . substr($path, 2);
428 else if(strpos($file,
'../') === 0)
445 if($file->index !== 0)
450 $dirName = str_replace(
'./',
'', $dirName);
451 $tmp = explode(
'/', $dirName);
453 $cssSortList = array(
'common' => -100000,
'layouts' => -90000,
'modules' => -80000,
'widgets' => -70000,
'addons' => -60000);
454 $file->index = $cssSortList[$tmp[0]];
const __XE_VERSION_STABLE__
unloadFile($fileName, $targetIe= '', $media= 'all')
_arrangeCssIndex($dirName, &$file)
_normalizeFilePath($path)
unloadAllFiles($type= 'all')
getJsFileList($type= 'head')