mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
issue 262 coding convention in classes
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12230 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
cf271c0a98
commit
d5a46e5e90
27 changed files with 1840 additions and 1625 deletions
|
|
@ -5,7 +5,8 @@
|
|||
* @package /classes/xml/xmlquery/queryargument
|
||||
* @version 0.1
|
||||
*/
|
||||
class QueryArgument {
|
||||
class QueryArgument
|
||||
{
|
||||
/**
|
||||
* Argument name
|
||||
* @var string
|
||||
|
|
@ -48,13 +49,14 @@ class QueryArgument {
|
|||
* @param bool $ignore_value
|
||||
* @return void
|
||||
*/
|
||||
function QueryArgument($tag, $ignore_value = false) {
|
||||
function QueryArgument($tag, $ignore_value = false)
|
||||
{
|
||||
static $number_of_arguments = 0;
|
||||
|
||||
$this->argument_name = $tag->attrs->var;
|
||||
if (!$this->argument_name)
|
||||
if(!$this->argument_name)
|
||||
$this->argument_name = str_replace('.', '_', $tag->attrs->name);
|
||||
if (!$this->argument_name)
|
||||
if(!$this->argument_name)
|
||||
$this->argument_name = str_replace('.', '_', $tag->attrs->column);
|
||||
|
||||
$this->variable_name = $this->argument_name;
|
||||
|
|
@ -63,41 +65,47 @@ class QueryArgument {
|
|||
$this->argument_name .= $number_of_arguments;
|
||||
|
||||
$name = $tag->attrs->name;
|
||||
if (!$name)
|
||||
if(!$name)
|
||||
$name = $tag->attrs->column;
|
||||
if (strpos($name, '.') === false)
|
||||
if(strpos($name, '.') === false)
|
||||
$this->column_name = $name;
|
||||
else {
|
||||
else
|
||||
{
|
||||
list($prefix, $name) = explode('.', $name);
|
||||
$this->column_name = $name;
|
||||
$this->table_name = $prefix;
|
||||
}
|
||||
|
||||
if ($tag->attrs->operation)
|
||||
if($tag->attrs->operation)
|
||||
$this->operation = $tag->attrs->operation;
|
||||
|
||||
$this->argument_validator = new QueryArgumentValidator($tag, $this);
|
||||
$this->ignore_value = $ignore_value;
|
||||
}
|
||||
|
||||
function getArgumentName() {
|
||||
function getArgumentName()
|
||||
{
|
||||
return $this->argument_name;
|
||||
}
|
||||
|
||||
function getColumnName() {
|
||||
function getColumnName()
|
||||
{
|
||||
return $this->column_name;
|
||||
}
|
||||
|
||||
function getTableName(){
|
||||
|
||||
function getTableName()
|
||||
{
|
||||
return $this->table_name;
|
||||
}
|
||||
|
||||
function getValidatorString() {
|
||||
function getValidatorString()
|
||||
{
|
||||
return $this->argument_validator->toString();
|
||||
}
|
||||
|
||||
function isConditionArgument() {
|
||||
if ($this->operation)
|
||||
function isConditionArgument()
|
||||
{
|
||||
if($this->operation)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -106,52 +114,56 @@ class QueryArgument {
|
|||
* Change QueryArgument object to string
|
||||
* @return string
|
||||
*/
|
||||
function toString() {
|
||||
if ($this->isConditionArgument()) {
|
||||
function toString()
|
||||
{
|
||||
if($this->isConditionArgument())
|
||||
{
|
||||
// Instantiation
|
||||
$arg = sprintf("\n" . '${\'%s_argument\'} = new ConditionArgument(\'%s\', %s, \'%s\');' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->variable_name
|
||||
, '$args->' . $this->variable_name
|
||||
, $this->operation
|
||||
);
|
||||
, $this->argument_name
|
||||
, $this->variable_name
|
||||
, '$args->' . $this->variable_name
|
||||
, $this->operation
|
||||
);
|
||||
// Call methods to validate argument and ensure default value
|
||||
$arg .= $this->argument_validator->toString();
|
||||
|
||||
// Prepare condition string
|
||||
$arg .= sprintf('${\'%s_argument\'}->createConditionValue();' . "\n"
|
||||
, $this->argument_name
|
||||
);
|
||||
, $this->argument_name
|
||||
);
|
||||
|
||||
// Check that argument passed validation, else return
|
||||
$arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
} else {
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$arg = sprintf("\n" . '${\'%s_argument\'} = new Argument(\'%s\', %s);' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->variable_name
|
||||
, $this->ignore_value ? 'null' : '$args->{\'' . $this->variable_name . '\'}');
|
||||
, $this->argument_name
|
||||
, $this->variable_name
|
||||
, $this->ignore_value ? 'null' : '$args->{\'' . $this->variable_name . '\'}');
|
||||
|
||||
$arg .= $this->argument_validator->toString();
|
||||
|
||||
$arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
}
|
||||
|
||||
// If the argument is null, skip it
|
||||
if ($this->argument_validator->isIgnorable()) {
|
||||
if($this->argument_validator->isIgnorable())
|
||||
{
|
||||
$arg = sprintf("if(isset(%s)) {", '$args->' . $this->variable_name)
|
||||
. $arg
|
||||
. sprintf("} else\n" . '${\'%s_argument\'} = null;', $this->argument_name);
|
||||
. $arg
|
||||
. sprintf("} else\n" . '${\'%s_argument\'} = null;', $this->argument_name);
|
||||
}
|
||||
|
||||
return $arg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
/* End of file QueryArgument.class.php */
|
||||
/* Location: ./classes/xml/xmlquery/queryargument/QueryArgument.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue