From 7c37c65366e9343f71cd2e35d4a13dcfc035a924 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 15 Jul 2008 16:24:35 +0000 Subject: [PATCH] =?UTF-8?q?-=20select.php=20&=20view.php=20:=20Correction?= =?UTF-8?q?=20d'un=20bug=20concernant=20le=20trie=20lors=20d'un=20=20=20ra?= =?UTF-8?q?fraichissement.=20-=20base.css=20:=20netoyage=20-=20LSform.js?= =?UTF-8?q?=20:=20=20=20->=20initializeLSform=5FAddAndRemoveBtns()=20:=20M?= =?UTF-8?q?odularisation=20des=20ajouts=20=20=20=20=20=20d'=C3=A9venements?= =?UTF-8?q?=20=20=20->=20Ajout=20du=20concept=20de=20modules=20permettant?= =?UTF-8?q?=20l'initialisation=20JS=20=C3=A0=20l'ajout=20d'un=20=20=20=20?= =?UTF-8?q?=20=20field=20vide=20d'un=20type=20avanc=C3=A9=20-=20Ajout=20de?= =?UTF-8?q?=20types=20de=20champs=20de=20formulaire=20:=20=20=20->=20LSfor?= =?UTF-8?q?mElement=5Furl=20:=20Un=20liens=20web=20(URL)=20=20=20->=20LSfo?= =?UTF-8?q?rmElement=5Frss=20:=20Un=20lien=20RSS=20-=20class.LSformElement?= =?UTF-8?q?.php=20:=20=20=20->=20ajout=20de=20la=20m=C3=A9thode=20getTitle?= =?UTF-8?q?()=20:=20Texte=20descriptif=20du=20champ=20-=20LSdefault.js=20:?= =?UTF-8?q?=20Correction=20de=20la=20d=C3=A9claration=20de=20la=20variable?= =?UTF-8?q?=20LSdebug=5Factive=20-=20modify.php=20:=20Modification=20du=20?= =?UTF-8?q?titre=20des=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../includes/class/class.LSattr_html_rss.php | 53 +++++++++++ .../includes/class/class.LSattr_html_url.php | 53 +++++++++++ trunk/includes/class/class.LSformElement.php | 9 ++ .../class/class.LSformElement_rss.php | 87 +++++++++++++++++ .../class/class.LSformElement_url.php | 88 ++++++++++++++++++ trunk/includes/js/LSdefault.js | 2 +- trunk/includes/js/LSform.js | 36 ++++--- trunk/includes/js/LSformElement_rss.js | 34 +++++++ trunk/includes/js/LSformElement_url.js | 56 +++++++++++ trunk/index_ajax.php | 1 + trunk/modify.php | 5 +- trunk/select.php | 3 + trunk/templates/css/base.css | 1 - trunk/templates/images/rss.png | Bin 0 -> 793 bytes trunk/templates/images/url_add.png | Bin 0 -> 619 bytes trunk/templates/images/url_go.png | Bin 0 -> 634 bytes trunk/view.php | 4 +- 17 files changed, 415 insertions(+), 17 deletions(-) create mode 100644 trunk/includes/class/class.LSattr_html_rss.php create mode 100644 trunk/includes/class/class.LSattr_html_url.php create mode 100644 trunk/includes/class/class.LSformElement_rss.php create mode 100644 trunk/includes/class/class.LSformElement_url.php create mode 100644 trunk/includes/js/LSformElement_rss.js create mode 100644 trunk/includes/js/LSformElement_url.js create mode 100644 trunk/templates/images/rss.png create mode 100644 trunk/templates/images/url_add.png create mode 100644 trunk/templates/images/url_go.png diff --git a/trunk/includes/class/class.LSattr_html_rss.php b/trunk/includes/class/class.LSattr_html_rss.php new file mode 100644 index 00000000..6f505427 --- /dev/null +++ b/trunk/includes/class/class.LSattr_html_rss.php @@ -0,0 +1,53 @@ + + */ +class LSattr_html_rss extends LSattr_html { + + /** + * Ajoute l'attribut au formualaire passer en paramètre + * + * @param[in] &$form LSform Le formulaire + * @param[in] $idForm L'identifiant du formulaire + * @param[in] $data Valeur du champs du formulaire + * + * @retval LSformElement L'element du formulaire ajouté + */ + function addToForm (&$form,$idForm,$data=NULL) { + $element=$form -> addElement('rss', $this -> name, $this -> config['label'],$this -> config, $this); + if(!$element) { + $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); + return; + } + if ($data) { + $element -> setValue($data); + } + return $element; + } + +} + +?> diff --git a/trunk/includes/class/class.LSattr_html_url.php b/trunk/includes/class/class.LSattr_html_url.php new file mode 100644 index 00000000..b7ba0ada --- /dev/null +++ b/trunk/includes/class/class.LSattr_html_url.php @@ -0,0 +1,53 @@ + + */ +class LSattr_html_url extends LSattr_html { + + /** + * Ajoute l'attribut au formualaire passer en paramètre + * + * @param[in] &$form LSform Le formulaire + * @param[in] $idForm L'identifiant du formulaire + * @param[in] $data Valeur du champs du formulaire + * + * @retval LSformElement L'element du formulaire ajouté + */ + function addToForm (&$form,$idForm,$data=NULL) { + $element=$form -> addElement('url', $this -> name, $this -> config['label'],$this -> config, $this); + if(!$element) { + $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); + return; + } + if ($data) { + $element -> setValue($data); + } + return $element; + } + +} + +?> diff --git a/trunk/includes/class/class.LSformElement.php b/trunk/includes/class/class.LSformElement.php index 8296ee98..f75c2bfb 100644 --- a/trunk/includes/class/class.LSformElement.php +++ b/trunk/includes/class/class.LSformElement.php @@ -259,6 +259,15 @@ class LSformElement { return ''; } } + + /** + * Retourne le titre du champ + * + * @retval string Titre du champ + **/ + function getTitle() { + return $this -> form -> ldapObject -> getDisplayValue().' - '.$this -> getLabel(); + } } ?> diff --git a/trunk/includes/class/class.LSformElement_rss.php b/trunk/includes/class/class.LSformElement_rss.php new file mode 100644 index 00000000..a1ce75ca --- /dev/null +++ b/trunk/includes/class/class.LSformElement_rss.php @@ -0,0 +1,87 @@ + + */ + +class LSformElement_rss extends LSformElement { + + /** + * Retourne les infos d'affichage de l'élément + * + * Cette méthode retourne les informations d'affichage de l'élement + * + * @retval array + */ + function getDisplay(){ + $return = $this -> getLabelInfos(); + // value + if (!$this -> isFreeze()) { + $return['html'] = "\n"; + $GLOBALS['LSsession'] -> addJSscript('LSformElement_rss.js'); + } + else { + $return['html'] = "\n"; + } + return $return; + } + + /** + * Retourne le code HTML d'un champ vide + * + * @retval string Code HTML d'un champ vide. + */ + function getEmptyField() { + $multiple = $this -> getMultipleData(); + return ""._(".$multiple; + } +} + +?> diff --git a/trunk/includes/class/class.LSformElement_url.php b/trunk/includes/class/class.LSformElement_url.php new file mode 100644 index 00000000..b20a4665 --- /dev/null +++ b/trunk/includes/class/class.LSformElement_url.php @@ -0,0 +1,88 @@ + + */ + +class LSformElement_url extends LSformElement { + + /** + * Retourne les infos d'affichage de l'élément + * + * Cette méthode retourne les informations d'affichage de l'élement + * + * @retval array + */ + function getDisplay(){ + $return = $this -> getLabelInfos(); + // value + if (!$this -> isFreeze()) { + $return['html'] = "\n"; + $GLOBALS['LSsession'] -> addJSscript('LSformElement_url.js'); + } + else { + $return['html'] = "\n"; + } + return $return; + } + + /** + * Retourne le code HTML d'un champ vide + * + * @retval string Code HTML d'un champ vide. + */ + function getEmptyField() { + $multiple = $this -> getMultipleData(); + return " getTitle()."\">"._( "._(".$multiple; + } + +} + +?> diff --git a/trunk/includes/js/LSdefault.js b/trunk/includes/js/LSdefault.js index 56686957..b9539808 100644 --- a/trunk/includes/js/LSdefault.js +++ b/trunk/includes/js/LSdefault.js @@ -144,7 +144,7 @@ window.addEvent(window.ie ? 'load' : 'domready', function() { varLSdefault = new LSdefault(); }); -LSdebug_active = 0; +var LSdebug_active = 0; function LSdebug() { if (LSdebug_active != 1) return; diff --git a/trunk/includes/js/LSform.js b/trunk/includes/js/LSform.js index 0f9ca468..4678f52a 100644 --- a/trunk/includes/js/LSform.js +++ b/trunk/includes/js/LSform.js @@ -1,14 +1,25 @@ var LSform = new Class({ initialize: function(){ - $$('img.LSform-add-field-btn').each(function(el) { - el.addEvent('click',this.onAddFieldBtnClick.bind(this,el)); + this._modules=[]; + this.initializeLSform_AddAndRemoveBtns(); + }, + + initializeLSform_AddAndRemoveBtns: function(el) { + if (typeof(el) == 'undefined') { + el = document; + } + el.getElements('img[class=LSform-add-field-btn]').each(function(btn) { + btn.addEvent('click',this.onAddFieldBtnClick.bind(this,btn)); }, this); - - $$('img.LSform-remove-field-btn').each(function(el) { - el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el)); + el.getElements('img[class=LSform-remove-field-btn]').each(function(btn) { + btn.addEvent('click',this.onRemoveFieldBtnClick.bind(this,btn)); }, this); }, + addModule: function(name,obj) { + this._modules[name]=obj; + }, + onAddFieldBtnClick: function(img){ var getAttrName = /LSform_add_field_btn_(.*)_.*/ var attrName = getAttrName.exec(img.id)[1]; @@ -36,12 +47,15 @@ var LSform = new Class({ var img = $(data.img); li.set('html',data.html); li.injectAfter(img.getParent()); - li.getElements('img[class=LSform-add-field-btn]').each(function(el) { - el.addEvent('click',this.onAddFieldBtnClick.bind(this,el)); - }, this); - li.getElements('img[class=LSform-remove-field-btn]').each(function(el) { - el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el)); - }, this); + this.initializeLSform_AddAndRemoveBtns(li); + if (typeof(this._modules[data.fieldtype]) != "undefined") { + try { + this._modules[data.fieldtype].reinitialize(li); + } + catch(e) { + LSdebug('Pas de reinitialise pour ' + data.fieldtype); + } + } } }, diff --git a/trunk/includes/js/LSformElement_rss.js b/trunk/includes/js/LSformElement_rss.js new file mode 100644 index 00000000..ecab313b --- /dev/null +++ b/trunk/includes/js/LSformElement_rss.js @@ -0,0 +1,34 @@ +var LSformElement_rss = new Class({ + initialize: function(){ + this.initialiseLSformElement_rss(); + if (typeof(varLSform) != "undefined") { + varLSform.addModule("LSformElement_rss",this); + } + }, + + initialiseLSformElement_rss: function(el) { + if (typeof(el) == 'undefined') { + el = document; + } + el.getElements('img.LSformElement_rss_btn').each(function(btn) { + btn.addEvent('click',this.onBtnClick.bind(this,btn)); + }, this); + }, + + reinitialize: function(el) { + this.initialiseLSformElement_rss(el); + }, + + onBtnClick: function(btn) { + var href = btn.getParent().getFirst().href; + if (typeof(href)=="undefined") { + href = btn.getParent().getFirst().value; + } + if (href!="") { + window.open(href,'_blank'); + } + } +}); +window.addEvent(window.ie ? 'load' : 'domready', function() { + varLSformElement_rss = new LSformElement_rss(); +}); diff --git a/trunk/includes/js/LSformElement_url.js b/trunk/includes/js/LSformElement_url.js new file mode 100644 index 00000000..acb2a6ce --- /dev/null +++ b/trunk/includes/js/LSformElement_url.js @@ -0,0 +1,56 @@ +var LSformElement_url = new Class({ + initialize: function(){ + this.initialiseLSformElement_url(); + if (typeof(varLSform) != "undefined") { + varLSform.addModule("LSformElement_url",this); + } + }, + + initialiseLSformElement_url: function(el) { + if (typeof(el) == 'undefined') { + el = document; + } + el.getElements('img.LSformElement_url_go_btn').each(function(btn) { + btn.addEvent('click',this.onGoBtnClick.bind(this,btn)); + }, this); + el.getElements('img.LSformElement_url_add_favorite_btn').each(function(btn) { + btn.addEvent('click',this.onAddFavoriteBtnClick.bind(this,btn)); + }, this); + }, + + reinitialize: function(el) { + this.initialiseLSformElement_url(el); + }, + + onGoBtnClick: function(btn) { + var href = btn.getParent().getFirst().href; + if (typeof(href)=="undefined") { + href = btn.getParent().getFirst().value; + } + if (href!="") { + window.open(href,'_blank'); + } + }, + + onAddFavoriteBtnClick: function(btn) { + var href = btn.getParent().getFirst().value; + if (typeof(href)=="undefined") { + href = btn.getParent().getFirst().href; + } + var name = btn.getParent().getFirst().title; + if (href!="") { + if (window.sidebar) { + window.sidebar.addPanel(name,href,''); + } + else if(document.all) { + window.external.AddFavorite(href,name); + } + else { + alert('Fonctionnalité pas encore supportée pour votre navigateur.'); + } + } + } +}); +window.addEvent(window.ie ? 'load' : 'domready', function() { + varLSformElement_url = new LSformElement_url(); +}); diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php index 263d3977..899ef8d0 100644 --- a/trunk/index_ajax.php +++ b/trunk/index_ajax.php @@ -46,6 +46,7 @@ if (!isset($_ERRORS)) { $data = array( 'html' => $form -> getEmptyField($_REQUEST['attribute']), 'img' => $_REQUEST['img'], + 'fieldtype' => get_class($form -> getElement($_REQUEST['attribute'])) ); } } diff --git a/trunk/modify.php b/trunk/modify.php index 7bf7e94c..1d36856f 100644 --- a/trunk/modify.php +++ b/trunk/modify.php @@ -27,9 +27,6 @@ $GLOBALS['LSsession'] = new LSsession(); if($LSsession -> startLSsession()) { - // Définition du Titre de la page - $GLOBALS['Smarty'] -> assign('pagetitle',_('Modifier')); - if (isset($_POST['LSform_objecttype'])) { $LSobject = $_POST['LSform_objecttype']; } @@ -64,6 +61,8 @@ if($LSsession -> startLSsession()) { $object = new $LSobject(); if ($object -> loadData($dn)) { + // Définition du Titre de la page + $GLOBALS['Smarty'] -> assign('pagetitle',_('Modifier').' : '.$object -> getDisplayValue()); $form = $object -> getForm('modify'); if ($form->validate()) { // MàJ des données de l'objet LDAP diff --git a/trunk/select.php b/trunk/select.php index ed24fd3f..b06ac619 100644 --- a/trunk/select.php +++ b/trunk/select.php @@ -225,6 +225,9 @@ if($LSsession -> startLSsession()) { if ($GLOBALS['LSsession'] -> cacheSearch()) { $_SESSION['LSsession']['LSsearch'][$hash]=$searchData; } + if ($orderby) { + $sort=true; + } } $GLOBALS['Smarty']->assign('LSobject_list_nbresult',$searchData['LSobject_list_nbresult']); diff --git a/trunk/templates/css/base.css b/trunk/templates/css/base.css index 860e4a7f..b9acf97e 100644 --- a/trunk/templates/css/base.css +++ b/trunk/templates/css/base.css @@ -196,7 +196,6 @@ td.LSobject-list-names { p.LSobject-list-page { text-align: center; margin: 0.5em; - //width: 100%; } a.LSobject-list-page { diff --git a/trunk/templates/images/rss.png b/trunk/templates/images/rss.png new file mode 100644 index 0000000000000000000000000000000000000000..677d87f9a7a5e130608dc0d19b0c7c13d71c6b6c GIT binary patch literal 793 zcmV+!1LpjRP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L0Cg|`0Cg|{-7|8{00007bV*G`2iOM> z4j~9oAV_}z00NmwL_t(I%capvZ%knT#_|9Ap7Wl|+|IPxDIHBkXpp!xMXwS`CE^wf zAt7Oh4`5;I6OdR~NNh;Dl8{K)AxeuC(VIqQFyqn|HRf_o=k{7O6p>hXl4twNlRN@I z_x9L?BOOR-@UPTsb;_U8tb3jpm%-HiUGmGujaQ3Xw;gdEhlr`L4S_)X9jI2}!L1C% z>7C%GOcch4<;|V+^pO{WkL3ldQi(`zp5}6Z`V&wVEKj!ax^@CMXX1bxi9D>FK3+)}KL<=NZ$W1-R zOHUxQhGHJRz6X1eGjZTeDNo6b6ZP{f%gqt}Hb*!!MPbzj^rl|amTpSQAT&0Lcs&M2 z1$?;#l$6Bn8UWK|wp2i+$7#xp5qmjGG4~O@^AOgiZmKhB)W}V+fRY6)Ah987`ZP@3 z$C*tL^5TTL2Pq65BXDfO*%wqF-T)~v2KG^J^cLsqFaQ!4Vpf2cdPLL6HR87~AhMG< ziB{_SPg8YmqNx!IlTVTHCiLK8a0G}SfCHFSzLtG5+CmoI6TNqd%H%LA8b=QvM;5Y( zyO*g{D#)(g=!p9}P>`A@?R(G%&$7^e6j{#^dVB?c_ARPyJ@vK@!r!LJXQmO2NoZ{c z8Ce3#w#nMf+wnXPw{o zXG1^^WF7O}FtwQpWGDo#!1z24b1xB=2~9}=gud7be(@yr+9kk5OF#h@2nB`>QZ3d{ zV7stp7X-;OV*i2j0zjWa0=>Xm$|lreKoo=r(gQOF$^$C~%T~a^jvS72NA&dt{BOPk Xvi0WoMp8^F00000NkvXXu0mjf_#IPO literal 0 HcmV?d00001 diff --git a/trunk/templates/images/url_add.png b/trunk/templates/images/url_add.png new file mode 100644 index 0000000000000000000000000000000000000000..2e945076cf7686b3b408d6eb2cf913992100da15 GIT binary patch literal 619 zcmV-x0+juUP)0Ag3?`k8$#1J0F}NdayEtTz+~+#EG995YAF(1xew#=1J)ogJuY z3Lxu(1VP;KAh`GKm^?X0f~UCV*)Nf5F(3GKr=#9qzp;L29U)FF98>T4&VoHZ|-ho>^FRq4ws;uOVa=V002ovPDHLk FV1kR43LgLf literal 0 HcmV?d00001 diff --git a/trunk/templates/images/url_go.png b/trunk/templates/images/url_go.png new file mode 100644 index 0000000000000000000000000000000000000000..5cc2b0dd36978513f3ca009c68ebc4150976fc80 GIT binary patch literal 634 zcmV-=0)_pFP)cA1hmXWM zDZ#H?v3PJ5$Hq5OmbDN{wJ%9%wAR zT-Qu9!vIN`896F;t~rD&@Nfe0`Nv1rEgogE>hi36i1p_V%rE6ZqX5JdGmz-z3Rm#{ z+Z*c0z*?bg!mefM79{Zs`zK3~u)rkEuD#mHG}dlY@$@R6?<^o~D%1C9AK Udps;mZ~y=R07*qoM6N<$f`qvmMgRZ+ literal 0 HcmV?d00001 diff --git a/trunk/view.php b/trunk/view.php index 874b45cb..44e93ba2 100644 --- a/trunk/view.php +++ b/trunk/view.php @@ -326,7 +326,9 @@ if($LSsession -> startLSsession()) { $searchData['objectList']=$objectList; $searchData['LSview_actions'] = $LSview_actions; - + if ($orderby) { + $sort=true; + } } if ((!isset($searchData['objectList'][0]['actions']))&&(!empty($searchData['objectList']))) {