views

Library 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
view name (label)
html view id
two dimension array (table contain)
This variable contains header of view (table).
link to next page
link to backwards page
count of rows in all view
count of rows per page
count of pages
number of current page
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.
fill buffer lsPageBuffer, where will be pages list
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 lsPageBuffer when it should be
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
SQLClass object
sql query for load view
sql query for select row count.
sql part of LIMIT definitions
Sets SQLClass and calls View.View
call lsSQLRowCount query
Loads View from SQL
Class as configuration for UserView.
the filter Form
if is empty, it will be build
definitions of GROUP BY example: array(‘0’=>’u_evid’) -> GROUP BY u_evid
default grouping, index in laGroupBy TODO: work with dot char like in laWhere.
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.
default ordering, indox in laOrderBy
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’);
Sets the ViewConfigParams object
this can generate complex users views.
SQLView object
ORDER BY clause
WHERE clause
GROUP BY clause
full sql query with all clauses
count SQL query.
number of start page
Returns options tags from ViewConfigParams.laOrderBy
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.

Variables

view_buffer

$GLOBALS['view_buffer']

buffer for main view (main space) on page

left_panel

$GLOBALS['left_panel']

buffer for left panel, it’s usable for menu for example

right_panel

$GLOBALS['right_panel']

buffer for right panel, it’s usable for RSS channels for example

Functions

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.

iaRowrow in view
inKeycolumn 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.

iaRowrow in view
inKeycolumn 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

View

class for work with views and tables

Summary
view name (label)
html view id
two dimension array (table contain)
This variable contains header of view (table).
link to next page
link to backwards page
count of rows in all view
count of rows per page
count of pages
number of current page
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.
fill buffer lsPageBuffer, where will be pages list
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 lsPageBuffer when it should be
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

Variables

lsName

var $lsName

view name (label)

lsId

var $lsId

html view id

laTable

var $laTable

two dimension array (table contain)

laHeader

var $laHeader

This 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).
CssClasscss class of cell, cell could be generate as <td> or <div>, this is their class.
Fcefunction 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

var $lsPageLink
page urltypical index.php?module=myviews&amp;action=litleview.  It is using for pages in filter.

lsPageLinkNext

var $lsPageLinkNext

link to next page

lsPageLinkBack

var $lsPageLinkBack

link to backwards page

lnAllRows

var $lnAllRows

count of rows in all view

lnRowsOnPage

var $lnRowsOnPage

count of rows per page

lnPageCount

var $lnPageCount

count of pages

lnCurrentPage

var $lnCurrentPage

number of current page

lnCurrentStart

var $lnCurrentStart

number of real start record on pages

lnCurrentEnd

var $lnCurrentEnd

number of real end record on pages

lsPageBuffer

var $lsPageBuffer

buffer with count of pages

Functions

View

function View($isName)

Sets 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.

inRowNumbersets lnCurrentStart
inAllRowscount of all rows
inRowsOnPagesets lnRowsOnPage

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 ;)

iaTablesee laTable
iaHeadersee laHeader

Add_Column

function Add_Column($isHeader,  
$isFce =  NULL)

Adds column to view and returns it’s index.

isHeaderColumn Name
isFcecolumn 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.

isHeadercolumn name
isInputstart of xhtml code.  For example: ‘<input type=”text” value = “1” name=”item_’
inAddColumnValuecolumn 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"/>

IsPaging

function IsPaging()

Returns 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_Paging

function Get_Paging()

Returns full xhtml control panel

Generate_table

function Generate_table()

Returns buffer with xhtml code of view based on table

Generate_table

Returns buffer with xhtml code of view based on div

Generate

function Generate($isType =  '',
$isPaging =  'both')

Returns xhtml code of view

isTypeList | Table (default)
isPaging’’| up | donw | both (default)

SQLView

SQLView extends View over SQL queries and automatic work with pages

Summary
SQLClass object
sql query for load view
sql query for select row count.
sql part of LIMIT definitions
Sets SQLClass and calls View.View
call lsSQLRowCount query
Loads View from SQL

Variables

loSQLClass

var $loSQLClass

SQLClass object

lsSqlSelect

var $lsSqlSelect

sql query for load view

lsSQLRowCount

var $lsSQLRowCount

sql query for select row count.  It Should returns only one value.  For example: SELECT count(*) AS COUNT FROM SuperTable

lsSQLLimit

var $lsSQLLimit

sql part of LIMIT definitions

Functions

SQLView

function SQLView($isName,
$ioSQLClass)

Sets SQLClass and calls View.View

isNameView Name
ioSQLClassSQLClass object

SetSqlStrings

function SetSqlStrings($isSQLSelect,
$isSQLRowCount)
isSQLSelectsee <lsSQLSelect>
isSQLRowCountsee lsSQLRowCount

db_count_select

function db_count_select()

call lsSQLRowCount query

TableSelect

function TableSelect($inRowNumber,  
$inRowsOnPage,  
$iaHeader =  NULL)

Loads View from SQL

inRowNumbernumber of real start record on pages
inRowNumbercount of rows per page
iaHeaderView.laHeader, if is not set (NULL), its calculate

ViewConfigParams

Class as configuration for UserView.

Summary
the filter Form
if is empty, it will be build
definitions of GROUP BY example: array(‘0’=>’u_evid’) -> GROUP BY u_evid
default grouping, index in laGroupBy TODO: work with dot char like in laWhere.
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.
default ordering, indox in laOrderBy
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’);
Sets the ViewConfigParams object

Variables

lsUsersViewLink

var $lsUsersViewLink

lsTable

var $lsTable

lsId

var $lsId

lsSQL

var $lsSQL

lrFilter

var $lrFilter

the filter Form

lsCountSQL

var $lsCountSQL

if is empty, it will be build

lnPageStart

var $lnPageStart

lnPage

var $lnPage

laGroupBy

var $laGroupBy

definitions of GROUP BY example: array(‘0’=>’u_evid’) -> GROUP BY u_evid

lnGroupBy

var $lnGroupBy

default grouping, index in laGroupBy TODO: work with dot char like in laWhere.

laOrderBy

var $laOrderBy

definitions of ORDER BY example: array(‘By Time’=>’A.time’, ‘By Name’ => ‘A.Name’)

lsOrderBy

var $lsOrderBy

default sort type (DESC | ASC) TODO: work with dot char like in laWhere.

lnOrderBy

var $lnOrderBy

default ordering, indox in laOrderBy

laWhere

var $laWhere

array 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.

laWhereInValues

var $laWhereInValues

array of default values in writing: ($key=>array(type,array(‘value_1’,’value_2’))) TODO: not implement yet

laWhereOpers

var $laWhereOpers

array of ends values in writing: ($key=>operator) example: array(‘aid’=>’NOT LIKE’,’A@title’=>’LIKE’);

laWhereValues

var $laWhereValues

array of ends values in writing: ($key=>value) example: array(‘aid’=>’25’,’A@title’=>’My Title’);

lnFilterType

var $lnFilterType
0hidden / shows line with controls
1visible

Functions

ViewConfigParams

function ViewConfigParams($isUsersViewLink,
$isId,
$isSQL,
$isTable)

Sets the ViewConfigParams object

isUsersViewLinkLink, which is use to gets this view.  See <lsPageLink>
isIdview html id
isSQLsql query, see SQLView.SetSqlStrings
isTableSQL table (or view)

UserView

this can generate complex users views.

Summary
SQLView object
ORDER BY clause
WHERE clause
GROUP BY clause
full sql query with all clauses
count SQL query.
number of start page
Returns options tags from ViewConfigParams.laOrderBy
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.

Variables

lrParams

var $lrParams

ViewConfigParams object

lrSql

var $lrSql

MySQLConfig object

lrView

var $lrView

SQLView object

lsOrderBy

var $lsOrderBy

ORDER BY clause

lsWhere

var $lsWhere

WHERE clause

lsGroupBy

GROUP BY clause

lsSQL

var $lsSQL

full sql query with all clauses

lsCountSQL

var $lsCountSQL

count SQL query. if not exist, it will be generated

lnStart

var $lnStart

number of start page

Functions

UserView

function UserView($irParams)
irParamsViewConfigParams object

GetOrderInput

function GetOrderInput()

Returns options tags from ViewConfigParams.laOrderBy

CheckSession

function CheckSession()

Checks if is defined session for lrView, if no, create it

GetGETParams

function GetGETParams()

read values, which can be set via GET method

GetPOSTParams

function GetPOSTParams()

read values, which can be set via POST method

GetSessionParams

function GetSessionParams()

read values, which was be save to session of lrView

SetFilterSql

function SetFilterSql()

Generate 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.

isActionmodule action, see Form.lsAction
isModulemodule name, see Form.lsModule
isHeaderfilter label, see Form.lsHeader
ibPanelcontrol panel setting, see Form.lbPanel
$GLOBALS['view_buffer']
buffer for main view (main space) on page
$GLOBALS['left_panel']
buffer for left panel, it’s usable for menu for example
$GLOBALS['right_panel']
buffer for right panel, it’s usable for RSS channels for example
function add_view($isString,  
$buffer_name =  'view_buffer')
Adds string to global buffer
function cell_time2Human(&$iaRow,
$inKey)
special view function for easy covert string from SQL to Human readable string and returns it.
function cell_image(&$iaRow,
$inKey)
special view function for easy covert string from SQL to image xhtml tag snd returns it.
function create_colHeader($isName,  
$ibVisble =  true,
$isLink =  '',
$isCss =  '',
$isFce =  NULL)
Returns column header with column configuration.
var $lsName
view name (label)
var $lsId
html view id
var $laTable
two dimension array (table contain)
var $laHeader
This variable contains header of view (table).
var $lsPageLink
var $lsPageLinkNext
link to next page
var $lsPageLinkBack
link to backwards page
var $lnAllRows
count of rows in all view
var $lnRowsOnPage
count of rows per page
var $lnPageCount
count of pages
var $lnCurrentPage
number of current page
var $lnCurrentStart
number of real start record on pages
var $lnCurrentEnd
number of real end record on pages
var $lsPageBuffer
buffer with count of pages
function View($isName)
Sets main values of view.
function SetPage($inRowNumber,
$inAllRows,
$inRowsOnPage)
set variables, which is need to calculate pages.
function FillPageBuffer()
fill buffer lsPageBuffer, where will be pages list
function SetTable($iaTable,  
$iaHeader =  NULL)
Sets laTable, if $iaHeader is not set, then generates it ;)
function Add_Column($isHeader,  
$isFce =  NULL)
Adds column to view and returns it’s index.
function Add_InputColumn($isHeader,
$isInput,
$inAddColumnValue)
pridam do tabulky dalsi sloupecek string se zklada napri.
function IsPaging()
Returns true if paging is available and pages are more then row per page.
function Get_Paging_Back()
Returns xhtml element for page backwards
function Get_Paging_Next()
Returns xhtml element for page forwards
function Get_Paging_Pages()
Returns lsPageBuffer when it should be
function Get_Paging()
Returns full xhtml control panel
function Generate_table()
Returns buffer with xhtml code of view based on table
function Generate($isType =  '',
$isPaging =  'both')
Returns xhtml code of view
class for work with views and tables
var $loSQLClass
SQLClass object
Base SQL class, it’s contains only basic variables and definitions of common methods, which could be usable in others children.
var $lsSqlSelect
sql query for load view
var $lsSQLRowCount
sql query for select row count.
var $lsSQLLimit
sql part of LIMIT definitions
function SQLView($isName,
$ioSQLClass)
Sets SQLClass and calls View.View
function SetSqlStrings($isSQLSelect,
$isSQLRowCount)
function db_count_select()
call lsSQLRowCount query
function TableSelect($inRowNumber,  
$inRowsOnPage,  
$iaHeader =  NULL)
Loads View from SQL
var $lsUsersViewLink
var $lsTable
var $lsId
var $lsSQL
var $lrFilter
the filter Form
Form class can generate form with some functions like be center on page as normal window.
var $lsCountSQL
if is empty, it will be build
var $lnPageStart
var $lnPage
var $laGroupBy
definitions of GROUP BY example: array(‘0’=>’u_evid’) -> GROUP BY u_evid
var $lnGroupBy
default grouping, index in laGroupBy TODO: work with dot char like in laWhere.
var $laWhere
array of values in writing: (‘Label’ => ‘key’) example: array(‘Author’=>’aid’,’Title’=>’A@title’);
var $laOrderBy
definitions of ORDER BY example: array(‘By Time’=>’A.time’, ‘By Name’ => ‘A.Name’)
var $lsOrderBy
default sort type (DESC | ASC) TODO: work with dot char like in laWhere.
var $lnOrderBy
default ordering, indox in laOrderBy
var $laWhereInValues
array of default values in writing: ($key=>array(type,array(‘value_1’,’value_2’))) TODO: not implement yet
var $laWhereOpers
array of ends values in writing: ($key=>operator) example: array(‘aid’=>’NOT LIKE’,’A@title’=>’LIKE’);
var $laWhereValues
array of ends values in writing: ($key=>value) example: array(‘aid’=>’25’,’A@title’=>’My Title’);
var $lnFilterType
function ViewConfigParams($isUsersViewLink,
$isId,
$isSQL,
$isTable)
Sets the ViewConfigParams object
var $lrParams
ViewConfigParams object
Class as configuration for UserView.
var $lrSql
MySQLConfig object
class base on MySQLClass, constructor don’t neet params, cause it reads from SQL_server from config.php TODO: in future this class probably will be top of all SQLClasses (mysql, sqlite etc), technology will be using according to SQL_server.Type.
var $lrView
SQLView object
SQLView extends View over SQL queries and automatic work with pages
var $lsOrderBy
ORDER BY clause
var $lsWhere
WHERE clause
var $lsSQL
full sql query with all clauses
var $lsCountSQL
count SQL query.
var $lnStart
number of start page
function UserView($irParams)
function GetOrderInput()
Returns options tags from ViewConfigParams.laOrderBy
function CheckSession()
Checks if is defined session for lrView, if no, create it
function GetGETParams()
read values, which can be set via GET method
function GetPOSTParams()
read values, which can be set via POST method
function GetSessionParams()
read values, which was be save to session of lrView
function SetFilterSql()
Generate sql parts WHERE, ORDER BY and GROUP BY from session values
function GenerateFilter($isAction =  '',
$isModule =  '',
$isHeader =  '',
$ibPanel =  false)
Generates filter and returns its xhtml code from lrParams attributes via Form class.
public $lsAction
Action variable which is post with form.
public $lsModule
Module variable which is post with form.
public $lsHeader
label which is on top of form
public $lbPanel
show control icons in top panel of form