CODE STYLE class.propelTable.php
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* class.propelTable.php
|
||||
*
|
||||
* @package workflow.gulliver.system
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -31,6 +32,7 @@
|
||||
|
||||
/**
|
||||
* Class pagedTable
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com> *
|
||||
* @access public
|
||||
* @package workflow.gulliver.system
|
||||
@@ -80,6 +82,7 @@ class propelTable
|
||||
var $editRow = false;
|
||||
var $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 = "";
|
||||
@@ -100,12 +103,14 @@ class propelTable
|
||||
//Config Save definition
|
||||
var $__Configuration = 'orderBy,filter,fastSearch,style/*/showInTable'; //order,rowsPerPage,disableFooter';
|
||||
|
||||
|
||||
//Variable for MasterDetail feature
|
||||
var $masterdetail = '';
|
||||
var $title;
|
||||
|
||||
/**
|
||||
* Function prepareQuery
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param string $limitPage
|
||||
@@ -121,8 +126,7 @@ class propelTable
|
||||
foreach ($aSB as $sBy) {
|
||||
$subFilter .= ($subFilter !== '') ? ' OR ' : '';
|
||||
//TODO: Get DATABASE type from Criteria, I think sql delimeter is needed too
|
||||
$subFilter .= $sBy . ' LIKE "%'.
|
||||
G::sqlEscape($this->fastSearch ).'%"';
|
||||
$subFilter .= $sBy . ' LIKE "%' . G::sqlEscape( $this->fastSearch ) . '%"';
|
||||
}
|
||||
if ($subFilter !== '') {
|
||||
//Get the first defined table in Criteria.
|
||||
@@ -177,13 +181,14 @@ class propelTable
|
||||
$this->criteria->addDescendingOrderByColumn( $field );
|
||||
}
|
||||
}
|
||||
/** Add limits */
|
||||
/**
|
||||
* Add limits
|
||||
*/
|
||||
$this->criteria->setLimit( 0 );
|
||||
$this->criteria->setOffset( 0 );
|
||||
if ($this->criteria->getDbName() == 'dbarray') {
|
||||
$this->totRows = ArrayBasePeer::doCount( $this->criteria );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->totRows = GulliverBasePeer::doCount( $this->criteria );
|
||||
}
|
||||
$this->totPages = ceil( $this->totRows / $this->rowsPerPage );
|
||||
@@ -211,15 +216,20 @@ class propelTable
|
||||
$this->id = $xmlForm->id;
|
||||
//$this->sqlConnection=((isset($this->xmlForm->sqlConnection))?$this->xmlForm->sqlConnection:'');
|
||||
if (isset( $_GET['page'] ))
|
||||
$this->currentPage = $_GET['page']; else $this->currentPage = 1;
|
||||
$this->currentPage = $_GET['page'];
|
||||
else
|
||||
$this->currentPage = 1;
|
||||
if (isset( $_GET['order'] ))
|
||||
$this->orderBy = urldecode($_GET['order']); else $this->orderBy = "";
|
||||
$this->orderBy = urldecode( $_GET['order'] );
|
||||
else
|
||||
$this->orderBy = "";
|
||||
if (isset( $_GET['filter'] ))
|
||||
$this->filter = urldecode($_GET['filter']); else $this->filter = "";
|
||||
$this->filter = urldecode( $_GET['filter'] );
|
||||
else
|
||||
$this->filter = "";
|
||||
if ($xmlForm->ajaxServer != '') {
|
||||
$this->ajaxServer = G::encryptLink( $xmlForm->ajaxServer );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->ajaxServer = G::encryptLink( '../gulliver/propelTableAjax' );
|
||||
}
|
||||
$this->ownerPage = G::encryptLink( SYS_CURRENT_URI );
|
||||
@@ -236,12 +246,13 @@ class propelTable
|
||||
foreach ($this->masterdetail as $keyMasterDetail => $valueMasterDetail) {
|
||||
$this->masterdetail[$keyMasterDetail] = trim( $valueMasterDetail );
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->masterdetail = array ();
|
||||
}
|
||||
//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;
|
||||
@@ -254,7 +265,8 @@ class propelTable
|
||||
//Set the default settings
|
||||
$this->defaultStyle();
|
||||
//continue with the setup
|
||||
$this->gridWidth=''; $this->gridFields='';
|
||||
$this->gridWidth = '';
|
||||
$this->gridFields = '';
|
||||
foreach ($this->xmlForm->fields as $f => $v) {
|
||||
$r = $f;
|
||||
//Parse the column properties
|
||||
@@ -279,6 +291,7 @@ class propelTable
|
||||
|
||||
/**
|
||||
* Function count
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @return string
|
||||
@@ -291,6 +304,7 @@ class propelTable
|
||||
|
||||
/**
|
||||
* Function renderTitle
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @return string
|
||||
@@ -299,7 +313,8 @@ class propelTable
|
||||
{
|
||||
//fix the bug about showing hidden fields in propel table.
|
||||
foreach ($this->fields as $r => $rval) {
|
||||
if ( $this->style[$r]['type'] == 'hidden') $this->style[$r]['showInTable'] = '0';
|
||||
if ($this->style[$r]['type'] == 'hidden')
|
||||
$this->style[$r]['showInTable'] = '0';
|
||||
}
|
||||
//Render headers
|
||||
$this->colCount = 0;
|
||||
@@ -310,9 +325,7 @@ class propelTable
|
||||
$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 !=='' ? ( G::createUID('',$this->fields[$r]['Name'] ) . '=' . $sortOrder):'')
|
||||
. '&page=' . $this->currentPage;
|
||||
$this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? (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'] ))
|
||||
$this->tpl->assign( "href", $this->style[$r]['href'] );
|
||||
@@ -338,8 +351,7 @@ class propelTable
|
||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? '<img src="/images/arrow-up.gif">' : '');
|
||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '<img src="/images/arrow-down.gif">' : $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;' );
|
||||
}
|
||||
@@ -352,6 +364,7 @@ class propelTable
|
||||
|
||||
/**
|
||||
* Function renderField
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param eter string row
|
||||
@@ -381,16 +394,22 @@ class propelTable
|
||||
$this->tpl->assign( "alignAttr", $alignAttr );
|
||||
$fieldName = $this->fields[$r]['Name'];
|
||||
$fieldClass = get_class( $this->xmlForm->fields[$fieldName] );
|
||||
/*** 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']]->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[$fieldName]->value )) {
|
||||
$this->xmlForm->fields[$fieldName]->value = G::replaceDataField( $styleData['value'], $result );
|
||||
}
|
||||
/*** END : Reeplace of @@, @%,... */
|
||||
/*** Rendering of the field */
|
||||
/**
|
||||
* * END : Reeplace of @@, @%,...
|
||||
*/
|
||||
/**
|
||||
* * Rendering of the field
|
||||
*/
|
||||
$this->xmlForm->fields[$fieldName]->mode = 'view';
|
||||
$this->xmlForm->setDefaultValues();
|
||||
$this->xmlForm->setValues( $result );
|
||||
@@ -423,6 +442,7 @@ class propelTable
|
||||
|
||||
/**
|
||||
* Function defaultStyle
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @return string
|
||||
@@ -430,11 +450,8 @@ class propelTable
|
||||
function defaultStyle ()
|
||||
{
|
||||
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))
|
||||
$this->style[$r]['colWidth'] = '70';
|
||||
@@ -447,8 +464,7 @@ class propelTable
|
||||
if (! isset( $this->style[$r]['showInTable'] )) {
|
||||
if (! (strpos( ' title button endgrid2 submit password ', ' ' . $this->fields[$r]['Type'] . ' ' ) === FALSE)) {
|
||||
$this->style[$r]['showInTable'] = '0';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->style[$r]['showInTable'] = '1';
|
||||
}
|
||||
}
|
||||
@@ -486,6 +502,7 @@ class propelTable
|
||||
|
||||
/**
|
||||
* Function renderTable
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @param eter $block : = 'content'(Prints contentBlock only)
|
||||
* @access public
|
||||
@@ -508,7 +525,8 @@ class propelTable
|
||||
$oHeadPublisher->addInstanceModule( 'leimnud', 'panel' );
|
||||
$time_start = microtime( true );
|
||||
$this->prepareQuery( true );
|
||||
$time_end = microtime(true); $time = $time_end - $time_start;
|
||||
$time_end = microtime( true );
|
||||
$time = $time_end - $time_start;
|
||||
// verify if there are templates folders registered, template and method folders are the same
|
||||
$folderTemplate = explode( '/', $this->template );
|
||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
@@ -524,7 +542,9 @@ class propelTable
|
||||
$this->tpl->assignGlobal( $key, $val ); //Changed to Global by JHL on Dec 14,2009.. then thes fields are available for all Blocks
|
||||
}
|
||||
}
|
||||
/********** HEAD BLOCK ***************/
|
||||
/**
|
||||
* ******** HEAD BLOCK **************
|
||||
*/
|
||||
if (($block === '') || ($block === 'head')) {
|
||||
$this->tpl->newBlock( 'headBlock' );
|
||||
$this->tpl->assign( 'pagedTable_Id', $this->id );
|
||||
@@ -541,9 +561,11 @@ class propelTable
|
||||
$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_ID' => $this->id
|
||||
) );
|
||||
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->addScriptFile( $menu->scriptURL );
|
||||
@@ -556,8 +578,10 @@ class propelTable
|
||||
$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->addScriptFile( $filterForm->scriptURL );
|
||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||
@@ -567,7 +591,9 @@ class propelTable
|
||||
|
||||
}
|
||||
|
||||
/********** CONTENT BLOCK ***************/
|
||||
/**
|
||||
* ******** CONTENT BLOCK **************
|
||||
*/
|
||||
if (($block === '') || ($block === 'content')) {
|
||||
$this->tpl->newBlock( 'contentBlock' );
|
||||
$this->tpl->assign( 'gridWidth', '=[' . substr( $this->gridWidth, 1 ) . ']' );
|
||||
@@ -589,8 +615,7 @@ class propelTable
|
||||
//Render rows
|
||||
if ($this->criteria->getDbName() == 'dbarray') {
|
||||
$rs = ArrayBasePeer::doSelectRs( $this->criteria );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rs = GulliverBasePeer::doSelectRs( $this->criteria );
|
||||
}
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
@@ -652,7 +677,8 @@ class propelTable
|
||||
}
|
||||
}
|
||||
$this->tpl->gotoblock( "row" );
|
||||
if ( !isset($rowName) ) $rowName = array();
|
||||
if (! isset( $rowName ))
|
||||
$rowName = array ();
|
||||
$this->tpl->assign( "rowName", implode( ",", $rowName ) );
|
||||
}
|
||||
//End Master Detail: This enable the MasterDEtail view
|
||||
@@ -668,8 +694,7 @@ class propelTable
|
||||
$this->xmlForm->setValues( $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') {
|
||||
if (($this->style[$r]['showInTable'] != '0') && (! (in_array( $this->fields[$r]['Name'], $this->masterdetail ))))
|
||||
$this->renderField( $j + 1, $r, $result );
|
||||
}
|
||||
@@ -686,8 +711,7 @@ class propelTable
|
||||
$prevAjax = $this->id . ".doGoToPage(" . $prevpage . ");return false;";
|
||||
$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>";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$first = "<a class='noFirstPage'> </a>";
|
||||
$prev = "<a class='noPreviousPage'> </a>";
|
||||
}
|
||||
@@ -699,8 +723,7 @@ class propelTable
|
||||
$nextAjax = $this->id . ".doGoToPage(" . $nextpage . ");return false;";
|
||||
$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>";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$next = "<a class='noNextPage'> </a>";
|
||||
$last = "<a class='noLastPage'> </a>";
|
||||
}
|
||||
@@ -717,7 +740,8 @@ class propelTable
|
||||
$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) {
|
||||
@@ -773,7 +797,9 @@ var popupHeight<?php echo '='.$this->popupHeight?>;
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
/********** CLOSE BLOCK ***************/
|
||||
/**
|
||||
* ******** CLOSE BLOCK **************
|
||||
*/
|
||||
if (($block === '') || ($block === 'close')) {
|
||||
$this->tpl->newBlock( "closeBlock" );
|
||||
}
|
||||
@@ -790,14 +816,17 @@ var popupHeight<?php echo '='.$this->popupHeight?>;
|
||||
$this->fastSearch = '';
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function printForm
|
||||
*
|
||||
* @param string $filename
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
function printForm ($filename, $data = array())
|
||||
{ global $G_PUBLISH;
|
||||
{
|
||||
global $G_PUBLISH;
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit );
|
||||
G::RenderPage( "publish", "blank" );
|
||||
|
||||
Reference in New Issue
Block a user