Changeset 8170 for trunk/include/template.class.php
- Timestamp:
- Dec 17, 2010, 7:33:16 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/template.class.php
r8162 r8170 399 399 $content[]= 400 400 '<script type="text/javascript" src="' 401 . Template::make_script_src($script)401 . self::make_script_src($script) 402 402 .'"></script>'; 403 403 } … … 996 996 } 997 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 998 private static function do_combine($scripts, $load_mode) 999 { 1000 global $conf; 1001 if (count($scripts)<2 or !$conf['template_combine_files']) 1002 return $scripts; 1003 $combiner = new FileCombiner('js'); 1004 foreach ($scripts as $script) 1005 { 1006 if ($script->is_remote()) fatal_error("NOT IMPLEMENTED");// TODO - we cannot combine remote scripts 1007 $combiner->add( $script->path, $script->version ); 1008 } 1009 if ( $combiner->combine( $out_file, $out_version) ) 1010 { 1011 return array( 'combi' => new Script($load_mode, 'combi', $out_file, $out_version, array() ) ); 1012 } 1013 return null; 1014 } 1015 1016 // checks that if B depends on A, then B->load_mode >= A->load_mode in order to respect execution order 1017 1017 private static function check_load_dep($scripts) 1018 1018 { 1019 1019 global $conf; 1020 1020 do 1021 1021 { … … 1062 1062 } 1063 1063 1064 private function compute_script_topological_order($script_id )1064 private function compute_script_topological_order($script_id, $recursion_limiter=0) 1065 1065 { 1066 1066 if (!isset($this->registered_scripts[$script_id])) … … 1069 1069 return 0; 1070 1070 } 1071 $recursion_limiter<5 or fatal_error("combined script circular dependency"); 1071 1072 $script = & $this->registered_scripts[$script_id]; 1072 1073 if (isset($script->extra['order'])) … … 1076 1077 $max = 0; 1077 1078 foreach( $script->precedents as $precedent) 1078 $max = max($max, $this->compute_script_topological_order($precedent ) );1079 $max = max($max, $this->compute_script_topological_order($precedent, $recursion_limiter+1) ); 1079 1080 $max++; 1080 1081 return ($script->extra['order'] = $max); … … 1209 1210 if (strpos($file, '.min')===false and strpos($file, '.packed')===false ) 1210 1211 { 1211 //TODO minify javascript with some php lib from www... 1212 require_once(PHPWG_ROOT_PATH.'include/jsmin.class.php'); 1213 try { $js = JSMin::minify($js); } catch(Exception $e) {} 1212 1214 } 1213 1215 return $js; … … 1215 1217 1216 1218 private static function process_css($file) 1219 { 1220 $css = self::process_css_rec($file); 1221 require_once(PHPWG_ROOT_PATH.'include/cssmin.class.php'); 1222 $css = CssMin::minify($css, array('emulate-css3-variables'=>false)); 1223 return $css; 1224 } 1225 1226 private static function process_css_rec($file) 1217 1227 { 1218 1228 static $PATTERN = "#url\(\s*['|\"]{0,1}(.*?)['|\"]{0,1}\s*\)#"; … … 1240 1250 { 1241 1251 $search[] = $match[0]; 1242 $replace[] = self::process_css (dirname($file) . "/$match[1]");1252 $replace[] = self::process_css_rec(dirname($file) . "/$match[1]"); 1243 1253 } 1244 1254 $css = str_replace($search, $replace, $css);
Note: See TracChangeset
for help on using the changeset viewer.