CODE STYLE format

Changes in format file
This commit is contained in:
norahmollo
2012-10-23 21:14:04 +00:00
parent 266937e496
commit 911b417e72
3 changed files with 260 additions and 226 deletions

View File

@@ -43,49 +43,49 @@
class Table class Table
{ {
var $Columns = null; public $Columns = null;
var $Labels = null; public $Labels = null;
var $rows_per_page = 25; public $rows_per_page = 25;
var $show_nummbers = null; public $show_nummbers = null;
var $first_row = 0; public $first_row = 0;
var $row_pos = 0; public $row_pos = 0;
var $Action = ""; //not used public $Action = ""; //not used
var $ActionLabel = "Continuar"; //not used public $ActionLabel = "Continuar"; //not used
var $_dbc = null; public $_dbc = null;
var $_dbses = null; public $_dbses = null;
var $_dbset = null; public $_dbset = null;
var $_source = ""; public $_source = "";
var $DefaultOrder = "UID"; public $DefaultOrder = "UID";
var $DefaultOrderDir = 'ASC'; public $DefaultOrderDir = 'ASC';
var $CustomOrder = ""; public $CustomOrder = "";
var $WhereClause = ""; public $WhereClause = "";
var $_row_values = null; public $_row_values = null;
var $_ordered = true; public $_ordered = true;
var $orderprefix = ""; public $orderprefix = "";
var $CountQry = ""; public $CountQry = "";
var $filtro = 1; public $filtro = 1;
var $title = ''; public $title = '';
/** /**
* Asocia un arreglo con valores de traducci?n/conversi?n a un contexto * Asocia un arreglo con valores de traducci?n/conversi?n a un contexto
* *
* @var array * @var array
*/ */
var $contexto = null; public $contexto = null;
/** /**
* Arreglo que contiene las cadenas que van a ser usadas al traducir/convertir * Arreglo que contiene las cadenas que van a ser usadas al traducir/convertir
* *
* @var array * @var array
*/ */
var $translate = null; public $translate = null;
/** /**
* Establece el ?ltimo contexto utilizado * Establece el ?ltimo contexto utilizado
* *
* @var string * @var string
*/ */
var $_contexto = ''; public $_contexto = '';
/** /**
* Set conecction using default values * Set conecction using default values
@@ -95,7 +95,7 @@ class Table
* @param string $objConnection connection string * @param string $objConnection connection string
* @return void * @return void
*/ */
function Table ($objConnection = null) public function Table ($objConnection = null)
{ {
$this->SetTo( $objConnection ); $this->SetTo( $objConnection );
} }
@@ -108,7 +108,7 @@ class Table
* @param string $objConnection connection string * @param string $objConnection connection string
* @return void * @return void
*/ */
function SetTo ($objConnection = null) public function SetTo ($objConnection = null)
{ {
$this->_dbc = $objConnection; $this->_dbc = $objConnection;
} }
@@ -122,7 +122,7 @@ class Table
* @param string $stDefaultOrder index to order by, default value='UID' * @param string $stDefaultOrder index to order by, default value='UID'
* @return void * @return void
*/ */
function SetSource ($stQry = "", $stDefaultOrder = "UID", $stDefaultOrderDir = 'ASC') public function SetSource ($stQry = "", $stDefaultOrder = "UID", $stDefaultOrderDir = 'ASC')
{ {
//to fix missing value for variable orderDir, when between pages changes. //to fix missing value for variable orderDir, when between pages changes.
$url1 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?'; $url1 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?';
@@ -149,7 +149,7 @@ class Table
* @access public * @access public
* @return void * @return void
*/ */
function GetSource () public function GetSource ()
{ {
global $HTTP_GET_VARS; global $HTTP_GET_VARS;
global $HTTP_SESSION_VARS; global $HTTP_SESSION_VARS;
@@ -238,7 +238,7 @@ class Table
* @access public * @access public
* @return int * @return int
*/ */
function TotalCount () public function TotalCount ()
{ {
global $HTTP_GET_VARS; global $HTTP_GET_VARS;
global $HTTP_SESSION_VARS; global $HTTP_SESSION_VARS;
@@ -275,7 +275,7 @@ class Table
* @access public * @access public
* @return int * @return int
*/ */
function Count () public function Count ()
{ {
if (is_object( $this->_dbset )) { if (is_object( $this->_dbset )) {
return $this->_dbset->Count(); return $this->_dbset->Count();
@@ -291,7 +291,7 @@ class Table
* @access public * @access public
* @return int * @return int
*/ */
function CurRow () public function CurRow ()
{ {
return $this->row_pos; return $this->row_pos;
} }
@@ -303,7 +303,7 @@ class Table
* @access public * @access public
* @return int * @return int
*/ */
function ColumnCount () public function ColumnCount ()
{ {
$result = 0; $result = 0;
if (is_array( $this->Columns )) { if (is_array( $this->Columns )) {
@@ -319,7 +319,7 @@ class Table
* @access public * @access public
* @return array * @return array
*/ */
function Read () public function Read ()
{ {
$this->_row_values = $this->_dbset->Read(); $this->_row_values = $this->_dbset->Read();
$this->row_pos ++; $this->row_pos ++;
@@ -334,7 +334,7 @@ class Table
* @param int $intPos position to seek * @param int $intPos position to seek
* @return int * @return int
*/ */
function Seek ($intPos = 0) public function Seek ($intPos = 0)
{ {
$result = $this->_dbset->Seek( $intPos ); $result = $this->_dbset->Seek( $intPos );
if ($result) { if ($result) {
@@ -350,7 +350,7 @@ class Table
* @access public * @access public
* @return int * @return int
*/ */
function MoveFirst () public function MoveFirst ()
{ {
if ($this->Count() != 0) { if ($this->Count() != 0) {
if ($this->first_row < $this->Count()) { if ($this->first_row < $this->Count()) {
@@ -366,7 +366,7 @@ class Table
* @access public * @access public
* @return boolean * @return boolean
*/ */
function EOF () public function EOF ()
{ {
$result = false; $result = false;
if ($this->Count() == 0) { if ($this->Count() == 0) {
@@ -399,7 +399,7 @@ class Table
* @param $strContent * @param $strContent
* @return void * @return void
*/ */
function AddColumn ($strLabel = "", $strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "") public function AddColumn ($strLabel = "", $strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "")
{ {
$tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent $tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent
); );
@@ -427,7 +427,7 @@ class Table
* @param $orderByThis * @param $orderByThis
* @return void * @return void
*/ */
function AddRawColumn ($strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "", $strExtra = "", $strCondition = "", $orderByThis = true) public function AddRawColumn ($strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "", $strExtra = "", $strCondition = "", $orderByThis = true)
{ {
$tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent,"Extra" => $strExtra,"Condition" => $strCondition,"orderByThis" => $orderByThis $tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent,"Extra" => $strExtra,"Condition" => $strCondition,"orderByThis" => $orderByThis
); );
@@ -449,7 +449,7 @@ class Table
* @param $strClass * @param $strClass
* @return void * @return void
*/ */
function RenderTitle ($pa, $intPos = 1, $strClass = "tblHeader") public function RenderTitle ($pa, $intPos = 1, $strClass = "tblHeader")
{ {
if (! defined( 'ENABLE_ENCRYPT' )) { if (! defined( 'ENABLE_ENCRYPT' )) {
define( 'ENABLE_ENCRYPT', 'no' ); define( 'ENABLE_ENCRYPT', 'no' );
@@ -492,7 +492,7 @@ class Table
* @param $strClass * @param $strClass
* @return void * @return void
*/ */
function RenderTitle_ajax ($pa, $intPos = 1, $strClass = "tblHeader") public function RenderTitle_ajax ($pa, $intPos = 1, $strClass = "tblHeader")
{ {
global $HTTP_SESSION_VARS; global $HTTP_SESSION_VARS;
$col = $this->Columns[$intPos]; $col = $this->Columns[$intPos];
@@ -543,7 +543,7 @@ class Table
* @param $auxgetval * @param $auxgetval
* @return void * @return void
*/ */
function RenderTitle2 ($pa, $fil, $intPos, $strClass = "tblHeader", $auxgetval = '') public function RenderTitle2 ($pa, $fil, $intPos, $strClass = "tblHeader", $auxgetval = '')
{ {
if (! defined( 'ENABLE_ENCRYPT' )) { if (! defined( 'ENABLE_ENCRYPT' )) {
define( 'ENABLE_ENCRYPT', 'no' ); define( 'ENABLE_ENCRYPT', 'no' );
@@ -609,7 +609,7 @@ class Table
* @param $renderTD if this value = 1, this function will include the TD tags * @param $renderTD if this value = 1, this function will include the TD tags
* @return void * @return void
*/ */
function RenderColumn ($intPos = 0, $strClass = "tblCell", $strClassLink = "tblCellA", $number = 0, $renderTD = 1) public function RenderColumn ($intPos = 0, $strClass = "tblCell", $strClassLink = "tblCellA", $number = 0, $renderTD = 1)
{ {
if (! defined( 'ENABLE_ENCRYPT' )) { if (! defined( 'ENABLE_ENCRYPT' )) {
define( 'ENABLE_ENCRYPT', 'no' ); define( 'ENABLE_ENCRYPT', 'no' );
@@ -777,7 +777,8 @@ class Table
$tlabel = substr( $col["Content"], 0, 1 ); $tlabel = substr( $col["Content"], 0, 1 );
$vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) );
$lval = $this->_row_values[$vname]; $lval = $this->_row_values[$vname];
//$res .= "<a href='" . $col["Target"] . $lval . "' target='_new' > $image</a> "; //It open a new window... better the other way By JHL 16/11/06 //$res .= "<a href='" . $col["Target"] . $lval . "' target='_new' > $image</a> ";
//It open a new window... better the other way By JHL 16/11/06
$res .= "<a href='" . $col["Target"] . $lval . "' > $image</a> "; $res .= "<a href='" . $col["Target"] . $lval . "' > $image</a> ";
} else { } else {
$res .= "&nbsp;"; $res .= "&nbsp;";
@@ -828,14 +829,13 @@ class Table
} else { } else {
$val2 = "<span class='txtin3'>" . strtoupper( $fieldname ) . "</span>"; $val2 = "<span class='txtin3'>" . strtoupper( $fieldname ) . "</span>";
} }
// break; //break;
case "link": case "link":
if ($val == "") { if ($val == "") {
$res .= "&nbsp;"; $res .= "&nbsp;";
} }
$title = ''; $title = '';
if ($col["Type"] == 'link' && trim( isset( $this->_row_values['TOOLTIP'] ) ? $this->_row_values['TOOLTIP'] : '' )) if ($col["Type"] == 'link' && trim( isset( $this->_row_values['TOOLTIP'] ) ? $this->_row_values['TOOLTIP'] : '' ));
;
$title = (isset( $this->_row_values['TOOLTIP'] ) ? "title=\" " . $this->_row_values['TOOLTIP'] . " \"" : ''); $title = (isset( $this->_row_values['TOOLTIP'] ) ? "title=\" " . $this->_row_values['TOOLTIP'] . " \"" : '');
if (is_array( $col['Content'] ) && $col['Content'] != "") { if (is_array( $col['Content'] ) && $col['Content'] != "") {
// Hay mas de un valor para el link // Hay mas de un valor para el link
@@ -1070,7 +1070,7 @@ class Table
* @param string $strLabel Label * @param string $strLabel Label
* @return void * @return void
*/ */
function SetAction ($strAction, $strLabel = "Continue") public function SetAction ($strAction, $strLabel = "Continue")
{ {
$this->Action = $strAction; $this->Action = $strAction;
$this->ActionLabel = $strLabel; $this->ActionLabel = $strLabel;
@@ -1086,7 +1086,7 @@ class Table
* @access public * @access public
* @return void * @return void
*/ */
function setTranslate ($contexto, $tabla, $nombre) public function setTranslate ($contexto, $tabla, $nombre)
{ {
if (is_array( $this->contexto )) { if (is_array( $this->contexto )) {
$this->contexto[0][] = $contexto; $this->contexto[0][] = $contexto;
@@ -1118,7 +1118,7 @@ class Table
* @param string $lang El lenguaje que se va utilizar * @param string $lang El lenguaje que se va utilizar
* @return mixed * @return mixed
*/ */
function translateValue ($contexto, $valor, $lang) public function translateValue ($contexto, $valor, $lang)
{ {
// Verificar si exite el contexto // Verificar si exite el contexto
if (in_array( $contexto, $this->contexto[0] )) { if (in_array( $contexto, $this->contexto[0] )) {
@@ -1146,7 +1146,7 @@ class Table
* @param string $contexto Contexto en el cual se busca la traducci?n * @param string $contexto Contexto en el cual se busca la traducci?n
* @return void * @return void
*/ */
function setContext ($contexto) public function setContext ($contexto)
{ {
$this->_context = $contexto; $this->_context = $contexto;
} }
@@ -1158,7 +1158,7 @@ class Table
* @access public * @access public
* @return void * @return void
*/ */
function ParsingFromHtml ($value, $number = '100000000') public function ParsingFromHtml ($value, $number = '100000000')
{ {
$car = substr( $value, 0, 1 ); $car = substr( $value, 0, 1 );
$len = strlen( $value ); $len = strlen( $value );

View File

@@ -75,15 +75,18 @@ define( "TP_ROOTBLOCK", '_ROOT' );
*/ */
class TemplatePowerParser class TemplatePowerParser
{ {
var $tpl_base; //Array( [filename/varcontent], [T_BYFILE/T_BYVAR] ) public $tpl_base;
var $tpl_include; //Array( [filename/varcontent], [T_BYFILE/T_BYVAR] ) //Array( [filename/varcontent], [T_BYFILE/T_BYVAR] )
var $tpl_count; public $tpl_include;
var $parent = Array (); // $parent[{blockname}] = {parentblockname} //Array( [filename/varcontent], [T_BYFILE/T_BYVAR] )
var $defBlock = Array (); public $tpl_count;
var $rootBlockName; public $parent = Array ();
var $ignore_stack; // $parent[{blockname}] = {parentblockname}
var $version; public $defBlock = Array ();
var $unhtmlentities = 0; public $rootBlockName;
public $ignore_stack;
public $version;
public $unhtmlentities = 0;
/** /**
* TemplatePowerParser::TemplatePowerParser() * TemplatePowerParser::TemplatePowerParser()
@@ -92,14 +95,12 @@ class TemplatePowerParser
* @param string $type * @param string $type
* @access private * @access private
*/ */
function TemplatePowerParser ($tpl_file, $type) public function TemplatePowerParser ($tpl_file, $type)
{ {
$this->version = '3.0.2'; $this->version = '3.0.2';
$this->tpl_base = Array ($tpl_file,$type $this->tpl_base = Array ($tpl_file,$type);
);
$this->tpl_count = 0; $this->tpl_count = 0;
$this->ignore_stack = Array (false $this->ignore_stack = Array (false);
);
} }
/** /**
@@ -109,7 +110,7 @@ class TemplatePowerParser
* *
* @access private * @access private
*/ */
function __errorAlert ($message) public function __errorAlert ($message)
{ {
print ('<br>' . $message . '<br>' . "\r\n") ; print ('<br>' . $message . '<br>' . "\r\n") ;
} }
@@ -120,7 +121,7 @@ class TemplatePowerParser
* @access private * @access private
* @return void * @return void
*/ */
function __prepare () public function __prepare ()
{ {
$this->defBlock[TP_ROOTBLOCK] = Array (); $this->defBlock[TP_ROOTBLOCK] = Array ();
$tplvar = $this->__prepareTemplate( $this->tpl_base[0], $this->tpl_base[1] ); $tplvar = $this->__prepareTemplate( $this->tpl_base[0], $this->tpl_base[1] );
@@ -139,7 +140,7 @@ class TemplatePowerParser
* *
* @access private * @access private
*/ */
function __cleanUp () public function __cleanUp ()
{ {
for ($i = 0; $i <= $this->tpl_count; $i ++) { for ($i = 0; $i <= $this->tpl_count; $i ++) {
$tplvar = 'tpl_rawContent' . $i; $tplvar = 'tpl_rawContent' . $i;
@@ -154,14 +155,14 @@ class TemplatePowerParser
* @param string $type * @param string $type
* @access private * @access private
*/ */
function __prepareTemplate ($tpl_file, $type) public function __prepareTemplate ($tpl_file, $type)
{ {
$tplvar = 'tpl_rawContent' . $this->tpl_count; $tplvar = 'tpl_rawContent' . $this->tpl_count;
if ($type == T_BYVAR) { if ($type == T_BYVAR) {
$this->{$tplvar}["content"] = preg_split( "/\n/", $tpl_file, - 1, PREG_SPLIT_DELIM_CAPTURE ); $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 the error in the local scope of the function
// trigger_error ("Some error", E_USER_WARNING); //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->{$tplvar}["size"] = sizeof( $this->{$tplvar}["content"] );
@@ -177,7 +178,7 @@ class TemplatePowerParser
* @param string $initdev * @param string $initdev
* @access private * @access private
*/ */
function __parseTemplate ($tplvar, $blockname, $initdev) public function __parseTemplate ($tplvar, $blockname, $initdev)
{ {
$coderow = $initdev["coderow"]; $coderow = $initdev["coderow"];
$varrow = $initdev["varrow"]; $varrow = $initdev["varrow"];
@@ -203,12 +204,14 @@ class TemplatePowerParser
if (isset( $this->tpl_include[$regs[2]] )) { if (isset( $this->tpl_include[$regs[2]] )) {
$tpl_file = $this->tpl_include[$regs[2]][0]; $tpl_file = $this->tpl_include[$regs[2]][0];
$type = $this->tpl_include[$regs[2]][1]; $type = $this->tpl_include[$regs[2]][1];
} else if (file_exists( $regs[2] )) { //check if defined as constant in template } elseif (file_exists( $regs[2] )) {
//check if defined as constant in template
$tpl_file = $regs[2]; $tpl_file = $regs[2];
$type = T_BYFILE; $type = T_BYFILE;
} else { } else {
$include_defined = false; $include_defined = false;
} }
if ($include_defined) { if ($include_defined) {
//initialize startvalues for recursive call //initialize startvalues for recursive call
$initdev["varrow"] = $varrow; $initdev["varrow"] = $varrow;
@@ -220,13 +223,14 @@ class TemplatePowerParser
$coderow = $initdev["coderow"]; $coderow = $initdev["coderow"];
$varrow = $initdev["varrow"]; $varrow = $initdev["varrow"];
} }
} else if ($regs[1] == 'INCLUDESCRIPT') { } elseif ($regs[1] == 'INCLUDESCRIPT') {
$include_defined = true; $include_defined = true;
//check if the includescript file is assigned by the assignInclude function //check if the includescript file is assigned by the assignInclude function
if (isset( $this->tpl_include[$regs[2]] )) { if (isset( $this->tpl_include[$regs[2]] )) {
$include_file = $this->tpl_include[$regs[2]][0]; $include_file = $this->tpl_include[$regs[2]][0];
$type = $this->tpl_include[$regs[2]][1]; $type = $this->tpl_include[$regs[2]][1];
} else if (file_exists( $regs[2] )) { //check if defined as constant in template } elseif (file_exists( $regs[2] )) {
//check if defined as constant in template
$include_file = $regs[2]; $include_file = $regs[2];
$type = T_BYFILE; $type = T_BYFILE;
} else { } else {
@@ -246,7 +250,7 @@ class TemplatePowerParser
$coderow ++; $coderow ++;
ob_end_clean(); ob_end_clean();
} }
} else if ($regs[1] == 'REUSE') { } elseif ($regs[1] == 'REUSE') {
//do match for 'AS' //do match for 'AS'
if (preg_match( '/(.+) AS (.+)/', $regs[2], $reuse_regs )) { if (preg_match( '/(.+) AS (.+)/', $regs[2], $reuse_regs )) {
$originalbname = trim( $reuse_regs[1] ); $originalbname = trim( $reuse_regs[1] );
@@ -269,9 +273,11 @@ class TemplatePowerParser
$coderow ++; $coderow ++;
} }
} else { } else {
if ($regs[2] == $blockname) { //is it the end of a block if ($regs[2] == $blockname) {
//is it the end of a block
break; 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 //make a child block and tell the parent that he has a child
$this->defBlock[$regs[2]] = Array (); $this->defBlock[$regs[2]] = Array ();
$this->defBlock[$blockname]["_B:" . $regs[2]] = ''; $this->defBlock[$blockname]["_B:" . $regs[2]] = '';
@@ -288,7 +294,8 @@ class TemplatePowerParser
$index = $initdev["index"]; $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 '{' //explode current template line on the curly bracket '{'
$sstr = explode( '{', $this->{$tplvar}["content"][$index] ); $sstr = explode( '{', $this->{$tplvar}["content"][$index] );
reset( $sstr ); reset( $sstr );
@@ -350,7 +357,7 @@ class TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function version () public function version ()
{ {
return $this->version; return $this->version;
} }
@@ -364,10 +371,9 @@ class TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function assignInclude ($iblockname, $value, $type = T_BYFILE) public function assignInclude ($iblockname, $value, $type = T_BYFILE)
{ {
$this->tpl_include["$iblockname"] = Array ($value,$type $this->tpl_include["$iblockname"] = Array ($value,$type);
);
} }
} }
@@ -378,13 +384,14 @@ class TemplatePowerParser
*/ */
class TemplatePower extends TemplatePowerParser class TemplatePower extends TemplatePowerParser
{ {
var $index = Array (); // $index[{blockname}] = {indexnumber} public $index = Array ();
var $content = Array (); // $index[{blockname}] = {indexnumber}
var $currentBlock; public $content = Array ();
var $showUnAssigned; public $currentBlock;
var $serialized; public $showUnAssigned;
var $globalvars = Array (); public $serialized;
var $prepared; public $globalvars = Array ();
public $prepared;
/** /**
* TemplatePower::TemplatePower() * TemplatePower::TemplatePower()
@@ -394,12 +401,13 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function TemplatePower ($tpl_file = '', $type = T_BYFILE) public function TemplatePower ($tpl_file = '', $type = T_BYFILE)
{ {
TemplatePowerParser::TemplatePowerParser( $tpl_file, $type ); TemplatePowerParser::TemplatePowerParser( $tpl_file, $type );
$this->prepared = false; $this->prepared = false;
$this->showUnAssigned = false; $this->showUnAssigned = false;
$this->serialized = false; //added: 26 April 2002 $this->serialized = false;
//added: 26 April 2002
} }
/** /**
@@ -410,7 +418,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access private * @access private
*/ */
function __deSerializeTPL ($stpl_file, $type) public function __deSerializeTPL ($stpl_file, $type)
{ {
if ($type == T_BYFILE) { if ($type == T_BYFILE) {
$serializedTPL = @file( $stpl_file ) or die( $this->__errorAlert( 'TemplatePower Error: Can\'t open [ ' . $stpl_file . ' ]!' ) ); $serializedTPL = @file( $stpl_file ) or die( $this->__errorAlert( 'TemplatePower Error: Can\'t open [ ' . $stpl_file . ' ]!' ) );
@@ -429,10 +437,9 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access private * @access private
*/ */
function __makeContentRoot () public 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]; $this->currentBlock = &$this->content[TP_ROOTBLOCK . "_0"][0];
} }
@@ -445,9 +452,10 @@ class TemplatePower extends TemplatePowerParser
* *
* @access private * @access private
*/ */
function __assign ($varname, $value) public function __assign ($varname, $value)
{ {
if (sizeof( $regs = explode( '.', $varname ) ) == 2) { //this is faster then preg_match if (sizeof( $regs = explode( '.', $varname ) ) == 2) {
//this is faster then preg_match
$ind_blockname = $regs[0] . '_' . $this->index[$regs[0]]; $ind_blockname = $regs[0] . '_' . $this->index[$regs[0]];
$lastitem = sizeof( $this->content[$ind_blockname] ); $lastitem = sizeof( $this->content[$ind_blockname] );
$lastitem > 1 ? $lastitem -- : $lastitem = 0; $lastitem > 1 ? $lastitem -- : $lastitem = 0;
@@ -467,7 +475,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access private * @access private
*/ */
function __assignGlobal ($varname, $value) public function __assignGlobal ($varname, $value)
{ {
$this->globalvars[$varname] = $value; $this->globalvars[$varname] = $value;
} }
@@ -479,7 +487,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access private * @access private
*/ */
function __outputContent ($blockname) public function __outputContent ($blockname)
{ {
$numrows = sizeof( $this->content[$blockname] ); $numrows = sizeof( $this->content[$blockname] );
for ($i = 0; $i < $numrows; $i ++) { for ($i = 0; $i < $numrows; $i ++) {
@@ -487,7 +495,7 @@ class TemplatePower extends TemplatePowerParser
for (reset( $this->defBlock[$defblockname] ); $k = key( $this->defBlock[$defblockname] ); next( $this->defBlock[$defblockname] )) { for (reset( $this->defBlock[$defblockname] ); $k = key( $this->defBlock[$defblockname] ); next( $this->defBlock[$defblockname] )) {
if ($k[1] == 'C') { if ($k[1] == 'C') {
print ($this->defBlock[$defblockname][$k]) ; print ($this->defBlock[$defblockname][$k]) ;
} else if ($k[1] == 'V') { } elseif ($k[1] == 'V') {
$defValue = $this->defBlock[$defblockname][$k]; $defValue = $this->defBlock[$defblockname][$k];
if (! isset( $this->content[$blockname][$i]["_V:" . $defValue] )) { if (! isset( $this->content[$blockname][$i]["_V:" . $defValue] )) {
if (isset( $this->globalvars[$defValue] )) { if (isset( $this->globalvars[$defValue] )) {
@@ -514,7 +522,7 @@ class TemplatePower extends TemplatePowerParser
if ($this->unhtmlentities) if ($this->unhtmlentities)
$value = G::unhtmlentities( $value ); $value = G::unhtmlentities( $value );
print ($value) ; print ($value) ;
} else if ($k[1] == 'B') { } elseif ($k[1] == 'B') {
if (isset( $this->content[$blockname][$i][$k] )) { if (isset( $this->content[$blockname][$i][$k] )) {
$this->__outputContent( $this->content[$blockname][$i][$k] ); $this->__outputContent( $this->content[$blockname][$i][$k] );
} }
@@ -529,7 +537,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function __printVars () public function __printVars ()
{ {
var_dump( $this->defBlock ); var_dump( $this->defBlock );
print ("<br>--------------------<br>") ; print ("<br>--------------------<br>") ;
@@ -549,7 +557,7 @@ class TemplatePower extends TemplatePowerParser
* *
* @access public * @access public
*/ */
function serializedBase () public function serializedBase ()
{ {
$this->serialized = true; $this->serialized = true;
$this->__deSerializeTPL( $this->tpl_base[0], $this->tpl_base[1] ); $this->__deSerializeTPL( $this->tpl_base[0], $this->tpl_base[1] );
@@ -562,7 +570,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function showUnAssigned ($state = true) public function showUnAssigned ($state = true)
{ {
$this->showUnAssigned = $state; $this->showUnAssigned = $state;
} }
@@ -573,7 +581,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function prepare () public function prepare ()
{ {
if (! $this->serialized) { if (! $this->serialized) {
TemplatePowerParser::__prepare(); TemplatePowerParser::__prepare();
@@ -590,7 +598,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function newBlock ($blockname) public function newBlock ($blockname)
{ {
$parent = &$this->content[$this->parent[$blockname] . '_' . $this->index[$this->parent[$blockname]]]; $parent = &$this->content[$this->parent[$blockname] . '_' . $this->index[$this->parent[$blockname]]];
$lastitem = sizeof( $parent ); $lastitem = sizeof( $parent );
@@ -624,7 +632,7 @@ class TemplatePower extends TemplatePowerParser
* *
* @access public * @access public
*/ */
function assignGlobal ($varname, $value = '') public function assignGlobal ($varname, $value = '')
{ {
if (is_array( $varname )) { if (is_array( $varname )) {
foreach ($varname as $var => $value) { foreach ($varname as $var => $value) {
@@ -643,7 +651,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function assign ($varname, $value = '') public function assign ($varname, $value = '')
{ {
if (is_array( $varname )) { if (is_array( $varname )) {
foreach ($varname as $var => $value) { foreach ($varname as $var => $value) {
@@ -661,7 +669,7 @@ class TemplatePower extends TemplatePowerParser
* @param string $blockname * @param string $blockname
* @access public * @access public
*/ */
function gotoBlock ($blockname) public function gotoBlock ($blockname)
{ {
if (isset( $this->defBlock[$blockname] )) { if (isset( $this->defBlock[$blockname] )) {
$ind_blockname = $blockname . '_' . $this->index[$blockname]; $ind_blockname = $blockname . '_' . $this->index[$blockname];
@@ -680,9 +688,10 @@ class TemplatePower extends TemplatePowerParser
* @param string $varname * @param string $varname
* @access public * @access public
*/ */
function getVarValue ($varname) public function getVarValue ($varname)
{ {
if (sizeof( $regs = explode( '.', $varname ) ) == 2) { //this is faster then preg_match{ if (sizeof( $regs = explode( '.', $varname ) ) == 2) {
//this is faster then preg_match{
$ind_blockname = $regs[0] . '_' . $this->index[$regs[0]]; $ind_blockname = $regs[0] . '_' . $this->index[$regs[0]];
$lastitem = sizeof( $this->content[$ind_blockname] ); $lastitem = sizeof( $this->content[$ind_blockname] );
$lastitem > 1 ? $lastitem -- : $lastitem = 0; $lastitem > 1 ? $lastitem -- : $lastitem = 0;
@@ -700,7 +709,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function printToScreen () public function printToScreen ()
{ {
if ($this->prepared) { if ($this->prepared) {
$this->__outputContent( TP_ROOTBLOCK . '_0' ); $this->__outputContent( TP_ROOTBLOCK . '_0' );
@@ -715,7 +724,7 @@ class TemplatePower extends TemplatePowerParser
* @return void * @return void
* @access public * @access public
*/ */
function getOutputContent () public function getOutputContent ()
{ {
ob_start(); ob_start();
$this->printToScreen(); $this->printToScreen();
@@ -724,3 +733,4 @@ class TemplatePower extends TemplatePowerParser
return $content; return $content;
} }
} }

View File

@@ -38,15 +38,14 @@
class System class System
{ {
public $sFilename;
var $sFilename; public $sFilesList;
var $sFilesList; public $sUpgradeFileList;
var $sUpgradeFileList; public $aErrors;
var $aErrors; public $aWorkspaces;
var $aWorkspaces; public $sRevision;
var $sRevision; public $sPath;
var $sPath; public $newSystemClass;
var $newSystemClass;
/** /**
* List currently installed plugins * List currently installed plugins
@@ -84,9 +83,10 @@ class System
$oDirectory = dir( PATH_DB ); $oDirectory = dir( PATH_DB );
$aWorkspaces = array (); $aWorkspaces = array ();
foreach (glob( PATH_DB . "*" ) as $filename) { foreach (glob( PATH_DB . "*" ) as $filename) {
if (is_dir( $filename ) && file_exists( $filename . "/db.php" )) if (is_dir( $filename ) && file_exists( $filename . "/db.php" )) {
$aWorkspaces[] = new workspaceTools( basename( $filename ) ); $aWorkspaces[] = new workspaceTools( basename( $filename ) );
} }
}
return $aWorkspaces; return $aWorkspaces;
} }
@@ -105,8 +105,9 @@ class System
include (PATH_METHODS . 'login/version-pmos.php'); include (PATH_METHODS . 'login/version-pmos.php');
} else { } else {
$version = self::getVersionFromGit(); $version = self::getVersionFromGit();
if ($version === false) if ($version === false) {
$version = 'Development Version'; $version = 'Development Version';
}
define( 'PM_VERSION', $version ); define( 'PM_VERSION', $version );
} }
} }
@@ -119,12 +120,14 @@ class System
* @author Alexandre Rosenfeld <alexandre@colosa.com> * @author Alexandre Rosenfeld <alexandre@colosa.com>
* @return string branch and tag information * @return string branch and tag information
*/ */
public static function getVersionFromGit ($dir = NULL) public static function getVersionFromGit ($dir = null)
{ {
if ($dir == NULL) if ($dir == null) {
$dir = PATH_TRUNK; $dir = PATH_TRUNK;
if (! file_exists( "$dir/.git" )) }
if (! file_exists( "$dir/.git" )) {
return false; return false;
}
if (exec( "cd $dir && git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* \(.*\)$/(Branch \\1)/'", $target )) { if (exec( "cd $dir && git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* \(.*\)$/(Branch \\1)/'", $target )) {
exec( "cd $dir && git describe", $target ); exec( "cd $dir && git describe", $target );
return implode( ' ', $target ); return implode( ' ', $target );
@@ -163,17 +166,19 @@ class System
if (empty( $distro )) { if (empty( $distro )) {
foreach (glob( "/etc/*release" ) as $filename) { foreach (glob( "/etc/*release" ) as $filename) {
$distro = trim( file_get_contents( $filename ) ); $distro = trim( file_get_contents( $filename ) );
if (! empty( $distro )) if (! empty( $distro )) {
break; break;
} }
}
if (empty( $distro )) { if (empty( $distro )) {
foreach (glob( "/etc/*version" ) as $filename) { foreach (glob( "/etc/*version" ) as $filename) {
$distro = trim( file_get_contents( $filename ) ); $distro = trim( file_get_contents( $filename ) );
if (! empty( $distro )) if (! empty( $distro )) {
break; break;
} }
} }
} }
}
/* CentOS returns a string with quotes, remove them and append /* CentOS returns a string with quotes, remove them and append
* the OS name (such as LINUX, WINNT, DARWIN, etc) * the OS name (such as LINUX, WINNT, DARWIN, etc)
@@ -210,18 +215,21 @@ class System
public static function verifyChecksum () public static function verifyChecksum ()
{ {
if (! file_exists( PATH_TRUNK . "checksum.txt" )) if (! file_exists( PATH_TRUNK . "checksum.txt" )) {
return false; return false;
}
$lines = explode( "\n", file_get_contents( PATH_TRUNK . "checksum.txt" ) ); $lines = explode( "\n", file_get_contents( PATH_TRUNK . "checksum.txt" ) );
$result = array ("diff" => array (),"missing" => array () $result = array ("diff" => array (),"missing" => array ()
); );
foreach ($lines as $line) { foreach ($lines as $line) {
if (empty( $line )) if (empty( $line )) {
continue; continue;
}
list ($checksum, $empty, $filename) = explode( " ", $line ); list ($checksum, $empty, $filename) = explode( " ", $line );
//Skip xmlform because these files always change. //Skip xmlform because these files always change.
if (strpos( $filename, "/xmlform/" ) !== false) if (strpos( $filename, "/xmlform/" ) !== false) {
continue; continue;
}
if (file_exists( realpath( $filename ) )) { if (file_exists( realpath( $filename ) )) {
if (strcmp( $checksum, md5_file( realpath( $filename ) ) ) != 0) { if (strcmp( $checksum, md5_file( realpath( $filename ) ) ) != 0) {
$result['diff'][] = $filename; $result['diff'][] = $filename;
@@ -242,7 +250,7 @@ class System
* param * param
* @return boolean * @return boolean
*/ */
function verifyFileForUpgrade () public function verifyFileForUpgrade ()
{ {
$upgradeFilename = isset( $_FILES['form']['name']['UPGRADE_FILENAME'] ) ? $_FILES['form']['name']['UPGRADE_FILENAME'] : ''; $upgradeFilename = isset( $_FILES['form']['name']['UPGRADE_FILENAME'] ) ? $_FILES['form']['name']['UPGRADE_FILENAME'] : '';
$tempFilename = isset( $_FILES['form']['tmp_name']['UPGRADE_FILENAME'] ) ? $_FILES['form']['tmp_name']['UPGRADE_FILENAME'] : ''; $tempFilename = isset( $_FILES['form']['tmp_name']['UPGRADE_FILENAME'] ) ? $_FILES['form']['tmp_name']['UPGRADE_FILENAME'] : '';
@@ -266,7 +274,7 @@ class System
* param * param
* @return void * @return void
*/ */
function getUpgradedFilesList () public function getUpgradedFilesList ()
{ {
G::LoadClass( 'archive' ); G::LoadClass( 'archive' );
$this->sFilesList = new gzip_file( $this->sFilename ); $this->sFilesList = new gzip_file( $this->sFilename );
@@ -294,7 +302,7 @@ class System
* param * param
* @return boolean * @return boolean
*/ */
function verifyForBootstrapUpgrade () public function verifyForBootstrapUpgrade ()
{ {
foreach ($this->sFilesList->files as $sFile) { foreach ($this->sFilesList->files as $sFile) {
if (basename( $sFile ) == 'schema.xml') { if (basename( $sFile ) == 'schema.xml') {
@@ -314,7 +322,7 @@ class System
* param * param
* @return array * @return array
*/ */
function upgrade () public function upgrade ()
{ {
//get special files //get special files
$sListFile = ''; $sListFile = '';
@@ -417,8 +425,9 @@ class System
} }
} else { } else {
$dirName = PATH_TRUNK . $sFilePath; $dirName = PATH_TRUNK . $sFilePath;
if ($dirName[strlen( $dirName ) - 1] == '/') if ($dirName[strlen( $dirName ) - 1] == '/') {
$dirName = substr( $dirName, 0, strlen( $dirName ) - 1 ); $dirName = substr( $dirName, 0, strlen( $dirName ) - 1 );
}
$auxDir = explode( '/', $dirName ); $auxDir = explode( '/', $dirName );
array_pop( $auxDir ); array_pop( $auxDir );
$parentDir = implode( '/', $auxDir ); $parentDir = implode( '/', $auxDir );
@@ -462,13 +471,15 @@ class System
if (is_writable( $targetFileName )) { if (is_writable( $targetFileName )) {
$this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName ); $this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName );
@chmod( $targetFileName, 0666 ); @chmod( $targetFileName, 0666 );
} else } else {
throw (new Exception( "Failed to open file: Permission denied in $targetFileName." )); throw (new Exception( "Failed to open file: Permission denied in $targetFileName." ));
}
} else { } else {
$this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName ); $this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName );
@chmod( $targetFileName, 0666 ); @chmod( $targetFileName, 0666 );
} }
} else { //delete unused files } else {
//delete unused files
if (file_exists( $targetFileName )) { if (file_exists( $targetFileName )) {
@unlink( $targetFileName ); @unlink( $targetFileName );
} }
@@ -478,7 +489,7 @@ class System
mkdir( PATH_TRUNK . $sFilePath, 0777 ); mkdir( PATH_TRUNK . $sFilePath, 0777 );
} }
} }
} else if (file_exists( PATH_TRUNK . $sFilePath ) && $sFilePath != 'workflow/engine/gulliver') { } elseif (file_exists( PATH_TRUNK . $sFilePath ) && $sFilePath != 'workflow/engine/gulliver') {
@unlink( PATH_TRUNK . $sFilePath ); @unlink( PATH_TRUNK . $sFilePath );
} }
} }
@@ -512,8 +523,9 @@ class System
fclose( $fp ); fclose( $fp );
} }
if ($missed > 0) if ($missed > 0) {
$aErrors[] = "Warning: there are $missed missed files. "; $aErrors[] = "Warning: there are $missed missed files. ";
}
$aErrors[] = $missedFiles; $aErrors[] = $missedFiles;
if ($distinct > 0) { if ($distinct > 0) {
@@ -557,9 +569,7 @@ class System
while (($sObject = $oDirectory->read())) { while (($sObject = $oDirectory->read())) {
if (is_dir( PATH_DB . $sObject ) && substr( $sObject, 0, 1 ) != '.') { if (is_dir( PATH_DB . $sObject ) && substr( $sObject, 0, 1 ) != '.') {
if (file_exists( PATH_DB . $sObject . PATH_SEP . 'db.php' )) { if (file_exists( PATH_DB . $sObject . PATH_SEP . 'db.php' )) {
eval( $this->getDatabaseCredentials( PATH_DB . $sObject . PATH_SEP . 'db.php' ) ); eval( $this->getDatabaseCredentials( PATH_DB . $sObject . PATH_SEP . 'db.php' ) );
} }
$aEnvironmentsUpdated[] = $sObject; $aEnvironmentsUpdated[] = $sObject;
$aEnvironmentsDiff[] = $sObject; $aEnvironmentsDiff[] = $sObject;
@@ -629,7 +639,7 @@ class System
* @param string $target * @param string $target
* @return void * @return void
*/ */
function pm_copy ($source, $target) public function pm_copy ($source, $target)
{ {
if (! is_dir( dirname( $target ) )) { if (! is_dir( dirname( $target ) )) {
G::mk_dir( dirname( $target ) ); G::mk_dir( dirname( $target ) );
@@ -649,7 +659,7 @@ class System
* @param string $dbFile * @param string $dbFile
* @return $sContent * @return $sContent
*/ */
function getDatabaseCredentials ($dbFile) public function getDatabaseCredentials ($dbFile)
{ {
$sContent = file_get_contents( $dbFile ); $sContent = file_get_contents( $dbFile );
$sContent = str_replace( '<?php', '', $sContent ); $sContent = str_replace( '<?php', '', $sContent );
@@ -680,11 +690,12 @@ class System
*/ */
public static function getPluginSchema ($pluginName) public static function getPluginSchema ($pluginName)
{ {
if (file_exists( PATH_PLUGINS . $pluginName . "/config/schema.xml" )) if (file_exists( PATH_PLUGINS . $pluginName . "/config/schema.xml" )) {
return System::getSchema( PATH_PLUGINS . $pluginName . "/config/schema.xml" ); return System::getSchema( PATH_PLUGINS . $pluginName . "/config/schema.xml" );
else } else {
return false; return false;
} }
}
/** /**
* Retrieves a schema array from a file. * Retrieves a schema array from a file.
@@ -716,33 +727,37 @@ class System
$type = $oColumn->hasAttribute( 'type' ) ? strtoupper( $oColumn->getAttribute( 'type' ) ) : "VARCHAR"; $type = $oColumn->hasAttribute( 'type' ) ? strtoupper( $oColumn->getAttribute( 'type' ) ) : "VARCHAR";
/* Convert type to MySQL type according to Propel */ /* Convert type to MySQL type according to Propel */
if (array_key_exists( $type, $mysqlTypes )) if (array_key_exists( $type, $mysqlTypes )) {
$type = $mysqlTypes[$type]; $type = $mysqlTypes[$type];
}
$size = $oColumn->hasAttribute( 'size' ) ? $oColumn->getAttribute( 'size' ) : NULL; $size = $oColumn->hasAttribute( 'size' ) ? $oColumn->getAttribute( 'size' ) : null;
/* Add default sizes from MySQL */ /* Add default sizes from MySQL */
if ($type == "TINYINT" && ! $size) if ($type == "TINYINT" && ! $size) {
$size = "4"; $size = "4";
if ($type == "INT" && ! $size) }
if ($type == "INT" && ! $size) {
$size = "11"; $size = "11";
}
if ($size) if ($size) {
$type = "$type($size)"; $type = "$type($size)";
}
$required = $oColumn->hasAttribute( 'required' ) ? $oColumn->getAttribute( 'required' ) : NULL; $required = $oColumn->hasAttribute( 'required' ) ? $oColumn->getAttribute( 'required' ) : null;
/* Convert $required to a bool */ /* Convert $required to a bool */
$required = (in_array( strtolower( $required ), array ('1','true' $required = (in_array( strtolower( $required ), array ('1','true'
) )); ) ));
$default = $oColumn->hasAttribute( 'default' ) ? $oColumn->getAttribute( 'default' ) : NULL; $default = $oColumn->hasAttribute( 'default' ) ? $oColumn->getAttribute( 'default' ) : null;
$primaryKey = $oColumn->hasAttribute( 'primaryKey' ) ? $oColumn->getAttribute( 'primaryKey' ) : NULL; $primaryKey = $oColumn->hasAttribute( 'primaryKey' ) ? $oColumn->getAttribute( 'primaryKey' ) : null;
/* Convert $primaryKey to a bool */ /* Convert $primaryKey to a bool */
$primaryKey = (in_array( strtolower( $primaryKey ), array ('1','true' $primaryKey = (in_array( strtolower( $primaryKey ), array ('1','true'
) )); ) ));
if ($primaryKey) if ($primaryKey) {
$aPrimaryKeys[] = $sColumName; $aPrimaryKeys[] = $sColumName;
}
$aSchema[$sTableName][$sColumName] = array ('Field' => $sColumName,'Type' => $type,'Null' => $required ? "NO" : "YES",'Default' => $default $aSchema[$sTableName][$sColumName] = array ('Field' => $sColumName,'Type' => $type,'Null' => $required ? "NO" : "YES",'Default' => $default
); );
} }
@@ -806,64 +821,70 @@ class System
//foreach ($aNewSchema[$sTableName] as $sColumName => $aParameters) { //foreach ($aNewSchema[$sTableName] as $sColumName => $aParameters) {
foreach ($aColumns as $sColumName => $aParameters) { foreach ($aColumns as $sColumName => $aParameters) {
if ($sColumName != 'INDEXES') { if ($sColumName != 'INDEXES') {
if (! isset( $aOldSchema[$sTableName][$sColumName] )) { //this column doesnt exist in oldschema if (! isset( $aOldSchema[$sTableName][$sColumName] )) {
//this column doesnt exist in oldschema
if (! isset( $aChanges['tablesToAlter'][$sTableName] )) { if (! isset( $aChanges['tablesToAlter'][$sTableName] )) {
$aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array () $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array ()
); );
} }
$aChanges['tablesToAlter'][$sTableName]['ADD'][$sColumName] = $aParameters; $aChanges['tablesToAlter'][$sTableName]['ADD'][$sColumName] = $aParameters;
} else { //the column exists } else {
//the column exists
$newField = $aNewSchema[$sTableName][$sColumName]; $newField = $aNewSchema[$sTableName][$sColumName];
$oldField = $aOldSchema[$sTableName][$sColumName]; $oldField = $aOldSchema[$sTableName][$sColumName];
//both are null, no change is required //both are null, no change is required
if (! isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) if (! isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) {
$changeDefaultAttr = false; $changeDefaultAttr = false;
//one of them is null, change IS required //one of them is null, change IS required
if (! isset( $newField['Default'] ) && isset( $oldField['Default'] ) && $oldField['Default'] != '') }
if (! isset( $newField['Default'] ) && isset( $oldField['Default'] ) && $oldField['Default'] != '') {
$changeDefaultAttr = true; $changeDefaultAttr = true;
if (isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) }
if (isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) {
$changeDefaultAttr = true; $changeDefaultAttr = true;
//both are defined and they are different. //both are defined and they are different.
}
if (isset( $newField['Default'] ) && isset( $oldField['Default'] )) { if (isset( $newField['Default'] ) && isset( $oldField['Default'] )) {
if ($newField['Default'] != $oldField['Default']) if ($newField['Default'] != $oldField['Default']) {
$changeDefaultAttr = true; $changeDefaultAttr = true;
else } else {
$changeDefaultAttr = false; $changeDefaultAttr = false;
} }
}
//special cases //special cases
// BLOB and TEXT columns cannot have DEFAULT values. http://dev.mysql.com/doc/refman/5.0/en/blob.html // BLOB and TEXT columns cannot have DEFAULT values. http://dev.mysql.com/doc/refman/5.0/en/blob.html
if (in_array( strtolower( $newField['Type'] ), array ('text','mediumtext' if (in_array( strtolower( $newField['Type'] ), array ('text','mediumtext') )) {
) ))
$changeDefaultAttr = false; $changeDefaultAttr = false;
}
//#1067 - Invalid default value for datetime field //#1067 - Invalid default value for datetime field
if (in_array( $newField['Type'], array ('datetime' if (in_array( $newField['Type'], array ('datetime') ) && isset( $newField['Default'] ) && $newField['Default'] == '') {
) ) && isset( $newField['Default'] ) && $newField['Default'] == '')
$changeDefaultAttr = false; $changeDefaultAttr = false;
}
//#1067 - Invalid default value for int field //#1067 - Invalid default value for int field
if (substr( $newField['Type'], 0, 3 ) == "int" && isset( $newField['Default'] ) && $newField['Default'] == '') if (substr( $newField['Type'], 0, 3 ) == "int" && isset( $newField['Default'] ) && $newField['Default'] == '') {
$changeDefaultAttr = false; $changeDefaultAttr = false;
}
//if any difference exists, then insert the difference in aChanges //if any difference exists, then insert the difference in aChanges
if (strcasecmp( $newField['Field'], $oldField['Field'] ) !== 0 || strcasecmp( $newField['Type'], $oldField['Type'] ) !== 0 || strcasecmp( $newField['Null'], $oldField['Null'] ) !== 0 || $changeDefaultAttr) { if (strcasecmp( $newField['Field'], $oldField['Field'] ) !== 0 || strcasecmp( $newField['Type'], $oldField['Type'] ) !== 0 || strcasecmp( $newField['Null'], $oldField['Null'] ) !== 0 || $changeDefaultAttr) {
if (! isset( $aChanges['tablesToAlter'][$sTableName] )) { if (! isset( $aChanges['tablesToAlter'][$sTableName] )) {
$aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array () $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array ());
);
} }
$aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Field'] = $newField['Field']; $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Field'] = $newField['Field'];
$aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Type'] = $newField['Type']; $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Type'] = $newField['Type'];
$aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Null'] = $newField['Null']; $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Null'] = $newField['Null'];
if (isset( $newField['Default'] )) if (isset( $newField['Default'] )) {
$aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = $newField['Default']; $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = $newField['Default'];
else } else {
$aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = null; $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = null;
} }
} }
} //only columns, no the indexes column }
} //foreach $aColumns }
//only columns, no the indexes column
}
//foreach $aColumns
//now check the indexes of table //now check the indexes of table
if (isset( $aNewSchema[$sTableName]['INDEXES'] )) { if (isset( $aNewSchema[$sTableName]['INDEXES'] )) {
@@ -883,12 +904,14 @@ class System
} }
} }
} }
} //for-else table exists }
} //for new schema //for-else table exists
}
//for new schema
return $aChanges; return $aChanges;
} }
function getEmailConfiguration () public function getEmailConfiguration ()
{ {
G::LoadClass( 'configuration' ); G::LoadClass( 'configuration' );
$conf = new Configurations(); $conf = new Configurations();
@@ -897,7 +920,7 @@ class System
return $config; return $config;
} }
function getSkingList () public function getSkingList ()
{ {
//Create Skins custom folder if it doesn't exists //Create Skins custom folder if it doesn't exists
if (! is_dir( PATH_CUSTOM_SKINS )) { if (! is_dir( PATH_CUSTOM_SKINS )) {
@@ -949,7 +972,7 @@ class System
return $skinListArray; return $skinListArray;
} }
function getAllTimeZones () public function getAllTimeZones ()
{ {
$timezones = DateTimeZone::listAbbreviations(); $timezones = DateTimeZone::listAbbreviations();
@@ -968,9 +991,9 @@ class System
} }
// For each city, have a comma separated list of all possible timezones for that city. // For each city, have a comma separated list of all possible timezones for that city.
foreach ($cities as $key => $value) foreach ($cities as $key => $value) {
$cities[$key] = join( ', ', $value ); $cities[$key] = join( ', ', $value );
}
// Only keep one city (the first and also most important) for each set of possibilities. // Only keep one city (the first and also most important) for each set of possibilities.
$cities = array_unique( $cities ); $cities = array_unique( $cities );
@@ -990,10 +1013,10 @@ class System
} }
if (empty( $wsIniFile )) { if (empty( $wsIniFile )) {
if (defined( 'PATH_DB' )) { // if we're on a valid workspace env. if (defined( 'PATH_DB' )) {
// if we're on a valid workspace env.
if (empty( $wsName )) { if (empty( $wsName )) {
$uriParts = explode( '/', getenv( "REQUEST_URI" ) ); $uriParts = explode( '/', getenv( "REQUEST_URI" ) );
if (isset( $uriParts[1] )) { if (isset( $uriParts[1] )) {
if (substr( $uriParts[1], 0, 3 ) == 'sys') { if (substr( $uriParts[1], 0, 3 ) == 'sys') {
$wsName = substr( $uriParts[1], 3 ); $wsName = substr( $uriParts[1], 3 );
@@ -1010,12 +1033,12 @@ class System
if (isset( $_SESSION['PROCESSMAKER_ENV'] )) { if (isset( $_SESSION['PROCESSMAKER_ENV'] )) {
$md5 = array (); $md5 = array ();
if ($readGlobalIniFile) if ($readGlobalIniFile) {
$md5[] = md5_file( $globalIniFile ); $md5[] = md5_file( $globalIniFile );
}
if ($readWsIniFile) if ($readWsIniFile) {
$md5[] = md5_file( $wsIniFile ); $md5[] = md5_file( $wsIniFile );
}
$hash = implode( '-', $md5 ); $hash = implode( '-', $md5 );
if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) { if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
@@ -1046,12 +1069,12 @@ class System
} }
$md5 = array (); $md5 = array ();
if ($readGlobalIniFile) if ($readGlobalIniFile) {
$md5[] = md5_file( $globalIniFile ); $md5[] = md5_file( $globalIniFile );
}
if ($readWsIniFile) if ($readWsIniFile) {
$md5[] = md5_file( $wsIniFile ); $md5[] = md5_file( $wsIniFile );
}
$hash = implode( '-', $md5 ); $hash = implode( '-', $md5 );
$_SESSION['PROCESSMAKER_ENV'] = $config; $_SESSION['PROCESSMAKER_ENV'] = $config;
@@ -1060,7 +1083,7 @@ class System
return $config; return $config;
} }
function updateIndexFile ($conf) public function updateIndexFile ($conf)
{ {
if (! file_exists( PATH_HTML . 'index.html' )) { if (! file_exists( PATH_HTML . 'index.html' )) {
throw new Exception( 'The public index file "' . PATH_HTML . 'index.html" does not exist!' ); throw new Exception( 'The public index file "' . PATH_HTML . 'index.html" does not exist!' );
@@ -1089,7 +1112,7 @@ class System
return $result; return $result;
} }
function solrEnv ($sysName = '') public function solrEnv ($sysName = '')
{ {
if (empty( $sysName )) { if (empty( $sysName )) {
$conf = System::getSystemConfiguration(); $conf = System::getSystemConfiguration();
@@ -1108,5 +1131,6 @@ class System
return false; return false;
} }
}
// end System class
}// end System class