From bbd63f0088fe3ee5ea491ac5da03d8b68b5b1a0b Mon Sep 17 00:00:00 2001 From: rvelices Date: Sat, 4 Dec 2010 20:32:44 +0000 Subject: [PATCH] trunk admin theme goes with combine_script instead of old style known_script git-svn-id: http://piwigo.org/svn/trunk@7995 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/template/admin.tpl | 25 +- admin/themes/default/template/cat_list.tpl | 54 ++-- .../default/template/element_set_global.tpl | 39 ++- .../default/template/element_set_ranks.tpl | 42 ++-- .../default/template/element_set_unit.tpl | 51 ++-- admin/themes/default/template/footer.tpl | 26 +- admin/themes/default/template/header.tpl | 7 +- admin/themes/default/template/history.tpl | 10 +- .../default/template/include/autosize.inc.tpl | 21 +- .../template/include/datepicker.inc.tpl | 17 +- .../default/template/include/dbselect.inc.tpl | 40 ++- .../default/template/include/resize.inc.tpl | 12 +- admin/themes/default/template/intro.tpl | 17 +- .../themes/default/template/languages_new.tpl | 15 +- admin/themes/default/template/menubar.tpl | 58 +++-- .../default/template/photos_add_direct.tpl | 10 +- .../default/template/picture_modify.tpl | 40 ++- admin/themes/default/template/plugins_new.tpl | 37 ++- .../default/template/plugins_update.tpl | 16 +- admin/themes/default/template/popuphelp.tpl | 2 - include/template.class.php | 236 +++++++++++------- profile.php | 2 +- themes/default/template/header.tpl | 2 - .../default/template/include/autosize.inc.tpl | 21 +- .../default/template/include/resize.inc.tpl | 9 +- 25 files changed, 412 insertions(+), 397 deletions(-) diff --git a/admin/themes/default/template/admin.tpl b/admin/themes/default/template/admin.tpl index 1e2b2f88e..bd6636323 100644 --- a/admin/themes/default/template/admin.tpl +++ b/admin/themes/default/template/admin.tpl @@ -1,17 +1,15 @@ -{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js" } -{known_script id="jquery.ui.accordion" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.accordion.packed.js" } -{known_script id="jquery.tipTip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.tipTip.minified.js" } - - +{/footer_script} + +{combine_script id='jquery.tipTip' load='async' path='themes/default/js/plugins/jquery.tipTip.minified.js'} +{footer_script require='jquery.tipTip'} +jQuery(document).ready(function() {ldelim} + jQuery('#pwgHead A, #footer A, .themeActions A, .themeActions SPAN, .languageActions A, .languageActions SPAN').tipTip({ldelim} + 'delay' : 0, + 'fadeIn' : 200, + 'fadeOut' : 200, + }); +}); +{/footer_script} + + +{get_combined_scripts load='footer'} + + {literal} diff --git a/admin/themes/default/template/history.tpl b/admin/themes/default/template/history.tpl index bca98b75e..f869e9222 100644 --- a/admin/themes/default/template/history.tpl +++ b/admin/themes/default/template/history.tpl @@ -1,12 +1,10 @@ {include file='include/datepicker.inc.tpl'} -{literal} - -{/literal} +{footer_script}{literal} + pwg_initialization_datepicker("#start_day", "#start_month", "#start_year", "#start_linked_date", null, null, "#end_linked_date"); + pwg_initialization_datepicker("#end_day", "#end_month", "#end_year", "#end_linked_date", null, "#start_linked_date", null); +{/literal}{/footer_script}

{'History'|@translate} {$TABSHEET_TITLE}

diff --git a/admin/themes/default/template/include/autosize.inc.tpl b/admin/themes/default/template/include/autosize.inc.tpl index 8f5c78c70..ea18e6d3a 100644 --- a/admin/themes/default/template/include/autosize.inc.tpl +++ b/admin/themes/default/template/include/autosize.inc.tpl @@ -1,13 +1,10 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.autogrow" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.autogrow-textarea.js"} - +{combine_script id='jquery' load='async' path='themes/default/js/jquery.packed.js'} +{combine_script id='jquery.autogrow' load='async' require='jquery' path='themes/default/js/plugins/jquery.autogrow-textarea.js'} {* Auto size and auto grow textarea *} -{literal} - -{/literal} +{footer_script require='jquery.autogrow'}{literal} +jQuery(document).ready(function(){ + jQuery('textarea').css('overflow-y', 'hidden'); + // Auto size and auto grow for all text area + jQuery('textarea').autogrow(); +}); +{/literal}{/footer_script} \ No newline at end of file diff --git a/admin/themes/default/template/include/datepicker.inc.tpl b/admin/themes/default/template/include/datepicker.inc.tpl index d85706903..8470c8fa3 100644 --- a/admin/themes/default/template/include/datepicker.inc.tpl +++ b/admin/themes/default/template/include/datepicker.inc.tpl @@ -1,24 +1,23 @@ - -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"} -{known_script id="jquery.ui.datepicker" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.datepicker.packed.js"} -{known_script id="datepicker.js" src=$ROOT_URL|@cat:"themes/default/js/datepicker.js"} +{combine_script id='jquery' load='footer' path='themes/default/js/jquery.packed.js'} +{combine_script id='jquery.ui' load='footer' require='jquery' path='themes/default/js/ui/packed/ui.core.packed.js'} +{combine_script id='jquery.ui.datepicker' load='footer' require='jquery.ui' path='themes/default/js/ui/packed/ui.datepicker.packed.js'} +{combine_script id='datepicker.js' load='footer' require='jquery.ui.datepicker' path='themes/default/js/datepicker.js'} {assign var="datepicker_language" value="themes/default/js/ui/i18n/ui.datepicker-"|@cat:$lang_info.code|@cat:".js"} {if "PHPWG_ROOT_PATH"|@constant|@cat:$datepicker_language|@file_exists} -{known_script id="jquery.ui.datepicker-$lang_info.code" src=$ROOT_URL|@cat:$datepicker_language} +{combine_script id="jquery.ui.datepicker-$lang_info.code" path=$datepicker_language} {/if} {html_head} {/html_head} - +}; +{/footer_script} diff --git a/admin/themes/default/template/include/dbselect.inc.tpl b/admin/themes/default/template/include/dbselect.inc.tpl index 009452c1e..297cff01a 100644 --- a/admin/themes/default/template/include/dbselect.inc.tpl +++ b/admin/themes/default/template/include/dbselect.inc.tpl @@ -1,22 +1,18 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"} -{known_script id="jquery.ui.resizable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.resizable.packed.js"} - -{* Resize possible *} -{literal} - -{/literal} +{combine_script id='jquery' load='async' path='themes/default/js/jquery.packed.js'} +{combine_script id='jquery.ui' load='async' require='jquery' path='themes/default/js/ui/packed/ui.core.packed.js' } +{combine_script id='jquery.ui.resizable' load='async' require='jquery.ui' path='themes/default/js/ui/packed/ui.resizable.packed.js' } +{footer_script require='jquery.ui.resizable'}{literal} +jQuery(document).ready(function(){ + // Resize possible for double select list + jQuery(".doubleSelect select.categoryList").resizable({ + handles: "w,e", + animate: true, + animateDuration: "slow", + animateEasing: "swing", + preventDefault: true, + preserveCursor: true, + autoHide: true, + ghost: true + }); +}); +{/literal}{/footer_script} \ No newline at end of file diff --git a/admin/themes/default/template/include/resize.inc.tpl b/admin/themes/default/template/include/resize.inc.tpl index 30a637563..b7076a752 100644 --- a/admin/themes/default/template/include/resize.inc.tpl +++ b/admin/themes/default/template/include/resize.inc.tpl @@ -1,10 +1,9 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"} -{known_script id="jquery.ui.resizable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.resizable.packed.js"} +{combine_script id='jquery' load='async' path='themes/default/js/jquery.packed.js'} +{combine_script id='jquery.ui' load='async' require='jquery' path='themes/default/js/ui/packed/ui.core.packed.js'} +{combine_script id='jquery.ui.resizable' load='async' require='jquery.ui' path='themes/default/js/ui/packed/ui.resizable.packed.js'} {* Resize possible *} -{literal} - -{/literal} +{/literal}{/footer_script} diff --git a/admin/themes/default/template/intro.tpl b/admin/themes/default/template/intro.tpl index a45e581a0..b3dbfbbac 100644 --- a/admin/themes/default/template/intro.tpl +++ b/admin/themes/default/template/intro.tpl @@ -1,15 +1,14 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"} +{combine_script id='jquery.cluetip' load='async' require='jquery' path='themes/default/js/plugins/jquery.cluetip.packed.js'} - +{/footer_script}

{'Piwigo administration'|@translate}

diff --git a/admin/themes/default/template/languages_new.tpl b/admin/themes/default/template/languages_new.tpl index 9b66e1724..2e9db5f91 100644 --- a/admin/themes/default/template/languages_new.tpl +++ b/admin/themes/default/template/languages_new.tpl @@ -1,14 +1,13 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"} +{combine_script id='jquery.cluetip' load='async' require='jquery' path='themes/default/js/plugins/jquery.cluetip.packed.js'} - +{/footer_script}

{'Add New Language'|@translate}

diff --git a/admin/themes/default/template/menubar.tpl b/admin/themes/default/template/menubar.tpl index 751d5de83..8886a505b 100644 --- a/admin/themes/default/template/menubar.tpl +++ b/admin/themes/default/template/menubar.tpl @@ -1,33 +1,31 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js" } -{known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js" } - - +{combine_script id='jquery.ui' load='async' require='jquery' path='themes/default/js/ui/packed/ui.core.packed.js' } +{combine_script id='jquery.ui.sortable' load='async' require='jquery.ui' path='themes/default/js/ui/packed/ui.sortable.packed.js' } +{footer_script require='jquery.ui.sortable'} +jQuery(document).ready(function(){ldelim} + jQuery(".menuPos").hide(); + jQuery(".drag_button").show(); + jQuery(".menuLi").css("cursor","move"); + jQuery(".menuUl").sortable({ldelim} + axis: "y", + opacity: 0.8 + }); + jQuery("input[name^='hide_']").click(function() {ldelim} + men = this.name.split('hide_'); + if (this.checked) {ldelim} + jQuery("#menu_"+men[1]).addClass('menuLi_hidden'); + } else {ldelim} + jQuery("#menu_"+men[1]).removeClass('menuLi_hidden'); + } + }); + jQuery("#menuOrdering").submit(function(){ldelim} + ar = jQuery('.menuUl').sortable('toArray'); + for(i=0;i

{'Menu Management'|translate}

diff --git a/admin/themes/default/template/photos_add_direct.tpl b/admin/themes/default/template/photos_add_direct.tpl index f737c540c..e16cb4f2c 100644 --- a/admin/themes/default/template/photos_add_direct.tpl +++ b/admin/themes/default/template/photos_add_direct.tpl @@ -1,16 +1,14 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.jgrowl" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.jgrowl_minimized.js"} +{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' } {if $upload_mode eq 'multiple'} - +{combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v2.1.0.min.js' } {/if} {html_head} {/html_head} -{literal} - +{/footer_script}

{'Upload Photos'|@translate}

diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl index 3d5ba4bab..ec0b14266 100644 --- a/admin/themes/default/template/picture_modify.tpl +++ b/admin/themes/default/template/picture_modify.tpl @@ -2,29 +2,25 @@ {include file='include/dbselect.inc.tpl'} {include file='include/datepicker.inc.tpl'} -{known_script id="jquery.fcbkcomplete" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.fcbkcomplete.js"} -{literal} - -{/literal} +{combine_script id='jquery.fcbkcomplete' load='async' require='jquery' path='themes/default/js/plugins/jquery.fcbkcomplete.js'} +{footer_script require='jquery.fcbkcomplete'}{literal} +jQuery(document).ready(function() { + jQuery("#tags").fcbkcomplete({ + json_url: "admin.php?fckb_tags=1", + cache: false, + filter_case: false, + filter_hide: true, + firstselected: true, + filter_selected: true, + maxitems: 100, + newel: true + }); +}); +{/literal}{/footer_script} -{literal} - -{/literal} +{footer_script} +pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#date_creation_year", "#date_creation_linked_date", "#date_creation_action_set"); +{/footer_script}

{'Modify informations about a picture'|@translate}

diff --git a/admin/themes/default/template/plugins_new.tpl b/admin/themes/default/template/plugins_new.tpl index e2ed85359..6546cdc38 100644 --- a/admin/themes/default/template/plugins_new.tpl +++ b/admin/themes/default/template/plugins_new.tpl @@ -1,25 +1,24 @@ -{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js" } -{known_script id="jquery.ui.effects" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/effects.core.packed.js" } -{known_script id="jquery.ui.blind" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/effects.blind.packed.js" } +{combine_script id='jquery.ui' load='async' require='jquery' path='themes/default/js/ui/packed/ui.core.packed.js' } +{combine_script id='jquery.ui.effects' load='async' require='jquery.ui' path='themes/default/js/ui/packed/effects.core.packed.js' } +{combine_script id='jquery.ui.effects.blind' load='async' require='jquery.ui.effects' path='themes/default/js/ui/packed/effects.blind.packed.js' } - +{/footer_script}
diff --git a/admin/themes/default/template/plugins_update.tpl b/admin/themes/default/template/plugins_update.tpl index 14d5aabb9..2304db112 100644 --- a/admin/themes/default/template/plugins_update.tpl +++ b/admin/themes/default/template/plugins_update.tpl @@ -1,14 +1,12 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"} - - +{/footer_script}

{'Plugins'|@translate}

diff --git a/admin/themes/default/template/popuphelp.tpl b/admin/themes/default/template/popuphelp.tpl index 718617baf..950e3ca0e 100644 --- a/admin/themes/default/template/popuphelp.tpl +++ b/admin/themes/default/template/popuphelp.tpl @@ -1,5 +1,3 @@ -{known_script id="jquery.tipTip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.tipTip.minified.js" } -
{$HELP_CONTENT}
diff --git a/include/template.class.php b/include/template.class.php index dcfc2d527..c1bdc67fa 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -45,11 +45,10 @@ class Template { const COMBINED_SCRIPTS_TAG = ''; var $scriptLoader; - var $html_footer_raw_script = array(); const COMBINED_CSS_TAG = ''; var $css_by_priority = array(); - + function Template($root = ".", $theme= "", $path = "template") { global $conf, $lang_info; @@ -79,7 +78,7 @@ class Template { conf_update_param('local_data_dir_checked', 'true'); } } - + $compile_dir = $conf['local_data_dir'].'/templates_c'; mkgetdir( $compile_dir ); @@ -187,6 +186,7 @@ class Template { $this->smarty->clear_compiled_tpl(); $this->smarty->compile_id = $save_compile_id; file_put_contents($this->smarty->compile_dir.'/index.htm', 'Not allowed!'); + FileCombiner::clear_combined_files(); } function get_themeconf($val) @@ -407,7 +407,7 @@ class Template { $this->output = substr_replace( $this->output, "\n".implode( "\n", $content ), $pos, strlen(self::COMBINED_SCRIPTS_TAG) ); } //else maybe error or warning ? } - + if(!empty($this->css_by_priority)) { ksort($this->css_by_priority); @@ -528,7 +528,7 @@ class Template { $this->block_html_head(null, $content, $smarty, $repeat); } } - + function func_combine_script($params, &$smarty) { if (!isset($params['id'])) @@ -546,9 +546,9 @@ class Template { default: $smarty->trigger_error("combine_script: invalid 'load' parameter", E_USER_ERROR); } } - $this->scriptLoader->add( $params['id'], $load, - empty($params['require']) ? array() : explode( ',', $params['require'] ), - @$params['path'], + $this->scriptLoader->add( $params['id'], $load, + empty($params['require']) ? array() : explode( ',', $params['require'] ), + @$params['path'], isset($params['version']) ? $params['version'] : 0 ); } @@ -561,7 +561,7 @@ class Template { } $load = $params['load']=='header' ? 0 : 1; $content = array(); - + if ($load==0) { return self::COMBINED_SCRIPTS_TAG; @@ -578,10 +578,10 @@ class Template { . Template::make_script_src($script) .'">'; } - if (count($this->html_footer_raw_script)) + if (count($this->scriptLoader->inline_scripts)) { $content[]= ''; } @@ -628,10 +628,10 @@ class Template { $content = trim($content); if ( !empty($content) ) { // second call - $this->html_footer_raw_script[] = $content; + $this->scriptLoader->add_inline( $content, @$params['require'] ); } } - + function func_combine_css($params, &$smarty) { !empty($params['path']) || fatal_error('combine_css missing path'); @@ -841,6 +841,11 @@ final class Script if (!empty($path)) $this->path = $path; } + + function is_remote() + { + return url_is_remote( $this->path ); + } } @@ -849,7 +854,11 @@ and later on by combining them in a unique file respecting at the same time depe class ScriptLoader { private $registered_scripts; + public $inline_scripts; + private $did_head; + private $head_done_scripts; + private static $known_paths = array( 'core.scripts' => 'themes/default/js/scripts.js', 'jquery' => 'themes/default/js/jquery.min.js', @@ -864,9 +873,24 @@ class ScriptLoader function clear() { $this->registered_scripts = array(); + $this->inline_scripts = array(); + $this->head_done_scripts = array(); $this->did_head = false; } + function add_inline($code, $require) + { + if(!empty($require)) + { + if(!isset($this->registered_scripts[$require])) + fatal_error("inline script not found require $require"); + $s = $this->registered_scripts[$require]; + if($s->load_mode==2) + $s->load_mode=1; // until now the implementation does not allow executing inline script depending on another async script + } + $this->inline_scripts[] = $code; + } + function add($id, $load_mode, $require, $path, $version=0) { if ($this->did_head && $load_mode==0 ) @@ -899,6 +923,91 @@ class ScriptLoader return $this->did_head; } + function get_head_scripts() + { + self::check_load_dep($this->registered_scripts); + foreach( array_keys($this->registered_scripts) as $id ) + { + $this->compute_script_topological_order($id); + } + + uasort($this->registered_scripts, array('ScriptLoader', 'cmp_by_mode_and_order')); + + foreach( $this->registered_scripts as $id => $script) + { + if ($script->load_mode > 0) + break; + if ( !empty($script->path) ) + $this->head_done_scripts[$id] = $script; + else + trigger_error("Script $id has an undefined path", E_USER_WARNING); + } + $this->did_head = true; + return $this->head_done_scripts; + } + + function get_footer_scripts() + { + if (!$this->did_head) + { + trigger_error("Attempt to write footer scripts without header scripts", E_USER_ERROR ); + } + + $todo = array(); + foreach( $this->registered_scripts as $id => $script) + { + if (!isset($this->head_done_scripts[$id])) + { + $todo[$id] = $script; + } + } + foreach( array_keys($todo) as $id ) + { + $this->compute_script_topological_order($id); + } + + uasort($todo, array('ScriptLoader', 'cmp_by_mode_and_order')); + + + $result = array( array(), array() ); + foreach( $todo as $id => $script) + { + $result[$script->load_mode-1][$id] = $script; + } + return $result; + } + + private static function check_load_dep($scripts) + { + do + { + $changed = false; + foreach( $scripts as $id => $script) + { + $load = $script->load_mode; + if ($load==0) + continue; + foreach( $script->precedents as $precedent) + { + if ( !isset($scripts[$precedent] ) ) + continue; + if ( $scripts[$precedent]->load_mode > $load ) + { + $scripts[$precedent]->load_mode = $load; + $changed = true; + } + if ($load==2 && $scripts[$precedent]->load_mode==2 && $script->is_remote() ) + {// we are async -> a predecessor cannot be async unlesss it can be merged; otherwise script execution order is not guaranteed + $scripts[$precedent]->load_mode = 1; + $changed = true; + } + } + } + } + while ($changed); + } + + private static function fill_well_known($id, $script) { if ( empty($script->path) && isset(self::$known_paths[$id])) @@ -914,78 +1023,6 @@ class ScriptLoader } } - function get_head_scripts() - { - do - { - $changed = false; - foreach( $this->registered_scripts as $id => $script) - { - $load = $script->load_mode; - if ($load==0) - continue; - if ($load==2) - $load=1; // we are async -> a predecessor cannot be async because the script execution order is not guaranteed - foreach( $script->precedents as $precedent) - { - if ( !isset($this->registered_scripts[$precedent] ) ) - { - trigger_error("Script $id requires undefined script $precedent", E_USER_WARNING); - continue; - } - if ( $this->registered_scripts[$precedent]->load_mode > $load ) - { - $this->registered_scripts[$precedent]->load_mode = $load; - $changed = true; - } - } - } - } - while ($changed); - - foreach( array_keys($this->registered_scripts) as $id ) - { - $this->compute_script_topological_order($id); - } - - uasort($this->registered_scripts, array('ScriptLoader', 'cmp_by_mode_and_order')); - - $result = array(); - foreach( $this->registered_scripts as $id => $script) - { - if ($script->load_mode > 0) - break; - if ( !empty($script->path) ) - $result[$id] = $script; - else - trigger_error("Script $id has an undefined path", E_USER_WARNING); - } - $this->did_head = true; - return $result; - } - - function get_footer_scripts() - { - if (!$this->did_head) - { - trigger_error("Attempt to write footer scripts without header scripts", E_USER_WARNING); - } - $result = array( array(), array() ); - foreach( $this->registered_scripts as $id => $script) - { - if ($script->load_mode > 0) - { - if ( !empty( $script->path ) ) - { - $result[$script->load_mode-1][$id] = $script; - } - else - trigger_error("Script $id has an undefined path", E_USER_WARNING); - } - } - return $result; - } - private function compute_script_topological_order($script_id) { if (!isset($this->registered_scripts[$script_id])) @@ -1008,9 +1045,16 @@ class ScriptLoader private static function cmp_by_mode_and_order($s1, $s2) { $ret = $s1->load_mode - $s2->load_mode; - if (!$ret) - $ret = $s1->extra['order'] - $s2->extra['order']; - return $ret; + if ($ret) return $ret; + + $ret = $s1->extra['order'] - $s2->extra['order']; + if ($ret) return $ret; + + if ($s1->extra['order']==0 and ($s1->is_remote() xor $s2->is_remote()) ) + { + return $s1->is_remote() ? -1 : 1; + } + return strcmp($s1->id,$s2->id); } } @@ -1027,6 +1071,17 @@ final class FileCombiner { $this->type = $type; } + + static function clear_combined_files() + { + $dir = opendir(PHPWG_ROOT_PATH.self::OUT_SUB_DIR); + while ($file = readdir($dir)) + { + if ( get_extension($file)=='js' || get_extension($file)=='css') + unlink(PHPWG_ROOT_PATH.self::OUT_SUB_DIR.$file); + } + closedir($dir); + } function add($file, $version) { @@ -1077,8 +1132,7 @@ final class FileCombiner } $output = ''; - if ($conf['debug_template']) - $output .= "/*".join("\n", $this->files)."*/\n"; + $output .= "/* ".count($this->files)."\n".join("\n", $this->files)."*/\n"; foreach ($this->files as $input_file) { $output .= "/* BEGIN $input_file */\n"; @@ -1132,4 +1186,4 @@ final class FileCombiner } } -?> +?> \ No newline at end of file diff --git a/profile.php b/profile.php index 547fc8ba1..160b649fd 100644 --- a/profile.php +++ b/profile.php @@ -84,7 +84,7 @@ SELECT '.implode(',', $fields).' } $template->set_filename('profile', 'profile.tpl'); trigger_action('loc_end_profile'); - $template->parse('profile'); + $template->pparse('profile'); include(PHPWG_ROOT_PATH.'include/page_tail.php'); } diff --git a/themes/default/template/header.tpl b/themes/default/template/header.tpl index 45152d206..5dc51f97b 100644 --- a/themes/default/template/header.tpl +++ b/themes/default/template/header.tpl @@ -30,9 +30,7 @@ {if isset($last.U_IMG) }{/if} {if isset($U_UP) }{/if} - {get_combined_css} - {foreach from=$themes item=theme} {if $theme.load_css} {combine_css path="themes/`$theme.id`/theme.css" order=-10} diff --git a/themes/default/template/include/autosize.inc.tpl b/themes/default/template/include/autosize.inc.tpl index 8f5c78c70..ea18e6d3a 100644 --- a/themes/default/template/include/autosize.inc.tpl +++ b/themes/default/template/include/autosize.inc.tpl @@ -1,13 +1,10 @@ -{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} -{known_script id="jquery.autogrow" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.autogrow-textarea.js"} - +{combine_script id='jquery' load='async' path='themes/default/js/jquery.packed.js'} +{combine_script id='jquery.autogrow' load='async' require='jquery' path='themes/default/js/plugins/jquery.autogrow-textarea.js'} {* Auto size and auto grow textarea *} -{literal} - -{/literal} +{footer_script require='jquery.autogrow'}{literal} +jQuery(document).ready(function(){ + jQuery('textarea').css('overflow-y', 'hidden'); + // Auto size and auto grow for all text area + jQuery('textarea').autogrow(); +}); +{/literal}{/footer_script} \ No newline at end of file diff --git a/themes/default/template/include/resize.inc.tpl b/themes/default/template/include/resize.inc.tpl index 5165f49a5..b7076a752 100644 --- a/themes/default/template/include/resize.inc.tpl +++ b/themes/default/template/include/resize.inc.tpl @@ -1,9 +1,9 @@ -{combine_script id='jquery' load='footer' path='themes/default/js/jquery.packed.js'} -{combine_script id='jquery.ui' load='footer' require='jquery' path='themes/default/js/ui/packed/ui.core.packed.js'} -{combine_script id='jquery.ui.resizable' load='footer' require='jquery.ui' path='themes/default/js/ui/packed/ui.resizable.packed.js'} +{combine_script id='jquery' load='async' path='themes/default/js/jquery.packed.js'} +{combine_script id='jquery.ui' load='async' require='jquery' path='themes/default/js/ui/packed/ui.core.packed.js'} +{combine_script id='jquery.ui.resizable' load='async' require='jquery.ui' path='themes/default/js/ui/packed/ui.resizable.packed.js'} {* Resize possible *} -{footer_script}{literal} +{footer_script require='jquery.ui.resizable'}{literal} jQuery().ready(function(){ // Resize possible for list jQuery(".categoryList").resizable({ @@ -18,4 +18,3 @@ }); }); {/literal}{/footer_script} -