Generic List

Definitions

 * id - mandatory, an id to identify the list
 * columns - mandatory, an associative array of columns, the key of each column must be unique (of course) the value is an array of values:
 * sort - optional, an associative array that holds the rules to sort the column, it can contain:
 * default - mandatory, the default sorting rule;
 * reverse - mandatory, the reverse sorting rule;
 * header - mandatory, an associative array describing the header of the column, it can contain the following indexes:
 * eval - optional (alternative to value), php code that will be passed to the php function eval;
 * value - optional (alternative to eval), a value (usually a string) that will be displayed as column header;
 * class - optional, a css class to use for the header of the column;
 * style - optional, a css style to use for the header of the column;
 * colspan - optional, a number that will be used for the colspan attribute of the header;
 * data - mandatory, an associative array that holds the information to display the information, it can contain:
 * db - optional (alternative to db_htmlsafe, sprintf, function, eval, value), the easiest way, a value straight from the database;
 * db_htmlsafe - optional (alternative to db, sprintf, function, eval, value), similar to db, but make the value HTML safe;
 * sprintf' - optional (alternative to db, db_htmlsafe, function, eval, value), uses vsprintf to prepare the value, it must be in the form of an associative array containing:
 * params - mandatory, pairs of values: the key holds the string to be used as parameter of vsprintf and the value is a boolean that defines if the key must be html safe or not.
 * format - mandatory, the format of the string (the first parameter of vsprintf).
 * function - optional (alternative to db, db_htmlsafe, sprintf, eval, value), a php function that returns the value that should be displayed;
 * eval - optional (alternative to db, db_htmlsafe, sprintf, function, value), code that is passed to the php eval function;
 * value - optional (alternative to db, db_htmlsafe, sprintf, function, eval), a literal value;
 * if none from db, db_htmlsafe, sprintf, function, eval, value is present an empty string will be displayed;
 * comma_format - optional, boolean if true the value is passed to the function comma_format;
 * timeformat - optional, boolean if true the value is passed to the function timeformat;
 * class - optional, a css class to use for the column;
 * style - optional, a css style to use for the column;


 * data_check - optional (2.1 only), an associative array, the key can be class or style, the value is a function that checks the value and return a class or a style to be used at the row (tr) level of the table.
 * items_per_page - optional (mandatory if get_count or base_href are present), the number of items to show in each page of the table;
 * get_count - an associative array that allows find the number of elements of the list, it can contain the following parameters:
 * file - optional a file (including path) to include;
 * function - mandatory, the function that counts the elements and return the value;
 * params - optional, an array of parameters that will be passed to the function;
 * base_href - optional (mandatory if items_per_page is present), the href to be user to construct the page index;
 * get_items - optional, an associative array that allows find the values of elements of the list, it can contain the following parameters:
 * file - optional a file (including path) to include;
 * function - mandatory, the function that returns the values of the elements;
 * params - optional, an array of parameters that will be passed to the function;
 * title - optional, the title of the table
 * start_var_name - optional, the starting variable name (not so sure)
 * default_sort_col - optional, the default column used to sort the table;
 * width - optional, the width of the table;
 * request_vars - optional, an associative array of values that can be taken from $_REQUEST to define the sorting (no idea what I'm writing), it can contain:
 * sort - optional, a $_GET variable name that define the column to sort;
 * desc - optional, a $_GET variable name to define if the column should be sorted ascending or descending;
 * form - optional, an associative array of data to create a form, it can contain:
 * hidden_fields - optional, an associative array in the form $key => $value that will be translated in hidden fields where $key will be the name of the field and $value the value (it contains by default the session data).
 * token - optional (2.1 only), a token name to be included as hidden field of the form;
 * include_start - optiolnal, boolean, if true include the starting page as hidden field (requires start_var_name);
 * include_sort - optional, booloean, if true add the parameter so that sorting remains the same after submitting;
 * no_items_label - optional, a string to show when there are no items in the list;
 * no_items_align - optional, value for the HTML property align (left, right, center, justify);
 * additional_rows - optional, an associative array or arrays that can contain HTML elements to be presented in different places on the list (supported positions are: top_of_list, after_title, above_column_headers, below_table_data, bottom_of_list), the position is the index of the associative array, than each array inside a certain position can contain:
 * value - mandatory, the HTML that will be inserted in the specified position;
 * class - optional, the name of a css class to style the element;
 * style - optional, a css in-line style that will be applied to the element;
 * javascript - optional, raw javascript that will be inserted at the end of the list;
 * list_menu - optional, an associative array that holds all the data to create a menu:
 * show_on - optional, where the menu should be created (can be both, top, bottom);
 * style - mandatory, can be button or tabs;
 * position - mandatory, the position of the tabs/buttons, it can be left or right (default is left);
 * links - mandatory, an array of associative data with the information to create the menu:
 * is_selected - mandatory, boolean, true if the menu item is selected;
 * href - mandatory, the url to be used for the menu;
 * label - mandatory, the name of the menu;

Calling the function
// Now that we have all the options, create the list. require_once($sourcedir . '/Subs-List.php'); createList($listOptions);

Setting up the template
$context['sub_template'] = 'show_list'; $context['default_list'] = 'member_list'; // this must be the same as the id in $listOptions