mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-16 09:49:54 +09:00
merge from 1.7.3.5(r13153:r13167)
git-svn-id: http://xe-core.googlecode.com/svn/trunk@13168 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
cc47d2b247
commit
2d3f149b5a
2042 changed files with 129266 additions and 126243 deletions
|
|
@ -1,146 +1,175 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DefaultValue class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/queryargument
|
||||
* @version 0.1
|
||||
*/
|
||||
class DefaultValue
|
||||
{
|
||||
|
||||
/**
|
||||
* DefaultValue class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/queryargument
|
||||
* @version 0.1
|
||||
* Column name
|
||||
* @var string
|
||||
*/
|
||||
class DefaultValue {
|
||||
/**
|
||||
* Column name
|
||||
* @var string
|
||||
*/
|
||||
var $column_name;
|
||||
/**
|
||||
* Value
|
||||
* @var mixed
|
||||
*/
|
||||
var $value;
|
||||
/**
|
||||
* sequnence status
|
||||
* @var bool
|
||||
*/
|
||||
var $is_sequence = false;
|
||||
/**
|
||||
* operation status
|
||||
* @var bool
|
||||
*/
|
||||
var $is_operation = false;
|
||||
/**
|
||||
* operation
|
||||
* @var string
|
||||
*/
|
||||
var $operation = '';
|
||||
/**
|
||||
* Checks if value is plain string or name of XE function (ipaddress, plus, etc).
|
||||
* @var bool
|
||||
*/
|
||||
var $_is_string = false;
|
||||
/**
|
||||
* Checks if value is string resulted from evaluating a piece of PHP code (see $_SERVER[REMOTE_ADDR])
|
||||
* @var bool
|
||||
*/
|
||||
var $_is_string_from_function = false;
|
||||
var $column_name;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name column name
|
||||
* @param mixed $value value
|
||||
* @return void
|
||||
*/
|
||||
function DefaultValue($column_name, $value){
|
||||
$dbParser = &DB::getParser();
|
||||
$this->column_name = $dbParser->parseColumnName($column_name);
|
||||
$this->value = $value;
|
||||
$this->value = $this->_setValue();
|
||||
}
|
||||
/**
|
||||
* Value
|
||||
* @var mixed
|
||||
*/
|
||||
var $value;
|
||||
|
||||
function isString(){
|
||||
return $this->_is_string;
|
||||
$str_pos = strpos($this->value, '(');
|
||||
if($str_pos===false) return true;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* sequnence status
|
||||
* @var bool
|
||||
*/
|
||||
var $is_sequence = FALSE;
|
||||
|
||||
function isStringFromFunction(){
|
||||
return $this->_is_string_from_function;
|
||||
}
|
||||
/**
|
||||
* operation status
|
||||
* @var bool
|
||||
*/
|
||||
var $is_operation = FALSE;
|
||||
|
||||
function isSequence(){
|
||||
return $this->is_sequence;
|
||||
}
|
||||
/**
|
||||
* operation
|
||||
* @var string
|
||||
*/
|
||||
var $operation = '';
|
||||
|
||||
function isOperation(){
|
||||
return $this->is_operation;
|
||||
}
|
||||
/**
|
||||
* Checks if value is plain string or name of XE function (ipaddress, plus, etc).
|
||||
* @var bool
|
||||
*/
|
||||
var $_is_string = FALSE;
|
||||
|
||||
function getOperation(){
|
||||
return $this->operation;
|
||||
}
|
||||
/**
|
||||
* Checks if value is string resulted from evaluating a piece of PHP code (see $_SERVER[REMOTE_ADDR])
|
||||
* @var bool
|
||||
*/
|
||||
var $_is_string_from_function = FALSE;
|
||||
|
||||
function _setValue(){
|
||||
if(!isset($this->value)) return;
|
||||
|
||||
// If value contains comma separated values and does not contain paranthesis
|
||||
// -> default value is an array
|
||||
if(strpos($this->value, ',') !== false && strpos($this->value, '(') === false) {
|
||||
return sprintf('array(%s)', $this->value);
|
||||
}
|
||||
|
||||
$str_pos = strpos($this->value, '(');
|
||||
// // TODO Replace this with parseExpression
|
||||
if($str_pos===false) {
|
||||
$this->_is_string = true;
|
||||
return '\''.$this->value.'\'';
|
||||
}
|
||||
//if($str_pos===false) return $this->value;
|
||||
|
||||
$func_name = substr($this->value, 0, $str_pos);
|
||||
$args = substr($this->value, $str_pos+1, -1);
|
||||
|
||||
switch($func_name) {
|
||||
case 'ipaddress' :
|
||||
$val = '$_SERVER[\'REMOTE_ADDR\']';
|
||||
$this->_is_string_from_function = true;
|
||||
break;
|
||||
case 'unixtime' :
|
||||
$val = 'time()';
|
||||
break;
|
||||
case 'curdate' :
|
||||
$val = 'date("YmdHis")';
|
||||
$this->_is_string_from_function = true;
|
||||
break;
|
||||
case 'sequence' :
|
||||
$this->is_sequence = true;
|
||||
$val = '$sequence';
|
||||
break;
|
||||
case 'plus' :
|
||||
$args = abs($args);
|
||||
$this->is_operation = true;
|
||||
$this->operation = '+';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
case 'minus' :
|
||||
$args = abs($args);
|
||||
$this->is_operation = true;
|
||||
$this->operation = '-';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
case 'multiply' :
|
||||
$args = intval($args);
|
||||
$this->is_operation = true;
|
||||
$this->operation = '*';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
default :
|
||||
$val = '\'' . $this->value . '\'';
|
||||
//$val = $this->value;
|
||||
}
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
function toString(){
|
||||
return $this->value;
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name column name
|
||||
* @param mixed $value value
|
||||
* @return void
|
||||
*/
|
||||
function DefaultValue($column_name, $value)
|
||||
{
|
||||
$dbParser = DB::getParser();
|
||||
$this->column_name = $dbParser->parseColumnName($column_name);
|
||||
$this->value = $value;
|
||||
$this->value = $this->_setValue();
|
||||
}
|
||||
|
||||
function isString()
|
||||
{
|
||||
return $this->_is_string;
|
||||
$str_pos = strpos($this->value, '(');
|
||||
if($str_pos === false)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function isStringFromFunction()
|
||||
{
|
||||
return $this->_is_string_from_function;
|
||||
}
|
||||
|
||||
function isSequence()
|
||||
{
|
||||
return $this->is_sequence;
|
||||
}
|
||||
|
||||
function isOperation()
|
||||
{
|
||||
return $this->is_operation;
|
||||
}
|
||||
|
||||
function getOperation()
|
||||
{
|
||||
return $this->operation;
|
||||
}
|
||||
|
||||
function _setValue()
|
||||
{
|
||||
if(!isset($this->value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If value contains comma separated values and does not contain paranthesis
|
||||
// -> default value is an array
|
||||
if(strpos($this->value, ',') !== FALSE && strpos($this->value, '(') === FALSE)
|
||||
{
|
||||
return sprintf('array(%s)', $this->value);
|
||||
}
|
||||
|
||||
$str_pos = strpos($this->value, '(');
|
||||
// // TODO Replace this with parseExpression
|
||||
if($str_pos === FALSE)
|
||||
{
|
||||
$this->_is_string = TRUE;
|
||||
return '\'' . $this->value . '\'';
|
||||
}
|
||||
//if($str_pos===false) return $this->value;
|
||||
|
||||
$func_name = substr($this->value, 0, $str_pos);
|
||||
$args = substr($this->value, $str_pos + 1, -1);
|
||||
|
||||
switch($func_name)
|
||||
{
|
||||
case 'ipaddress' :
|
||||
$val = '$_SERVER[\'REMOTE_ADDR\']';
|
||||
$this->_is_string_from_function = TRUE;
|
||||
break;
|
||||
case 'unixtime' :
|
||||
$val = 'time()';
|
||||
break;
|
||||
case 'curdate' :
|
||||
$val = 'date("YmdHis")';
|
||||
$this->_is_string_from_function = TRUE;
|
||||
break;
|
||||
case 'sequence' :
|
||||
$this->is_sequence = TRUE;
|
||||
$val = '$sequence';
|
||||
break;
|
||||
case 'plus' :
|
||||
$args = abs($args);
|
||||
$this->is_operation = TRUE;
|
||||
$this->operation = '+';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
case 'minus' :
|
||||
$args = abs($args);
|
||||
$this->is_operation = TRUE;
|
||||
$this->operation = '-';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
case 'multiply' :
|
||||
$args = intval($args);
|
||||
$this->is_operation = TRUE;
|
||||
$this->operation = '*';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
default :
|
||||
$val = '\'' . $this->value . '\'';
|
||||
//$val = $this->value;
|
||||
}
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
function toString()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file DefaultValue.class.php */
|
||||
/* Location: ./classes/xml/xmlquery/queryargument/DefaultValue.class.php */
|
||||
|
|
|
|||
|
|
@ -1,41 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* QueryArgument class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/queryargument
|
||||
* @version 0.1
|
||||
*/
|
||||
class QueryArgument {
|
||||
class QueryArgument
|
||||
{
|
||||
|
||||
/**
|
||||
* Argument name
|
||||
* @var string
|
||||
*/
|
||||
var $argument_name;
|
||||
|
||||
/**
|
||||
* Variable name
|
||||
* @var string
|
||||
*/
|
||||
var $variable_name;
|
||||
|
||||
/**
|
||||
* Argument validator
|
||||
* @var QueryArgumentValidator
|
||||
*/
|
||||
var $argument_validator;
|
||||
|
||||
/**
|
||||
* Column name
|
||||
* @var string
|
||||
*/
|
||||
var $column_name;
|
||||
|
||||
/**
|
||||
* Table name
|
||||
* @var string
|
||||
*/
|
||||
var $table_name;
|
||||
|
||||
/**
|
||||
* Operation
|
||||
* @var string
|
||||
*/
|
||||
var $operation;
|
||||
|
||||
/**
|
||||
* Ignore value
|
||||
* @var bool
|
||||
|
|
@ -48,14 +57,19 @@ 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,51 +77,67 @@ 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)
|
||||
return true;
|
||||
return false;
|
||||
function isConditionArgument()
|
||||
{
|
||||
if($this->operation)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
@ -128,11 +158,13 @@ class QueryArgument {
|
|||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
} else {
|
||||
}
|
||||
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->ignore_value ? 'NULL' : '$args->{\'' . $this->variable_name . '\'}');
|
||||
|
||||
$arg .= $this->argument_validator->toString();
|
||||
|
||||
|
|
@ -143,15 +175,16 @@ class QueryArgument {
|
|||
}
|
||||
|
||||
// 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);
|
||||
. 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 */
|
||||
|
|
|
|||
|
|
@ -1,29 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SortQueryArgument class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/queryargument
|
||||
* @version 0.1
|
||||
*/
|
||||
class SortQueryArgument extends QueryArgument
|
||||
{
|
||||
|
||||
/**
|
||||
* SortQueryArgument class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/queryargument
|
||||
* @version 0.1
|
||||
* Change SortQueryArgument object to string
|
||||
* @return string
|
||||
*/
|
||||
class SortQueryArgument extends QueryArgument{
|
||||
/**
|
||||
* Change SortQueryArgument object to string
|
||||
* @return string
|
||||
*/
|
||||
function toString(){
|
||||
$arg = sprintf("\n" . '${\'%s_argument\'} = new SortArgument(\'%s\', %s);' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
, '$args->'.$this->variable_name);
|
||||
function toString()
|
||||
{
|
||||
$arg = sprintf("\n" . '${\'%s_argument\'} = new SortArgument(\'%s\', %s);' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
, '$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
|
||||
);
|
||||
return $arg;
|
||||
}
|
||||
|
||||
$arg .= $this->argument_validator->toString();
|
||||
|
||||
$arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file DefaultValue.class.php */
|
||||
/* Location: ./classes/xml/xmlquery/queryargument/DefaultValue.class.php */
|
||||
|
|
|
|||
|
|
@ -1,113 +1,134 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* QueryArgumentValidator class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/queryargument/validator
|
||||
* @version 0.1
|
||||
*/
|
||||
class QueryArgumentValidator
|
||||
{
|
||||
|
||||
/**
|
||||
* QueryArgumentValidator class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/queryargument/validator
|
||||
* @version 0.1
|
||||
* Argument name
|
||||
* @var string
|
||||
*/
|
||||
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 $argument_name;
|
||||
|
||||
var $validator_string;
|
||||
/**
|
||||
* Default value
|
||||
* @var string
|
||||
*/
|
||||
var $default_value;
|
||||
|
||||
/**
|
||||
* Query argument for validate
|
||||
* @var QueryArgument object
|
||||
*/
|
||||
var $argument;
|
||||
/**
|
||||
* Notnull status setting, if value should be not null, this value is 'notnull'
|
||||
* @var string
|
||||
*/
|
||||
var $notnull;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param Xml_Node_ $tag tag object by Query xml file parse
|
||||
* @param QueryArgument $argument
|
||||
* @return void
|
||||
*/
|
||||
function QueryArgumentValidator($tag, $argument){
|
||||
$this->argument = $argument;
|
||||
$this->argument_name = $this->argument->getArgumentName();
|
||||
/**
|
||||
* Filter for value type, for example number
|
||||
* @var string
|
||||
*/
|
||||
var $filter;
|
||||
|
||||
$this->default_value = $tag->attrs->default;
|
||||
$this->notnull = $tag->attrs->notnull;
|
||||
$this->filter = $tag->attrs->filter;
|
||||
$this->min_length = $tag->attrs->min_length;
|
||||
$this->max_length = $tag->attrs->max_length;
|
||||
}
|
||||
/**
|
||||
* Minimum length for value
|
||||
* @var int
|
||||
*/
|
||||
var $min_length;
|
||||
|
||||
function isIgnorable(){
|
||||
if(isset($this->default_value) || isset($this->notnull)) return false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Maximum length for value
|
||||
* @var int
|
||||
*/
|
||||
var $max_length;
|
||||
var $validator_string;
|
||||
|
||||
function toString(){
|
||||
$validator = '';
|
||||
if($this->filter){
|
||||
$validator .= sprintf('${\'%s_argument\'}->checkFilter(\'%s\');' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->filter
|
||||
);
|
||||
}
|
||||
if($this->min_length){
|
||||
$validator .= sprintf('${\'%s_argument\'}->checkMinLength(%s);' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->min_length
|
||||
);
|
||||
}
|
||||
if($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(); ';
|
||||
if($this->default_value->isOperation())
|
||||
$validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->default_value->getOperation()
|
||||
);
|
||||
$validator .= sprintf('${\'%s_argument\'}->ensureDefaultValue(%s);' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->default_value->toString()
|
||||
);
|
||||
}
|
||||
if($this->notnull){
|
||||
$validator .= sprintf('${\'%s_argument\'}->checkNotNull();' . "\n"
|
||||
, $this->argument_name
|
||||
);
|
||||
}
|
||||
return $validator;
|
||||
}
|
||||
/**
|
||||
* Query argument for validate
|
||||
* @var QueryArgument object
|
||||
*/
|
||||
var $argument;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param Xml_Node_ $tag tag object by Query xml file parse
|
||||
* @param QueryArgument $argument
|
||||
* @return void
|
||||
*/
|
||||
function QueryArgumentValidator($tag, $argument)
|
||||
{
|
||||
$this->argument = $argument;
|
||||
$this->argument_name = $this->argument->getArgumentName();
|
||||
|
||||
$this->default_value = $tag->attrs->default;
|
||||
$this->notnull = $tag->attrs->notnull;
|
||||
$this->filter = $tag->attrs->filter;
|
||||
$this->min_length = $tag->attrs->min_length;
|
||||
$this->max_length = $tag->attrs->max_length;
|
||||
}
|
||||
|
||||
?>
|
||||
function isIgnorable()
|
||||
{
|
||||
if(isset($this->default_value) || isset($this->notnull))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function toString()
|
||||
{
|
||||
$validator = '';
|
||||
if($this->filter)
|
||||
{
|
||||
$validator .= sprintf('${\'%s_argument\'}->checkFilter(\'%s\');' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->filter
|
||||
);
|
||||
}
|
||||
if($this->min_length)
|
||||
{
|
||||
$validator .= sprintf('${\'%s_argument\'}->checkMinLength(%s);' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->min_length
|
||||
);
|
||||
}
|
||||
if($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(); ';
|
||||
if($this->default_value->isOperation())
|
||||
{
|
||||
$validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->default_value->getOperation()
|
||||
);
|
||||
}
|
||||
$validator .= sprintf('${\'%s_argument\'}->ensureDefaultValue(%s);' . "\n"
|
||||
, $this->argument_name
|
||||
, $this->default_value->toString()
|
||||
);
|
||||
}
|
||||
if($this->notnull)
|
||||
{
|
||||
$validator .= sprintf('${\'%s_argument\'}->checkNotNull();' . "\n"
|
||||
, $this->argument_name
|
||||
);
|
||||
}
|
||||
return $validator;
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file QueryArgumentValidator.class.php */
|
||||
/* Location: ./classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue