1 |
<?php |
<?php |
|
|
|
2 |
/** |
/** |
3 |
* This is the base class for managing a list |
* This is the base class for managing a list |
4 |
* of data points. |
* of data points. |
7 |
* @package phpHtmlLib |
* @package phpHtmlLib |
8 |
*/ |
*/ |
9 |
|
|
10 |
|
/** |
11 |
|
* Some global defines used |
12 |
|
*/ |
13 |
define("SORTABLE", TRUE); |
define("SORTABLE", TRUE); |
14 |
define("NOT_SORTABLE", FALSE); |
define("NOT_SORTABLE", FALSE); |
15 |
define("SEARCHABLE", TRUE); |
define("SEARCHABLE", TRUE); |
144 |
*/ |
*/ |
145 |
var $_global_prefix = ''; |
var $_global_prefix = ''; |
146 |
|
|
|
/** |
|
|
* The offset variable name |
|
|
*/ |
|
|
var $_offsetVar = "offset"; |
|
147 |
|
|
148 |
/** |
/** |
149 |
* The order by variable name |
* Holds an array of all the |
150 |
*/ |
* form vars we need for this |
151 |
var $_orderbyVar = "orderby"; |
* class to work. |
152 |
|
*/ |
153 |
|
var $_vars = array("offsetVar" => "offset", |
154 |
|
"orderbyVar" => "orderby", |
155 |
|
"reverseorderVar" => "reverseorder", |
156 |
|
"numrowsVar" => "numrows", |
157 |
|
"showallVar" => "showall", |
158 |
|
"search_fieldVar" => "search_field", |
159 |
|
"search_valueVar" => "search_value", |
160 |
|
"search_typeVar" => "search_type", |
161 |
|
"simple_search_modifierVar" => "simple_search_modifier"); |
162 |
|
|
163 |
/** |
/** |
164 |
* Holds the db column name that |
* Holds the db column name that |
167 |
var $_default_orderby = ''; |
var $_default_orderby = ''; |
168 |
|
|
169 |
/** |
/** |
|
* The reverseorder variable name |
|
|
*/ |
|
|
var $_reverseorderVar = "reverseorder"; |
|
|
|
|
|
/** |
|
170 |
* Holds a flag to let us know to |
* Holds a flag to let us know to |
171 |
* reverse order the column by default |
* reverse order the column by default |
172 |
*/ |
*/ |
173 |
var $_default_reverseorder = "false"; |
var $_default_reverseorder = "false"; |
174 |
|
|
175 |
/** |
/** |
|
* The number of rows variable name |
|
|
*/ |
|
|
var $_numrowsVar = "numrows"; |
|
|
|
|
|
/** |
|
|
* This var to tell us to show all |
|
|
* data or not. |
|
|
*/ |
|
|
var $_showallVar = "showall"; |
|
|
|
|
|
/** |
|
|
* The search field variable |
|
|
*/ |
|
|
var $_search_fieldVar = "search_field"; |
|
|
|
|
|
/** |
|
|
* The search value |
|
|
*/ |
|
|
var $_search_valueVar = "search_value"; |
|
|
|
|
|
/** |
|
|
* The type of search |
|
|
* advanced/simple |
|
|
*/ |
|
|
var $_search_typeVar = "search_type"; |
|
|
|
|
|
/** |
|
|
* The simple search modifier |
|
|
* var name. |
|
|
* |
|
|
*/ |
|
|
var $_simple_search_modifierVar = "simple_search_modifier"; |
|
|
|
|
|
|
|
|
/** |
|
176 |
* Flag to let us know that search |
* Flag to let us know that search |
177 |
* is enabled. |
* is enabled. |
178 |
* |
* |
195 |
var $_simple_search_modifier = FALSE; |
var $_simple_search_modifier = FALSE; |
196 |
|
|
197 |
|
|
198 |
/** |
/** |
199 |
* Holds the object block that is the |
* Holds the object block that is the |
200 |
* search UI |
* search UI |
201 |
*/ |
*/ |
202 |
var $_search_table = NULL; |
var $_search_table = NULL; |
203 |
|
|
204 |
/** |
/** |
205 |
* This holds a list of |
* This holds a list of |
211 |
var $_save_vars = array(); |
var $_save_vars = array(); |
212 |
|
|
213 |
|
|
214 |
/** |
/** |
215 |
* The column descriptions |
* The column descriptions |
216 |
* for the data we are working on |
* for the data we are working on |
217 |
* |
* |
218 |
* @var array |
* @var array |
219 |
*/ |
*/ |
220 |
var $_columns = array(); |
var $_columns = array(); |
221 |
|
|
222 |
/** |
/** |
223 |
* Keeps track of the # of columns we have |
* Keeps track of the # of columns we have |
224 |
*/ |
*/ |
225 |
var $_num_columns = 0; |
var $_num_columns = 0; |
226 |
|
|
227 |
|
|
228 |
/** |
/** |
229 |
* This holds the form attributes |
* This holds the form attributes |
230 |
* |
* |
231 |
*/ |
*/ |
232 |
var $_form_attributes = array("method" => "GET", |
var $_form_attributes = array("method" => "GET", |
233 |
"target" => "", |
"target" => "", |
234 |
"action" => "", |
"action" => "", |
235 |
"name" => ""); |
"name" => ""); |
236 |
|
|
237 |
/** |
/** |
238 |
* Build everything inside a form? |
* Build everything inside a form? |
239 |
* |
* |
240 |
*/ |
*/ |
241 |
var $_form_render_flag = FALSE; |
var $_form_render_flag = FALSE; |
242 |
|
|
243 |
|
|
244 |
/** |
/** |
245 |
* flag to let us know if we want to show |
* flag to let us know if we want to show |
246 |
* the results or not. |
* the results or not. |
247 |
*/ |
*/ |
248 |
var $_show_results_flag = TRUE; |
var $_show_results_flag = TRUE; |
249 |
|
|
250 |
|
|
251 |
/** |
/** |
252 |
* Holds our reference/copy of the |
* Holds our reference/copy of the |
253 |
* DataListSource object which is used to |
* DataListSource object which is used to |
254 |
* access the data that this object uses |
* access the data that this object uses |
255 |
* |
* |
256 |
* @var DataListSource object |
* @var DataListSource object |
257 |
*/ |
*/ |
258 |
var $_datasource = NULL; |
var $_datasource = NULL; |
259 |
|
|
260 |
/** |
/** |
261 |
* This stores the base path to where the |
* This stores the base path to where the |
262 |
* tool link images live. This lets you |
* tool link images live. This lets you |
263 |
* specify a new path to where your images |
* specify a new path to where your images |
264 |
* live. |
* live. |
265 |
*/ |
*/ |
266 |
var $_image_path = "/phphtmllib/images/widgets"; |
var $_image_path = "/phphtmllib/images/widgets"; |
267 |
|
|
268 |
|
|
269 |
/** |
/** |
270 |
* The constructor |
* The constructor |
271 |
* |
* |
272 |
* @param string - the title of the data list |
* @param string - the title of the data list |
273 |
* @param string - the overall width |
* @param string - the overall width |
274 |
* @param string - the column to use as the default sorting order |
* @param string - the column to use as the default sorting order |
275 |
* @param boolean - sort the default column in reverse order? |
* @param boolean - sort the default column in reverse order? |
276 |
*/ |
*/ |
277 |
function DataList($title, $width = "100%", $default_orderby='', |
function DataList($title, $width = "100%", $default_orderby='', |
278 |
$default_reverseorder=FALSE) { |
$default_reverseorder=FALSE) { |
279 |
$this->set_title( $title ); |
$this->set_title( $title ); |
280 |
$this->set_form_name( str_replace(' ', '_', strtolower($title)) ); |
$this->set_form_name( str_replace(' ', '_', strtolower($title)) ); |
281 |
$this->set_width( $width ); |
$this->set_width( $width ); |
282 |
|
|
283 |
|
|
284 |
$this->_default_orderby = $default_orderby; |
$this->_default_orderby = $default_orderby; |
285 |
if ($default_reverseorder === TRUE) { |
if ( $default_reverseorder === TRUE ) { |
286 |
$default_reverseorder = "true"; |
$default_reverseorder = "true"; |
287 |
} if ($default_reverse_order === FALSE) { |
}if ( $default_reverse_order === FALSE ) { |
288 |
$default_reverseorder = "false"; |
$default_reverseorder = "false"; |
289 |
} |
} |
290 |
$this->_default_reverseorder = $default_reverseorder; |
$this->_default_reverseorder = $default_reverseorder; |
291 |
|
|
292 |
|
|
295 |
//item lists per html page. |
//item lists per html page. |
296 |
$this->set_global_prefix(''); |
$this->set_global_prefix(''); |
297 |
|
|
298 |
//child class MUST override this |
//child class MUST override this |
299 |
//method to automatically set |
//method to automatically set |
300 |
//the DataListSource object. |
//the DataListSource object. |
301 |
//This class doesn't work without it. |
//This class doesn't work without it. |
302 |
$this->get_data_source(); |
$this->get_data_source(); |
303 |
|
|
304 |
//Call the subclass setup function. |
//Call the subclass setup function. |
305 |
//This is a way to get around having |
//This is a way to get around having |
306 |
//to override the constructor and |
//to override the constructor and |
307 |
//pass in the same params. |
//pass in the same params. |
308 |
$this->user_setup(); |
$this->user_setup(); |
309 |
} |
} |
310 |
|
|
311 |
|
/** |
312 |
|
* This function renders the final |
313 |
|
* widget |
314 |
|
* |
315 |
|
*/ |
316 |
|
function render($indent_level, $output_debug) { |
317 |
|
|
318 |
|
//setup the columns in their sorts |
319 |
|
$this->setup_columns(); |
320 |
|
|
321 |
|
//do any data prefetch work |
322 |
|
//which may be child specific |
323 |
|
if ( $this->_show_results() ) { |
324 |
|
$this->data_prefetch(); |
325 |
|
} |
326 |
|
|
327 |
|
//This function gives the child class |
328 |
|
//a chance to build the tables/divs/containers |
329 |
|
//that will be responsible for the look/feel |
330 |
|
//of the DataList |
331 |
|
$this->gui_init(); |
332 |
|
|
333 |
/** |
//see if we need to build the search area. |
334 |
* This function renders the final |
if ( $this->is_search_enabled() || $this->is_advanced_search_enabled() ) { |
335 |
* widget |
$this->_search_table = $this->child_build_search_table(); |
336 |
* |
if ( $this->_search_table ) { |
337 |
*/ |
$this->set_form_render(TRUE); |
338 |
function render($indent_level, $output_debug) { |
} |
|
|
|
|
//setup the columns in their sorts |
|
|
$this->setup_columns(); |
|
|
|
|
|
//do any data prefetch work |
|
|
//which may be child specific |
|
|
if ($this->_show_results()) { |
|
|
$this->data_prefetch(); |
|
|
} |
|
|
|
|
|
//This function gives the child class |
|
|
//a chance to build the tables/divs/containers |
|
|
//that will be responsible for the look/feel |
|
|
//of the DataList |
|
|
$this->gui_init(); |
|
|
|
|
|
//see if we need to build the search area. |
|
|
if ($this->is_search_enabled() || $this->is_advanced_search_enabled()) { |
|
|
$this->_search_table = $this->child_build_search_table(); |
|
|
if ($this->_search_table) { |
|
|
$this->set_form_render(TRUE); |
|
|
} |
|
339 |
} |
} |
|
|
|
340 |
|
|
341 |
if ($this->get_form_render()) { |
|
342 |
|
if ( $this->get_form_render() ) { |
343 |
$form = new FORMtag( array("method" => $this->get_form_method(), |
$form = new FORMtag( array("method" => $this->get_form_method(), |
344 |
"action" => $this->build_base_url(), |
"action" => $this->build_base_url(), |
345 |
"name" => $this->get_form_name(), |
"name" => $this->get_form_name(), |
346 |
"style" => "margin-top: 0px;margin-bottom:0px;") ); |
"style" => "margin-top: 0px;margin-bottom:0px;") ); |
347 |
|
|
348 |
$target = $this->get_form_target(); |
$target = $this->get_form_target(); |
349 |
if ($target != NULL) |
if ( $target != NULL ) |
350 |
$form->set_tag_attribute("target",$target); |
$form->set_tag_attribute("target",$target); |
351 |
|
|
352 |
$action = $this->get_form_action(); |
$action = $this->get_form_action(); |
353 |
if ($action != NULL) |
if ( $action != NULL ) |
354 |
$form->set_tag_attribute("action",$action); |
$form->set_tag_attribute("action",$action); |
355 |
|
|
356 |
//now build the UI and return it |
//now build the UI and return it |
357 |
$form->add( $this->build_gui() ); |
$form->add( $this->build_gui() ); |
358 |
|
|
|
//add the save vars the user wants. |
|
|
$form->add( $this->_build_save_vars() ); |
|
359 |
} else { |
} else { |
360 |
$form = container(); |
$form = container(); |
361 |
|
|
362 |
|
//now build the UI and return it |
363 |
|
$form->add( $this->build_gui() ); |
364 |
|
} |
365 |
|
|
366 |
|
//add the hidden vars if we are a POST |
367 |
|
if ($this->get_form_method() == "POST") { |
368 |
|
$form->add( $this->_build_default_vars() ); |
369 |
|
} |
370 |
|
|
371 |
//now build the UI and return it |
//add the save vars the user wants. |
372 |
$form->add( $this->build_gui() ); |
$form->add( $this->_build_save_vars() ); |
|
} |
|
373 |
|
|
374 |
//add any javascript required |
//add any javascript required |
375 |
$container = container( $this->_javascript(), $form ); |
$container = container( $this->_javascript(), $form ); |
376 |
return $container->render( $indent_level, $output_debug ); |
return $container->render( $indent_level, $output_debug ); |
377 |
} |
} |
378 |
|
|
379 |
|
/** |
380 |
|
* This function is responsible for calling the child |
381 |
|
* class's methods for building the GUI container. |
382 |
|
* This function builds the search area, the |
383 |
|
* title, page controls, the column headers, |
384 |
|
* and walks the rows of data and adds them |
385 |
|
* |
386 |
|
* A child class can override this method to |
387 |
|
* move the placement of the search box |
388 |
|
* relative to the data list. By default |
389 |
|
* the search area comes above the table |
390 |
|
* for the data list and page controls |
391 |
|
* |
392 |
|
* @return Container |
393 |
|
*/ |
394 |
|
function build_gui() { |
395 |
|
$container = container(); |
396 |
|
|
397 |
/** |
//if we have a search area to show |
398 |
* This function is responsible for calling the child |
//add it to the ui. |
399 |
* class's methods for building the GUI container. |
if ( $this->_search_table ) { |
400 |
* This function builds the search area, the |
$container->add( $this->_search_table ); |
401 |
* title, page controls, the column headers, |
} |
402 |
* and walks the rows of data and adds them |
|
403 |
* |
if ( $this->_show_results() ) { |
404 |
* A child class can override this method to |
//walk the list of columns and call the child |
405 |
* move the placement of the search box |
//method to add it |
406 |
* relative to the data list. By default |
$column_count = count($this->_columns); |
407 |
* the search area comes above the table |
foreach( $this->_columns as $name => $col ) { |
408 |
* for the data list and page controls |
$this->child_build_column_header( $name, $col, $column_count); |
409 |
* |
} |
410 |
* @return Container |
|
411 |
*/ |
//now walk the list of rows and build and add the |
412 |
function build_gui() { |
//cells of data |
413 |
$container = container(); |
$col_count = count($this->_columns); |
414 |
|
while ( $row = $this->_datasource->get_next_data_row() ) { |
415 |
//if we have a search area to show |
$cnt = 1; |
416 |
//add it to the ui. |
foreach( $this->_columns as $col_name => $data ) { |
417 |
if ($this->_search_table) { |
$obj = $this->build_column_item($row, $col_name); |
418 |
$container->add( $this->_search_table ); |
if ( !is_object($obj) ) { |
419 |
} |
$obj = $this->_clean_string($obj, $col_name); |
|
|
|
|
if ($this->_show_results()) { |
|
|
//walk the list of columns and call the child |
|
|
//method to add it |
|
|
$column_count = count($this->_columns); |
|
|
foreach( $this->_columns as $name => $col ) { |
|
|
$this->child_build_column_header( $name, $col, $column_count); |
|
|
} |
|
|
|
|
|
//now walk the list of rows and build and add the |
|
|
//cells of data |
|
|
$col_count = count($this->_columns); |
|
|
while ($row = $this->_datasource->get_next_data_row()) { |
|
|
$cnt = 1; |
|
|
foreach( $this->_columns as $col_name => $data ) { |
|
|
$obj = $this->build_column_item($row, $col_name); |
|
|
if (!is_object($obj)) { |
|
|
$obj = $this->_clean_string($obj, $col_name); |
|
420 |
} |
} |
421 |
// |
// |
422 |
$this->child_add_row_cell($obj, $col_name, ($cnt == $col_count) ? TRUE : FALSE); |
$this->child_add_row_cell($obj, $col_name, |
423 |
$cnt++; |
(($cnt == $col_count) ? TRUE : FALSE), |
424 |
} |
$row); |
425 |
} |
$cnt++; |
426 |
$container->add( $this->child_get_gui() ); |
} |
427 |
} |
} |
428 |
|
$container->add( $this->child_get_gui() ); |
429 |
|
} |
430 |
return $container; |
|
431 |
} |
|
432 |
|
return $container; |
433 |
/** |
} |
434 |
* This function is called automatically by |
|
435 |
* the DataList constructor. It must be |
/** |
436 |
* extended by the child class to actually |
* This function is called automatically by |
437 |
* set the DataListSource object. |
* the DataList constructor. It must be |
438 |
* |
* extended by the child class to actually |
439 |
* |
* set the DataListSource object. |
440 |
*/ |
* |
441 |
function get_data_source() { |
* |
442 |
user_error("DataList::get_data_source() - ". |
*/ |
443 |
"child class must override this to ". |
function get_data_source() { |
444 |
"set the the DataListSource object."); |
user_error("DataList::get_data_source() - ". |
445 |
} |
"child class must override this to ". |
446 |
|
"set the the DataListSource object."); |
447 |
|
} |
448 |
|
|
449 |
/** |
/** |
450 |
* A subclass can override this function |
* A subclass can override this function |
451 |
* to setup the class variables after |
* to setup the class variables after |
452 |
* the constructor. The constructor |
* the constructor. The constructor |
453 |
* automatically calls this function. |
* automatically calls this function. |
454 |
* |
* |
455 |
*/ |
*/ |
456 |
function user_setup() { |
function user_setup() { |
457 |
user_error("DataList::user_setup() - ". |
user_error("DataList::user_setup() - ". |
458 |
"child class must override this method ". |
"child class must override this method ". |
459 |
"to set the columns, and any options for ". |
"to set the columns, and any options for ". |
460 |
"the DataListSource."); |
"the DataListSource."); |
461 |
} |
} |
462 |
|
|
463 |
/** |
/** |
465 |
* to setup the class variables after |
* to setup the class variables after |
466 |
* the constructor. The constructor |
* the constructor. The constructor |
467 |
* automatically calls this function. |
* automatically calls this function. |
468 |
* |
* |
469 |
*/ |
*/ |
470 |
function gui_init() { |
function gui_init() { |
471 |
user_error("DataList::gui_init() - ". |
user_error("DataList::gui_init() - ". |
472 |
"child class must override this method ". |
"child class must override this method ". |
473 |
"to set up the containers/objects that will ". |
"to set up the containers/objects that will ". |
474 |
"hold the search area, page controls, ". |
"hold the search area, page controls, ". |
475 |
"column headers and the data cells"); |
"column headers and the data cells"); |
476 |
} |
} |
477 |
|
|
478 |
/** |
/** |
479 |
* This method is supposed to be written by |
* This method is supposed to be written by |
480 |
* the child class to build and add the column |
* the child class to build and add the column |
481 |
* title to the UI |
* title to the UI |
482 |
* |
* |
483 |
* @param string - the title of the column |
* @param string - the title of the column |
484 |
* @param array - the column data ( from $this->_columns ) |
* @param array - the column data ( from $this->_columns ) |
485 |
* @param int - the column # |
* @param int - the column # |
486 |
* |
* |
487 |
*/ |
*/ |
488 |
function child_build_column_header($title, $col_data, $col_count) { |
function child_build_column_header($title, $col_data, $col_count) { |
489 |
user_error("DataList::child_build_column_header() - ". |
user_error("DataList::child_build_column_header() - ". |
490 |
"child class must override this method ". |
"child class must override this method ". |
491 |
"to build the object that will be the ". |
"to build the object that will be the ". |
492 |
"individual column header/itle"); |
"individual column header/itle"); |
493 |
} |
} |
494 |
|
|
495 |
/** |
/** |
496 |
* This method is supposed to be written by |
* This method is supposed to be written by |
497 |
* the child class to add the cell data to the |
* the child class to add the cell data to the |
498 |
* current row in the UI |
* current row in the UI |
499 |
* |
* |
500 |
* @param mixed - the object/string/entity that |
* @param mixed - the object/string/entity that |
501 |
* should get put into the column row cell. |
* should get put into the column row cell. |
502 |
* @param string - the name/title of the column that the |
* @param string - the name/title of the column that the |
503 |
* object will live in |
* object will live in |
504 |
* @param boolean - flag that tells the function if this is |
* @param boolean - flag that tells the function if this is |
505 |
* is the last cell for the current row. |
* is the last cell for the current row. |
506 |
* |
* |
507 |
*/ |
*/ |
508 |
function child_add_row_cell($obj, $col_name, $last_in_row_flag) { |
function child_add_row_cell($obj, $col_name, $last_in_row_flag) { |
509 |
user_error("DataList::child_build_column_header() - ". |
user_error("DataList::child_add_row_cell() - ". |
510 |
"child class must override this method ". |
"child class must override this method ". |
511 |
"to build the object that will be the ". |
"to build the object that will be the ". |
512 |
"individual column header/itle"); |
"individual column data cell"); |
513 |
} |
} |
514 |
|
|
515 |
/** |
/** |
516 |
* This function is called after all of the data has |
* This function is called after all of the data has |
517 |
* been added to the UI object. It just returns the |
* been added to the UI object. It just returns the |
518 |
* container that is the entire UI for the DataList |
* container that is the entire UI for the DataList |
519 |
* |
* |
520 |
* @return Container |
* @return Container |
521 |
*/ |
*/ |
522 |
function child_get_gui() { |
function child_get_gui() { |
523 |
user_error("DataList::child_get_gui() - ". |
user_error("DataList::child_get_gui() - ". |
524 |
"child class must override this method ". |
"child class must override this method ". |
525 |
"to return the wrapper that contains ". |
"to return the wrapper that contains ". |
526 |
"the entire UI."); |
"the entire UI."); |
527 |
} |
} |
|
|
|
|
/** |
|
|
* This function builds the search |
|
|
* block that lives above the results |
|
|
* |
|
|
* @return Container |
|
|
*/ |
|
|
function child_build_search_table() { |
|
|
user_error("DataList::child_build_search_table() - ". |
|
|
"child class must override this"); |
|
|
return NULL; |
|
|
} |
|
528 |
|
|
529 |
/** |
/** |
530 |
|
* This function builds the search |
531 |
|
* block that lives above the results |
532 |
|
* |
533 |
|
* @return Container |
534 |
|
*/ |
535 |
|
function child_build_search_table() { |
536 |
|
user_error("DataList::child_build_search_table() - ". |
537 |
|
"child class must override this"); |
538 |
|
return NULL; |
539 |
|
} |
540 |
|
|
541 |
|
/** |
542 |
* This function provides a way to automatically |
* This function provides a way to automatically |
543 |
* add javascript to this object. |
* add javascript to this object. |
544 |
* This function is meant to be extended by the |
* This function is meant to be extended by the |
572 |
$max_text_length=NULL) { |
$max_text_length=NULL) { |
573 |
|
|
574 |
$this->_columns[$label] = array("size" => $size, |
$this->_columns[$label] = array("size" => $size, |
575 |
"data_name" => $data_name, |
"data_name" => $data_name, |
576 |
"sortable" => $sortable, |
"sortable" => $sortable, |
577 |
"searchable" => $searchable, |
"searchable" => $searchable, |
578 |
"align" => $align, |
"align" => $align, |
579 |
"sortorder" => $sortorder, |
"sortorder" => $sortorder, |
580 |
"maxtextlength" => $max_text_length); |
"maxtextlength" => $max_text_length); |
581 |
$this->_num_headers++; |
$this->_num_headers++; |
582 |
|
|
583 |
$this->_check_datasource("add_header_item"); |
$this->_check_datasource("add_header_item"); |
584 |
$this->_datasource->add_column($label, $data_name, $sortable, |
$this->_datasource->add_column($label, $data_name, $sortable, |
585 |
$searchable, $sortorder); |
$searchable, $sortorder); |
586 |
} |
} |
587 |
|
|
588 |
|
|
595 |
* @param string $prefix - the prefix for all vars. |
* @param string $prefix - the prefix for all vars. |
596 |
*/ |
*/ |
597 |
function set_global_prefix($prefix) { |
function set_global_prefix($prefix) { |
598 |
$this->_global_prefix = $prefix; |
$this->_global_prefix = $prefix; |
599 |
$this->_offsetVar = $prefix . "offset"; |
//update all the vars used |
600 |
$this->_orderbyVar = $prefix . "orderby"; |
foreach ($this->_vars as $name => $value ) { |
601 |
$this->_reverseorderVar = $prefix . "reverseorder"; |
$this->_vars[$name] = $prefix.$value; |
602 |
$this->_numrowsVar = $prefix . "numrows"; |
} |
|
$this->_showallVar = $prefix . "showall"; |
|
|
$this->_search_fieldVar = $prefix . "search_field"; |
|
|
$this->_search_valueVar = $prefix . "search_value"; |
|
|
$this->_search_typeVar = $prefix . $this->_search_typeVar; |
|
|
$this->_simple_search_modifierVar = $prefix . $this->_simple_search_modifierVar; |
|
603 |
} |
} |
604 |
|
|
605 |
/** |
/** |
612 |
return $this->_global_prefix; |
return $this->_global_prefix; |
613 |
} |
} |
614 |
|
|
615 |
/** |
/** |
616 |
* This function is used to set the |
* This function is used to set the |
617 |
* DataListSource object for this instance |
* DataListSource object for this instance |
618 |
* |
* |
619 |
* @param DataListSource object |
* @param DataListSource object |
620 |
*/ |
*/ |
621 |
function set_data_source( $datasource ) { |
function set_data_source( $datasource ) { |
622 |
$this->_datasource = &$datasource; |
$this->_datasource = &$datasource; |
623 |
} |
} |
624 |
|
|
625 |
/** |
/** |
626 |
* Enable the search ability. |
* Enable the search ability. |
629 |
*/ |
*/ |
630 |
function search_enable( ) { |
function search_enable( ) { |
631 |
$this->_search_flag = TRUE; |
$this->_search_flag = TRUE; |
632 |
if (!$this->is_advanced_search_enabled()) { |
if ( !$this->is_advanced_search_enabled() ) { |
633 |
$this->set_search_type("simple"); |
$this->set_search_type("simple"); |
634 |
} |
} |
635 |
} |
} |
663 |
*/ |
*/ |
664 |
function advanced_search_enable() { |
function advanced_search_enable() { |
665 |
$this->_advanced_search_flag = TRUE; |
$this->_advanced_search_flag = TRUE; |
666 |
if (!$this->is_search_enabled()) { |
if ( !$this->is_search_enabled() ) { |
667 |
$this->set_search_type("advanced"); |
$this->set_search_type("advanced"); |
668 |
} |
} |
669 |
} |
} |
709 |
* @param string |
* @param string |
710 |
*/ |
*/ |
711 |
function set_simple_search_modifier( $modifier = SEARCH_ALL ) { |
function set_simple_search_modifier( $modifier = SEARCH_ALL ) { |
712 |
if ($modifier == 0) { |
if ( $modifier == 0 ) { |
713 |
$this->_simple_search_modifier = SEARCH_BEGINS_WITH | |
$this->_simple_search_modifier = SEARCH_BEGINS_WITH | |
714 |
SEARCH_CONTAINS | |
SEARCH_CONTAINS | |
715 |
SEARCH_EXACT | |
SEARCH_EXACT | |
748 |
return $this->_default_rows_per_page; |
return $this->_default_rows_per_page; |
749 |
} |
} |
750 |
|
|
751 |
|
/** |
752 |
|
* This returns the Maximum # of rows to |
753 |
|
* display when in expand mode |
754 |
|
* |
755 |
|
* @return int |
756 |
|
*/ |
757 |
|
function get_max_rows() { |
758 |
|
return $this->_max_rows; |
759 |
|
} |
760 |
|
|
761 |
/** |
/** |
762 |
* This function sets the save variables |
* This sets the maximum # of rows to |
763 |
* that the user/child wants to automatically |
* display when in expand mode |
764 |
* propogate |
* |
765 |
|
* @param int - new # of maximum rows |
766 |
|
* to display when in 'expand' mode |
767 |
* |
* |
|
* @param array - name=>value pairs of the data |
|
|
* that they want to propogate |
|
768 |
*/ |
*/ |
769 |
function set_save_vars( $vars ) { |
function set_max_rows( $max ) { |
770 |
$this->_save_vars = $vars; |
$this->_max_rows = $max; |
771 |
} |
} |
772 |
|
|
|
/** |
|
|
* This returns the Maximum # of rows to |
|
|
* display when in expand mode |
|
|
* |
|
|
* @return int |
|
|
*/ |
|
|
function get_max_rows() { |
|
|
return $this->_max_rows; |
|
|
} |
|
|
|
|
|
/** |
|
|
* This sets the maximum # of rows to |
|
|
* display when in expand mode |
|
|
* |
|
|
* @param int - new # of maximum rows |
|
|
* to display when in 'expand' mode |
|
|
* |
|
|
*/ |
|
|
function set_max_rows( $max ) { |
|
|
$this->_max_rows = $max; |
|
|
} |
|
773 |
|
|
774 |
|
|
775 |
|
/** |
776 |
|
* This function is used to set up any |
777 |
|
* data that needs to be munged before the |
778 |
|
* data is fetched from the DataListSource |
779 |
|
* |
780 |
|
*/ |
781 |
|
function data_prefetch() { |
782 |
|
$this->_check_datasource("data_prefetch"); |
783 |
|
|
784 |
|
if ( $this->showall() ) { |
785 |
|
$this->set_default_num_rows( $this->get_max_rows() ); |
786 |
|
$this->set_numrows( $this->get_max_rows() ); |
787 |
|
} |
788 |
|
|
789 |
/** |
$limit = $this->numrows(); |
790 |
* This function is used to set up any |
$this->_datasource->query($this->offset(), $limit, |
791 |
* data that needs to be munged before the |
$this->orderby(), $this->reverseorder(), |
792 |
* data is fetched from the DataListSource |
$this->search_field(), $this->search_value(), |
793 |
* |
$this->simple_search_modifier_value(), |
794 |
*/ |
$this->search_type() ); |
795 |
function data_prefetch() { |
} |
|
$this->_check_datasource("data_prefetch"); |
|
|
|
|
|
if ($this->showall()) { |
|
|
$this->set_default_num_rows( $this->get_max_rows() ); |
|
|
$this->set_numrows( $this->get_max_rows() ); |
|
|
} |
|
|
|
|
|
$limit = $this->numrows(); |
|
|
$this->_datasource->query($this->offset(), $limit, |
|
|
$this->orderby(), $this->reverseorder(), |
|
|
$this->search_field(), $this->search_value(), |
|
|
$this->simple_search_modifier_value(), |
|
|
$this->search_type() ); |
|
|
} |
|
796 |
|
|
797 |
|
|
798 |
|
|
804 |
$temp_headers = array(); |
$temp_headers = array(); |
805 |
|
|
806 |
foreach( $this->_columns as $col_name => $data ) { |
foreach( $this->_columns as $col_name => $data ) { |
807 |
if ($data["sortorder"] == "reverse") { |
if ( $data["sortorder"] == "reverse" ) { |
808 |
$data["reverseorder"] = "true"; |
$data["reverseorder"] = "true"; |
809 |
} |
} else { |
|
else { |
|
810 |
$data["reverseorder"] = "false"; |
$data["reverseorder"] = "false"; |
811 |
} |
} |
812 |
$temp_headers[$col_name] = $data; |
$temp_headers[$col_name] = $data; |
816 |
|
|
817 |
|
|
818 |
|
|
819 |
/** |
/** |
820 |
* general DataListSource object checker. |
* general DataListSource object checker. |
821 |
* |
* |
822 |
*/ |
*/ |
823 |
function _check_datasource($function_name) { |
function _check_datasource($function_name) { |
824 |
if (!is_object($this->_datasource)) { |
if ( !is_object($this->_datasource) ) { |
825 |
user_error("DataList::".$function_name."() - DataListSource object is not set"); |
user_error("DataList::".$function_name."() - DataListSource object is not set"); |
826 |
exit; |
exit; |
827 |
} |
} |
828 |
} |
} |
829 |
|
|
830 |
|
|
831 |
/*********************************************/ |
/*********************************************/ |
832 |
/* REQUEST VARIABLE SECTION */ |
/* REQUEST VARIABLE SECTION */ |
833 |
/*********************************************/ |
/*********************************************/ |
834 |
|
|
835 |
|
|
836 |
|
|
837 |
/** |
/** |
838 |
|
* Function used to get the current |
839 |
|
* value of one of the control vars |
840 |
|
* for this class |
841 |
|
* |
842 |
|
* @param string - the name we want to get |
843 |
|
* @param mixed - the default value if not set |
844 |
|
* @return the current value or default if not set |
845 |
|
*/ |
846 |
|
function _get($name, $default_value=NULL) { |
847 |
|
if ( !$_REQUEST[$this->_vars[$name]] ) { |
848 |
|
$this->_set($name, $default_value); |
849 |
|
} |
850 |
|
//ddd( $name . " : ". $_REQUEST[$this->_vars[$name]] ); |
851 |
|
return $_REQUEST[$this->_vars[$name]]; |
852 |
|
} |
853 |
|
|
854 |
|
/** |
855 |
|
* This function is used to set the |
856 |
|
* value of the control var |
857 |
|
* |
858 |
|
* @param string - the name we want to get |
859 |
|
* @param mixed - the new value for it. |
860 |
|
*/ |
861 |
|
function _set($name, $value) { |
862 |
|
$_REQUEST[$this->_vars[$name]] = $value; |
863 |
|
} |
864 |
|
|
865 |
|
/** |
866 |
* This function returns the current value |
* This function returns the current value |
867 |
* of the offset variable. This is an offset |
* of the offset variable. This is an offset |
868 |
* into the query return data set. |
* into the query return data set. |
870 |
* @return int - the current value. |
* @return int - the current value. |
871 |
*/ |
*/ |
872 |
function offset() { |
function offset() { |
873 |
if (!$_REQUEST[$this->_offsetVar]) { |
return(int)$this->_get("offsetVar", 0); |
|
$this->set_offset(0); |
|
|
} |
|
|
return (int)$_REQUEST[$this->_offsetVar]; |
|
874 |
} |
} |
875 |
|
|
876 |
/** |
/** |
877 |
* This function is used to set/change |
* This function is used to set/change |
878 |
* the offset for this list. |
* the offset for this list. |
879 |
* |
* |
880 |
* @param int - the new offset. |
* @param int - the new offset. |
881 |
*/ |
*/ |
882 |
function set_offset($new_offset) { |
function set_offset($new_offset) { |
883 |
$_REQUEST[$this->_offsetVar] = $new_offset; |
$this->_set("offsetVar", $new_offset); |
884 |
} |
} |
885 |
|
|
886 |
/** |
/** |
887 |
* This function returns the value of the |
* This function returns the value of the |
888 |
* current orderby variable. |
* current orderby variable. |
889 |
* |
* |
890 |
* @return string. |
* @return string. |
891 |
*/ |
*/ |
892 |
function orderby() { |
function orderby() { |
893 |
if (!$_REQUEST[$this->_orderbyVar]) { |
return $this->_get("orderbyVar", $this->_default_orderby); |
|
$_REQUEST[$this->_orderbyVar] = $this->_default_orderby; |
|
|
} |
|
|
|
|
|
return $_REQUEST[$this->_orderbyVar]; |
|
894 |
} |
} |
895 |
|
|
896 |
/** |
/** |
897 |
* This builds a query string var for the |
* This builds a query string var for the |
898 |
* orderby value. |
* orderby value. |
899 |
* |
* |
900 |
* @return string - "orderby=(thevalue)" |
* @return string - "orderby=(thevalue)" |
901 |
*/ |
*/ |
902 |
function build_orderby_querystring() { |
function build_orderby_querystring() { |
903 |
$str = $this->_orderbyVar."=".$this->orderby(); |
$str = $this->_vars["orderbyVar"]."=".urlencode($this->orderby()); |
904 |
return $str; |
return $str; |
905 |
} |
} |
906 |
|
|
911 |
* @return string. |
* @return string. |
912 |
*/ |
*/ |
913 |
function reverseorder() { |
function reverseorder() { |
914 |
if (!$_REQUEST[$this->_reverseorderVar]) { |
return $this->_get("reverseorderVar", $this->_default_reverseorder); |
|
$this->set_reverseorder($this->_default_reverseorder); |
|
|
} |
|
|
return $_REQUEST[$this->_reverseorderVar]; |
|
915 |
} |
} |
916 |
|
|
917 |
/** |
/** |
921 |
* @param string - the new value. |
* @param string - the new value. |
922 |
*/ |
*/ |
923 |
function set_reverseorder($new_value) { |
function set_reverseorder($new_value) { |
924 |
$_REQUEST[$this->_reverseorderVar] = $new_value; |
$this->_set("reverseorderVar", $new_value); |
925 |
} |
} |
926 |
|
|
927 |
/** |
/** |
928 |
* This builds a query string var for the |
* This builds a query string var for the |
929 |
* reverseorder value. |
* reverseorder value. |
930 |
* |
* |
931 |
* @return string - "orderby=(thevalue)" |
* @return string - "orderby=(thevalue)" |
932 |
*/ |
*/ |
933 |
function build_reverseorder_querystring() { |
function build_reverseorder_querystring() { |
934 |
$str = $this->_reverseorderVar."=".$this->reverseorder(); |
$str = $this->_vars["reverseorderVar"]."=".urlencode($this->reverseorder()); |
935 |
return $str; |
return $str; |
936 |
} |
} |
937 |
|
|
942 |
* @return int - the number of rows |
* @return int - the number of rows |
943 |
*/ |
*/ |
944 |
function numrows() { |
function numrows() { |
945 |
if (!$_REQUEST[$this->_numrowsVar]) { |
return(int)$this->_get("numrowsVar", $this->_default_rows_per_page); |
|
$this->set_numrows($this->_default_rows_per_page); |
|
|
} |
|
|
return (int) $_REQUEST[$this->_numrowsVar]; |
|
946 |
} |
} |
947 |
|
|
948 |
/** |
/** |
952 |
* @param int - the # of rows |
* @param int - the # of rows |
953 |
*/ |
*/ |
954 |
function set_numrows($new_numrows) { |
function set_numrows($new_numrows) { |
955 |
$_REQUEST[$this->_numrowsVar] = $new_numrows; |
$this->_set("numrowsVar", $new_numrows); |
956 |
} |
} |
957 |
|
|
958 |
/** |
/** |
962 |
* @return string |
* @return string |
963 |
*/ |
*/ |
964 |
function search_field() { |
function search_field() { |
965 |
if (!$_REQUEST[$this->_search_fieldVar]) { |
return $this->_get("search_fieldVar", ''); |
|
$_REQUEST[$this->_search_fieldVar] = ''; |
|
|
} |
|
|
return $_REQUEST[$this->_search_fieldVar]; |
|
966 |
} |
} |
967 |
|
|
968 |
/** |
/** |
969 |
* This builds a query string var for the |
* This builds a query string var for the |
970 |
* searchfield value. |
* searchfield value. |
971 |
* |
* |
972 |
* @return string - "orderby=(thevalue)" |
* @return string - "orderby=(thevalue)" |
973 |
*/ |
*/ |
974 |
function build_searchfield_querystring() { |
function build_searchfield_querystring() { |
975 |
$str = $this->_search_fieldVar."=".$this->searchfield(); |
$str = $this->_vars["search_fieldVar"]."=".urlencode($this->searchfield()); |
976 |
return $str; |
return $str; |
977 |
} |
} |
978 |
|
|
983 |
* @return string |
* @return string |
984 |
*/ |
*/ |
985 |
function search_value() { |
function search_value() { |
986 |
if (!$_REQUEST[$this->_search_valueVar]) { |
return $this->_get("search_valueVar", ''); |
|
$_REQUEST[$this->_search_valueVar] = ''; |
|
|
} |
|
|
return $_REQUEST[$this->_search_valueVar]; |
|
987 |
} |
} |
988 |
|
|
989 |
/** |
/** |
990 |
* This builds a query string var for the |
* This builds a query string var for the |
991 |
* searchfield value. |
* searchfield value. |
992 |
* |
* |
993 |
* @return string - "orderby=(thevalue)" |
* @return string - "orderby=(thevalue)" |
994 |
*/ |
*/ |
995 |
function build_searchvalue_querystring() { |
function build_searchvalue_querystring() { |
996 |
$str = $this->_search_valueVar."=".$this->search_value(); |
$str = $this->_vars["search_valueVar"]."=".urlencode($this->search_value()); |
997 |
return $str; |
return $str; |
998 |
} |
} |
999 |
|
|
1004 |
* @return string |
* @return string |
1005 |
*/ |
*/ |
1006 |
function simple_search_modifier_value() { |
function simple_search_modifier_value() { |
1007 |
if (!$_REQUEST[$this->_simple_search_modifierVar]) { |
return $this->_get("simple_search_modifierVar", ''); |
|
$_REQUEST[$this->_simple_search_modifierVar] = ''; |
|
|
} |
|
|
return $_REQUEST[$this->_simple_search_modifierVar]; |
|
1008 |
} |
} |
1009 |
|
|
1010 |
|
|
1014 |
* @return string |
* @return string |
1015 |
*/ |
*/ |
1016 |
function search_type() { |
function search_type() { |
1017 |
if (!$_REQUEST[$this->_search_typeVar]) { |
return $this->_get("search_typeVar", "simple"); |
|
$_REQUEST[$this->_search_typeVar] = "simple"; |
|
|
} |
|
|
return $_REQUEST[$this->_search_typeVar]; |
|
1018 |
} |
} |
1019 |
|
|
1020 |
/** |
/** |
1024 |
* "simple" or "advanced" |
* "simple" or "advanced" |
1025 |
*/ |
*/ |
1026 |
function set_search_type($type) { |
function set_search_type($type) { |
1027 |
$_REQUEST[$this->_search_typeVar] = $type; |
$this->_set("search_typeVar", $type); |
1028 |
} |
} |
1029 |
|
|
1030 |
|
|
1036 |
* @return string - the current value |
* @return string - the current value |
1037 |
*/ |
*/ |
1038 |
function showall() { |
function showall() { |
1039 |
if (!$_REQUEST[$this->_showallVar]) { |
return(int)$this->_get("showallVar", 0); |
|
$_REQUEST[$this->_showallVar] = 0; |
|
|
} |
|
|
return (int) $_REQUEST[$this->_showallVar]; |
|
1040 |
} |
} |
1041 |
|
|
1042 |
/** |
/** |
1055 |
function build_column_item($row_data, $col_name) { |
function build_column_item($row_data, $col_name) { |
1056 |
$key = $this->_columns[$col_name]["data_name"]; |
$key = $this->_columns[$col_name]["data_name"]; |
1057 |
|
|
1058 |
if ($row_data[$key] == '') { |
if ( $row_data[$key] == '' ) { |
1059 |
return " "; |
return " "; |
1060 |
} else { |
} else { |
1061 |
return $this->_filter_column_string($row_data[$key]); |
return $this->_filter_column_string($row_data[$key]); |
1073 |
* @return string the cleaned/filtered data |
* @return string the cleaned/filtered data |
1074 |
*/ |
*/ |
1075 |
function _filter_column_string($data) { |
function _filter_column_string($data) { |
1076 |
return htmlspecialchars(trim($data)); |
// WAS: return htmlspecialchars(trim($data)); |
1077 |
|
|
1078 |
|
// NEW: require 'flib/Application/i18n/TextEncode.php' |
1079 |
|
// this will do a 'htmlentities' RECURSIVE on each item |
1080 |
|
$encoder = new Data_Encode($data); |
1081 |
|
$encoder->toHTML(); |
1082 |
|
return $data; |
1083 |
} |
} |
1084 |
|
|
1085 |
|
|
1086 |
/*******************************************/ |
/*******************************************/ |
1087 |
/* FORM VARIABLES SECTION */ |
/* FORM VARIABLES SECTION */ |
1088 |
/*******************************************/ |
/*******************************************/ |
1089 |
|
|
1090 |
/** |
/** |
1091 |
* This function is used to set the |
* This function is used to set the |
1092 |
* form name |
* form name |
1093 |
* |
* |
1126 |
function get_form_target() { |
function get_form_target() { |
1127 |
return $this->_form_attributes["target"]; |
return $this->_form_attributes["target"]; |
1128 |
} |
} |
1129 |
|
|
1130 |
/** |
/** |
1131 |
* This function is used to set the |
* This function is used to set the |
1132 |
* form method |
* form method |
1134 |
* @param string (POST or GET) |
* @param string (POST or GET) |
1135 |
*/ |
*/ |
1136 |
function set_form_method($method) { |
function set_form_method($method) { |
1137 |
if ($method != "GET" && $method != "POST") { |
if ( $method != "GET" && $method != "POST" ) { |
1138 |
user_error("DataList::set_form_method() - INVALID Form method ".$method); |
user_error("DataList::set_form_method() - INVALID Form method ".$method); |
1139 |
} else { |
} else { |
1140 |
$this->_form_attributes["method"] = $method; |
$this->_form_attributes["method"] = $method; |
1141 |
} |
} |
1142 |
} |
} |
1143 |
|
|
1144 |
/** |
/** |
1151 |
return $this->_form_attributes["method"]; |
return $this->_form_attributes["method"]; |
1152 |
} |
} |
1153 |
|
|
1154 |
/** |
/** |
1155 |
* Sets the form action |
* Sets the form action |
1156 |
* |
* |
1157 |
* @param string |
* @param string |
1158 |
*/ |
*/ |
1159 |
function set_form_action($action) { |
function set_form_action($action) { |
1160 |
$this->_form_attributes["action"] = $action; |
$this->_form_attributes["action"] = $action; |
1161 |
} |
} |
1162 |
|
|
1163 |
/** |
/** |
1164 |
* This function is used to get |
* This function is used to get |
1165 |
* the form action |
* the form action |
1166 |
* |
* |
1189 |
} |
} |
1190 |
|
|
1191 |
/** |
/** |
1192 |
* This function is used to set the |
* This function is used to set the |
1193 |
* message displayed when no data is found |
* message displayed when no data is found |
1194 |
* |
* |
1195 |
* @param string |
* @param string |
1196 |
*/ |
*/ |
1197 |
function set_not_found_message($mesg) { |
function set_not_found_message($mesg) { |
1198 |
$this->_check_datasource("set_not_found_message"); |
$this->_check_datasource("set_not_found_message"); |
1199 |
$this->_datasource->set_not_found_message($mesg); |
$this->_datasource->set_not_found_message($mesg); |
1200 |
} |
} |
1201 |
|
|
1202 |
|
|
1203 |
/** |
/** |
1204 |
* This function is used to set the value |
* This function is used to set the value |
1205 |
* of the _show_results_flag |
* of the _show_results_flag |
1206 |
* |
* |
1207 |
* @param boolean - TRUE to show the results |
* @param boolean - TRUE to show the results |
1208 |
*/ |
*/ |
1209 |
function set_show_results( $flag=TRUE ) { |
function set_show_results( $flag=TRUE ) { |
1210 |
$this->_show_results_flag = $flag; |
$this->_show_results_flag = $flag; |
1211 |
} |
} |
1212 |
|
|
1213 |
|
|
1214 |
/** |
/** |
1215 |
* This function is used to let render() know |
* This function is used to let render() know |
1216 |
* that we should show the results or not. |
* that we should show the results or not. |
1217 |
* |
* |
1218 |
* @return boolean |
* @return boolean |
1219 |
*/ |
*/ |
1220 |
function _show_results() { |
function _show_results() { |
1221 |
return $this->_show_results_flag; |
return $this->_show_results_flag; |
1222 |
} |
} |
1223 |
|
|
1224 |
/** |
/** |
1225 |
* this method builds some hidden |
* this method builds some hidden |
1226 |
* form fields to automatically |
* form fields to automatically |
1227 |
* be placed inside the form. |
* be placed inside the form. |
1228 |
|
* |
1229 |
|
* This method returns a list of |
1230 |
|
* hidden form fields if we are a POST. |
1231 |
|
* It returns a portion of a query string |
1232 |
|
* If we are a GET. |
1233 |
* |
* |
1234 |
* @return ContainerWidget object. |
* @return mixed depending on form method |
1235 |
*/ |
*/ |
1236 |
function _build_save_vars() { |
function _build_save_vars() { |
1237 |
$container = container(); |
$container = container(); |
1241 |
return $container; |
return $container; |
1242 |
} |
} |
1243 |
|
|
1244 |
/** |
/** |
1245 |
* This function sets the save variables |
* This function sets the save variables |
1246 |
* that the user/child wants to automatically |
* that the user/child wants to automatically |
1247 |
* propogate |
* propogate |
1254 |
} |
} |
1255 |
|
|
1256 |
/** |
/** |
1257 |
|
* This function builds the list of |
1258 |
|
* default hidden form vars for when |
1259 |
|
* the datalist is being rendered |
1260 |
|
* as a POST |
1261 |
|
* |
1262 |
|
* @return Container |
1263 |
|
*/ |
1264 |
|
function _build_default_vars() { |
1265 |
|
// the navigation links will set the offset anyway |
1266 |
|
$container = container(form_hidden($this->_vars["offsetVar"], $this->offset()), |
1267 |
|
form_hidden($this->_vars["orderbyVar"], $this->orderby()), |
1268 |
|
form_hidden($this->_vars["reverseorderVar"], $this->reverseorder()), |
1269 |
|
form_hidden($this->_vars["showallVar"], $this->showall())); |
1270 |
|
return $container; |
1271 |
|
} |
1272 |
|
|
1273 |
|
|
1274 |
|
|
1275 |
|
/** |
1276 |
* This builds the base url used |
* This builds the base url used |
1277 |
* by the column headers as well |
* by the column headers as well |
1278 |
* as the page tool links. |
* as the page tool links. |
1286 |
|
|
1287 |
$url = $_SERVER["PHP_SELF"]."?"; |
$url = $_SERVER["PHP_SELF"]."?"; |
1288 |
|
|
1289 |
if ($this->get_form_method() == "POST") { |
if ( $this->get_form_method() == "POST" ) { |
1290 |
return $url; |
return $url; |
1291 |
} |
} |
1292 |
|
|
1293 |
$vars = array_merge($_POST, $_GET); |
$vars = array_merge($_POST, $_GET); |
1294 |
//request method independant access to |
//request method independant access to |
1295 |
//browser variables |
//browser variables |
1296 |
if (count($vars)) { |
if ( count($vars) ) { |
1297 |
//walk through all of the get vars |
//walk through all of the get vars |
1298 |
//and add them to the url to save them. |
//and add them to the url to save them. |
1299 |
foreach($vars as $name => $value) { |
foreach($vars as $name => $value) { |
1300 |
|
|
1301 |
if ($name != $this->_offsetVar && |
if ( $name != $this->_vars["offsetVar"] && |
1302 |
$name != $this->_orderbyVar && |
$name != $this->_vars["orderbyVar"] && |
1303 |
$name != $this->_reverseorderVar && |
$name != $this->_vars["reverseorderVar"] && |
1304 |
$name != $this->_search_valueVar |
$name != $this->_vars["search_valueVar"] |
1305 |
) { |
) { |
1306 |
if (is_array($value)) { |
if ( is_array($value) ) { |
1307 |
$url .= $name."[]=".implode("&".$name."[]=",$value)."&"; |
$url .= $name."[]=".implode("&".$name."[]=",$value)."&"; |
1308 |
} else { |
} else { |
1309 |
$url .= $name."=".urlencode(stripslashes($value))."&"; |
$url .= $name."=".urlencode(stripslashes($value))."&"; |
1310 |
} |
} |
1311 |
} |
} |
1312 |
} |
} |
1313 |
} |
} |
1314 |
|
|
1315 |
return $url; |
return htmlentities($url); |
1316 |
} |
} |
1317 |
|
|
1318 |
/** |
/** |
1319 |
* This function builds the 'tool' images that |
* This function builds the 'tool' images that |
1320 |
* allow you to walk through the data list itself. |
* allow you to walk through the data list itself. |
1321 |
* It provides image links for |
* It provides image links for |
1322 |
* first - go to the first page in the data list |
* first - go to the first page in the data list |
1323 |
* prev - go to the previous page in the data list |
* prev - go to the previous page in the data list |
1324 |
* next - go to the next page in the data list |
* next - go to the next page in the data list |
1325 |
* last - go to the last page in the data list |
* last - go to the last page in the data list |
1326 |
* all - show the rest of the list from the current offset |
* all - show the rest of the list from the current offset |
1327 |
* |
* |
1328 |
* @param string - which tool image to build |
* @param string - which tool image to build |
1329 |
* @return Object |
* @return Object |
1330 |
*/ |
*/ |
1331 |
function build_tool_link( $which ) { |
function build_tool_link( $which ) { |
1332 |
$num_pages = $this->get_num_pages(); |
$num_pages = $this->get_num_pages(); |
1333 |
$cur_page = $this->get_current_page(); |
$cur_page = $this->get_current_page(); |
1334 |
$last_page = $this->get_last_page(); |
$last_page = $this->get_last_page(); |
1335 |
|
|
1336 |
$image_path = $this->get_image_path(); |
$image_path = $this->get_image_path(); |
1337 |
switch ($which) { |
switch ( $which ) { |
1338 |
|
|
1339 |
case "first": |
case "first": |
1340 |
$rows_string = "First ".$this->get_default_num_rows()." Rows"; |
$rows_string = "First ".$this->get_default_num_rows()." Rows"; |
1341 |
if ($this->offset() <= 0) { |
if ( $this->offset() <= 0 ) { |
1342 |
$obj = html_img($image_path."/first_group_button_inactive.gif", |
$obj = html_img($image_path."/first_group_button_inactive.gif", |
1343 |
'','',0,$rows_string, NULL, $rows_string); |
'','',0,$rows_string, NULL, $rows_string); |
1344 |
} else { |
} else { |
1345 |
$url = $this->_build_tool_url(0); |
$url = $this->_build_tool_url(0); |
1346 |
$obj = html_img_href($url, $image_path."/first_group_button.gif", |
$obj = html_img_href($url, $image_path."/first_group_button.gif", |
1347 |
'','',0, $rows_string, NULL, NULL, $rows_string); |
'','',0, $rows_string, NULL, NULL, $rows_string); |
1348 |
|
} |
1349 |
|
break; |
1350 |
|
|
1351 |
|
case "prev": |
1352 |
|
$rows_string = "Previous ".$this->get_default_num_rows()." Rows"; |
1353 |
|
if ( $this->offset() <= 0 ) { |
1354 |
|
$obj = html_img($image_path."/prev_group_button_inactive.gif", |
1355 |
|
'','',0,$rows_string, NULL, $rows_string); |
1356 |
|
} else { |
1357 |
|
$offset = $this->offset() - $this->numrows(); |
1358 |
|
if ( $offset < 0 ) { |
1359 |
|
$offset = 0; |
1360 |
|
} |
1361 |
|
$url = $this->_build_tool_url($offset); |
1362 |
|
$obj = html_img_href($url, $image_path."/prev_group_button.gif", |
1363 |
|
'','',0, $rows_string, NULL, NULL, $rows_string); |
1364 |
|
} |
1365 |
|
break; |
1366 |
|
|
1367 |
|
case "next": |
1368 |
|
$rows_string = "Next ".$this->get_default_num_rows()." Rows"; |
1369 |
|
if ( ($num_pages == 1) || ($cur_page == $last_page) ) { |
1370 |
|
$obj = html_img($image_path."/next_group_button_inactive.gif", |
1371 |
|
'','',0, $rows_string, NULL, $rows_string); |
1372 |
|
} else { |
1373 |
|
$offset = $this->offset() + $this->numrows(); |
1374 |
|
$url = $this->_build_tool_url($offset); |
1375 |
|
$obj = html_img_href($url, $image_path."/next_group_button.gif", |
1376 |
|
'','',0, $rows_string, NULL, NULL, $rows_string); |
1377 |
|
} |
1378 |
|
break; |
1379 |
|
|
1380 |
|
case "last": |
1381 |
|
$rows_string = "Last ".$this->get_default_num_rows()." Rows"; |
1382 |
|
if ( ($num_pages == 1) || ($cur_page == $last_page) ) { |
1383 |
|
$obj = html_img($image_path."/last_group_button_inactive.gif", |
1384 |
|
'','',0, $rows_string, NULL, $rows_string); |
1385 |
|
} else { |
1386 |
|
$offset = (int)(($num_pages - 1) * $this->numrows()); |
1387 |
|
$url = $this->_build_tool_url($offset); |
1388 |
|
$obj = html_img_href($url, $image_path."/last_group_button.gif", |
1389 |
|
'','',0, $rows_string, NULL, NULL, $rows_string); |
1390 |
|
} |
1391 |
|
break; |
1392 |
|
|
1393 |
|
case "all": |
1394 |
|
$offset = $this->offset(); |
1395 |
|
if ( $this->showall() ) { |
1396 |
|
$url = $this->_build_tool_url($offset, TRUE, 0); |
1397 |
|
$obj = html_img_href($url, $image_path."/close_group_button.gif", |
1398 |
|
'','',0,"Collapse Rows", NULL, NULL, "Collapse Rows"); |
1399 |
|
} else { |
1400 |
|
if ( ($num_pages == 1) ) { |
1401 |
|
$obj = html_img($image_path."/expand_group_button_inactive.gif", |
1402 |
|
'','',0, "Expand Rows", NULL, "Expand Rows"); |
1403 |
|
} else { |
1404 |
|
$url = $this->_build_tool_url($offset, TRUE, 1); |
1405 |
|
$obj = html_img_href($url, $image_path."/expand_group_button.gif", |
1406 |
|
'','',0,"Expand Rows", NULL, NULL, "Expand Rows"); |
1407 |
|
} |
1408 |
} |
} |
1409 |
break; |
//so we don't save it into the mozilla navigation bar links |
1410 |
|
unset($url); |
1411 |
|
break; |
1412 |
|
} |
1413 |
|
|
1414 |
|
if ( $url ) { |
1415 |
|
$this->_save_mozilla_nav_link($which, $url); |
1416 |
|
} |
1417 |
|
|
1418 |
case "prev": |
return $obj; |
1419 |
$rows_string = "Previous ".$this->get_default_num_rows()." Rows"; |
} |
1420 |
if ($this->offset() <= 0) { |
|
1421 |
$obj = html_img($image_path."/prev_group_button_inactive.gif", |
/** |
1422 |
'','',0,$rows_string, NULL, $rows_string); |
* This function is used to build the url |
1423 |
} else { |
* for a tool link. |
1424 |
$offset = $this->offset() - $this->numrows(); |
* (first, prev, next, last, all) |
1425 |
if ($offset < 0) { |
* |
1426 |
$offset = 0; |
* @param int - the offset for the link |
1427 |
} |
* @param boolean - add the showall value to the url |
1428 |
$url = $this->_build_tool_url($offset); |
* @param int - the showall value to use if the flag is on |
1429 |
$obj = html_img_href($url, $image_path."/prev_group_button.gif", |
* |
1430 |
'','',0, $rows_string, NULL, NULL, $rows_string); |
* @return string |
1431 |
} |
*/ |
1432 |
break; |
function _build_tool_url($offset, $showall_flag=FALSE, $showall_value=0) { |
1433 |
|
if ( $this->get_form_method() == "POST" ) { |
1434 |
case "next": |
$form_name = $this->get_form_name(); |
1435 |
$rows_string = "Next ".$this->get_default_num_rows()." Rows"; |
$url = "javascript: document.".$form_name; |
1436 |
if (($num_pages == 1) || ($cur_page == $last_page)) { |
$url .= ".".$this->_vars["offsetVar"].".value='".$offset."';"; |
1437 |
$obj = html_img($image_path."/next_group_button_inactive.gif", |
|
1438 |
'','',0, $rows_string, NULL, $rows_string); |
//add the showall variable to the post |
1439 |
} else { |
if ( $showall_flag ) { |
1440 |
$offset = $this->offset() + $this->numrows(); |
$form_field = $this->_vars["showallVar"]; |
|
$url = $this->_build_tool_url($offset); |
|
|
$obj = html_img_href($url, $image_path."/next_group_button.gif", |
|
|
'','',0, $rows_string, NULL, NULL, $rows_string); |
|
|
} |
|
|
break; |
|
|
|
|
|
case "last": |
|
|
$rows_string = "Last ".$this->get_default_num_rows()." Rows"; |
|
|
if (($num_pages == 1) || ($cur_page == $last_page)) { |
|
|
$obj = html_img($image_path."/last_group_button_inactive.gif", |
|
|
'','',0, $rows_string, NULL, $rows_string); |
|
|
} else { |
|
|
$offset = (int)(($num_pages - 1) * $this->numrows()); |
|
|
$url = $this->_build_tool_url($offset); |
|
|
$obj = html_img_href($url, $image_path."/last_group_button.gif", |
|
|
'','',0, $rows_string, NULL, NULL, $rows_string); |
|
|
} |
|
|
break; |
|
|
|
|
|
case "all": |
|
|
$offset = $this->offset(); |
|
|
if ($this->showall()) { |
|
|
$url = $this->_build_tool_url($offset, TRUE, 0); |
|
|
$obj = html_img_href($url, $image_path."/close_group_button.gif", |
|
|
'','',0,"Collapse Rows", NULL, NULL, "Collapse Rows"); |
|
|
} else { |
|
|
if (($num_pages == 1)) { |
|
|
$obj = html_img($image_path."/expand_group_button_inactive.gif", |
|
|
'','',0, "Expand Rows", NULL, "Expand Rows"); |
|
|
} else { |
|
|
$url = $this->_build_tool_url($offset, TRUE, 1); |
|
|
$obj = html_img_href($url, $image_path."/expand_group_button.gif", |
|
|
'','',0,"Expand Rows", NULL, NULL, "Expand Rows"); |
|
|
} |
|
|
} |
|
|
//so we don't save it into the mozilla navigation bar links |
|
|
unset($url); |
|
|
break; |
|
|
} |
|
|
|
|
|
if ($url) { |
|
|
$this->_save_mozilla_nav_link($which, $url); |
|
|
} |
|
|
|
|
|
return $obj; |
|
|
} |
|
|
|
|
|
/** |
|
|
* This function is used to build the url |
|
|
* for a tool link. |
|
|
* (first, prev, next, last, all) |
|
|
* |
|
|
* @param int - the offset for the link |
|
|
* @param boolean - add the showall value to the url |
|
|
* @param int - the showall value to use if the flag is on |
|
|
* |
|
|
* @return string |
|
|
*/ |
|
|
function _build_tool_url($offset, $showall_flag=FALSE, $showall_value=0) { |
|
|
if ($this->get_form_method() == "POST") { |
|
|
$form_name = $this->get_form_name(); |
|
|
$url = "javascript: document.".$form_name; |
|
|
$url .= ".".$this->_offsetVar.".value='".$offset."';"; |
|
|
|
|
|
//add the showall variable to the post |
|
|
if ($showall_flag) { |
|
|
$form_field = $this->_showallVar; |
|
1441 |
$url .= "document.".$form_name."."; |
$url .= "document.".$form_name."."; |
1442 |
$url .= $form_field.".value='".$showall_value."';"; |
$url .= $form_field.".value='".$showall_value."';"; |
1443 |
} |
} |
1444 |
|
|
1445 |
$url .= "document.".$form_name.".submit();"; |
$url .= "document.".$form_name.".submit();"; |
1446 |
} else { |
} else { |
1447 |
$url = $this->build_base_url(); |
$url = $this->build_base_url(); |
1448 |
$url .= $this->build_state_vars_query_string($offset, $showall_flag, |
$url .= $this->build_state_vars_query_string($offset, $showall_flag, |
1449 |
$showall_value); |
$showall_value); |
1450 |
} |
} |
1451 |
return $url; |
return $url; |
1452 |
} |
} |
1453 |
|
|
1454 |
/** |
/** |
1455 |
* this function is used to build a sub query string |
* this function is used to build a sub query string |
1460 |
* @return string - name=value& pairs |
* @return string - name=value& pairs |
1461 |
*/ |
*/ |
1462 |
function build_state_vars_query_string($offset, $showall_flag=FALSE, |
function build_state_vars_query_string($offset, $showall_flag=FALSE, |
1463 |
$showall_value=0) { |
$showall_value=0) { |
1464 |
$str = ""; |
$str = ""; |
1465 |
|
|
1466 |
$str .= $this->_offsetVar."=".urlencode($offset); |
$str .= $this->_vars["offsetVar"]."=".urlencode($offset); |
1467 |
$str .= "&".$this->_orderbyVar."=".urlencode($this->orderby()); |
$str .= "&".$this->_vars["orderbyVar"]."=".urlencode($this->orderby()); |
1468 |
$str .= "&".$this->_reverseorderVar."=".urlencode($this->reverseorder()); |
$str .= "&".$this->_vars["reverseorderVar"]."=".urlencode($this->reverseorder()); |
1469 |
$str .= "&".$this->_search_fieldVar."=".urlencode($this->search_field()); |
$str .= "&".$this->_vars["search_fieldVar"]."=".urlencode($this->search_field()); |
1470 |
$str .= "&".$this->_search_valueVar."=".urlencode($this->search_value()); |
$str .= "&".$this->_vars["search_valueVar"]."=".urlencode($this->search_value()); |
1471 |
$str .= "&".$this->_simple_search_modifierVar."=".urlencode($this->simple_search_modifier_value()); |
$str .= "&".$this->_vars["simple_search_modifierVar"]."=".urlencode($this->simple_search_modifier_value()); |
1472 |
$str .= "&".$this->_search_typeVar."=".urlencode($this->search_type()); |
$str .= "&".$this->_vars["search_typeVar"]."=".urlencode($this->search_type()); |
1473 |
if ($showall_flag) { |
if ( $showall_flag ) { |
1474 |
$str .= "&".$this->_showallVar."=".urlencode($showall_value); |
$str .= "&".$this->_vars["showallVar"]."=".urlencode($showall_value); |
1475 |
} |
} |
1476 |
|
|
1477 |
return $str; |
return htmlentities($str); |
1478 |
|
} |
1479 |
|
|
1480 |
|
/** |
1481 |
|
* This function stores the url for each of the tool |
1482 |
|
* urls, so we can push these out for mozilla. |
1483 |
|
* Mozilla has a nice navigation bar feature that |
1484 |
|
* lets you program first, prev, next, last links |
1485 |
|
* |
1486 |
|
* @param string - which tool link |
1487 |
|
* @param string - the url for that link |
1488 |
|
*/ |
1489 |
|
function _save_mozilla_nav_link($which, $url) { |
1490 |
|
$this->_mozilla_nav_links[$which] = $url; |
1491 |
} |
} |
1492 |
|
|
1493 |
/** |
|
1494 |
* This function stores the url for each of the tool |
/** |
1495 |
* urls, so we can push these out for mozilla. |
* This function returns the path to the |
1496 |
* Mozilla has a nice navigation bar feature that |
* images used in this class |
1497 |
* lets you program first, prev, next, last links |
* |
1498 |
* |
* @return string |
1499 |
* @param string - which tool link |
*/ |
1500 |
* @param string - the url for that link |
function get_image_path() { |
1501 |
*/ |
return $this->_image_path; |
1502 |
function _save_mozilla_nav_link($which, $url) { |
} |
1503 |
$this->_mozilla_nav_links[$which] = $url; |
|
1504 |
} |
/** |
1505 |
|
* This function returns the path to the |
1506 |
|
* images used in this class |
1507 |
/** |
* |
1508 |
* This function returns the path to the |
* @return string |
1509 |
* images used in this class |
*/ |
1510 |
* |
function set_image_path($path) { |
1511 |
* @return string |
return $this->_image_path = $path; |
1512 |
*/ |
} |
|
function get_image_path() { |
|
|
return $this->_image_path; |
|
|
} |
|
|
|
|
|
/** |
|
|
* This function returns the path to the |
|
|
* images used in this class |
|
|
* |
|
|
* @return string |
|
|
*/ |
|
|
function set_image_path($path) { |
|
|
return $this->_image_path = $path; |
|
|
} |
|
1513 |
|
|
1514 |
/** |
/** |
1515 |
* This function returns the current |
* This function returns the current |
1529 |
* @return int |
* @return int |
1530 |
*/ |
*/ |
1531 |
function get_num_pages() { |
function get_num_pages() { |
1532 |
$this->_check_datasource("get_num_pages"); |
$this->_check_datasource("get_num_pages"); |
1533 |
$total_rows = $this->_datasource->get_total_rows(); |
$total_rows = $this->_datasource->get_total_rows(); |
1534 |
|
|
1535 |
$cnt = (int)($total_rows / $this->numrows()); |
$cnt = (int)($total_rows / $this->numrows()); |
1536 |
if ((($total_rows % $this->numrows()) != 0) || ($total_rows == 0)) { |
if ( (($total_rows % $this->numrows()) != 0) || ($total_rows == 0) ) { |
1537 |
$cnt++; |
$cnt++; |
1538 |
} |
} |
1539 |
return $cnt; |
return $cnt; |
1562 |
$num_pages = $this->get_num_pages(); |
$num_pages = $this->get_num_pages(); |
1563 |
$num_rows_per_page = $this->numrows(); |
$num_rows_per_page = $this->numrows(); |
1564 |
|
|
1565 |
$this->_check_datasource("get_page_info"); |
$this->_check_datasource("get_page_info"); |
1566 |
$total_rows = $this->_datasource->get_total_rows(); |
$total_rows = $this->_datasource->get_total_rows(); |
1567 |
|
|
1568 |
$high_range = $low_range + ($num_rows_per_page - 1); |
$high_range = $low_range + ($num_rows_per_page - 1); |
1569 |
if ($high_range > $total_rows) { |
if ( $high_range > $total_rows ) { |
1570 |
$high_range = $total_rows; |
$high_range = $total_rows; |
1571 |
} |
} |
1572 |
|
|
1573 |
if ($total_rows == 0) { |
if ( $total_rows == 0 ) { |
1574 |
$str = "0 of 0"; |
$str = "0 of 0"; |
1575 |
} else { |
} else { |
1576 |
$str = $low_range . " to ". $high_range; |
$str = $low_range . " to ". $high_range; |
1596 |
|
|
1597 |
$order_value = $this->_columns[$col_name]["data_name"]; |
$order_value = $this->_columns[$col_name]["data_name"]; |
1598 |
$reverse_value = "false"; |
$reverse_value = "false"; |
1599 |
if (!$reverseorder) { |
if ( !$reverseorder ) { |
1600 |
$reverseorder = 'false'; |
$reverseorder = 'false'; |
1601 |
} |
} |
1602 |
|
|
1603 |
if ($orderby == $order_value && $reverseorder === 'false') { |
if ( $orderby == $order_value && $reverseorder === 'false' ) { |
1604 |
$reverse_value = "true"; |
$reverse_value = "true"; |
1605 |
} |
} |
1606 |
|
|
1607 |
if ($this->form_method == "POST") { |
if ( $this->get_form_method() == "POST" ) { |
1608 |
//we have to construct this url |
//we have to construct this url |
1609 |
//specially. |
//specially. |
1610 |
$form_name = $this->get_form_name(); |
$form_name = $this->get_form_name(); |
1611 |
|
|
1612 |
$url = "javascript: "; |
$url = "javascript: "; |
1613 |
//set the offset correctly |
//set the offset correctly |
1614 |
$url .= "document.".$form_name.".".$this->_offsetVar.".value='".$this->offset()."';"; |
$url .= "document.".$form_name.".".$this->_vars["offsetVar"].".value='".$this->offset()."';"; |
1615 |
//set the orderby correctly. |
//set the orderby correctly. |
1616 |
$url .= "document.".$form_name.".".$this->_orderbyVar.".value='".$order_value."';"; |
$url .= "document.".$form_name.".".$this->_vars["orderbyVar"].".value='".$order_value."';"; |
1617 |
//set the reverseorder |
//set the reverseorder |
1618 |
$url .= "document.".$form_name.".".$this->_reverseorderVar.".value='".$reverse_value."';"; |
$url .= "document.".$form_name.".".$this->_vars["reverseorderVar"].".value='".$reverse_value."';"; |
1619 |
|
|
1620 |
$url .= "document.".$form_name.".submit();"; |
$url .= "document.".$form_name.".submit();"; |
1621 |
} else { |
} else { |
1622 |
//handle the normal get. |
//handle the normal get. |
1623 |
$url = $this->build_base_url(); |
$url = $this->build_base_url(); |
1624 |
//Now add the orderby, reverseorder and offset vars |
//Now add the orderby, reverseorder and offset vars |
1625 |
$url .= $this->_offsetVar ."=0&"; |
$url .= $this->_vars["offsetVar"] ."=0&"; |
1626 |
//set the orderbyvar |
//set the orderbyvar |
1627 |
$url .= $this->_orderbyVar ."=".$order_value."&"; |
$url .= $this->_vars["orderbyVar"] ."=".$order_value."&"; |
1628 |
//set the reverseorder |
//set the reverseorder |
1629 |
$url .= $this->_reverseorderVar ."=".$reverse_value."&"; |
$url .= $this->_vars["reverseorderVar"] ."=".$reverse_value."&"; |
1630 |
//set the search value |
//set the search value |
1631 |
$url .= $this->_search_valueVar ."=".$search_value; |
$url .= $this->_vars["search_valueVar"] ."=".$search_value; |
1632 |
} |
} |
1633 |
|
|
1634 |
return $url; |
return $url; |
1635 |
} |
} |
1636 |
|
|
|
/** |
|
|
* This is the basic function for letting us |
|
|
* do a mapping between the column name in |
|
|
* the header, to the value found in the DB. |
|
|
* |
|
|
* NOTE: this function is meant to be overridden |
|
|
* so that you can push whatever you want. |
|
|
* |
|
|
* @param array - $row_data - the entire data for the row |
|
|
* @param string - $col_name - the name of the column header |
|
|
* for this row to render. |
|
|
* @return mixed - either a HTMLTag object, or raw text. |
|
|
*/ |
|
|
function build_column_item($row_data, $col_name) { |
|
|
$key = $this->_columns[$col_name]["data_name"]; |
|
|
|
|
|
if ($row_data[$key] == '') { |
|
|
return " "; |
|
|
} else { |
|
|
return $this->filter_column_string($row_data[$key]); |
|
|
} |
|
|
} |
|
|
|
|
1637 |
|
|
1638 |
/** |
/** |
1639 |
* This does some magic filtering on the data |
* This function is used to make sure that the string we are |
1640 |
* that we display in a column. This helps |
* placing in a cell has been "cleaned" |
|
* to prevent nast data that may have html |
|
|
* tags in it. |
|
1641 |
* |
* |
1642 |
* @param string - the column data u want to filter |
* @param mixed - the cell object. It can be a string. |
1643 |
* @return string the cleaned/filtered data |
* @param string - the name of the column this object/string |
1644 |
*/ |
* will live |
1645 |
function filter_column_string($data) { |
* |
1646 |
return htmlspecialchars(trim($data)); |
* @return mixed - the cleaned string or object |
1647 |
|
*/ |
1648 |
|
function _clean_string($obj, $col_name) { |
1649 |
|
if ( is_string($obj) ) { |
1650 |
|
if ( $this->_columns[$col_name]["maxtextlength"] ) { |
1651 |
|
//looks like we need to make sure we |
1652 |
|
//truncate the string to a max length |
1653 |
|
if ( strlen($obj) > $this->_columns[$col_name]["maxtextlength"] ) { |
1654 |
|
//we need to truncate it. |
1655 |
|
$obj = substr($obj, 0, $this->_columns[$col_name]["maxtextlength"]); |
1656 |
|
$obj .= "..."; |
1657 |
|
} |
1658 |
|
} |
1659 |
|
} |
1660 |
|
return $obj; |
1661 |
} |
} |
|
|
|
1662 |
|
|
1663 |
|
/********************************/ |
1664 |
/** |
/* SEARCH RELATED */ |
1665 |
* This function is used to make sure that the string we are |
/********************************/ |
|
* placing in a cell has been "cleaned" |
|
|
* |
|
|
* @param mixed - the cell object. It can be a string. |
|
|
* @param string - the name of the column this object/string |
|
|
* will live |
|
|
* |
|
|
* @return mixed - the cleaned string or object |
|
|
*/ |
|
|
function _clean_string($obj, $col_name){ |
|
|
if (is_string($obj)) { |
|
|
if ($this->_columns[$col_name]["maxtextlength"]) { |
|
|
//looks like we need to make sure we |
|
|
//truncate the string to a max length |
|
|
if (strlen($obj) > $this->_columns[$col_name]["maxtextlength"]) { |
|
|
//we need to truncate it. |
|
|
$obj = substr($obj, 0, $this->_columns[$col_name]["maxtextlength"]); |
|
|
$obj .= "..."; |
|
|
} |
|
|
} |
|
|
} |
|
|
return $obj; |
|
|
} |
|
|
|
|
|
/********************************/ |
|
|
/* SEARCH RELATED */ |
|
|
/********************************/ |
|
1666 |
|
|
1667 |
/** |
/** |
1668 |
* This method gets the array of |
* This method gets the array of |
1673 |
function _get_searchable_fields() { |
function _get_searchable_fields() { |
1674 |
$fields = array(); |
$fields = array(); |
1675 |
foreach($this->_columns as $name => $header) { |
foreach($this->_columns as $name => $header) { |
1676 |
if ($header["searchable"] == TRUE) { |
if ( $header["searchable"] == TRUE ) { |
1677 |
$fields[$name] = $header["data_name"]; |
$fields[$name] = $header["data_name"]; |
1678 |
} |
} |
1679 |
} |
} |
1692 |
|
|
1693 |
$modifier = $this->get_simple_search_modifier(); |
$modifier = $this->get_simple_search_modifier(); |
1694 |
|
|
1695 |
if ($modifier & SEARCH_BEGINS_WITH) { |
if ( $modifier & SEARCH_BEGINS_WITH ) { |
1696 |
$options["beginning with"] = "BEGINS"; |
$options["beginning with"] = "BEGINS"; |
1697 |
} |
} |
1698 |
if ($modifier & SEARCH_CONTAINS) { |
if ( $modifier & SEARCH_CONTAINS ) { |
1699 |
$options["containing"] = "CONTAINS"; |
$options["containing"] = "CONTAINS"; |
1700 |
} |
} |
1701 |
if ($modifier & SEARCH_EXACT) { |
if ( $modifier & SEARCH_EXACT ) { |
1702 |
$options["matching"] = "EXACT"; |
$options["matching"] = "EXACT"; |
1703 |
} |
} |
1704 |
if ($modifier & SEARCH_ENDS_WITH) { |
if ( $modifier & SEARCH_ENDS_WITH ) { |
1705 |
$options["ending with"] = "ENDS"; |
$options["ending with"] = "ENDS"; |
1706 |
} |
} |
1707 |
|
|
1708 |
$selected = $this->simple_search_modifier_value(); |
$selected = $this->simple_search_modifier_value(); |
1709 |
//make the default Begins with |
//make the default Begins with |
1710 |
if (!$selected) { |
if ( !$selected ) { |
1711 |
$selected = "BEGINS"; |
$selected = "BEGINS"; |
1712 |
} |
} |
1713 |
|
|
1714 |
return form_select($this->_simple_search_modifierVar, $options, $selected); |
return form_select($this->_vars["simple_search_modifierVar"], $options, $selected); |
1715 |
} |
} |
1716 |
|
|
1717 |
/** |
/** |
1718 |
* This function is used to make safe |
* This function is used to make safe |
1719 |
* any query string value that is used |
* any query string value that is used |
1720 |
* |
* |