CODE STYLE /gulliver/system/

files modified:   class.dvEditor.php
                  class.error.php
                  class.pagedTable.php
                  class.phpSqlParser.php
                  class.pmException.php
                  class.xmlMenu.php
This commit is contained in:
Ralph Asendeteufrer
2012-10-17 14:28:05 -04:00
parent 6e190143c8
commit a226a645d1
6 changed files with 2568 additions and 3043 deletions

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.dvEditor.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -27,29 +29,34 @@
/**
* XmlForm_Field_HTML class definition
* It is useful to see dynaforms how are built
*
* @package gulliver.system
* @author
*
* @copyright (C) 2002 by Colosa Development Team.
*
*/
class XmlForm_Field_HTML extends XmlForm_Field
{
var $toolbarSet = 'smallToolBar';
var $width = '100%';
var $height = '200' ;
var $defaultValue ='<br/>';
public $toolbarSet = 'smallToolBar';
public $width = '100%';
public $height = '200';
public $defaultValue = '<br/>';
/**
* render function is drawing the dynaform
*
* @author
*
*
* @access public
* @param string $value
* @param string $owner
* @return string
*
*/
function render( $value , $owner=NULL ) {
public function render ($value, $owner = null)
{
$value = ($value == '') ? '<br/>' : $value;
$html = "<div style='width:" . $this->width . ";'>";
$html .= "<input id='form[" . $this->name . "]' name='form[" . $this->name . "]' type='hidden' value=' " . htmlentities( $value, ENT_QUOTES, 'UTF-8' ) . "' />";
@@ -59,19 +66,23 @@ class XmlForm_Field_HTML extends XmlForm_Field
/**
* attachEvents function is putting its events
*
* @author
*
*
* @access public
* @param string $element
* @return string
*
*/
function attachEvents($element) {
public function attachEvents ($element)
{
$html = 'window._editor' . $this->name . '=new DVEditor(getField("' . $this->name . '").parentNode,getField("' . $this->name . '").value,element,"' . $this->height . '","' . $this->mode . '");';
if($this->mode=="edit")
if ($this->mode == "edit") {
$html .= 'window._editor' . $this->name . '.loadToolBar("/js/dveditor/core/toolbars/' . $this->toolbarSet . '.html");';
}
$html .= 'window._editor' . $this->name . '.syncHidden("window._editor' . $this->name . '");';
return $html;
}
}

View File

@@ -1,6 +1,7 @@
<?php
/**
* class.error.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -25,7 +26,9 @@
*/
/**
*
* @package gulliver.system
*
*/
require_once 'PEAR.php';
@@ -33,7 +36,6 @@ require_once 'PEAR.php';
/**
* G_Error implements a class for reporting portable database error
* messages
*
*/
define( 'G_ERROR', - 100 );
@@ -57,11 +59,14 @@ define('G_ERROR_DUE_DATE', -117);
define( 'G_ERROR_ALREADY_ASSIGNED', - 118 );
/**
*
* @package gulliver.system
*
*/
class G_Error extends PEAR_Error
{
/**
* G_Error constructor
*
@@ -72,33 +77,33 @@ class G_Error extends PEAR_Error
*
* @see PEAR_Error
*/
function G_Error($code = G_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null) {
public function G_Error ($code = G_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null)
{
if (is_int( $code )) {
$this->PEAR_Error( 'G Error: ' . G_Error::errorMessage( $code ), $code, $mode, $level, $debuginfo );
} else {
$this->PEAR_Error( "G Error: $code", DB_ERROR, $mode, $level, $debuginfo );
}
}
/**
* this function returns the kind of Error
*
* @author
*
* @access public
* @param string $code
* @return string
*
*/
function errorMessage ( $code ) {
public function errorMessage ($code)
{
static $gErrorMessages;
if ($code < 0 && $code > - 100) {
return DB::errorMessage( $code );
}
else {
} else {
if (! isset( $gErrorMessages )) {
$gErrorMessages = array(
G_ERROR => 'unknown error',
DB_ERROR_FEATURE_NOT_AVAILABLE => 'this function or feature is not available for this database engine',
DB_ERROR_OBJECT_NOT_DEFINED => 'Object or variable not defined',
G_ERROR_WARNING_MESSAGE => 'Warning message',
$gErrorMessages = array (G_ERROR => 'unknown error',DB_ERROR_FEATURE_NOT_AVAILABLE => 'this function or feature is not available for this database engine',DB_ERROR_OBJECT_NOT_DEFINED => 'Object or variable not defined',G_ERROR_WARNING_MESSAGE => 'Warning message'
);
}
/*
@@ -110,3 +115,4 @@ class G_Error extends PEAR_Error
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,24 @@
<?php
/**
* HttpProxyController
*
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
* @package gulliver.system
* @access public
*/
class PMException extends Exception
{
public function __construct($message, $code = 0, $previous = null) {
public function __construct ($message, $code = 0, $previous = null)
{
//parent::__construct($message, 1, $previous);
parent::__construct( $message, 1 );
}
public function __toString() {
public function __toString ()
{
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.xmlMenu.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -25,27 +27,29 @@
*/
/**
*
* @package gulliver.system
*/
class xmlMenu extends form
{
var $type = 'xmlmenu';
public $type = 'xmlmenu';
}
/**
* XmlForm_Field_XmlMenu
*
* extends XmlForm_Field
*
* @package gulliver.system
*
*/
class XmlForm_Field_XmlMenu extends XmlForm_Field
{
var $xmlfile = '';
var $type = 'xmlmenuDyn';
var $xmlMenu;
var $home ='';
var $withoutLabel = true;
public $xmlfile = '';
public $type = 'xmlmenuDyn';
public $xmlMenu;
public $home = '';
public $withoutLabel = true;
/**
* XmlForm_Field_XmlMenu
@@ -57,7 +61,7 @@
*
* @return none
*/
function XmlForm_Field_XmlMenu($xmlNode, $lang = 'en', $home = '', $owner)
public function XmlForm_Field_XmlMenu ($xmlNode, $lang = 'en', $home = '', $owner = null)
{
parent::XmlForm_Field( $xmlNode, $lang, $home, $owner );
$this->home = $home;
@@ -70,7 +74,7 @@
*
* @return object $out
*/
function render( $value )
public function render ($value)
{
$this->xmlMenu = new xmlMenu( $this->xmlfile, $this->home );
$this->xmlMenu->setValues( $value );
@@ -90,10 +94,9 @@
*
* @return none
*/
function renderGrid ($value)
public function renderGrid ($value)
{
return $this->render( $value );
}
}