>> all the above functions change for every table // >>> the calling script should include the correct versions of them. // NavMenus() // sql() // the class also assumes that the following files already exist: // print.gif // delete.gif // update.gif // search.gif // cancel_search.gif // insert.gif // asc.gif // desc.gif // scroll_bar.gif // scroll_box.gif // scroll_next.gif // scroll_previous.gif // the class assumes the following CSS classes have been defined: // Error // TableTitle // TableHeader // TextBox // TableBody // TableBodyNumeric // TableBodySelectedNumeric // TableBodySelected // TableFooter // SelectedOption var $Query, $ColWidth, // array of field widths $DataHeight, $AllowSelection, $AllowDelete, $AllowInsert, $AllowUpdate, $AllowFilters, $AllowSavingFilters, $AllowSorting, $AllowNavigation, $AllowPrinting, $HideTableView, $AllowCSV, $CSVSeparator, $QuickSearch, // 0 to 3 $RecordsPerPage, $ScriptFileName, $RedirectAfterInsert, $TableTitle, $PrimaryKey, // Templates variables $Template, $SelectedTemplate, $ShowTableHeader, // 1 = show standard table headers $ShowRecordSlots, // 1 = show empty record slots in table view // End of templates variables $HTML; // generated html after calling Render() function DataList() // Constructor function { $this->DataHeight = 150; $this->AllowSelection = 1; $this->AllowDelete = 1; $this->AllowInsert = 1; $this->AllowUpdate = 1; $this->AllowFilters = 1; $this->AllowNavigation = 1; $this->AllowPrinting = 1; $this->HideTableView = 0; $this->QuickSearch = 0; $this->AllowCSV = 0; $this->CSVSeparator = ","; $this->HighlightColor = '#FFE4E1'; // default highlight color $this->RecordsPerPage = 10; $this->Template = ''; $this->HTML = ""; } function Render() { // get post and get variables global $HTTP_SERVER_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS, $_SERVER, $Translation; $FiltersPerGroup = 4; if($HTTP_SERVER_VARS["REQUEST_METHOD"] == "GET") { $SortField = $HTTP_GET_VARS["SortField"]; $SortDirection = $HTTP_GET_VARS["SortDirection"]; $FirstRecord = $HTTP_GET_VARS["FirstRecord"]; $ScrollUp_y = $HTTP_GET_VARS["ScrollUp_y"]; $ScrollDn_y = $HTTP_GET_VARS["ScrollDn_y"]; $Previous_x = $HTTP_GET_VARS["Previous_x"]; $Next_x = $HTTP_GET_VARS["Next_x"]; $Filter_x = $HTTP_GET_VARS["Filter_x"]; $SaveFilter_x = $HTTP_GET_VARS["SaveFilter_x"]; $NoFilter_x = $HTTP_GET_VARS["NoFilter_x"]; $CancelFilter = $HTTP_GET_VARS["CancelFilter"]; $ApplyFilter = $HTTP_GET_VARS["ApplyFilter"]; $Search_x = $HTTP_GET_VARS["Search_x"]; $SearchString = $HTTP_GET_VARS["SearchString"]; $CSV_x = $HTTP_GET_VARS["CSV_x"]; $FilterAnd = $HTTP_GET_VARS["FilterAnd"]; $FilterField = $HTTP_GET_VARS["FilterField"]; $FilterOperator = $HTTP_GET_VARS["FilterOperator"]; $FilterValue = $HTTP_GET_VARS["FilterValue"]; $Print_x = $HTTP_GET_VARS["Print_x"]; $SelectedID = $HTTP_GET_VARS["SelectedID"]; $insert_x = $HTTP_GET_VARS["insert_x"]; $update_x = $HTTP_GET_VARS["update_x"]; $delete_x = $HTTP_GET_VARS["delete_x"]; $deselect_x = $HTTP_GET_VARS["deselect_x"]; } else { $SortField = $HTTP_POST_VARS["SortField"]; $SortDirection = $HTTP_POST_VARS["SortDirection"]; $FirstRecord = $HTTP_POST_VARS["FirstRecord"]; $ScrollUp_y = $HTTP_POST_VARS["ScrollUp_y"]; $ScrollDn_y = $HTTP_POST_VARS["ScrollDn_y"]; $Previous_x = $HTTP_POST_VARS["Previous_x"]; $Next_x = $HTTP_POST_VARS["Next_x"]; $Filter_x = $HTTP_POST_VARS["Filter_x"]; $SaveFilter_x = $HTTP_POST_VARS["SaveFilter_x"]; $NoFilter_x = $HTTP_POST_VARS["NoFilter_x"]; $CancelFilter = $HTTP_POST_VARS["CancelFilter"]; $ApplyFilter = $HTTP_POST_VARS["ApplyFilter"]; $Search_x = $HTTP_POST_VARS["Search_x"]; $SearchString = $HTTP_POST_VARS["SearchString"]; $CSV_x = $HTTP_POST_VARS["CSV_x"]; $FilterAnd = $HTTP_POST_VARS["FilterAnd"]; $FilterField = $HTTP_POST_VARS["FilterField"]; $FilterOperator = $HTTP_POST_VARS["FilterOperator"]; $FilterValue = $HTTP_POST_VARS["FilterValue"]; $Print_x = $HTTP_POST_VARS["Print_x"]; $SelectedID = $HTTP_POST_VARS["SelectedID"]; $insert_x = $HTTP_POST_VARS["insert_x"]; $update_x = $HTTP_POST_VARS["update_x"]; $delete_x = $HTTP_POST_VARS["delete_x"]; $deselect_x = $HTTP_POST_VARS["deselect_x"]; } // insure authenticity of user inputs: if(!$this->AllowSelection) { $insert_x = ""; $update_x = ""; $delete_x = ""; $deselect_x = ""; } if(!$this->AllowDelete) { $delete_x = ""; } if(!$this->AllowInsert) { $insert_x = ""; } if(!$this->AllowUpdate) { $update_x = ""; } if(!$this->AllowFilters) { $Filter_x = ""; } if(!$this->AllowPrinting) { $Print_x = ""; } if(!$this->QuickSearch) { $SeachString = ""; } if(!$this->AllowCSV) { $CSV_x = ""; } // retouch query to avoid case matching problems $this->Query = eregi_replace(" WHERE ", " where ", $this->Query); $this->Query = eregi_replace("SELECT ", "select ", $this->Query); $this->Query = eregi_replace(" FROM ", " from ", $this->Query); $this->Query = eregi_replace(" AS ", " as ", $this->Query); $this->HTML .= ""; $this->HTML .= "
"; @mysql_close(); // Das ist Alles! } } /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// class DataCombo { var $Query, // Only the first two fields of the query are used. // The first field is treated as the primary key (data values), // and the second field is the displayed data items. $Class, $Style, $SelectName, $FirstItem, // if not empty, the first item in the combo with value of "" $SelectedData, // a value compared to first field value of the query to select // an item from the combo. $ItemCount, // this is returned. It indicates the number of items in the combo. $HTML, // this is returned. The combo html source after calling Render(). $MatchText; // will store the parent caption value of the matching item. function DataCombo() // Constructor function { $this->FirstItem = ""; $this->HTML = ""; $this->Class = "Option"; $this->MatchText = ""; } function Render() { $result = sql($this->Query); $this->ItemCount = mysql_num_rows($result); $this->HTML .= ""; } } /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// class Combo { // The Combo class renders a drop down combo // filled with elements in an array ListItem[] // and associates each element with data from // an array ListData[], and optionally selects // one of the items. var $ListItem, // array of items in the combo $ListData, // array of items data values $Class, $SelectedClass, $Style, $SelectName, $SelectedData, $MatchText, // will store the text value of the matching item. $ListType, // 0: drop down combo, 1: list box, 2: radio buttons $ListBoxHeight, // if ListType=1, this is the height of the list box $RadiosPerLine, // if ListType=2, this is the number of options per line $AllowNull, $HTML; function Combo() // Constructor function { $this->Class = "Option"; $this->SelectedClass = "SelectedOption"; $this->HTML = ""; $this->ListType = 0; $this->ListBoxHeight = 10; $this->RadiosPerLine = 1; $this->AllowNull = true; } function Render() { $ArrayCount = count($this->ListItem); if($ArrayCount > count($this->ListData)) { $this->HTML .= "Invalid Class Definition"; return 0; } if($this->ListType!=2){ $this->HTML .= ""; }else{ global $Translation; $separator = " "; if($this->AllowNull){ $this->HTML .= "SelectName\" value=\"\" ".($this->SelectedData==''?'checked':'')."> ".$Translation['none']; $this->HTML .= ($this->RadiosPerLine==1 ? "