Source for file sp_grid_wlc.class.php
Documentation is available at sp_grid_wlc.class.php
// *** Tangra (Application Framework and Tools for PHP)
* Contains class SP_Grid_WLC
require_once(TANGRA_MAIN_DIR. 'grids/static_paginated_grid.class.php');
require_once(TANGRA_MAIN_DIR. 'exceptions/te_key_already_exists.class.php');
require_once(TANGRA_MAIN_DIR. 'exceptions/te_grid_invalid_number_values_for_link_cols.class.php');
* Static Grid with link columns and paginator
* Link columns capture values
* Adds new linl column to the grid with name <var>$name</var>,
* href link pointing to <var>$target</var> and capture <var>$capture</var>.
* Generated link will look like: <a href="$target?$capture=$link_column_capture">Something</a>
* @param string $name Column name
* @param string $target_page Target page
* @param string $capture Label for the capture
public function add_link_col($name, $target_page, $capture) {
$this->link_cols[$name]['target_page'] = $target_page;
$this->link_cols[$name]['capture'] = $capture;
throw new TE_Key_Already_Exists($name);
* Returns array containing web events that grid may generate
//matches only event targeted at current page
* Returns TPLE exports for the grid
* Returns HTML for the grid
* @param string $path Path to template file
* @param string $language Navive language code
$tple->set_delimiters('{@', '@}');
$tple->assign('grid_name', $this->get_name());
$tple->assign('link_cols', $this->link_cols);
$tple->assign('language', $language);
$html = $tple->fetch($path. '/sp_grid_wlc.tpl');
* Adds link columns capture values
* Link columns capture values are values that will be added at the end of the link.
* <a href="somepage.php?obj=5">
* somepage.php is <var>$target</var> @see SP_Grid_WLC::add_link_col()
* obj is the capture label
* 5 is the link column capture value - normally this is the id of the record but you
* may use different column @see SP_Grid_WLC::set_rows_and_link_cols_rows_from_raw_rows
if ($have == $must_have) {
throw new TE_Grid_Invalid_Number_Values_For_Link_Cols($must_have, $have);
* Sets all link columns capture values at once
* Prepares row to be used in a convinient way by this class
* @throws TE_Key_Not_Exists
foreach($this->rows as $row_key => $row) {
$ret[$row_key]['cols'] = $row;
throw new TE_Key_Not_Exists($row_key);
* Sets all data rows and link column capture rows using "raw rows"
* @param array $raw_rows Array of rows as returned by the SELECT form DB
* @param integer $use_col_num Which column to be used for value of link columns capture value
* @param boolean $skip_used_col If true used column will be skipped and will not exists in final array
foreach($raw_rows as $row) {
for($i = 0; $i <= (count($row) - 1);$i++ ) {
if ($use_col_num == $i) {
//preparing one row of link_cols_rows
$link_cols_row = array();
foreach($this->link_cols as $key => $link_col) {
$link_cols_row[$key] = $row[$use_col_num];
unset ($row[$use_col_num]);
* Shorhand for setting all rows with using column 0 and skipping used column
* This function is convinient when you select from database like:
* "Select obj.id, obj.name, obj.description where...".
* @see SP_Grid_WLC::set_rows_and_link_cols_rows_from_raw_rows
* Shifts down the array in order to have continiuos array index starting with 0
|