viewsLibrary for work with views and tables. Release: $Name: $ Edit by: $Author: mcbig $ Edit Date: $Date: 2007/01/02 16:13:12 $ Version: $Revision: 1.2 $ Summary | Library for work with views and tables. | | | | buffer for main view (main space) on page | | buffer for left panel, it’s usable for menu for example | | buffer for right panel, it’s usable for RSS channels for example | | | | Adds string to global buffer | | special view function for easy covert string from SQL to Human readable string and returns it. | | special view function for easy covert string from SQL to image xhtml tag snd returns it. | | Returns column header with column configuration. | | class for work with views and tables | | | | | | | | two dimension array (table contain) | | This variable contains header of view (table). | | | | | | | | count of rows in all view | | | | | | | | number of real start record on pages | | number of real end record on pages | | buffer with count of pages | | | | Sets main values of view. | | set variables, which is need to calculate pages. | | | | Sets laTable, if $iaHeader is not set, then generates it ;) | | Adds column to view and returns it’s index. | | pridam do tabulky dalsi sloupecek string se zklada napri. | | Returns true if paging is available and pages are more then row per page. | | Returns xhtml element for page backwards | | Returns xhtml element for page forwards | | | | Returns full xhtml control panel | | Returns buffer with xhtml code of view based on table | | Returns buffer with xhtml code of view based on div | | Returns xhtml code of view | | SQLView extends View over SQL queries and automatic work with pages | | | | | | | | sql query for select row count. | | sql part of LIMIT definitions | | | | | | | | | | | | Class as configuration for UserView. | | | | | | | | | | | | | | if is empty, it will be build | | | | | | definitions of GROUP BY example: array(‘0’=>’u_evid’) -> GROUP BY u_evid | | | | definitions of ORDER BY example: array(‘By Time’=>’A.time’, ‘By Name’ => ‘A.Name’) | | default sort type (DESC | ASC) TODO: work with dot char like in laWhere. | | | | array of values in writing: (‘Label’ => ‘key’) example: array(‘Author’=>’aid’,’Title’=>’A@title’); | | array of default values in writing: ($key=>array(type,array(‘value_1’,’value_2’))) TODO: not implement yet | | array of ends values in writing: ($key=>operator) example: array(‘aid’=>’NOT LIKE’,’A@title’=>’LIKE’); | | array of ends values in writing: ($key=>value) example: array(‘aid’=>’25’,’A@title’=>’My Title’); | | | | | | | | this can generate complex users views. | | | | | | | | | | | | | | | | full sql query with all clauses | | | | | | | | | | | | Checks if is defined session for lrView, if no, create it | | read values, which can be set via GET method | | read values, which can be set via POST method | | read values, which was be save to session of lrView | | Generate sql parts WHERE, ORDER BY and GROUP BY from session values | | Generates filter and returns its xhtml code from lrParams attributes via Form class. |
view_bufferbuffer for main view (main space) on page
left_panelbuffer for left panel, it’s usable for menu for example
right_panelbuffer for right panel, it’s usable for RSS channels for example
add_view| function add_view( | $isString, | | | | $buffer_name | = | 'view_buffer' | ) |
|
Adds string to global buffer
cell_time2Human| function cell_time2Human( | & | $iaRow, | | | $inKey | ) |
|
special view function for easy covert string from SQL to Human readable string and returns it. | iaRow | row in view | | inKey | column index in view which contains DATETIME |
cell_image| function cell_image( | & | $iaRow, | | | $inKey | ) |
|
special view function for easy covert string from SQL to image xhtml tag snd returns it. | iaRow | row in view | | inKey | column index in view which contains image location on web |
create_colHeader| function create_colHeader( | $isName, | | | | $ibVisble | = | true, | | $isLink | = | '', | | $isCss | = | '', | | $isFce | = | NULL | ) |
|
Returns column header with column configuration. For detail information about view header see View.laHeader isName - Name (Label) ibVisible - if column is visible (id column couldn’t be, but we can need them) isLink - column label link around the Name column.) isCss - css cell class isFce - function name
Viewclass for work with views and tables Summary | | | | | | | two dimension array (table contain) | | This variable contains header of view (table). | | | | | | | | count of rows in all view | | | | | | | | number of real start record on pages | | number of real end record on pages | | buffer with count of pages | | | | Sets main values of view. | | set variables, which is need to calculate pages. | | | | Sets laTable, if $iaHeader is not set, then generates it ;) | | Adds column to view and returns it’s index. | | pridam do tabulky dalsi sloupecek string se zklada napri. | | Returns true if paging is available and pages are more then row per page. | | Returns xhtml element for page backwards | | Returns xhtml element for page forwards | | | | Returns full xhtml control panel | | Returns buffer with xhtml code of view based on table | | Returns buffer with xhtml code of view based on div | | Returns xhtml code of view |
laTabletwo dimension array (table contain)
laHeaderThis variable contains header of view (table). Header is array and contains configuration of all columns in view. There are indexes by numbers in this sequence: | Name (string) | Name (Label) of column | | Visible (boolean) | if column is visible (id column couldn’t be, but we can need them) | | Link (string) | column label link (url). | | CssClass | css class of cell, cell could be generate as <td> or <div>, this is their class. | | Fce | function name to process with cell or full row. Function is call via eval php function and good examples how it could looks is cell_time2Human and cell_image. Function gets two variables: row array and column index, (cell is $Row[$Index]) and return value is save to cell. |
TODO: column key is now number of column, in future it could be string too, probably name of column.
lsPageLink| page url | typical index.php?module=myviews&action=litleview. It is using for pages in filter. |
lnAllRowscount of rows in all view
lnCurrentStartnumber of real start record on pages
lnCurrentEndnumber of real end record on pages
lsPageBufferbuffer with count of pages
ViewSets main values of view. lnRowsOnPage is set to -1 so we don’t make pages.
SetPage| function SetPage( | $inRowNumber, | | $inAllRows, | | $inRowsOnPage | ) |
|
set variables, which is need to calculate pages.
FillPageBuffer| function FillPageBuffer() |
fill buffer lsPageBuffer, where will be pages list
SetTable| function SetTable( | $iaTable, | | | | $iaHeader | = | NULL | ) |
|
Sets laTable, if $iaHeader is not set, then generates it ;)
Add_Column| function Add_Column( | $isHeader, | | | | $isFce | = | NULL | ) |
|
Adds column to view and returns it’s index. | isHeader | Column Name | | isFce | column function, see laHeader |
Add_InputColumn| function Add_InputColumn( | $isHeader, | | $isInput, | | $inAddColumnValue | ) |
|
pridam do tabulky dalsi sloupecek string se zklada napri. <input type=”text” value = “1” name=”prvek_ a pokracuje hodnoutou z inAddColumn Sloupce tedy 24 a konec je “> Adds input column to view and returns it’s index. | isHeader | column name | | isInput | start of xhtml code. For example: ‘<input type=”text” value = “1” name=”item_’ | | inAddColumnValue | column index to continue input tag. |
For example, third column (index 2) contains unique values 100, 101 and 105 (typical Id column). We call this function with like this: Add_InputColumn('sequence input', '<input type="text" value = "1" name="sq_', 2);
and in wiew will generate this column like this: <input type="text" value = "1" name="sq_100"/> <input type="text" value = "1" name="sq_101"/> <input type="text" value = "1" name="sq_105"/>
IsPagingReturns true if paging is available and pages are more then row per page. It calls to detect for pager buffer
Get_Paging_Back| function Get_Paging_Back() |
Returns xhtml element for page backwards
Get_Paging_Next| function Get_Paging_Next() |
Returns xhtml element for page forwards
Get_Paging_Pages| function Get_Paging_Pages() |
Returns lsPageBuffer when it should be
Get_PagingReturns full xhtml control panel
Generate_table| function Generate_table() |
Returns buffer with xhtml code of view based on table
Generate_tableReturns buffer with xhtml code of view based on div
Generate| function Generate( | $isType | = | '', | | $isPaging | = | 'both' | ) |
|
Returns xhtml code of view | isType | List | Table (default) | | isPaging | ’’| up | donw | both (default) |
SQLViewSQLView extends View over SQL queries and automatic work with pages Summary | | | | | | | sql query for select row count. | | sql part of LIMIT definitions | | | | | | | | | | |
lsSQLRowCountsql query for select row count. It Should returns only one value. For example: SELECT count(*) AS COUNT FROM SuperTable
lsSQLLimitsql part of LIMIT definitions
SetSqlStrings| function SetSqlStrings( | $isSQLSelect, | | $isSQLRowCount | ) |
|
db_count_select| function db_count_select() |
call lsSQLRowCount query
TableSelect| function TableSelect( | $inRowNumber, | | | | $inRowsOnPage, | | | | $iaHeader | = | NULL | ) |
|
Loads View from SQL | inRowNumber | number of real start record on pages | | inRowNumber | count of rows per page | | iaHeader | View.laHeader, if is not set (NULL), its calculate |
ViewConfigParamsClass as configuration for UserView. Summary | | | | | | | | | | | | | if is empty, it will be build | | | | | | definitions of GROUP BY example: array(‘0’=>’u_evid’) -> GROUP BY u_evid | | | | definitions of ORDER BY example: array(‘By Time’=>’A.time’, ‘By Name’ => ‘A.Name’) | | default sort type (DESC | ASC) TODO: work with dot char like in laWhere. | | | | array of values in writing: (‘Label’ => ‘key’) example: array(‘Author’=>’aid’,’Title’=>’A@title’); | | array of default values in writing: ($key=>array(type,array(‘value_1’,’value_2’))) TODO: not implement yet | | array of ends values in writing: ($key=>operator) example: array(‘aid’=>’NOT LIKE’,’A@title’=>’LIKE’); | | array of ends values in writing: ($key=>value) example: array(‘aid’=>’25’,’A@title’=>’My Title’); | | | | | | |
lsCountSQLif is empty, it will be build
laGroupBydefinitions of GROUP BY example: array(‘0’=>’u_evid’) -> GROUP BY u_evid
lnGroupBydefault grouping, index in laGroupBy TODO: work with dot char like in laWhere.
laOrderBydefinitions of ORDER BY example: array(‘By Time’=>’A.time’, ‘By Name’ => ‘A.Name’)
lsOrderBydefault sort type (DESC | ASC) TODO: work with dot char like in laWhere.
lnOrderBydefault ordering, indox in laOrderBy
laWherearray of values in writing: (‘Label’ => ‘key’) example: array(‘Author’=>’aid’,’Title’=>’A@title’); If you need tu use dot in key name, that can be problem, cause forms values from POST method fails. You can change dot(.) char to at(@) char. In WHERE clause generating it will be change to dot and all will works fine.
laWhereInValuesarray of default values in writing: ($key=>array(type,array(‘value_1’,’value_2’))) TODO: not implement yet
laWhereOpersarray of ends values in writing: ($key=>operator) example: array(‘aid’=>’NOT LIKE’,’A@title’=>’LIKE’);
laWhereValuesarray of ends values in writing: ($key=>value) example: array(‘aid’=>’25’,’A@title’=>’My Title’);
lnFilterType| 0 | hidden / shows line with controls | | 1 | visible |
ViewConfigParams| function ViewConfigParams( | $isUsersViewLink, | | $isId, | | $isSQL, | | $isTable | ) |
|
Sets the ViewConfigParams object | isUsersViewLink | Link, which is use to gets this view. See <lsPageLink> | | isId | view html id | | isSQL | sql query, see SQLView.SetSqlStrings | | isTable | SQL table (or view) |
UserViewthis can generate complex users views. Summary | | | | | | | | | | | | | | | full sql query with all clauses | | | | | | | | | | | | Checks if is defined session for lrView, if no, create it | | read values, which can be set via GET method | | read values, which can be set via POST method | | read values, which was be save to session of lrView | | Generate sql parts WHERE, ORDER BY and GROUP BY from session values | | Generates filter and returns its xhtml code from lrParams attributes via Form class. |
lsSQLfull sql query with all clauses
lsCountSQLcount SQL query. if not exist, it will be generated
UserView| function UserView( | $irParams | ) |
|
CheckSessionChecks if is defined session for lrView, if no, create it
GetGETParamsread values, which can be set via GET method
GetPOSTParamsread values, which can be set via POST method
GetSessionParams| function GetSessionParams() |
read values, which was be save to session of lrView
SetFilterSqlGenerate sql parts WHERE, ORDER BY and GROUP BY from session values
GenerateFilter| function GenerateFilter( | $isAction | = | '', | | $isModule | = | '', | | $isHeader | = | '', | | $ibPanel | = | false | ) |
|
Generates filter and returns its xhtml code from lrParams attributes via Form class.
|