diff --git a/doc/upgrade/upgrade.docbook b/doc/upgrade/upgrade.docbook index e1245f60..7a6405e8 100644 --- a/doc/upgrade/upgrade.docbook +++ b/doc/upgrade/upgrade.docbook @@ -212,11 +212,11 @@ grep -Er 'LSsession *:: *addCssFile\(.*\.\.\/' /etc/ldapsaisie/local/css : - {include file='ls:LSsession_css.tpl'} + {include file='ls:css.tpl'} {/block}]]> Ce block contient tous les CSS, y compris ceux gérés par LSsession :: addCssFile(). - Pensez à ajouter {include file='ls:LSsession_css.tpl'} pour conserver ces derniers. + Pensez à ajouter {include file='ls:css.tpl'} pour conserver ces derniers. @@ -286,12 +286,12 @@ grep -Er '\.(png|gif|jpg)' /etc/ldapsaisie/local/templates - {$LSsession_css} doit être remplacé par {include file='ls:LSsession_css.tpl'} + {$LSsession_css} doit être remplacé par {include file='ls:css.tpl'} - {$LSsession_js} doit être remplacé par {include file='ls:LSsession_js.tpl'} + {$LSsession_js} doit être remplacé par {include file='ls:js.tpl'} diff --git a/src/conf/config.inc.php b/src/conf/config.inc.php index 67e4f97a..16a3cdeb 100644 --- a/src/conf/config.inc.php +++ b/src/conf/config.inc.php @@ -259,14 +259,6 @@ $GLOBALS['NB_LSOBJECT_LIST_CHOICES'] = array(30, 60, 100); define('MAX_SEND_FILE_SIZE',2000000); -// Javascript -$GLOBALS['defaultJSscipts']=array( - 'mootools-core.js', - 'mootools-more.js', - 'functions.js', - 'LSdefault.js', - 'LSinfosBox.js' -); - -// CSS +// Default Javascript & CSS to include on all pages +$GLOBALS['defaultJSscipts']=array(); $GLOBALS['defaultCSSfiles']=array('light-blue.css'); diff --git a/src/includes/addons/LSaddons.LSaccessRightsMatrixView.php b/src/includes/addons/LSaddons.LSaccessRightsMatrixView.php index cc0815b2..b87f1186 100644 --- a/src/includes/addons/LSaddons.LSaccessRightsMatrixView.php +++ b/src/includes/addons/LSaddons.LSaccessRightsMatrixView.php @@ -157,6 +157,6 @@ function LSaccessRightsMatrixView() { LStemplate :: assign('LSobjects', $LSobjects); LStemplate :: assign('LSobject', $LSobject); - LSsession :: addCssFile('LSaccessRightsMatrixView.css'); + LStemplate :: addCssFile('LSaccessRightsMatrixView.css'); LSsession :: setTemplate('LSaccessRightsMatrixView.tpl'); } diff --git a/src/includes/class/class.LSconfirmBox.php b/src/includes/class/class.LSconfirmBox.php index 6fcdb67a..ac03046e 100644 --- a/src/includes/class/class.LSconfirmBox.php +++ b/src/includes/class/class.LSconfirmBox.php @@ -28,10 +28,10 @@ class LSconfirmBox { * @retval void */ public static function loadDependenciesDisplay() { - LSsession :: addJSscript('LSconfirmBox.js'); - LSsession :: addCssFile('LSconfirmBox.css'); + LStemplate :: addJSscript('LSconfirmBox.js'); + LStemplate :: addCssFile('LSconfirmBox.css'); - LSsession :: addJSconfigParam('LSconfirmBox_labels', array( + LStemplate :: addJSconfigParam('LSconfirmBox_labels', array( 'title' => _('Confirmation'), 'text' => _('You confirm your choice ?'), 'validate' => _('Validate'), diff --git a/src/includes/class/class.LSform.php b/src/includes/class/class.LSform.php index ccf559a0..fb29e524 100644 --- a/src/includes/class/class.LSform.php +++ b/src/includes/class/class.LSform.php @@ -87,10 +87,10 @@ class LSform { self :: loadDependenciesDisplayView($this -> $ldapObject); } else { - LSsession :: addJSscript('LSformElement_field.js'); - LSsession :: addJSscript('LSformElement.js'); - LSsession :: addJSscript('LSform.js'); - LSsession :: addCssFile('LSform.css'); + LStemplate :: addJSscript('LSformElement_field.js'); + LStemplate :: addJSscript('LSformElement.js'); + LStemplate :: addJSscript('LSform.js'); + LStemplate :: addCssFile('LSform.css'); } LSsession :: addHelpInfos( @@ -177,7 +177,7 @@ class LSform { $JSconfig['warnings']=$this -> warnings; } - LSsession :: addJSconfigParam('LSform_'.$this -> idForm,$JSconfig); + LStemplate :: addJSconfigParam('LSform_'.$this -> idForm,$JSconfig); LStemplate :: assign('LSform_submittxt',$this -> submit); } @@ -187,8 +187,8 @@ class LSform { * @retval void */ public static function loadDependenciesDisplayView($ldapObject=false, $search_view=false) { - LSsession :: addCssFile('LSform.css'); - LSsession :: addJSscript('LSform.js'); + LStemplate :: addCssFile('LSform.css'); + LStemplate :: addJSscript('LSform.js'); $customActionLabels = array (); if (is_a($ldapObject,'LSldapObject')) { $objectname=($search_view?$ldapObject -> getLabel():$ldapObject -> getDisplayName()); @@ -216,7 +216,7 @@ class LSform { } } } - LSsession :: addJSconfigParam('LSview_labels', array_merge(array( + LStemplate :: addJSconfigParam('LSview_labels', array_merge(array( 'delete_confirm_text' => _("Do you really want to delete"), 'delete_confirm_title' => _("Caution"), 'delete_confirm_validate' => _("Delete") @@ -224,7 +224,7 @@ class LSform { if (LSsession :: loadLSclass('LSconfirmBox')) { LSconfirmBox :: loadDependenciesDisplay(); } - LSsession :: addJSscript('LSview.js'); + LStemplate :: addJSscript('LSview.js'); } /** diff --git a/src/includes/class/class.LSformElement_boolean.php b/src/includes/class/class.LSformElement_boolean.php index 2b13ff5d..2cc84418 100644 --- a/src/includes/class/class.LSformElement_boolean.php +++ b/src/includes/class/class.LSformElement_boolean.php @@ -52,7 +52,7 @@ class LSformElement_boolean extends LSformElement { 'clear' => _('Reset the choice.') ) ); - LSsession :: addJSscript('LSformElement_boolean.js'); + LStemplate :: addJSscript('LSformElement_boolean.js'); } $return['html'] = $this -> fetchTemplate( NULL, diff --git a/src/includes/class/class.LSformElement_date.php b/src/includes/class/class.LSformElement_date.php index fca7c08a..15e93a59 100644 --- a/src/includes/class/class.LSformElement_date.php +++ b/src/includes/class/class.LSformElement_date.php @@ -162,18 +162,18 @@ class LSformElement_date extends LSformElement { 'showNowButton' => $this -> getParam('html_options.showNowButton', true, 'bool'), 'showTodayButton' => $this -> getParam('html_options.showTodayButton', true, 'bool'), ); - LSsession :: addJSconfigParam($this -> name, $params); + LStemplate :: addJSconfigParam($this -> name, $params); $codeLang = str_replace('_','-',preg_replace('/\..*$/','', LSlang :: getLang())); - LSsession :: addLibJSscript('arian-mootools-datepicker/Picker.js'); - LSsession :: addLibJSscript('arian-mootools-datepicker/Picker.Attach.js'); - LSsession :: addLibJSscript('arian-mootools-datepicker/Picker.Date.js'); - LSsession :: addLibJSscript('arian-mootools-datepicker/Locale.'.$codeLang.'.DatePicker.js'); - LSsession :: addLibCssFile('arian-mootools-datepicker/datepicker_'.$params['style'].'/datepicker_'.$params['style'].'.css'); + LStemplate :: addLibJSscript('arian-mootools-datepicker/Picker.js'); + LStemplate :: addLibJSscript('arian-mootools-datepicker/Picker.Attach.js'); + LStemplate :: addLibJSscript('arian-mootools-datepicker/Picker.Date.js'); + LStemplate :: addLibJSscript('arian-mootools-datepicker/Locale.'.$codeLang.'.DatePicker.js'); + LStemplate :: addLibCssFile('arian-mootools-datepicker/datepicker_'.$params['style'].'/datepicker_'.$params['style'].'.css'); - LSsession :: addJSscript('LSformElement_date_field.js'); - LSsession :: addJSscript('LSformElement_date.js'); + LStemplate :: addJSscript('LSformElement_date_field.js'); + LStemplate :: addJSscript('LSformElement_date.js'); } $return['html'] = $this -> fetchTemplate(); return $return; diff --git a/src/includes/class/class.LSformElement_image.php b/src/includes/class/class.LSformElement_image.php index 880a95cb..60779bf6 100644 --- a/src/includes/class/class.LSformElement_image.php +++ b/src/includes/class/class.LSformElement_image.php @@ -43,7 +43,7 @@ class LSformElement_image extends LSformElement { * @retval array */ public function getDisplay(){ - LSsession :: addCssFile('LSformElement_image.css'); + LStemplate :: addCssFile('LSformElement_image.css'); $return = true; $id=$this -> name.'_'.rand(); if (!$this -> isFreeze()) { @@ -75,7 +75,7 @@ class LSformElement_image extends LSformElement { if (LSsession :: loadLSclass('LSsmoothbox')) { LSsmoothbox :: loadDependenciesDisplay(); } - LSsession :: addJSscript('LSformElement_image.js'); + LStemplate :: addJSscript('LSformElement_image.js'); } return $return; } diff --git a/src/includes/class/class.LSformElement_jsonCompositeAttribute.php b/src/includes/class/class.LSformElement_jsonCompositeAttribute.php index a0f26d1d..2fcdf036 100644 --- a/src/includes/class/class.LSformElement_jsonCompositeAttribute.php +++ b/src/includes/class/class.LSformElement_jsonCompositeAttribute.php @@ -97,19 +97,19 @@ class LSformElement_jsonCompositeAttribute extends LSformElement { 'parseValues' => $parseValues, ) ); - LSsession :: addCssFile('LSformElement_jsonCompositeAttribute.css'); + LStemplate :: addCssFile('LSformElement_jsonCompositeAttribute.css'); if (!$this -> isFreeze()) { - LSsession :: addJSconfigParam( + LStemplate :: addJSconfigParam( $this -> name, array ( 'components' => $this -> components, ) ); - LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field_value_component_text_value.js'); - LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field_value_component.js'); - LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field_value.js'); - LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field.js'); - LSsession :: addJSscript('LSformElement_jsonCompositeAttribute.js'); + LStemplate :: addJSscript('LSformElement_jsonCompositeAttribute_field_value_component_text_value.js'); + LStemplate :: addJSscript('LSformElement_jsonCompositeAttribute_field_value_component.js'); + LStemplate :: addJSscript('LSformElement_jsonCompositeAttribute_field_value.js'); + LStemplate :: addJSscript('LSformElement_jsonCompositeAttribute_field.js'); + LStemplate :: addJSscript('LSformElement_jsonCompositeAttribute.js'); } return $return; diff --git a/src/includes/class/class.LSformElement_mail.php b/src/includes/class/class.LSformElement_mail.php index 9faee999..c93424cb 100644 --- a/src/includes/class/class.LSformElement_mail.php +++ b/src/includes/class/class.LSformElement_mail.php @@ -60,7 +60,7 @@ class LSformElement_mail extends LSformElement_text { LSmail :: loadDependenciesDisplay(); } if (!$this -> isFreeze() && $this -> getParam('html_options.autocomplete')) { - LSsession :: addJSconfigParam('LSformElement_mail_autocomplete_noResultLabel', _('No result')); + LStemplate :: addJSconfigParam('LSformElement_mail_autocomplete_noResultLabel', _('No result')); } return parent :: getDisplay(); } diff --git a/src/includes/class/class.LSformElement_mailQuota.php b/src/includes/class/class.LSformElement_mailQuota.php index 11bfbe14..3b694955 100644 --- a/src/includes/class/class.LSformElement_mailQuota.php +++ b/src/includes/class/class.LSformElement_mailQuota.php @@ -82,7 +82,7 @@ class LSformElement_mailQuota extends LSformElement { } } - LSsession :: addCssFile('LSformElement_mailQuota.css'); + LStemplate :: addCssFile('LSformElement_mailQuota.css'); $return['html'] = $this -> fetchTemplate( NULL, diff --git a/src/includes/class/class.LSformElement_password.php b/src/includes/class/class.LSformElement_password.php index 073adbf3..df954f61 100644 --- a/src/includes/class/class.LSformElement_password.php +++ b/src/includes/class/class.LSformElement_password.php @@ -122,7 +122,7 @@ class LSformElement_password extends LSformElement { * @retval array */ public function getDisplay(){ - LSsession :: addCssFile('LSformElement_password.css'); + LStemplate :: addCssFile('LSformElement_password.css'); $return = $this -> getLabelInfos(); $pwd = ""; if ($this -> getParam('html_options.clearView') or $this -> getParam('html_options.clearEdit')) { @@ -160,10 +160,10 @@ class LSformElement_password extends LSformElement { $params['mail'] = $this -> getParam('html_options.mail'); $params['mail']['mail_attr'] = $this -> getMailAttrs(); } - LSsession :: addJSconfigParam($this -> name, $params); + LStemplate :: addJSconfigParam($this -> name, $params); - LSsession :: addJSscript('LSformElement_password_field.js'); - LSsession :: addJSscript('LSformElement_password.js'); + LStemplate :: addJSscript('LSformElement_password_field.js'); + LStemplate :: addJSscript('LSformElement_password.js'); } $return['html'] = $this -> fetchTemplate ( NULL, diff --git a/src/includes/class/class.LSformElement_postaladdress.php b/src/includes/class/class.LSformElement_postaladdress.php index 58684813..c50645a6 100644 --- a/src/includes/class/class.LSformElement_postaladdress.php +++ b/src/includes/class/class.LSformElement_postaladdress.php @@ -63,7 +63,7 @@ class LSformElement_postaladdress extends LSformElement_textarea { else { $this -> attr_html -> attribute -> ldapObject -> registerOtherValue('pattern', LSformElement_postaladdress__generate_pattern($this)); } - LSsession :: addJSconfigParam('LSformElement_postaladdress_'.$this -> name, array ( + LStemplate :: addJSconfigParam('LSformElement_postaladdress_'.$this -> name, array ( 'map_url' => $this -> attr_html -> attribute -> ldapObject -> getFData($map_url_format) ) ); @@ -73,7 +73,7 @@ class LSformElement_postaladdress extends LSformElement_textarea { 'viewOnMap' => _('View on map') ) ); - LSsession :: addJSscript('LSformElement_postaladdress.js'); + LStemplate :: addJSscript('LSformElement_postaladdress.js'); } } return $return; diff --git a/src/includes/class/class.LSformElement_pre.php b/src/includes/class/class.LSformElement_pre.php index 1b3577bc..6d985948 100644 --- a/src/includes/class/class.LSformElement_pre.php +++ b/src/includes/class/class.LSformElement_pre.php @@ -41,7 +41,7 @@ class LSformElement_pre extends LSformElement_textarea { */ public function getDisplay(){ $return = parent :: getDisplay(); - LSsession :: addCssFile('LSformElement_pre.css'); + LStemplate :: addCssFile('LSformElement_pre.css'); return $return; } diff --git a/src/includes/class/class.LSformElement_quota.php b/src/includes/class/class.LSformElement_quota.php index f0cd2e79..13207dc6 100644 --- a/src/includes/class/class.LSformElement_quota.php +++ b/src/includes/class/class.LSformElement_quota.php @@ -82,7 +82,7 @@ class LSformElement_quota extends LSformElement { } } - LSsession :: addCssFile('LSformElement_quota.css'); + LStemplate :: addCssFile('LSformElement_quota.css'); $return['html'] = $this -> fetchTemplate( NULL, diff --git a/src/includes/class/class.LSformElement_select.php b/src/includes/class/class.LSformElement_select.php index 4e22d3f0..410edea0 100644 --- a/src/includes/class/class.LSformElement_select.php +++ b/src/includes/class/class.LSformElement_select.php @@ -52,7 +52,7 @@ class LSformElement_select extends LSformElement { 'clear' => _("Reset selection.") ) ); - LSsession :: addJSscript('LSformElement_select.js'); + LStemplate :: addJSscript('LSformElement_select.js'); } $params['possible_values'] = $this -> params['text_possible_values']; $params['unrecognized_value_label_format'] = _("%{value} (unrecognized value)"); diff --git a/src/includes/class/class.LSformElement_select_box.php b/src/includes/class/class.LSformElement_select_box.php index 432a3274..e3b039e2 100644 --- a/src/includes/class/class.LSformElement_select_box.php +++ b/src/includes/class/class.LSformElement_select_box.php @@ -45,7 +45,7 @@ class LSformElement_select_box extends LSformElement_select { */ public function getDisplay(){ if (!$this -> isFreeze()) { - LSsession :: addCssFile('LSformElement_select_box.css'); + LStemplate :: addCssFile('LSformElement_select_box.css'); } $this -> fetchVariables['translate_labels'] = $this -> getParam('translate_labels', true); return parent :: getDisplay(); diff --git a/src/includes/class/class.LSformElement_select_object.php b/src/includes/class/class.LSformElement_select_object.php index 27a05cb7..8bb6740f 100644 --- a/src/includes/class/class.LSformElement_select_object.php +++ b/src/includes/class/class.LSformElement_select_object.php @@ -54,14 +54,14 @@ class LSformElement_select_object extends LSformElement { * @retval array */ public function getDisplay($refresh=NULL){ - LSsession :: addCssFile('LSformElement_select_object.css'); + LStemplate :: addCssFile('LSformElement_select_object.css'); if ($refresh) { $this -> values = $this -> getValuesFromLSselect(); } $return = $this -> getLabelInfos(); if (!$this -> isFreeze()) { - LSsession :: addJSconfigParam( + LStemplate :: addJSconfigParam( $this -> name, array( 'LSselect_id' => $this -> attr_html -> getLSselectId(), @@ -86,8 +86,8 @@ class LSformElement_select_object extends LSformElement { ) ); - LSsession :: addJSscript('LSformElement_select_object_field.js'); - LSsession :: addJSscript('LSformElement_select_object.js'); + LStemplate :: addJSscript('LSformElement_select_object_field.js'); + LStemplate :: addJSscript('LSformElement_select_object.js'); if (LSsession :: loadLSclass('LSselect') && $this -> initLSselect()) { LSselect :: loadDependenciesDisplay(); } diff --git a/src/includes/class/class.LSformElement_ssh_key.php b/src/includes/class/class.LSformElement_ssh_key.php index 4d6eb13b..67edba06 100644 --- a/src/includes/class/class.LSformElement_ssh_key.php +++ b/src/includes/class/class.LSformElement_ssh_key.php @@ -43,14 +43,14 @@ class LSformElement_ssh_key extends LSformElement { * @retval array */ public function getDisplay(){ - LSsession :: addCssFile('LSformElement_ssh_key.css'); + LStemplate :: addCssFile('LSformElement_ssh_key.css'); $return = $this -> getLabelInfos(); $params = array(); if (!$this -> isFreeze()) { $params['values_txt'] = $this -> values; } else { - LSsession :: addJSscript('LSformElement_ssh_key.js'); + LStemplate :: addJSscript('LSformElement_ssh_key.js'); LSsession :: addHelpInfos ( 'LSformElement_ssh_key', array( diff --git a/src/includes/class/class.LSformElement_supannCompositeAttribute.php b/src/includes/class/class.LSformElement_supannCompositeAttribute.php index 705725a1..bd72d800 100644 --- a/src/includes/class/class.LSformElement_supannCompositeAttribute.php +++ b/src/includes/class/class.LSformElement_supannCompositeAttribute.php @@ -98,9 +98,9 @@ class LSformElement_supannCompositeAttribute extends LSformElement { 'components' => $this -> components ) ); - LSsession :: addCssFile('LSformElement_supannCompositeAttribute.css'); + LStemplate :: addCssFile('LSformElement_supannCompositeAttribute.css'); if (!$this -> isFreeze()) { - LSsession :: addJSconfigParam( + LStemplate :: addJSconfigParam( $this -> name, array( 'searchBtn' => _('Modify'), @@ -109,10 +109,10 @@ class LSformElement_supannCompositeAttribute extends LSformElement { 'components' => $this->components ) ); - LSsession :: addJSscript('LSformElement_supannCompositeAttribute_field_value_component.js'); - LSsession :: addJSscript('LSformElement_supannCompositeAttribute_field_value.js'); - LSsession :: addJSscript('LSformElement_supannCompositeAttribute_field.js'); - LSsession :: addJSscript('LSformElement_supannCompositeAttribute.js'); + LStemplate :: addJSscript('LSformElement_supannCompositeAttribute_field_value_component.js'); + LStemplate :: addJSscript('LSformElement_supannCompositeAttribute_field_value.js'); + LStemplate :: addJSscript('LSformElement_supannCompositeAttribute_field.js'); + LStemplate :: addJSscript('LSformElement_supannCompositeAttribute.js'); } return $return; } diff --git a/src/includes/class/class.LSformElement_supannLabeledValue.php b/src/includes/class/class.LSformElement_supannLabeledValue.php index 9f11b570..3ba4fb79 100644 --- a/src/includes/class/class.LSformElement_supannLabeledValue.php +++ b/src/includes/class/class.LSformElement_supannLabeledValue.php @@ -54,9 +54,9 @@ class LSformElement_supannLabeledValue extends LSformElement { $parseValues[]=$this -> parseValue($val); } $return['html'] = $this -> fetchTemplate(NULL,array('parseValues' => $parseValues)); - LSsession :: addCssFile('LSformElement_supannLabeledValue.css'); + LStemplate :: addCssFile('LSformElement_supannLabeledValue.css'); if (!$this -> isFreeze()) { - LSsession :: addJSconfigParam( + LStemplate :: addJSconfigParam( $this -> name, array( 'searchBtn' => _('Modify'), @@ -65,9 +65,9 @@ class LSformElement_supannLabeledValue extends LSformElement { 'components' => $this->components ) ); - LSsession :: addJSscript('LSformElement_supannLabeledValue_field_value.js'); - LSsession :: addJSscript('LSformElement_supannLabeledValue_field.js'); - LSsession :: addJSscript('LSformElement_supannLabeledValue.js'); + LStemplate :: addJSscript('LSformElement_supannLabeledValue_field_value.js'); + LStemplate :: addJSscript('LSformElement_supannLabeledValue_field.js'); + LStemplate :: addJSscript('LSformElement_supannLabeledValue.js'); } return $return; } diff --git a/src/includes/class/class.LSformElement_text.php b/src/includes/class/class.LSformElement_text.php index 6c2ef011..eae3846a 100644 --- a/src/includes/class/class.LSformElement_text.php +++ b/src/includes/class/class.LSformElement_text.php @@ -49,7 +49,7 @@ class LSformElement_text extends LSformElement { // value if (!$this -> isFreeze()) { if ($this -> getParam('html_options')) { - LSsession :: addJSconfigParam($this -> name, $this -> getParam('html_options')); + LStemplate :: addJSconfigParam($this -> name, $this -> getParam('html_options')); } LSsession :: addHelpInfos( 'LSformElement_text', @@ -57,14 +57,14 @@ class LSformElement_text extends LSformElement { 'generate' => _('Generate the value') ) ); - LSsession :: addJSscript('LSformElement_text_field.js'); - LSsession :: addJSscript('LSformElement_text.js'); + LStemplate :: addJSscript('LSformElement_text_field.js'); + LStemplate :: addJSscript('LSformElement_text.js'); } foreach ($this -> JSscripts as $js) { - LSsession :: addJSscript($js); + LStemplate :: addJSscript($js); } foreach ($this -> CSSfiles as $css) { - LSsession :: addCssFile($css); + LStemplate :: addCssFile($css); } $return['html'] = $this -> fetchTemplate(); return $return; diff --git a/src/includes/class/class.LSformElement_textarea.php b/src/includes/class/class.LSformElement_textarea.php index fb61eb6e..7168dbb4 100644 --- a/src/includes/class/class.LSformElement_textarea.php +++ b/src/includes/class/class.LSformElement_textarea.php @@ -51,9 +51,9 @@ class LSformElement_textarea extends LSformElement { 'clear' => _('Clear') ) ); - LSsession :: addJSscript('LSformElement_textarea.js'); + LStemplate :: addJSscript('LSformElement_textarea.js'); } - LSsession :: addCssFile('LSformElement_textarea.css'); + LStemplate :: addCssFile('LSformElement_textarea.css'); $return['html'] = $this -> fetchTemplate( NULL, array ( diff --git a/src/includes/class/class.LSformElement_valueWithUnit.php b/src/includes/class/class.LSformElement_valueWithUnit.php index af666d61..230f8b9c 100644 --- a/src/includes/class/class.LSformElement_valueWithUnit.php +++ b/src/includes/class/class.LSformElement_valueWithUnit.php @@ -111,7 +111,7 @@ class LSformElement_valueWithUnit extends LSformElement { } } - LSsession :: addCssFile('LSformElement_valueWithUnit.css'); + LStemplate :: addCssFile('LSformElement_valueWithUnit.css'); $return['html']=$this -> fetchTemplate( NULL, diff --git a/src/includes/class/class.LSformElement_wysiwyg.php b/src/includes/class/class.LSformElement_wysiwyg.php index fc01823c..290e4ed5 100644 --- a/src/includes/class/class.LSformElement_wysiwyg.php +++ b/src/includes/class/class.LSformElement_wysiwyg.php @@ -43,17 +43,17 @@ class LSformElement_wysiwyg extends LSformElement { public function getDisplay(){ $return = $this -> getLabelInfos(); if (!$this -> isFreeze()) { - LSsession :: addLibJSscript('tinymce/js/tinymce/tinymce.min.js'); - LSsession :: addJSconfigParam( + LStemplate :: addLibJSscript('tinymce/js/tinymce/tinymce.min.js'); + LStemplate :: addJSconfigParam( $this -> name, array( 'extra_options' => $this -> getParam('html_options.extra_options', array()), ) ); } - LSsession :: addJSscript('LSformElement_wysiwyg_field.js'); - LSsession :: addJSscript('LSformElement_wysiwyg.js'); - LSsession :: addCssFile('LSformElement_wysiwyg.css'); + LStemplate :: addJSscript('LSformElement_wysiwyg_field.js'); + LStemplate :: addJSscript('LSformElement_wysiwyg.js'); + LStemplate :: addCssFile('LSformElement_wysiwyg.css'); $return['html'] = $this -> fetchTemplate(); return $return; } diff --git a/src/includes/class/class.LSmail.php b/src/includes/class/class.LSmail.php index 5a72affd..e50fd9cf 100644 --- a/src/includes/class/class.LSmail.php +++ b/src/includes/class/class.LSmail.php @@ -32,8 +32,8 @@ class LSmail { LSsmoothbox :: loadDependenciesDisplay(); } - LSsession :: addJSscript('LSmail.js'); - LSsession :: addCssFile('LSmail.css'); + LStemplate :: addJSscript('LSmail.js'); + LStemplate :: addCssFile('LSmail.css'); } public static function ajax_display(&$data) { diff --git a/src/includes/class/class.LSrelation.php b/src/includes/class/class.LSrelation.php index 3d0fad89..2078837f 100644 --- a/src/includes/class/class.LSrelation.php +++ b/src/includes/class/class.LSrelation.php @@ -595,10 +595,10 @@ class LSrelation extends LSlog_staticLoggerClass { if (LSsession :: loadLSclass('LSselect')) { LSselect :: loadDependenciesDisplay(); } - LSsession :: addJSscript('LSrelation.js'); - LSsession :: addCssFile('LSrelation.css'); + LStemplate :: addJSscript('LSrelation.js'); + LStemplate :: addCssFile('LSrelation.css'); - LSsession :: addJSconfigParam('LSrelation_labels', array( + LStemplate :: addJSconfigParam('LSrelation_labels', array( 'close_confirm_text' => _('Do you really want to delete'), 'close_confirm_title' => _('Warning'), 'close_confirm_validate' => _('Delete') @@ -689,7 +689,7 @@ class LSrelation extends LSlog_staticLoggerClass { self :: loadDependenciesDisplay(); LStemplate :: assign('LSrelations',$LSrelations); - LSsession :: addJSconfigParam('LSrelations',$LSrelations_JSparams); + LStemplate :: addJSconfigParam('LSrelations',$LSrelations_JSparams); } /* diff --git a/src/includes/class/class.LSselect.php b/src/includes/class/class.LSselect.php index 8f88020f..c8919e86 100644 --- a/src/includes/class/class.LSselect.php +++ b/src/includes/class/class.LSselect.php @@ -33,8 +33,8 @@ class LSselect extends LSlog_staticLoggerClass { if (LSsession :: loadLSclass('LSsmoothbox')) { LSsmoothbox :: loadDependenciesDisplay(); } - LSsession :: addJSscript('LSselect.js'); - LSsession :: addCssFile('LSselect.css'); + LStemplate :: addJSscript('LSselect.js'); + LStemplate :: addCssFile('LSselect.css'); } /** diff --git a/src/includes/class/class.LSsession.php b/src/includes/class/class.LSsession.php index fec998af..03222b83 100644 --- a/src/includes/class/class.LSsession.php +++ b/src/includes/class/class.LSsession.php @@ -1356,7 +1356,7 @@ class LSsession { LStemplate :: assign('ldapservers', $ldapservers); LStemplate :: assign('ldapServerId', (self :: $ldapServerId?self :: $ldapServerId:0)); self :: setTemplate('login.tpl'); - self :: addJSscript('LSsession_login.js'); + LStemplate :: addJSscript('LSsession_login.js'); } /** @@ -1403,7 +1403,7 @@ class LSsession { LStemplate :: assign('recoverpassword_msg', $recoverpassword_msg); self :: setTemplate('recoverpassword.tpl'); - self :: addJSscript('LSsession_recoverPassword.js'); + LStemplate :: addJSscript('LSsession_recoverPassword.js'); } /** @@ -1425,28 +1425,44 @@ class LSsession { * * @param[in] $file string The JS filename * @param[in] $path string|null The sub-directory path that contain this file. - * Keep for retro-compatibility : you could just - * prefix the file name. + * @deprecated + * @see LStemplate :: addJSscript() * * @retval void */ public static function addJSscript($file, $path=NULL) { if ($path) $file = $path.$file; - if (!in_array($file, self :: $JSscripts)) - self :: $JSscripts[] = $file; + LStemplate :: addJSscript($file); + LSerror :: addErrorCode( + 'LSsession_27', + array( + 'old' => 'LStemplate :: addJSscript()', + 'new' => 'LStemplate :: addJSscript()', + 'context' => LSlog :: get_debug_backtrace_context(), + ) + ); } /** * Add a library JS file to load on page * * @param[in] $file string The JS filename + * @deprecated + * @see LStemplate :: addLibJSscript() * * @retval void */ public static function addLibJSscript($file) { - if (!in_array($file, self :: $LibsJSscripts)) - self :: $LibsJSscripts[] = $file; + LStemplate :: addLibJSscript($file); + LSerror :: addErrorCode( + 'LSsession_27', + array( + 'old' => 'LStemplate :: addLibJSscript()', + 'new' => 'LStemplate :: addLibJSscript()', + 'context' => LSlog :: get_debug_backtrace_context(), + ) + ); } /** @@ -1454,11 +1470,22 @@ class LSsession { * * @param[in] $name string Nom de la variable de configuration * @param[in] $val mixed Valeur de la variable de configuration + * @deprecated + * @see LStemplate :: addJSconfigParam() * * @retval void */ - public static function addJSconfigParam($name,$val) { - self :: $_JSconfigParams[$name]=$val; + public static function addJSconfigParam($name, $val) { + LStemplate :: addJSconfigParam($name, $val); + LSerror :: addErrorCode( + 'LSsession_27', + array( + 'old' => 'LStemplate :: addJSconfigParam()', + 'new' => 'LStemplate :: addJSconfigParam()', + 'context' => LSlog :: get_debug_backtrace_context(), + ), + false + ); } /** @@ -1466,28 +1493,44 @@ class LSsession { * * @param[in] $file string The CSS filename * @param[in] $path string|null The sub-directory path that contain this file. - * Keep for retro-compatibility : you could just - * prefix the file name. + * @deprecated + * @see LStemplate :: addCssFile() * * @retval void */ public static function addCssFile($file, $path=NULL) { if ($path) $file = $path.$file; - if (!in_array($file, self :: $CssFiles)) - self :: $CssFiles[] = $file; + LStemplate :: addCssFile($file); + LSerror :: addErrorCode( + 'LSsession_27', + array( + 'old' => 'LStemplate :: addCssFile()', + 'new' => 'LStemplate :: addCssFile()', + 'context' => LSlog :: get_debug_backtrace_context(), + ) + ); } /** * Add a library CSS file to load on page * * @param[in] $file string The CSS filename + * @deprecated + * @see LStemplate :: addLibCssFile() * * @retval void */ public static function addLibCssFile($file) { - if (!in_array($file, self :: $LibsCssFiles)) - self :: $LibsCssFiles[] = $file; + LStemplate :: addLibCssFile($file); + LSerror :: addErrorCode( + 'LSsession_27', + array( + 'old' => 'LStemplate :: addLibCssFile()', + 'new' => 'LStemplate :: addLibCssFile()', + 'context' => LSlog :: get_debug_backtrace_context(), + ) + ); } /** @@ -1508,37 +1551,12 @@ class LSsession { || (self :: $ldapServer['keepLSsessionActive']) ) { - self :: addJSconfigParam('keepLSsessionActive',ini_get('session.gc_maxlifetime')); + LStemplate :: addJSconfigParam('keepLSsessionActive',ini_get('session.gc_maxlifetime')); } - LStemplate :: assign('LSjsConfig',base64_encode(json_encode(self :: $_JSconfigParams))); - - // JS files - $JSscripts = array(); - if (isset($GLOBALS['defaultJSscipts']) && is_array($GLOBALS['defaultJSscipts'])) - foreach ($GLOBALS['defaultJSscipts'] as $script) - if (!in_array($script, $JSscripts)) - $JSscripts[] = $script; - - foreach (self :: $JSscripts as $script) - if (!in_array($script, $JSscripts)) - $JSscripts[] = $script; - LStemplate :: assign('JSscripts', $JSscripts); - LStemplate :: assign('LibsJSscripts', self :: $LibsJSscripts); - LStemplate :: assign('LSdebug', boolval(LSdebug)); - - // CSS files - self :: addCssFile("LSdefault.css"); - if (isset($GLOBALS['defaultCSSfiles']) && is_array($GLOBALS['defaultCSSfiles'])) - foreach ($GLOBALS['defaultCSSfiles'] as $file) - if (!in_array($script, self :: $CssFiles)) - self :: addCssFile($file); - LStemplate :: assign('CssFiles', self :: $CssFiles); - LStemplate :: assign('LibsCssFiles', self :: $LibsCssFiles); - // Access LStemplate :: assign('LSaccess', self :: getLSaccess()); - LStemplate :: assign('LSaddonsViewsAccess',self :: $LSaddonsViewsAccess); + LStemplate :: assign('LSaddonsViewsAccess', self :: $LSaddonsViewsAccess); // Niveau $listTopDn = self :: getSubDnLdapServer(); @@ -2574,7 +2592,14 @@ class LSsession { * @retval void */ public static function redirect($url, $exit=true) { - LSerror :: addErrorCode('LSsession_27'); + LSerror :: addErrorCode( + 'LSsession_27', + array( + 'old' => 'LSsession :: redirect()', + 'new' => 'LSurl :: redirect()', + 'context' => LSlog :: get_debug_backtrace_context(), + ) + ); LSurl :: redirect($url); } @@ -2714,7 +2739,7 @@ class LSsession { _("LSsession : You have been redirect from an old-style URL %{url}. Please upgrade this link.") ); LSerror :: defineError('LSsession_27', - _("LSsession : You still seen use LSsession :: redirect() in your custom code. Please upgrade it and use LSurl :: redirect().") + _("LSsession : You always seem to use %{old} in your custom code: Please upgrade it and use %{new}.
\nContext:\n%{context}
") ); } diff --git a/src/includes/class/class.LSsmoothbox.php b/src/includes/class/class.LSsmoothbox.php index f7ac3be3..736880a8 100644 --- a/src/includes/class/class.LSsmoothbox.php +++ b/src/includes/class/class.LSsmoothbox.php @@ -31,10 +31,10 @@ class LSsmoothbox { if (LSsession :: loadLSclass('LSconfirmBox')) { LSconfirmBox :: loadDependenciesDisplay(); } - LSsession :: addJSscript('LSsmoothbox.js'); - LSsession :: addCssFile('LSsmoothbox.css'); + LStemplate :: addJSscript('LSsmoothbox.js'); + LStemplate :: addCssFile('LSsmoothbox.css'); - LSsession :: addJSconfigParam('LSsmoothbox_labels', array( + LStemplate :: addJSconfigParam('LSsmoothbox_labels', array( 'close_confirm_text' => _('Are you sure to want to close this window and lose all changes ?'), 'validate' => _('Validate') )); diff --git a/src/includes/class/class.LStemplate.php b/src/includes/class/class.LStemplate.php index be11bef3..d1348b2f 100644 --- a/src/includes/class/class.LStemplate.php +++ b/src/includes/class/class.LStemplate.php @@ -31,6 +31,21 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); */ class LStemplate extends LSlog_staticLoggerClass { + // Javascript files to load on page + private static $JSscripts = array(); + + // Libs JS files to load on page + private static $LibsJSscripts = array(); + + // Javascript configuration parameter to set on page + private static $JSconfigParams = array(); + + // CSS files to load on page + private static $CssFiles = array(); + + // Libs CSS files to load on page + private static $LibsCssFiles = array(); + /** * LStemplate configuration * @@ -350,6 +365,48 @@ class LStemplate extends LSlog_staticLoggerClass { return self :: $_smarty -> assign($name,$value); } + /** + * Assign common template variables + * + * @retval void + **/ + public static function assignCommonVars() { + // JS config + LStemplate :: assign('LSjsConfig', base64_encode(json_encode(self :: $JSconfigParams))); + + // JS files + $defaultJSscripts = array( + 'mootools-core.js', + 'mootools-more.js', + 'functions.js', + 'LSdefault.js', + 'LSinfosBox.js', + ); + if (isset($GLOBALS['defaultJSscripts']) && is_array($GLOBALS['defaultJSscripts'])) + foreach ($GLOBALS['defaultJSscripts'] as $file) + if (!in_array($file, $defaultJSscripts)) + $defaultJSscripts[] = $file; + LStemplate :: assign('defaultJSscripts', $defaultJSscripts); + + $JSscripts = array(); + foreach (self :: $JSscripts as $script) + if (!in_array($script, $JSscripts) && !in_array($script, $defaultJSscripts)) + $JSscripts[] = $script; + LStemplate :: assign('JSscripts', $JSscripts); + LStemplate :: assign('LibsJSscripts', self :: $LibsJSscripts); + LStemplate :: assign('LSdebug', boolval(LSdebug)); + + // CSS files + $defaultCssFiles = array("LSdefault.css"); + if (isset($GLOBALS['defaultCSSfiles']) && is_array($GLOBALS['defaultCSSfiles'])) + foreach ($GLOBALS['defaultCSSfiles'] as $file) + if (!in_array($file, $defaultCssFiles)) + $defaultCssFiles[] = $file; + LStemplate :: assign('defaultCssFiles', $defaultCssFiles); + LStemplate :: assign('CssFiles', self :: $CssFiles); + LStemplate :: assign('LibsCssFiles', self :: $LibsCssFiles); + } + /** * Display a template * @@ -362,6 +419,7 @@ class LStemplate extends LSlog_staticLoggerClass { self :: fireEvent('displaying'); try { + self :: assignCommonVars(); self :: $_smarty -> display("ls:$template"); } catch (Exception $e) { @@ -464,6 +522,77 @@ class LStemplate extends LSlog_staticLoggerClass { return $return; } + /* + * Javascript & CSS files helpers methods + */ + + + /** + * Add a JS script to load on page + * + * @param[in] $file string The JS filename + * + * Note: about old $path of the LStemplate :: addJSscript() method, corresponding to + * the sub-directory path that contain the file, you could just prefix the file name. + * + * @retval void + */ + public static function addJSscript($file) { + if (!in_array($file, self :: $JSscripts)) + self :: $JSscripts[] = $file; + } + + /** + * Add a library JS file to load on page + * + * @param[in] $file string The JS filename + * + * @retval void + */ + public static function addLibJSscript($file) { + if (!in_array($file, self :: $LibsJSscripts)) + self :: $LibsJSscripts[] = $file; + } + + /** + * Add Javascript configuration parameter + * + * @param[in] $name string Name of the configuration parameter + * @param[in] $val mixed Value of the configuration parameter + * + * @retval void + */ + public static function addJSconfigParam($name,$val) { + self :: $JSconfigParams[$name]=$val; + } + + /** + * Add a CSS file to load on page + * + * @param[in] $file string The CSS filename + * + * Note: about old $path of the LStemplate :: addCssFile() method, corresponding to + * the sub-directory path that contain the file, you could just prefix the file name. + * + * @retval void + */ + public static function addCssFile($file) { + if (!in_array($file, self :: $CssFiles)) + self :: $CssFiles[] = $file; + } + + /** + * Add a library CSS file to load on page + * + * @param[in] $file string The CSS filename + * + * @retval void + */ + public static function addLibCssFile($file) { + if (!in_array($file, self :: $LibsCssFiles)) + self :: $LibsCssFiles[] = $file; + } + } function LStemplate_smarty_getFData($params) { diff --git a/src/includes/routes.php b/src/includes/routes.php index 9f35c290..1a087117 100644 --- a/src/includes/routes.php +++ b/src/includes/routes.php @@ -742,8 +742,8 @@ function handle_LSobject_import($request) { // Set & display template LSsession :: setTemplate('import.tpl'); - LSsession :: addCssFile('LSform.css'); - LSsession :: addCssFile('LSimport.css'); + LStemplate :: addCssFile('LSform.css'); + LStemplate :: addCssFile('LSimport.css'); LSsession :: displayTemplate(); } LSurl :: add_handler('#^object/(?P[^/]+)/import/?$#', 'handle_LSobject_import'); diff --git a/src/templates/default/LSsession_css.tpl b/src/templates/default/LSsession_css.tpl deleted file mode 100644 index a8db2663..00000000 --- a/src/templates/default/LSsession_css.tpl +++ /dev/null @@ -1,13 +0,0 @@ -{if isset($CssFiles) && is_array($CssFiles)} - -{foreach $CssFiles as $file} - -{/foreach} -{/if} - -{if isset($LibsCssFiles) && is_array($LibsCssFiles)} - -{foreach $LibsCssFiles as $file} - -{/foreach} -{/if} diff --git a/src/templates/default/base.tpl b/src/templates/default/base.tpl index f5902f76..0e073f5c 100644 --- a/src/templates/default/base.tpl +++ b/src/templates/default/base.tpl @@ -9,7 +9,7 @@ {block name="css"} - {include file='ls:LSsession_css.tpl'} + {include file='ls:css.tpl'} {/block} {block name="head"}{/block} @@ -19,7 +19,7 @@ {block name="body"}{/block} -{include file='ls:LSsession_js.tpl'} +{include file='ls:js.tpl'} {block name="js"}{/block} diff --git a/src/templates/default/css.tpl b/src/templates/default/css.tpl new file mode 100644 index 00000000..1aa698c5 --- /dev/null +++ b/src/templates/default/css.tpl @@ -0,0 +1,20 @@ +{if isset($LibsCssFiles) && is_array($LibsCssFiles) && !empty($LibsCssFiles)} + +{foreach $LibsCssFiles as $file} + +{/foreach} +{/if} + +{if isset($CssFiles) && is_array($CssFiles) && !empty($CssFiles)} + +{foreach $CssFiles as $file} + +{/foreach} +{/if} + +{if isset($defaultCssFiles) && is_array($defaultCssFiles) && !empty($defaultCssFiles)} + +{foreach $defaultCssFiles as $file} + +{/foreach} +{/if} diff --git a/src/templates/default/LSsession_js.tpl b/src/templates/default/js.tpl similarity index 51% rename from src/templates/default/LSsession_js.tpl rename to src/templates/default/js.tpl index c682230f..61dc35a3 100644 --- a/src/templates/default/LSsession_js.tpl +++ b/src/templates/default/js.tpl @@ -1,4 +1,11 @@ -{if isset($JSscripts) && is_array($JSscripts)} +{if isset($defaultJSscripts) && is_array($defaultJSscripts) && !empty($defaultJSscripts)} + +{foreach $defaultJSscripts as $file} + +{/foreach} +{/if} + +{if isset($JSscripts) && is_array($JSscripts) && !empty($JSscripts)} {foreach $JSscripts as $file} @@ -8,7 +15,7 @@ -{if isset($LibsJSscripts) && is_array($LibsJSscripts)} +{if isset($LibsJSscripts) && is_array($LibsJSscripts) && !empty($LibsJSscripts)} {foreach $LibsJSscripts as $file} diff --git a/src/templates/default/login.tpl b/src/templates/default/login.tpl index 09ca7b16..2805e497 100644 --- a/src/templates/default/login.tpl +++ b/src/templates/default/login.tpl @@ -1,7 +1,7 @@ {extends file='ls:base.tpl'} {block name="css"} -{include file='ls:LSsession_css.tpl'} +{include file='ls:css.tpl'} {/block} {block name="body"}
diff --git a/src/templates/default/recoverpassword.tpl b/src/templates/default/recoverpassword.tpl index c3b6af3e..cc399489 100644 --- a/src/templates/default/recoverpassword.tpl +++ b/src/templates/default/recoverpassword.tpl @@ -1,7 +1,7 @@ {extends file='ls:base.tpl'} {block name="css"} -{include file='ls:LSsession_css.tpl'} +{include file='ls:css.tpl'} {/block} {block name="body"}