XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
ConditionGroup.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
10 {
11 
17 
22  var $pipe;
23  var $_group;
24  var $_show;
25 
32  function __construct($conditions, $pipe = "")
33  {
34  $this->conditions = array();
35  foreach($conditions as $condition)
36  {
37  if($condition->show())
38  {
39  $this->conditions[] = $condition;
40  }
41  }
42  if(count($this->conditions) === 0)
43  {
44  $this->_show = false;
45  }
46  else
47  {
48  $this->_show = true;
49  }
50 
51  $this->pipe = $pipe;
52  }
53 
54  function show()
55  {
56  return $this->_show;
57  }
58 
59  function setPipe($pipe)
60  {
61  if($this->pipe !== $pipe)
62  {
63  $this->_group = null;
64  }
65  $this->pipe = $pipe;
66  }
67 
73  function toString($with_value = true)
74  {
75  if(!isset($this->_group))
76  {
77  $cond_indx = 0;
78  $group = '';
79 
80  foreach($this->conditions as $condition)
81  {
82  if($cond_indx === 0)
83  {
84  $condition->setPipe("");
85  }
86  $group .= $condition->toString($with_value) . ' ';
87  $cond_indx++;
88  }
89 
90  if($this->pipe !== "" && trim($group) !== '')
91  {
92  $group = $this->pipe . ' (' . $group . ')';
93  }
94 
95  $this->_group = $group;
96  }
97  return $this->_group;
98  }
99 
104  function getArguments()
105  {
106  $args = array();
107  foreach($this->conditions as $condition)
108  {
109  $arg = $condition->getArgument();
110  if($arg)
111  {
112  $args[] = $arg;
113  }
114  }
115  return $args;
116  }
117 
118 }
119 /* End of file ConditionGroup.class.php */
120 /* Location: ./classes/db/queryparts/condition/ConditionGroup.class.php */
toString($with_value=true)
$args
Definition: ko.install.php:185
__construct($conditions, $pipe="")