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
{
var $Columns = null;
var $Labels = null;
var $rows_per_page = 25;
var $show_nummbers = null;
var $first_row = 0;
var $row_pos = 0;
var $Action = ""; //not used
var $ActionLabel = "Continuar"; //not used
var $_dbc = null;
var $_dbses = null;
var $_dbset = null;
var $_source = "";
var $DefaultOrder = "UID";
var $DefaultOrderDir = 'ASC';
var $CustomOrder = "";
var $WhereClause = "";
var $_row_values = null;
var $_ordered = true;
var $orderprefix = "";
var $CountQry = "";
var $filtro = 1;
var $title = '';
public $Columns = null;
public $Labels = null;
public $rows_per_page = 25;
public $show_nummbers = null;
public $first_row = 0;
public $row_pos = 0;
public $Action = ""; //not used
public $ActionLabel = "Continuar"; //not used
public $_dbc = null;
public $_dbses = null;
public $_dbset = null;
public $_source = "";
public $DefaultOrder = "UID";
public $DefaultOrderDir = 'ASC';
public $CustomOrder = "";
public $WhereClause = "";
public $_row_values = null;
public $_ordered = true;
public $orderprefix = "";
public $CountQry = "";
public $filtro = 1;
public $title = '';
/**
* Asocia un arreglo con valores de traducci?n/conversi?n a un contexto
*
* @var array
*/
var $contexto = null;
public $contexto = null;
/**
* Arreglo que contiene las cadenas que van a ser usadas al traducir/convertir
*
* @var array
*/
var $translate = null;
public $translate = null;
/**
* Establece el ?ltimo contexto utilizado
*
* @var string
*/
var $_contexto = '';
public $_contexto = '';
/**
* Set conecction using default values
@@ -95,7 +95,7 @@ class Table
* @param string $objConnection connection string
* @return void
*/
function Table ($objConnection = null)
public function Table ($objConnection = null)
{
$this->SetTo( $objConnection );
}
@@ -108,7 +108,7 @@ class Table
* @param string $objConnection connection string
* @return void
*/
function SetTo ($objConnection = null)
public function SetTo ($objConnection = null)
{
$this->_dbc = $objConnection;
}
@@ -122,7 +122,7 @@ class Table
* @param string $stDefaultOrder index to order by, default value='UID'
* @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.
$url1 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?';
@@ -149,7 +149,7 @@ class Table
* @access public
* @return void
*/
function GetSource ()
public function GetSource ()
{
global $HTTP_GET_VARS;
global $HTTP_SESSION_VARS;
@@ -238,7 +238,7 @@ class Table
* @access public
* @return int
*/
function TotalCount ()
public function TotalCount ()
{
global $HTTP_GET_VARS;
global $HTTP_SESSION_VARS;
@@ -275,7 +275,7 @@ class Table
* @access public
* @return int
*/
function Count ()
public function Count ()
{
if (is_object( $this->_dbset )) {
return $this->_dbset->Count();
@@ -291,7 +291,7 @@ class Table
* @access public
* @return int
*/
function CurRow ()
public function CurRow ()
{
return $this->row_pos;
}
@@ -303,7 +303,7 @@ class Table
* @access public
* @return int
*/
function ColumnCount ()
public function ColumnCount ()
{
$result = 0;
if (is_array( $this->Columns )) {
@@ -319,7 +319,7 @@ class Table
* @access public
* @return array
*/
function Read ()
public function Read ()
{
$this->_row_values = $this->_dbset->Read();
$this->row_pos ++;
@@ -334,7 +334,7 @@ class Table
* @param int $intPos position to seek
* @return int
*/
function Seek ($intPos = 0)
public function Seek ($intPos = 0)
{
$result = $this->_dbset->Seek( $intPos );
if ($result) {
@@ -350,7 +350,7 @@ class Table
* @access public
* @return int
*/
function MoveFirst ()
public function MoveFirst ()
{
if ($this->Count() != 0) {
if ($this->first_row < $this->Count()) {
@@ -366,7 +366,7 @@ class Table
* @access public
* @return boolean
*/
function EOF ()
public function EOF ()
{
$result = false;
if ($this->Count() == 0) {
@@ -399,7 +399,7 @@ class Table
* @param $strContent
* @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
);
@@ -427,7 +427,7 @@ class Table
* @param $orderByThis
* @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
);
@@ -449,7 +449,7 @@ class Table
* @param $strClass
* @return void
*/
function RenderTitle ($pa, $intPos = 1, $strClass = "tblHeader")
public function RenderTitle ($pa, $intPos = 1, $strClass = "tblHeader")
{
if (! defined( 'ENABLE_ENCRYPT' )) {
define( 'ENABLE_ENCRYPT', 'no' );
@@ -492,7 +492,7 @@ class Table
* @param $strClass
* @return void
*/
function RenderTitle_ajax ($pa, $intPos = 1, $strClass = "tblHeader")
public function RenderTitle_ajax ($pa, $intPos = 1, $strClass = "tblHeader")
{
global $HTTP_SESSION_VARS;
$col = $this->Columns[$intPos];
@@ -543,7 +543,7 @@ class Table
* @param $auxgetval
* @return void
*/
function RenderTitle2 ($pa, $fil, $intPos, $strClass = "tblHeader", $auxgetval = '')
public function RenderTitle2 ($pa, $fil, $intPos, $strClass = "tblHeader", $auxgetval = '')
{
if (! defined( 'ENABLE_ENCRYPT' )) {
define( 'ENABLE_ENCRYPT', 'no' );
@@ -609,7 +609,7 @@ class Table
* @param $renderTD if this value = 1, this function will include the TD tags
* @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' )) {
define( 'ENABLE_ENCRYPT', 'no' );
@@ -777,7 +777,8 @@ class Table
$tlabel = substr( $col["Content"], 0, 1 );
$vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) );
$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> ";
} else {
$res .= "&nbsp;";
@@ -828,14 +829,13 @@ class Table
} else {
$val2 = "<span class='txtin3'>" . strtoupper( $fieldname ) . "</span>";
}
// break;
//break;
case "link":
if ($val == "") {
$res .= "&nbsp;";
}
$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'] . " \"" : '');
if (is_array( $col['Content'] ) && $col['Content'] != "") {
// Hay mas de un valor para el link
@@ -1070,7 +1070,7 @@ class Table
* @param string $strLabel Label
* @return void
*/
function SetAction ($strAction, $strLabel = "Continue")
public function SetAction ($strAction, $strLabel = "Continue")
{
$this->Action = $strAction;
$this->ActionLabel = $strLabel;
@@ -1086,7 +1086,7 @@ class Table
* @access public
* @return void
*/
function setTranslate ($contexto, $tabla, $nombre)
public function setTranslate ($contexto, $tabla, $nombre)
{
if (is_array( $this->contexto )) {
$this->contexto[0][] = $contexto;
@@ -1118,7 +1118,7 @@ class Table
* @param string $lang El lenguaje que se va utilizar
* @return mixed
*/
function translateValue ($contexto, $valor, $lang)
public function translateValue ($contexto, $valor, $lang)
{
// Verificar si exite el contexto
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
* @return void
*/
function setContext ($contexto)
public function setContext ($contexto)
{
$this->_context = $contexto;
}
@@ -1158,7 +1158,7 @@ class Table
* @access public
* @return void
*/
function ParsingFromHtml ($value, $number = '100000000')
public function ParsingFromHtml ($value, $number = '100000000')
{
$car = substr( $value, 0, 1 );
$len = strlen( $value );

View File

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

View File

@@ -38,15 +38,14 @@
class System
{
var $sFilename;
var $sFilesList;
var $sUpgradeFileList;
var $aErrors;
var $aWorkspaces;
var $sRevision;
var $sPath;
var $newSystemClass;
public $sFilename;
public $sFilesList;
public $sUpgradeFileList;
public $aErrors;
public $aWorkspaces;
public $sRevision;
public $sPath;
public $newSystemClass;
/**
* List currently installed plugins
@@ -84,8 +83,9 @@ class System
$oDirectory = dir( PATH_DB );
$aWorkspaces = array ();
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 ) );
}
}
return $aWorkspaces;
}
@@ -105,8 +105,9 @@ class System
include (PATH_METHODS . 'login/version-pmos.php');
} else {
$version = self::getVersionFromGit();
if ($version === false)
if ($version === false) {
$version = 'Development Version';
}
define( 'PM_VERSION', $version );
}
}
@@ -119,12 +120,14 @@ class System
* @author Alexandre Rosenfeld <alexandre@colosa.com>
* @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;
if (! file_exists( "$dir/.git" ))
}
if (! file_exists( "$dir/.git" )) {
return false;
}
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 );
return implode( ' ', $target );
@@ -152,32 +155,34 @@ class System
}
/* For distros with the lsb_release, this returns a one-line description of
* the distro name, such as "CentOS release 5.3 (Final)" or "Ubuntu 10.10"
*/
* the distro name, such as "CentOS release 5.3 (Final)" or "Ubuntu 10.10"
*/
$distro = exec( "lsb_release -d -s 2> /dev/null" );
/* For distros without lsb_release, we look for *release (such as
* redhat-release, gentoo-release, SuSE-release, etc) or *version (such as
* debian_version, slackware-version, etc)
*/
* redhat-release, gentoo-release, SuSE-release, etc) or *version (such as
* debian_version, slackware-version, etc)
*/
if (empty( $distro )) {
foreach (glob( "/etc/*release" ) as $filename) {
$distro = trim( file_get_contents( $filename ) );
if (! empty( $distro ))
if (! empty( $distro )) {
break;
}
}
if (empty( $distro )) {
foreach (glob( "/etc/*version" ) as $filename) {
$distro = trim( file_get_contents( $filename ) );
if (! empty( $distro ))
if (! empty( $distro )) {
break;
}
}
}
}
/* 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)
*/
$distro = trim( $distro, "\"" ) . " (" . PHP_OS . ")";
$Fields = array ();
@@ -210,18 +215,21 @@ class System
public static function verifyChecksum ()
{
if (! file_exists( PATH_TRUNK . "checksum.txt" ))
if (! file_exists( PATH_TRUNK . "checksum.txt" )) {
return false;
}
$lines = explode( "\n", file_get_contents( PATH_TRUNK . "checksum.txt" ) );
$result = array ("diff" => array (),"missing" => array ()
);
foreach ($lines as $line) {
if (empty( $line ))
if (empty( $line )) {
continue;
}
list ($checksum, $empty, $filename) = explode( " ", $line );
//Skip xmlform because these files always change.
if (strpos( $filename, "/xmlform/" ) !== false)
if (strpos( $filename, "/xmlform/" ) !== false) {
continue;
}
if (file_exists( realpath( $filename ) )) {
if (strcmp( $checksum, md5_file( realpath( $filename ) ) ) != 0) {
$result['diff'][] = $filename;
@@ -242,7 +250,7 @@ class System
* param
* @return boolean
*/
function verifyFileForUpgrade ()
public function verifyFileForUpgrade ()
{
$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'] : '';
@@ -266,7 +274,7 @@ class System
* param
* @return void
*/
function getUpgradedFilesList ()
public function getUpgradedFilesList ()
{
G::LoadClass( 'archive' );
$this->sFilesList = new gzip_file( $this->sFilename );
@@ -294,7 +302,7 @@ class System
* param
* @return boolean
*/
function verifyForBootstrapUpgrade ()
public function verifyForBootstrapUpgrade ()
{
foreach ($this->sFilesList->files as $sFile) {
if (basename( $sFile ) == 'schema.xml') {
@@ -314,7 +322,7 @@ class System
* param
* @return array
*/
function upgrade ()
public function upgrade ()
{
//get special files
$sListFile = '';
@@ -417,8 +425,9 @@ class System
}
} else {
$dirName = PATH_TRUNK . $sFilePath;
if ($dirName[strlen( $dirName ) - 1] == '/')
if ($dirName[strlen( $dirName ) - 1] == '/') {
$dirName = substr( $dirName, 0, strlen( $dirName ) - 1 );
}
$auxDir = explode( '/', $dirName );
array_pop( $auxDir );
$parentDir = implode( '/', $auxDir );
@@ -462,13 +471,15 @@ class System
if (is_writable( $targetFileName )) {
$this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName );
@chmod( $targetFileName, 0666 );
} else
} else {
throw (new Exception( "Failed to open file: Permission denied in $targetFileName." ));
}
} else {
$this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName );
@chmod( $targetFileName, 0666 );
}
} else { //delete unused files
} else {
//delete unused files
if (file_exists( $targetFileName )) {
@unlink( $targetFileName );
}
@@ -478,7 +489,7 @@ class System
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 );
}
}
@@ -512,8 +523,9 @@ class System
fclose( $fp );
}
if ($missed > 0)
if ($missed > 0) {
$aErrors[] = "Warning: there are $missed missed files. ";
}
$aErrors[] = $missedFiles;
if ($distinct > 0) {
@@ -557,9 +569,7 @@ class System
while (($sObject = $oDirectory->read())) {
if (is_dir( PATH_DB . $sObject ) && substr( $sObject, 0, 1 ) != '.') {
if (file_exists( PATH_DB . $sObject . PATH_SEP . 'db.php' )) {
eval( $this->getDatabaseCredentials( PATH_DB . $sObject . PATH_SEP . 'db.php' ) );
}
$aEnvironmentsUpdated[] = $sObject;
$aEnvironmentsDiff[] = $sObject;
@@ -629,7 +639,7 @@ class System
* @param string $target
* @return void
*/
function pm_copy ($source, $target)
public function pm_copy ($source, $target)
{
if (! is_dir( dirname( $target ) )) {
G::mk_dir( dirname( $target ) );
@@ -649,7 +659,7 @@ class System
* @param string $dbFile
* @return $sContent
*/
function getDatabaseCredentials ($dbFile)
public function getDatabaseCredentials ($dbFile)
{
$sContent = file_get_contents( $dbFile );
$sContent = str_replace( '<?php', '', $sContent );
@@ -680,10 +690,11 @@ class System
*/
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" );
else
} else {
return false;
}
}
/**
@@ -696,8 +707,8 @@ class System
{
/* This is the MySQL mapping that Propel uses (from MysqlPlatform.php) */
$mysqlTypes = array ('NUMERIC' => "DECIMAL",'LONGVARCHAR' => "MEDIUMTEXT",'TIMESTAMP' => "DATETIME",'BU_TIMESTAMP' => "DATETIME",'BINARY' => "BLOB",'VARBINARY' => "MEDIUMBLOB",'LONGVARBINARY' => "LONGBLOB",'BLOB' => "LONGBLOB",'CLOB' => "LONGTEXT",
/* This is not from Propel, but is required to get INT right */
'INTEGER' => "INT"
/* This is not from Propel, but is required to get INT right */
'INTEGER' => "INT"
);
$aSchema = array ();
@@ -716,33 +727,37 @@ class System
$type = $oColumn->hasAttribute( 'type' ) ? strtoupper( $oColumn->getAttribute( 'type' ) ) : "VARCHAR";
/* Convert type to MySQL type according to Propel */
if (array_key_exists( $type, $mysqlTypes ))
if (array_key_exists( $type, $mysqlTypes )) {
$type = $mysqlTypes[$type];
}
$size = $oColumn->hasAttribute( 'size' ) ? $oColumn->getAttribute( 'size' ) : NULL;
$size = $oColumn->hasAttribute( 'size' ) ? $oColumn->getAttribute( 'size' ) : null;
/* Add default sizes from MySQL */
if ($type == "TINYINT" && ! $size)
if ($type == "TINYINT" && ! $size) {
$size = "4";
if ($type == "INT" && ! $size)
}
if ($type == "INT" && ! $size) {
$size = "11";
}
if ($size)
if ($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 */
$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 */
$primaryKey = (in_array( strtolower( $primaryKey ), array ('1','true'
) ));
if ($primaryKey)
if ($primaryKey) {
$aPrimaryKeys[] = $sColumName;
}
$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 ($aColumns as $sColumName => $aParameters) {
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] )) {
$aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array ()
);
}
$aChanges['tablesToAlter'][$sTableName]['ADD'][$sColumName] = $aParameters;
} else { //the column exists
} else {
//the column exists
$newField = $aNewSchema[$sTableName][$sColumName];
$oldField = $aOldSchema[$sTableName][$sColumName];
//both are null, no change is required
if (! isset( $newField['Default'] ) && ! isset( $oldField['Default'] ))
if (! isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) {
$changeDefaultAttr = false;
//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;
if (isset( $newField['Default'] ) && ! isset( $oldField['Default'] ))
}
if (isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) {
$changeDefaultAttr = true;
//both are defined and they are different.
}
if (isset( $newField['Default'] ) && isset( $oldField['Default'] )) {
if ($newField['Default'] != $oldField['Default'])
if ($newField['Default'] != $oldField['Default']) {
$changeDefaultAttr = true;
else
} else {
$changeDefaultAttr = false;
}
}
//special cases
// 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;
}
//#1067 - Invalid default value for datetime field
if (in_array( $newField['Type'], array ('datetime'
) ) && isset( $newField['Default'] ) && $newField['Default'] == '')
if (in_array( $newField['Type'], array ('datetime') ) && isset( $newField['Default'] ) && $newField['Default'] == '') {
$changeDefaultAttr = false;
}
//#1067 - Invalid default value for int field
if (substr( $newField['Type'], 0, 3 ) == "int" && isset( $newField['Default'] ) && $newField['Default'] == '')
//#1067 - Invalid default value for int field
if (substr( $newField['Type'], 0, 3 ) == "int" && isset( $newField['Default'] ) && $newField['Default'] == '') {
$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 (! 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]['Type'] = $newField['Type'];
$aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Null'] = $newField['Null'];
if (isset( $newField['Default'] ))
if (isset( $newField['Default'] )) {
$aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = $newField['Default'];
else
} else {
$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
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;
}
function getEmailConfiguration ()
public function getEmailConfiguration ()
{
G::LoadClass( 'configuration' );
$conf = new Configurations();
@@ -897,7 +920,7 @@ class System
return $config;
}
function getSkingList ()
public function getSkingList ()
{
//Create Skins custom folder if it doesn't exists
if (! is_dir( PATH_CUSTOM_SKINS )) {
@@ -949,7 +972,7 @@ class System
return $skinListArray;
}
function getAllTimeZones ()
public function getAllTimeZones ()
{
$timezones = DateTimeZone::listAbbreviations();
@@ -968,10 +991,10 @@ class System
}
// 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 );
// 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 );
// Sort by area/city name.
@@ -990,10 +1013,10 @@ class System
}
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 )) {
$uriParts = explode( '/', getenv( "REQUEST_URI" ) );
if (isset( $uriParts[1] )) {
if (substr( $uriParts[1], 0, 3 ) == 'sys') {
$wsName = substr( $uriParts[1], 3 );
@@ -1010,12 +1033,12 @@ class System
if (isset( $_SESSION['PROCESSMAKER_ENV'] )) {
$md5 = array ();
if ($readGlobalIniFile)
if ($readGlobalIniFile) {
$md5[] = md5_file( $globalIniFile );
if ($readWsIniFile)
}
if ($readWsIniFile) {
$md5[] = md5_file( $wsIniFile );
}
$hash = implode( '-', $md5 );
if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
@@ -1046,12 +1069,12 @@ class System
}
$md5 = array ();
if ($readGlobalIniFile)
if ($readGlobalIniFile) {
$md5[] = md5_file( $globalIniFile );
if ($readWsIniFile)
}
if ($readWsIniFile) {
$md5[] = md5_file( $wsIniFile );
}
$hash = implode( '-', $md5 );
$_SESSION['PROCESSMAKER_ENV'] = $config;
@@ -1060,7 +1083,7 @@ class System
return $config;
}
function updateIndexFile ($conf)
public function updateIndexFile ($conf)
{
if (! file_exists( PATH_HTML . 'index.html' )) {
throw new Exception( 'The public index file "' . PATH_HTML . 'index.html" does not exist!' );
@@ -1089,7 +1112,7 @@ class System
return $result;
}
function solrEnv ($sysName = '')
public function solrEnv ($sysName = '')
{
if (empty( $sysName )) {
$conf = System::getSystemConfiguration();
@@ -1108,5 +1131,6 @@ class System
return false;
}
}
// end System class
}// end System class