b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.8) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Class: Results

Source Location: /blogs/inc/_misc/_results.class.php

Class Results

Direct descendents
Child Class Description
FilteredResults
DataObjectList Data Object List Base Class
ResultSel ResultSel class: displays Results and provides Selection capabilities
ArchiveList Archive List Class

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Widget

Widget::$global_icons
Widget::$title

Inherited From Widget

Widget::gen_global_icons()
Generate img tags for registered icons, through global_icon().
Widget::global_icon()
Registers a global action icon
Widget::replace_callback()
Callback function used to replace only necessary values in template.
Widget::replace_callback_wrapper()
This is an additional wrapper to replace_vars() that allows to react on the return value of it.
Widget::replace_vars()
Replaces $vars$ with appropriate values.

[ Top ]
Property Summary
mixed   $Cache   Cache to use to instantiate an object and cache it for each line of results.
mixed   $cols   Definitions for each column:
boolean   $col_headers   Do we want to display column headers?
string   $current_group_ID   Current group identifier:
mixed   $current_idx   Current object idx in $rows array:
mixed   $current_Obj   This will hold the object instantiated by the Cache for the current line.
mixed   $DB  
mixed   $filter_area   Parameters for the filter area:
mixed   $functions_area   Parameters for the functions area (to display functions at the end of results array):
mixed   $global_idx   idx relative to whole list (range: 0 to total_rows-1)
mixed   $global_is_first   Is this gobally the 1st item in the list? (NOT just the 1st in current page)
mixed   $global_is_last   Is this gobally the last item in the list? (NOT just the last in current page)
string   $group_by   Fieldname to group on.
mixed   $grp_cols   Definitions for each GROUP column:
string   $ID_col   Fieldname to detect empty data rows.
mixed   $limit   Number of lines per page
mixed   $nb_cols   Lazy filled.
mixed   $order_field_list   List of sortable fields
mixed   $order_param  
mixed   $page   Current page
mixed   $page_ID_array   Array of IDs for current page.
mixed   $page_ID_list   List of IDs for current page.
mixed   $page_param  
mixed   $params   Display parameters
mixed   $param_prefix   URL param names
mixed   $result_num_rows   Number of rows in result set for current page.
mixed   $rows   Array of DB rows for current page.
mixed   $sql   SQL query
mixed   $total_pages   Total number of pages
mixed   $total_rows   Total number of rows (if > $limit, it will result in multiple pages)

[ Top ]
Method Summary
Results   Results()   Constructor
void   count_total_rows()   Count the total number of rows of the SQL result (all pages)
int   display()   Display paged list/table based on object parameters
void   display_body()   Display list/table body.
void   display_filters()   Display the filtering form
void   display_first()   returns the link to the first page, if necessary
void   display_functions()   Display the functions
void   display_head()   Display list/table head.
true   display_if_empty()   Template function: display message if list is empty
void   display_init()   Initialize things in order to be ready for displaying.
void   display_last()   returns the link to the last page, if necessary
void   display_list_end()   Display list/table end.
void   display_list_start()   Display list/table start.
void   display_nav()   Display navigation text, based on template.
void   display_next()   returns a link to next pages, if necessary
void   display_prev()   returns a link to previous pages, if necessary
void   display_totals()   Display totals line if set.
void   first()   Returns the first page number to be displayed in the list
array   get_col_sort_values()   Returns values needed to make sort links for a given column
integer   get_num_rows()   Get number of rows available for display
string   get_order_field_list()   Returns order field list add to SQL query:
void   get_page_ID_array()   Get an array of IDs for current page
void   get_page_ID_list()   Get a list of IDs for current page
void   instantiate_page_to_Cache()   Note: this function might actually not be very useful.
void   last()   returns the last page number to be displayed in the list
void   move_icons()  
void   next_idx()   Increment and update all necessary counters before processing a new line in result set
void   page_list()   Returns the page link list under the table
void   page_scroll_list()  
void   parse_col_content()   Handle variable subtitutions for column contents.
void   query()   Run the query now!
string   replace_callback()   Widget callback for template vars.
void   restart()   Rewind resultset

[ Top ]
Properties
mixed   $Cache [line 122]

Cache to use to instantiate an object and cache it for each line of results.

For this to work, all columns of the related table must be selected in the query


[ Top ]
mixed   $cols [line 144]

Definitions for each column:

  • th
  • td
  • order: SQL column name(s) to sort by (delimited by comma)
  • td_start
A column with no def will be displayed using the default defs from Results::params, that is to say, one of these:
  • $this->params['col_start_first'];
  • $this->params['col_start_last'];
  • $this->params['col_start'];


[ Top ]
boolean   $col_headers = true [line 155]

Do we want to display column headers?


[ Top ]
string   $current_group_ID = 0 [line 177]

Current group identifier:


[ Top ]
mixed   $current_idx = 0 [line 99]

Current object idx in $rows array:


[ Top ]
mixed   $current_Obj [line 127]

This will hold the object instantiated by the Cache for the current line.


[ Top ]
mixed   $DB [line 47]

[ Top ]
mixed   $filter_area [line 216]

Parameters for the filter area:


[ Top ]
mixed   $functions_area [line 222]

Parameters for the functions area (to display functions at the end of results array):


[ Top ]
mixed   $global_idx [line 104]

idx relative to whole list (range: 0 to total_rows-1)


[ Top ]
mixed   $global_is_first [line 109]

Is this gobally the 1st item in the list? (NOT just the 1st in current page)


[ Top ]
mixed   $global_is_last [line 114]

Is this gobally the last item in the list? (NOT just the last in current page)


[ Top ]
string   $group_by = '' [line 171]

Fieldname to group on.

Leave empty if you don't want to group.


[ Top ]
mixed   $grp_cols = NULL [line 188]

Definitions for each GROUP column:

-td -td_start. A column with no def will de displayed using the default defs from Results::params, that is to say, one of these:

  • $this->params['grp_col_start_first'];
  • $this->params['grp_col_start_last'];
  • $this->params['grp_col_start'];


[ Top ]
string   $ID_col = '' [line 198]

Fieldname to detect empty data rows.

Empty data rows can happen when left joining on groups. Leave empty if you don't want to detect empty datarows.


[ Top ]
mixed   $limit [line 62]

Number of lines per page


[ Top ]
mixed   $nb_cols [line 149]

Lazy filled.


[ Top ]
mixed   $order_field_list [line 210]

List of sortable fields


[ Top ]
mixed   $order_param [line 205]

[ Top ]
mixed   $page [line 77]

Current page


[ Top ]
mixed   $page_ID_array [line 94]

Array of IDs for current page.

API Tags:
Uses:  Results::ID_col


[ Top ]
mixed   $page_ID_list [line 88]

List of IDs for current page.

API Tags:
Uses:  Results::ID_col


[ Top ]
mixed   $page_param [line 204]

[ Top ]
mixed   $params = NULL [line 161]

Display parameters


[ Top ]
mixed   $param_prefix [line 203]

URL param names


[ Top ]
mixed   $result_num_rows [line 67]

Number of rows in result set for current page.


[ Top ]
mixed   $rows [line 82]

Array of DB rows for current page.


[ Top ]
mixed   $sql [line 52]

SQL query


[ Top ]
mixed   $total_pages [line 72]

Total number of pages


[ Top ]
mixed   $total_rows [line 57]

Total number of rows (if > $limit, it will result in multiple pages)


[ Top ]
Methods
Constructor Results  [line 241]

  Results Results( string $sql, [string $param_prefix = ''], [string $default_order = ''], [integer $limit = 20], [boolean $count_sql = NULL], [NULL|string $init_page = true]  )

Constructor

Parameters:
string   $sql:  SQL query
string   $param_prefix:  prefix to differentiate page/order params when multiple Results appear one same page
string   $default_order:  default ordering of columns (special syntax) if not specified in the URL params example: -A-- will sort in ascending order on 2nd column example: ---D will sort in descending order on 4th column
integer   $limit:  number of lines displayed on one page
boolean   $count_sql: 
NULL|string   $init_page:  SQL query used to count the total # of rows (if NULL, we'll try to COUNT(*) by ourselves)

Information Tags:
Todo:  we might not want to count total rows when not needed...
Todo:  fplanque: I am seriously considering putting $count_sqlinto 2nd or 3rd position. Any prefs?

[ Top ]
count_total_rows  [line 443]

  void count_total_rows( [ $sql_count = NULL]  )

Count the total number of rows of the SQL result (all pages)

This is done by dynamically modifying the SQL query and forging a COUNT() into it.

Parameters:
   $sql_count: 

Information Tags:
Todo:  allow overriding?
Todo:  handle problem of empty groups!

Redefined in descendants as:

[ Top ]
display  [line 541]

  int display( [array|NULL $display_params = NULL], [array $fadeout = array()]  )

Display paged list/table based on object parameters

This is the meat of this class!

Parameters:
array|NULL   $display_params: 
array   $fadeout:  Fadeout settings (column key => crit (array))

API Tags:
Return:  # of rows displayed


[ Top ]
display_body  [line 1083]

  void display_body( [array $fadeout = array()]  )

Display list/table body.

This includes groups and data rows.

Parameters:
array   $fadeout:  fadeout list

API Tags:
Access:  protected


[ Top ]
display_filters  [line 673]

  void display_filters( )

Display the filtering form



[ Top ]
display_first  [line 1823]

  void display_first( )

returns the link to the first page, if necessary



[ Top ]
display_functions  [line 1356]

  void display_functions( )

Display the functions



Redefined in descendants as:

[ Top ]
display_head  [line 786]

  void display_head( )

Display list/table head.

This includes list head/title and column headers. This is optional and will only produce output if column headers are defined. EXPERIMENTAL: also dispays <tfoot>


API Tags:
Access:  protected


[ Top ]
display_if_empty  [line 1985]

  true display_if_empty( [string $message = '']  )

Template function: display message if list is empty

Parameters:
string   $message:  String to display if list is empty

API Tags:
Return:  if empty


Redefined in descendants as:

[ Top ]
display_init  [line 603]

  void display_init( [ $display_params = NULL]  )

Initialize things in order to be ready for displaying.

This is useful when manually displaying, i-e: not by using Results::display()

Parameters:
   $display_params: 


[ Top ]
display_last  [line 1839]

  void display_last( )

returns the link to the last page, if necessary



[ Top ]
display_list_end  [line 657]

  void display_list_end( [boolean $detect_no_results = true]  )

Display list/table end.

Typically outputs </ul> or </table>

Parameters:
boolean   $detect_no_results:  do we want special treatment when there are no results


Redefined in descendants as:

[ Top ]
display_list_start  [line 637]

  void display_list_start( [boolean $detect_no_results = true]  )

Display list/table start.

Typically outputs UL or TABLE tags.

Parameters:
boolean   $detect_no_results:  do we want special treatment when there are no results


Redefined in descendants as:

[ Top ]
display_nav  [line 1411]

  void display_nav( string $template  )

Display navigation text, based on template.

Parameters:
string   $template:  template: 'header' or 'footer'

API Tags:
Access:  protected


[ Top ]
display_next  [line 1869]

  void display_next( )

returns a link to next pages, if necessary



[ Top ]
display_prev  [line 1855]

  void display_prev( )

returns a link to previous pages, if necessary



[ Top ]
display_totals  [line 1277]

  void display_totals( )

Display totals line if set.



[ Top ]
first  [line 1787]

  void first( )

Returns the first page number to be displayed in the list



[ Top ]
get_col_sort_values  [line 1440]

  array get_col_sort_values( integer $col_idx  )

Returns values needed to make sort links for a given column

Returns an array containing the following values:

  • current_order : 'ASC', 'DESC' or ''
  • order_asc : url to order in ascending order
  • order_desc
  • order_toggle : url to toggle sort order

Parameters:
integer   $col_idx:  column to sort


Redefined in descendants as:

[ Top ]
get_num_rows  [line 1973]

  integer get_num_rows( )

Get number of rows available for display



[ Top ]
get_order_field_list  [line 1510]

  string get_order_field_list( )

Returns order field list add to SQL query:


API Tags:
Return:  May be empty


[ Top ]
get_page_ID_array  [line 419]

  void get_page_ID_array( )

Get an array of IDs for current page


API Tags:
Uses:  Results::ID_col


[ Top ]
get_page_ID_list  [line 402]

  void get_page_ID_list( )

Get a list of IDs for current page


API Tags:
Uses:  Results::ID_col


[ Top ]
instantiate_page_to_Cache  [line 515]

  void instantiate_page_to_Cache( DataObjectCache &$Cache  )

Note: this function might actually not be very useful.

If you define ->Cache before display, all rows will be instantiated on the fly. No need to restart et go through the rows a second time here.

Parameters:
DataObjectCache   &$Cache: 


[ Top ]
last  [line 1807]

  void last( )

returns the last page number to be displayed in the list



[ Top ]
move_icons  [line 1620]

  void move_icons( )


Information Tags:
Todo:  Support Results::order_callbacks

[ Top ]
next_idx  [line 290]

  void next_idx( )

Increment and update all necessary counters before processing a new line in result set



[ Top ]
page_list  [line 1882]

  void page_list( $min, $max  )

Returns the page link list under the table

Parameters:
   $min: 
   $max: 


[ Top ]
page_scroll_list  [line 1905]

  void page_scroll_list( )



[ Top ]
parse_col_content  [line 1581]

  void parse_col_content( $content  )

Handle variable subtitutions for column contents.

This is one of the key functions to look at when you want to use the Results class.

  • $var$
  • £var£
  • #var#
  • {row}
  • {global_idx}
  • {global_is_first}
  • {global_is_last}
  • %func()%
  • ¤func()¤

Parameters:
   $content: 


[ Top ]
query  [line 311]

  void query( $sql, [ $create_default_cols_if_needed = true], [ $append_limit = true]  )

Run the query now!

Will only run if it has not executed before.

Parameters:
   $sql: 
   $create_default_cols_if_needed: 
   $append_limit: 

Information Tags:
Todo:  do we need that $sql param ???

Redefined in descendants as:

[ Top ]
replace_callback  [line 1711]

  string replace_callback( $matches  )

Widget callback for template vars.

This allows to replace template vars, see Widget::replace_callback().

Parameters:
   $matches: 


Redefinition of:
Widget::replace_callback()
Callback function used to replace only necessary values in template.

[ Top ]
restart  [line 270]

  void restart( )

Rewind resultset



Redefined in descendants as:

[ Top ]

Documentation generated on Tue, 18 Dec 2007 23:22:03 +0100 by phpDocumentor 1.4.0