issue 2119. supporting php 5.4. object, page and security classes.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12693 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2013-02-05 02:33:02 +00:00
parent 9b5bee6544
commit 915cdb3824
5 changed files with 409 additions and 333 deletions

View file

@ -1,4 +1,5 @@
<?php
/**
* Every modules inherits from Object class. It includes error, message, and other variables for communicatin purpose.
*
@ -6,6 +7,7 @@
*/
class Object
{
/**
* Error code. If `0`, it is not an error.
* @var int
@ -16,7 +18,7 @@ class Object
* Error message. If `success`, it is not an error.
* @var string
*/
var $message = 'success';
var $message = 'success';
/**
* An additional variable
@ -30,7 +32,6 @@ class Object
*/
var $httpStatusCode = NULL;
/**
* Constructor
*
@ -44,7 +45,6 @@ class Object
$this->setMessage($message);
}
/**
* Setter to set error code
*
@ -95,11 +95,12 @@ class Object
*/
function setMessage($message = 'success')
{
if(Context::getLang($message)) $message = Context::getLang($message);
if(Context::getLang($message))
$message = Context::getLang($message);
$this->message = $message;
// TODO This method always returns True. We'd better remove it
return true;
return TRUE;
}
/**
@ -135,11 +136,14 @@ class Object
if(is_object($object))
{
$object = get_object_vars($object);
}
}
if(is_array($object))
{
foreach($object as $key => $val) $this->variables[$key] = $val;
foreach($object as $key => $val)
{
$this->variables[$key] = $val;
}
}
}
@ -154,7 +158,6 @@ class Object
return $this->variables[$key];
}
/**
* Method to retrieve an object containing a key/value paris
*
@ -164,7 +167,7 @@ class Object
{
$num_args = func_num_args();
$args_list = func_get_args();
for($i=0;$i<$num_args;$i++)
for($i = 0; $i < $num_args; $i++)
{
$key = $args_list[$i];
$output->{$key} = $this->get($key);
@ -189,7 +192,11 @@ class Object
*/
function getObjectVars()
{
foreach($this->variables as $key => $val) $output->{$key} = $val;
$output = new stdClass();
foreach($this->variables as $key => $val)
{
$output->{$key} = $val;
}
return $output;
}
@ -201,10 +208,9 @@ class Object
function toBool()
{
// TODO This method is misleading in that it returns true if error is 0, which should be true in boolean representation.
return $this->error==0?true:false;
return $this->error == 0 ? TRUE : FALSE;
}
/**
* Method to return either true or false depnding on the value in a 'error' variable
*
@ -214,7 +220,7 @@ class Object
{
return $this->toBool();
}
}
}
/* End of file Object.class.php */
/* Location: ./classes/object/Object.class.php */