| 1 | <?php | 
| 2 |  | 
| 3 | /** | 
| 4 | * This example illustrates the use of the | 
| 5 | * DataList object classes.  This object | 
| 6 | * can show a list of data from any data source | 
| 7 | * and have any GUI layout and provide the | 
| 8 | * features of: | 
| 9 | * searching, sorting, paging of the data. | 
| 10 | * | 
| 11 | * This page shows the Data coming a CSV | 
| 12 | * (comma seperated values) file on disk. | 
| 13 | * | 
| 14 | * $Id: widget7.php,v 1.7 2004/03/24 22:52:09 hemna Exp $ | 
| 15 | * | 
| 16 | * @author Walter A. Boring IV <waboring@buildabetterweb.com> | 
| 17 | * @package phpHtmlLib | 
| 18 | * @subpackage widget-examples | 
| 19 | * @version 2.0 | 
| 20 | * | 
| 21 | */ | 
| 22 |  | 
| 23 | /** | 
| 24 | * Include the phphtmllib libraries | 
| 25 | * | 
| 26 | */ | 
| 27 | include_once("includes.inc"); | 
| 28 | include_once("db_defines.inc"); | 
| 29 |  | 
| 30 | include_once($phphtmllib."/widgets/data_list/includes.inc"); | 
| 31 | include_once($phphtmllib."/widgets/data_list/CSVFILEDataListSource.inc"); | 
| 32 |  | 
| 33 |  | 
| 34 | /** | 
| 35 | * This class shows how to use the data coming | 
| 36 | * from a CSV Formatted file | 
| 37 | * | 
| 38 | */ | 
| 39 | class csvfilelist extends DefaultGUIDataList { | 
| 40 |  | 
| 41 | function get_data_source() { | 
| 42 | $source = new CSVFILEDataListSource("test.csv"); | 
| 43 | $this->set_data_source( &$source ); | 
| 44 | } | 
| 45 |  | 
| 46 | function user_setup() { | 
| 47 | $this->add_header_item("First Name", "200", "FName", SORTABLE, SEARCHABLE); | 
| 48 | $this->add_header_item("Last Name", "200", "LName", SORTABLE, SEARCHABLE); | 
| 49 | $this->add_header_item("Email", "200", "Email", SORTABLE, SEARCHABLE, "center"); | 
| 50 |  | 
| 51 | //turn on the 'collapsable' search block. | 
| 52 | //The word 'Search' in the output will be clickable, | 
| 53 | //and hide/show the search box. | 
| 54 | $this->_collapsable_search = TRUE; | 
| 55 |  | 
| 56 | //lets add an action column of checkboxes, | 
| 57 | //and allow us to save the checked items between pages. | 
| 58 | $this->add_action_column('checkbox', 'FIRST', 'Email'); | 
| 59 |  | 
| 60 | //we have to be in POST mode, or we could run out | 
| 61 | //of space in the http request with the saved | 
| 62 | //checkbox items | 
| 63 | $this->set_form_method('POST'); | 
| 64 |  | 
| 65 | //set the flag to save the checked items | 
| 66 | //between pages. | 
| 67 | $this->save_checked_items(TRUE); | 
| 68 | } | 
| 69 |  | 
| 70 | function actionbar_cell() { | 
| 71 | //don't actually do anything. | 
| 72 | //just show how to add a button | 
| 73 | return $this->action_button('Test',''); | 
| 74 | } | 
| 75 | } | 
| 76 |  | 
| 77 |  | 
| 78 | //create the page object | 
| 79 | $page = new HTMLPageClass("phpHtmlLib Widgets - DataList Example", | 
| 80 | XHTML_TRANSITIONAL); | 
| 81 |  | 
| 82 | //enable output debugging. | 
| 83 | if (isset($_GET['debug'])) { | 
| 84 | $page->set_text_debug( TRUE ); | 
| 85 | } | 
| 86 |  | 
| 87 | //add the css | 
| 88 | $page->add_head_css( new DefaultGUIDataListCSS ); | 
| 89 |  | 
| 90 | //build the csv file data list object. | 
| 91 | $csvlist = new csvfilelist("CSV File list", 600, "LName"); | 
| 92 |  | 
| 93 | $page->add( html_span("font10", "View the source ", | 
| 94 | html_a("test.csv", "test.csv file.")), | 
| 95 | html_br(2), | 
| 96 | $csvlist ); | 
| 97 |  | 
| 98 | print $page->render(); | 
| 99 | ?> |