7 |
* @package phpHtmlLib |
* @package phpHtmlLib |
8 |
*/ |
*/ |
9 |
|
|
10 |
|
/** |
11 |
|
* We require the DataListSource |
12 |
|
*/ |
13 |
|
require_once($phphtmllib."/widgets/data_list/DataListSource.inc"); |
14 |
|
|
15 |
/** |
/** |
16 |
* |
* |
36 |
|
|
37 |
|
|
38 |
/** |
/** |
39 |
|
* The flag that tells us to use |
40 |
|
* case sensitive order by as a default. |
41 |
|
* |
42 |
|
* NOTE: we are case sensitive by default |
43 |
|
* |
44 |
|
*/ |
45 |
|
var $_default_order_sensitivity = TRUE; |
46 |
|
|
47 |
|
|
48 |
|
/** |
49 |
* Set which DB options |
* Set which DB options |
50 |
* to use for this list. |
* to use for this list. |
51 |
* |
* |
309 |
* |
* |
310 |
* @param string - DB table field to order by |
* @param string - DB table field to order by |
311 |
* @param string - order assension value. |
* @param string - order assension value. |
312 |
|
* @param boolean - case insensitive sort? |
313 |
* |
* |
314 |
* @return string. |
* @return string. |
315 |
*/ |
*/ |
316 |
function setup_order($orderby, $reverseorder) { |
function setup_order($orderby, $reverseorder, $icase_sort=FALSE) { |
317 |
|
if ($icase_sort) { |
318 |
|
$orderby = "lower(".$orderby.")"; |
319 |
|
} |
320 |
|
|
321 |
|
$secondary = $this->get_secondary_orderby(); |
322 |
|
|
323 |
|
if (count($secondary) > 0) { |
324 |
|
$orderby .= ",".implode(",", $secondary); |
325 |
|
} |
326 |
|
|
327 |
if ($reverseorder == "true") { |
if ($reverseorder == "true") { |
328 |
return "order by ".$orderby." DESC"; |
return "order by ".$orderby." DESC"; |
329 |
} |
} |
330 |
else { |
else { |
331 |
return "order by ".$orderby; |
return "order by ".$orderby." ASC"; |
332 |
} |
} |
333 |
} |
} |
334 |
|
|
340 |
*/ |
*/ |
341 |
function build_order_clause() { |
function build_order_clause() { |
342 |
|
|
343 |
// Set up reverseorder correctly |
//Set up reverseorder correctly |
344 |
|
$icase_sort = !$this->get_default_order_case_sensitive(); |
345 |
|
$orderby = $this->get_orderby(); |
346 |
foreach( $this->_columns as $col_name => $data ) { |
foreach( $this->_columns as $col_name => $data ) { |
347 |
if (($data["data_name"] == $this->get_orderby()) && |
if (($data["data_name"] == $orderby) && |
348 |
($data["reverseorder"] == "true") && |
($data["reverseorder"] == "true") && |
349 |
!isset( ${$this->reverseorderVar})) { |
!isset( ${$this->reverseorderVar})) { |
350 |
$this->set_reverseorder( $data["reverseorder"] ); |
$this->set_reverseorder( $data["reverseorder"] ); |
351 |
} |
} |
352 |
|
if ($data["data_name"] == $orderby && |
353 |
|
$data["sortable"] == SORTABLE_ICASE) { |
354 |
|
$icase_sort = TRUE; |
355 |
|
} else { |
356 |
|
$icase_sort = FALSE; |
357 |
|
} |
358 |
} |
} |
359 |
|
|
360 |
$orderClause = $this->setup_order($this->get_orderby(), $this->get_reverseorder() ); |
$orderClause = $this->setup_order($orderby, |
361 |
|
$this->get_reverseorder(), |
362 |
|
$icase_sort ); |
363 |
return $orderClause; |
return $orderClause; |
364 |
} |
} |
365 |
|
|
369 |
* @return string |
* @return string |
370 |
*/ |
*/ |
371 |
function build_groupby_clause() { |
function build_groupby_clause() { |
372 |
$groupby = $this->_groupby_clause; |
$groupby = $this->_db_options["groupby_clause"]; |
373 |
if ($groupby) { |
if ($groupby) { |
374 |
$groupby = " GROUP BY $groupby "; |
$groupby = " GROUP BY $groupby "; |
375 |
} |
} |
455 |
* Do the query to the DB and pull in all of |
* Do the query to the DB and pull in all of |
456 |
* the records locally. |
* the records locally. |
457 |
* |
* |
458 |
|
* @return boolean - the query passed/failed. |
459 |
*/ |
*/ |
460 |
function do_query() { |
function do_query() { |
461 |
//execute the sql query. |
//execute the sql query. |
462 |
//we don't actually get the results of |
//we don't actually get the results of |
463 |
//the query here, when just execute it. |
//the query here, when just execute it. |
464 |
user_error("SQLDataListSource::do_query() - Child must override"); |
user_error("SQLDataListSource::do_query() - Child must override"); |
465 |
|
return false; |
466 |
} |
} |
467 |
|
|
468 |
/** |
/** |
473 |
*/ |
*/ |
474 |
function get_next_data_row() { |
function get_next_data_row() { |
475 |
user_error("SQLDataListSource::get_next_data_row() - Child must override"); |
user_error("SQLDataListSource::get_next_data_row() - Child must override"); |
476 |
|
return array(); |
477 |
} |
} |
478 |
|
|
479 |
/** |
/** |
502 |
user_error("SQLDataListSource::count() - Child must override"); |
user_error("SQLDataListSource::count() - Child must override"); |
503 |
} |
} |
504 |
|
|
505 |
|
/** |
506 |
|
* This function is used to set the flag for the |
507 |
|
* ability to sort/order by case sensitive or not. |
508 |
|
* |
509 |
|
* @param boolean - TRUE = case sensitive by default |
510 |
|
* @return none |
511 |
|
*/ |
512 |
|
function set_default_order_case_sensitive($flag=TRUE) { |
513 |
|
$this->_default_order_sensitivity = $flag; |
514 |
|
} |
515 |
|
|
516 |
|
/** |
517 |
|
* This function is used to get the flag for the |
518 |
|
* ability to sort/order by case sensitive or not. |
519 |
|
* |
520 |
|
* @param boolean - TRUE = case sensitive by default |
521 |
|
* @return none |
522 |
|
*/ |
523 |
|
function get_default_order_case_sensitive() { |
524 |
|
return $this->_default_order_sensitivity; |
525 |
|
} |
526 |
} |
} |
527 |
|
|
528 |
?> |
?> |