Location: PHPKode > projects > OpenNitro > trunk/Nitro/Libraries/List.inc.php
<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Libraries :: Listing                                             |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2003 June Systems BV                                        |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it   |
// | under the terms of the GNU Lesser General Public License as published by  |
// | the Free Software Foundation; either version 2.1 of the License, or (at   |
// | your option) any later version.                                           |
// |                                                                           |
// | This library is distributed in the hope that it will be useful, but       |
// | WITHOUT ANY WARRANTY; without even the implied warranty of                |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser   |
// | General Public License for more details.                                  |
// |                                                                           |
// | You should have received a copy of the GNU Lesser General Public License  |
// | along with this library; if not, write to the Free Software Foundation,   |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA            |
// +---------------------------------------------------------------------------+
// | Authors: Oli Oskarsson <hide@address.com>                              |
// +---------------------------------------------------------------------------+
//
// $Id: List.inc.php 229 2008-04-17 09:20:31Z oli $
//
// This file contains the List functions to create Listings
//

/**
 * This file contains the listing class.
 *
 * This class can be used to create lists.
 *
 * @package	Nitro
 * @subpackage	Libraries
 * @author 		Oli Oskarsson
 * @version 	$Revision: 1.33 $
 * @copyright	2004 June Systems BV
 */

/**
 * Defines
 */
define ('NITRO_DEF_LIST_TEMPLATE', "List");
define ('NITRO_DEF_LISTROW_TEMPLATE', "ListRow");

/**
 * Include Nitro template support
 */
require_once "Nitro/Template.inc.php";

/**
 * The Listing class
 *
 * This class contains the listing definition.
 *
 * <CODE>
 * $Listing = new Listing("Listing Name", "ListingID");
 *
 * $Listing->EnableFilter = true;
 * $Listing->SetTemplate('Nitro:'.NitroGetTemplateID('DefaultList'));
 *
 * $Listing->AddActions(array('EditID' => '&nbsp;', 'DeleteID' => '&nbsp;'));
 * $Listing->AddColumns(array(
 * 		"Name" 		=> Language("Name"),
 *		"Active"	=> Language("Active")
 *		));
 * $Listing->SetFilterVariable("Enabled", "VALUES");
 * $Listing->TableWidth = "auto";
 *
 * $ListRow = new ListingRow();
 * $ListRow->AddData(array(
 * 		"Name"		=> "<NOBR>".$Data["Name"]."</NOBR>",
 * 		"Enabled"	=> ($Data["Enabled"] == 'true' ? Language("Yes") : Language("No")),
 * 		"Branche"	=> "<NOBR>".$Data["BranchName"]."</NOBR>"
 * 		));
 * $ListRow->SetAction('EditID', 'Edit Text', $this->Conf["Settings"]["PageURL"].$_GET['P'].'&A=EDIT&ID=1');
 * $ListRow->SetAction('DeleteID', 'Delete Text', $this->Conf["Settings"]["PageURL"].$_GET['P'].'&A=DEL&ID=1');
 * $Listing->AddListRow($ListRow);
 *
 * echo $Listing->Draw();
 *</CODE>
 *
 * @package	Nitro
 * @subpackage	Libraries
 * @access	public
 */
class Listing {
	var $ListID;
	
	var $Template;
	var $Title;
	var $inDiv; // inDiv extra, place total list in a Div!
	
	var $Columns = array();
	var $ColumnAligns = array();
	var $ColumnWidths = array();
	var $Rows = array();
	var $hiddenRows = array();
	
	var $ColumnID = 0;
	var $RowID = 0;
	
	var $Actions;
	var $ListActions = array();

	// Filter
	var $EnableFilter = FALSE;
	var $ListFilterVariables = Array();
	var $ListFilterVariableValues = Array();
	var $ListFilterValues = Array();
	var $FilterValuesDone = array();
	
	//MISC
	var $TableWidth = '650px';
	var $AlignData = 'right';
	var $RepeatHeader = FALSE;
	var $EnableRowHighlighting = FALSE;
	var $EnableColumnHighlighting = FALSE;
	var $NoRedirect = FALSE;
	var $UseListSort = TRUE;
	var $AddNoBreaks = FALSE;
	//var $DrawFormTags;
	var $showHiddenRows = FALSE;
	var $UsePages = TRUE;
	var $ShowMaxCountSelection = TRUE;
	var $ListDivID;
	var $SetScrollPosition = TRUE;

	/**
	 * @var int Amount of items per page used when no settings found in session
	 */
	var $initialMaxCountPerPage = 0;
	
	/**
	 * @var bool Should the table be split if the template supports it
	 */
	var $splitTable = FALSE;
	/**
	 * @var int after how many Columns should the table split
	 */
	var $columnNumberSplit = 2;
	/**
	 * @var array Array containing maximum string lengths per column for use with splitTable
	 */
	var $ColumnLengths = Array();
	
	/**
	 * Listing constructor
	 *
	 * @param	string	$Title			Title of the Form
	 * @param	string	$ListID			ID of the list used to set and restore session information
	 * @param	boolean	$NoRedirect	Variable used to define if document should be redirected after form submit
	 * @access	public
	 */
	function Listing($Title = "", $ListID = NULL, $inDiv = NULL, $NoRedirect = FALSE)
	{
		global $__NSess, $__NitroConf;
		
		$this->NoRedirect = $NoRedirect;
		$this->Template = "file:".NITRO_PATH."Defaults/Templates/List.tpl";
		$this->Title = $Title;
		$this->inDiv = ( $inDiv != NULL ) ? $inDiv : "";
		$this->Conf = $__NitroConf->CONF;
		
		// Reconstruct query string in order to not accumulate &OrderBy=... clauses
		$P = $_GET['P'];
		$queryArray = array();
		foreach ($_GET AS $key => $value) {
			if ($key != 'P' && $key != 'disableInitXML' && $key != 'OrderBy' && !is_array($value)) $queryArray[] = rawurlencode($key)."=".rawurlencode($value);
		}
		$queryString = (count($queryArray) ? '&'.implode('&', $queryArray) : "");
		$this->ListURL = $this->Conf["Settings"]["PageURL"].$P.$queryString.'&disableInitXML=1'; //disable needed for Daphne/Nitro compatibility
		$this->OrderByURL =& $this->ListURL;
		
		if (isset($ListID)) {
			$this->ListID = $ListID;
			// List met Sessie support
			if(!is_array($__NSess->Lists[$ListID])){
				//bestaat nog niet
				$__NSess->Lists[$ListID] = array();
			}
			$this->ListSettings =& $__NSess->Lists[$ListID];
		}else{
			//geen ListID dus temp List ID aanmaken
			$this->ListID = "TEMP_".$this->IDString;
			$this->ListSettings = array();
		}
		
		if (strlen($_GET["PageNr"])) $this->ListSettings["PageNr"] = (int)$_GET["PageNr"];
		if (isset($_POST["ListFilter"][$this->ListID]["MaxCountPerPage"])) $this->ListSettings["MaxCountPerPage"] = (int)$_POST["ListFilter"][$this->ListID]["MaxCountPerPage"];
		
		if (strlen($_GET["OrderBy"])) {
			if (is_array($this->ListSettings["OrderBy"][0])) {
				if ($this->ListSettings["OrderBy"][0][0] == $_GET["OrderBy"]) {
					// old order by, change dir
					$this->ListSettings["OrderBy"][0][1] = ($this->ListSettings["OrderBy"][0][1] == "ASC" ? "DESC" : "ASC");
				} else {
					// new order by
					$this->ListSettings["OrderBy"][1] = $this->ListSettings["OrderBy"][0];
					$this->ListSettings["OrderBy"][0] = Array($_GET["OrderBy"], "ASC");
				}
			} else {
				// fresh order by
				$this->ListSettings["OrderBy"][0] = Array($_GET["OrderBy"], "ASC");
			}
		}
		if(is_array($_POST["ListFilter"][$this->ListID])) {
			foreach($_POST["ListFilter"][$this->ListID] AS $Variable => $Value) {
				$this->ListFilterValues[$Variable] = $Value;
			}
			$this->ListSettings["ListFilter"] = $this->ListFilterValues;
			if (!$this->NoRedirect) {
				if (function_exists('redirectto')) {
					RedirectTo($this->ListURL);
				} else {
					if (isset($this->Sess)) {
						$this->Sess->SaveToDisk();
						Header("Location: ".$this->ListURL);
						exit;
					} else {
						//redirect not supported
					}
				}
			}
		} else {
			$this->ListFilterValues = $this->ListSettings["ListFilter"];
		}
	}
	
	/**
	 * Set the Template
	 *
	 * @param	string	$Template	Template string, e.g. 'Nitro:'.NitroGetTemplateID('DefaultList')
	 * @access	public
	 */
	function SetTemplate($Template)
	{
		$this->Template = $Template;
	}
	
	/**
	 * Adds a ListRow
	 *
	 * @param	object	$ListRow Complete class ListRow object containing the row information, but undrawn
	 * @access	public
	 */
	function AddListRow($ListRow)
	{
		$rv = true;
		if(is_object($ListRow) && count($ListRow)){
			$this->Rows[$this->RowID] = $ListRow;
			if ($this->ListFilterVariables) {
				// add filter variable values if filter defined
				foreach($ListRow->Data AS $Variable => $Value) {
					$Value = ereg_replace('<[^>]*>','',$Value);
					$Key = (isset($ListRow->DataValue[$Variable]) ? $ListRow->DataValue[$Variable] : $Value);
					
					switch ($this->ListFilterVariables[$Variable]) {
						case "VALUES":
						case "VALUES_SELECT":
						case "VALUES_RADIO":
						case "VALUES_CHECK":
						case "VALUES_CHECKBOX":
							if (!is_array($this->ListFilterVariableValues[$Variable])) $this->ListFilterVariableValues[$Variable] = Array();
							if (
								(
									(isset($Value) && !in_array($Value, $this->ListFilterVariableValues[$Variable]))
									||
									(isset($Key) && array_key_exists($Key, $this->ListFilterVariableValues[$Variable]))
								)
								&&
								!$this->FilterValuesDone[$Variable]
								) {
								$this->ListFilterVariableValues[$Variable][$Value] = $Value;
							}
							break;
					}
				}
			}
			$this->RowID++;
			$rv = true;
		}else{
			$rv = false;
		}
		return $rv;
	}
	
	/**
	 * Adds a Column
	 *
	 * @param	string	$ColumnName	Name of column to be used in Header
	 * @param string	$ColumnID ID of Column to be used when linking it to links
	 * @access	public
	 */
	function AddColumn($ColumnName, $ColumnID = NULL, $Center = FALSE)
	{
		if(!strlen($ColumnName)) $ColumnName = Language("Undefined");
		if(isset($ColumnID)){
			$this->Columns[$ColumnID] = Array( $ColumnName, $Center );
		}else{
			$this->Columns[] = Array( $ColumnName, $Center );
		}
		
		return true;
	}
	
	/**
	 * Adds multiple Columns at once
	 *
	 * @param	array	$Columns array of Columns, eg. array('ID1' => 'Name1', 'ID2' => 'Name2');
	 * @see Listing::AddColumn()
	 * @access	public
	 */
	function AddColumns($Columns = array())
	{
		if(is_array($Columns) && count($Columns)){
			foreach($Columns AS $ColumnID => $ColumnName){
				$this->AddColumn($ColumnName, $ColumnID);
			}
			$rv = true;
		}else{
			$rv = false;
		}
		return $rv;
	}
	
	/**
	 * Sets the width for 1 or more columns at once
	 *
	 * @param	mixed $ColumnWidths array of Columnwidths, eg. array('ID1' => 'Width1', 'ID2' => 'Width2') OR str Width of 1 column
	 * @param string	$ColumnKey ColumnID, only used if given together with a width
	 * @access	public
	 */
	function SetColumnWidth($ColumnWidths = array(), $ColumnKey = NULL)
	{
		$rv = true;
		if(is_array($ColumnWidths) && count($ColumnWidths)){
			foreach($ColumnWidths AS $ColumnKey => $Width){
				$this->ColumnWidths[$ColumnKey] = $Width;
			}
		}elseif (strlen($ColumnWidths) && $ColumnKey) {
			$this->ColumnWidths[$ColumnKey] = $ColumnWidths;
			$rv = true;
		}else{
			$rv = false;
		}
		return $rv;
	}
	
	/**
	 * Sets the alignment for 1 or more columns at once
	 *
	 * @param	mixed $ColumnAligns array of Columnaligns, eg. array('ID1' => 'Align1', 'ID2' => 'Align2')
	 * @param string	$ColumnKey ColumnID, only used if given together with a width
	 * @access	public
	 */
	function SetColumnAlignment($ColumnAligns = array(), $ColumnKey = NULL)
	{
		if (is_array($ColumnAligns) && count($ColumnAligns)) {
			foreach ($ColumnAligns AS $ColumnKey => $Align) {
				$this->ColumnAligns[$ColumnKey] = $Align;
			}
			$rv = true;
		} elseif (strlen($ColumnAligns) && $ColumnKey) {
			$this->ColumnAligns[$ColumnKey] = $ColumnAligns;
			$rv = true;
		} else {
			$rv = false;
		}
		
		return $rv;
	}
	
	/**
	 * Set the type of filter to be used for a column
	 *
	 * @param	string	$Variable ColumnID of given Column to be set for
	 * @param string	$Method Method to be used in the filter, eg, VALUES, SELECT, RADIO
	 * @param array		$Values if given the values will be used to fill the filters
	 * @access	public
	 */
	function SetFilterVariable($Variable, $Method, $Values = NULL)
	{
		$Method = strtoupper($Method);
		switch ($Method) {
			case "VALUES":
			case "VALUES_SELECT":
			case "VALUES_RADIO":
			case "VALUES_CHECK":
			case "VALUES_CHECKBOX":
				$this->ListFilterVariables[$Variable] = $Method;
				if (is_array($Values) && count($Values)) {
					foreach ($Values AS $key => $Value) {
						$this->ListFilterVariableValues[$Variable][$key] = $Value;
					}
					$this->FilterValuesDone[$Variable] = true;
				} else {				
					if (count($this->Rows)) {
						// rows alread added, add values from rows
						foreach($this->Rows AS $Data) {
							$Value = $Data->Data[$Variable];
							if (isset($Data->DataValue[$Variable])) $Value = $Data->DataValue[$Variable];
							$Value = ereg_replace('<[^>]*>','',$Value);// rip all html tags
							if (!is_array($this->ListFilterVariableValues[$Variable])) $this->ListFilterVariableValues[$Variable] = Array();
							if ($Value && !in_array($Value, $this->ListFilterVariableValues[$Variable])) {
								$this->ListFilterVariableValues[$Variable][$Value] = $Value;
							}
						}
					}
				}
				break;
			case "SELECT":
				$this->ListFilterVariables[$Variable] = $Method;
				$this->ListFilterVariableValues[$Variable] = $Values;
				break;
			case "RADIO":
				$this->ListFilterVariables[$Variable] = $Method;
				$this->ListFilterVariableValues[$Variable] = $Values;
				break;
			default:
				$this->ListFilterVariables[$Variable] = "TEXT";
				break;				
		}
	}
	
	/**
	 * Add an action
	 *
	 * @param	string $ID ActionID by which links will be added to
	 * @param string	$Lable Action lable, if not given, ID will be used
	 * @access	public
	 */
	function AddAction($ID, $Lable = NULL)
	{
		if (!isset($Lable)) $Lable = $ID;
		$ID = strtoupper($ID);
		$this->Actions[$ID] = $Lable;
	}
	
	/**
	 * Adds multiple actions at once
	 *
	 * @param	array $Actions adds actions, eg. array('aID1' => 'Action1', 'aID2' => 'Action2');
	 * @access	public
	 */
	function AddActions($Actions = array())
	{
		if(is_array($Actions) && count($Actions)){
			foreach($Actions AS $ActionID => $ActionLable){
				if (is_int($ActionID)) $ActionID = $ActionLable;
				$this->AddAction($ActionID, $ActionLable);
			}
			$rv = true;
		}else{
			$rv = false;
		}
		return $rv;
	}
	
	/**
	 * Adds list action (usually a link above the listing to for example Add an item)
	 *
	 * @param	string $Type Action description usually displayed inside the link
	 * @param string $URL The URL where the link refers to
	 * @param string $onClickAction onClickAction used, if you use 'return false' at the end of the onClickAction, the browser will not use the URL link
	 * @access	public
	 */
	function AddListAction($Type, $URL, $onClickAction = "", $Style = FALSE, $Title = FALSE)
	{
		$tmp["Type"] = $Type;
		$tmp["URL"] = $URL;
		$tmp["onClickAction"] = $onClickAction;
		$tmp["Style"] = $Style;
		$tmp["Title"] = $Title;
		$this->ListActions[] = $tmp;
	}
	
	/**
	 * Sort array of row objects
	 *
	 * @param	object	$RowObject1	Object of row 1
	 * @param	object	$RowObject2	Object of row 2
	 * @static
	 * @access private
	 */
	function SortRows($RowObject1, $RowObject2)
	{
		global $NitroCurrentListSettings;
		$ListSettings =& $NitroCurrentListSettings;

		// sort array of row objects ...

		$Sort1 =& $ListSettings["OrderBy"][0][0];
		$Sort2 =& $ListSettings["OrderBy"][1][0];
		if (is_int($Sort1)) {
			// no id given in columns, using column id
			$keys = array_keys($RowObject1->Data);
			$Sort1 = $keys[$Sort1];
		}
		if (is_int($Sort2)) {
			// no id given in columns, using column id
			$keys = array_keys($RowObject1->Data);
			$Sort2 = $keys[$Sort2];
		}
		$Dir1 =& $ListSettings["OrderBy"][0][1];
		$Dir2 =& $ListSettings["OrderBy"][1][1];

		if ($RowObject1->Data[$Sort1] == $RowObject2->Data[$Sort1]) {
			// identical rows, use sort 2....
			if ($RowObject1->Data[$Sort2] == $RowObject2->Data[$Sort2]) {
				// again identical, leave order
				return 1;
			} else {
				// sort by Sort2
				$Sort = $Sort2;
				$Dir = $Dir2;
			}
		} else {
			// sort by Sort1
			$Sort = $Sort1;
			$Dir = $Dir1;
		}

		// do the real sorting
		if (strtoupper($RowObject1->Data[$Sort]) > strtoupper($RowObject2->Data[$Sort])) {
			// 1 > 2
			if ($Dir == "ASC") return 1;
			else return -1;
		} else {
			// 1 < 2
			if ($Dir == "ASC") return -1;
			else return 1;
		}
	}
	
	/**
	 * Remove rows based on filtersettings
	 *
	 * @static
	 * @access private
	 */
	function FilterRows()
	{
		if (is_Array($this->ListFilterValues) && count($this->ListFilterValues)) {
			$FilteredRows = Array();
			foreach($this->Rows AS $Key => $RowObj) {
				foreach($this->ListFilterValues AS $Variable => $Value) {
					if (isset($RowObj->DataValue[$Variable])) $RowObj->Data = $RowObj->DataValue;
					$Value = ereg_replace('<[^>]*>','',$Value);
					if ($Value && isset($RowObj->Data[$Variable]) && !@eregi($Value, $RowObj->Data[$Variable])) {
						// remove row, does not contain string
						$this->hiddenRows[] = $this->Rows[$Key];
						unset($this->Rows[$Key]);
					}
				}
			}
		}
	}
	
	function setColumnLengths()
	{
		foreach ($this->Columns as $ColumnID => $ColumnName) {
			foreach($this->Rows AS $Key => $RowObj) {
				//set maximum strlen per column per variable for use in setColumnWidths later on if splitTable is true
				$Length = (int)strlen(ereg_replace('<[^>]*>','',$RowObj->Data[$ColumnID]));
				if ($Length > $this->ColumnLengths[$ColumnID] || !isset($this->ColumnLengths[$ColumnID])) $this->ColumnLengths[$ColumnID] = $Length;
			}
		}
	}
	
	/**
	 * Show or hide rows based on page selection system
	 *
	 * @static
	 * @access private
	 */
	function FilterRowsForPage()
	{
		$PageNr = (int)$this->ListSettings["PageNr"];
		$MaxCountPerPage = (isset($this->ListSettings["MaxCountPerPage"]) ? (int)$this->ListSettings["MaxCountPerPage"] : $this->initialMaxCountPerPage);
		
		$Pages = array();
		if ($MaxCountPerPage > 0) {
			$CountStart = ($PageNr * $MaxCountPerPage) + 1;
			$CountEnd = ($PageNr + 1) * $MaxCountPerPage;
			$i = 1;
			if ($CountStart > count($this->Rows)) {
				//is gefilterd of iets verandert, dus resetten
				$this->ListSettings["PageNr"] = 0;
				$CountStart = 1;
				$CountEnd = $MaxCountPerPage;
			}
			foreach($this->Rows AS $Key => $RowObj) {
				if ($i > $CountEnd || $i < $CountStart) {
					// remove row, valt buiten bereik
					$this->hiddenRows[] = $this->Rows[$Key];
					unset($this->Rows[$Key]);
				}
				$i++;
			}
			$MaxPageNr = ceil($i / $MaxCountPerPage);
			
			for ($i = 0; $i < $MaxPageNr; $i++) {
				$Pages[$i] = ($i + 1);
			}
		}
		
		$MaxCountSelect = "<SELECT NAME=\"ListFilter[".$this->ListID."][MaxCountPerPage]\" STYLE=\"width: 45px\" STYLE=\"vertical-align: middle\" onChange=\"this.form.submit()\">";
		$MaxCountSelect.= "<OPTION VALUE=\"0\">".Language("All")."</OPTION>";
		for ($i = 10; $i <= 100; $i = $i + 10) {
			$SEL = "";
			if ($MaxCountPerPage == $i) $SEL = " SELECTED";
			$MaxCountSelect.= "<OPTION VALUE=\"".$i."\"".$SEL.">".$i."</OPTION>";
		}
		$MaxCountSelect.= "</SELECT>";
		
		return array("Pages" => $Pages, "CountSelect" => $MaxCountSelect);
	}
	
	/**
	 * Returns array containing all the rows in the order they have been filtered and/or sorted, has to be called AFTER Draw()
	 *
	 */
	function returnRowArray()
	{
		$tmp = array();
		foreach ($this->Rows AS $rowObject) {
			$tmp[] = $rowObject->rowID;
		}
		return $tmp;
	}
	
	/**
	 * Draws Listing
	 *
	 * @static
	 * @access private
	 */
	function Draw()
	{
		global $__NSess;
		
		//omdat DrawFormTags tegenwoordig default niet geset wordt, aanzetten indien pages of filters gebruikt worden
		if (!isset($this->DrawFormTags)) {
			if ($this->EnableFilter || ((int)$this->UsePages && count($this->Rows) > 20)) {
				$this->DrawFormTags = true;
			} else {
				$this->DrawFormTags = false;
			}
		}
		
		$NitroTemplate = new NitroTemplate();
		
		$NitroTemplate->assign("ListID", $this->ListID);
		$NitroTemplate->assign("URL", $_SERVER["REQUEST_URI"]);
		//$NitroTemplate->assign("URL", $_SERVER["SCRIPT_NAME"].'?'.$_SERVER['QUERY_STRING']);
		$NitroTemplate->assign("Title", $this->Title);
		$NitroTemplate->assign("inDiv", $this->inDiv);
		$NitroTemplate->assign("OrderBy", $this->ListSettings["OrderBy"]);
		$NitroTemplate->assign("ListURL", $this->ListURL);
		$NitroTemplate->assign("Columns", $this->Columns);
		$NitroTemplate->assign("AddNoBreaks", $this->AddNoBreaks);
		$NitroTemplate->assign("DrawFormTags", $this->DrawFormTags);
		$NitroTemplate->assign("EnableFilter", $this->EnableFilter);
		if ($this->ListID && is_array($this->ListSettings["OrderBy"][0]) && $this->UseListSort) {
			global $NitroCurrentListSettings;
			$NitroCurrentListSettings = $this->ListSettings;
			usort($this->Rows, array("Listing", "SortRows"));
		}
		
		if ($this->EnableFilter) {
			$NitroTemplate->assign("ListFilterVariables", $this->ListFilterVariables);
			foreach($this->ListFilterVariableValues AS $Key => $Row) {
				asort($this->ListFilterVariableValues[$Key]);
			}
			$NitroTemplate->assign("ListFilterVariableValues", $this->ListFilterVariableValues);
			$NitroTemplate->assign("ListFilterValues", $this->ListFilterValues);
			// filter rows to show in list
			$this->FilterRows();
		}
		
		if ((int)$this->UsePages && count($this->Rows) > 20) {
			$NitroTemplate->assign("UsePages", TRUE);
			$NitroTemplate->assign("ShowMaxCountSelection", $this->ShowMaxCountSelection);
			$PageData = $this->FilterRowsForPage();
			$NitroTemplate->assign("MaxCountSelect", $PageData["CountSelect"]);
			if(count($PageData["Pages"]) > 1) {
				$NitroTemplate->assign("AllPages", $PageData["Pages"]);
				$NitroTemplate->assign("CurrentPageNr", (int)$this->ListSettings["PageNr"]);
			}
		}
		
		if ($this->splitTable) {
			$NitroTemplate->assign("splitTable", $this->splitTable);
			$NitroTemplate->assign("columnNumberSplit", $this->columnNumberSplit);
			$this->setColumnLengths();
			foreach ($this->Columns AS $ColumnID => $ColumName) {
				if (!$this->ColumnWidths[$ColumnID]) $this->ColumnWidths[$ColumnID] = (($this->ColumnLengths[$ColumnID] * 6) + 20)."px";
			}
		}
		$NitroTemplate->assign("ColumnWidths", $this->ColumnWidths);
		$NitroTemplate->assign("ColumnAligns", $this->ColumnAligns);
		
		$NitroTemplate->assign("Rows", $this->Rows);
		if($this->showHiddenRows) $NitroTemplate->assign("hiddenRows", $this->hiddenRows);
		$NitroTemplate->assign("ListActions", $this->ListActions);	
		$NitroTemplate->assign("Actions", $this->Actions);	
		
		//MISC
		$NitroTemplate->assign("ListDivID", $this->ListDivID);	
		$NitroTemplate->assign("TableWidth", $this->TableWidth);	
		$NitroTemplate->assign("AlignData", $this->AlignData);	
		$NitroTemplate->assign("RepeatHeader", $this->RepeatHeader);
		$NitroTemplate->assign("EnableRowHighlighting", $this->EnableRowHighlighting);
		$NitroTemplate->assign("EnableColumnHighlighting", $this->EnableColumnHighlighting);
		if ($this->SetScrollPosition) {
			$NitroTemplate->assign("ScrollTop", array_key_exists('Scroll', $__NSess) ? (int)$__NSess->Scroll[$this->ListID]["Top"] : 0);	
			$NitroTemplate->assign("ScrollLeft", array_key_exists('Scroll', $__NSess) ? (int)$__NSess->Scroll[$this->ListID]["Left"] : 0);	
		}
		
		// Create List
		$rv = $NitroTemplate->fetch($this->Template);

		return $rv;
	}
}

/**
 * The Listing row class
 *
 * This class should only by used by the listing class
 *
 * @package	Nitro
 * @subpackage	Libraries
 * @access	public
 * @see Listing
 */
class ListingRow {
	var $Data = array();
	var $DataValue = array();
	var $ColumnID = 0;
	
	var $ActionName = array();
	var $ActionURL = array();
	var $ActionOnClick = array();
	var $ActionStyle = array();
	
	/**
	 * ListingRow constructor
	 *
	 * @access	public
	 */
	function ListingRow($rowID = 0)
	{
		$this->rowID = $rowID;
	}
	
	/**
	 * Adds data to the ListingRow object
	 *
	 * @param	mixed	$DataRow String containing ColumnID OR array containing data (eg array('cID1' => 'Data1', 'cID2' => 'Data2')) in which the value can be an array as well with array($Value, $Lable), e.g. array('cID1' => array(1 => 'Data1'), 'cID2' => array(2 => 'Data2')))
	 * @param	string $Value Value of current column being added, only used if $DataRow given is a string
	 * @access	public
	 */
	function AddData($DataRow = array(), $Value = NULL)
	{
		if(is_array($DataRow) && count($DataRow)){
			foreach($DataRow AS $Key => $Data){
				if (is_array($Data)) {
					$this->Data[$Key] = reset($Data);
					$this->DataValue[$Key] = key($Data);
				} else {
					$this->Data[$Key] = $Data;
				}
			}
			$rv = true;
		} elseif ($DataRow && isset($Value)) {
			if (is_array($Value)) {
				$this->DataValue[$DataRow] = $Value[0];
				$this->Data[$DataRow] = $Value[1];
			} else {
				$this->Data[$DataRow] = $Value;
			}
			$rv = true;
		} else {
			$rv = false;
		}
		return $rv;
	}
	
	/**
	 * Defines an action for the current RowObject
	 *
	 * @param	string	$ActionID ID of the Action Column being set
	 * @param	string	$Name Name that's gonna be displayed, often an Image is used here
	 * @param string	$URL URL that Action points to
	 * @param string	$onClickAction onClick action to be taken when clicked on, if 'return false' is added the URL will not be executed
	 * @access	public
	 */
	function SetAction($ActionID, $Name, $URL = "", $onClickAction = "", $Style = FALSE, $Center = FALSE, $Title = FALSE, $NoLink = FALSE)
	{
		$ActionID = strtoupper($ActionID);
		//$this->Action[$ActionID] = array("Name" => $Name, "URL" => $URL, "onClickAction" => $onClickAction);
		$this->ActionName[$ActionID] = $Name;
		$this->ActionURL[$ActionID] = $URL;
		$this->ActionOnClick[$ActionID] = $onClickAction;
		$this->ActionStyle[$ActionID] = $Style;
		$this->ActionCenter[$ActionID] = $Center;
		$this->ActionTitle[$ActionID] = $Title;
		$this->ActionNoLink[$ActionID] = $NoLink;
	}

	/*
	function Draw($ShowAddColumn, $ShowEditColumn, $ShowDeleteColumn)
	{
		//THIS IS DONE IN THE DRAWLIST TEMPLATE
		$rv = "<TR><TD>Not ready</TD></TR>";
		
		$NitroTemplate = new NitroTemplate();
		
		$NitroTemplate->assign("Data", $this->Data);
		if($ShowAddColumn) $NitroTemplate->assign("AddURL", $this->AddURL);
		if($ShowEditColumn) $NitroTemplate->assign("EditURL", $this->EditURL);
		if($ShowDeleteColumn) $NitroTemplate->assign("DeleteURL", $this->DeleteURL);
		
		// Create List
		$rv = $NitroTemplate->fetch($this->Template);
		
		return $rv;
	}
	*/
}
?>
Return current item: OpenNitro