@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | public function getUserFromToken($token) |
32 | 32 | { |
33 | - if($token === false) |
|
33 | + if ($token === false) |
|
34 | 34 | { |
35 | 35 | $token = \FlipSession::getVar('OAuthToken'); |
36 | 36 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | |
26 | 26 | public function getUserFromToken($token) |
27 | 27 | { |
28 | - if($token === false) |
|
28 | + if ($token === false) |
|
29 | 29 | { |
30 | 30 | $token = \FlipSession::getVar('OAuthToken'); |
31 | 31 | } |
32 | 32 | $resp = \Httpful\Request::get('https://api.github.com/user')->addHeader('Authorization', 'token '.$token['access_token'])->send(); |
33 | 33 | $github_user = $resp->body; |
34 | 34 | $user = new \Auth\PendingUser(); |
35 | - if(isset($github_user->name)) |
|
35 | + if (isset($github_user->name)) |
|
36 | 36 | { |
37 | 37 | $name = explode(' ', $github_user->name); |
38 | 38 | $user->setGivenName($name[0]); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function login($username, $password) |
48 | 48 | { |
49 | 49 | $resp = \Httpful\Request::post('https://profiles.test.burningflipside.com/api/v1/login?username='.urlencode($username).'&password='.urlencode($password))->send(); |
50 | - if($resp->hasErrors()) |
|
50 | + if ($resp->hasErrors()) |
|
51 | 51 | { |
52 | 52 | return false; |
53 | 53 | } |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | |
59 | 59 | public function isLoggedIn($data) |
60 | 60 | { |
61 | - if(isset($this->user)) |
|
61 | + if (isset($this->user)) |
|
62 | 62 | { |
63 | 63 | return true; |
64 | 64 | } |
65 | - if(isset($data['res'])) |
|
65 | + if (isset($data['res'])) |
|
66 | 66 | { |
67 | 67 | return $data['res']; |
68 | 68 | } |
@@ -30,14 +30,14 @@ |
||
30 | 30 | |
31 | 31 | public function getUserFromToken($token) |
32 | 32 | { |
33 | - if($token === false) |
|
33 | + if ($token === false) |
|
34 | 34 | { |
35 | 35 | $token = \FlipSession::getVar('OAuthToken'); |
36 | 36 | } |
37 | 37 | $resp = \Httpful\Request::get('https://api.github.com/user')->addHeader('Authorization', 'token '.$token['access_token'])->send(); |
38 | 38 | $github_user = $resp->body; |
39 | 39 | $user = new \Auth\PendingUser(); |
40 | - if(isset($github_user->name)) |
|
40 | + if (isset($github_user->name)) |
|
41 | 41 | { |
42 | 42 | $name = explode(' ', $github_user->name); |
43 | 43 | $user->setGivenName($name[0]); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | public function isLoggedIn($data) |
12 | 12 | { |
13 | - if(isset($data['res'])) |
|
13 | + if (isset($data['res'])) |
|
14 | 14 | { |
15 | 15 | return $data['res']; |
16 | 16 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @SuppressWarnings("UnusedFormalParameter") |
104 | 104 | */ |
105 | - public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
105 | + public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
106 | 106 | { |
107 | 107 | return false; |
108 | 108 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @SuppressWarnings("UnusedFormalParameter") |
122 | 122 | */ |
123 | - public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
123 | + public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
124 | 124 | { |
125 | 125 | return false; |
126 | 126 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @SuppressWarnings("UnusedFormalParameter") |
140 | 140 | */ |
141 | - public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
141 | + public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
142 | 142 | { |
143 | 143 | return false; |
144 | 144 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function getActiveUserCount() |
152 | 152 | { |
153 | 153 | $users = $this->getUsersByFilter(false); |
154 | - if($users === false) |
|
154 | + if ($users === false) |
|
155 | 155 | { |
156 | 156 | return 0; |
157 | 157 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function getPendingUserCount() |
167 | 167 | { |
168 | 168 | $users = $this->getPendingUsersByFilter(false); |
169 | - if($users === false) |
|
169 | + if ($users === false) |
|
170 | 170 | { |
171 | 171 | return 0; |
172 | 172 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | public function getGroupCount() |
182 | 182 | { |
183 | 183 | $groups = $this->getGroupsByFilter(false); |
184 | - if($groups === false) |
|
184 | + if ($groups === false) |
|
185 | 185 | { |
186 | 186 | return 0; |
187 | 187 | } |
@@ -26,16 +26,16 @@ |
||
26 | 26 | { |
27 | 27 | $namespace = substr($classname, 0, $lastNsPos); |
28 | 28 | $classname = substr($classname, $lastNsPos + 1); |
29 | - $filename = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
|
29 | + $filename = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; |
|
30 | 30 | } |
31 | 31 | $filename = __DIR__.DIRECTORY_SEPARATOR.$filename.'class.'.$classname.'.php'; |
32 | - if(is_readable($filename)) |
|
32 | + if (is_readable($filename)) |
|
33 | 33 | { |
34 | 34 | require $filename; |
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -if(version_compare(PHP_VERSION, '5.3.0', '>=')) |
|
38 | +if (version_compare(PHP_VERSION, '5.3.0', '>=')) |
|
39 | 39 | { |
40 | 40 | spl_autoload_register('FlipsideAutoload', true, true); |
41 | 41 | } |
@@ -5,18 +5,18 @@ discard block |
||
5 | 5 | { |
6 | 6 | protected $data = null; |
7 | 7 | |
8 | - function count($filter=false) |
|
8 | + function count($filter = false) |
|
9 | 9 | { |
10 | 10 | throw new \Exception('Unimplemented'); |
11 | 11 | } |
12 | 12 | |
13 | - function search($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false) |
|
13 | + function search($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false) |
|
14 | 14 | { |
15 | - if($this->data === null) |
|
15 | + if ($this->data === null) |
|
16 | 16 | { |
17 | 17 | throw new \Exception('Unimplemented'); |
18 | 18 | } |
19 | - if($filter !== false) |
|
19 | + if ($filter !== false) |
|
20 | 20 | { |
21 | 21 | $array = $filter->filter_array($this->data); |
22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | throw new \Exception('Unimplemented'); |
29 | 29 | } |
30 | 30 | |
31 | - function read($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false) |
|
31 | + function read($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false) |
|
32 | 32 | { |
33 | 33 | return $this->search($filter, $select, $count, $skip, $sort, $params); |
34 | 34 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | function __construct($params) |
9 | 9 | { |
10 | - if(isset($params['user'])) |
|
10 | + if (isset($params['user'])) |
|
11 | 11 | { |
12 | 12 | $this->pdo = new \PDO($params['dsn'], $params['user'], $params['pass']); |
13 | 13 | } |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | function _get_row_count_for_query($sql) |
21 | 21 | { |
22 | 22 | $stmt = $this->pdo->query($sql); |
23 | - if($stmt === false) |
|
23 | + if ($stmt === false) |
|
24 | 24 | { |
25 | 25 | return 0; |
26 | 26 | } |
27 | 27 | $count = $stmt->rowCount(); |
28 | - if($count === 0) |
|
28 | + if ($count === 0) |
|
29 | 29 | { |
30 | 30 | $array = $stmt->fetchAll(); |
31 | 31 | $count = count($array); |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | |
36 | 36 | function _tableExistsNoPrefix($name) |
37 | 37 | { |
38 | - if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote($name)) > 0) |
|
38 | + if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote($name)) > 0) |
|
39 | 39 | { |
40 | 40 | return true; |
41 | 41 | } |
42 | - else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0) |
|
42 | + else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0) |
|
43 | 43 | { |
44 | 44 | return true; |
45 | 45 | } |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | |
49 | 49 | function _tableExists($name) |
50 | 50 | { |
51 | - if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
51 | + if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
52 | 52 | { |
53 | 53 | return true; |
54 | 54 | } |
55 | - else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
55 | + else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
56 | 56 | { |
57 | 57 | return true; |
58 | 58 | } |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | |
62 | 62 | function _viewExists($name) |
63 | 63 | { |
64 | - if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
64 | + if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
65 | 65 | { |
66 | 66 | return true; |
67 | 67 | } |
68 | - else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
68 | + else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
69 | 69 | { |
70 | 70 | return true; |
71 | 71 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | |
75 | 75 | function tableExists($name) |
76 | 76 | { |
77 | - if($this->_tableExists($name)) |
|
77 | + if ($this->_tableExists($name)) |
|
78 | 78 | { |
79 | 79 | return true; |
80 | 80 | } |
81 | - if($this->_tableExistsNoPrefix($name)) |
|
81 | + if ($this->_tableExistsNoPrefix($name)) |
|
82 | 82 | { |
83 | 83 | return true; |
84 | 84 | } |
85 | - if($this->_viewExists($name)) |
|
85 | + if ($this->_viewExists($name)) |
|
86 | 86 | { |
87 | 87 | return true; |
88 | 88 | } |
@@ -91,60 +91,60 @@ discard block |
||
91 | 91 | |
92 | 92 | function getTable($name) |
93 | 93 | { |
94 | - if($this->_tableExists($name)) |
|
94 | + if ($this->_tableExists($name)) |
|
95 | 95 | { |
96 | 96 | return new SQLDataTable($this, 'tbl'.$name); |
97 | 97 | } |
98 | - if($this->_viewExists($name)) |
|
98 | + if ($this->_viewExists($name)) |
|
99 | 99 | { |
100 | 100 | return new SQLDataTable($this, 'v'.$name); |
101 | 101 | } |
102 | - if($this->_tableExistsNoPrefix($name)) |
|
102 | + if ($this->_tableExistsNoPrefix($name)) |
|
103 | 103 | { |
104 | 104 | return new SQLDataTable($this, $name); |
105 | 105 | } |
106 | 106 | throw new \Exception('No such table '.$name); |
107 | 107 | } |
108 | 108 | |
109 | - function read($tablename, $where=false, $select='*', $count=false, $skip=false, $sort=false) |
|
109 | + function read($tablename, $where = false, $select = '*', $count = false, $skip = false, $sort = false) |
|
110 | 110 | { |
111 | - if($select === false) |
|
111 | + if ($select === false) |
|
112 | 112 | { |
113 | 113 | $select = '*'; |
114 | 114 | } |
115 | 115 | $sql = "SELECT $select FROM $tablename"; |
116 | - if($where !== false) |
|
116 | + if ($where !== false) |
|
117 | 117 | { |
118 | - $sql.=' WHERE '.$where; |
|
118 | + $sql .= ' WHERE '.$where; |
|
119 | 119 | } |
120 | - if($count !== false) |
|
120 | + if ($count !== false) |
|
121 | 121 | { |
122 | - if($skip === false) |
|
122 | + if ($skip === false) |
|
123 | 123 | { |
124 | - $sql.=' LIMIT '.(int)$count; |
|
124 | + $sql .= ' LIMIT '.(int)$count; |
|
125 | 125 | } |
126 | 126 | else |
127 | 127 | { |
128 | - $sql.=" LIMIT $skip, $count"; |
|
128 | + $sql .= " LIMIT $skip, $count"; |
|
129 | 129 | } |
130 | 130 | } |
131 | - if($sort !== false) |
|
131 | + if ($sort !== false) |
|
132 | 132 | { |
133 | - $sql.=' ORDER BY '; |
|
133 | + $sql .= ' ORDER BY '; |
|
134 | 134 | $tmp = array(); |
135 | - foreach($sort as $sort_col=>$dir) |
|
135 | + foreach ($sort as $sort_col=>$dir) |
|
136 | 136 | { |
137 | - array_push($tmp, $sort_col.' '.($dir === 1?'ASC':'DESC')); |
|
137 | + array_push($tmp, $sort_col.' '.($dir === 1 ? 'ASC' : 'DESC')); |
|
138 | 138 | } |
139 | - $sql.=implode($tmp,','); |
|
139 | + $sql .= implode($tmp, ','); |
|
140 | 140 | } |
141 | 141 | $stmt = $this->pdo->query($sql, \PDO::FETCH_ASSOC); |
142 | - if($stmt === false) |
|
142 | + if ($stmt === false) |
|
143 | 143 | { |
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | $ret = $stmt->fetchAll(); |
147 | - if($ret === false || empty($ret)) |
|
147 | + if ($ret === false || empty($ret)) |
|
148 | 148 | { |
149 | 149 | return false; |
150 | 150 | } |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | function update($tablename, $where, $data) |
155 | 155 | { |
156 | 156 | $set = array(); |
157 | - if(is_object($data)) |
|
157 | + if (is_object($data)) |
|
158 | 158 | { |
159 | 159 | $data = (array)$data; |
160 | 160 | } |
161 | 161 | $cols = array_keys($data); |
162 | 162 | $count = count($cols); |
163 | - for($i = 0; $i < $count; $i++) |
|
163 | + for ($i = 0; $i < $count; $i++) |
|
164 | 164 | { |
165 | 165 | array_push($set, $cols[$i].'='.$this->pdo->quote($data[$cols[$i]])); |
166 | 166 | } |
167 | 167 | $set = implode(',', $set); |
168 | 168 | $sql = "UPDATE $tablename SET $set WHERE $where"; |
169 | - if($this->pdo->exec($sql) === false) |
|
169 | + if ($this->pdo->exec($sql) === false) |
|
170 | 170 | { |
171 | 171 | return false; |
172 | 172 | } |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | function create($tablename, $data) |
177 | 177 | { |
178 | 178 | $set = array(); |
179 | - if(is_object($data)) |
|
179 | + if (is_object($data)) |
|
180 | 180 | { |
181 | 181 | $data = (array)$data; |
182 | 182 | } |
183 | 183 | $cols = array_keys($data); |
184 | 184 | $count = count($cols); |
185 | - for($i = 0; $i < $count; $i++) |
|
185 | + for ($i = 0; $i < $count; $i++) |
|
186 | 186 | { |
187 | 187 | array_push($set, $this->pdo->quote($data[$cols[$i]])); |
188 | 188 | } |
189 | 189 | $cols = implode(',', $cols); |
190 | 190 | $set = implode(',', $set); |
191 | 191 | $sql = "INSERT INTO $tablename ($cols) VALUES ($set);"; |
192 | - if($this->pdo->exec($sql) === false) |
|
192 | + if ($this->pdo->exec($sql) === false) |
|
193 | 193 | { |
194 | 194 | return false; |
195 | 195 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | function delete($tablename, $where) |
200 | 200 | { |
201 | 201 | $sql = "DELETE FROM $tablename WHERE $where"; |
202 | - if($this->pdo->exec($sql) === false) |
|
202 | + if ($this->pdo->exec($sql) === false) |
|
203 | 203 | { |
204 | 204 | return false; |
205 | 205 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | function raw_query($sql) |
210 | 210 | { |
211 | 211 | $stmt = $this->pdo->query($sql, \PDO::FETCH_ASSOC); |
212 | - if($stmt === false) |
|
212 | + if ($stmt === false) |
|
213 | 213 | { |
214 | 214 | return false; |
215 | 215 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | function __construct($string = false) |
11 | 11 | { |
12 | - if($string !== false) |
|
12 | + if ($string !== false) |
|
13 | 13 | { |
14 | 14 | $this->string = $string; |
15 | 15 | $this->children = self::process_string($this->string); |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | { |
21 | 21 | $parens = false; |
22 | 22 | //First check for parenthesis... |
23 | - if($string[0] === '(' && substr($string, -1) === ')') |
|
23 | + if ($string[0] === '(' && substr($string, -1) === ')') |
|
24 | 24 | { |
25 | - $string = substr($string, 1, strlen($string)-2); |
|
25 | + $string = substr($string, 1, strlen($string) - 2); |
|
26 | 26 | $parens = true; |
27 | 27 | } |
28 | - if(preg_match('/(.+?)( and | or )(.+)/', $string, $clauses) === 0) |
|
28 | + if (preg_match('/(.+?)( and | or )(.+)/', $string, $clauses) === 0) |
|
29 | 29 | { |
30 | 30 | return array(new FilterClause($string)); |
31 | 31 | } |
32 | 32 | $children = array(); |
33 | - if($parens) array_push($children, '('); |
|
33 | + if ($parens) array_push($children, '('); |
|
34 | 34 | $children = array_merge($children, self::process_string($clauses[1])); |
35 | 35 | array_push($children, trim($clauses[2])); |
36 | 36 | $children = array_merge($children, self::process_string($clauses[3])); |
37 | - if($parens) array_push($children, ')'); |
|
37 | + if ($parens) array_push($children, ')'); |
|
38 | 38 | return $children; |
39 | 39 | } |
40 | 40 | |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | { |
43 | 43 | $ret = ''; |
44 | 44 | $count = count($this->children); |
45 | - for($i = 0; $i < $count; $i++) |
|
45 | + for ($i = 0; $i < $count; $i++) |
|
46 | 46 | { |
47 | - if($this->children[$i] === '(' || $this->children[$i] === ')') |
|
47 | + if ($this->children[$i] === '(' || $this->children[$i] === ')') |
|
48 | 48 | { |
49 | - $ret.=$this->children[$i]; |
|
49 | + $ret .= $this->children[$i]; |
|
50 | 50 | } |
51 | - else if($this->children[$i] === 'and') |
|
51 | + else if ($this->children[$i] === 'and') |
|
52 | 52 | { |
53 | - $ret.=' AND '; |
|
53 | + $ret .= ' AND '; |
|
54 | 54 | } |
55 | - else if($this->children[$i] === 'or') |
|
55 | + else if ($this->children[$i] === 'or') |
|
56 | 56 | { |
57 | - $ret.=' OR '; |
|
57 | + $ret .= ' OR '; |
|
58 | 58 | } |
59 | 59 | else |
60 | 60 | { |
61 | - $ret.=$this->children[$i]->to_sql_string(); |
|
61 | + $ret .= $this->children[$i]->to_sql_string(); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | return $ret.$this->sqlAppend; |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | $ret = ''; |
70 | 70 | $count = count($this->children); |
71 | 71 | $prefix = ''; |
72 | - for($i = 0; $i < $count; $i++) |
|
72 | + for ($i = 0; $i < $count; $i++) |
|
73 | 73 | { |
74 | - if($this->children[$i] === 'and') |
|
74 | + if ($this->children[$i] === 'and') |
|
75 | 75 | { |
76 | - if($prefix == '|') |
|
76 | + if ($prefix == '|') |
|
77 | 77 | { |
78 | 78 | throw new \Exception('Do not support both and or'); |
79 | 79 | } |
80 | 80 | $prefix = '&'; |
81 | 81 | } |
82 | - else if($this->children[$i] === 'or') |
|
82 | + else if ($this->children[$i] === 'or') |
|
83 | 83 | { |
84 | - if($prefix == '&') |
|
84 | + if ($prefix == '&') |
|
85 | 85 | { |
86 | 86 | throw new \Exception('Do not support both and or'); |
87 | 87 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
92 | - $ret.=$this->children[$i]->to_ldap_string(); |
|
92 | + $ret .= $this->children[$i]->to_ldap_string(); |
|
93 | 93 | } |
94 | 94 | } |
95 | - if($count === 1 && $prefix === '') |
|
95 | + if ($count === 1 && $prefix === '') |
|
96 | 96 | { |
97 | 97 | return $ret; |
98 | 98 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | { |
104 | 104 | $ret = array(); |
105 | 105 | $count = count($this->children); |
106 | - for($i = 0; $i < $count; $i++) |
|
106 | + for ($i = 0; $i < $count; $i++) |
|
107 | 107 | { |
108 | - if($this->children[$i] === 'and') |
|
108 | + if ($this->children[$i] === 'and') |
|
109 | 109 | { |
110 | 110 | $old = array_pop($ret); |
111 | 111 | array_push($ret, array('$and'=>array($old, $this->children[++$i]->to_mongo_filter()))); |
112 | 112 | } |
113 | - else if($this->children[$i] === 'or') |
|
113 | + else if ($this->children[$i] === 'or') |
|
114 | 114 | { |
115 | 115 | $old = array_pop($ret); |
116 | 116 | array_push($ret, array('$or'=>array($old, $this->children[++$i]->to_mongo_filter()))); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | array_push($ret, $this->children[$i]->to_mongo_filter()); |
121 | 121 | } |
122 | 122 | } |
123 | - if(count($ret) == 1 && is_array($ret[0])) |
|
123 | + if (count($ret) == 1 && is_array($ret[0])) |
|
124 | 124 | { |
125 | 125 | //print_r(json_encode($ret[0])); die(); |
126 | 126 | return $ret[0]; |
@@ -131,27 +131,27 @@ discard block |
||
131 | 131 | function filter_array(&$array) |
132 | 132 | { |
133 | 133 | $res = array(); |
134 | - if(is_array($array)) |
|
134 | + if (is_array($array)) |
|
135 | 135 | { |
136 | 136 | $search = $array; |
137 | 137 | $count = count($this->children); |
138 | - for($i = 0; $i < $count; $i++) |
|
138 | + for ($i = 0; $i < $count; $i++) |
|
139 | 139 | { |
140 | - if($this->children[$i] === 'and') |
|
140 | + if ($this->children[$i] === 'and') |
|
141 | 141 | { |
142 | 142 | $search = $res; |
143 | 143 | } |
144 | - else if($this->children[$i] === 'or') |
|
144 | + else if ($this->children[$i] === 'or') |
|
145 | 145 | { |
146 | 146 | $search = $array; |
147 | 147 | } |
148 | 148 | else |
149 | 149 | { |
150 | - foreach($search as $subarray) |
|
150 | + foreach ($search as $subarray) |
|
151 | 151 | { |
152 | - if(isset($subarray[$this->children[$i]->var1])) |
|
152 | + if (isset($subarray[$this->children[$i]->var1])) |
|
153 | 153 | { |
154 | - if($this->children[$i]->php_compare($subarray[$this->children[$i]->var1])) |
|
154 | + if ($this->children[$i]->php_compare($subarray[$this->children[$i]->var1])) |
|
155 | 155 | { |
156 | 156 | array_push($res, $subarray); |
157 | 157 | } |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | public function getClause($substr) |
172 | 172 | { |
173 | 173 | $count = count($this->children); |
174 | - for($i = 0; $i < $count; $i++) |
|
174 | + for ($i = 0; $i < $count; $i++) |
|
175 | 175 | { |
176 | - if(!is_object($this->children[$i])) continue; |
|
177 | - if(strstr($this->children[$i]->var1, $substr) !== false || |
|
176 | + if (!is_object($this->children[$i])) continue; |
|
177 | + if (strstr($this->children[$i]->var1, $substr) !== false || |
|
178 | 178 | strstr($this->children[$i]->var2, $substr) !== false) |
179 | 179 | { |
180 | 180 | return $this->children[$i]; |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | |
185 | 185 | public function addToSQLString($string) |
186 | 186 | { |
187 | - $this->sqlAppend.=$string; |
|
187 | + $this->sqlAppend .= $string; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public function appendChild($child) |
191 | 191 | { |
192 | - if($child === 'and' || $child === 'or') |
|
192 | + if ($child === 'and' || $child === 'or') |
|
193 | 193 | { |
194 | 194 | array_push($this->children, $child); |
195 | 195 | return; |
196 | 196 | } |
197 | - else if(is_a($child, '\Data\Filter')) |
|
197 | + else if (is_a($child, '\Data\Filter')) |
|
198 | 198 | { |
199 | 199 | $this->children = array_merge($this->children, $child->children); |
200 | 200 | } |