@@ -1,6 +1,7 @@
< ? php
< ? php
/**
/**
* class.pagedTable.php
* class.pagedTable.php
*
* @package gulliver.system
* @package gulliver.system
*
*
* ProcessMaker Open Source Edition
* ProcessMaker Open Source Edition
@@ -29,6 +30,7 @@ G::LoadClass('xmlMenu');
/**
/**
* Class pagedTable
* Class pagedTable
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @package gulliver.system
* @package gulliver.system
* @access public
* @access public
@@ -36,79 +38,81 @@ G::LoadClass('xmlMenu');
class pagedTable
class pagedTable
{
{
var $xmlFormFile ;
public $xmlFormFile ;
var $currentPage ;
public $currentPage ;
var $orderBy = '' ;
public $orderBy = '' ;
var $filter = array ();
public $filter = array ();
var $filterType = array ();
public $filterType = array ();
var $searchBy = '' ;
public $searchBy = '' ;
var $fastSearch = '' ;
public $fastSearch = '' ;
var $order = '' ;
public $order = '' ;
var $template = 'templates/paged-table.html' ;
public $template = 'templates/paged-table.html' ;
var $tpl ;
public $tpl ;
var $style = array ();
public $style = array ();
var $rowsPerPage = 25 ;
public $rowsPerPage = 25 ;
var $ownerPage ;
public $ownerPage ;
var $popupPage ;
public $popupPage ;
var $popupSubmit ;
public $popupSubmit ;
var $popupWidth = 450 ;
public $popupWidth = 450 ;
var $popupHeight = 200 ;
public $popupHeight = 200 ;
var $ajaxServer ;
public $ajaxServer ;
var $fields ;
public $fields ;
var $query ;
public $query ;
var $totpages ;
public $totpages ;
//SQL QUERIES
//SQL QUERIES
var $sql = '' ;
public $sql = '' ;
var $sqlWhere = '' ;
public $sqlWhere = '' ;
var $sqlGroupBy = '' ;
public $sqlGroupBy = '' ;
var $sqlSelect = 'SELECT 1' ;
public $sqlSelect = 'SELECT 1' ;
var $sqlDelete = '' ;
public $sqlDelete = '' ;
var $sqlInsert = '' ;
public $sqlInsert = '' ;
var $sqlUpdate = '' ;
public $sqlUpdate = '' ;
var $fieldDataList = '' ;
public $fieldDataList = '' ;
//Configuration
//Configuration
var $xmlPopup = '' ;
public $xmlPopup = '' ;
var $addRow = false ;
public $addRow = false ;
var $deleteRow = false ;
public $deleteRow = false ;
var $editRow = false ;
public $editRow = false ;
var $notFields = ' title button linknew begingrid2 endgrid2 ' ; // These are not considered to build the sql queries (update,insert,delete)
public $notFields = ' title button linknew begingrid2 endgrid2 ' ; // These are not considered to build the sql queries (update,insert,delete)
//JavaScript Object attributes
//JavaScript Object attributes
var $onUpdateField = " " ;
public $onUpdateField = " " ;
var $onDeleteField = " " ;
public $onDeleteField = " " ;
var $afterDeleteField = " " ;
public $afterDeleteField = " " ;
var $onInsertField = " " ;
public $onInsertField = " " ;
//New gulliver
//New gulliver
var $xmlForm ;
public $xmlForm ;
var $menu = '' ;
public $menu = '' ;
var $filterForm = '' ;
public $filterForm = '' ;
var $filterForm_Id = '' ;
public $filterForm_Id = '' ;
var $name = 'pagedTable' ;
public $name = 'pagedTable' ;
var $id = 'A1' ;
public $id = 'A1' ;
var $disableFooter = false ;
public $disableFooter = false ;
//This attribute is used to set STYLES to groups of TD, using the field type "cellMark" (see XmlForm_Field_cellMark)
//This attribute is used to set STYLES to groups of TD, using the field type "cellMark" (see XmlForm_Field_cellMark)
var $tdStyle = '' ;
public $tdStyle = '' ;
var $tdClass = '' ;
public $tdClass = '' ;
//Config Save definition
//Config Save definition
var $__Configuration = 'orderBy,filter,fastSearch,style/*/showInTable' ; //order,rowsPerPage,disableFooter';
public $__Configuration = 'orderBy,filter,fastSearch,style/*/showInTable' ; //order,rowsPerPage,disableFooter';
/**
/**
* Function analizeSql
* Function analizeSql
* You can to distribute the component of the query like: Select, Where, Group by and order by
* You can to distribute the component of the query like: Select, Where, Group by and order by
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @return string
* @return string
*/
*/
function analizeSql ()
public function analizeSql ()
{
{
if ( 1 === preg_match ( '/^\s*SELECT\s+(.+?)(?:\s+FROM\s+(.+?))(?:\s+WHERE\s+(.+?))?(?:\s+GROUP\s+BY\s+(.+?))?(?:\s+ORDER\s+BY\s+(.+?))?(?:\s+BETWEEN\s+(.+?)\s+AND\s+(.+?))?\s*$/im' , $this -> sqlSelect , $matches )) {
if ( 1 === preg_match ( '/^\s*SELECT\s+(.+?)(?:\s+FROM\s+(.+?))(?:\s+WHERE\s+(.+?))?(?:\s+GROUP\s+BY\s+(.+?))?(?:\s+ORDER\s+BY\s+(.+?))?(?:\s+BETWEEN\s+(.+?)\s+AND\s+(.+?))?\s*$/im' , $this -> sqlSelect , $matches )) {
$this -> sqlSelect = 'SELECT ' . $matches [ 1 ] . (( $matches [ 2 ] != '' ) ? ' FROM ' . $matches [ 2 ] : '' );
$this -> sqlSelect = 'SELECT ' . $matches [ 1 ] . (( $matches [ 2 ] != '' ) ? ' FROM ' . $matches [ 2 ] : '' );
$this -> sqlSelect = 'SELECT ' . $matches [ 1 ] . (( $matches [ 2 ] != '' ) ? ' FROM ' . $matches [ 2 ] : '' );
$this -> sqlSelect = 'SELECT ' . $matches [ 1 ] . (( $matches [ 2 ] != '' ) ? ' FROM ' . $matches [ 2 ] : '' );
}
} else {
else {
//echo('Warning: SQL Query is not well formed.');
//echo('Warning: SQL Query is not well formed.');
return ;
return ;
}
}
@@ -120,73 +124,87 @@ class pagedTable
if ( $this -> sqlOrderBy != '' ) {
if ( $this -> sqlOrderBy != '' ) {
if ( $n = preg_match_all ( '/\b([\w\.]+)\b(?:\s+(ASC|DESC))?,?/im' , $this -> sqlOrderBy , $matches , PREG_SET_ORDER )) {
if ( $n = preg_match_all ( '/\b([\w\.]+)\b(?:\s+(ASC|DESC))?,?/im' , $this -> sqlOrderBy , $matches , PREG_SET_ORDER )) {
for ( $r = 0 ; $r < $n ; $r ++ ) {
for ( $r = 0 ; $r < $n ; $r ++ ) {
if ( ! isset ( $matches [ $r ][ 2 ]))
if ( ! isset ( $matches [ $r ][ 2 ] )) {
$matches [ $r ][ 2 ] = '' ;
$matches [ $r ][ 2 ] = '' ;
if ( $matches [ $r ][ 2 ] == '' )
}
if ( $matches [ $r ][ 2 ] == '' ) {
$matches [ $r ][ 2 ] = 'ASC' ;
$matches [ $r ][ 2 ] = 'ASC' ;
}
$ord = G :: createUID ( '' , $matches [ $r ][ 1 ] ) . '=' . urlencode ( $matches [ $r ][ 2 ] );
$ord = G :: createUID ( '' , $matches [ $r ][ 1 ] ) . '=' . urlencode ( $matches [ $r ][ 2 ] );
if ( $this -> order == '' )
if ( $this -> order == '' ) {
$this -> order = $ord ;
$this -> order = $ord ;
else
} else {
$this -> order .= '&' . $ord ;
$this -> order .= '&' . $ord ;
}
}
}
//Orden ascendente
//Orden ascendente
if ( $n == 1 )
if ( $n == 1 ) {
$this -> order = G :: createUID ( '' , $matches [ 0 ][ 1 ] ) . '=' . $matches [ 0 ][ 2 ];
$this -> order = G :: createUID ( '' , $matches [ 0 ][ 1 ] ) . '=' . $matches [ 0 ][ 2 ];
}
}
}
}
}
//Generate: $uniqueWhere=Identify a row bys its data content
//Generate: $uniqueWhere=Identify a row bys its data content
//$this->fieldDataList=url text that dentify a row bys its data content
//$this->fieldDataList=url text that dentify a row bys its data content
$uniqueWhere = '' ;
$uniqueWhere = '' ;
$this -> fieldDataList = '' ;
$this -> fieldDataList = '' ;
foreach ( $this -> fields as $r => $field )
foreach ( $this -> fields as $r => $field ) {
if (( strpos ( $this -> notFields , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === FALSE )){
if (( strpos ( $this -> notFields , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === false )) {
if ( $uniqueWhere == '' )
if ( $uniqueWhere == '' ) {
$uniqueWhere = (( $this -> sqlWhere != '' ) ? ( '(' . $this -> sqlWhere . ') AND (' ) : '(' );
$uniqueWhere = (( $this -> sqlWhere != '' ) ? ( '(' . $this -> sqlWhere . ') AND (' ) : '(' );
else
} else {
$uniqueWhere .= ' AND ' ;
$uniqueWhere .= ' AND ' ;
}
$uniqueWhere .= $this -> fields [ $r ][ 'Name' ] . '=' . '@@' . $this -> fields [ $r ][ 'Name' ];
$uniqueWhere .= $this -> fields [ $r ][ 'Name' ] . '=' . '@@' . $this -> fields [ $r ][ 'Name' ];
if ( $this -> fieldDataList == '' )
if ( $this -> fieldDataList == '' ) {
$this -> fieldDataList = '' ;
$this -> fieldDataList = '' ;
else
} else {
$this -> fieldDataList .= '&' ;
$this -> fieldDataList .= '&' ;
}
$this -> fieldDataList .= $this -> fields [ $r ][ 'Name' ] . '=' . '@@_' . $this -> fields [ $r ][ 'Name' ];
$this -> fieldDataList .= $this -> fields [ $r ][ 'Name' ] . '=' . '@@_' . $this -> fields [ $r ][ 'Name' ];
}
}
if ( $uniqueWhere != '' )
}
if ( $uniqueWhere != '' ) {
$uniqueWhere .= ')' ;
$uniqueWhere .= ')' ;
}
}
}
/**
/**
* Function prepareQuery
* Function prepareQuery
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @return string
* @return string
*/
*/
function prepareQuery ()
public function prepareQuery ()
{
{
//DBConnection
//DBConnection
if ( ! $this -> sqlConnection )
if ( ! $this -> sqlConnection ) {
$this -> dbc = new DBConnection ();
$this -> dbc = new DBConnection ();
else {
} else {
if ( defined ( 'DB_' . $this -> sqlConnection . '_USER' )) {
if ( defined ( 'DB_' . $this -> sqlConnection . '_USER' )) {
if ( defined ( 'DB_' . $this -> sqlConnection . '_HOST' ))
if ( defined ( 'DB_' . $this -> sqlConnection . '_HOST' )) {
eval ( '$res[\'DBC_SERVER\'] = DB_' . $this -> sqlConnection . '_HOST;' );
eval ( '$res[\'DBC_SERVER\'] = DB_' . $this -> sqlConnection . '_HOST;' );
else
} else {
$res [ 'DBC_SERVER' ] = DB_HOST ;
$res [ 'DBC_SERVER' ] = DB_HOST ;
if ( defined ( 'DB_' . $this -> sqlConnection . '_USER' ))
}
if ( defined ( 'DB_' . $this -> sqlConnection . '_USER' )) {
eval ( '$res[\'DBC_USERNAME\'] = DB_' . $this -> sqlConnection . '_USER;' );
eval ( '$res[\'DBC_USERNAME\'] = DB_' . $this -> sqlConnection . '_USER;' );
if ( defined ( 'DB_' . $this -> sqlConnection . '_PASS' ))
}
if ( defined ( 'DB_' . $this -> sqlConnection . '_PASS' )) {
eval ( '$res[\'DBC_PASSWORD\'] = DB_' . $this -> sqlConnection . '_PASS;' );
eval ( '$res[\'DBC_PASSWORD\'] = DB_' . $this -> sqlConnection . '_PASS;' );
else
} else {
$res [ 'DBC_PASSWORD' ] = DB_PASS ;
$res [ 'DBC_PASSWORD' ] = DB_PASS ;
if ( defined ( 'DB_' . $this -> sqlConnection . '_NAME' ))
}
if ( defined ( 'DB_' . $this -> sqlConnection . '_NAME' )) {
eval ( '$res[\'DBC_DATABASE\'] = DB_' . $this -> sqlConnection . '_NAME;' );
eval ( '$res[\'DBC_DATABASE\'] = DB_' . $this -> sqlConnection . '_NAME;' );
else
} else {
$res [ 'DBC_DATABASE' ] = DB_NAME ;
$res [ 'DBC_DATABASE' ] = DB_NAME ;
if ( defined ( 'DB_' . $this -> sqlConnection . '_TYPE' ))
}
if ( defined ( 'DB_' . $this -> sqlConnection . '_TYPE' )) {
eval ( '$res[\'DBC_TYPE\'] = DB_' . $this -> sqlConnection . '_TYPE;' );
eval ( '$res[\'DBC_TYPE\'] = DB_' . $this -> sqlConnection . '_TYPE;' );
else
} else {
$res [ 'DBC_TYPE' ] = defined ( 'DB_TYPE' ) ? DB_TYPE : 'mysql' ;
$res [ 'DBC_TYPE' ] = defined ( 'DB_TYPE' ) ? DB_TYPE : 'mysql' ;
}
$this -> dbc = new DBConnection ( $res [ 'DBC_SERVER' ], $res [ 'DBC_USERNAME' ], $res [ 'DBC_PASSWORD' ], $res [ 'DBC_DATABASE' ], $res [ 'DBC_TYPE' ] );
$this -> dbc = new DBConnection ( $res [ 'DBC_SERVER' ], $res [ 'DBC_USERNAME' ], $res [ 'DBC_PASSWORD' ], $res [ 'DBC_DATABASE' ], $res [ 'DBC_TYPE' ] );
} else {
} else {
$dbc = new DBConnection ();
$dbc = new DBConnection ();
@@ -206,10 +224,11 @@ class pagedTable
}
}
$this -> aFilter = $filterFields ;
$this -> aFilter = $filterFields ;
$filter = '' ;
$filter = '' ;
foreach ( $filterFields as $field => $like )
foreach ( $filterFields as $field => $like ) {
if ( $like != '' ) {
if ( $like != '' ) {
if ( $filter !== '' )
if ( $filter !== '' ) {
$filter .= ' AND ' ;
$filter .= ' AND ' ;
}
if ( isset ( $this -> filterType [ $field ] )) {
if ( isset ( $this -> filterType [ $field ] )) {
switch ( $this -> filterType [ $field ]) {
switch ( $this -> filterType [ $field ]) {
case '=' :
case '=' :
@@ -229,6 +248,7 @@ class pagedTable
$filter .= $field . ' = "' . mysql_real_escape_string ( $like ) . '"' ;
$filter .= $field . ' = "' . mysql_real_escape_string ( $like ) . '"' ;
}
}
}
}
}
/*
/*
* QuickSearch
* QuickSearch
*/
*/
@@ -237,8 +257,7 @@ class pagedTable
$subFilter = '' ;
$subFilter = '' ;
foreach ( $aSB as $sBy ) {
foreach ( $aSB as $sBy ) {
$subFilter .= ( $subFilter !== '' ) ? ' OR ' : '' ;
$subFilter .= ( $subFilter !== '' ) ? ' OR ' : '' ;
$subFilter .= $sBy . ' LIKE "%' .
$subFilter .= $sBy . ' LIKE "%' . G :: sqlEscape ( $this -> fastSearch , $this -> dbc -> type ) . '%"' ;
G :: sqlEscape ( $this -> fastSearch , $this -> dbc -> type ) . '%"' ;
}
}
if ( $subFilter !== '' ) {
if ( $subFilter !== '' ) {
$filter .= ( $filter !== '' ) ? ' AND ' : '' ;
$filter .= ( $filter !== '' ) ? ' AND ' : '' ;
@@ -258,26 +277,23 @@ class pagedTable
foreach ( $orderFields as $field => $fieldOrder ) {
foreach ( $orderFields as $field => $fieldOrder ) {
$field = G :: getUIDName ( $field , '' );
$field = G :: getUIDName ( $field , '' );
$fieldOrder = strtoupper ( $fieldOrder );
$fieldOrder = strtoupper ( $fieldOrder );
if ( $fieldOrder === 'A' )
if ( $fieldOrder === 'A' ) {
$fieldOrder = 'ASC' ;
$fieldOrder = 'ASC' ;
if ( $fieldOrder === 'D' )
}
if ( $fieldOrder === 'D' ) {
$fieldOrder = 'DESC' ;
$fieldOrder = 'DESC' ;
}
switch ( $fieldOrder ) {
switch ( $fieldOrder ) {
case 'ASC' :
case 'ASC' :
case 'DESC' :
case 'DESC' :
if ( $order !== '' )
if ( $order !== '' ) {
$order .= ', ' ;
$order .= ', ' ;
}
$order .= $field . ' ' . $fieldOrder ;
$order .= $field . ' ' . $fieldOrder ;
$this -> aOrder [ $field ] = $fieldOrder ;
$this -> aOrder [ $field ] = $fieldOrder ;
}
}
}
}
$this -> sql = $this -> sqlSelect .
$this -> sql = $this -> sqlSelect . ((( $this -> sqlWhere != '' ) || ( $filter != '' )) ? ' WHERE ' : '' ) . (( $this -> sqlWhere != '' ) ? '(' . $this -> sqlWhere . ')' : '' ) . ((( $this -> sqlWhere != '' ) && ( $filter != '' )) ? ' AND ' : '' ) . (( $filter != '' ) ? '(' . $filter . ')' : '' ) . (( $this -> sqlGroupBy != '' ) ? ' GROUP BY ' . $this -> sqlGroupBy : '' ) . (( $order != '' ) ? ' ORDER BY ' . $order : '' );
((( $this -> sqlWhere != '' ) || ( $filter != '' )) ? ' WHERE ' : '' ) .
(( $this -> sqlWhere != '' ) ? '(' . $this -> sqlWhere . ')' : '' ) .
((( $this -> sqlWhere != '' ) && ( $filter != '' )) ? ' AND ' : '' ) .
(( $filter != '' ) ? '(' . $filter . ')' : '' ) .
(( $this -> sqlGroupBy != '' ) ? ' GROUP BY ' . $this -> sqlGroupBy : '' ) .
(( $order != '' ) ? ' ORDER BY ' . $order : '' );
//$this->query=$this->ses->execute($this->sql);
//$this->query=$this->ses->execute($this->sql);
//$this->totpages=ceil($this->query->count()/$this->rowsPerPage);
//$this->totpages=ceil($this->query->count()/$this->rowsPerPage);
return ;
return ;
@@ -285,55 +301,65 @@ class pagedTable
/**
/**
* Function setupFromXmlform
* Function setupFromXmlform
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @param string xmlForm
* @param string xmlForm
* @return string
* @return string
*/
*/
function setupFromXmlform ( $xmlForm )
public function setupFromXmlform ( $xmlForm )
{
{
$this -> xmlForm = $xmlForm ;
$this -> xmlForm = $xmlForm ;
//Config
//Config
$this -> name = $xmlForm -> name ;
$this -> name = $xmlForm -> name ;
$this -> id = $xmlForm -> id ;
$this -> id = $xmlForm -> id ;
$this -> sqlConnection = (( isset ( $this -> xmlForm -> sqlConnection )) ? $this -> xmlForm -> sqlConnection : '' );
$this -> sqlConnection = (( isset ( $this -> xmlForm -> sqlConnection )) ? $this -> xmlForm -> sqlConnection : '' );
if ( isset ( $_GET [ 'page' ]))
if ( isset ( $_GET [ 'page' ] )) {
$this -> currentPage = $_GET [ 'page' ];
$this -> currentPage = $_GET [ 'page' ];
else
} else {
$this -> currentPage = 1 ;
$this -> currentPage = 1 ;
if ( isset ( $_GET [ 'order' ]))
}
if ( isset ( $_GET [ 'order' ] )) {
$this -> orderBy = urldecode ( $_GET [ 'order' ] );
$this -> orderBy = urldecode ( $_GET [ 'order' ] );
else
} else {
$this -> orderBy = " " ;
$this -> orderBy = " " ;
if ( isset ( $_GET [ 'filter' ]))
}
if ( isset ( $_GET [ 'filter' ] )) {
$this -> filter = urldecode ( $_GET [ 'filter' ] );
$this -> filter = urldecode ( $_GET [ 'filter' ] );
else
} else {
$this -> filter = " " ;
$this -> filter = " " ;
}
$this -> ajaxServer = G :: encryptLink ( '../gulliver/pagedTableAjax' );
$this -> ajaxServer = G :: encryptLink ( '../gulliver/pagedTableAjax' );
$this -> ownerPage = G :: encryptLink ( SYS_CURRENT_URI );
$this -> ownerPage = G :: encryptLink ( SYS_CURRENT_URI );
//Needed for $mysql_real_escape_string
//Needed for $mysql_real_escape_string
$auxDbc = new DBConnection ();
$auxDbc = new DBConnection ();
if ( isset ( $this -> xmlForm -> sql ))
if ( isset ( $this -> xmlForm -> sql )) {
$this -> sqlSelect = G :: replaceDataField ( $this -> xmlForm -> sql , $this -> xmlForm -> values );
$this -> sqlSelect = G :: replaceDataField ( $this -> xmlForm -> sql , $this -> xmlForm -> values );
else
} else {
trigger_Error ( 'Warning: sql query is empty' , E_USER_WARNING );
trigger_Error ( 'Warning: sql query is empty' , E_USER_WARNING );
}
// Config attributes from XMLFORM file
// Config attributes from XMLFORM file
$myAttributes = get_class_vars ( get_class ( $this ) );
$myAttributes = get_class_vars ( get_class ( $this ) );
foreach ( $this -> xmlForm -> xmlform -> tree -> attribute as $atrib => $value )
foreach ( $this -> xmlForm -> xmlform -> tree -> attribute as $atrib => $value ) {
if ( array_key_exists ( $atrib , $myAttributes )) {
if ( array_key_exists ( $atrib , $myAttributes )) {
eval ( 'settype($value,gettype($this->' . $atrib . '));' );
eval ( 'settype($value,gettype($this->' . $atrib . '));' );
if ( $value !== '' )
if ( $value !== '' ) {
eval ( '$this->' . $atrib . '=$value;' );
eval ( '$this->' . $atrib . '=$value;' );
}
}
}
}
//Prepare the fields
//Prepare the fields
$this -> style = array (); $this -> gridWidth = " " ; $this -> gridFields = " " ;
$this -> style = array ();
$this -> gridWidth = " " ;
$this -> gridFields = " " ;
$this -> fieldsType = array ();
$this -> fieldsType = array ();
foreach ( $this -> xmlForm -> fields as $f => $v ) {
foreach ( $this -> xmlForm -> fields as $f => $v ) {
$r = $f ;
$r = $f ;
$this -> fields [ $r ][ 'Name' ] = $this -> xmlForm -> fields [ $f ] -> name ;
$this -> fields [ $r ][ 'Name' ] = $this -> xmlForm -> fields [ $f ] -> name ;
$this -> fields [ $r ][ 'Type' ] = $this -> xmlForm -> fields [ $f ] -> type ;
$this -> fields [ $r ][ 'Type' ] = $this -> xmlForm -> fields [ $f ] -> type ;
if ( isset ( $this -> xmlForm -> fields [ $f ] -> size ))
if ( isset ( $this -> xmlForm -> fields [ $f ] -> size )) {
$this -> fields [ $r ][ 'Size' ] = $this -> xmlForm -> fields [ $f ] -> size ;
$this -> fields [ $r ][ 'Size' ] = $this -> xmlForm -> fields [ $f ] -> size ;
}
$this -> fields [ $r ][ 'Label' ] = $this -> xmlForm -> fields [ $f ] -> label ;
$this -> fields [ $r ][ 'Label' ] = $this -> xmlForm -> fields [ $f ] -> label ;
}
}
//Autocomplete the sql queries
//Autocomplete the sql queries
@@ -342,7 +368,8 @@ class pagedTable
//Set the default settings
//Set the default settings
$this -> defaultStyle ();
$this -> defaultStyle ();
//continue whith the setup
//continue whith the setup
$this -> gridWidth = '' ; $this -> gridFields = '' ;
$this -> gridWidth = '' ;
$this -> gridFields = '' ;
foreach ( $this -> xmlForm -> fields as $f => $v ) {
foreach ( $this -> xmlForm -> fields as $f => $v ) {
$r = $f ;
$r = $f ;
//Parse the column properties
//Parse the column properties
@@ -359,14 +386,17 @@ class pagedTable
}
}
}
}
$totalWidth = 0 ;
$totalWidth = 0 ;
foreach ( $this -> fields as $r => $rval )
foreach ( $this -> fields as $r => $rval ) {
if ( $this -> style [ $r ][ 'showInTable' ] != '0' )
if ( $this -> style [ $r ][ 'showInTable' ] != '0' ) {
$totalWidth += $this -> style [ $r ][ 'colWidth' ];
$totalWidth += $this -> style [ $r ][ 'colWidth' ];
}
}
$this -> totalWidth = $totalWidth ;
$this -> totalWidth = $totalWidth ;
}
}
/**
/**
* Function setupFromTable
* Function setupFromTable
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @param eter string table
* @param eter string table
@@ -497,13 +527,15 @@ class pagedTable
//// var_dump2($this);
//// var_dump2($this);
// }
// }
/**
/**
* Function count
* Function count
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @return string
* @return string
*/
*/
function count ()
public function count ()
{
{
$this -> prepareQuery ();
$this -> prepareQuery ();
return $this -> query -> count ();
return $this -> query -> count ();
@@ -511,50 +543,54 @@ class pagedTable
/**
/**
* Function renderTitle
* Function renderTitle
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @return string
* @return string
*/
*/
function renderTitle ()
public function renderTitle ()
{
{
//Render Title
//Render Title
$thereisnotitle = true ;
$thereisnotitle = true ;
foreach ( $this -> fields as $r => $rval )
foreach ( $this -> fields as $r => $rval ) {
if ( $this -> fields [ $r ][ 'Type' ] === 'title' ) {
if ( $this -> fields [ $r ][ 'Type' ] === 'title' ) {
$this -> tpl -> assign ( " title " , $this -> fields [ $r ][ 'Label' ] );
$this -> tpl -> assign ( " title " , $this -> fields [ $r ][ 'Label' ] );
$thereisnotitle = false ;
$thereisnotitle = false ;
}
}
}
if ( $thereisnotitle ) {
if ( $thereisnotitle ) {
$this -> tpl -> assign ( " title " , ' ' );
$this -> tpl -> assign ( " title " , ' ' );
}
}
//Render headers
//Render headers
$this -> colCount = 0 ;
$this -> colCount = 0 ;
$this -> shownFields = '[' ;
$this -> shownFields = '[' ;
foreach ( $this -> fields as $r => $rval )
foreach ( $this -> fields as $r => $rval ) {
if ( $this -> style [ $r ][ 'showInTable' ] != '0' ) {
if ( $this -> style [ $r ][ 'showInTable' ] != '0' ) {
$this -> tpl -> newBlock ( " headers " );
$this -> tpl -> newBlock ( " headers " );
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'ASC' )) ? 'DESC' : 'ASC' );
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'ASC' )) ? 'DESC' : 'ASC' );
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'DESC' )) ? '' : $sortOrder );
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'DESC' )) ? '' : $sortOrder );
$this -> style [ $r ][ 'href' ] = $this -> ownerPage . '?order=' .
$this -> style [ $r ][ 'href' ] = $this -> ownerPage . '?order=' . ( $sortOrder !== '' ? urlencode ( G :: createUID ( '' , $this -> fields [ $r ][ 'Name' ] ) . '=' . $sortOrder ) : '' ) . '&page=' . $this -> currentPage ;
( $sortOrder !== '' ? urlencode ( G :: createUID ( '' , $this -> fields [ $r ][ 'Name' ]) . '=' . $sortOrder ) : '' )
. '&page=' . $this -> currentPage ;
$this -> style [ $r ][ 'onsort' ] = $this -> id . '.doSort("' . G :: createUID ( '' , $this -> fields [ $r ][ 'Name' ] ) . '" , "' . $sortOrder . '");return false;' ;
$this -> style [ $r ][ 'onsort' ] = $this -> id . '.doSort("' . G :: createUID ( '' , $this -> fields [ $r ][ 'Name' ] ) . '" , "' . $sortOrder . '");return false;' ;
if ( isset ( $this -> style [ $r ][ 'href' ]))
if ( isset ( $this -> style [ $r ][ 'href' ] )) {
$this -> tpl -> assign ( " href " , $this -> style [ $r ][ 'href' ] );
$this -> tpl -> assign ( " href " , $this -> style [ $r ][ 'href' ] );
if ( isset ( $this -> style [ $r ][ 'onsort' ]))
}
if ( isset ( $this -> style [ $r ][ 'onsort' ] )) {
$this -> tpl -> assign ( " onclick " , htmlentities ( $this -> style [ $r ][ 'onsort' ], ENT_QUOTES , 'UTF-8' ) );
$this -> tpl -> assign ( " onclick " , htmlentities ( $this -> style [ $r ][ 'onsort' ], ENT_QUOTES , 'UTF-8' ) );
if ( isset ( $this -> style [ $r ][ 'colWidth' ]))
}
if ( isset ( $this -> style [ $r ][ 'colWidth' ] )) {
$this -> tpl -> assign ( " width " , $this -> style [ $r ][ 'colWidth' ] );
$this -> tpl -> assign ( " width " , $this -> style [ $r ][ 'colWidth' ] );
if ( isset ( $this -> style [ $r ][ 'colWidth' ]))
}
if ( isset ( $this -> style [ $r ][ 'colWidth' ] )) {
$this -> tpl -> assign ( " widthPercent " , ( $this -> style [ $r ][ 'colWidth' ] * 100 / $this -> totalWidth ) . " % " );
$this -> tpl -> assign ( " widthPercent " , ( $this -> style [ $r ][ 'colWidth' ] * 100 / $this -> totalWidth ) . " % " );
if ( isset ( $this -> style [ $r ][ 'titleAlign' ]))
}
if ( isset ( $this -> style [ $r ][ 'titleAlign' ] )) {
$this -> tpl -> assign ( " align " , 'text-align:' . $this -> style [ $r ][ 'titleAlign' ] . ';' );
$this -> tpl -> assign ( " align " , 'text-align:' . $this -> style [ $r ][ 'titleAlign' ] . ';' );
}
if ( $this -> style [ $r ][ 'titleVisibility' ] != '0' ) {
if ( $this -> style [ $r ][ 'titleVisibility' ] != '0' ) {
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'ASC' )) ? 'b 2' : '' );
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'ASC' )) ? 'b 2' : '' );
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'DESC' )) ? 'b <' : $sortOrder );
$sortOrder = ((( isset ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] )) && ( $this -> aOrder [ $this -> fields [ $r ][ 'Name' ]] === 'DESC' )) ? 'b <' : $sortOrder );
$this -> tpl -> assign ( " header " , $this -> fields [ $r ][ 'Label' ] . $sortOrder );
$this -> tpl -> assign ( " header " , $this -> fields [ $r ][ 'Label' ] . $sortOrder );
$this -> tpl -> assign ( 'displaySeparator' ,
$this -> tpl -> assign ( 'displaySeparator' , (( $this -> colCount == 0 ) || ( ! isset ( $this -> fields [ $r ][ 'Label' ] )) || ( $this -> fields [ $r ][ 'Label' ] === '' )) ? 'display:none;' : '' );
(( $this -> colCount == 0 ) || ( ! isset ( $this -> fields [ $r ][ 'Label' ])) || ( $this -> fields [ $r ][ 'Label' ] === '' )) ? 'display:none;' : '' );
} else {
} else {
$this -> tpl -> assign ( 'displaySeparator' , 'display:none;' );
$this -> tpl -> assign ( 'displaySeparator' , 'display:none;' );
}
}
@@ -562,11 +598,13 @@ class pagedTable
$this -> shownFields .= ( $this -> shownFields !== '[' ) ? ',' : '' ;
$this -> shownFields .= ( $this -> shownFields !== '[' ) ? ',' : '' ;
$this -> shownFields .= '"' . $r . '"' ;
$this -> shownFields .= '"' . $r . '"' ;
}
}
}
$this -> shownFields .= ']' ;
$this -> shownFields .= ']' ;
}
}
/**
/**
* Function renderField
* Function renderField
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @param eter string row
* @param eter string row
@@ -574,7 +612,7 @@ class pagedTable
* @param eter string result
* @param eter string result
* @return string
* @return string
*/
*/
function renderField ( $row , $r , $result )
public function renderField ( $row , $r , $result )
{
{
global $G_DATE_FORMAT ;
global $G_DATE_FORMAT ;
//BEGIN: Special content: __sqlEdit__,__sqlDelete__
//BEGIN: Special content: __sqlEdit__,__sqlDelete__
@@ -597,36 +635,35 @@ class pagedTable
/*Accept dates like 20070515 without - or / to separate its parts*/
/*Accept dates like 20070515 without - or / to separate its parts*/
if ( strlen ( $value ) <= 10 && strlen ( $value ) > 4 ) {
if ( strlen ( $value ) <= 10 && strlen ( $value ) > 4 ) {
$value = str_replace ( '/' , '-' , $value );
$value = str_replace ( '/' , '-' , $value );
if ( strpos ( $value , '-' ) === FALSE )
if ( strpos ( $value , '-' ) === false ) {
$value = substr ( $value , 0 , 4 ) . '-' . substr ( $value , 4 , 2 ) . '-' . substr ( $value , 6 , 2 );
$value = substr ( $value , 0 , 4 ) . '-' . substr ( $value , 4 , 2 ) . '-' . substr ( $value , 6 , 2 );
}
}
}
}
}
$this -> tpl -> newBlock ( " field " );
$this -> tpl -> newBlock ( " field " );
$this -> tpl -> assign ( 'width' , $this -> style [ $r ][ 'colWidth' ] );
$this -> tpl -> assign ( 'width' , $this -> style [ $r ][ 'colWidth' ] );
$this -> tpl -> assign ( 'widthPercent' , ( $this -> style [ $r ][ 'colWidth' ] * 100 / $this -> totalWidth ) . '%' );
$this -> tpl -> assign ( 'widthPercent' , ( $this -> style [ $r ][ 'colWidth' ] * 100 / $this -> totalWidth ) . '%' );
$this -> tpl -> assign ( 'className' ,
$this -> tpl -> assign ( 'className' , ( isset ( $this -> style [ $r ][ 'colClassName' ] ) && ( $this -> style [ $r ][ 'colClassName' ])) ? $this -> style [ $r ][ 'colClassName' ] : $this -> tdClass );
( isset ( $this -> style [ $r ][ 'colClassName' ]) && ( $this -> style [ $r ][ 'colClassName' ])) ?
$this -> style [ $r ][ 'colClassName' ] : $this -> tdClass );
$this -> tpl -> assign ( 'style' , $this -> tdStyle );
$this -> tpl -> assign ( 'style' , $this -> tdStyle );
if ( isset ( $this -> style [ $r ][ 'align' ]))
if ( isset ( $this -> style [ $r ][ 'align' ] )) {
$this -> tpl -> assign ( " align " , $this -> style [ $r ][ 'align' ] );
$this -> tpl -> assign ( " align " , $this -> style [ $r ][ 'align' ] );
if ( isset ( $this -> style [ $r ][ 'colAlign' ]))
}
if ( isset ( $this -> style [ $r ][ 'colAlign' ] )) {
$this -> tpl -> assign ( " align " , $this -> style [ $r ][ 'colAlign' ] );
$this -> tpl -> assign ( " align " , $this -> style [ $r ][ 'colAlign' ] );
}
/**
/**
* BEGIN : Reeplace of @@, @%,... in field's attributes like onclick, link,
* BEGIN : Reeplace of @@, @%,...
* in field's attributes like onclick, link,
* ...
* ...
*/
*/
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> onclick )) {
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> onclick )) {
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] -> onclick
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> onclick = G :: replaceDataField ( $this -> style [ $r ][ 'onclick' ], $result );
= G :: replaceDataField ( $this -> style [ $r ][ 'onclick' ], $result );
}
}
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> link )) {
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> link )) {
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] -> link
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> link = G :: replaceDataField ( $this -> style [ $r ][ 'link' ], $result );
= G :: replaceDataField ( $this -> style [ $r ][ 'link' ], $result );
}
}
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> value )) {
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> value )) {
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] -> value
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> value = G :: replaceDataField ( $this -> style [ $r ][ 'value' ], $result );
= G :: replaceDataField ( $this -> style [ $r ][ 'value' ], $result );
}
}
/**
/**
* BREAK : Reeplace of @@, @%,...
* BREAK : Reeplace of @@, @%,...
@@ -637,9 +674,9 @@ class pagedTable
$this -> xmlForm -> setDefaultValues ();
$this -> xmlForm -> setDefaultValues ();
$this -> xmlForm -> setValues ( $result );
$this -> xmlForm -> setValues ( $result );
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> mode = 'view' ;
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> mode = 'view' ;
if (( array_search ( 'rendergrid' , get_class_methods ( get_class ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] )) ) !== FALSE )
if (( array_search ( 'rendergrid' , get_class_methods ( get_class ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] ) ) ) !== false ) || ( array_search ( 'renderGrid' , get_class_methods ( get_class ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] ) ) ) !== false )) {
|| ( array_search ( 'renderGrid' , get_class_methods ( get_class ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ])) ) !== FALSE )) {
$htmlField = $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> renderGrid ( array ( $value
$htmlField = $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] -> renderGrid ( array ( $value ) , $this -> xmlForm );
) , $this -> xmlForm );
$this -> tpl -> assign ( " value " , $htmlField [ 0 ] );
$this -> tpl -> assign ( " value " , $htmlField [ 0 ] );
} else {
} else {
}
}
@@ -647,16 +684,13 @@ class pagedTable
* CONTINUE : Reeplace of @@, @%,...
* CONTINUE : Reeplace of @@, @%,...
*/
*/
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> onclick )) {
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> onclick )) {
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] -> onclick
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> onclick = $this -> style [ $r ][ ' onclick' ];
= $this -> style [ $r ][ 'onclick' ];
}
}
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> link )) {
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> link )) {
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] -> link
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> link = $this -> style [ $r ][ 'link' ];
= $this -> style [ $r ][ 'link' ];
}
}
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> value )) {
if ( isset ( $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> value )) {
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ] ] -> value
$this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> value = $this -> style [ $r ][ 'value' ];
= $this -> style [ $r ][ 'value' ];
}
}
/**
/**
* END : Reeplace of @@, @%,...
* END : Reeplace of @@, @%,...
@@ -666,77 +700,83 @@ class pagedTable
/**
/**
* Function defaultStyle
* Function defaultStyle
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @access public
* @return string
* @return string
*/
*/
function defaultStyle ()
public function defaultStyle ()
{
{
// for($r=1;$r<=sizeof($this->fields);$r++)
// for($r=1;$r<=sizeof($this->fields);$r++)
foreach ( $this -> fields as $r => $rval ) {
foreach ( $this -> fields as $r => $rval ) {
$this -> style [ $r ] = array ( 'showInTable' => '1' ,
$this -> style [ $r ] = array ( 'showInTable' => '1' , 'titleVisibility' => '1' , 'colWidth' => '150 ' , 'onclick' => '' , 'event' => ''
'titleVisibility' => '1' ,
'colWidth' => '150' ,
'onclick' => '' ,
'event' => ''
);
);
//Some widths
//Some widths
if ( ! ( strpos ( ' date linknew ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === FALSE ))
if ( ! ( strpos ( ' date linknew ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === false )) {
$this -> style [ $r ][ 'colWidth' ] = '70' ;
$this -> style [ $r ][ 'colWidth' ] = '70' ;
//Data source:
//Data source:
if ( ! ( strpos ( ' title button linknew image-text jslink ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === FALSE ))
}
if ( ! ( strpos ( ' title button linknew image-text jslink ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === false )) {
$this -> style [ $r ][ 'data' ] = '' ; //If the control is a link it shows the label
$this -> style [ $r ][ 'data' ] = '' ; //If the control is a link it shows the label
else
} else {
$this -> style [ $r ][ 'data' ] = $this -> fields [ $r ][ 'Name' ]; //ELSE: The data value for that field
$this -> style [ $r ][ 'data' ] = $this -> fields [ $r ][ 'Name' ]; //ELSE: The data value for that field
}
//Hidden fields
//Hidden fields
if ( ! isset ( $this -> style [ $r ][ 'showInTable' ] )) {
if ( ! isset ( $this -> style [ $r ][ 'showInTable' ] )) {
if ( ! ( strpos ( ' title button endgrid2 submit password ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === FALSE )){
if ( ! ( strpos ( ' title button endgrid2 submit password ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === false )) {
$this -> style [ $r ][ 'showInTable' ] = '0' ;
$this -> style [ $r ][ 'showInTable' ] = '0' ;
}
} else {
else {
$this -> style [ $r ][ 'showInTable' ] = '1' ;
$this -> style [ $r ][ 'showInTable' ] = '1' ;
}
}
}
}
//Hidden titles
//Hidden titles
if ( ! ( strpos ( ' linknew button endgrid2 ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === FALSE )){
if ( ! ( strpos ( ' linknew button endgrid2 ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === false )) {
$this -> style [ $r ][ 'titleVisibility' ] = '0' ;
$this -> style [ $r ][ 'titleVisibility' ] = '0' ;
}
}
//Align titles
//Align titles
$this -> style [ $r ][ 'titleAlign' ] = 'center' ;
$this -> style [ $r ][ 'titleAlign' ] = 'center' ;
//Align fields
//Align fields
if ( isset ( $_SESSION [ 'SET_DIRECTION' ]) && ( strcasecmp ( $_SESSION [ 'SET_DIRECTION' ], 'rtl' ) === 0 ))
if ( isset ( $_SESSION [ 'SET_DIRECTION' ] ) && ( strcasecmp ( $_SESSION [ 'SET_DIRECTION' ], 'rtl' ) === 0 )) {
$this -> style [ $r ][ 'align' ] = 'right' ;
$this -> style [ $r ][ 'align' ] = 'right' ;
else
} else {
$this -> style [ $r ][ 'align' ] = 'left' ;
$this -> style [ $r ][ 'align' ] = 'left' ;
if ( ! ( strpos ( ' linknew date ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === FALSE )){
}
if ( ! ( strpos ( ' linknew date ' , ' ' . $this -> fields [ $r ][ 'Type' ] . ' ' ) === false )) {
$this -> style [ $r ][ 'align' ] = 'center' ;
$this -> style [ $r ][ 'align' ] = 'center' ;
}
}
}
}
// Adjust the columns width to prevent overflow the page width
// Adjust the columns width to prevent overflow the page width
//Render headers
//Render headers
$totalWidth = 0 ;
$totalWidth = 0 ;
foreach ( $this -> fields as $r => $rval )
foreach ( $this -> fields as $r => $rval ) {
if ( $this -> style [ $r ][ 'showInTable' ] != '0' )
if ( $this -> style [ $r ][ 'showInTable' ] != '0' ) {
$totalWidth += $this -> style [ $r ][ 'colWidth' ];
$totalWidth += $this -> style [ $r ][ 'colWidth' ];
}
}
$this -> totalWidth = $totalWidth ;
$this -> totalWidth = $totalWidth ;
$maxWidth = 1800 ;
$maxWidth = 1800 ;
$proportion = $totalWidth / $maxWidth ;
$proportion = $totalWidth / $maxWidth ;
if ( $proportion > 1 )
if ( $proportion > 1 ) {
$this -> totalWidth = 1800 ;
$this -> totalWidth = 1800 ;
if ( $proportion > 1 )
}
foreach ( $this -> fields as $r => $rval )
if ( $proportion > 1 ) {
if ( $this -> style [ $r ][ 'showInTable' ] != '0' )
foreach ( $this -> fields as $r => $rval ) {
if ( $this -> style [ $r ][ 'showInTable' ] != '0' ) {
$this -> style [ $r ][ 'colWidth' ] = $this -> style [ $r ][ 'colWidth' ] / $proportion ;
$this -> style [ $r ][ 'colWidth' ] = $this -> style [ $r ][ 'colWidth' ] / $proportion ;
}
}
}
}
}
/**
/**
* Function renderTable
* Function renderTable
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @param $block : = 'content'(Prints contentBlock only)
* @param $block : = 'content'(Prints contentBlock only)
* @access public
* @access public
* @return string
* @return string
*/
*/
function renderTable ( $block = '' )
public function renderTable ( $block = '' )
{
{
// DBConnection
// DBConnection
$this -> prepareQuery ();
$this -> prepareQuery ();
@@ -749,7 +789,9 @@ class pagedTable
// Prepare the template
// Prepare the template
$this -> tpl = new TemplatePower ( PATH_CORE . $this -> template );
$this -> tpl = new TemplatePower ( PATH_CORE . $this -> template );
$this -> tpl -> prepare ();
$this -> tpl -> prepare ();
/********** HEAD BLOCK ***************/
/**
* ******** HEAD BLOCK **************
*/
if (( $block === '' ) || ( $block === 'head' )) {
if (( $block === '' ) || ( $block === 'head' )) {
$this -> tpl -> newBlock ( 'headBlock' );
$this -> tpl -> newBlock ( 'headBlock' );
$this -> tpl -> assign ( 'pagedTable_Id' , $this -> id );
$this -> tpl -> assign ( 'pagedTable_Id' , $this -> id );
@@ -757,18 +799,22 @@ class pagedTable
$this -> tpl -> assign ( 'pagedTable_Height' , $this -> xmlForm -> height );
$this -> tpl -> assign ( 'pagedTable_Height' , $this -> xmlForm -> height );
if ( file_exists ( $this -> xmlForm -> home . $this -> filterForm . '.xml' )) {
if ( file_exists ( $this -> xmlForm -> home . $this -> filterForm . '.xml' )) {
$filterForm = new filterForm ( $this -> filterForm , $this -> xmlForm -> home );
$filterForm = new filterForm ( $this -> filterForm , $this -> xmlForm -> home );
if ( $this -> menu === '' )
if ( $this -> menu === '' ) {
$this -> menu = 'gulliver/pagedTable_Options' ;
$this -> menu = 'gulliver/pagedTable_Options' ;
}
}
}
if ( file_exists ( $this -> xmlForm -> home . $this -> menu . '.xml' )) {
if ( file_exists ( $this -> xmlForm -> home . $this -> menu . '.xml' )) {
$menu = new xmlMenu ( $this -> menu , $this -> xmlForm -> home );
$menu = new xmlMenu ( $this -> menu , $this -> xmlForm -> home );
$this -> tpl -> newBlock ( 'headerBlock' );
$this -> tpl -> newBlock ( 'headerBlock' );
$template = PATH_CORE . 'templates' . PATH_SEP . $menu -> type . '.html' ;
$template = PATH_CORE . 'templates' . PATH_SEP . $menu -> type . '.html' ;
$menu -> setValues ( $this -> xmlForm -> values );
$menu -> setValues ( $this -> xmlForm -> values );
$menu -> setValues ( array ( 'PAGED_TABLE_ID' => $this -> id ));
$menu -> setValues ( array ( 'PAGED_TABLE_ID' => $this -> id
$menu -> setValues ( array ( 'PAGED_TABLE_FAST_SEARCH' => $this -> fastSearch ) );
) );
$menu -> setValues ( array ( 'PAGED_TABLE_FAST_SEARCH' => $this -> fastSearch
) );
if ( isset ( $filterForm -> name )) {
if ( isset ( $filterForm -> name )) {
$menu -> setValues ( array ( 'SEARCH_FILTER_FORM' => $filterForm -> name ));
$menu -> setValues ( array ( 'SEARCH_FILTER_FORM' => $filterForm -> name
) );
}
}
$this -> tpl -> assign ( 'content' , $menu -> render ( $template , $scriptCode ) );
$this -> tpl -> assign ( 'content' , $menu -> render ( $template , $scriptCode ) );
$oHeadPublisher = & headPublisher :: getSingleton ();
$oHeadPublisher = & headPublisher :: getSingleton ();
@@ -782,17 +828,22 @@ class pagedTable
$filterForm -> ajaxServer = '../gulliver/defaultAjax' ;
$filterForm -> ajaxServer = '../gulliver/defaultAjax' ;
$template = PATH_CORE . 'templates/' . $filterForm -> type . '.html' ;
$template = PATH_CORE . 'templates/' . $filterForm -> type . '.html' ;
$filterForm -> setValues ( $this -> xmlForm -> values );
$filterForm -> setValues ( $this -> xmlForm -> values );
$filterForm -> setValues ( array ( 'PAGED_TABLE_ID' => $this -> id ));
$filterForm -> setValues ( array ( 'PAGED_TABLE_ID' => $this -> id
$filterForm -> setValues ( array ( 'PAGED_TABLE_FAST_SEARCH' => $this -> fastSearch )) ;
) );
$filterForm -> setValues ( array ( 'PAGED_TABLE_FAST_SEARCH' => $this -> fastSearch
) );
$this -> tpl -> assign ( 'content' , $filterForm -> render ( $template , $scriptCode ) );
$this -> tpl -> assign ( 'content' , $filterForm -> render ( $template , $scriptCode ) );
$oHeadPublisher = & headPublisher :: getSingleton ();
$oHeadPublisher = & headPublisher :: getSingleton ();
$oHeadPublisher -> addScriptFile ( $filterForm -> scriptURL );
$oHeadPublisher -> addScriptFile ( $filterForm -> scriptURL );
$oHeadPublisher -> addScriptCode ( $scriptCode );
$oHeadPublisher -> addScriptCode ( $scriptCode );
if ( isset ( $_SESSION ))
if ( isset ( $_SESSION )) {
$_SESSION [ $filterForm -> id ] = $filterForm -> values ;
$_SESSION [ $filterForm -> id ] = $filterForm -> values ;
}
}
}
}
/********** CONTENT BLOCK ***************/
}
/**
* ******** CONTENT BLOCK **************
*/
if (( $block === '' ) || ( $block === 'content' )) {
if (( $block === '' ) || ( $block === 'content' )) {
$this -> tpl -> newBlock ( 'contentBlock' );
$this -> tpl -> newBlock ( 'contentBlock' );
$this -> tpl -> assign ( 'gridWidth' , '=[' . substr ( $this -> gridWidth , 1 ) . ']' );
$this -> tpl -> assign ( 'gridWidth' , '=[' . substr ( $this -> gridWidth , 1 ) . ']' );
@@ -816,7 +867,7 @@ class pagedTable
for ( $j = 0 ; $j < $this -> query -> count (); $j ++ ) {
for ( $j = 0 ; $j < $this -> query -> count (); $j ++ ) {
$result = $this -> query -> read ();
$result = $this -> query -> read ();
//if (($j>=(($this->currentPage-1)*$this->rowsPerPage))&&($j<(($this->currentPage)*$this->rowsPerPage)))
//if (($j>=(($this->currentPage-1)*$this->rowsPerPage))&&($j<(($this->currentPage)*$this->rowsPerPage)))
{
//{
$gridRows ++ ;
$gridRows ++ ;
$this -> tpl -> newBlock ( " row " );
$this -> tpl -> newBlock ( " row " );
$this -> tpl -> assign ( " class " , " Row " . (( $j % 2 ) + 1 ) );
$this -> tpl -> assign ( " class " , " Row " . (( $j % 2 ) + 1 ) );
@@ -831,12 +882,11 @@ class pagedTable
$result1 = array_merge ( $this -> xmlForm -> values , $result1 );
$result1 = array_merge ( $this -> xmlForm -> values , $result1 );
$this -> tdStyle = $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> tdStyle ( $result1 , $this -> xmlForm );
$this -> tdStyle = $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> tdStyle ( $result1 , $this -> xmlForm );
$this -> tdClass = $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> tdClass ( $result1 , $this -> xmlForm );
$this -> tdClass = $this -> xmlForm -> fields [ $this -> fields [ $r ][ 'Name' ]] -> tdClass ( $result1 , $this -> xmlForm );
}
} elseif ( $this -> style [ $r ][ 'showInTable' ] != '0' ) {
elseif ( $this -> style [ $r ][ 'showInTable' ] != '0' ){
$this -> renderField ( $j + 1 , $r , $result );
$this -> renderField ( $j + 1 , $r , $result );
}
}
}
}
}
//}
}
}
$this -> tpl -> assign ( '_ROOT.gridRows' , '=' . $gridRows ); //number of rows in the current page
$this -> tpl -> assign ( '_ROOT.gridRows' , '=' . $gridRows ); //number of rows in the current page
$this -> tpl -> newBlock ( 'rowTag' );
$this -> tpl -> newBlock ( 'rowTag' );
@@ -849,8 +899,7 @@ class pagedTable
$prevAjax = $this -> id . " .doGoToPage( " . $prevpage . " );return false; " ;
$prevAjax = $this -> id . " .doGoToPage( " . $prevpage . " );return false; " ;
$first = " <a href= \" " . htmlentities ( $firstUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $firstAjax . " \" class='firstPage'> </a> " ;
$first = " <a href= \" " . htmlentities ( $firstUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $firstAjax . " \" class='firstPage'> </a> " ;
$prev = " <a href= \" " . htmlentities ( $prevUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $prevAjax . " \" class='previousPage'> </a> " ;
$prev = " <a href= \" " . htmlentities ( $prevUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $prevAjax . " \" class='previousPage'> </a> " ;
}
} else {
else {
$first = " <a class='noFirstPage'> </a> " ;
$first = " <a class='noFirstPage'> </a> " ;
$prev = " <a class='noPreviousPage'> </a> " ;
$prev = " <a class='noPreviousPage'> </a> " ;
}
}
@@ -862,25 +911,28 @@ class pagedTable
$nextAjax = $this -> id . " .doGoToPage( " . $nextpage . " );return false; " ;
$nextAjax = $this -> id . " .doGoToPage( " . $nextpage . " );return false; " ;
$next = " <a href= \" " . htmlentities ( $nextUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $nextAjax . " \" class='nextPage'> </a> " ;
$next = " <a href= \" " . htmlentities ( $nextUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $nextAjax . " \" class='nextPage'> </a> " ;
$last = " <a href= \" " . htmlentities ( $lastUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $lastAjax . " \" class='lastPage'> </a> " ;
$last = " <a href= \" " . htmlentities ( $lastUrl , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $lastAjax . " \" class='lastPage'> </a> " ;
}
} else {
else {
$next = " <a class='noNextPage'> </a> " ;
$next = " <a class='noNextPage'> </a> " ;
$last = " <a class='noLastPage'> </a> " ;
$last = " <a class='noLastPage'> </a> " ;
}
}
$pagesEnum = '' ;
$pagesEnum = '' ;
for ( $r = 1 ; $r <= $this -> totpages ; $r ++ )
for ( $r = 1 ; $r <= $this -> totpages ; $r ++ ) {
if (( $r >= ( $this -> currentPage - 5 )) && ( $r <= ( $this -> currentPage + 5 ))) {
if (( $r >= ( $this -> currentPage - 5 )) && ( $r <= ( $this -> currentPage + 5 ))) {
$pageAjax = $this -> id . " .doGoToPage( " . $r . " );return false; " ;
$pageAjax = $this -> id . " .doGoToPage( " . $r . " );return false; " ;
if ( $r != $this -> currentPage )
if ( $r != $this -> currentPage ) {
$pagesEnum .= " <a href= \" " . htmlentities ( $this -> ownerPage . '?order=' . $this -> orderBy . '&page=' . $r , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $pageAjax . " \" > " . $r . " </a> " ;
$pagesEnum .= " <a href= \" " . htmlentities ( $this -> ownerPage . '?order=' . $this -> orderBy . '&page=' . $r , ENT_QUOTES , 'utf-8' ) . " \" onclick= \" " . $pageAjax . " \" > " . $r . " </a> " ;
else
} else {
$pagesEnum .= " <a> " . $r . " </a> " ;
$pagesEnum .= " <a> " . $r . " </a> " ;
}
}
}
}
if ( $this -> query -> count () === 0 ) {
if ( $this -> query -> count () === 0 ) {
$this -> tpl -> newBlock ( 'norecords' );
$this -> tpl -> newBlock ( 'norecords' );
$this -> tpl -> assign ( " columnCount " , $this -> colCount );
$this -> tpl -> assign ( " columnCount " , $this -> colCount );
$noRecordsFound = 'ID_NO_RECORDS_FOUND' ;
$noRecordsFound = 'ID_NO_RECORDS_FOUND' ;
if ( G :: LoadTranslation ( $noRecordsFound )) $noRecordsFound = G :: LoadTranslation ( $noRecordsFound );
if ( G :: LoadTranslation ( $noRecordsFound )) {
$noRecordsFound = G :: LoadTranslation ( $noRecordsFound );
}
$this -> tpl -> assign ( " noRecordsFound " , $noRecordsFound );
$this -> tpl -> assign ( " noRecordsFound " , $noRecordsFound );
}
}
if ( ! $this -> disableFooter ) {
if ( ! $this -> disableFooter ) {
@@ -909,9 +961,11 @@ class pagedTable
} else {
} else {
$this -> tpl -> assign ( " fastSearchStyle " , 'visibility:hidden;' );
$this -> tpl -> assign ( " fastSearchStyle " , 'visibility:hidden;' );
}
}
if ( $this -> addRow )
if ( $this -> addRow ) {
if ( $this -> sqlInsert != '' )
if ( $this -> sqlInsert != '' ) {
$this -> tpl -> assign ( " insert " , '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this -> popupPage . '\');return false;">' ./* G :: LoadXml ( 'labels' , 'ID_ADD_NEW' ) */ 'ID_ADD_NEW' . '</a>' );
$this -> tpl -> assign ( " insert " , '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this -> popupPage . '\');return false;">' ./* G :: LoadXml ( 'labels' , 'ID_ADD_NEW' ) */ 'ID_ADD_NEW' . '</a>' );
}
}
$this -> tpl -> assign ( " pagesEnum " , $pagesEnum );
$this -> tpl -> assign ( " pagesEnum " , $pagesEnum );
}
}
?>
?>
@@ -935,7 +989,9 @@ var popupHeight<?php echo '='.$this->popupHeight?>;
</script>
</script>
<?php
<?php
}
}
/********** CLOSE BLOCK ***************/
/**
* ******** CLOSE BLOCK **************
*/
if (($block === '') || ($block === 'close')) {
if (($block === '') || ($block === 'close')) {
$this->tpl->newBlock( "closeBlock" );
$this->tpl->newBlock( "closeBlock" );
}
}
@@ -949,12 +1005,13 @@ var popupHeight<?php echo '='.$this->popupHeight?>;
/**
/**
* Function printForm
* Function printForm
*
* @access public
* @access public
* @param string $filename
* @param string $filename
* @param array $data
* @param array $data
* @return void
* @return void
*/
*/
function printForm($filename,$data= array())
public function printForm ($filename, $data = array())
{
{
// $G_FORM = new Form($filename, PATH_XMLFORM);
// $G_FORM = new Form($filename, PATH_XMLFORM);
// echo $G_FORM->render(PATH_TPL . 'xmlform.html', $scriptContent);
// echo $G_FORM->render(PATH_TPL . 'xmlform.html', $scriptContent);
@@ -967,13 +1024,14 @@ var popupHeight<?php echo '='.$this->popupHeight?>;
/**
/**
* Function var_dump2
* Function var_dump2
*
* @access public
* @access public
* @param string $o
* @param string $o
* @return void
* @return void
*/
*/
function var_dump2 ($o)
function var_dump2 ($o)
{
{
if (is_object($o) || is_array($o))
if (is_object( $o ) || is_array( $o )) {
foreach ($o as $key => $value) {
foreach ($o as $key => $value) {
echo ('<b>');
echo ('<b>');
var_dump( $key );
var_dump( $key );
@@ -981,6 +1039,8 @@ function var_dump2($o)
print_r( $value );
print_r( $value );
echo ('<br>');
echo ('<br>');
}
}
else
} else {
var_dump( $o );
var_dump( $o );
}
}
}