mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-23 05:09:56 +09:00
Updates to Condition - refactored some methods to save calculated values in private properties, so that the parsing won't execute multiple times.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9064 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
385d704388
commit
ec0bad3f64
5 changed files with 114 additions and 97 deletions
|
|
@ -3,47 +3,45 @@
|
|||
class ConditionGroup {
|
||||
var $conditions;
|
||||
var $pipe;
|
||||
|
||||
|
||||
function ConditionGroup($conditions, $pipe = "") {
|
||||
$this->conditions = $conditions;
|
||||
$this->conditions = array();
|
||||
foreach($conditions as $condition){
|
||||
if($condition->show())
|
||||
$this->conditions[] = $condition;
|
||||
}
|
||||
$this->pipe = $pipe;
|
||||
}
|
||||
|
||||
|
||||
function setPipe($pipe){
|
||||
$this->pipe = $pipe;
|
||||
}
|
||||
|
||||
|
||||
function toString($with_value = true){
|
||||
if($this->pipe !== "")
|
||||
$group = $this->pipe .' (';
|
||||
else $group = '';
|
||||
|
||||
$cond_indx = 0;
|
||||
|
||||
$group = '';
|
||||
|
||||
foreach($this->conditions as $condition){
|
||||
if($condition->show()){
|
||||
if($cond_indx === 0) $condition->setPipe("");
|
||||
$group .= $condition->toString($with_value) . ' ';
|
||||
$cond_indx++;
|
||||
}
|
||||
if($cond_indx === 0) $condition->setPipe("");
|
||||
$group .= $condition->toString($with_value) . ' ';
|
||||
$cond_indx++;
|
||||
}
|
||||
// If the group has no conditions in it, return ''
|
||||
if($cond_indx === 0) return '';
|
||||
|
||||
if($this->pipe !== "")
|
||||
$group .= ')';
|
||||
|
||||
|
||||
if($this->pipe !== ""){
|
||||
$group = $this->pipe . ' (' . $group . ')';
|
||||
}
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
|
||||
function getArguments(){
|
||||
$args = array();
|
||||
foreach($this->conditions as $condition){
|
||||
if($condition->show()){
|
||||
$arg = $condition->getArgument();
|
||||
if($arg) $args[] = $arg;
|
||||
}
|
||||
}
|
||||
$arg = $condition->getArgument();
|
||||
if($arg) $args[] = $arg;
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue