FreePBX API: Modules GUI API

This Tables API is implemented in Modules API version 2. Part of the ApiDocs.

Intro

This is a fairly simple class that generates tables based on PEAR DB result sets. At a minimum, toHtml() or showHtml() needs to be called, but usually you will call setIdField() and possibly setTitles(). setImagePrefix() will use different IconSets for the buttons.

API

class table {
	/** Constructor
	 * @param DB_result  The database result to use
	 */
	function table($dbresult) 
	
	/** Set the titles for the table
	 * Titles will be generated automatically if this function is not called
	 * @param  array   The assoc array containing field=>title
	 */
	function setTitles($fields) 
	
	/** changes to use the set of "$prefix_edit.png" _delete, etc images.
	 * @param  string   The prefix to use
	 */
	function setImagePrefix($prefix) 
	
	/** Sets the field to be used as an identifier, and if that field is displayed
	 * If not called, either 'id' or (if no id field exists) the first field will be used, 
	 * and it will not be displayed.
	 * @param  string   The name of the field
	 * @param  bool     If the field should be displayed in the list
	 */
	function setIdField($fieldname = 'id', $display = false) 

	/** Returns the html representation of the table
	 */
	function toHtml() 
	
	/** Displays the HTML of the table 
	 */
	function show() 
}

Example use

class ampusers { 
	function index() {
		$table = new table(core_ampusers_list());
		$table->setIdField('username', true); // set and display id field
		$table->setImagePrefix('user');
		$table->show();
	}
}

Output is attached

Attachments

Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads