CODE STYLE Formating gulliver/system/class.templatePower.php

Change format files in gulliver/system/class.templatePower.php
This commit is contained in:
norahmollo
2012-10-17 19:42:03 +00:00
parent f61d9ca408
commit 5ae1df4427

View File

@@ -1,6 +1,7 @@
<?php
/**
* class.templatePower.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -54,8 +55,11 @@
//
// $Id: Version 3.0.2$
/**
*
* @package gulliver.system
*
*/
define( "T_BYFILE", 0 );
@@ -65,6 +69,7 @@ define("TP_ROOTBLOCK", '_ROOT');
/**
* class TemplatePowerParser
*
* @package gulliver.system
*
*/
@@ -90,9 +95,11 @@ class TemplatePowerParser
function TemplatePowerParser ($tpl_file, $type)
{
$this->version = '3.0.2';
$this->tpl_base = Array( $tpl_file, $type );
$this->tpl_base = Array ($tpl_file,$type
);
$this->tpl_count = 0;
$this->ignore_stack = Array( false );
$this->ignore_stack = Array (false
);
}
/**
@@ -109,6 +116,7 @@ class TemplatePowerParser
/**
* TemplatePowerParser::__prepare()
*
* @access private
* @return void
*/
@@ -151,12 +159,10 @@ class TemplatePowerParser
$tplvar = 'tpl_rawContent' . $this->tpl_count;
if ($type == T_BYVAR) {
$this->{$tplvar}["content"] = preg_split( "/\n/", $tpl_file, - 1, PREG_SPLIT_DELIM_CAPTURE );
}
else{
} else {
// Trigger the error in the local scope of the function
// trigger_error ("Some error", E_USER_WARNING);
$this->{$tplvar}["content"] = @file( $tpl_file ) or
die( $this->__errorAlert('TemplatePower Error: Couldn\'t open [ '. $tpl_file .' ]!'));
$this->{$tplvar}["content"] = @file( $tpl_file ) or die( $this->__errorAlert( 'TemplatePower Error: Couldn\'t open [ ' . $tpl_file . ' ]!' ) );
}
$this->{$tplvar}["size"] = sizeof( $this->{$tplvar}["content"] );
$this->tpl_count ++;
@@ -182,13 +188,11 @@ class TemplatePowerParser
if ($ignreg[1] == 'START') {
//$ignore = true;
array_push( $this->ignore_stack, true );
}
else{
} else {
//$ignore = false;
array_pop( $this->ignore_stack );
}
}
else{
} else {
if (! end( $this->ignore_stack )) {
if (preg_match( '/<!--[ ]?(START|END|INCLUDE|INCLUDESCRIPT|REUSE) BLOCK : (.+)-->/', $this->{$tplvar}["content"][$index], $regs )) {
//remove trailing and leading spaces
@@ -199,13 +203,10 @@ class TemplatePowerParser
if (isset( $this->tpl_include[$regs[2]] )) {
$tpl_file = $this->tpl_include[$regs[2]][0];
$type = $this->tpl_include[$regs[2]][1];
}
else
if (file_exists( $regs[2] )){ //check if defined as constant in template
} else if (file_exists( $regs[2] )) { //check if defined as constant in template
$tpl_file = $regs[2];
$type = T_BYFILE;
}
else{
} else {
$include_defined = false;
}
if ($include_defined) {
@@ -219,21 +220,16 @@ class TemplatePowerParser
$coderow = $initdev["coderow"];
$varrow = $initdev["varrow"];
}
}
else
if( $regs[1] == 'INCLUDESCRIPT' ){
} else if ($regs[1] == 'INCLUDESCRIPT') {
$include_defined = true;
//check if the includescript file is assigned by the assignInclude function
if (isset( $this->tpl_include[$regs[2]] )) {
$include_file = $this->tpl_include[$regs[2]][0];
$type = $this->tpl_include[$regs[2]][1];
}
else
if (file_exists( $regs[2] )){ //check if defined as constant in template
} else if (file_exists( $regs[2] )) { //check if defined as constant in template
$include_file = $regs[2];
$type = T_BYFILE;
}
else{
} else {
$include_defined = false;
}
if ($include_defined) {
@@ -243,17 +239,14 @@ class TemplatePowerParser
$this->__errorAlert( 'TemplatePower Error: Couldn\'t include script [ ' . $include_file . ' ]!' );
exit();
}
}
else{
} else {
eval( "?>" . $include_file );
}
$this->defBlock[$blockname]["_C:$coderow"] = ob_get_contents();
$coderow ++;
ob_end_clean();
}
}
else
if( $regs[1] == 'REUSE' ){
} else if ($regs[1] == 'REUSE') {
//do match for 'AS'
if (preg_match( '/(.+) AS (.+)/', $regs[2], $reuse_regs )) {
$originalbname = trim( $reuse_regs[1] );
@@ -267,22 +260,18 @@ class TemplatePowerParser
//create index and parent info
$this->index[$copybname] = 0;
$this->parent[$copybname] = $blockname;
}
else{
} else {
$this->__errorAlert( 'TemplatePower Error: Can\'t find block \'' . $originalbname . '\' to REUSE as \'' . $copybname . '\'' );
}
}
else{
} else {
//so it isn't a correct REUSE tag, save as code
$this->defBlock[$blockname]["_C:$coderow"] = $this->{$tplvar}["content"][$index];
$coderow ++;
}
}
else{
} else {
if ($regs[2] == $blockname) { //is it the end of a block
break;
}
else{ //its the start of a block
} else { //its the start of a block
//make a child block and tell the parent that he has a child
$this->defBlock[$regs[2]] = Array ();
$this->defBlock[$blockname]["_B:" . $regs[2]] = '';
@@ -299,8 +288,7 @@ class TemplatePowerParser
$index = $initdev["index"];
}
}
}
else{ //is it code and/or var(s)
} else { //is it code and/or var(s)
//explode current template line on the curly bracket '{'
$sstr = explode( '{', $this->{$tplvar}["content"][$index] );
reset( $sstr );
@@ -324,8 +312,7 @@ class TemplatePowerParser
//so, it isn't a variable, save as code
$this->defBlock[$blockname]["_C:$coderow"] = '{' . current( $sstr );
$coderow ++;
}
else{
} else {
//save the variable
$this->defBlock[$blockname]["_V:$varrow"] = $varname;
$varrow ++;
@@ -336,8 +323,7 @@ class TemplatePowerParser
$coderow ++;
}
}
}
else{
} else {
//no end curly bracket '}' found
//so, the curly bracket is part of the text. Save as code, with the '{'
$this->defBlock[$blockname]["_C:$coderow"] = '{' . current( $sstr );
@@ -345,8 +331,7 @@ class TemplatePowerParser
}
}
}
}
else{
} else {
$this->defBlock[$blockname]["_C:$coderow"] = $this->{$tplvar}["content"][$index];
$coderow ++;
}
@@ -359,7 +344,6 @@ class TemplatePowerParser
return $initdev;
}
/**
* TemplatePowerParser::version()
*
@@ -382,12 +366,14 @@ class TemplatePowerParser
*/
function assignInclude ($iblockname, $value, $type = T_BYFILE)
{
$this->tpl_include["$iblockname"] = Array( $value, $type );
$this->tpl_include["$iblockname"] = Array ($value,$type
);
}
}
/**
* class TemplatePower
*
* @package gulliver.system
*/
class TemplatePower extends TemplatePowerParser
@@ -427,10 +413,8 @@ class TemplatePower extends TemplatePowerParser
function __deSerializeTPL ($stpl_file, $type)
{
if ($type == T_BYFILE) {
$serializedTPL = @file( $stpl_file ) or
die( $this->__errorAlert('TemplatePower Error: Can\'t open [ '. $stpl_file .' ]!'));
}
else{
$serializedTPL = @file( $stpl_file ) or die( $this->__errorAlert( 'TemplatePower Error: Can\'t open [ ' . $stpl_file . ' ]!' ) );
} else {
$serializedTPL = $stpl_file;
}
$serializedStuff = unserialize( join( '', $serializedTPL ) );
@@ -447,7 +431,8 @@ class TemplatePower extends TemplatePowerParser
*/
function __makeContentRoot ()
{
$this->content[ TP_ROOTBLOCK ."_0" ][0] = Array( TP_ROOTBLOCK );
$this->content[TP_ROOTBLOCK . "_0"][0] = Array (TP_ROOTBLOCK
);
$this->currentBlock = &$this->content[TP_ROOTBLOCK . "_0"][0];
}
@@ -468,8 +453,7 @@ class TemplatePower extends TemplatePowerParser
$lastitem > 1 ? $lastitem -- : $lastitem = 0;
$block = &$this->content[$ind_blockname][$lastitem];
$varname = $regs[1];
}
else{
} else {
$block = &$this->currentBlock;
}
$block["_V:$varname"] = $value;
@@ -488,7 +472,6 @@ class TemplatePower extends TemplatePowerParser
$this->globalvars[$varname] = $value;
}
/**
* TemplatePower::__outputContent()
*
@@ -504,42 +487,34 @@ class TemplatePower extends TemplatePowerParser
for (reset( $this->defBlock[$defblockname] ); $k = key( $this->defBlock[$defblockname] ); next( $this->defBlock[$defblockname] )) {
if ($k[1] == 'C') {
print ($this->defBlock[$defblockname][$k]) ;
}
else
if ($k[1] == 'V'){
} else if ($k[1] == 'V') {
$defValue = $this->defBlock[$defblockname][$k];
if (! isset( $this->content[$blockname][$i]["_V:" . $defValue] )) {
if (isset( $this->globalvars[$defValue] )) {
$value = $this->globalvars[$defValue];
}
else{
} else {
//Verify if $defValue is like
// "xmlfile:ID_LABEL"
//if it is load an xml label.
//if not continues with non assigned value.
if (preg_match( "/(.+):(.+)/", $defValue, $xmlreg )) {
$value = G::LoadTranslation(/*$xmlreg[1],*/$xmlreg[2] );
}
else {
} else {
if ($this->showUnAssigned) {
//$value = '{'. $this->defBlock[ $defblockname ][$k] .'}';
$value = '{' . $defValue . '}';
}
else{
} else {
$value = '';
}
}
}
}
else{
} else {
$value = $this->content[$blockname][$i]["_V:" . $defValue];
}
if ($this->unhtmlentities)
$value = G::unhtmlentities( $value );
print ($value) ;
}
else
if ($k[1] == 'B'){
} else if ($k[1] == 'B') {
if (isset( $this->content[$blockname][$i][$k] )) {
$this->__outputContent( $this->content[$blockname][$i][$k] );
}
@@ -561,10 +536,11 @@ class TemplatePower extends TemplatePowerParser
var_dump( $this->content );
}
/**********
public members
***********/
/**
* ********
* public members
* *********
*/
/**
* TemplatePower::serializedBase()
@@ -633,7 +609,8 @@ class TemplatePower extends TemplatePowerParser
}
//now, make a copy of the block defenition
$blocksize = sizeof( $this->content[$ind_blockname] );
$this->content[ $ind_blockname ][ $blocksize ] = Array( $blockname );
$this->content[$ind_blockname][$blocksize] = Array ($blockname
);
//link the current block to the block we just created
$this->currentBlock = &$this->content[$ind_blockname][$blocksize];
}
@@ -653,8 +630,7 @@ class TemplatePower extends TemplatePowerParser
foreach ($varname as $var => $value) {
$this->__assignGlobal( $var, $value );
}
}
else{
} else {
$this->__assignGlobal( $varname, $value );
}
}
@@ -673,8 +649,7 @@ class TemplatePower extends TemplatePowerParser
foreach ($varname as $var => $value) {
$this->__assign( $var, $value );
}
}
else{
} else {
$this->__assign( $varname, $value );
}
}
@@ -713,8 +688,7 @@ class TemplatePower extends TemplatePowerParser
$lastitem > 1 ? $lastitem -- : $lastitem = 0;
$block = &$this->content[$ind_blockname][$lastitem];
$varname = $regs[1];
}
else{
} else {
$block = &$this->currentBlock;
}
return $block["_V:$varname"];
@@ -730,8 +704,7 @@ class TemplatePower extends TemplatePowerParser
{
if ($this->prepared) {
$this->__outputContent( TP_ROOTBLOCK . '_0' );
}
else{
} else {
$this->__errorAlert( 'TemplatePower Error: Template isn\'t prepared!' );
}
}