issue 2119. supporting php 5.4. widget and xml classes.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12697 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2013-02-05 03:25:47 +00:00
parent 285301a8c9
commit ba9800ff34
37 changed files with 1187 additions and 473 deletions

View file

@ -1,4 +1,5 @@
<?php
/**
* QueryArgumentValidator class
* @author NHN (developers@xpressengine.com)
@ -7,37 +8,42 @@
*/
class QueryArgumentValidator
{
/**
* Argument name
* @var string
*/
var $argument_name;
/**
* Default value
* @var string
*/
var $default_value;
/**
* Notnull status setting, if value should be not null, this value is 'notnull'
* @var string
*/
var $notnull;
/**
* Filter for value type, for example number
* @var string
*/
var $filter;
/**
* Minimum length for value
* @var int
*/
var $min_length;
/**
* Maximum length for value
* @var int
*/
var $max_length;
var $validator_string;
/**
@ -66,8 +72,11 @@ class QueryArgumentValidator
function isIgnorable()
{
if(isset($this->default_value) || isset($this->notnull)) return false;
return true;
if(isset($this->default_value) || isset($this->notnull))
{
return FALSE;
}
return TRUE;
}
function toString()
@ -76,50 +85,50 @@ class QueryArgumentValidator
if($this->filter)
{
$validator .= sprintf('${\'%s_argument\'}->checkFilter(\'%s\');' . "\n"
, $this->argument_name
, $this->filter
);
, $this->argument_name
, $this->filter
);
}
if($this->min_length)
{
$validator .= sprintf('${\'%s_argument\'}->checkMinLength(%s);' . "\n"
, $this->argument_name
, $this->min_length
);
, $this->argument_name
, $this->min_length
);
}
if($this->max_length)
{
$validator .= sprintf('${\'%s_argument\'}->checkMaxLength(%s);'. "\n"
, $this->argument_name
, $this->max_length
);
$validator .= sprintf('${\'%s_argument\'}->checkMaxLength(%s);' . "\n"
, $this->argument_name
, $this->max_length
);
}
if(isset($this->default_value))
{
$this->default_value = new DefaultValue($this->argument_name, $this->default_value);
if($this->default_value->isSequence())
$validator .= '$db = &DB::getInstance(); $sequence = $db->getNextSequence(); ';
$validator .= '$db = DB::getInstance(); $sequence = $db->getNextSequence(); ';
if($this->default_value->isOperation())
{
$validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');' . "\n"
, $this->argument_name
, $this->default_value->getOperation()
);
, $this->argument_name
, $this->default_value->getOperation()
);
}
$validator .= sprintf('${\'%s_argument\'}->ensureDefaultValue(%s);' . "\n"
, $this->argument_name
, $this->default_value->toString()
);
, $this->argument_name
, $this->default_value->toString()
);
}
if($this->notnull)
{
$validator .= sprintf('${\'%s_argument\'}->checkNotNull();' . "\n"
, $this->argument_name
);
, $this->argument_name
);
}
return $validator;
}
}
}
/* End of file QueryArgumentValidator.class.php */
/* Location: ./classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php */