@@ -51,12 +51,14 @@ public function loadListDef($file, $module = '')
5151 $ this ->module = $ module ;
5252
5353 //* Fill datasources
54- foreach ($ this ->listDef ['item ' ] as $ key => $ field ) {
55- if (@is_array ($ field ['datasource ' ])) {
56- $ this ->listDef ['item ' ][$ key ]['value ' ] = $ this ->getDatasourceData ($ field );
57- }
54+ if (@is_array ($ this ->listDef ['item ' ])) {
55+ foreach ($ this ->listDef ['item ' ] as $ key => $ field ) {
56+ if (@is_array ($ field ['datasource ' ])) {
57+ $ this ->listDef ['item ' ][$ key ]['value ' ] = $ this ->getDatasourceData ($ field );
58+ }
59+ }
5860 }
59-
61+
6062 //* Set local Language File
6163 $ lng_file = 'lib/lang/ ' .$ _SESSION ['s ' ]['language ' ].'_ ' .$ this ->listDef ['name ' ].'_list.lng ' ;
6264 if (!file_exists ($ lng_file )) $ lng_file = 'lib/lang/en_ ' .$ this ->listDef ['name ' ].'_list.lng ' ;
@@ -136,51 +138,53 @@ public function getSearchSQL($sql_where = '')
136138 }
137139
138140 //* store retrieval query
139- foreach ($ this ->listDef ['item ' ] as $ i ) {
140- $ field = $ i ['field ' ];
141-
142- //* The search string has been changed
143- if (isset ($ _REQUEST [$ search_prefix .$ field ]) && isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]) && $ _REQUEST [$ search_prefix .$ field ] != $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]){
144- $ this ->searchChanged = 1 ;
145-
146- //* Jump back to page 1 of the list when search has changed.
147- $ _SESSION ['search ' ][$ list_name ]['page ' ] = 0 ;
148- }
141+ if (@is_array ($ this ->listDef ['item ' ])) {
142+ foreach ($ this ->listDef ['item ' ] as $ i ) {
143+ $ field = $ i ['field ' ];
144+
145+ //* The search string has been changed
146+ if (isset ($ _REQUEST [$ search_prefix .$ field ]) && isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]) && $ _REQUEST [$ search_prefix .$ field ] != $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]){
147+ $ this ->searchChanged = 1 ;
148+
149+ //* Jump back to page 1 of the list when search has changed.
150+ $ _SESSION ['search ' ][$ list_name ]['page ' ] = 0 ;
151+ }
149152
150- //* Store field in session
151- if (isset ($ _REQUEST [$ search_prefix .$ field ])){
152- $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ] = $ _REQUEST [$ search_prefix .$ field ];
153- }
153+ //* Store field in session
154+ if (isset ($ _REQUEST [$ search_prefix .$ field ])){
155+ $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ] = $ _REQUEST [$ search_prefix .$ field ];
156+ }
154157
155- if (isset ($ i ['formtype ' ]) && $ i ['formtype ' ] == 'SELECT ' ){
156- if (is_array ($ i ['value ' ])) {
157- $ out = '<option value=""></option> ' ;
158- foreach ($ i ['value ' ] as $ k => $ v ) {
159- // TODO: this could be more elegant
160- $ selected = (isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ])
161- && $ k == $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]
162- && $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ] != '' )
163- ? ' SELECTED ' : '' ;
164- $ out .= "<option value=' $ k' $ selected> $ v</option> \r\n" ;
158+ if (isset ($ i ['formtype ' ]) && $ i ['formtype ' ] == 'SELECT ' ){
159+ if (is_array ($ i ['value ' ])) {
160+ $ out = '<option value=""></option> ' ;
161+ foreach ($ i ['value ' ] as $ k => $ v ) {
162+ // TODO: this could be more elegant
163+ $ selected = (isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ])
164+ && $ k == $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]
165+ && $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ] != '' )
166+ ? ' SELECTED ' : '' ;
167+ $ out .= "<option value=' $ k' $ selected> $ v</option> \r\n" ;
168+ }
169+ }
170+ $ this ->searchValues [$ search_prefix .$ field ] = $ out ;
171+ } else {
172+ if (isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ])){
173+ $ this ->searchValues [$ search_prefix .$ field ] = htmlspecialchars ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]);
165174 }
166- }
167- $ this ->searchValues [$ search_prefix .$ field ] = $ out ;
168- } else {
169- if (isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ])){
170- $ this ->searchValues [$ search_prefix .$ field ] = htmlspecialchars ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]);
171175 }
172176 }
173177 }
174-
175178 //* Store variables in object | $this->searchValues = $_SESSION["search"][$list_name];
176- foreach ($ this ->listDef ['item ' ] as $ i ) {
177- $ field = $ i ['field ' ];
178- // if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and";
179- if (isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]) && $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ] != '' ){
180- $ sql_where .= " $ field " .$ i ['op ' ]." ' " .$ i ['prefix ' ].$ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ].$ i ['suffix ' ]."' and " ;
179+ if (@is_array ($ this ->listDef ['item ' ])) {
180+ foreach ($ this ->listDef ['item ' ] as $ i ) {
181+ $ field = $ i ['field ' ];
182+ // if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and";
183+ if (isset ($ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ]) && $ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ] != '' ){
184+ $ sql_where .= " $ field " .$ i ['op ' ]." ' " .$ i ['prefix ' ].$ _SESSION ['search ' ][$ list_name ][$ search_prefix .$ field ].$ i ['suffix ' ]."' and " ;
185+ }
181186 }
182187 }
183-
184188 return ( $ sql_where != '' ) ? $ sql_where = substr ($ sql_where ,0 ,-3 ) : '1 ' ;
185189 }
186190
0 commit comments