@@ -383,7 +383,7 @@ |
||
383 | 383 | * @param Object $queryObject |
384 | 384 | * @param resource $connection |
385 | 385 | * @param boolean $with_values |
386 | - * @return Object |
|
386 | + * @return Object|null |
|
387 | 387 | */ |
388 | 388 | function _executeSelectAct($queryObject, $connection = null, $with_values = false) |
389 | 389 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | function DBMysqli($auto_connect = TRUE) |
24 | 24 | { |
25 | 25 | $this->_setDBInfo(); |
26 | - if($auto_connect) $this->_connect(); |
|
26 | + if ($auto_connect) $this->_connect(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | function __connect($connection) |
45 | 45 | { |
46 | 46 | // Attempt to connect |
47 | - if($connection["db_port"]) |
|
47 | + if ($connection["db_port"]) |
|
48 | 48 | { |
49 | 49 | $result = @mysqli_connect($connection["db_hostname"] |
50 | 50 | , $connection["db_userid"] |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | , $connection["db_database"]); |
61 | 61 | } |
62 | 62 | $error = mysqli_connect_errno(); |
63 | - if($error) |
|
63 | + if ($error) |
|
64 | 64 | { |
65 | 65 | $this->setError($error, mysqli_connect_error()); |
66 | 66 | return; |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function addQuotes($string) |
89 | 89 | { |
90 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
90 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
91 | 91 | { |
92 | 92 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
93 | 93 | } |
94 | - if(!is_numeric($string)) |
|
94 | + if (!is_numeric($string)) |
|
95 | 95 | { |
96 | 96 | $connection = $this->_getConnection('master'); |
97 | 97 | $string = mysqli_escape_string($connection, $string); |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function __query($query, $connection) |
110 | 110 | { |
111 | - if($this->use_prepared_statements == 'Y') |
|
111 | + if ($this->use_prepared_statements == 'Y') |
|
112 | 112 | { |
113 | 113 | // 1. Prepare query |
114 | 114 | $stmt = mysqli_prepare($connection, $query); |
115 | - if($stmt) |
|
115 | + if ($stmt) |
|
116 | 116 | { |
117 | 117 | $types = ''; |
118 | 118 | $params = array(); |
119 | 119 | $this->_prepareQueryParameters($types, $params); |
120 | 120 | |
121 | - if(!empty($params)) |
|
121 | + if (!empty($params)) |
|
122 | 122 | { |
123 | 123 | $args[0] = $stmt; |
124 | 124 | $args[1] = $types; |
125 | 125 | |
126 | 126 | $i = 2; |
127 | - foreach($params as $key => $param) |
|
127 | + foreach ($params as $key => $param) |
|
128 | 128 | { |
129 | 129 | $copy[$key] = $param; |
130 | 130 | $args[$i++] = &$copy[$key]; |
@@ -132,18 +132,18 @@ discard block |
||
132 | 132 | |
133 | 133 | // 2. Bind parameters |
134 | 134 | $status = call_user_func_array('mysqli_stmt_bind_param', $args); |
135 | - if(!$status) |
|
135 | + if (!$status) |
|
136 | 136 | { |
137 | - $this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
|
137 | + $this->setError(-1, "Invalid arguments: $query".mysqli_error($connection).PHP_EOL.print_r($args, true)); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | 141 | // 3. Execute query |
142 | 142 | $status = mysqli_stmt_execute($stmt); |
143 | 143 | |
144 | - if(!$status) |
|
144 | + if (!$status) |
|
145 | 145 | { |
146 | - $this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
|
146 | + $this->setError(-1, "Prepared statement failed: $query".mysqli_error($connection).PHP_EOL.print_r($args, true)); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Return stmt for other processing - like retrieving resultset (_fetch) |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $result = mysqli_query($connection, $query); |
156 | 156 | // Error Check |
157 | 157 | $error = mysqli_error($connection); |
158 | - if($error) |
|
158 | + if ($error) |
|
159 | 159 | { |
160 | 160 | $this->setError(mysqli_errno($connection), $error); |
161 | 161 | } |
@@ -174,23 +174,23 @@ discard block |
||
174 | 174 | { |
175 | 175 | $types = ''; |
176 | 176 | $params = array(); |
177 | - if(!$this->param) |
|
177 | + if (!$this->param) |
|
178 | 178 | { |
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - foreach($this->param as $k => $o) |
|
182 | + foreach ($this->param as $k => $o) |
|
183 | 183 | { |
184 | 184 | $value = $o->getUnescapedValue(); |
185 | 185 | $type = $o->getType(); |
186 | 186 | |
187 | 187 | // Skip column names -> this should be concatenated to query string |
188 | - if($o->isColumnName()) |
|
188 | + if ($o->isColumnName()) |
|
189 | 189 | { |
190 | 190 | continue; |
191 | 191 | } |
192 | 192 | |
193 | - switch($type) |
|
193 | + switch ($type) |
|
194 | 194 | { |
195 | 195 | case 'number' : |
196 | 196 | $type = 'i'; |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $type = 's'; |
203 | 203 | } |
204 | 204 | |
205 | - if(is_array($value)) |
|
205 | + if (is_array($value)) |
|
206 | 206 | { |
207 | - foreach($value as $v) |
|
207 | + foreach ($value as $v) |
|
208 | 208 | { |
209 | 209 | $params[] = $v; |
210 | 210 | $types .= $type; |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function _fetch($result, $arrayIndexEndValue = NULL) |
228 | 228 | { |
229 | - if($this->use_prepared_statements != 'Y') |
|
229 | + if ($this->use_prepared_statements != 'Y') |
|
230 | 230 | { |
231 | 231 | return parent::_fetch($result, $arrayIndexEndValue); |
232 | 232 | } |
233 | 233 | $output = array(); |
234 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
234 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
235 | 235 | { |
236 | 236 | return $output; |
237 | 237 | } |
@@ -247,25 +247,25 @@ discard block |
||
247 | 247 | * MYSQLI_TYPE for longtext is 252 |
248 | 248 | */ |
249 | 249 | $longtext_exists = false; |
250 | - foreach($fields as $field) |
|
250 | + foreach ($fields as $field) |
|
251 | 251 | { |
252 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
252 | + if (isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
253 | 253 | { |
254 | - $field->name = 'repeat_' . $field->name; |
|
254 | + $field->name = 'repeat_'.$field->name; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // Array passed needs to contain references, not values |
258 | 258 | $row[$field->name] = ""; |
259 | 259 | $resultArray[$field->name] = &$row[$field->name]; |
260 | 260 | |
261 | - if($field->type == 252) |
|
261 | + if ($field->type == 252) |
|
262 | 262 | { |
263 | 263 | $longtext_exists = true; |
264 | 264 | } |
265 | 265 | } |
266 | 266 | $resultArray = array_merge(array($stmt), $resultArray); |
267 | 267 | |
268 | - if($longtext_exists) |
|
268 | + if ($longtext_exists) |
|
269 | 269 | { |
270 | 270 | mysqli_stmt_store_result($stmt); |
271 | 271 | } |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | call_user_func_array('mysqli_stmt_bind_result', $resultArray); |
274 | 274 | |
275 | 275 | $rows = array(); |
276 | - while(mysqli_stmt_fetch($stmt)) |
|
276 | + while (mysqli_stmt_fetch($stmt)) |
|
277 | 277 | { |
278 | 278 | $resultObject = new stdClass(); |
279 | 279 | |
280 | - foreach($resultArray as $key => $value) |
|
280 | + foreach ($resultArray as $key => $value) |
|
281 | 281 | { |
282 | - if($key === 0) |
|
282 | + if ($key === 0) |
|
283 | 283 | { |
284 | 284 | continue; // Skip stmt object |
285 | 285 | } |
286 | - if(strpos($key, 'repeat_')) |
|
286 | + if (strpos($key, 'repeat_')) |
|
287 | 287 | { |
288 | 288 | $key = substr($key, 6); |
289 | 289 | } |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | |
296 | 296 | mysqli_stmt_close($stmt); |
297 | 297 | |
298 | - if($arrayIndexEndValue) |
|
298 | + if ($arrayIndexEndValue) |
|
299 | 299 | { |
300 | - foreach($rows as $row) |
|
300 | + foreach ($rows as $row) |
|
301 | 301 | { |
302 | 302 | $output[$arrayIndexEndValue--] = $row; |
303 | 303 | } |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | $output = $rows; |
308 | 308 | } |
309 | 309 | |
310 | - if(count($output) == 1) |
|
310 | + if (count($output) == 1) |
|
311 | 311 | { |
312 | - if(isset($arrayIndexEndValue)) |
|
312 | + if (isset($arrayIndexEndValue)) |
|
313 | 313 | { |
314 | 314 | return $output; |
315 | 315 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | function _executeInsertAct($queryObject, $with_values = false) |
332 | 332 | { |
333 | - if($this->use_prepared_statements != 'Y') |
|
333 | + if ($this->use_prepared_statements != 'Y') |
|
334 | 334 | { |
335 | 335 | return parent::_executeInsertAct($queryObject); |
336 | 336 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | */ |
349 | 349 | function _executeUpdateAct($queryObject, $with_values = false) |
350 | 350 | { |
351 | - if($this->use_prepared_statements != 'Y') |
|
351 | + if ($this->use_prepared_statements != 'Y') |
|
352 | 352 | { |
353 | 353 | return parent::_executeUpdateAct($queryObject); |
354 | 354 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function _executeDeleteAct($queryObject, $with_values = false) |
368 | 368 | { |
369 | - if($this->use_prepared_statements != 'Y') |
|
369 | + if ($this->use_prepared_statements != 'Y') |
|
370 | 370 | { |
371 | 371 | return parent::_executeDeleteAct($queryObject); |
372 | 372 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | function _executeSelectAct($queryObject, $connection = null, $with_values = false) |
389 | 389 | { |
390 | - if($this->use_prepared_statements != 'Y') |
|
390 | + if ($this->use_prepared_statements != 'Y') |
|
391 | 391 | { |
392 | 392 | return parent::_executeSelectAct($queryObject, $connection); |
393 | 393 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | function DBMysqli($auto_connect = TRUE) |
24 | 24 | { |
25 | 25 | $this->_setDBInfo(); |
26 | - if($auto_connect) $this->_connect(); |
|
26 | + if($auto_connect) { |
|
27 | + $this->_connect(); |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | /** |
@@ -51,8 +53,7 @@ discard block |
||
51 | 53 | , $connection["db_password"] |
52 | 54 | , $connection["db_database"] |
53 | 55 | , $connection["db_port"]); |
54 | - } |
|
55 | - else |
|
56 | + } else |
|
56 | 57 | { |
57 | 58 | $result = @mysqli_connect($connection["db_hostname"] |
58 | 59 | , $connection["db_userid"] |
@@ -209,8 +210,7 @@ discard block |
||
209 | 210 | $params[] = $v; |
210 | 211 | $types .= $type; |
211 | 212 | } |
212 | - } |
|
213 | - else |
|
213 | + } else |
|
214 | 214 | { |
215 | 215 | $params[] = $value; |
216 | 216 | $types .= $type; |
@@ -249,10 +249,12 @@ discard block |
||
249 | 249 | $longtext_exists = false; |
250 | 250 | foreach($fields as $field) |
251 | 251 | { |
252 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
252 | + if(isset($resultArray[$field->name])) { |
|
253 | + // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
253 | 254 | { |
254 | 255 | $field->name = 'repeat_' . $field->name; |
255 | 256 | } |
257 | + } |
|
256 | 258 | |
257 | 259 | // Array passed needs to contain references, not values |
258 | 260 | $row[$field->name] = ""; |
@@ -301,8 +303,7 @@ discard block |
||
301 | 303 | { |
302 | 304 | $output[$arrayIndexEndValue--] = $row; |
303 | 305 | } |
304 | - } |
|
305 | - else |
|
306 | + } else |
|
306 | 307 | { |
307 | 308 | $output = $rows; |
308 | 309 | } |
@@ -312,8 +313,7 @@ discard block |
||
312 | 313 | if(isset($arrayIndexEndValue)) |
313 | 314 | { |
314 | 315 | return $output; |
315 | - } |
|
316 | - else |
|
316 | + } else |
|
317 | 317 | { |
318 | 318 | return $output[0]; |
319 | 319 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Initilization |
44 | - * @return void |
|
44 | + * @return ModuleObject|null |
|
45 | 45 | */ |
46 | 46 | function init() |
47 | 47 | { |
@@ -566,7 +566,7 @@ |
||
566 | 566 | /** |
567 | 567 | * Retrun server environment to XML string |
568 | 568 | * @return object |
569 | - */ |
|
569 | + */ |
|
570 | 570 | function dispAdminViewServerEnv() |
571 | 571 | { |
572 | 572 | $info = array(); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | $db_info = Context::getDBInfo(); |
30 | 30 | |
31 | - if(strpos($db_info->default_url, 'xn--') !== FALSE) |
|
31 | + if (strpos($db_info->default_url, 'xn--') !== FALSE) |
|
32 | 32 | { |
33 | 33 | $xe_default_url = Context::decodeIdna($db_info->default_url); |
34 | 34 | } |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | // forbit access if the user is not an administrator |
49 | 49 | $oMemberModel = getModel('member'); |
50 | 50 | $logged_info = $oMemberModel->getLoggedInfo(); |
51 | - if($logged_info->is_admin != 'Y') |
|
51 | + if ($logged_info->is_admin != 'Y') |
|
52 | 52 | { |
53 | 53 | return $this->stop("msg_is_not_administrator"); |
54 | 54 | } |
55 | 55 | |
56 | 56 | // change into administration layout |
57 | - $this->setTemplatePath($this->module_path . 'tpl'); |
|
57 | + $this->setTemplatePath($this->module_path.'tpl'); |
|
58 | 58 | $this->setLayoutPath($this->getTemplatePath()); |
59 | 59 | $this->setLayoutFile('layout.html'); |
60 | 60 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | Context::set('use_db_session', $db_info->use_db_session == 'N' ? 'N' : 'Y'); |
75 | 75 | Context::set('use_mobile_view', $db_info->use_mobile_view == 'Y' ? 'Y' : 'N'); |
76 | 76 | Context::set('use_ssl', $db_info->use_ssl ? $db_info->use_ssl : "none"); |
77 | - if($db_info->http_port) |
|
77 | + if ($db_info->http_port) |
|
78 | 78 | { |
79 | 79 | Context::set('http_port', $db_info->http_port); |
80 | 80 | } |
81 | - if($db_info->https_port) |
|
81 | + if ($db_info->https_port) |
|
82 | 82 | { |
83 | 83 | Context::set('https_port', $db_info->https_port); |
84 | 84 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | function checkEasyinstall() |
95 | 95 | { |
96 | 96 | $lastTime = (int) FileHandler::readFile($this->easyinstallCheckFile); |
97 | - if($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30) |
|
97 | + if ($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30) |
|
98 | 98 | { |
99 | 99 | return; |
100 | 100 | } |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | $lUpdateDoc = $xml_lUpdate->parse($buff); |
109 | 109 | $updateDate = $lUpdateDoc->response->updatedate->body; |
110 | 110 | |
111 | - if(!$updateDate) |
|
111 | + if (!$updateDate) |
|
112 | 112 | { |
113 | 113 | $this->_markingCheckEasyinstall(); |
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $item = $oAutoinstallModel->getLatestPackage(); |
118 | - if(!$item || $item->updatedate < $updateDate) |
|
118 | + if (!$item || $item->updatedate < $updateDate) |
|
119 | 119 | { |
120 | 120 | $oController = getAdminController('autoinstall'); |
121 | 121 | $oController->_updateinfo(); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | // Check is_shortcut column |
146 | 146 | $oDB = DB::getInstance(); |
147 | - if(!$oDB->isColumnExists('menu_item', 'is_shortcut')) |
|
147 | + if (!$oDB->isColumnExists('menu_item', 'is_shortcut')) |
|
148 | 148 | { |
149 | 149 | return; |
150 | 150 | } |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | $currentAct = Context::get('act'); |
163 | 163 | $subMenuTitle = ''; |
164 | 164 | |
165 | - foreach((array) $moduleActionInfo->menu as $key => $value) |
|
165 | + foreach ((array) $moduleActionInfo->menu as $key => $value) |
|
166 | 166 | { |
167 | - if(isset($value->acts) && is_array($value->acts) && in_array($currentAct, $value->acts)) |
|
167 | + if (isset($value->acts) && is_array($value->acts) && in_array($currentAct, $value->acts)) |
|
168 | 168 | { |
169 | 169 | $subMenuTitle = $value->title; |
170 | 170 | break; |
@@ -173,21 +173,21 @@ discard block |
||
173 | 173 | // get current menu's srl(=parentSrl) |
174 | 174 | $parentSrl = 0; |
175 | 175 | $oMenuAdminConroller = getAdminController('menu'); |
176 | - foreach((array) $menu->list as $parentKey => $parentMenu) |
|
176 | + foreach ((array) $menu->list as $parentKey => $parentMenu) |
|
177 | 177 | { |
178 | - if(!is_array($parentMenu['list']) || !count($parentMenu['list'])) |
|
178 | + if (!is_array($parentMenu['list']) || !count($parentMenu['list'])) |
|
179 | 179 | { |
180 | 180 | continue; |
181 | 181 | } |
182 | - if($parentMenu['href'] == '#' && count($parentMenu['list'])) |
|
182 | + if ($parentMenu['href'] == '#' && count($parentMenu['list'])) |
|
183 | 183 | { |
184 | 184 | $firstChild = current($parentMenu['list']); |
185 | 185 | $menu->list[$parentKey]['href'] = $firstChild['href']; |
186 | 186 | } |
187 | 187 | |
188 | - foreach($parentMenu['list'] as $childKey => $childMenu) |
|
188 | + foreach ($parentMenu['list'] as $childKey => $childMenu) |
|
189 | 189 | { |
190 | - if($subMenuTitle == $childMenu['text'] && $parentSrl == 0) |
|
190 | + if ($subMenuTitle == $childMenu['text'] && $parentSrl == 0) |
|
191 | 191 | { |
192 | 192 | $parentSrl = $childMenu['parent_srl']; |
193 | 193 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $gnbTitleInfo->adminTitle = $objConfig->adminTitle ? $objConfig->adminTitle : 'XE Admin'; |
201 | 201 | $gnbTitleInfo->adminLogo = $objConfig->adminLogo ? $objConfig->adminLogo : 'modules/admin/tpl/img/xe.h1.png'; |
202 | 202 | |
203 | - $browserTitle = ($subMenuTitle ? $subMenuTitle : 'Dashboard') . ' - ' . $gnbTitleInfo->adminTitle; |
|
203 | + $browserTitle = ($subMenuTitle ? $subMenuTitle : 'Dashboard').' - '.$gnbTitleInfo->adminTitle; |
|
204 | 204 | |
205 | 205 | // Get list of favorite |
206 | 206 | $oAdminAdminModel = getAdminModel('admin'); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // move from index method, because use in admin footer |
212 | 212 | $newest_news_url = sprintf("http://news.xpressengine.com/%s/news.php?version=%s&package=%s", _XE_LOCATION_, __XE_VERSION__, _XE_PACKAGE_); |
213 | 213 | $cache_file = sprintf("%sfiles/cache/newest_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_); |
214 | - if(!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < $_SERVER['REQUEST_TIME']) |
|
214 | + if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < $_SERVER['REQUEST_TIME']) |
|
215 | 215 | { |
216 | 216 | // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing administration page |
217 | 217 | // Ensure to access the administration page even though news cannot be displayed |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl(''))); |
220 | 220 | } |
221 | 221 | |
222 | - if(file_exists($cache_file)) |
|
222 | + if (file_exists($cache_file)) |
|
223 | 223 | { |
224 | 224 | $oXml = new XmlParser(); |
225 | 225 | $buff = $oXml->parse(FileHandler::readFile($cache_file)); |
226 | 226 | |
227 | 227 | $item = $buff->zbxe_news->item; |
228 | - if($item) |
|
228 | + if ($item) |
|
229 | 229 | { |
230 | - if(!is_array($item)) |
|
230 | + if (!is_array($item)) |
|
231 | 231 | { |
232 | 232 | $item = array($item); |
233 | 233 | } |
234 | 234 | |
235 | - foreach($item as $key => $val) |
|
235 | + foreach ($item as $key => $val) |
|
236 | 236 | { |
237 | 237 | $obj = new stdClass(); |
238 | 238 | $obj->title = $val->body; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $news[] = $obj; |
242 | 242 | } |
243 | 243 | Context::set('news', $news); |
244 | - if(isset($news) && is_array($news)) |
|
244 | + if (isset($news) && is_array($news)) |
|
245 | 245 | { |
246 | 246 | Context::set('latestVersion', array_shift($news)); |
247 | 247 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | function dispAdminIndex() |
265 | 265 | { |
266 | 266 | $db_info = Context::getDBInfo(); |
267 | - Context::set('db_info',$db_info); |
|
267 | + Context::set('db_info', $db_info); |
|
268 | 268 | |
269 | 269 | // Get statistics |
270 | 270 | $args = new stdClass(); |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | $args = new stdClass(); |
302 | 302 | $args->list_count = 5; |
303 | 303 | $output = $oCommentModel->getNewestCommentList($args, $columnList); |
304 | - if(is_array($output)) |
|
304 | + if (is_array($output)) |
|
305 | 305 | { |
306 | - foreach($output AS $key => $value) |
|
306 | + foreach ($output AS $key => $value) |
|
307 | 307 | { |
308 | 308 | $value->content = strip_tags($value->content); |
309 | 309 | } |
@@ -314,17 +314,17 @@ discard block |
||
314 | 314 | // Get list of modules |
315 | 315 | $oModuleModel = getModel('module'); |
316 | 316 | $module_list = $oModuleModel->getModuleList(); |
317 | - if(is_array($module_list)) |
|
317 | + if (is_array($module_list)) |
|
318 | 318 | { |
319 | 319 | $needUpdate = FALSE; |
320 | 320 | $addTables = FALSE; |
321 | - foreach($module_list AS $key => $value) |
|
321 | + foreach ($module_list AS $key => $value) |
|
322 | 322 | { |
323 | - if($value->need_install) |
|
323 | + if ($value->need_install) |
|
324 | 324 | { |
325 | 325 | $addTables = TRUE; |
326 | 326 | } |
327 | - if($value->need_update) |
|
327 | + if ($value->need_update) |
|
328 | 328 | { |
329 | 329 | $needUpdate = TRUE; |
330 | 330 | } |
@@ -335,12 +335,12 @@ discard block |
||
335 | 335 | $oAutoinstallAdminModel = getAdminModel('autoinstall'); |
336 | 336 | $needUpdateList = $oAutoinstallAdminModel->getNeedUpdateList(); |
337 | 337 | |
338 | - if(is_array($needUpdateList)) |
|
338 | + if (is_array($needUpdateList)) |
|
339 | 339 | { |
340 | - foreach($needUpdateList AS $key => $value) |
|
340 | + foreach ($needUpdateList AS $key => $value) |
|
341 | 341 | { |
342 | 342 | $helpUrl = './admin/help/index.html#'; |
343 | - switch($value->type) |
|
343 | + switch ($value->type) |
|
344 | 344 | { |
345 | 345 | case 'addon': |
346 | 346 | $helpUrl .= 'UMAN_terminology_addon'; |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | |
368 | 368 | $site_module_info = Context::get('site_module_info'); |
369 | 369 | $oAddonAdminModel = getAdminModel('addon'); |
370 | - $counterAddonActivated = $oAddonAdminModel->isActivatedAddon('counter', $site_module_info->site_srl ); |
|
371 | - if(!$counterAddonActivated) |
|
370 | + $counterAddonActivated = $oAddonAdminModel->isActivatedAddon('counter', $site_module_info->site_srl); |
|
371 | + if (!$counterAddonActivated) |
|
372 | 372 | { |
373 | 373 | $columnList = array('member_srl', 'nick_name', 'user_name', 'user_id', 'email_address'); |
374 | 374 | $args = new stdClass; |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | |
392 | 392 | // gathering enviroment check |
393 | 393 | $mainVersion = join('.', array_slice(explode('.', __XE_VERSION__), 0, 2)); |
394 | - $path = FileHandler::getRealPath('./files/env/' . $mainVersion); |
|
394 | + $path = FileHandler::getRealPath('./files/env/'.$mainVersion); |
|
395 | 395 | $isEnviromentGatheringAgreement = FALSE; |
396 | - if(file_exists($path)) |
|
396 | + if (file_exists($path)) |
|
397 | 397 | { |
398 | 398 | $isEnviromentGatheringAgreement = TRUE; |
399 | 399 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $isLicenseAgreement = FALSE; |
404 | 404 | $path = FileHandler::getRealPath('./files/env/license_agreement'); |
405 | 405 | $isLicenseAgreement = FALSE; |
406 | - if(file_exists($path)) |
|
406 | + if (file_exists($path)) |
|
407 | 407 | { |
408 | 408 | $isLicenseAgreement = TRUE; |
409 | 409 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | |
426 | 426 | Context::set('selected_lang', $db_info->lang_type); |
427 | 427 | |
428 | - if(strpos($db_info->default_url, 'xn--') !== FALSE) |
|
428 | + if (strpos($db_info->default_url, 'xn--') !== FALSE) |
|
429 | 429 | { |
430 | 430 | $db_info->default_url = Context::decodeIdna($db_info->default_url); |
431 | 431 | } |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | |
435 | 435 | // site lock |
436 | 436 | Context::set('IP', $_SERVER['REMOTE_ADDR']); |
437 | - if(!$db_info->sitelock_title) $db_info->sitelock_title = 'Maintenance in progress...'; |
|
438 | - if(!in_array('127.0.0.1', $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = '127.0.0.1'; |
|
439 | - if(!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR']; |
|
437 | + if (!$db_info->sitelock_title) $db_info->sitelock_title = 'Maintenance in progress...'; |
|
438 | + if (!in_array('127.0.0.1', $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = '127.0.0.1'; |
|
439 | + if (!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR']; |
|
440 | 440 | $db_info->sitelock_whitelist = array_unique($db_info->sitelock_whitelist); |
441 | 441 | Context::set('remote_addr', $_SERVER['REMOTE_ADDR']); |
442 | 442 | Context::set('use_sitelock', $db_info->use_sitelock); |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | Context::set('sitelock_whitelist', $whitelist); |
448 | 448 | |
449 | 449 | |
450 | - if($db_info->admin_ip_list) $admin_ip_list = implode("\r\n", $db_info->admin_ip_list); |
|
450 | + if ($db_info->admin_ip_list) $admin_ip_list = implode("\r\n", $db_info->admin_ip_list); |
|
451 | 451 | else $admin_ip_list = ''; |
452 | 452 | Context::set('admin_ip_list', $admin_ip_list); |
453 | 453 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | Context::set('htmlFooter', htmlspecialchars($config->htmlFooter)); |
471 | 471 | |
472 | 472 | // embed filter |
473 | - require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php'); |
|
473 | + require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php'); |
|
474 | 474 | $oEmbedFilter = EmbedFilter::getInstance(); |
475 | 475 | context::set('embed_white_object', implode(PHP_EOL, $oEmbedFilter->whiteUrlList)); |
476 | 476 | context::set('embed_white_iframe', implode(PHP_EOL, $oEmbedFilter->whiteIframeUrlList)); |
@@ -529,36 +529,36 @@ discard block |
||
529 | 529 | */ |
530 | 530 | function showSendEnv() |
531 | 531 | { |
532 | - if(Context::getResponseMethod() != 'HTML') |
|
532 | + if (Context::getResponseMethod() != 'HTML') |
|
533 | 533 | { |
534 | 534 | return; |
535 | 535 | } |
536 | 536 | |
537 | 537 | $server = 'http://collect.xpressengine.com/env/img.php?'; |
538 | 538 | $path = './files/env/'; |
539 | - $install_env = $path . 'install'; |
|
539 | + $install_env = $path.'install'; |
|
540 | 540 | $mainVersion = join('.', array_slice(explode('.', __XE_VERSION__), 0, 2)); |
541 | 541 | |
542 | - if(file_exists(FileHandler::getRealPath($install_env))) |
|
542 | + if (file_exists(FileHandler::getRealPath($install_env))) |
|
543 | 543 | { |
544 | 544 | $oAdminAdminModel = getAdminModel('admin'); |
545 | 545 | $params = $oAdminAdminModel->getEnv('INSTALL'); |
546 | - $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params); |
|
546 | + $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server.$params); |
|
547 | 547 | Context::addHtmlFooter($img); |
548 | 548 | |
549 | - FileHandler::writeFile($path . $mainVersion, '1'); |
|
549 | + FileHandler::writeFile($path.$mainVersion, '1'); |
|
550 | 550 | } |
551 | - else if(isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion))) |
|
551 | + else if (isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path.$mainVersion))) |
|
552 | 552 | { |
553 | - if($_SESSION['enviroment_gather'] == 'Y') |
|
553 | + if ($_SESSION['enviroment_gather'] == 'Y') |
|
554 | 554 | { |
555 | 555 | $oAdminAdminModel = getAdminModel('admin'); |
556 | 556 | $params = $oAdminAdminModel->getEnv(); |
557 | - $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params); |
|
557 | + $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server.$params); |
|
558 | 558 | Context::addHtmlFooter($img); |
559 | 559 | } |
560 | 560 | |
561 | - FileHandler::writeFile($path . $mainVersion, '1'); |
|
561 | + FileHandler::writeFile($path.$mainVersion, '1'); |
|
562 | 562 | unset($_SESSION['enviroment_gather']); |
563 | 563 | } |
564 | 564 | } |
@@ -576,64 +576,64 @@ discard block |
||
576 | 576 | $tmp = explode("&", $envInfo); |
577 | 577 | $arrInfo = array(); |
578 | 578 | $xe_check_env = array(); |
579 | - foreach($tmp as $value) { |
|
579 | + foreach ($tmp as $value) { |
|
580 | 580 | $arr = explode("=", $value); |
581 | - if($arr[0]=="type") { |
|
581 | + if ($arr[0] == "type") { |
|
582 | 582 | continue; |
583 | - }elseif($arr[0]=="phpext" ) { |
|
583 | + }elseif ($arr[0] == "phpext") { |
|
584 | 584 | $str = urldecode($arr[1]); |
585 | - $xe_check_env[$arr[0]]= str_replace("|", ", ", $str); |
|
586 | - } elseif($arr[0]=="module" ) { |
|
585 | + $xe_check_env[$arr[0]] = str_replace("|", ", ", $str); |
|
586 | + } elseif ($arr[0] == "module") { |
|
587 | 587 | $str = urldecode($arr[1]); |
588 | 588 | $arrModuleName = explode("|", $str); |
589 | 589 | $oModuleModel = getModel("module"); |
590 | 590 | $mInfo = array(); |
591 | - foreach($arrModuleName as $moduleName) { |
|
591 | + foreach ($arrModuleName as $moduleName) { |
|
592 | 592 | $moduleInfo = $oModuleModel->getModuleInfoXml($moduleName); |
593 | 593 | $mInfo[] = "{$moduleName}({$moduleInfo->version})"; |
594 | 594 | } |
595 | - $xe_check_env[$arr[0]]= join(", ", $mInfo); |
|
596 | - } elseif($arr[0]=="addon") { |
|
595 | + $xe_check_env[$arr[0]] = join(", ", $mInfo); |
|
596 | + } elseif ($arr[0] == "addon") { |
|
597 | 597 | $str = urldecode($arr[1]); |
598 | 598 | $arrAddonName = explode("|", $str); |
599 | 599 | $oAddonModel = getAdminModel("addon"); |
600 | 600 | $mInfo = array(); |
601 | - foreach($arrAddonName as $addonName) { |
|
601 | + foreach ($arrAddonName as $addonName) { |
|
602 | 602 | $addonInfo = $oAddonModel->getAddonInfoXml($addonName); |
603 | 603 | $mInfo[] = "{$addonName}({$addonInfo->version})"; |
604 | 604 | } |
605 | - $xe_check_env[$arr[0]]= join(", ", $mInfo); |
|
606 | - } elseif($arr[0]=="widget") { |
|
605 | + $xe_check_env[$arr[0]] = join(", ", $mInfo); |
|
606 | + } elseif ($arr[0] == "widget") { |
|
607 | 607 | $str = urldecode($arr[1]); |
608 | 608 | $arrWidgetName = explode("|", $str); |
609 | 609 | $oWidgetModel = getModel("widget"); |
610 | 610 | $mInfo = array(); |
611 | - foreach($arrWidgetName as $widgetName) { |
|
611 | + foreach ($arrWidgetName as $widgetName) { |
|
612 | 612 | $widgetInfo = $oWidgetModel->getWidgetInfo($widgetName); |
613 | 613 | $mInfo[] = "{$widgetName}({$widgetInfo->version})"; |
614 | 614 | } |
615 | - $xe_check_env[$arr[0]]= join(", ", $mInfo); |
|
616 | - } elseif($arr[0]=="widgetstyle") { |
|
615 | + $xe_check_env[$arr[0]] = join(", ", $mInfo); |
|
616 | + } elseif ($arr[0] == "widgetstyle") { |
|
617 | 617 | $str = urldecode($arr[1]); |
618 | 618 | $arrWidgetstyleName = explode("|", $str); |
619 | 619 | $oWidgetModel = getModel("widget"); |
620 | 620 | $mInfo = array(); |
621 | - foreach($arrWidgetstyleName as $widgetstyleName) { |
|
621 | + foreach ($arrWidgetstyleName as $widgetstyleName) { |
|
622 | 622 | $widgetstyleInfo = $oWidgetModel->getWidgetStyleInfo($widgetstyleName); |
623 | 623 | $mInfo[] = "{$widgetstyleName}({$widgetstyleInfo->version})"; |
624 | 624 | } |
625 | - $xe_check_env[$arr[0]]= join(", ", $mInfo); |
|
625 | + $xe_check_env[$arr[0]] = join(", ", $mInfo); |
|
626 | 626 | |
627 | - } elseif($arr[0]=="layout") { |
|
627 | + } elseif ($arr[0] == "layout") { |
|
628 | 628 | $str = urldecode($arr[1]); |
629 | 629 | $arrLayoutName = explode("|", $str); |
630 | 630 | $oLayoutModel = getModel("layout"); |
631 | 631 | $mInfo = array(); |
632 | - foreach($arrLayoutName as $layoutName) { |
|
632 | + foreach ($arrLayoutName as $layoutName) { |
|
633 | 633 | $layoutInfo = $oLayoutModel->getLayoutInfo($layoutName); |
634 | 634 | $mInfo[] = "{$layoutName}({$layoutInfo->version})"; |
635 | 635 | } |
636 | - $xe_check_env[$arr[0]]= join(", ", $mInfo); |
|
636 | + $xe_check_env[$arr[0]] = join(", ", $mInfo); |
|
637 | 637 | } else { |
638 | 638 | $xe_check_env[$arr[0]] = urldecode($arr[1]); |
639 | 639 | } |
@@ -647,15 +647,15 @@ discard block |
||
647 | 647 | $php_core['memory_limit'] = "{$ini_info['memory_limit']['local_value']}"; |
648 | 648 | $info['PHP_Core'] = $php_core; |
649 | 649 | |
650 | - $str_info = "[XE Server Environment " . date("Y-m-d") . "]\n\n"; |
|
650 | + $str_info = "[XE Server Environment ".date("Y-m-d")."]\n\n"; |
|
651 | 651 | $str_info .= "realpath : ".realpath('./')."\n"; |
652 | - foreach( $info as $key=>$value ) |
|
652 | + foreach ($info as $key=>$value) |
|
653 | 653 | { |
654 | - if( is_array( $value ) == false ) { |
|
654 | + if (is_array($value) == false) { |
|
655 | 655 | $str_info .= "{$key} : {$value}\n"; |
656 | 656 | } else { |
657 | 657 | //$str_info .= "\n{$key} \n"; |
658 | - foreach( $value as $key2=>$value2 ) |
|
658 | + foreach ($value as $key2=>$value2) |
|
659 | 659 | $str_info .= "{$key2} : {$value2}\n"; |
660 | 660 | } |
661 | 661 | } |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | Context::set('use_rewrite', $useRewrite); |
673 | 673 | |
674 | 674 | // nginx 체크, rewrite 사용법 안내 |
675 | - if($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) Context::set('use_nginx', 'Y'); |
|
675 | + if ($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) Context::set('use_nginx', 'Y'); |
|
676 | 676 | |
677 | 677 | Context::set('useable', $oInstallController->checkInstallEnv()); |
678 | 678 | $this->setTemplateFile('check_env.html'); |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | if(strpos($db_info->default_url, 'xn--') !== FALSE) |
32 | 32 | { |
33 | 33 | $xe_default_url = Context::decodeIdna($db_info->default_url); |
34 | - } |
|
35 | - else |
|
34 | + } else |
|
36 | 35 | { |
37 | 36 | $xe_default_url = $db_info->default_url; |
38 | 37 | } |
@@ -434,9 +433,15 @@ discard block |
||
434 | 433 | |
435 | 434 | // site lock |
436 | 435 | Context::set('IP', $_SERVER['REMOTE_ADDR']); |
437 | - if(!$db_info->sitelock_title) $db_info->sitelock_title = 'Maintenance in progress...'; |
|
438 | - if(!in_array('127.0.0.1', $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = '127.0.0.1'; |
|
439 | - if(!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR']; |
|
436 | + if(!$db_info->sitelock_title) { |
|
437 | + $db_info->sitelock_title = 'Maintenance in progress...'; |
|
438 | + } |
|
439 | + if(!in_array('127.0.0.1', $db_info->sitelock_whitelist)) { |
|
440 | + $db_info->sitelock_whitelist[] = '127.0.0.1'; |
|
441 | + } |
|
442 | + if(!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) { |
|
443 | + $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR']; |
|
444 | + } |
|
440 | 445 | $db_info->sitelock_whitelist = array_unique($db_info->sitelock_whitelist); |
441 | 446 | Context::set('remote_addr', $_SERVER['REMOTE_ADDR']); |
442 | 447 | Context::set('use_sitelock', $db_info->use_sitelock); |
@@ -447,8 +452,11 @@ discard block |
||
447 | 452 | Context::set('sitelock_whitelist', $whitelist); |
448 | 453 | |
449 | 454 | |
450 | - if($db_info->admin_ip_list) $admin_ip_list = implode("\r\n", $db_info->admin_ip_list); |
|
451 | - else $admin_ip_list = ''; |
|
455 | + if($db_info->admin_ip_list) { |
|
456 | + $admin_ip_list = implode("\r\n", $db_info->admin_ip_list); |
|
457 | + } else { |
|
458 | + $admin_ip_list = ''; |
|
459 | + } |
|
452 | 460 | Context::set('admin_ip_list', $admin_ip_list); |
453 | 461 | |
454 | 462 | Context::set('lang_selected', Context::loadLangSelected()); |
@@ -547,8 +555,7 @@ discard block |
||
547 | 555 | Context::addHtmlFooter($img); |
548 | 556 | |
549 | 557 | FileHandler::writeFile($path . $mainVersion, '1'); |
550 | - } |
|
551 | - else if(isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion))) |
|
558 | + } else if(isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion))) |
|
552 | 559 | { |
553 | 560 | if($_SESSION['enviroment_gather'] == 'Y') |
554 | 561 | { |
@@ -580,7 +587,7 @@ discard block |
||
580 | 587 | $arr = explode("=", $value); |
581 | 588 | if($arr[0]=="type") { |
582 | 589 | continue; |
583 | - }elseif($arr[0]=="phpext" ) { |
|
590 | + } elseif($arr[0]=="phpext" ) { |
|
584 | 591 | $str = urldecode($arr[1]); |
585 | 592 | $xe_check_env[$arr[0]]= str_replace("|", ", ", $str); |
586 | 593 | } elseif($arr[0]=="module" ) { |
@@ -655,8 +662,9 @@ discard block |
||
655 | 662 | $str_info .= "{$key} : {$value}\n"; |
656 | 663 | } else { |
657 | 664 | //$str_info .= "\n{$key} \n"; |
658 | - foreach( $value as $key2=>$value2 ) |
|
659 | - $str_info .= "{$key2} : {$value2}\n"; |
|
665 | + foreach( $value as $key2=>$value2 ) { |
|
666 | + $str_info .= "{$key2} : {$value2}\n"; |
|
667 | + } |
|
660 | 668 | } |
661 | 669 | } |
662 | 670 | |
@@ -672,7 +680,9 @@ discard block |
||
672 | 680 | Context::set('use_rewrite', $useRewrite); |
673 | 681 | |
674 | 682 | // nginx 체크, rewrite 사용법 안내 |
675 | - if($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) Context::set('use_nginx', 'Y'); |
|
683 | + if($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) { |
|
684 | + Context::set('use_nginx', 'Y'); |
|
685 | + } |
|
676 | 686 | |
677 | 687 | Context::set('useable', $oInstallController->checkInstallEnv()); |
678 | 688 | $this->setTemplateFile('check_env.html'); |
@@ -470,7 +470,7 @@ |
||
470 | 470 | * set query debug log |
471 | 471 | * @param array $log values set query debug |
472 | 472 | * @return void |
473 | - */ |
|
473 | + */ |
|
474 | 474 | function setQueryLog($log) |
475 | 475 | { |
476 | 476 | $GLOBALS['__db_queries__'][] = $log; |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | */ |
142 | 142 | function getInstance($db_type = NULL) |
143 | 143 | { |
144 | - if(!$db_type) |
|
144 | + if (!$db_type) |
|
145 | 145 | { |
146 | 146 | $db_type = Context::getDBType(); |
147 | 147 | } |
148 | - if(!$db_type && Context::isInstalled()) |
|
148 | + if (!$db_type && Context::isInstalled()) |
|
149 | 149 | { |
150 | 150 | return new Object(-1, 'msg_db_not_setted'); |
151 | 151 | } |
152 | 152 | |
153 | - if(!isset($GLOBALS['__DB__'])) |
|
153 | + if (!isset($GLOBALS['__DB__'])) |
|
154 | 154 | { |
155 | 155 | $GLOBALS['__DB__'] = array(); |
156 | 156 | } |
157 | - if(!isset($GLOBALS['__DB__'][$db_type])) |
|
157 | + if (!isset($GLOBALS['__DB__'][$db_type])) |
|
158 | 158 | { |
159 | - $class_name = 'DB' . ucfirst($db_type); |
|
160 | - $class_file = _XE_PATH_ . "classes/db/$class_name.class.php"; |
|
161 | - if(!file_exists($class_file)) |
|
159 | + $class_name = 'DB'.ucfirst($db_type); |
|
160 | + $class_file = _XE_PATH_."classes/db/$class_name.class.php"; |
|
161 | + if (!file_exists($class_file)) |
|
162 | 162 | { |
163 | 163 | return new Object(-1, 'msg_db_not_setted'); |
164 | 164 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function DB() |
189 | 189 | { |
190 | - $this->count_cache_path = _XE_PATH_ . $this->count_cache_path; |
|
191 | - $this->cache_file = _XE_PATH_ . $this->cache_file; |
|
190 | + $this->count_cache_path = _XE_PATH_.$this->count_cache_path; |
|
191 | + $this->cache_file = _XE_PATH_.$this->cache_file; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -210,18 +210,18 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public static function getEnableList() |
212 | 212 | { |
213 | - if(!self::$supported_list) |
|
213 | + if (!self::$supported_list) |
|
214 | 214 | { |
215 | 215 | $oDB = new DB(); |
216 | 216 | self::$supported_list = $oDB->_getSupportedList(); |
217 | 217 | } |
218 | 218 | |
219 | 219 | $enableList = array(); |
220 | - if(is_array(self::$supported_list)) |
|
220 | + if (is_array(self::$supported_list)) |
|
221 | 221 | { |
222 | - foreach(self::$supported_list AS $key => $value) |
|
222 | + foreach (self::$supported_list AS $key => $value) |
|
223 | 223 | { |
224 | - if($value->enable) |
|
224 | + if ($value->enable) |
|
225 | 225 | { |
226 | 226 | $enableList[] = $value; |
227 | 227 | } |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public static function getDisableList() |
239 | 239 | { |
240 | - if(!self::$supported_list) |
|
240 | + if (!self::$supported_list) |
|
241 | 241 | { |
242 | 242 | $oDB = new DB(); |
243 | 243 | self::$supported_list = $oDB->_getSupportedList(); |
244 | 244 | } |
245 | 245 | |
246 | 246 | $disableList = array(); |
247 | - if(is_array(self::$supported_list)) |
|
247 | + if (is_array(self::$supported_list)) |
|
248 | 248 | { |
249 | - foreach(self::$supported_list AS $key => $value) |
|
249 | + foreach (self::$supported_list AS $key => $value) |
|
250 | 250 | { |
251 | - if(!$value->enable) |
|
251 | + if (!$value->enable) |
|
252 | 252 | { |
253 | 253 | $disableList[] = $value; |
254 | 254 | } |
@@ -265,24 +265,24 @@ discard block |
||
265 | 265 | function _getSupportedList() |
266 | 266 | { |
267 | 267 | static $get_supported_list = ''; |
268 | - if(is_array($get_supported_list)) |
|
268 | + if (is_array($get_supported_list)) |
|
269 | 269 | { |
270 | 270 | self::$supported_list = $get_supported_list; |
271 | 271 | return self::$supported_list; |
272 | 272 | } |
273 | 273 | $get_supported_list = array(); |
274 | - $db_classes_path = _XE_PATH_ . "classes/db/"; |
|
274 | + $db_classes_path = _XE_PATH_."classes/db/"; |
|
275 | 275 | $filter = "/^DB([^\.]+)\.class\.php/i"; |
276 | 276 | $supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE); |
277 | 277 | |
278 | 278 | // after creating instance of class, check is supported |
279 | - for($i = 0; $i < count($supported_list); $i++) |
|
279 | + for ($i = 0; $i < count($supported_list); $i++) |
|
280 | 280 | { |
281 | 281 | $db_type = $supported_list[$i]; |
282 | 282 | |
283 | 283 | $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); |
284 | - $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name); |
|
285 | - if(!file_exists($class_file)) |
|
284 | + $class_file = sprintf(_XE_PATH_."classes/db/%s.class.php", $class_name); |
|
285 | + if (!file_exists($class_file)) |
|
286 | 286 | { |
287 | 287 | continue; |
288 | 288 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | require_once($class_file); |
292 | 292 | $oDB = new $class_name(FALSE); |
293 | 293 | |
294 | - if(!$oDB) |
|
294 | + if (!$oDB) |
|
295 | 295 | { |
296 | 296 | continue; |
297 | 297 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | function _sortDBMS($a, $b) |
317 | 317 | { |
318 | - if(!isset($this->priority_dbms[$a->db_type])) |
|
318 | + if (!isset($this->priority_dbms[$a->db_type])) |
|
319 | 319 | { |
320 | 320 | $priority_a = 0; |
321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $priority_a = $this->priority_dbms[$a->db_type]; |
325 | 325 | } |
326 | 326 | |
327 | - if(!isset($this->priority_dbms[$b->db_type])) |
|
327 | + if (!isset($this->priority_dbms[$b->db_type])) |
|
328 | 328 | { |
329 | 329 | $priority_b = 0; |
330 | 330 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $priority_b = $this->priority_dbms[$b->db_type]; |
334 | 334 | } |
335 | 335 | |
336 | - if($priority_a == $priority_b) |
|
336 | + if ($priority_a == $priority_b) |
|
337 | 337 | { |
338 | 338 | return 0; |
339 | 339 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | */ |
360 | 360 | function isConnected($type = 'master', $indx = 0) |
361 | 361 | { |
362 | - if($type == 'master') |
|
362 | + if ($type == 'master') |
|
363 | 363 | { |
364 | 364 | return $this->master_db["is_connected"] ? TRUE : FALSE; |
365 | 365 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function actFinish() |
390 | 390 | { |
391 | - if(!$this->query) |
|
391 | + if (!$this->query) |
|
392 | 392 | { |
393 | 393 | return; |
394 | 394 | } |
@@ -409,14 +409,14 @@ discard block |
||
409 | 409 | |
410 | 410 | $bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace(); |
411 | 411 | |
412 | - foreach($bt as $no => $call) |
|
412 | + foreach ($bt as $no => $call) |
|
413 | 413 | { |
414 | - if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
414 | + if ($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
415 | 415 | { |
416 | 416 | $call_no = $no; |
417 | 417 | $call_no++; |
418 | 418 | $log['called_file'] = $bt[$call_no]['file'].':'.$bt[$call_no]['line']; |
419 | - $log['called_file'] = str_replace(_XE_PATH_ , '', $log['called_file']); |
|
419 | + $log['called_file'] = str_replace(_XE_PATH_, '', $log['called_file']); |
|
420 | 420 | $call_no++; |
421 | 421 | $log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function']; |
422 | 422 | break; |
@@ -424,22 +424,22 @@ discard block |
||
424 | 424 | } |
425 | 425 | |
426 | 426 | // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined) |
427 | - if($this->isError()) |
|
427 | + if ($this->isError()) |
|
428 | 428 | { |
429 | 429 | $log['result'] = 'Failed'; |
430 | 430 | $log['errno'] = $this->errno; |
431 | 431 | $log['errstr'] = $this->errstr; |
432 | 432 | |
433 | - if(__DEBUG_DB_OUTPUT__ == 1) |
|
433 | + if (__DEBUG_DB_OUTPUT__ == 1) |
|
434 | 434 | { |
435 | - $debug_file = _XE_PATH_ . "files/_debug_db_query.php"; |
|
435 | + $debug_file = _XE_PATH_."files/_debug_db_query.php"; |
|
436 | 436 | $buff = array(); |
437 | - if(!file_exists($debug_file)) |
|
437 | + if (!file_exists($debug_file)) |
|
438 | 438 | { |
439 | - $buff[] = '<?php exit(); ?' . '>'; |
|
439 | + $buff[] = '<?php exit(); ?'.'>'; |
|
440 | 440 | } |
441 | 441 | $buff[] = print_r($log, TRUE); |
442 | - @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); |
|
442 | + @file_put_contents($log_file, implode("\n", $buff)."\n\n", FILE_APPEND | LOCK_EX); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | else |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | $log_args = new stdClass; |
453 | 453 | $log_args->query = $this->query; |
454 | 454 | $log_args->query_id = $this->query_id; |
455 | - $log_args->caller = $log['called_method'] . '() in ' . $log['called_file']; |
|
455 | + $log_args->caller = $log['called_method'].'() in '.$log['called_file']; |
|
456 | 456 | $log_args->connection = $log['connection']; |
457 | 457 | writeSlowlog('query', $elapsed_time, $log_args); |
458 | 458 | } |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | { |
511 | 511 | static $cache_file = array(); |
512 | 512 | |
513 | - if(!$query_id) |
|
513 | + if (!$query_id) |
|
514 | 514 | { |
515 | 515 | return new Object(-1, 'msg_invalid_queryid'); |
516 | 516 | } |
517 | - if(!$this->db_type) |
|
517 | + if (!$this->db_type) |
|
518 | 518 | { |
519 | 519 | return; |
520 | 520 | } |
@@ -523,20 +523,20 @@ discard block |
||
523 | 523 | |
524 | 524 | $this->query_id = $query_id; |
525 | 525 | |
526 | - if(!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
526 | + if (!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
527 | 527 | { |
528 | 528 | $id_args = explode('.', $query_id); |
529 | - if(count($id_args) == 2) |
|
529 | + if (count($id_args) == 2) |
|
530 | 530 | { |
531 | 531 | $target = 'modules'; |
532 | 532 | $module = $id_args[0]; |
533 | 533 | $id = $id_args[1]; |
534 | 534 | } |
535 | - elseif(count($id_args) == 3) |
|
535 | + elseif (count($id_args) == 3) |
|
536 | 536 | { |
537 | 537 | $target = $id_args[0]; |
538 | 538 | $typeList = array('addons' => 1, 'widgets' => 1); |
539 | - if(!isset($typeList[$target])) |
|
539 | + if (!isset($typeList[$target])) |
|
540 | 540 | { |
541 | 541 | $this->actDBClassFinish(); |
542 | 542 | return; |
@@ -544,14 +544,14 @@ discard block |
||
544 | 544 | $module = $id_args[1]; |
545 | 545 | $id = $id_args[2]; |
546 | 546 | } |
547 | - if(!$target || !$module || !$id) |
|
547 | + if (!$target || !$module || !$id) |
|
548 | 548 | { |
549 | 549 | $this->actDBClassFinish(); |
550 | 550 | return new Object(-1, 'msg_invalid_queryid'); |
551 | 551 | } |
552 | 552 | |
553 | 553 | $xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id); |
554 | - if(!file_exists($xml_file)) |
|
554 | + if (!file_exists($xml_file)) |
|
555 | 555 | { |
556 | 556 | $this->actDBClassFinish(); |
557 | 557 | return new Object(-1, 'msg_invalid_queryid'); |
@@ -579,13 +579,13 @@ discard block |
||
579 | 579 | $cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type); |
580 | 580 | |
581 | 581 | $cache_time = -1; |
582 | - if(file_exists($cache_file)) |
|
582 | + if (file_exists($cache_file)) |
|
583 | 583 | { |
584 | 584 | $cache_time = filemtime($cache_file); |
585 | 585 | } |
586 | 586 | |
587 | 587 | // if there is no cache file or is not new, find original xml query file and parse it |
588 | - if($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_ . 'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_ . 'classes/xml/XmlQueryParser.class.php')) |
|
588 | + if ($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_.'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_.'classes/xml/XmlQueryParser.class.php')) |
|
589 | 589 | { |
590 | 590 | $oParser = new XmlQueryParser(); |
591 | 591 | $oParser->parse($query_id, $xml_file, $cache_file); |
@@ -606,27 +606,27 @@ discard block |
||
606 | 606 | { |
607 | 607 | global $lang; |
608 | 608 | |
609 | - if(!in_array($type, array('master','slave'))) $type = 'slave'; |
|
609 | + if (!in_array($type, array('master', 'slave'))) $type = 'slave'; |
|
610 | 610 | |
611 | - if(!file_exists($cache_file)) |
|
611 | + if (!file_exists($cache_file)) |
|
612 | 612 | { |
613 | 613 | return new Object(-1, 'msg_invalid_queryid'); |
614 | 614 | } |
615 | 615 | |
616 | - if($source_args) |
|
616 | + if ($source_args) |
|
617 | 617 | { |
618 | 618 | $args = clone $source_args; |
619 | 619 | } |
620 | 620 | |
621 | 621 | $output = include($cache_file); |
622 | 622 | |
623 | - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) |
|
623 | + if ((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) |
|
624 | 624 | { |
625 | 625 | return $output; |
626 | 626 | } |
627 | 627 | |
628 | 628 | // execute appropriate query |
629 | - switch($output->getAction()) |
|
629 | + switch ($output->getAction()) |
|
630 | 630 | { |
631 | 631 | case 'insert' : |
632 | 632 | case 'insert-select' : |
@@ -649,11 +649,11 @@ discard block |
||
649 | 649 | break; |
650 | 650 | } |
651 | 651 | |
652 | - if($this->isError()) |
|
652 | + if ($this->isError()) |
|
653 | 653 | { |
654 | 654 | $output = $this->getError(); |
655 | 655 | } |
656 | - else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
656 | + else if (!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) |
|
657 | 657 | { |
658 | 658 | $output = new Object(); |
659 | 659 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | */ |
800 | 800 | function dropTable($table_name) |
801 | 801 | { |
802 | - if(!$table_name) |
|
802 | + if (!$table_name) |
|
803 | 803 | { |
804 | 804 | return; |
805 | 805 | } |
@@ -816,59 +816,59 @@ discard block |
||
816 | 816 | function getSelectSql($query, $with_values = TRUE) |
817 | 817 | { |
818 | 818 | $select = $query->getSelectString($with_values); |
819 | - if($select == '') |
|
819 | + if ($select == '') |
|
820 | 820 | { |
821 | 821 | return new Object(-1, "Invalid query"); |
822 | 822 | } |
823 | - $select = 'SELECT ' . $select; |
|
823 | + $select = 'SELECT '.$select; |
|
824 | 824 | |
825 | 825 | $from = $query->getFromString($with_values); |
826 | - if($from == '') |
|
826 | + if ($from == '') |
|
827 | 827 | { |
828 | 828 | return new Object(-1, "Invalid query"); |
829 | 829 | } |
830 | - $from = ' FROM ' . $from; |
|
830 | + $from = ' FROM '.$from; |
|
831 | 831 | |
832 | 832 | $where = $query->getWhereString($with_values); |
833 | - if($where != '') |
|
833 | + if ($where != '') |
|
834 | 834 | { |
835 | - $where = ' WHERE ' . $where; |
|
835 | + $where = ' WHERE '.$where; |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | $tableObjects = $query->getTables(); |
839 | 839 | $index_hint_list = ''; |
840 | - foreach($tableObjects as $tableObject) |
|
840 | + foreach ($tableObjects as $tableObject) |
|
841 | 841 | { |
842 | - if(is_a($tableObject, 'CubridTableWithHint')) |
|
842 | + if (is_a($tableObject, 'CubridTableWithHint')) |
|
843 | 843 | { |
844 | - $index_hint_list .= $tableObject->getIndexHintString() . ', '; |
|
844 | + $index_hint_list .= $tableObject->getIndexHintString().', '; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | $index_hint_list = substr($index_hint_list, 0, -2); |
848 | - if($index_hint_list != '') |
|
848 | + if ($index_hint_list != '') |
|
849 | 849 | { |
850 | - $index_hint_list = 'USING INDEX ' . $index_hint_list; |
|
850 | + $index_hint_list = 'USING INDEX '.$index_hint_list; |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | $groupBy = $query->getGroupByString(); |
854 | - if($groupBy != '') |
|
854 | + if ($groupBy != '') |
|
855 | 855 | { |
856 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
856 | + $groupBy = ' GROUP BY '.$groupBy; |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | $orderBy = $query->getOrderByString(); |
860 | - if($orderBy != '') |
|
860 | + if ($orderBy != '') |
|
861 | 861 | { |
862 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
862 | + $orderBy = ' ORDER BY '.$orderBy; |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | $limit = $query->getLimitString(); |
866 | - if($limit != '') |
|
866 | + if ($limit != '') |
|
867 | 867 | { |
868 | - $limit = ' LIMIT ' . $limit; |
|
868 | + $limit = ' LIMIT '.$limit; |
|
869 | 869 | } |
870 | 870 | |
871 | - return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
871 | + return $select.' '.$from.' '.$where.' '.$index_hint_list.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | /** |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | { |
887 | 887 | $new_update_columns = array(); |
888 | 888 | $click_count_columns = $queryObject->getClickCountColumns(); |
889 | - foreach($click_count_columns as $click_count_column) |
|
889 | + foreach ($click_count_columns as $click_count_column) |
|
890 | 890 | { |
891 | 891 | $click_count_column_name = $click_count_column->column_name; |
892 | 892 | |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $sql .= $tables[0]->getAlias(); |
919 | 919 | |
920 | 920 | $from = $query->getFromString($with_values); |
921 | - if($from == '') |
|
921 | + if ($from == '') |
|
922 | 922 | { |
923 | 923 | return new Object(-1, "Invalid query"); |
924 | 924 | } |
925 | - $sql .= ' FROM ' . $from; |
|
925 | + $sql .= ' FROM '.$from; |
|
926 | 926 | |
927 | 927 | $where = $query->getWhereString($with_values); |
928 | - if($where != '') |
|
928 | + if ($where != '') |
|
929 | 929 | { |
930 | - $sql .= ' WHERE ' . $where; |
|
930 | + $sql .= ' WHERE '.$where; |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | return $sql; |
@@ -943,26 +943,26 @@ discard block |
||
943 | 943 | function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE) |
944 | 944 | { |
945 | 945 | $columnsList = $query->getUpdateString($with_values); |
946 | - if($columnsList == '') |
|
946 | + if ($columnsList == '') |
|
947 | 947 | { |
948 | 948 | return new Object(-1, "Invalid query"); |
949 | 949 | } |
950 | 950 | |
951 | 951 | $tables = $query->getFromString($with_values); |
952 | - if($tables == '') |
|
952 | + if ($tables == '') |
|
953 | 953 | { |
954 | 954 | return new Object(-1, "Invalid query"); |
955 | 955 | } |
956 | 956 | |
957 | 957 | $where = $query->getWhereString($with_values); |
958 | - if($where != '') |
|
958 | + if ($where != '') |
|
959 | 959 | { |
960 | - $where = ' WHERE ' . $where; |
|
960 | + $where = ' WHERE '.$where; |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | $priority = $with_priority ? $query->getPriority() : ''; |
964 | 964 | |
965 | - return "UPDATE $priority $tables SET $columnsList " . $where; |
|
965 | + return "UPDATE $priority $tables SET $columnsList ".$where; |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -1000,27 +1000,27 @@ discard block |
||
1000 | 1000 | */ |
1001 | 1001 | function _getConnection($type = 'master', $indx = NULL) |
1002 | 1002 | { |
1003 | - if($type == 'master') |
|
1003 | + if ($type == 'master') |
|
1004 | 1004 | { |
1005 | - if(!$this->master_db['is_connected']) |
|
1005 | + if (!$this->master_db['is_connected']) |
|
1006 | 1006 | { |
1007 | 1007 | $this->_connect($type); |
1008 | 1008 | } |
1009 | - $this->connection = 'Master ' . $this->master_db['db_hostname']; |
|
1009 | + $this->connection = 'Master '.$this->master_db['db_hostname']; |
|
1010 | 1010 | return $this->master_db["resource"]; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - if($indx === NULL) |
|
1013 | + if ($indx === NULL) |
|
1014 | 1014 | { |
1015 | 1015 | $indx = $this->_getSlaveConnectionStringIndex($type); |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - if(!$this->slave_db[$indx]['is_connected']) |
|
1018 | + if (!$this->slave_db[$indx]['is_connected']) |
|
1019 | 1019 | { |
1020 | 1020 | $this->_connect($type, $indx); |
1021 | 1021 | } |
1022 | 1022 | |
1023 | - $this->connection = 'Slave ' . $this->slave_db[$indx]['db_hostname']; |
|
1023 | + $this->connection = 'Slave '.$this->slave_db[$indx]['db_hostname']; |
|
1024 | 1024 | return $this->slave_db[$indx]["resource"]; |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1030,11 +1030,11 @@ discard block |
||
1030 | 1030 | */ |
1031 | 1031 | function _dbInfoExists() |
1032 | 1032 | { |
1033 | - if(!$this->master_db) |
|
1033 | + if (!$this->master_db) |
|
1034 | 1034 | { |
1035 | 1035 | return FALSE; |
1036 | 1036 | } |
1037 | - if(count($this->slave_db) === 0) |
|
1037 | + if (count($this->slave_db) === 0) |
|
1038 | 1038 | { |
1039 | 1039 | return FALSE; |
1040 | 1040 | } |
@@ -1060,12 +1060,12 @@ discard block |
||
1060 | 1060 | */ |
1061 | 1061 | function close($type = 'master', $indx = 0) |
1062 | 1062 | { |
1063 | - if(!$this->isConnected($type, $indx)) |
|
1063 | + if (!$this->isConnected($type, $indx)) |
|
1064 | 1064 | { |
1065 | 1065 | return; |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - if($type == 'master') |
|
1068 | + if ($type == 'master') |
|
1069 | 1069 | { |
1070 | 1070 | $connection = &$this->master_db; |
1071 | 1071 | } |
@@ -1096,12 +1096,12 @@ discard block |
||
1096 | 1096 | */ |
1097 | 1097 | function begin() |
1098 | 1098 | { |
1099 | - if(!$this->isConnected()) |
|
1099 | + if (!$this->isConnected()) |
|
1100 | 1100 | { |
1101 | 1101 | return; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if($this->_begin($this->transactionNestedLevel)) |
|
1104 | + if ($this->_begin($this->transactionNestedLevel)) |
|
1105 | 1105 | { |
1106 | 1106 | $this->transaction_started = TRUE; |
1107 | 1107 | $this->transactionNestedLevel++; |
@@ -1124,15 +1124,15 @@ discard block |
||
1124 | 1124 | */ |
1125 | 1125 | function rollback() |
1126 | 1126 | { |
1127 | - if(!$this->isConnected() || !$this->transaction_started) |
|
1127 | + if (!$this->isConnected() || !$this->transaction_started) |
|
1128 | 1128 | { |
1129 | 1129 | return; |
1130 | 1130 | } |
1131 | - if($this->_rollback($this->transactionNestedLevel)) |
|
1131 | + if ($this->_rollback($this->transactionNestedLevel)) |
|
1132 | 1132 | { |
1133 | 1133 | $this->transactionNestedLevel--; |
1134 | 1134 | |
1135 | - if(!$this->transactionNestedLevel) |
|
1135 | + if (!$this->transactionNestedLevel) |
|
1136 | 1136 | { |
1137 | 1137 | $this->transaction_started = FALSE; |
1138 | 1138 | } |
@@ -1156,11 +1156,11 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | function commit($force = FALSE) |
1158 | 1158 | { |
1159 | - if(!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
1159 | + if (!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
1160 | 1160 | { |
1161 | 1161 | return; |
1162 | 1162 | } |
1163 | - if($this->transactionNestedLevel == 1 && $this->_commit()) |
|
1163 | + if ($this->transactionNestedLevel == 1 && $this->_commit()) |
|
1164 | 1164 | { |
1165 | 1165 | $this->transaction_started = FALSE; |
1166 | 1166 | $this->transactionNestedLevel = 0; |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | */ |
1193 | 1193 | function _query($query, $connection = NULL) |
1194 | 1194 | { |
1195 | - if($connection == NULL) |
|
1195 | + if ($connection == NULL) |
|
1196 | 1196 | { |
1197 | 1197 | $connection = $this->_getConnection('master'); |
1198 | 1198 | } |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | { |
1218 | 1218 | $db_info = Context::getDBInfo(); |
1219 | 1219 | $this->master_db = $db_info->master_db; |
1220 | - if($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
1220 | + if ($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
1221 | 1221 | && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"] |
1222 | 1222 | && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"] |
1223 | 1223 | && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"] |
@@ -1265,18 +1265,18 @@ discard block |
||
1265 | 1265 | */ |
1266 | 1266 | function _connect($type = 'master', $indx = 0) |
1267 | 1267 | { |
1268 | - if($this->isConnected($type, $indx)) |
|
1268 | + if ($this->isConnected($type, $indx)) |
|
1269 | 1269 | { |
1270 | 1270 | return; |
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | // Ignore if no DB information exists |
1274 | - if(!$this->_dbInfoExists()) |
|
1274 | + if (!$this->_dbInfoExists()) |
|
1275 | 1275 | { |
1276 | 1276 | return; |
1277 | 1277 | } |
1278 | 1278 | |
1279 | - if($type == 'master') |
|
1279 | + if ($type == 'master') |
|
1280 | 1280 | { |
1281 | 1281 | $connection = &$this->master_db; |
1282 | 1282 | } |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | $result = $this->__connect($connection); |
1289 | - if($result === NULL || $result === FALSE) |
|
1289 | + if ($result === NULL || $result === FALSE) |
|
1290 | 1290 | { |
1291 | 1291 | $connection["is_connected"] = FALSE; |
1292 | 1292 | return; |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | $connection["is_connected"] = TRUE; |
1298 | 1298 | |
1299 | 1299 | // Save connection info for db logs |
1300 | - $this->connection = ucfirst($type) . ' ' . $connection["db_hostname"]; |
|
1300 | + $this->connection = ucfirst($type).' '.$connection["db_hostname"]; |
|
1301 | 1301 | |
1302 | 1302 | // regist $this->close callback |
1303 | 1303 | register_shutdown_function(array($this, "close")); |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | */ |
1323 | 1323 | function actDBClassFinish() |
1324 | 1324 | { |
1325 | - if(!$this->query) |
|
1325 | + if (!$this->query) |
|
1326 | 1326 | { |
1327 | 1327 | return; |
1328 | 1328 | } |
@@ -1345,7 +1345,7 @@ discard block |
||
1345 | 1345 | function getParser($force = FALSE) |
1346 | 1346 | { |
1347 | 1347 | static $dbParser = NULL; |
1348 | - if(!$dbParser || $force) |
|
1348 | + if (!$dbParser || $force) |
|
1349 | 1349 | { |
1350 | 1350 | $oDB = DB::getInstance(); |
1351 | 1351 | $dbParser = $oDB->getParser(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | function DBCubrid($auto_connect = TRUE) |
53 | 53 | { |
54 | 54 | $this->_setDBInfo(); |
55 | - if($auto_connect) $this->_connect(); |
|
55 | + if ($auto_connect) $this->_connect(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | $result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]); |
77 | 77 | |
78 | 78 | // check connections |
79 | - if(!$result) |
|
79 | + if (!$result) |
|
80 | 80 | { |
81 | 81 | $this->setError(-1, 'database connect fail'); |
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - if(!defined('__CUBRID_VERSION__')) |
|
85 | + if (!defined('__CUBRID_VERSION__')) |
|
86 | 86 | { |
87 | 87 | $cubrid_version = cubrid_get_server_info($result); |
88 | 88 | $cubrid_version_elem = explode('.', $cubrid_version); |
89 | - $cubrid_version = $cubrid_version_elem[0] . '.' . $cubrid_version_elem[1] . '.' . $cubrid_version_elem[2]; |
|
89 | + $cubrid_version = $cubrid_version_elem[0].'.'.$cubrid_version_elem[1].'.'.$cubrid_version_elem[2]; |
|
90 | 90 | define('__CUBRID_VERSION__', $cubrid_version); |
91 | 91 | } |
92 | 92 | |
93 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
93 | + if (__CUBRID_VERSION__ >= '8.4.0') |
|
94 | 94 | cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
95 | 95 | |
96 | 96 | return $result; |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function addQuotes($string) |
118 | 118 | { |
119 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && |
|
119 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && |
|
120 | 120 | get_magic_quotes_gpc()) |
121 | 121 | { |
122 | 122 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
123 | 123 | } |
124 | 124 | |
125 | - if(!is_numeric($string)) |
|
125 | + if (!is_numeric($string)) |
|
126 | 126 | { |
127 | 127 | /* |
128 | 128 | if ($this->isConnected()) { |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | */ |
147 | 147 | function _begin($transactionLevel = 0) |
148 | 148 | { |
149 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
149 | + if (__CUBRID_VERSION__ >= '8.4.0') |
|
150 | 150 | { |
151 | 151 | $connection = $this->_getConnection('master'); |
152 | 152 | |
153 | - if(!$transactionLevel) |
|
153 | + if (!$transactionLevel) |
|
154 | 154 | { |
155 | 155 | cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE); |
156 | 156 | } |
157 | 157 | else |
158 | 158 | { |
159 | - $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
|
159 | + $this->_query("SAVEPOINT SP".$transactionLevel, $connection); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | return TRUE; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | |
174 | 174 | $point = $transactionLevel - 1; |
175 | 175 | |
176 | - if($point) |
|
176 | + if ($point) |
|
177 | 177 | { |
178 | - $this->_query("ROLLBACK TO SP" . $point, $connection); |
|
178 | + $this->_query("ROLLBACK TO SP".$point, $connection); |
|
179 | 179 | } |
180 | 180 | else |
181 | 181 | { |
@@ -206,29 +206,29 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function __query($query, $connection) |
208 | 208 | { |
209 | - if($this->use_prepared_statements == 'Y') |
|
209 | + if ($this->use_prepared_statements == 'Y') |
|
210 | 210 | { |
211 | 211 | $req = @cubrid_prepare($connection, $query); |
212 | - if(!$req) |
|
212 | + if (!$req) |
|
213 | 213 | { |
214 | 214 | $this->_setError(); |
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | 218 | $position = 0; |
219 | - if($this->param) |
|
219 | + if ($this->param) |
|
220 | 220 | { |
221 | - foreach($this->param as $param) |
|
221 | + foreach ($this->param as $param) |
|
222 | 222 | { |
223 | 223 | $value = $param->getUnescapedValue(); |
224 | 224 | $type = $param->getType(); |
225 | 225 | |
226 | - if($param->isColumnName()) |
|
226 | + if ($param->isColumnName()) |
|
227 | 227 | { |
228 | 228 | continue; |
229 | 229 | } |
230 | 230 | |
231 | - switch($type) |
|
231 | + switch ($type) |
|
232 | 232 | { |
233 | 233 | case 'number' : |
234 | 234 | $bind_type = 'numeric'; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | $bind_type = 'string'; |
241 | 241 | } |
242 | 242 | |
243 | - if(is_array($value)) |
|
243 | + if (is_array($value)) |
|
244 | 244 | { |
245 | - foreach($value as $v) |
|
245 | + foreach ($value as $v) |
|
246 | 246 | { |
247 | 247 | $bound = @cubrid_bind($req, ++$position, $v, $bind_type); |
248 | - if(!$bound) |
|
248 | + if (!$bound) |
|
249 | 249 | { |
250 | 250 | $this->_setError(); |
251 | 251 | return false; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | else |
256 | 256 | { |
257 | 257 | $bound = @cubrid_bind($req, ++$position, $value, $bind_type); |
258 | - if(!$bound) |
|
258 | + if (!$bound) |
|
259 | 259 | { |
260 | 260 | $this->_setError(); |
261 | 261 | return false; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | $result = @cubrid_execute($req); |
268 | - if(!$result) |
|
268 | + if (!$result) |
|
269 | 269 | { |
270 | 270 | $this->_setError(); |
271 | 271 | return false; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | // Execute the query |
276 | 276 | $result = @cubrid_execute($connection, $query); |
277 | 277 | // error check |
278 | - if(!$result) |
|
278 | + if (!$result) |
|
279 | 279 | { |
280 | 280 | $this->_setError(); |
281 | 281 | return false; |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | function _fetch($result, $arrayIndexEndValue = NULL) |
307 | 307 | { |
308 | 308 | $output = array(); |
309 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
309 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
310 | 310 | { |
311 | 311 | return array(); |
312 | 312 | } |
313 | 313 | |
314 | - if($this->use_prepared_statements == 'Y') |
|
314 | + if ($this->use_prepared_statements == 'Y') |
|
315 | 315 | { |
316 | 316 | |
317 | 317 | } |
@@ -322,25 +322,25 @@ discard block |
||
322 | 322 | $col_names = cubrid_column_names($result); |
323 | 323 | $max = count($col_types); |
324 | 324 | |
325 | - for($count = 0; $count < $max; $count++) |
|
325 | + for ($count = 0; $count < $max; $count++) |
|
326 | 326 | { |
327 | - if(preg_match("/^char/", $col_types[$count]) > 0) |
|
327 | + if (preg_match("/^char/", $col_types[$count]) > 0) |
|
328 | 328 | { |
329 | 329 | $char_type_fields[] = $col_names[$count]; |
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | - while($tmp = cubrid_fetch($result, CUBRID_OBJECT)) |
|
333 | + while ($tmp = cubrid_fetch($result, CUBRID_OBJECT)) |
|
334 | 334 | { |
335 | - if(is_array($char_type_fields)) |
|
335 | + if (is_array($char_type_fields)) |
|
336 | 336 | { |
337 | - foreach($char_type_fields as $val) |
|
337 | + foreach ($char_type_fields as $val) |
|
338 | 338 | { |
339 | 339 | $tmp->{$val} = rtrim($tmp->{$val}); |
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - if($arrayIndexEndValue) |
|
343 | + if ($arrayIndexEndValue) |
|
344 | 344 | { |
345 | 345 | $output[$arrayIndexEndValue--] = $tmp; |
346 | 346 | } |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | |
353 | 353 | unset($char_type_fields); |
354 | 354 | |
355 | - if($result) |
|
355 | + if ($result) |
|
356 | 356 | { |
357 | 357 | cubrid_close_request($result); |
358 | 358 | } |
359 | 359 | |
360 | - if(count($output) == 1) |
|
360 | + if (count($output) == 1) |
|
361 | 361 | { |
362 | 362 | // If call is made for pagination, always return array |
363 | - if(isset($arrayIndexEndValue)) |
|
363 | + if (isset($arrayIndexEndValue)) |
|
364 | 364 | { |
365 | 365 | return $output; |
366 | 366 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | */ |
396 | 396 | function _makeSequence() |
397 | 397 | { |
398 | - if($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
398 | + if ($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
399 | 399 | return; |
400 | 400 | |
401 | 401 | // check cubrid serial |
@@ -404,21 +404,21 @@ discard block |
||
404 | 404 | $output = $this->_fetch($result); |
405 | 405 | |
406 | 406 | // if do not create serial |
407 | - if($output->count == 0) |
|
408 | - { |
|
409 | - $query = sprintf('select max("a"."srl") as "srl" from ' . |
|
410 | - '( select max("document_srl") as "srl" from ' . |
|
411 | - '"%sdocuments" UNION ' . |
|
412 | - 'select max("comment_srl") as "srl" from ' . |
|
413 | - '"%scomments" UNION ' . |
|
414 | - 'select max("member_srl") as "srl" from ' . |
|
415 | - '"%smember"' . |
|
407 | + if ($output->count == 0) |
|
408 | + { |
|
409 | + $query = sprintf('select max("a"."srl") as "srl" from '. |
|
410 | + '( select max("document_srl") as "srl" from '. |
|
411 | + '"%sdocuments" UNION '. |
|
412 | + 'select max("comment_srl") as "srl" from '. |
|
413 | + '"%scomments" UNION '. |
|
414 | + 'select max("member_srl") as "srl" from '. |
|
415 | + '"%smember"'. |
|
416 | 416 | ') as "a"', $this->prefix, $this->prefix, $this->prefix); |
417 | 417 | |
418 | 418 | $result = $this->_query($query); |
419 | 419 | $output = $this->_fetch($result); |
420 | 420 | $srl = $output->srl; |
421 | - if($srl < 1) |
|
421 | + if ($srl < 1) |
|
422 | 422 | { |
423 | 423 | $start = 1; |
424 | 424 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | function isTableExists($target_name) |
444 | 444 | { |
445 | - if($target_name == 'sequence') |
|
445 | + if ($target_name == 'sequence') |
|
446 | 446 | { |
447 | 447 | $query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name); |
448 | 448 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | $result = $this->_query($query); |
455 | - if(cubrid_num_rows($result) > 0) |
|
455 | + if (cubrid_num_rows($result) > 0) |
|
456 | 456 | { |
457 | 457 | $output = TRUE; |
458 | 458 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $output = FALSE; |
462 | 462 | } |
463 | 463 | |
464 | - if($result) |
|
464 | + if ($result) |
|
465 | 465 | { |
466 | 466 | cubrid_close_request($result); |
467 | 467 | } |
@@ -482,22 +482,22 @@ discard block |
||
482 | 482 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = FALSE) |
483 | 483 | { |
484 | 484 | $type = strtoupper($this->column_type[$type]); |
485 | - if($type == 'INTEGER') |
|
485 | + if ($type == 'INTEGER') |
|
486 | 486 | { |
487 | 487 | $size = ''; |
488 | 488 | } |
489 | 489 | |
490 | 490 | $query = sprintf("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name); |
491 | 491 | |
492 | - if($type == 'char' || $type == 'varchar') |
|
492 | + if ($type == 'char' || $type == 'varchar') |
|
493 | 493 | { |
494 | - if($size) |
|
494 | + if ($size) |
|
495 | 495 | { |
496 | 496 | $size = $size * 3; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - if($size) |
|
500 | + if ($size) |
|
501 | 501 | { |
502 | 502 | $query .= sprintf("%s(%s) ", $type, $size); |
503 | 503 | } |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | $query .= sprintf("%s ", $type); |
507 | 507 | } |
508 | 508 | |
509 | - if(isset($default)) |
|
509 | + if (isset($default)) |
|
510 | 510 | { |
511 | - if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
|
511 | + if ($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
|
512 | 512 | { |
513 | 513 | $query .= sprintf("default %d ", $default); |
514 | 514 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | - if($notnull) |
|
521 | + if ($notnull) |
|
522 | 522 | { |
523 | 523 | $query .= "not null "; |
524 | 524 | } |
@@ -547,10 +547,10 @@ discard block |
||
547 | 547 | */ |
548 | 548 | function isColumnExists($table_name, $column_name) |
549 | 549 | { |
550 | - $query = sprintf("select \"attr_name\" from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); |
|
550 | + $query = sprintf("select \"attr_name\" from \"db_attribute\" where "."\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); |
|
551 | 551 | $result = $this->_query($query); |
552 | 552 | |
553 | - if(cubrid_num_rows($result) > 0) |
|
553 | + if (cubrid_num_rows($result) > 0) |
|
554 | 554 | { |
555 | 555 | $output = TRUE; |
556 | 556 | } |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | $output = FALSE; |
560 | 560 | } |
561 | 561 | |
562 | - if($result) |
|
562 | + if ($result) |
|
563 | 563 | { |
564 | 564 | cubrid_close_request($result); |
565 | 565 | } |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | */ |
580 | 580 | function addIndex($table_name, $index_name, $target_columns, $is_unique = FALSE) |
581 | 581 | { |
582 | - if(!is_array($target_columns)) |
|
582 | + if (!is_array($target_columns)) |
|
583 | 583 | { |
584 | 584 | $target_columns = array($target_columns); |
585 | 585 | } |
586 | 586 | |
587 | - $query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"' . implode('","', $target_columns) . '"'); |
|
587 | + $query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"'.implode('","', $target_columns).'"'); |
|
588 | 588 | |
589 | 589 | $this->_query($query); |
590 | 590 | } |
@@ -611,17 +611,17 @@ discard block |
||
611 | 611 | */ |
612 | 612 | function isIndexExists($table_name, $index_name) |
613 | 613 | { |
614 | - $query = sprintf("select \"index_name\" from \"db_index\" where " . "\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix . $index_name, $index_name); |
|
614 | + $query = sprintf("select \"index_name\" from \"db_index\" where "."\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix.$index_name, $index_name); |
|
615 | 615 | $result = $this->_query($query); |
616 | 616 | |
617 | - if($this->isError()) |
|
617 | + if ($this->isError()) |
|
618 | 618 | { |
619 | 619 | return FALSE; |
620 | 620 | } |
621 | 621 | |
622 | 622 | $output = $this->_fetch($result); |
623 | 623 | |
624 | - if(!$output) |
|
624 | + if (!$output) |
|
625 | 625 | { |
626 | 626 | return FALSE; |
627 | 627 | } |
@@ -653,25 +653,25 @@ discard block |
||
653 | 653 | ", strlen($this->prefix) |
654 | 654 | , $this->prefix |
655 | 655 | , strlen($this->prefix) + 1 |
656 | - , "'" . $this->prefix . '%' . "'" |
|
656 | + , "'".$this->prefix.'%'."'" |
|
657 | 657 | , strlen($this->prefix) |
658 | 658 | , $this->prefix |
659 | 659 | , strlen($this->prefix) + 1 |
660 | 660 | ); |
661 | 661 | $result = $this->_query($query); |
662 | 662 | |
663 | - if($this->isError()) |
|
663 | + if ($this->isError()) |
|
664 | 664 | { |
665 | 665 | return FALSE; |
666 | 666 | } |
667 | 667 | |
668 | 668 | $output = $this->_fetch($result); |
669 | - if(!$output) |
|
669 | + if (!$output) |
|
670 | 670 | { |
671 | 671 | return FALSE; |
672 | 672 | } |
673 | 673 | |
674 | - if(!is_array($output)) |
|
674 | + if (!is_array($output)) |
|
675 | 675 | { |
676 | 676 | $indexes_to_be_deleted = array($output); |
677 | 677 | } |
@@ -680,10 +680,10 @@ discard block |
||
680 | 680 | $indexes_to_be_deleted = $output; |
681 | 681 | } |
682 | 682 | |
683 | - foreach($indexes_to_be_deleted as $index) |
|
683 | + foreach ($indexes_to_be_deleted as $index) |
|
684 | 684 | { |
685 | 685 | $this->dropIndex(substr($index->class_name, strlen($this->prefix)) |
686 | - , $this->prefix . $index->unprefixed_index_name |
|
686 | + , $this->prefix.$index->unprefixed_index_name |
|
687 | 687 | , $index->is_unique == 'YES' ? TRUE : FALSE); |
688 | 688 | } |
689 | 689 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | */ |
708 | 708 | function createTableByXmlFile($file_name) |
709 | 709 | { |
710 | - if(!file_exists($file_name)) |
|
710 | + if (!file_exists($file_name)) |
|
711 | 711 | { |
712 | 712 | return; |
713 | 713 | } |
@@ -734,28 +734,28 @@ discard block |
||
734 | 734 | $table_name = $xml_obj->table->attrs->name; |
735 | 735 | |
736 | 736 | // if the table already exists exit function |
737 | - if($this->isTableExists($table_name)) |
|
737 | + if ($this->isTableExists($table_name)) |
|
738 | 738 | { |
739 | 739 | return; |
740 | 740 | } |
741 | 741 | |
742 | 742 | // If the table name is sequence, it creates a serial |
743 | - if($table_name == 'sequence') |
|
743 | + if ($table_name == 'sequence') |
|
744 | 744 | { |
745 | - $query = sprintf('create serial "%s" start with 1 increment by 1' . |
|
746 | - ' minvalue 1 ' . |
|
747 | - 'maxvalue 10000000000000000000000000000000000000' . ' nocycle;', $this->prefix . $table_name); |
|
745 | + $query = sprintf('create serial "%s" start with 1 increment by 1'. |
|
746 | + ' minvalue 1 '. |
|
747 | + 'maxvalue 10000000000000000000000000000000000000'.' nocycle;', $this->prefix.$table_name); |
|
748 | 748 | |
749 | 749 | return $this->_query($query); |
750 | 750 | } |
751 | 751 | |
752 | 752 | |
753 | - $table_name = $this->prefix . $table_name; |
|
753 | + $table_name = $this->prefix.$table_name; |
|
754 | 754 | |
755 | 755 | $query = sprintf('create class "%s";', $table_name); |
756 | 756 | $this->_query($query); |
757 | 757 | |
758 | - if(!is_array($xml_obj->table->column)) |
|
758 | + if (!is_array($xml_obj->table->column)) |
|
759 | 759 | { |
760 | 760 | $columns[] = $xml_obj->table->column; |
761 | 761 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | $unique_list = array(); |
771 | 771 | $index_list = array(); |
772 | 772 | |
773 | - foreach($columns as $column) |
|
773 | + foreach ($columns as $column) |
|
774 | 774 | { |
775 | 775 | $name = $column->attrs->name; |
776 | 776 | $type = $column->attrs->type; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | $unique = $column->attrs->unique; |
782 | 782 | $default = $column->attrs->default; |
783 | 783 | |
784 | - switch($this->column_type[$type]) |
|
784 | + switch ($this->column_type[$type]) |
|
785 | 785 | { |
786 | 786 | case 'integer' : |
787 | 787 | $size = NULL; |
@@ -791,58 +791,58 @@ discard block |
||
791 | 791 | break; |
792 | 792 | } |
793 | 793 | |
794 | - if(isset($default) && ($type == 'varchar' || $type == 'char' || |
|
794 | + if (isset($default) && ($type == 'varchar' || $type == 'char' || |
|
795 | 795 | $type == 'text' || $type == 'tinytext' || $type == 'bigtext')) |
796 | 796 | { |
797 | 797 | $default = sprintf("'%s'", $default); |
798 | 798 | } |
799 | 799 | |
800 | - if($type == 'varchar' || $type == 'char') |
|
800 | + if ($type == 'varchar' || $type == 'char') |
|
801 | 801 | { |
802 | - if($size) |
|
802 | + if ($size) |
|
803 | 803 | $size = $size * 3; |
804 | 804 | } |
805 | 805 | |
806 | 806 | |
807 | - $column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default " . $default : '', $notnull ? 'not null' : ''); |
|
807 | + $column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default ".$default : '', $notnull ? 'not null' : ''); |
|
808 | 808 | |
809 | - if($primary_key) |
|
809 | + if ($primary_key) |
|
810 | 810 | { |
811 | 811 | $primary_list[] = $name; |
812 | 812 | } |
813 | - else if($unique) |
|
813 | + else if ($unique) |
|
814 | 814 | { |
815 | 815 | $unique_list[$unique][] = $name; |
816 | 816 | } |
817 | - else if($index) |
|
817 | + else if ($index) |
|
818 | 818 | { |
819 | 819 | $index_list[$index][] = $name; |
820 | 820 | } |
821 | 821 | } |
822 | 822 | |
823 | - $query .= implode(',', $column_schema) . ';'; |
|
823 | + $query .= implode(',', $column_schema).';'; |
|
824 | 824 | $this->_query($query); |
825 | 825 | |
826 | - if(count($primary_list)) |
|
826 | + if (count($primary_list)) |
|
827 | 827 | { |
828 | - $query = sprintf("alter class \"%s\" add attribute constraint " . "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"' . implode('","', $primary_list) . '"'); |
|
828 | + $query = sprintf("alter class \"%s\" add attribute constraint "."\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"'.implode('","', $primary_list).'"'); |
|
829 | 829 | $this->_query($query); |
830 | 830 | } |
831 | 831 | |
832 | - if(count($unique_list)) |
|
832 | + if (count($unique_list)) |
|
833 | 833 | { |
834 | - foreach($unique_list as $key => $val) |
|
834 | + foreach ($unique_list as $key => $val) |
|
835 | 835 | { |
836 | - $query = sprintf("create unique index \"%s\" on \"%s\" " . "(%s);", $key, $table_name, '"' . implode('","', $val) . '"'); |
|
836 | + $query = sprintf("create unique index \"%s\" on \"%s\" "."(%s);", $key, $table_name, '"'.implode('","', $val).'"'); |
|
837 | 837 | $this->_query($query); |
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
841 | - if(count($index_list)) |
|
841 | + if (count($index_list)) |
|
842 | 842 | { |
843 | - foreach($index_list as $key => $val) |
|
843 | + foreach ($index_list as $key => $val) |
|
844 | 844 | { |
845 | - $query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"' . implode('","', $val) . '"'); |
|
845 | + $query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"'.implode('","', $val).'"'); |
|
846 | 846 | $this->_query($query); |
847 | 847 | } |
848 | 848 | } |
@@ -856,22 +856,22 @@ discard block |
||
856 | 856 | */ |
857 | 857 | function _executeInsertAct($queryObject, $with_values = TRUE) |
858 | 858 | { |
859 | - if($this->use_prepared_statements == 'Y') |
|
859 | + if ($this->use_prepared_statements == 'Y') |
|
860 | 860 | { |
861 | 861 | $this->param = $queryObject->getArguments(); |
862 | 862 | $with_values = FALSE; |
863 | 863 | } |
864 | 864 | $query = $this->getInsertSql($queryObject, $with_values); |
865 | - if(is_a($query, 'Object')) |
|
865 | + if (is_a($query, 'Object')) |
|
866 | 866 | { |
867 | 867 | unset($this->param); |
868 | 868 | return; |
869 | 869 | } |
870 | 870 | |
871 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
871 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
872 | 872 | |
873 | 873 | $result = $this->_query($query); |
874 | - if($result && !$this->transaction_started) |
|
874 | + if ($result && !$this->transaction_started) |
|
875 | 875 | { |
876 | 876 | $this->_commit(); |
877 | 877 | } |
@@ -887,23 +887,23 @@ discard block |
||
887 | 887 | */ |
888 | 888 | function _executeUpdateAct($queryObject, $with_values = TRUE) |
889 | 889 | { |
890 | - if($this->use_prepared_statements == 'Y') |
|
890 | + if ($this->use_prepared_statements == 'Y') |
|
891 | 891 | { |
892 | 892 | $this->param = $queryObject->getArguments(); |
893 | 893 | $with_values = FALSE; |
894 | 894 | } |
895 | 895 | $query = $this->getUpdateSql($queryObject, $with_values); |
896 | - if(is_a($query, 'Object')) |
|
896 | + if (is_a($query, 'Object')) |
|
897 | 897 | { |
898 | 898 | unset($this->param); |
899 | 899 | return; |
900 | 900 | } |
901 | 901 | |
902 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
902 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
903 | 903 | |
904 | 904 | $result = $this->_query($query); |
905 | 905 | |
906 | - if($result && !$this->transaction_started) |
|
906 | + if ($result && !$this->transaction_started) |
|
907 | 907 | { |
908 | 908 | $this->_commit(); |
909 | 909 | } |
@@ -919,23 +919,23 @@ discard block |
||
919 | 919 | */ |
920 | 920 | function _executeDeleteAct($queryObject, $with_values = TRUE) |
921 | 921 | { |
922 | - if($this->use_prepared_statements == 'Y') |
|
922 | + if ($this->use_prepared_statements == 'Y') |
|
923 | 923 | { |
924 | 924 | $this->param = $queryObject->getArguments(); |
925 | 925 | $with_values = FALSE; |
926 | 926 | } |
927 | 927 | $query = $this->getDeleteSql($queryObject, $with_values); |
928 | - if(is_a($query, 'Object')) |
|
928 | + if (is_a($query, 'Object')) |
|
929 | 929 | { |
930 | 930 | unset($this->param); |
931 | 931 | return; |
932 | 932 | } |
933 | 933 | |
934 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
934 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
935 | 935 | |
936 | 936 | $result = $this->_query($query); |
937 | 937 | |
938 | - if($result && !$this->transaction_started) |
|
938 | + if ($result && !$this->transaction_started) |
|
939 | 939 | { |
940 | 940 | $this->_commit(); |
941 | 941 | } |
@@ -955,36 +955,36 @@ discard block |
||
955 | 955 | */ |
956 | 956 | function _executeSelectAct($queryObject, $connection = NULL, $with_values = TRUE) |
957 | 957 | { |
958 | - if($this->use_prepared_statements == 'Y') |
|
958 | + if ($this->use_prepared_statements == 'Y') |
|
959 | 959 | { |
960 | 960 | $this->param = $queryObject->getArguments(); |
961 | 961 | $with_values = FALSE; |
962 | 962 | } |
963 | 963 | $limit = $queryObject->getLimit(); |
964 | - if($limit && $limit->isPageHandler()) |
|
964 | + if ($limit && $limit->isPageHandler()) |
|
965 | 965 | { |
966 | 966 | return $this->queryPageLimit($queryObject, $connection, $with_values); |
967 | 967 | } |
968 | 968 | else |
969 | 969 | { |
970 | 970 | $query = $this->getSelectSql($queryObject, $with_values); |
971 | - if(is_a($query, 'Object')) |
|
971 | + if (is_a($query, 'Object')) |
|
972 | 972 | { |
973 | 973 | unset($this->param); |
974 | 974 | return; |
975 | 975 | } |
976 | 976 | |
977 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
977 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
978 | 978 | $result = $this->_query($query, $connection); |
979 | 979 | |
980 | - if($this->isError()) |
|
980 | + if ($this->isError()) |
|
981 | 981 | { |
982 | 982 | unset($this->param); |
983 | 983 | return $this->queryError($queryObject); |
984 | 984 | } |
985 | 985 | |
986 | 986 | $data = $this->_fetch($result); |
987 | - $buff = new Object (); |
|
987 | + $buff = new Object(); |
|
988 | 988 | $buff->data = $data; |
989 | 989 | |
990 | 990 | unset($this->param); |
@@ -1000,16 +1000,16 @@ discard block |
||
1000 | 1000 | function queryError($queryObject) |
1001 | 1001 | { |
1002 | 1002 | $limit = $queryObject->getLimit(); |
1003 | - if($limit && $limit->isPageHandler()) |
|
1003 | + if ($limit && $limit->isPageHandler()) |
|
1004 | 1004 | { |
1005 | - $buff = new Object (); |
|
1005 | + $buff = new Object(); |
|
1006 | 1006 | $buff->total_count = 0; |
1007 | 1007 | $buff->total_page = 0; |
1008 | 1008 | $buff->page = 1; |
1009 | 1009 | $buff->data = array(); |
1010 | 1010 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
1011 | 1011 | return $buff; |
1012 | - }else |
|
1012 | + } else |
|
1013 | 1013 | return; |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1025,48 +1025,48 @@ discard block |
||
1025 | 1025 | $limit = $queryObject->getLimit(); |
1026 | 1026 | // Total count |
1027 | 1027 | $temp_where = $queryObject->getWhereString($with_values, FALSE); |
1028 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
1028 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
1029 | 1029 | |
1030 | 1030 | // Check for distinct query and if found update count query structure |
1031 | 1031 | $temp_select = $queryObject->getSelectString($with_values); |
1032 | 1032 | $uses_distinct = stripos($temp_select, "distinct") !== FALSE; |
1033 | 1033 | $uses_groupby = $queryObject->getGroupByString() != ''; |
1034 | - if($uses_distinct || $uses_groupby) |
|
1034 | + if ($uses_distinct || $uses_groupby) |
|
1035 | 1035 | { |
1036 | 1036 | $count_query = sprintf('select %s %s %s %s' |
1037 | 1037 | , $temp_select |
1038 | - , 'FROM ' . $queryObject->getFromString($with_values) |
|
1039 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
1040 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
1038 | + , 'FROM '.$queryObject->getFromString($with_values) |
|
1039 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
1040 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
1041 | 1041 | ); |
1042 | 1042 | |
1043 | 1043 | // If query uses grouping or distinct, count from original select |
1044 | 1044 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
1045 | 1045 | } |
1046 | 1046 | |
1047 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; |
|
1047 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $queryObject->queryID) : ''; |
|
1048 | 1048 | $result = $this->_query($count_query, $connection); |
1049 | 1049 | $count_output = $this->_fetch($result); |
1050 | 1050 | $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL); |
1051 | 1051 | |
1052 | 1052 | $list_count = $limit->list_count->getValue(); |
1053 | - if(!$list_count) |
|
1053 | + if (!$list_count) |
|
1054 | 1054 | { |
1055 | 1055 | $list_count = 20; |
1056 | 1056 | } |
1057 | 1057 | $page_count = $limit->page_count->getValue(); |
1058 | - if(!$page_count) |
|
1058 | + if (!$page_count) |
|
1059 | 1059 | { |
1060 | 1060 | $page_count = 10; |
1061 | 1061 | } |
1062 | 1062 | $page = $limit->page->getValue(); |
1063 | - if(!$page || $page < 1) |
|
1063 | + if (!$page || $page < 1) |
|
1064 | 1064 | { |
1065 | 1065 | $page = 1; |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | // total pages |
1069 | - if($total_count) |
|
1069 | + if ($total_count) |
|
1070 | 1070 | { |
1071 | 1071 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
1072 | 1072 | } |
@@ -1076,11 +1076,11 @@ discard block |
||
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | // check the page variables |
1079 | - if($page > $total_page) |
|
1079 | + if ($page > $total_page) |
|
1080 | 1080 | { |
1081 | 1081 | // If requested page is bigger than total number of pages, return empty list |
1082 | 1082 | |
1083 | - $buff = new Object (); |
|
1083 | + $buff = new Object(); |
|
1084 | 1084 | $buff->total_count = $total_count; |
1085 | 1085 | $buff->total_page = $total_page; |
1086 | 1086 | $buff->page = $page; |
@@ -1092,9 +1092,9 @@ discard block |
||
1092 | 1092 | $start_count = ($page - 1) * $list_count; |
1093 | 1093 | |
1094 | 1094 | $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count); |
1095 | - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
1095 | + $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
1096 | 1096 | $result = $this->_query($query, $connection); |
1097 | - if($this->isError()) |
|
1097 | + if ($this->isError()) |
|
1098 | 1098 | { |
1099 | 1099 | unset($this->param); |
1100 | 1100 | return $this->queryError($queryObject); |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $virtual_no = $total_count - ($page - 1) * $list_count; |
1104 | 1104 | $data = $this->_fetch($result, $virtual_no); |
1105 | 1105 | |
1106 | - $buff = new Object (); |
|
1106 | + $buff = new Object(); |
|
1107 | 1107 | $buff->total_count = $total_count; |
1108 | 1108 | $buff->total_page = $total_page; |
1109 | 1109 | $buff->page = $page; |
@@ -1135,44 +1135,44 @@ discard block |
||
1135 | 1135 | { |
1136 | 1136 | |
1137 | 1137 | $select = $query->getSelectString($with_values); |
1138 | - if($select == '') |
|
1138 | + if ($select == '') |
|
1139 | 1139 | { |
1140 | 1140 | return new Object(-1, "Invalid query"); |
1141 | 1141 | } |
1142 | - $select = 'SELECT ' . $select; |
|
1142 | + $select = 'SELECT '.$select; |
|
1143 | 1143 | |
1144 | 1144 | $from = $query->getFromString($with_values); |
1145 | - if($from == '') |
|
1145 | + if ($from == '') |
|
1146 | 1146 | { |
1147 | 1147 | return new Object(-1, "Invalid query"); |
1148 | 1148 | } |
1149 | - $from = ' FROM ' . $from; |
|
1149 | + $from = ' FROM '.$from; |
|
1150 | 1150 | |
1151 | 1151 | $where = $query->getWhereString($with_values); |
1152 | - if($where != '') |
|
1152 | + if ($where != '') |
|
1153 | 1153 | { |
1154 | - $where = ' WHERE ' . $where; |
|
1154 | + $where = ' WHERE '.$where; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | $groupBy = $query->getGroupByString(); |
1158 | - if($groupBy != '') |
|
1158 | + if ($groupBy != '') |
|
1159 | 1159 | { |
1160 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
1160 | + $groupBy = ' GROUP BY '.$groupBy; |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | $orderBy = $query->getOrderByString(); |
1164 | - if($orderBy != '') |
|
1164 | + if ($orderBy != '') |
|
1165 | 1165 | { |
1166 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
1166 | + $orderBy = ' ORDER BY '.$orderBy; |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | $limit = $query->getLimitString(); |
1170 | - if($limit != '') |
|
1170 | + if ($limit != '') |
|
1171 | 1171 | { |
1172 | 1172 | $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count); |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
1175 | + return $select.' '.$from.' '.$where.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | } |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | function DBCubrid($auto_connect = TRUE) |
53 | 53 | { |
54 | 54 | $this->_setDBInfo(); |
55 | - if($auto_connect) $this->_connect(); |
|
55 | + if($auto_connect) { |
|
56 | + $this->_connect(); |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | |
58 | 60 | /** |
@@ -90,8 +92,9 @@ discard block |
||
90 | 92 | define('__CUBRID_VERSION__', $cubrid_version); |
91 | 93 | } |
92 | 94 | |
93 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
94 | - cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
|
95 | + if(__CUBRID_VERSION__ >= '8.4.0') { |
|
96 | + cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
|
97 | + } |
|
95 | 98 | |
96 | 99 | return $result; |
97 | 100 | } |
@@ -153,8 +156,7 @@ discard block |
||
153 | 156 | if(!$transactionLevel) |
154 | 157 | { |
155 | 158 | cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE); |
156 | - } |
|
157 | - else |
|
159 | + } else |
|
158 | 160 | { |
159 | 161 | $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
160 | 162 | } |
@@ -176,8 +178,7 @@ discard block |
||
176 | 178 | if($point) |
177 | 179 | { |
178 | 180 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
179 | - } |
|
180 | - else |
|
181 | + } else |
|
181 | 182 | { |
182 | 183 | @cubrid_rollback($connection); |
183 | 184 | } |
@@ -251,8 +252,7 @@ discard block |
||
251 | 252 | return false; |
252 | 253 | } |
253 | 254 | } |
254 | - } |
|
255 | - else |
|
255 | + } else |
|
256 | 256 | { |
257 | 257 | $bound = @cubrid_bind($req, ++$position, $value, $bind_type); |
258 | 258 | if(!$bound) |
@@ -343,8 +343,7 @@ discard block |
||
343 | 343 | if($arrayIndexEndValue) |
344 | 344 | { |
345 | 345 | $output[$arrayIndexEndValue--] = $tmp; |
346 | - } |
|
347 | - else |
|
346 | + } else |
|
348 | 347 | { |
349 | 348 | $output[] = $tmp; |
350 | 349 | } |
@@ -395,8 +394,9 @@ discard block |
||
395 | 394 | */ |
396 | 395 | function _makeSequence() |
397 | 396 | { |
398 | - if($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
399 | - return; |
|
397 | + if($_GLOBALS['XE_EXISTS_SEQUENCE']) { |
|
398 | + return; |
|
399 | + } |
|
400 | 400 | |
401 | 401 | // check cubrid serial |
402 | 402 | $query = sprintf('select count(*) as "count" from "db_serial" where name=\'%ssequence\'', $this->prefix); |
@@ -421,8 +421,7 @@ discard block |
||
421 | 421 | if($srl < 1) |
422 | 422 | { |
423 | 423 | $start = 1; |
424 | - } |
|
425 | - else |
|
424 | + } else |
|
426 | 425 | { |
427 | 426 | $start = $srl + 1000000; |
428 | 427 | } |
@@ -445,8 +444,7 @@ discard block |
||
445 | 444 | if($target_name == 'sequence') |
446 | 445 | { |
447 | 446 | $query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name); |
448 | - } |
|
449 | - else |
|
447 | + } else |
|
450 | 448 | { |
451 | 449 | $query = sprintf("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name); |
452 | 450 | } |
@@ -455,8 +453,7 @@ discard block |
||
455 | 453 | if(cubrid_num_rows($result) > 0) |
456 | 454 | { |
457 | 455 | $output = TRUE; |
458 | - } |
|
459 | - else |
|
456 | + } else |
|
460 | 457 | { |
461 | 458 | $output = FALSE; |
462 | 459 | } |
@@ -500,8 +497,7 @@ discard block |
||
500 | 497 | if($size) |
501 | 498 | { |
502 | 499 | $query .= sprintf("%s(%s) ", $type, $size); |
503 | - } |
|
504 | - else |
|
500 | + } else |
|
505 | 501 | { |
506 | 502 | $query .= sprintf("%s ", $type); |
507 | 503 | } |
@@ -511,8 +507,7 @@ discard block |
||
511 | 507 | if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
512 | 508 | { |
513 | 509 | $query .= sprintf("default %d ", $default); |
514 | - } |
|
515 | - else |
|
510 | + } else |
|
516 | 511 | { |
517 | 512 | $query .= sprintf("default '%s' ", $default); |
518 | 513 | } |
@@ -553,8 +548,7 @@ discard block |
||
553 | 548 | if(cubrid_num_rows($result) > 0) |
554 | 549 | { |
555 | 550 | $output = TRUE; |
556 | - } |
|
557 | - else |
|
551 | + } else |
|
558 | 552 | { |
559 | 553 | $output = FALSE; |
560 | 554 | } |
@@ -674,8 +668,7 @@ discard block |
||
674 | 668 | if(!is_array($output)) |
675 | 669 | { |
676 | 670 | $indexes_to_be_deleted = array($output); |
677 | - } |
|
678 | - else |
|
671 | + } else |
|
679 | 672 | { |
680 | 673 | $indexes_to_be_deleted = $output; |
681 | 674 | } |
@@ -758,8 +751,7 @@ discard block |
||
758 | 751 | if(!is_array($xml_obj->table->column)) |
759 | 752 | { |
760 | 753 | $columns[] = $xml_obj->table->column; |
761 | - } |
|
762 | - else |
|
754 | + } else |
|
763 | 755 | { |
764 | 756 | $columns = $xml_obj->table->column; |
765 | 757 | } |
@@ -799,8 +791,9 @@ discard block |
||
799 | 791 | |
800 | 792 | if($type == 'varchar' || $type == 'char') |
801 | 793 | { |
802 | - if($size) |
|
803 | - $size = $size * 3; |
|
794 | + if($size) { |
|
795 | + $size = $size * 3; |
|
796 | + } |
|
804 | 797 | } |
805 | 798 | |
806 | 799 | |
@@ -809,12 +802,10 @@ discard block |
||
809 | 802 | if($primary_key) |
810 | 803 | { |
811 | 804 | $primary_list[] = $name; |
812 | - } |
|
813 | - else if($unique) |
|
805 | + } else if($unique) |
|
814 | 806 | { |
815 | 807 | $unique_list[$unique][] = $name; |
816 | - } |
|
817 | - else if($index) |
|
808 | + } else if($index) |
|
818 | 809 | { |
819 | 810 | $index_list[$index][] = $name; |
820 | 811 | } |
@@ -964,8 +955,7 @@ discard block |
||
964 | 955 | if($limit && $limit->isPageHandler()) |
965 | 956 | { |
966 | 957 | return $this->queryPageLimit($queryObject, $connection, $with_values); |
967 | - } |
|
968 | - else |
|
958 | + } else |
|
969 | 959 | { |
970 | 960 | $query = $this->getSelectSql($queryObject, $with_values); |
971 | 961 | if(is_a($query, 'Object')) |
@@ -1009,8 +999,9 @@ discard block |
||
1009 | 999 | $buff->data = array(); |
1010 | 1000 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
1011 | 1001 | return $buff; |
1012 | - }else |
|
1013 | - return; |
|
1002 | + } else { |
|
1003 | + return; |
|
1004 | + } |
|
1014 | 1005 | } |
1015 | 1006 | |
1016 | 1007 | /** |
@@ -1069,8 +1060,7 @@ discard block |
||
1069 | 1060 | if($total_count) |
1070 | 1061 | { |
1071 | 1062 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
1072 | - } |
|
1073 | - else |
|
1063 | + } else |
|
1074 | 1064 | { |
1075 | 1065 | $total_page = 1; |
1076 | 1066 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | function DBMssql($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if ($auto_connect) $this->_connect(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | //sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL ); |
71 | 71 | $result = @sqlsrv_connect($connection["db_hostname"], array('Database' => $connection["db_database"], 'UID' => $connection["db_userid"], 'PWD' => $connection["db_password"])); |
72 | 72 | |
73 | - if(!$result) |
|
73 | + if (!$result) |
|
74 | 74 | { |
75 | 75 | $errors = print_r(sqlsrv_errors(), true); |
76 | - $this->setError(-1, 'database connect fail' . PHP_EOL . $errors); |
|
76 | + $this->setError(-1, 'database connect fail'.PHP_EOL.$errors); |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | return $result; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function addQuotes($string) |
101 | 101 | { |
102 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
102 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
103 | 103 | { |
104 | 104 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
105 | 105 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | { |
118 | 118 | $connection = $this->_getConnection('master'); |
119 | 119 | |
120 | - if(!$transactionLevel) |
|
120 | + if (!$transactionLevel) |
|
121 | 121 | { |
122 | - if(sqlsrv_begin_transaction($connection) === false) |
|
122 | + if (sqlsrv_begin_transaction($connection) === false) |
|
123 | 123 | { |
124 | 124 | return; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | else |
128 | 128 | { |
129 | - $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
|
129 | + $this->_query("SAVE TRANS SP".$transactionLevel, $connection); |
|
130 | 130 | } |
131 | 131 | return true; |
132 | 132 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | |
143 | 143 | $point = $transactionLevel - 1; |
144 | 144 | |
145 | - if($point) |
|
145 | + if ($point) |
|
146 | 146 | { |
147 | - $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
|
147 | + $this->_query("ROLLBACK TRANS SP".$point, $connection); |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
@@ -176,18 +176,18 @@ discard block |
||
176 | 176 | { |
177 | 177 | $_param = array(); |
178 | 178 | |
179 | - if(count($this->param)) |
|
179 | + if (count($this->param)) |
|
180 | 180 | { |
181 | - foreach($this->param as $k => $o) |
|
181 | + foreach ($this->param as $k => $o) |
|
182 | 182 | { |
183 | - if($o->isColumnName()) |
|
183 | + if ($o->isColumnName()) |
|
184 | 184 | { |
185 | 185 | continue; |
186 | 186 | } |
187 | - if($o->getType() == 'number') |
|
187 | + if ($o->getType() == 'number') |
|
188 | 188 | { |
189 | 189 | $value = $o->getUnescapedValue(); |
190 | - if(is_array($value)) |
|
190 | + if (is_array($value)) |
|
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | 193 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | else |
200 | 200 | { |
201 | 201 | $value = $o->getUnescapedValue(); |
202 | - if(is_array($value)) |
|
202 | + if (is_array($value)) |
|
203 | 203 | { |
204 | - foreach($value as $v) |
|
204 | + foreach ($value as $v) |
|
205 | 205 | { |
206 | 206 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 207 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | // Run the query statement |
218 | 218 | $result = false; |
219 | - if(count($_param)) |
|
219 | + if (count($_param)) |
|
220 | 220 | { |
221 | 221 | $args = $this->_getParametersByReference($_param); |
222 | 222 | $stmt = sqlsrv_prepare($connection, $query, $args); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 227 | } |
228 | 228 | |
229 | - if(!$stmt) |
|
229 | + if (!$stmt) |
|
230 | 230 | { |
231 | 231 | $result = false; |
232 | 232 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | // Error Check |
239 | - if(!$result) |
|
239 | + if (!$result) |
|
240 | 240 | { |
241 | 241 | $this->setError(print_r(sqlsrv_errors(), true)); |
242 | 242 | } |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | $copy = array(); |
260 | 260 | $args = array(); |
261 | 261 | $i = 0; |
262 | - foreach($_param as $key => $value) |
|
262 | + foreach ($_param as $key => $value) |
|
263 | 263 | { |
264 | - if(is_array($value)) |
|
264 | + if (is_array($value)) |
|
265 | 265 | { |
266 | 266 | $value_copy = $value; |
267 | 267 | $value_arg = array(); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | function _fetch($result, $arrayIndexEndValue = NULL) |
289 | 289 | { |
290 | 290 | $output = array(); |
291 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
291 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
292 | 292 | { |
293 | 293 | return $output; |
294 | 294 | } |
@@ -296,18 +296,18 @@ discard block |
||
296 | 296 | $c = sqlsrv_num_fields($result); |
297 | 297 | $m = null; |
298 | 298 | |
299 | - while(sqlsrv_fetch($result)) |
|
299 | + while (sqlsrv_fetch($result)) |
|
300 | 300 | { |
301 | - if(!$m) |
|
301 | + if (!$m) |
|
302 | 302 | { |
303 | 303 | $m = sqlsrv_field_metadata($result); |
304 | 304 | } |
305 | 305 | unset($row); |
306 | - for($i = 0; $i < $c; $i++) |
|
306 | + for ($i = 0; $i < $c; $i++) |
|
307 | 307 | { |
308 | 308 | $row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8')); |
309 | 309 | } |
310 | - if($arrayIndexEndValue) |
|
310 | + if ($arrayIndexEndValue) |
|
311 | 311 | { |
312 | 312 | $output[$arrayIndexEndValue--] = $row; |
313 | 313 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - if(count($output) == 1) |
|
320 | + if (count($output) == 1) |
|
321 | 321 | { |
322 | - if(isset($arrayIndexEndValue)) |
|
322 | + if (isset($arrayIndexEndValue)) |
|
323 | 323 | { |
324 | 324 | return $output; |
325 | 325 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $result = $this->_query($query); |
361 | 361 | $tmp = $this->_fetch($result); |
362 | 362 | |
363 | - if(!$tmp) |
|
363 | + if (!$tmp) |
|
364 | 364 | { |
365 | 365 | return false; |
366 | 366 | } |
@@ -379,18 +379,18 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
381 | 381 | { |
382 | - if($this->isColumnExists($table_name, $column_name)) |
|
382 | + if ($this->isColumnExists($table_name, $column_name)) |
|
383 | 383 | { |
384 | 384 | return; |
385 | 385 | } |
386 | 386 | $type = $this->column_type[$type]; |
387 | - if(strtoupper($type) == 'INTEGER') |
|
387 | + if (strtoupper($type) == 'INTEGER') |
|
388 | 388 | { |
389 | 389 | $size = ''; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name); |
393 | - if($size) |
|
393 | + if ($size) |
|
394 | 394 | { |
395 | 395 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | 396 | } |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | $query .= sprintf(" %s ", $type); |
400 | 400 | } |
401 | 401 | |
402 | - if(isset($default)) |
|
402 | + if (isset($default)) |
|
403 | 403 | { |
404 | 404 | $query .= sprintf(" default '%s' ", $default); |
405 | 405 | } |
406 | - if($notnull) |
|
406 | + if ($notnull) |
|
407 | 407 | { |
408 | 408 | $query .= " not null "; |
409 | 409 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | function dropColumn($table_name, $column_name) |
421 | 421 | { |
422 | - if(!$this->isColumnExists($table_name, $column_name)) |
|
422 | + if (!$this->isColumnExists($table_name, $column_name)) |
|
423 | 423 | { |
424 | 424 | return; |
425 | 425 | } |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | { |
438 | 438 | $query = sprintf("select syscolumns.name as name from syscolumns, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = syscolumns.id and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name); |
439 | 439 | $result = $this->_query($query); |
440 | - if($this->isError()) |
|
440 | + if ($this->isError()) |
|
441 | 441 | { |
442 | 442 | return; |
443 | 443 | } |
444 | 444 | $tmp = $this->_fetch($result); |
445 | - if(!$tmp->name) |
|
445 | + if (!$tmp->name) |
|
446 | 446 | { |
447 | 447 | return false; |
448 | 448 | } |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
463 | 463 | { |
464 | - if($this->isIndexExists($table_name, $index_name)) |
|
464 | + if ($this->isIndexExists($table_name, $index_name)) |
|
465 | 465 | { |
466 | 466 | return; |
467 | 467 | } |
468 | - if(!is_array($target_columns)) |
|
468 | + if (!is_array($target_columns)) |
|
469 | 469 | { |
470 | 470 | $target_columns = array($target_columns); |
471 | 471 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | function dropIndex($table_name, $index_name, $is_unique = false) |
485 | 485 | { |
486 | - if(!$this->isIndexExists($table_name, $index_name)) |
|
486 | + if (!$this->isIndexExists($table_name, $index_name)) |
|
487 | 487 | { |
488 | 488 | return; |
489 | 489 | } |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | $query = sprintf("select sysindexes.name as name from sysindexes, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = sysindexes.id and sysindexes.name = '%s'", $this->prefix, $table_name, $index_name); |
503 | 503 | |
504 | 504 | $result = $this->_query($query); |
505 | - if($this->isError()) |
|
505 | + if ($this->isError()) |
|
506 | 506 | { |
507 | 507 | return; |
508 | 508 | } |
509 | 509 | $tmp = $this->_fetch($result); |
510 | 510 | |
511 | - if(!$tmp->name) |
|
511 | + if (!$tmp->name) |
|
512 | 512 | { |
513 | 513 | return false; |
514 | 514 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | */ |
533 | 533 | function createTableByXmlFile($file_name) |
534 | 534 | { |
535 | - if(!file_exists($file_name)) |
|
535 | + if (!file_exists($file_name)) |
|
536 | 536 | { |
537 | 537 | return; |
538 | 538 | } |
@@ -557,22 +557,22 @@ discard block |
||
557 | 557 | $xml_obj = $oXml->parse($xml_doc); |
558 | 558 | // Create a table schema |
559 | 559 | $table_name = $xml_obj->table->attrs->name; |
560 | - if($this->isTableExists($table_name)) |
|
560 | + if ($this->isTableExists($table_name)) |
|
561 | 561 | { |
562 | 562 | return; |
563 | 563 | } |
564 | 564 | |
565 | - if($table_name == 'sequence') |
|
565 | + if ($table_name == 'sequence') |
|
566 | 566 | { |
567 | - $table_name = $this->prefix . $table_name; |
|
567 | + $table_name = $this->prefix.$table_name; |
|
568 | 568 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 569 | return $this->_query($query); |
570 | 570 | } |
571 | 571 | else |
572 | 572 | { |
573 | - $table_name = $this->prefix . $table_name; |
|
573 | + $table_name = $this->prefix.$table_name; |
|
574 | 574 | |
575 | - if(!is_array($xml_obj->table->column)) |
|
575 | + if (!is_array($xml_obj->table->column)) |
|
576 | 576 | { |
577 | 577 | $columns[] = $xml_obj->table->column; |
578 | 578 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $index_list = array(); |
587 | 587 | |
588 | 588 | $typeList = array('number' => 1, 'text' => 1); |
589 | - foreach($columns as $column) |
|
589 | + foreach ($columns as $column) |
|
590 | 590 | { |
591 | 591 | $name = $column->attrs->name; |
592 | 592 | $type = $column->attrs->type; |
@@ -598,48 +598,48 @@ discard block |
||
598 | 598 | $default = $column->attrs->default; |
599 | 599 | $auto_increment = $column->attrs->auto_increment; |
600 | 600 | |
601 | - $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
601 | + $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
602 | 602 | |
603 | - if($primary_key) |
|
603 | + if ($primary_key) |
|
604 | 604 | { |
605 | 605 | $primary_list[] = $name; |
606 | 606 | } |
607 | - else if($unique) |
|
607 | + else if ($unique) |
|
608 | 608 | { |
609 | 609 | $unique_list[$unique][] = $name; |
610 | 610 | } |
611 | - else if($index) |
|
611 | + else if ($index) |
|
612 | 612 | { |
613 | 613 | $index_list[$index][] = $name; |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - if(count($primary_list)) |
|
617 | + if (count($primary_list)) |
|
618 | 618 | { |
619 | - $column_schema[] = sprintf("primary key (%s)", '"' . implode($primary_list, '","') . '"'); |
|
619 | + $column_schema[] = sprintf("primary key (%s)", '"'.implode($primary_list, '","').'"'); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | $schema = sprintf('create table [%s] (%s%s)', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n")); |
623 | 623 | $output = $this->_query($schema); |
624 | - if(!$output) |
|
624 | + if (!$output) |
|
625 | 625 | { |
626 | 626 | return false; |
627 | 627 | } |
628 | 628 | |
629 | - if(count($unique_list)) |
|
629 | + if (count($unique_list)) |
|
630 | 630 | { |
631 | - foreach($unique_list as $key => $val) |
|
631 | + foreach ($unique_list as $key => $val) |
|
632 | 632 | { |
633 | - $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
633 | + $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
634 | 634 | $this->_query($query); |
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
638 | - if(count($index_list)) |
|
638 | + if (count($index_list)) |
|
639 | 639 | { |
640 | - foreach($index_list as $key => $val) |
|
640 | + foreach ($index_list as $key => $val) |
|
641 | 641 | { |
642 | - $query = sprintf("create index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
642 | + $query = sprintf("create index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
643 | 643 | $this->_query($query); |
644 | 644 | } |
645 | 645 | } |
@@ -682,34 +682,34 @@ discard block |
||
682 | 682 | function getUpdateSql($query, $with_values = true, $with_priority = false) |
683 | 683 | { |
684 | 684 | $columnsList = $query->getUpdateString($with_values); |
685 | - if($columnsList == '') |
|
685 | + if ($columnsList == '') |
|
686 | 686 | { |
687 | 687 | return new Object(-1, "Invalid query"); |
688 | 688 | } |
689 | 689 | |
690 | 690 | $from = $query->getFromString($with_values); |
691 | - if($from == '') |
|
691 | + if ($from == '') |
|
692 | 692 | { |
693 | 693 | return new Object(-1, "Invalid query"); |
694 | 694 | } |
695 | 695 | |
696 | 696 | $tables = $query->getTables(); |
697 | 697 | $alias_list = ''; |
698 | - foreach($tables as $table) |
|
698 | + foreach ($tables as $table) |
|
699 | 699 | { |
700 | 700 | $alias_list .= $table->getAlias(); |
701 | 701 | } |
702 | 702 | implode(',', explode(' ', $alias_list)); |
703 | 703 | |
704 | 704 | $where = $query->getWhereString($with_values); |
705 | - if($where != '') |
|
705 | + if ($where != '') |
|
706 | 706 | { |
707 | - $where = ' WHERE ' . $where; |
|
707 | + $where = ' WHERE '.$where; |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | $priority = $with_priority ? $query->getPriority() : ''; |
711 | 711 | |
712 | - return "UPDATE $priority $alias_list SET $columnsList FROM " . $from . $where; |
|
712 | + return "UPDATE $priority $alias_list SET $columnsList FROM ".$from.$where; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @param boolean $with_values |
731 | 731 | * @return string |
732 | 732 | */ |
733 | - function getSelectSql($query, $with_values = TRUE, $connection=NULL) |
|
733 | + function getSelectSql($query, $with_values = TRUE, $connection = NULL) |
|
734 | 734 | { |
735 | 735 | $with_values = false; |
736 | 736 | |
@@ -740,75 +740,75 @@ discard block |
||
740 | 740 | $limit = ''; |
741 | 741 | $limitCount = ''; |
742 | 742 | $limitQueryPart = $query->getLimit(); |
743 | - if($limitQueryPart) |
|
743 | + if ($limitQueryPart) |
|
744 | 744 | { |
745 | 745 | $limitCount = $limitQueryPart->getLimit(); |
746 | 746 | } |
747 | - if($limitCount != '') |
|
747 | + if ($limitCount != '') |
|
748 | 748 | { |
749 | - $limit = 'SELECT TOP ' . $limitCount; |
|
749 | + $limit = 'SELECT TOP '.$limitCount; |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | $select = $query->getSelectString($with_values); |
753 | - if($select == '') |
|
753 | + if ($select == '') |
|
754 | 754 | { |
755 | 755 | return new Object(-1, "Invalid query"); |
756 | 756 | } |
757 | - if($limit != '') |
|
757 | + if ($limit != '') |
|
758 | 758 | { |
759 | - $select = $limit . ' ' . $select; |
|
759 | + $select = $limit.' '.$select; |
|
760 | 760 | } |
761 | 761 | else |
762 | 762 | { |
763 | - $select = 'SELECT ' . $select; |
|
763 | + $select = 'SELECT '.$select; |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | $from = $query->getFromString($with_values); |
767 | - if($from == '') |
|
767 | + if ($from == '') |
|
768 | 768 | { |
769 | 769 | return new Object(-1, "Invalid query"); |
770 | 770 | } |
771 | - $from = ' FROM ' . $from; |
|
771 | + $from = ' FROM '.$from; |
|
772 | 772 | |
773 | 773 | $where = $query->getWhereString($with_values); |
774 | - if($where != '') |
|
774 | + if ($where != '') |
|
775 | 775 | { |
776 | - $where = ' WHERE ' . $where; |
|
776 | + $where = ' WHERE '.$where; |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | $groupBy = $query->getGroupByString(); |
780 | - if($groupBy != '') |
|
780 | + if ($groupBy != '') |
|
781 | 781 | { |
782 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
782 | + $groupBy = ' GROUP BY '.$groupBy; |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | $orderBy = $query->getOrderByString(); |
786 | - if($orderBy != '') |
|
786 | + if ($orderBy != '') |
|
787 | 787 | { |
788 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
788 | + $orderBy = ' ORDER BY '.$orderBy; |
|
789 | 789 | } |
790 | 790 | |
791 | - if($limitCount != '' && $query->limit->start > 0) |
|
791 | + if ($limitCount != '' && $query->limit->start > 0) |
|
792 | 792 | { |
793 | 793 | $order = $query->getOrder(); |
794 | 794 | $first_columns = array(); |
795 | - foreach($order as $val) |
|
795 | + foreach ($order as $val) |
|
796 | 796 | { |
797 | 797 | $tmpColumnName = $val->getPureColumnName(); |
798 | - $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder()=='asc'?'max':'min', $tmpColumnName, $tmpColumnName); |
|
798 | + $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder() == 'asc' ? 'max' : 'min', $tmpColumnName, $tmpColumnName); |
|
799 | 799 | $first_sub_columns[] = $tmpColumnName; |
800 | 800 | } |
801 | 801 | |
802 | - $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',',$first_columns), $query->limit->start, implode(',',$first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
802 | + $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',', $first_columns), $query->limit->start, implode(',', $first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
803 | 803 | $this->param = $query->getArguments(); |
804 | 804 | $result = $this->__query($first_query, $connection); |
805 | 805 | $tmp = $this->_fetch($result); |
806 | 806 | |
807 | 807 | $sub_cond = array(); |
808 | - foreach($order as $k => $v) |
|
808 | + foreach ($order as $k => $v) |
|
809 | 809 | { |
810 | 810 | //for example... use Document |
811 | - if(get_class($v->sort_order) == 'SortArgument') |
|
811 | + if (get_class($v->sort_order) == 'SortArgument') |
|
812 | 812 | { |
813 | 813 | $sort_order = $v->sort_order->value; |
814 | 814 | } |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | $sort_order = $v->sort_order; |
819 | 819 | } |
820 | 820 | |
821 | - $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order=='asc'?'>':'<', $tmp->{$v->getPureColumnName()}); |
|
821 | + $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order == 'asc' ? '>' : '<', $tmp->{$v->getPureColumnName()}); |
|
822 | 822 | } |
823 | 823 | |
824 | - if(!$where) |
|
824 | + if (!$where) |
|
825 | 825 | { |
826 | - $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
|
826 | + $sub_condition = ' WHERE ( '.implode(' and ', $sub_cond).' )'; |
|
827 | 827 | } |
828 | 828 | else |
829 | 829 | { |
830 | - $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
|
830 | + $sub_condition = ' and ( '.implode(' and ', $sub_cond).' )'; |
|
831 | 831 | } |
832 | 832 | } |
833 | - return $select . ' ' . $from . ' ' . $where .$sub_condition. ' ' . $groupBy . ' ' . $orderBy; |
|
833 | + return $select.' '.$from.' '.$where.$sub_condition.' '.$groupBy.' '.$orderBy; |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | { |
846 | 846 | $query = $this->getSelectSql($queryObject, true, $connection); |
847 | 847 | |
848 | - if(strpos($query, "substr")) |
|
848 | + if (strpos($query, "substr")) |
|
849 | 849 | { |
850 | 850 | $query = str_replace("substr", "substring", $query); |
851 | 851 | } |
@@ -853,10 +853,10 @@ discard block |
||
853 | 853 | // TODO Decide if we continue to pass parameters like this |
854 | 854 | $this->param = $queryObject->getArguments(); |
855 | 855 | |
856 | - $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
856 | + $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
857 | 857 | $result = $this->_query($query, $connection); |
858 | 858 | |
859 | - if($this->isError()) |
|
859 | + if ($this->isError()) |
|
860 | 860 | { |
861 | 861 | return $this->queryError($queryObject); |
862 | 862 | } |
@@ -884,9 +884,9 @@ discard block |
||
884 | 884 | function queryError($queryObject) |
885 | 885 | { |
886 | 886 | $limit = $queryObject->getLimit(); |
887 | - if($limit && $limit->isPageHandler()) |
|
887 | + if ($limit && $limit->isPageHandler()) |
|
888 | 888 | { |
889 | - $buff = new Object (); |
|
889 | + $buff = new Object(); |
|
890 | 890 | $buff->total_count = 0; |
891 | 891 | $buff->total_page = 0; |
892 | 892 | $buff->page = 1; |
@@ -910,52 +910,52 @@ discard block |
||
910 | 910 | function queryPageLimit($queryObject, $result, $connection) |
911 | 911 | { |
912 | 912 | $limit = $queryObject->getLimit(); |
913 | - if($limit && $limit->isPageHandler()) |
|
913 | + if ($limit && $limit->isPageHandler()) |
|
914 | 914 | { |
915 | 915 | // Total count |
916 | 916 | $temp_where = $queryObject->getWhereString(true, false); |
917 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
917 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
918 | 918 | |
919 | 919 | // Check for distinct query and if found update count query structure |
920 | 920 | $temp_select = $queryObject->getSelectString(true); |
921 | 921 | $uses_distinct = stripos($temp_select, "distinct") !== false; |
922 | 922 | $uses_groupby = $queryObject->getGroupByString() != ''; |
923 | - if($uses_distinct || $uses_groupby) |
|
923 | + if ($uses_distinct || $uses_groupby) |
|
924 | 924 | { |
925 | 925 | $count_query = sprintf('select %s %s %s %s' |
926 | 926 | , $temp_select |
927 | - , 'FROM ' . $queryObject->getFromString(true) |
|
928 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
929 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
927 | + , 'FROM '.$queryObject->getFromString(true) |
|
928 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
929 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
930 | 930 | ); |
931 | 931 | |
932 | 932 | // If query uses grouping or distinct, count from original select |
933 | 933 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
934 | 934 | } |
935 | 935 | |
936 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
936 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
937 | 937 | $this->param = $queryObject->getArguments(); |
938 | 938 | $result_count = $this->_query($count_query, $connection); |
939 | 939 | $count_output = $this->_fetch($result_count); |
940 | 940 | $total_count = (int) $count_output->count; |
941 | 941 | |
942 | 942 | $list_count = $limit->list_count->getValue(); |
943 | - if(!$list_count) |
|
943 | + if (!$list_count) |
|
944 | 944 | { |
945 | 945 | $list_count = 20; |
946 | 946 | } |
947 | 947 | $page_count = $limit->page_count->getValue(); |
948 | - if(!$page_count) |
|
948 | + if (!$page_count) |
|
949 | 949 | { |
950 | 950 | $page_count = 10; |
951 | 951 | } |
952 | 952 | $page = $limit->page->getValue(); |
953 | - if(!$page || $page < 1) |
|
953 | + if (!$page || $page < 1) |
|
954 | 954 | { |
955 | 955 | $page = 1; |
956 | 956 | } |
957 | 957 | // Total pages |
958 | - if($total_count) |
|
958 | + if ($total_count) |
|
959 | 959 | { |
960 | 960 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | 961 | } |
@@ -965,11 +965,11 @@ discard block |
||
965 | 965 | } |
966 | 966 | |
967 | 967 | // check the page variables |
968 | - if($page > $total_page) |
|
968 | + if ($page > $total_page) |
|
969 | 969 | { |
970 | 970 | // If requested page is bigger than total number of pages, return empty list |
971 | 971 | |
972 | - $buff = new Object (); |
|
972 | + $buff = new Object(); |
|
973 | 973 | $buff->total_count = $total_count; |
974 | 974 | $buff->total_page = $total_page; |
975 | 975 | $buff->page = $page; |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
978 | 978 | return $buff; |
979 | 979 | |
980 | - if($queryObject->usesClickCount()) |
|
980 | + if ($queryObject->usesClickCount()) |
|
981 | 981 | { |
982 | 982 | $update_query = $this->getClickCountQuery($queryObject); |
983 | 983 | $this->_executeUpdateAct($update_query); |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | $virtual_no = $total_count - $start_count; |
990 | 990 | $data = $this->_fetch($result, $virtual_no); |
991 | 991 | |
992 | - $buff = new Object (); |
|
992 | + $buff = new Object(); |
|
993 | 993 | $buff->total_count = $total_count; |
994 | 994 | $buff->total_page = $total_page; |
995 | 995 | $buff->page = $page; |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | else |
1000 | 1000 | { |
1001 | 1001 | $data = $this->_fetch($result); |
1002 | - $buff = new Object (); |
|
1002 | + $buff = new Object(); |
|
1003 | 1003 | $buff->data = $data; |
1004 | 1004 | } |
1005 | 1005 | return $buff; |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | function DBMssql($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if($auto_connect) { |
|
49 | + $this->_connect(); |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | /** |
@@ -123,8 +125,7 @@ discard block |
||
123 | 125 | { |
124 | 126 | return; |
125 | 127 | } |
126 | - } |
|
127 | - else |
|
128 | + } else |
|
128 | 129 | { |
129 | 130 | $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
130 | 131 | } |
@@ -145,8 +146,7 @@ discard block |
||
145 | 146 | if($point) |
146 | 147 | { |
147 | 148 | $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
148 | - } |
|
149 | - else |
|
149 | + } else |
|
150 | 150 | { |
151 | 151 | sqlsrv_rollback($connection); |
152 | 152 | } |
@@ -190,13 +190,11 @@ discard block |
||
190 | 190 | if(is_array($value)) |
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | - } |
|
194 | - else |
|
193 | + } else |
|
195 | 194 | { |
196 | 195 | $_param[] = $o->getUnescapedValue(); |
197 | 196 | } |
198 | - } |
|
199 | - else |
|
197 | + } else |
|
200 | 198 | { |
201 | 199 | $value = $o->getUnescapedValue(); |
202 | 200 | if(is_array($value)) |
@@ -205,8 +203,7 @@ discard block |
||
205 | 203 | { |
206 | 204 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 205 | } |
208 | - } |
|
209 | - else |
|
206 | + } else |
|
210 | 207 | { |
211 | 208 | $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
212 | 209 | } |
@@ -220,8 +217,7 @@ discard block |
||
220 | 217 | { |
221 | 218 | $args = $this->_getParametersByReference($_param); |
222 | 219 | $stmt = sqlsrv_prepare($connection, $query, $args); |
223 | - } |
|
224 | - else |
|
220 | + } else |
|
225 | 221 | { |
226 | 222 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 223 | } |
@@ -229,8 +225,7 @@ discard block |
||
229 | 225 | if(!$stmt) |
230 | 226 | { |
231 | 227 | $result = false; |
232 | - } |
|
233 | - else |
|
228 | + } else |
|
234 | 229 | { |
235 | 230 | $result = sqlsrv_execute($stmt); |
236 | 231 | } |
@@ -268,8 +263,7 @@ discard block |
||
268 | 263 | $value_arg[] = &$value_copy[0]; |
269 | 264 | $value_arg[] = $value_copy[1]; |
270 | 265 | $value_arg[] = $value_copy[2]; |
271 | - } |
|
272 | - else |
|
266 | + } else |
|
273 | 267 | { |
274 | 268 | $value_arg = $value; |
275 | 269 | } |
@@ -310,8 +304,7 @@ discard block |
||
310 | 304 | if($arrayIndexEndValue) |
311 | 305 | { |
312 | 306 | $output[$arrayIndexEndValue--] = $row; |
313 | - } |
|
314 | - else |
|
307 | + } else |
|
315 | 308 | { |
316 | 309 | $output[] = $row; |
317 | 310 | } |
@@ -322,8 +315,7 @@ discard block |
||
322 | 315 | if(isset($arrayIndexEndValue)) |
323 | 316 | { |
324 | 317 | return $output; |
325 | - } |
|
326 | - else |
|
318 | + } else |
|
327 | 319 | { |
328 | 320 | return $output[0]; |
329 | 321 | } |
@@ -393,8 +385,7 @@ discard block |
||
393 | 385 | if($size) |
394 | 386 | { |
395 | 387 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | - } |
|
397 | - else |
|
388 | + } else |
|
398 | 389 | { |
399 | 390 | $query .= sprintf(" %s ", $type); |
400 | 391 | } |
@@ -567,16 +558,14 @@ discard block |
||
567 | 558 | $table_name = $this->prefix . $table_name; |
568 | 559 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 560 | return $this->_query($query); |
570 | - } |
|
571 | - else |
|
561 | + } else |
|
572 | 562 | { |
573 | 563 | $table_name = $this->prefix . $table_name; |
574 | 564 | |
575 | 565 | if(!is_array($xml_obj->table->column)) |
576 | 566 | { |
577 | 567 | $columns[] = $xml_obj->table->column; |
578 | - } |
|
579 | - else |
|
568 | + } else |
|
580 | 569 | { |
581 | 570 | $columns = $xml_obj->table->column; |
582 | 571 | } |
@@ -603,12 +592,10 @@ discard block |
||
603 | 592 | if($primary_key) |
604 | 593 | { |
605 | 594 | $primary_list[] = $name; |
606 | - } |
|
607 | - else if($unique) |
|
595 | + } else if($unique) |
|
608 | 596 | { |
609 | 597 | $unique_list[$unique][] = $name; |
610 | - } |
|
611 | - else if($index) |
|
598 | + } else if($index) |
|
612 | 599 | { |
613 | 600 | $index_list[$index][] = $name; |
614 | 601 | } |
@@ -757,8 +744,7 @@ discard block |
||
757 | 744 | if($limit != '') |
758 | 745 | { |
759 | 746 | $select = $limit . ' ' . $select; |
760 | - } |
|
761 | - else |
|
747 | + } else |
|
762 | 748 | { |
763 | 749 | $select = 'SELECT ' . $select; |
764 | 750 | } |
@@ -824,8 +810,7 @@ discard block |
||
824 | 810 | if(!$where) |
825 | 811 | { |
826 | 812 | $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
827 | - } |
|
828 | - else |
|
813 | + } else |
|
829 | 814 | { |
830 | 815 | $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
831 | 816 | } |
@@ -859,8 +844,7 @@ discard block |
||
859 | 844 | if($this->isError()) |
860 | 845 | { |
861 | 846 | return $this->queryError($queryObject); |
862 | - } |
|
863 | - else |
|
847 | + } else |
|
864 | 848 | { |
865 | 849 | return $this->queryPageLimit($queryObject, $result, $connection); |
866 | 850 | } |
@@ -893,8 +877,7 @@ discard block |
||
893 | 877 | $buff->data = array(); |
894 | 878 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
895 | 879 | return $buff; |
896 | - } |
|
897 | - else |
|
880 | + } else |
|
898 | 881 | { |
899 | 882 | return; |
900 | 883 | } |
@@ -958,8 +941,7 @@ discard block |
||
958 | 941 | if($total_count) |
959 | 942 | { |
960 | 943 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | - } |
|
962 | - else |
|
944 | + } else |
|
963 | 945 | { |
964 | 946 | $total_page = 1; |
965 | 947 | } |
@@ -995,8 +977,7 @@ discard block |
||
995 | 977 | $buff->page = $page; |
996 | 978 | $buff->data = $data; |
997 | 979 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
998 | - } |
|
999 | - else |
|
980 | + } else |
|
1000 | 981 | { |
1001 | 982 | $data = $this->_fetch($result); |
1002 | 983 | $buff = new Object (); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * DB transaction start |
113 | 113 | * this method is private |
114 | - * @return boolean |
|
114 | + * @return null|boolean |
|
115 | 115 | */ |
116 | 116 | function _begin($transactionLevel = 0) |
117 | 117 | { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * this method is private |
171 | 171 | * @param string $query |
172 | 172 | * @param resource $connection |
173 | - * @return resource|boolean Returns a statement resource on success and FALSE if an error occurred. |
|
173 | + * @return resource Returns a statement resource on success and FALSE if an error occurred. |
|
174 | 174 | */ |
175 | 175 | function __query($query, $connection) |
176 | 176 | { |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param int $size column size |
376 | 376 | * @param string|int $default default value |
377 | 377 | * @param boolean $notnull not null status, default value is false |
378 | - * @return void |
|
378 | + * @return null|resource |
|
379 | 379 | */ |
380 | 380 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
381 | 381 | { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * Check column exist status of the table |
432 | 432 | * @param string $table_name table name |
433 | 433 | * @param string $column_name column name |
434 | - * @return boolean |
|
434 | + * @return null|boolean |
|
435 | 435 | */ |
436 | 436 | function isColumnExists($table_name, $column_name) |
437 | 437 | { |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * Check index status of the table |
496 | 496 | * @param string $table_name table name |
497 | 497 | * @param string $index_name index name |
498 | - * @return boolean |
|
498 | + * @return null|boolean |
|
499 | 499 | */ |
500 | 500 | function isIndexExists($table_name, $index_name) |
501 | 501 | { |
@@ -728,6 +728,7 @@ discard block |
||
728 | 728 | * Return select query string |
729 | 729 | * @param object $query |
730 | 730 | * @param boolean $with_values |
731 | + * @param resource $connection |
|
731 | 732 | * @return string |
732 | 733 | */ |
733 | 734 | function getSelectSql($query, $with_values = TRUE, $connection=NULL) |
@@ -839,7 +840,7 @@ discard block |
||
839 | 840 | * it supports a method as navigation |
840 | 841 | * @param Object $queryObject |
841 | 842 | * @param resource $connection |
842 | - * @return Object |
|
843 | + * @return Object|null |
|
843 | 844 | */ |
844 | 845 | function _executeSelectAct($queryObject, $connection = null) |
845 | 846 | { |
@@ -879,7 +880,7 @@ discard block |
||
879 | 880 | /** |
880 | 881 | * If have a error, return error object |
881 | 882 | * @param Object $queryObject |
882 | - * @return Object |
|
883 | + * @return Object|null |
|
883 | 884 | */ |
884 | 885 | function queryError($queryObject) |
885 | 886 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | function DBMysqli_innodb($auto_connect = TRUE) |
24 | 24 | { |
25 | 25 | $this->_setDBInfo(); |
26 | - if($auto_connect) $this->_connect(); |
|
26 | + if ($auto_connect) $this->_connect(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | function __connect($connection) |
45 | 45 | { |
46 | 46 | // Attempt to connect |
47 | - if($connection["db_port"]) |
|
47 | + if ($connection["db_port"]) |
|
48 | 48 | { |
49 | 49 | $result = @mysqli_connect($connection["db_hostname"] |
50 | 50 | , $connection["db_userid"] |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | , $connection["db_database"]); |
61 | 61 | } |
62 | 62 | $error = mysqli_connect_errno(); |
63 | - if($error) |
|
63 | + if ($error) |
|
64 | 64 | { |
65 | 65 | $this->setError($error, mysqli_connect_error()); |
66 | 66 | return; |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | { |
90 | 90 | $connection = $this->_getConnection('master'); |
91 | 91 | |
92 | - if(!$transactionLevel) |
|
92 | + if (!$transactionLevel) |
|
93 | 93 | { |
94 | 94 | $this->_query("begin"); |
95 | 95 | } |
96 | 96 | else |
97 | 97 | { |
98 | - $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
|
98 | + $this->_query("SAVEPOINT SP".$transactionLevel, $connection); |
|
99 | 99 | } |
100 | 100 | return true; |
101 | 101 | } |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | |
112 | 112 | $point = $transactionLevel - 1; |
113 | 113 | |
114 | - if($point) |
|
114 | + if ($point) |
|
115 | 115 | { |
116 | - $this->_query("ROLLBACK TO SP" . $point, $connection); |
|
116 | + $this->_query("ROLLBACK TO SP".$point, $connection); |
|
117 | 117 | } |
118 | 118 | else |
119 | 119 | { |
120 | 120 | mysqli_rollback($connection); |
121 | - $this->setQueryLog( array("query"=>"rollback") ); |
|
121 | + $this->setQueryLog(array("query"=>"rollback")); |
|
122 | 122 | } |
123 | 123 | return true; |
124 | 124 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | $connection = $this->_getConnection('master'); |
134 | 134 | mysqli_commit($connection); |
135 | - $this->setQueryLog( array("query"=>"commit") ); |
|
135 | + $this->setQueryLog(array("query"=>"commit")); |
|
136 | 136 | return true; |
137 | 137 | } |
138 | 138 | |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function addQuotes($string) |
147 | 147 | { |
148 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
148 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
149 | 149 | { |
150 | 150 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
151 | 151 | } |
152 | - if(!is_numeric($string)) |
|
152 | + if (!is_numeric($string)) |
|
153 | 153 | { |
154 | 154 | $connection = $this->_getConnection('master'); |
155 | 155 | $string = mysqli_escape_string($connection, $string); |
@@ -166,23 +166,23 @@ discard block |
||
166 | 166 | */ |
167 | 167 | function __query($query, $connection) |
168 | 168 | { |
169 | - if($this->use_prepared_statements == 'Y') |
|
169 | + if ($this->use_prepared_statements == 'Y') |
|
170 | 170 | { |
171 | 171 | // 1. Prepare query |
172 | 172 | $stmt = mysqli_prepare($connection, $query); |
173 | - if($stmt) |
|
173 | + if ($stmt) |
|
174 | 174 | { |
175 | 175 | $types = ''; |
176 | 176 | $params = array(); |
177 | 177 | $this->_prepareQueryParameters($types, $params); |
178 | 178 | |
179 | - if(!empty($params)) |
|
179 | + if (!empty($params)) |
|
180 | 180 | { |
181 | 181 | $args[0] = $stmt; |
182 | 182 | $args[1] = $types; |
183 | 183 | |
184 | 184 | $i = 2; |
185 | - foreach($params as $key => $param) |
|
185 | + foreach ($params as $key => $param) |
|
186 | 186 | { |
187 | 187 | $copy[$key] = $param; |
188 | 188 | $args[$i++] = &$copy[$key]; |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | |
191 | 191 | // 2. Bind parameters |
192 | 192 | $status = call_user_func_array('mysqli_stmt_bind_param', $args); |
193 | - if(!$status) |
|
193 | + if (!$status) |
|
194 | 194 | { |
195 | - $this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
|
195 | + $this->setError(-1, "Invalid arguments: $query".mysqli_error($connection).PHP_EOL.print_r($args, true)); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | // 3. Execute query |
200 | 200 | $status = mysqli_stmt_execute($stmt); |
201 | 201 | |
202 | - if(!$status) |
|
202 | + if (!$status) |
|
203 | 203 | { |
204 | - $this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
|
204 | + $this->setError(-1, "Prepared statement failed: $query".mysqli_error($connection).PHP_EOL.print_r($args, true)); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | // Return stmt for other processing - like retrieving resultset (_fetch) |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $result = mysqli_query($connection, $query); |
214 | 214 | // Error Check |
215 | 215 | $error = mysqli_error($connection); |
216 | - if($error) |
|
216 | + if ($error) |
|
217 | 217 | { |
218 | 218 | $this->setError(mysqli_errno($connection), $error); |
219 | 219 | } |
@@ -232,23 +232,23 @@ discard block |
||
232 | 232 | { |
233 | 233 | $types = ''; |
234 | 234 | $params = array(); |
235 | - if(!$this->param) |
|
235 | + if (!$this->param) |
|
236 | 236 | { |
237 | 237 | return; |
238 | 238 | } |
239 | 239 | |
240 | - foreach($this->param as $k => $o) |
|
240 | + foreach ($this->param as $k => $o) |
|
241 | 241 | { |
242 | 242 | $value = $o->getUnescapedValue(); |
243 | 243 | $type = $o->getType(); |
244 | 244 | |
245 | 245 | // Skip column names -> this should be concatenated to query string |
246 | - if($o->isColumnName()) |
|
246 | + if ($o->isColumnName()) |
|
247 | 247 | { |
248 | 248 | continue; |
249 | 249 | } |
250 | 250 | |
251 | - switch($type) |
|
251 | + switch ($type) |
|
252 | 252 | { |
253 | 253 | case 'number' : |
254 | 254 | $type = 'i'; |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | $type = 's'; |
261 | 261 | } |
262 | 262 | |
263 | - if(is_array($value)) |
|
263 | + if (is_array($value)) |
|
264 | 264 | { |
265 | - foreach($value as $v) |
|
265 | + foreach ($value as $v) |
|
266 | 266 | { |
267 | 267 | $params[] = $v; |
268 | 268 | $types .= $type; |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | */ |
285 | 285 | function _fetch($result, $arrayIndexEndValue = NULL) |
286 | 286 | { |
287 | - if($this->use_prepared_statements != 'Y') |
|
287 | + if ($this->use_prepared_statements != 'Y') |
|
288 | 288 | { |
289 | 289 | return parent::_fetch($result, $arrayIndexEndValue); |
290 | 290 | } |
291 | 291 | $output = array(); |
292 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
292 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
293 | 293 | { |
294 | 294 | return $output; |
295 | 295 | } |
@@ -305,25 +305,25 @@ discard block |
||
305 | 305 | * MYSQLI_TYPE for longtext is 252 |
306 | 306 | */ |
307 | 307 | $longtext_exists = false; |
308 | - foreach($fields as $field) |
|
308 | + foreach ($fields as $field) |
|
309 | 309 | { |
310 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
310 | + if (isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
311 | 311 | { |
312 | - $field->name = 'repeat_' . $field->name; |
|
312 | + $field->name = 'repeat_'.$field->name; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Array passed needs to contain references, not values |
316 | 316 | $row[$field->name] = ""; |
317 | 317 | $resultArray[$field->name] = &$row[$field->name]; |
318 | 318 | |
319 | - if($field->type == 252) |
|
319 | + if ($field->type == 252) |
|
320 | 320 | { |
321 | 321 | $longtext_exists = true; |
322 | 322 | } |
323 | 323 | } |
324 | 324 | $resultArray = array_merge(array($stmt), $resultArray); |
325 | 325 | |
326 | - if($longtext_exists) |
|
326 | + if ($longtext_exists) |
|
327 | 327 | { |
328 | 328 | mysqli_stmt_store_result($stmt); |
329 | 329 | } |
@@ -331,17 +331,17 @@ discard block |
||
331 | 331 | call_user_func_array('mysqli_stmt_bind_result', $resultArray); |
332 | 332 | |
333 | 333 | $rows = array(); |
334 | - while(mysqli_stmt_fetch($stmt)) |
|
334 | + while (mysqli_stmt_fetch($stmt)) |
|
335 | 335 | { |
336 | 336 | $resultObject = new stdClass(); |
337 | 337 | |
338 | - foreach($resultArray as $key => $value) |
|
338 | + foreach ($resultArray as $key => $value) |
|
339 | 339 | { |
340 | - if($key === 0) |
|
340 | + if ($key === 0) |
|
341 | 341 | { |
342 | 342 | continue; // Skip stmt object |
343 | 343 | } |
344 | - if(strpos($key, 'repeat_')) |
|
344 | + if (strpos($key, 'repeat_')) |
|
345 | 345 | { |
346 | 346 | $key = substr($key, 6); |
347 | 347 | } |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | |
354 | 354 | mysqli_stmt_close($stmt); |
355 | 355 | |
356 | - if($arrayIndexEndValue) |
|
356 | + if ($arrayIndexEndValue) |
|
357 | 357 | { |
358 | - foreach($rows as $row) |
|
358 | + foreach ($rows as $row) |
|
359 | 359 | { |
360 | 360 | $output[$arrayIndexEndValue--] = $row; |
361 | 361 | } |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | $output = $rows; |
366 | 366 | } |
367 | 367 | |
368 | - if(count($output) == 1) |
|
368 | + if (count($output) == 1) |
|
369 | 369 | { |
370 | - if(isset($arrayIndexEndValue)) |
|
370 | + if (isset($arrayIndexEndValue)) |
|
371 | 371 | { |
372 | 372 | return $output; |
373 | 373 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function _executeInsertAct($queryObject, $with_values = false) |
390 | 390 | { |
391 | - if($this->use_prepared_statements != 'Y') |
|
391 | + if ($this->use_prepared_statements != 'Y') |
|
392 | 392 | { |
393 | 393 | return parent::_executeInsertAct($queryObject); |
394 | 394 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | function _executeUpdateAct($queryObject, $with_values = false) |
408 | 408 | { |
409 | - if($this->use_prepared_statements != 'Y') |
|
409 | + if ($this->use_prepared_statements != 'Y') |
|
410 | 410 | { |
411 | 411 | return parent::_executeUpdateAct($queryObject); |
412 | 412 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | */ |
425 | 425 | function _executeDeleteAct($queryObject, $with_values = false) |
426 | 426 | { |
427 | - if($this->use_prepared_statements != 'Y') |
|
427 | + if ($this->use_prepared_statements != 'Y') |
|
428 | 428 | { |
429 | 429 | return parent::_executeDeleteAct($queryObject); |
430 | 430 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | function _executeSelectAct($queryObject, $connection = null, $with_values = false) |
447 | 447 | { |
448 | - if($this->use_prepared_statements != 'Y') |
|
448 | + if ($this->use_prepared_statements != 'Y') |
|
449 | 449 | { |
450 | 450 | return parent::_executeSelectAct($queryObject, $connection); |
451 | 451 | } |
@@ -503,13 +503,13 @@ discard block |
||
503 | 503 | $xml_obj = $oXml->parse($xml_doc); |
504 | 504 | // Create a table schema |
505 | 505 | $table_name = $xml_obj->table->attrs->name; |
506 | - if($this->isTableExists($table_name)) |
|
506 | + if ($this->isTableExists($table_name)) |
|
507 | 507 | { |
508 | 508 | return; |
509 | 509 | } |
510 | - $table_name = $this->prefix . $table_name; |
|
510 | + $table_name = $this->prefix.$table_name; |
|
511 | 511 | |
512 | - if(!is_array($xml_obj->table->column)) |
|
512 | + if (!is_array($xml_obj->table->column)) |
|
513 | 513 | { |
514 | 514 | $columns[] = $xml_obj->table->column; |
515 | 515 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | $columns = $xml_obj->table->column; |
519 | 519 | } |
520 | 520 | |
521 | - foreach($columns as $column) |
|
521 | + foreach ($columns as $column) |
|
522 | 522 | { |
523 | 523 | $name = $column->attrs->name; |
524 | 524 | $type = $column->attrs->type; |
@@ -530,47 +530,47 @@ discard block |
||
530 | 530 | $default = $column->attrs->default; |
531 | 531 | $auto_increment = $column->attrs->auto_increment; |
532 | 532 | |
533 | - $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
533 | + $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
534 | 534 | |
535 | - if($primary_key) |
|
535 | + if ($primary_key) |
|
536 | 536 | { |
537 | 537 | $primary_list[] = $name; |
538 | 538 | } |
539 | - else if($unique) |
|
539 | + else if ($unique) |
|
540 | 540 | { |
541 | 541 | $unique_list[$unique][] = $name; |
542 | 542 | } |
543 | - else if($index) |
|
543 | + else if ($index) |
|
544 | 544 | { |
545 | 545 | $index_list[$index][] = $name; |
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
549 | - if(count($primary_list)) |
|
549 | + if (count($primary_list)) |
|
550 | 550 | { |
551 | - $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`'); |
|
551 | + $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list, '`,`').'`'); |
|
552 | 552 | } |
553 | 553 | |
554 | - if(count($unique_list)) |
|
554 | + if (count($unique_list)) |
|
555 | 555 | { |
556 | - foreach($unique_list as $key => $val) |
|
556 | + foreach ($unique_list as $key => $val) |
|
557 | 557 | { |
558 | - $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
558 | + $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
562 | - if(count($index_list)) |
|
562 | + if (count($index_list)) |
|
563 | 563 | { |
564 | - foreach($index_list as $key => $val) |
|
564 | + foreach ($index_list as $key => $val) |
|
565 | 565 | { |
566 | - $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
566 | + $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
570 | 570 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci"); |
571 | 571 | |
572 | 572 | $output = $this->_query($schema); |
573 | - if(!$output) |
|
573 | + if (!$output) |
|
574 | 574 | { |
575 | 575 | return false; |
576 | 576 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | function DBMysqli_innodb($auto_connect = TRUE) |
24 | 24 | { |
25 | 25 | $this->_setDBInfo(); |
26 | - if($auto_connect) $this->_connect(); |
|
26 | + if($auto_connect) { |
|
27 | + $this->_connect(); |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | /** |
@@ -51,8 +53,7 @@ discard block |
||
51 | 53 | , $connection["db_password"] |
52 | 54 | , $connection["db_database"] |
53 | 55 | , $connection["db_port"]); |
54 | - } |
|
55 | - else |
|
56 | + } else |
|
56 | 57 | { |
57 | 58 | $result = @mysqli_connect($connection["db_hostname"] |
58 | 59 | , $connection["db_userid"] |
@@ -92,8 +93,7 @@ discard block |
||
92 | 93 | if(!$transactionLevel) |
93 | 94 | { |
94 | 95 | $this->_query("begin"); |
95 | - } |
|
96 | - else |
|
96 | + } else |
|
97 | 97 | { |
98 | 98 | $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
99 | 99 | } |
@@ -114,8 +114,7 @@ discard block |
||
114 | 114 | if($point) |
115 | 115 | { |
116 | 116 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
117 | - } |
|
118 | - else |
|
117 | + } else |
|
119 | 118 | { |
120 | 119 | mysqli_rollback($connection); |
121 | 120 | $this->setQueryLog( array("query"=>"rollback") ); |
@@ -267,8 +266,7 @@ discard block |
||
267 | 266 | $params[] = $v; |
268 | 267 | $types .= $type; |
269 | 268 | } |
270 | - } |
|
271 | - else |
|
269 | + } else |
|
272 | 270 | { |
273 | 271 | $params[] = $value; |
274 | 272 | $types .= $type; |
@@ -307,10 +305,12 @@ discard block |
||
307 | 305 | $longtext_exists = false; |
308 | 306 | foreach($fields as $field) |
309 | 307 | { |
310 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
308 | + if(isset($resultArray[$field->name])) { |
|
309 | + // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
311 | 310 | { |
312 | 311 | $field->name = 'repeat_' . $field->name; |
313 | 312 | } |
313 | + } |
|
314 | 314 | |
315 | 315 | // Array passed needs to contain references, not values |
316 | 316 | $row[$field->name] = ""; |
@@ -359,8 +359,7 @@ discard block |
||
359 | 359 | { |
360 | 360 | $output[$arrayIndexEndValue--] = $row; |
361 | 361 | } |
362 | - } |
|
363 | - else |
|
362 | + } else |
|
364 | 363 | { |
365 | 364 | $output = $rows; |
366 | 365 | } |
@@ -370,8 +369,7 @@ discard block |
||
370 | 369 | if(isset($arrayIndexEndValue)) |
371 | 370 | { |
372 | 371 | return $output; |
373 | - } |
|
374 | - else |
|
372 | + } else |
|
375 | 373 | { |
376 | 374 | return $output[0]; |
377 | 375 | } |
@@ -512,8 +510,7 @@ discard block |
||
512 | 510 | if(!is_array($xml_obj->table->column)) |
513 | 511 | { |
514 | 512 | $columns[] = $xml_obj->table->column; |
515 | - } |
|
516 | - else |
|
513 | + } else |
|
517 | 514 | { |
518 | 515 | $columns = $xml_obj->table->column; |
519 | 516 | } |
@@ -535,12 +532,10 @@ discard block |
||
535 | 532 | if($primary_key) |
536 | 533 | { |
537 | 534 | $primary_list[] = $name; |
538 | - } |
|
539 | - else if($unique) |
|
535 | + } else if($unique) |
|
540 | 536 | { |
541 | 537 | $unique_list[$unique][] = $name; |
542 | - } |
|
543 | - else if($index) |
|
538 | + } else if($index) |
|
544 | 539 | { |
545 | 540 | $index_list[$index][] = $name; |
546 | 541 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | function DBMysql($auto_connect = TRUE) |
47 | 47 | { |
48 | 48 | $this->_setDBInfo(); |
49 | - if($auto_connect) $this->_connect(); |
|
49 | + if ($auto_connect) $this->_connect(); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -67,32 +67,32 @@ discard block |
||
67 | 67 | function __connect($connection) |
68 | 68 | { |
69 | 69 | // Ignore if no DB information exists |
70 | - if(strpos($connection["db_hostname"], ':') === false && $connection["db_port"]) |
|
70 | + if (strpos($connection["db_hostname"], ':') === false && $connection["db_port"]) |
|
71 | 71 | { |
72 | - $connection["db_hostname"] .= ':' . $connection["db_port"]; |
|
72 | + $connection["db_hostname"] .= ':'.$connection["db_port"]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Attempt to connect |
76 | 76 | $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]); |
77 | - if(!$result) |
|
77 | + if (!$result) |
|
78 | 78 | { |
79 | 79 | exit('XE cannot connect to DB.'); |
80 | 80 | } |
81 | 81 | |
82 | - if(mysql_error()) |
|
82 | + if (mysql_error()) |
|
83 | 83 | { |
84 | 84 | $this->setError(mysql_errno(), mysql_error()); |
85 | 85 | return; |
86 | 86 | } |
87 | 87 | // Error appears if the version is lower than 4.1 |
88 | - if(version_compare(mysql_get_server_info($result), '4.1', '<')) |
|
88 | + if (version_compare(mysql_get_server_info($result), '4.1', '<')) |
|
89 | 89 | { |
90 | - $this->setError(-1, 'XE cannot be installed under the version of mysql 4.1. Current mysql version is ' . mysql_get_server_info()); |
|
90 | + $this->setError(-1, 'XE cannot be installed under the version of mysql 4.1. Current mysql version is '.mysql_get_server_info()); |
|
91 | 91 | return; |
92 | 92 | } |
93 | 93 | // select db |
94 | 94 | @mysql_select_db($connection["db_database"], $result); |
95 | - if(mysql_error()) |
|
95 | + if (mysql_error()) |
|
96 | 96 | { |
97 | 97 | $this->setError(mysql_errno(), mysql_error()); |
98 | 98 | return; |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function addQuotes($string) |
133 | 133 | { |
134 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
134 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
135 | 135 | { |
136 | 136 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
137 | 137 | } |
138 | - if(!is_numeric($string)) |
|
138 | + if (!is_numeric($string)) |
|
139 | 139 | { |
140 | 140 | $string = @mysql_real_escape_string($string); |
141 | 141 | } |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function __query($query, $connection) |
183 | 183 | { |
184 | - if(!$connection) |
|
184 | + if (!$connection) |
|
185 | 185 | { |
186 | 186 | exit('XE cannot handle DB connection.'); |
187 | 187 | } |
188 | 188 | // Run the query statement |
189 | 189 | $result = mysql_query($query, $connection); |
190 | 190 | // Error Check |
191 | - if(mysql_error($connection)) |
|
191 | + if (mysql_error($connection)) |
|
192 | 192 | { |
193 | 193 | $this->setError(mysql_errno($connection), mysql_error($connection)); |
194 | 194 | } |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | function _fetch($result, $arrayIndexEndValue = NULL) |
206 | 206 | { |
207 | 207 | $output = array(); |
208 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
208 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
209 | 209 | { |
210 | 210 | return $output; |
211 | 211 | } |
212 | - while($tmp = $this->db_fetch_object($result)) |
|
212 | + while ($tmp = $this->db_fetch_object($result)) |
|
213 | 213 | { |
214 | - if($arrayIndexEndValue) |
|
214 | + if ($arrayIndexEndValue) |
|
215 | 215 | { |
216 | 216 | $output[$arrayIndexEndValue--] = $tmp; |
217 | 217 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | $output[] = $tmp; |
221 | 221 | } |
222 | 222 | } |
223 | - if(count($output) == 1) |
|
223 | + if (count($output) == 1) |
|
224 | 224 | { |
225 | - if(isset($arrayIndexEndValue)) |
|
225 | + if (isset($arrayIndexEndValue)) |
|
226 | 226 | { |
227 | 227 | return $output; |
228 | 228 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $query = sprintf("insert into `%ssequence` (seq) values ('0')", $this->prefix); |
246 | 246 | $this->_query($query); |
247 | 247 | $sequence = $this->db_insert_id(); |
248 | - if($sequence % 10000 == 0) |
|
248 | + if ($sequence % 10000 == 0) |
|
249 | 249 | { |
250 | 250 | $query = sprintf("delete from `%ssequence` where seq < %d", $this->prefix, $sequence); |
251 | 251 | $this->_query($query); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $query = sprintf("select password('%s') as password, old_password('%s') as old_password", $this->addQuotes($password), $this->addQuotes($password)); |
266 | 266 | $result = $this->_query($query); |
267 | 267 | $tmp = $this->_fetch($result); |
268 | - if($tmp->password === $saved_password || $tmp->old_password === $saved_password) |
|
268 | + if ($tmp->password === $saved_password || $tmp->old_password === $saved_password) |
|
269 | 269 | { |
270 | 270 | return true; |
271 | 271 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $query = sprintf("show tables like '%s%s'", $this->prefix, $this->addQuotes($target_name)); |
283 | 283 | $result = $this->_query($query); |
284 | 284 | $tmp = $this->_fetch($result); |
285 | - if(!$tmp) |
|
285 | + if (!$tmp) |
|
286 | 286 | { |
287 | 287 | return false; |
288 | 288 | } |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
303 | 303 | { |
304 | 304 | $type = $this->column_type[$type]; |
305 | - if(strtoupper($type) == 'INTEGER') |
|
305 | + if (strtoupper($type) == 'INTEGER') |
|
306 | 306 | { |
307 | 307 | $size = ''; |
308 | 308 | } |
309 | 309 | |
310 | 310 | $query = sprintf("alter table `%s%s` add `%s` ", $this->prefix, $table_name, $column_name); |
311 | - if($size) |
|
311 | + if ($size) |
|
312 | 312 | { |
313 | 313 | $query .= sprintf(" %s(%s) ", $type, $size); |
314 | 314 | } |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | { |
317 | 317 | $query .= sprintf(" %s ", $type); |
318 | 318 | } |
319 | - if(isset($default)) |
|
319 | + if (isset($default)) |
|
320 | 320 | { |
321 | 321 | $query .= sprintf(" default '%s' ", $default); |
322 | 322 | } |
323 | - if($notnull) |
|
323 | + if ($notnull) |
|
324 | 324 | { |
325 | 325 | $query .= " not null "; |
326 | 326 | } |
@@ -350,18 +350,18 @@ discard block |
||
350 | 350 | { |
351 | 351 | $query = sprintf("show fields from `%s%s`", $this->prefix, $table_name); |
352 | 352 | $result = $this->_query($query); |
353 | - if($this->isError()) |
|
353 | + if ($this->isError()) |
|
354 | 354 | { |
355 | 355 | return; |
356 | 356 | } |
357 | 357 | $output = $this->_fetch($result); |
358 | - if($output) |
|
358 | + if ($output) |
|
359 | 359 | { |
360 | 360 | $column_name = strtolower($column_name); |
361 | - foreach($output as $key => $val) |
|
361 | + foreach ($output as $key => $val) |
|
362 | 362 | { |
363 | 363 | $name = strtolower($val->Field); |
364 | - if($column_name == $name) |
|
364 | + if ($column_name == $name) |
|
365 | 365 | { |
366 | 366 | return true; |
367 | 367 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
384 | 384 | { |
385 | - if(!is_array($target_columns)) |
|
385 | + if (!is_array($target_columns)) |
|
386 | 386 | { |
387 | 387 | $target_columns = array($target_columns); |
388 | 388 | } |
@@ -415,23 +415,23 @@ discard block |
||
415 | 415 | //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name); |
416 | 416 | $query = sprintf("show indexes from `%s%s`", $this->prefix, $table_name); |
417 | 417 | $result = $this->_query($query); |
418 | - if($this->isError()) |
|
418 | + if ($this->isError()) |
|
419 | 419 | { |
420 | 420 | return; |
421 | 421 | } |
422 | 422 | $output = $this->_fetch($result); |
423 | - if(!$output) |
|
423 | + if (!$output) |
|
424 | 424 | { |
425 | 425 | return; |
426 | 426 | } |
427 | - if(!is_array($output)) |
|
427 | + if (!is_array($output)) |
|
428 | 428 | { |
429 | 429 | $output = array($output); |
430 | 430 | } |
431 | 431 | |
432 | - for($i = 0; $i < count($output); $i++) |
|
432 | + for ($i = 0; $i < count($output); $i++) |
|
433 | 433 | { |
434 | - if($output[$i]->Key_name == $index_name) |
|
434 | + if ($output[$i]->Key_name == $index_name) |
|
435 | 435 | { |
436 | 436 | return true; |
437 | 437 | } |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | function createTableByXmlFile($file_name) |
458 | 458 | { |
459 | - if(!file_exists($file_name)) |
|
459 | + if (!file_exists($file_name)) |
|
460 | 460 | { |
461 | 461 | return; |
462 | 462 | } |
@@ -481,13 +481,13 @@ discard block |
||
481 | 481 | $xml_obj = $oXml->parse($xml_doc); |
482 | 482 | // Create a table schema |
483 | 483 | $table_name = $xml_obj->table->attrs->name; |
484 | - if($this->isTableExists($table_name)) |
|
484 | + if ($this->isTableExists($table_name)) |
|
485 | 485 | { |
486 | 486 | return; |
487 | 487 | } |
488 | - $table_name = $this->prefix . $table_name; |
|
488 | + $table_name = $this->prefix.$table_name; |
|
489 | 489 | |
490 | - if(!is_array($xml_obj->table->column)) |
|
490 | + if (!is_array($xml_obj->table->column)) |
|
491 | 491 | { |
492 | 492 | $columns[] = $xml_obj->table->column; |
493 | 493 | } |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | $unique_list = array(); |
501 | 501 | $index_list = array(); |
502 | 502 | |
503 | - foreach($columns as $column) |
|
503 | + foreach ($columns as $column) |
|
504 | 504 | { |
505 | 505 | $name = $column->attrs->name; |
506 | 506 | $type = $column->attrs->type; |
@@ -512,47 +512,47 @@ discard block |
||
512 | 512 | $default = $column->attrs->default; |
513 | 513 | $auto_increment = $column->attrs->auto_increment; |
514 | 514 | |
515 | - $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
515 | + $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
516 | 516 | |
517 | - if($primary_key) |
|
517 | + if ($primary_key) |
|
518 | 518 | { |
519 | 519 | $primary_list[] = $name; |
520 | 520 | } |
521 | - else if($unique) |
|
521 | + else if ($unique) |
|
522 | 522 | { |
523 | 523 | $unique_list[$unique][] = $name; |
524 | 524 | } |
525 | - else if($index) |
|
525 | + else if ($index) |
|
526 | 526 | { |
527 | 527 | $index_list[$index][] = $name; |
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - if(count($primary_list)) |
|
531 | + if (count($primary_list)) |
|
532 | 532 | { |
533 | - $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`'); |
|
533 | + $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list, '`,`').'`'); |
|
534 | 534 | } |
535 | 535 | |
536 | - if(count($unique_list)) |
|
536 | + if (count($unique_list)) |
|
537 | 537 | { |
538 | - foreach($unique_list as $key => $val) |
|
538 | + foreach ($unique_list as $key => $val) |
|
539 | 539 | { |
540 | - $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
540 | + $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | - if(count($index_list)) |
|
544 | + if (count($index_list)) |
|
545 | 545 | { |
546 | - foreach($index_list as $key => $val) |
|
546 | + foreach ($index_list as $key => $val) |
|
547 | 547 | { |
548 | - $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
548 | + $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | 552 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci"); |
553 | 553 | |
554 | 554 | $output = $this->_query($schema); |
555 | - if(!$output) |
|
555 | + if (!$output) |
|
556 | 556 | return false; |
557 | 557 | } |
558 | 558 | |
@@ -565,8 +565,8 @@ discard block |
||
565 | 565 | function _executeInsertAct($queryObject, $with_values = true) |
566 | 566 | { |
567 | 567 | $query = $this->getInsertSql($queryObject, $with_values, true); |
568 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
569 | - if(is_a($query, 'Object')) |
|
568 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
569 | + if (is_a($query, 'Object')) |
|
570 | 570 | { |
571 | 571 | return; |
572 | 572 | } |
@@ -582,13 +582,13 @@ discard block |
||
582 | 582 | function _executeUpdateAct($queryObject, $with_values = true) |
583 | 583 | { |
584 | 584 | $query = $this->getUpdateSql($queryObject, $with_values, true); |
585 | - if(is_a($query, 'Object')) |
|
585 | + if (is_a($query, 'Object')) |
|
586 | 586 | { |
587 | - if(!$query->toBool()) return $query; |
|
587 | + if (!$query->toBool()) return $query; |
|
588 | 588 | else return; |
589 | 589 | } |
590 | 590 | |
591 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
591 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
592 | 592 | |
593 | 593 | |
594 | 594 | return $this->_query($query); |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | function _executeDeleteAct($queryObject, $with_values = true) |
604 | 604 | { |
605 | 605 | $query = $this->getDeleteSql($queryObject, $with_values, true); |
606 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
607 | - if(is_a($query, 'Object')) |
|
606 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
607 | + if (is_a($query, 'Object')) |
|
608 | 608 | { |
609 | 609 | return; |
610 | 610 | } |
@@ -624,30 +624,30 @@ discard block |
||
624 | 624 | { |
625 | 625 | $limit = $queryObject->getLimit(); |
626 | 626 | $result = NULL; |
627 | - if($limit && $limit->isPageHandler()) |
|
627 | + if ($limit && $limit->isPageHandler()) |
|
628 | 628 | { |
629 | 629 | return $this->queryPageLimit($queryObject, $result, $connection, $with_values); |
630 | 630 | } |
631 | 631 | else |
632 | 632 | { |
633 | 633 | $query = $this->getSelectSql($queryObject, $with_values); |
634 | - if(is_a($query, 'Object')) |
|
634 | + if (is_a($query, 'Object')) |
|
635 | 635 | { |
636 | 636 | return; |
637 | 637 | } |
638 | - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; |
|
638 | + $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $queryObject->queryID) : ''; |
|
639 | 639 | |
640 | 640 | $result = $this->_query($query, $connection); |
641 | - if($this->isError()) |
|
641 | + if ($this->isError()) |
|
642 | 642 | { |
643 | 643 | return $this->queryError($queryObject); |
644 | 644 | } |
645 | 645 | |
646 | 646 | $data = $this->_fetch($result); |
647 | - $buff = new Object (); |
|
647 | + $buff = new Object(); |
|
648 | 648 | $buff->data = $data; |
649 | 649 | |
650 | - if($queryObject->usesClickCount()) |
|
650 | + if ($queryObject->usesClickCount()) |
|
651 | 651 | { |
652 | 652 | $update_query = $this->getClickCountQuery($queryObject); |
653 | 653 | $this->_executeUpdateAct($update_query, $with_values); |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | function queryError($queryObject) |
709 | 709 | { |
710 | 710 | $limit = $queryObject->getLimit(); |
711 | - if($limit && $limit->isPageHandler()) |
|
711 | + if ($limit && $limit->isPageHandler()) |
|
712 | 712 | { |
713 | - $buff = new Object (); |
|
713 | + $buff = new Object(); |
|
714 | 714 | $buff->total_count = 0; |
715 | 715 | $buff->total_page = 0; |
716 | 716 | $buff->page = 1; |
@@ -737,48 +737,48 @@ discard block |
||
737 | 737 | $limit = $queryObject->getLimit(); |
738 | 738 | // Total count |
739 | 739 | $temp_where = $queryObject->getWhereString($with_values, false); |
740 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
740 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
741 | 741 | |
742 | 742 | // Check for distinct query and if found update count query structure |
743 | 743 | $temp_select = $queryObject->getSelectString($with_values); |
744 | 744 | $uses_distinct = stripos($temp_select, "distinct") !== false; |
745 | 745 | $uses_groupby = $queryObject->getGroupByString() != ''; |
746 | - if($uses_distinct || $uses_groupby) |
|
746 | + if ($uses_distinct || $uses_groupby) |
|
747 | 747 | { |
748 | 748 | $count_query = sprintf('select %s %s %s %s' |
749 | 749 | , $temp_select == '*' ? '1' : $temp_select |
750 | - , 'FROM ' . $queryObject->getFromString($with_values) |
|
751 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
752 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
750 | + , 'FROM '.$queryObject->getFromString($with_values) |
|
751 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
752 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
753 | 753 | ); |
754 | 754 | |
755 | 755 | // If query uses grouping or distinct, count from original select |
756 | 756 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
757 | 757 | } |
758 | 758 | |
759 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; |
|
759 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $queryObject->queryID) : ''; |
|
760 | 760 | $result_count = $this->_query($count_query, $connection); |
761 | 761 | $count_output = $this->_fetch($result_count); |
762 | 762 | $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL); |
763 | 763 | |
764 | 764 | $list_count = $limit->list_count->getValue(); |
765 | - if(!$list_count) |
|
765 | + if (!$list_count) |
|
766 | 766 | { |
767 | 767 | $list_count = 20; |
768 | 768 | } |
769 | 769 | $page_count = $limit->page_count->getValue(); |
770 | - if(!$page_count) |
|
770 | + if (!$page_count) |
|
771 | 771 | { |
772 | 772 | $page_count = 10; |
773 | 773 | } |
774 | 774 | $page = $limit->page->getValue(); |
775 | - if(!$page || $page < 1) |
|
775 | + if (!$page || $page < 1) |
|
776 | 776 | { |
777 | 777 | $page = 1; |
778 | 778 | } |
779 | 779 | |
780 | 780 | // total pages |
781 | - if($total_count) |
|
781 | + if ($total_count) |
|
782 | 782 | { |
783 | 783 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
784 | 784 | } |
@@ -788,10 +788,10 @@ discard block |
||
788 | 788 | } |
789 | 789 | |
790 | 790 | // check the page variables |
791 | - if($page > $total_page) |
|
791 | + if ($page > $total_page) |
|
792 | 792 | { |
793 | 793 | // If requested page is bigger than total number of pages, return empty list |
794 | - $buff = new Object (); |
|
794 | + $buff = new Object(); |
|
795 | 795 | $buff->total_count = $total_count; |
796 | 796 | $buff->total_page = $total_page; |
797 | 797 | $buff->page = $page; |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | |
804 | 804 | $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count); |
805 | 805 | |
806 | - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
806 | + $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
807 | 807 | $result = $this->_query($query, $connection); |
808 | - if($this->isError()) |
|
808 | + if ($this->isError()) |
|
809 | 809 | { |
810 | 810 | return $this->queryError($queryObject); |
811 | 811 | } |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | $virtual_no = $total_count - ($page - 1) * $list_count; |
814 | 814 | $data = $this->_fetch($result, $virtual_no); |
815 | 815 | |
816 | - $buff = new Object (); |
|
816 | + $buff = new Object(); |
|
817 | 817 | $buff->total_count = $total_count; |
818 | 818 | $buff->total_page = $total_page; |
819 | 819 | $buff->page = $page; |
@@ -833,44 +833,44 @@ discard block |
||
833 | 833 | function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) |
834 | 834 | { |
835 | 835 | $select = $query->getSelectString($with_values); |
836 | - if($select == '') |
|
836 | + if ($select == '') |
|
837 | 837 | { |
838 | 838 | return new Object(-1, "Invalid query"); |
839 | 839 | } |
840 | - $select = 'SELECT ' . $select; |
|
840 | + $select = 'SELECT '.$select; |
|
841 | 841 | |
842 | 842 | $from = $query->getFromString($with_values); |
843 | - if($from == '') |
|
843 | + if ($from == '') |
|
844 | 844 | { |
845 | 845 | return new Object(-1, "Invalid query"); |
846 | 846 | } |
847 | - $from = ' FROM ' . $from; |
|
847 | + $from = ' FROM '.$from; |
|
848 | 848 | |
849 | 849 | $where = $query->getWhereString($with_values); |
850 | - if($where != '') |
|
850 | + if ($where != '') |
|
851 | 851 | { |
852 | - $where = ' WHERE ' . $where; |
|
852 | + $where = ' WHERE '.$where; |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | $groupBy = $query->getGroupByString(); |
856 | - if($groupBy != '') |
|
856 | + if ($groupBy != '') |
|
857 | 857 | { |
858 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
858 | + $groupBy = ' GROUP BY '.$groupBy; |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | $orderBy = $query->getOrderByString(); |
862 | - if($orderBy != '') |
|
862 | + if ($orderBy != '') |
|
863 | 863 | { |
864 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
864 | + $orderBy = ' ORDER BY '.$orderBy; |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | $limit = $query->getLimitString(); |
868 | - if($limit != '') |
|
868 | + if ($limit != '') |
|
869 | 869 | { |
870 | 870 | $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count); |
871 | 871 | } |
872 | 872 | |
873 | - return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
873 | + return $select.' '.$from.' '.$where.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | } |
@@ -46,7 +46,9 @@ discard block |
||
46 | 46 | function DBMysql($auto_connect = TRUE) |
47 | 47 | { |
48 | 48 | $this->_setDBInfo(); |
49 | - if($auto_connect) $this->_connect(); |
|
49 | + if($auto_connect) { |
|
50 | + $this->_connect(); |
|
51 | + } |
|
50 | 52 | } |
51 | 53 | |
52 | 54 | /** |
@@ -214,8 +216,7 @@ discard block |
||
214 | 216 | if($arrayIndexEndValue) |
215 | 217 | { |
216 | 218 | $output[$arrayIndexEndValue--] = $tmp; |
217 | - } |
|
218 | - else |
|
219 | + } else |
|
219 | 220 | { |
220 | 221 | $output[] = $tmp; |
221 | 222 | } |
@@ -225,8 +226,7 @@ discard block |
||
225 | 226 | if(isset($arrayIndexEndValue)) |
226 | 227 | { |
227 | 228 | return $output; |
228 | - } |
|
229 | - else |
|
229 | + } else |
|
230 | 230 | { |
231 | 231 | return $output[0]; |
232 | 232 | } |
@@ -311,8 +311,7 @@ discard block |
||
311 | 311 | if($size) |
312 | 312 | { |
313 | 313 | $query .= sprintf(" %s(%s) ", $type, $size); |
314 | - } |
|
315 | - else |
|
314 | + } else |
|
316 | 315 | { |
317 | 316 | $query .= sprintf(" %s ", $type); |
318 | 317 | } |
@@ -490,8 +489,7 @@ discard block |
||
490 | 489 | if(!is_array($xml_obj->table->column)) |
491 | 490 | { |
492 | 491 | $columns[] = $xml_obj->table->column; |
493 | - } |
|
494 | - else |
|
492 | + } else |
|
495 | 493 | { |
496 | 494 | $columns = $xml_obj->table->column; |
497 | 495 | } |
@@ -517,12 +515,10 @@ discard block |
||
517 | 515 | if($primary_key) |
518 | 516 | { |
519 | 517 | $primary_list[] = $name; |
520 | - } |
|
521 | - else if($unique) |
|
518 | + } else if($unique) |
|
522 | 519 | { |
523 | 520 | $unique_list[$unique][] = $name; |
524 | - } |
|
525 | - else if($index) |
|
521 | + } else if($index) |
|
526 | 522 | { |
527 | 523 | $index_list[$index][] = $name; |
528 | 524 | } |
@@ -552,8 +548,9 @@ discard block |
||
552 | 548 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci"); |
553 | 549 | |
554 | 550 | $output = $this->_query($schema); |
555 | - if(!$output) |
|
556 | - return false; |
|
551 | + if(!$output) { |
|
552 | + return false; |
|
553 | + } |
|
557 | 554 | } |
558 | 555 | |
559 | 556 | /** |
@@ -584,8 +581,11 @@ discard block |
||
584 | 581 | $query = $this->getUpdateSql($queryObject, $with_values, true); |
585 | 582 | if(is_a($query, 'Object')) |
586 | 583 | { |
587 | - if(!$query->toBool()) return $query; |
|
588 | - else return; |
|
584 | + if(!$query->toBool()) { |
|
585 | + return $query; |
|
586 | + } else { |
|
587 | + return; |
|
588 | + } |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
@@ -627,8 +627,7 @@ discard block |
||
627 | 627 | if($limit && $limit->isPageHandler()) |
628 | 628 | { |
629 | 629 | return $this->queryPageLimit($queryObject, $result, $connection, $with_values); |
630 | - } |
|
631 | - else |
|
630 | + } else |
|
632 | 631 | { |
633 | 632 | $query = $this->getSelectSql($queryObject, $with_values); |
634 | 633 | if(is_a($query, 'Object')) |
@@ -717,8 +716,7 @@ discard block |
||
717 | 716 | $buff->data = array(); |
718 | 717 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
719 | 718 | return $buff; |
720 | - } |
|
721 | - else |
|
719 | + } else |
|
722 | 720 | { |
723 | 721 | return; |
724 | 722 | } |
@@ -781,8 +779,7 @@ discard block |
||
781 | 779 | if($total_count) |
782 | 780 | { |
783 | 781 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
784 | - } |
|
785 | - else |
|
782 | + } else |
|
786 | 783 | { |
787 | 784 | $total_page = 1; |
788 | 785 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | function DBMysql_innodb($auto_connect = TRUE) |
24 | 24 | { |
25 | 25 | $this->_setDBInfo(); |
26 | - if($auto_connect) $this->_connect(); |
|
26 | + if ($auto_connect) $this->_connect(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | { |
56 | 56 | $connection = $this->_getConnection('master'); |
57 | 57 | |
58 | - if(!$transactionLevel) |
|
58 | + if (!$transactionLevel) |
|
59 | 59 | { |
60 | 60 | $this->_query("START TRANSACTION", $connection); |
61 | 61 | } |
62 | 62 | else |
63 | 63 | { |
64 | - $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
|
64 | + $this->_query("SAVEPOINT SP".$transactionLevel, $connection); |
|
65 | 65 | } |
66 | 66 | return true; |
67 | 67 | } |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | |
78 | 78 | $point = $transactionLevel - 1; |
79 | 79 | |
80 | - if($point) |
|
80 | + if ($point) |
|
81 | 81 | { |
82 | - $this->_query("ROLLBACK TO SP" . $point, $connection); |
|
82 | + $this->_query("ROLLBACK TO SP".$point, $connection); |
|
83 | 83 | } |
84 | 84 | else |
85 | 85 | { |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function __query($query, $connection) |
111 | 111 | { |
112 | - if(!$connection) |
|
112 | + if (!$connection) |
|
113 | 113 | { |
114 | 114 | exit('XE cannot handle DB connection.'); |
115 | 115 | } |
116 | 116 | // Run the query statement |
117 | 117 | $result = @mysql_query($query, $connection); |
118 | 118 | // Error Check |
119 | - if(mysql_error($connection)) |
|
119 | + if (mysql_error($connection)) |
|
120 | 120 | { |
121 | 121 | $this->setError(mysql_errno($connection), mysql_error($connection)); |
122 | 122 | } |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | $xml_obj = $oXml->parse($xml_doc); |
141 | 141 | // Create a table schema |
142 | 142 | $table_name = $xml_obj->table->attrs->name; |
143 | - if($this->isTableExists($table_name)) |
|
143 | + if ($this->isTableExists($table_name)) |
|
144 | 144 | { |
145 | 145 | return; |
146 | 146 | } |
147 | - $table_name = $this->prefix . $table_name; |
|
147 | + $table_name = $this->prefix.$table_name; |
|
148 | 148 | |
149 | - if(!is_array($xml_obj->table->column)) |
|
149 | + if (!is_array($xml_obj->table->column)) |
|
150 | 150 | { |
151 | 151 | $columns[] = $xml_obj->table->column; |
152 | 152 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $columns = $xml_obj->table->column; |
156 | 156 | } |
157 | 157 | |
158 | - foreach($columns as $column) |
|
158 | + foreach ($columns as $column) |
|
159 | 159 | { |
160 | 160 | $name = $column->attrs->name; |
161 | 161 | $type = $column->attrs->type; |
@@ -167,47 +167,47 @@ discard block |
||
167 | 167 | $default = $column->attrs->default; |
168 | 168 | $auto_increment = $column->attrs->auto_increment; |
169 | 169 | |
170 | - $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
170 | + $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
171 | 171 | |
172 | - if($primary_key) |
|
172 | + if ($primary_key) |
|
173 | 173 | { |
174 | 174 | $primary_list[] = $name; |
175 | 175 | } |
176 | - else if($unique) |
|
176 | + else if ($unique) |
|
177 | 177 | { |
178 | 178 | $unique_list[$unique][] = $name; |
179 | 179 | } |
180 | - else if($index) |
|
180 | + else if ($index) |
|
181 | 181 | { |
182 | 182 | $index_list[$index][] = $name; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - if(count($primary_list)) |
|
186 | + if (count($primary_list)) |
|
187 | 187 | { |
188 | - $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`'); |
|
188 | + $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list, '`,`').'`'); |
|
189 | 189 | } |
190 | 190 | |
191 | - if(count($unique_list)) |
|
191 | + if (count($unique_list)) |
|
192 | 192 | { |
193 | - foreach($unique_list as $key => $val) |
|
193 | + foreach ($unique_list as $key => $val) |
|
194 | 194 | { |
195 | - $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
195 | + $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - if(count($index_list)) |
|
199 | + if (count($index_list)) |
|
200 | 200 | { |
201 | - foreach($index_list as $key => $val) |
|
201 | + foreach ($index_list as $key => $val) |
|
202 | 202 | { |
203 | - $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
203 | + $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
207 | 207 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci"); |
208 | 208 | |
209 | 209 | $output = $this->_query($schema); |
210 | - if(!$output) |
|
210 | + if (!$output) |
|
211 | 211 | { |
212 | 212 | return false; |
213 | 213 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | function DBMysql_innodb($auto_connect = TRUE) |
24 | 24 | { |
25 | 25 | $this->_setDBInfo(); |
26 | - if($auto_connect) $this->_connect(); |
|
26 | + if($auto_connect) { |
|
27 | + $this->_connect(); |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | /** |
@@ -58,8 +60,7 @@ discard block |
||
58 | 60 | if(!$transactionLevel) |
59 | 61 | { |
60 | 62 | $this->_query("START TRANSACTION", $connection); |
61 | - } |
|
62 | - else |
|
63 | + } else |
|
63 | 64 | { |
64 | 65 | $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
65 | 66 | } |
@@ -80,8 +81,7 @@ discard block |
||
80 | 81 | if($point) |
81 | 82 | { |
82 | 83 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
83 | - } |
|
84 | - else |
|
84 | + } else |
|
85 | 85 | { |
86 | 86 | $this->_query("ROLLBACK", $connection); |
87 | 87 | } |
@@ -149,8 +149,7 @@ discard block |
||
149 | 149 | if(!is_array($xml_obj->table->column)) |
150 | 150 | { |
151 | 151 | $columns[] = $xml_obj->table->column; |
152 | - } |
|
153 | - else |
|
152 | + } else |
|
154 | 153 | { |
155 | 154 | $columns = $xml_obj->table->column; |
156 | 155 | } |
@@ -172,12 +171,10 @@ discard block |
||
172 | 171 | if($primary_key) |
173 | 172 | { |
174 | 173 | $primary_list[] = $name; |
175 | - } |
|
176 | - else if($unique) |
|
174 | + } else if($unique) |
|
177 | 175 | { |
178 | 176 | $unique_list[$unique][] = $name; |
179 | - } |
|
180 | - else if($index) |
|
177 | + } else if($index) |
|
181 | 178 | { |
182 | 179 | $index_list[$index][] = $name; |
183 | 180 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function _loadFromDB($load_extra_vars = true) |
81 | 81 | { |
82 | - if(!$this->document_srl) return; |
|
82 | + if (!$this->document_srl) return; |
|
83 | 83 | |
84 | 84 | $document_item = false; |
85 | 85 | $cache_put = false; |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | // cache controll |
90 | 90 | $oCacheHandler = CacheHandler::getInstance('object'); |
91 | - if($oCacheHandler->isSupport()) |
|
91 | + if ($oCacheHandler->isSupport()) |
|
92 | 92 | { |
93 | - $cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl; |
|
93 | + $cache_key = 'document_item:'.getNumberingPath($this->document_srl).$this->document_srl; |
|
94 | 94 | $document_item = $oCacheHandler->get($cache_key); |
95 | - if($document_item !== false) |
|
95 | + if ($document_item !== false) |
|
96 | 96 | { |
97 | 97 | $columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count'); |
98 | 98 | } |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | $args->document_srl = $this->document_srl; |
103 | 103 | $output = executeQuery('document.getDocument', $args, $columnList); |
104 | 104 | |
105 | - if($document_item === false) |
|
105 | + if ($document_item === false) |
|
106 | 106 | { |
107 | 107 | $document_item = $output->data; |
108 | 108 | |
109 | 109 | //insert in cache |
110 | - if($document_item && $oCacheHandler->isSupport()) |
|
110 | + if ($document_item && $oCacheHandler->isSupport()) |
|
111 | 111 | { |
112 | 112 | $oCacheHandler->put($cache_key, $document_item); |
113 | 113 | } |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | $this->setAttribute($document_item, $load_extra_vars); |
125 | 125 | } |
126 | 126 | |
127 | - function setAttribute($attribute, $load_extra_vars=true) |
|
127 | + function setAttribute($attribute, $load_extra_vars = true) |
|
128 | 128 | { |
129 | - if(!$attribute->document_srl) |
|
129 | + if (!$attribute->document_srl) |
|
130 | 130 | { |
131 | 131 | $this->document_srl = null; |
132 | 132 | return; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $this->adds($attribute); |
137 | 137 | |
138 | 138 | // Tags |
139 | - if($this->get('tags')) |
|
139 | + if ($this->get('tags')) |
|
140 | 140 | { |
141 | 141 | $tag_list = explode(',', $this->get('tags')); |
142 | 142 | $tag_list = array_map('trim', $tag_list); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | $oDocumentModel = getModel('document'); |
147 | - if($load_extra_vars) |
|
147 | + if ($load_extra_vars) |
|
148 | 148 | { |
149 | 149 | $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this; |
150 | 150 | $oDocumentModel->setToAllDocumentExtraVars(); |
@@ -159,23 +159,23 @@ discard block |
||
159 | 159 | |
160 | 160 | function isGranted() |
161 | 161 | { |
162 | - if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
162 | + if ($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
163 | 163 | |
164 | - if($this->grant_cache !== null) |
|
164 | + if ($this->grant_cache !== null) |
|
165 | 165 | { |
166 | 166 | return $this->grant_cache; |
167 | 167 | } |
168 | 168 | |
169 | - if(!Context::get('is_logged')) return $this->grant_cache = false; |
|
169 | + if (!Context::get('is_logged')) return $this->grant_cache = false; |
|
170 | 170 | |
171 | 171 | $logged_info = Context::get('logged_info'); |
172 | - if($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
172 | + if ($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
173 | 173 | |
174 | 174 | $oModuleModel = getModel('module'); |
175 | 175 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
176 | - if($grant->manager) return $this->grant_cache = true; |
|
176 | + if ($grant->manager) return $this->grant_cache = true; |
|
177 | 177 | |
178 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
178 | + if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
179 | 179 | |
180 | 180 | return $this->grant_cache = false; |
181 | 181 | } |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | |
189 | 189 | function isAccessible() |
190 | 190 | { |
191 | - return $_SESSION['accessible'][$this->document_srl]==true?true:false; |
|
191 | + return $_SESSION['accessible'][$this->document_srl] == true ? true : false; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | function allowComment() |
195 | 195 | { |
196 | 196 | // init write, document is not exists. so allow comment status is true |
197 | - if(!$this->isExists()) return true; |
|
197 | + if (!$this->isExists()) return true; |
|
198 | 198 | |
199 | 199 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
200 | 200 | } |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | function allowTrackback() |
203 | 203 | { |
204 | 204 | static $allow_trackback_status = null; |
205 | - if(is_null($allow_trackback_status)) |
|
205 | + if (is_null($allow_trackback_status)) |
|
206 | 206 | { |
207 | 207 | |
208 | 208 | // Check the tarckback module exist |
209 | - if(!getClass('trackback')) |
|
209 | + if (!getClass('trackback')) |
|
210 | 210 | { |
211 | 211 | $allow_trackback_status = false; |
212 | 212 | } |
@@ -216,20 +216,20 @@ discard block |
||
216 | 216 | $oModuleModel = getModel('module'); |
217 | 217 | $trackback_config = $oModuleModel->getModuleConfig('trackback'); |
218 | 218 | |
219 | - if(!$trackback_config) |
|
219 | + if (!$trackback_config) |
|
220 | 220 | { |
221 | 221 | $trackback_config = new stdClass(); |
222 | 222 | } |
223 | 223 | |
224 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
225 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
224 | + if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
225 | + if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
226 | 226 | else |
227 | 227 | { |
228 | 228 | $module_srl = $this->get('module_srl'); |
229 | 229 | // Check settings of each module |
230 | 230 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
231 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
232 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
231 | + if ($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
232 | + else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | } |
@@ -238,14 +238,14 @@ discard block |
||
238 | 238 | |
239 | 239 | function isLocked() |
240 | 240 | { |
241 | - if(!$this->isExists()) return false; |
|
241 | + if (!$this->isExists()) return false; |
|
242 | 242 | |
243 | 243 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
244 | 244 | } |
245 | 245 | |
246 | 246 | function isEditable() |
247 | 247 | { |
248 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
248 | + if ($this->isGranted() || !$this->get('member_srl')) return true; |
|
249 | 249 | return false; |
250 | 250 | } |
251 | 251 | |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | |
263 | 263 | function useNotify() |
264 | 264 | { |
265 | - return $this->get('notify_message')=='Y' ? true : false; |
|
265 | + return $this->get('notify_message') == 'Y' ? true : false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | function doCart() |
269 | 269 | { |
270 | - if(!$this->document_srl) return false; |
|
271 | - if($this->isCarted()) $this->removeCart(); |
|
270 | + if (!$this->document_srl) return false; |
|
271 | + if ($this->isCarted()) $this->removeCart(); |
|
272 | 272 | else $this->addCart(); |
273 | 273 | } |
274 | 274 | |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function notify($type, $content) |
297 | 297 | { |
298 | - if(!$this->document_srl) return; |
|
298 | + if (!$this->document_srl) return; |
|
299 | 299 | // return if it is not useNotify |
300 | - if(!$this->useNotify()) return; |
|
300 | + if (!$this->useNotify()) return; |
|
301 | 301 | // Pass if an author is not a logged-in user |
302 | - if(!$this->get('member_srl')) return; |
|
302 | + if (!$this->get('member_srl')) return; |
|
303 | 303 | // Return if the currently logged-in user is an author |
304 | 304 | $logged_info = Context::get('logged_info'); |
305 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
305 | + if ($logged_info->member_srl == $this->get('member_srl')) return; |
|
306 | 306 | // List variables |
307 | - if($type) $title = "[".$type."] "; |
|
307 | + if ($type) $title = "[".$type."] "; |
|
308 | 308 | $title .= cut_str(strip_tags($content), 10, '...'); |
309 | - $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
|
309 | + $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl)); |
|
310 | 310 | $receiver_srl = $this->get('member_srl'); |
311 | 311 | $sender_member_srl = $logged_info->member_srl; |
312 | 312 | // Send a message |
@@ -321,26 +321,26 @@ discard block |
||
321 | 321 | |
322 | 322 | function getIpAddress() |
323 | 323 | { |
324 | - if($this->isGranted()) |
|
324 | + if ($this->isGranted()) |
|
325 | 325 | { |
326 | 326 | return $this->get('ipaddress'); |
327 | 327 | } |
328 | 328 | |
329 | - return '*' . strstr($this->get('ipaddress'), '.'); |
|
329 | + return '*'.strstr($this->get('ipaddress'), '.'); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | function isExistsHomepage() |
333 | 333 | { |
334 | - if(trim($this->get('homepage'))) return true; |
|
334 | + if (trim($this->get('homepage'))) return true; |
|
335 | 335 | return false; |
336 | 336 | } |
337 | 337 | |
338 | 338 | function getHomepageUrl() |
339 | 339 | { |
340 | 340 | $url = trim($this->get('homepage')); |
341 | - if(!$url) return; |
|
341 | + if (!$url) return; |
|
342 | 342 | |
343 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
343 | + if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://'.$url; |
|
344 | 344 | |
345 | 345 | return $url; |
346 | 346 | } |
@@ -370,52 +370,52 @@ discard block |
||
370 | 370 | return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
371 | 371 | } |
372 | 372 | |
373 | - function getTitleText($cut_size = 0, $tail='...') |
|
373 | + function getTitleText($cut_size = 0, $tail = '...') |
|
374 | 374 | { |
375 | - if(!$this->document_srl) return; |
|
375 | + if (!$this->document_srl) return; |
|
376 | 376 | |
377 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
377 | + if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
378 | 378 | else $title = $this->get('title'); |
379 | 379 | |
380 | 380 | return $title; |
381 | 381 | } |
382 | 382 | |
383 | - function getTitle($cut_size = 0, $tail='...') |
|
383 | + function getTitle($cut_size = 0, $tail = '...') |
|
384 | 384 | { |
385 | - if(!$this->document_srl) return; |
|
385 | + if (!$this->document_srl) return; |
|
386 | 386 | |
387 | 387 | $title = $this->getTitleText($cut_size, $tail); |
388 | 388 | |
389 | 389 | $attrs = array(); |
390 | 390 | $this->add('title_color', trim($this->get('title_color'))); |
391 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
392 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
391 | + if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;"; |
|
392 | + if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
393 | 393 | |
394 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
394 | + if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
395 | 395 | else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
396 | 396 | } |
397 | 397 | |
398 | 398 | function getContentText($strlen = 0) |
399 | 399 | { |
400 | - if(!$this->document_srl) return; |
|
400 | + if (!$this->document_srl) return; |
|
401 | 401 | |
402 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
402 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
403 | 403 | |
404 | 404 | $result = $this->_checkAccessibleFromStatus(); |
405 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
405 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
406 | 406 | |
407 | 407 | $content = $this->get('content'); |
408 | 408 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
409 | 409 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
410 | 410 | |
411 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
411 | + if ($strlen) return cut_str(strip_tags($content), $strlen, '...'); |
|
412 | 412 | |
413 | 413 | return htmlspecialchars($content); |
414 | 414 | } |
415 | 415 | |
416 | 416 | function _addAllowScriptAccess($m) |
417 | 417 | { |
418 | - if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
418 | + if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
419 | 419 | { |
420 | 420 | $m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>'; |
421 | 421 | } |
@@ -425,26 +425,26 @@ discard block |
||
425 | 425 | |
426 | 426 | function _checkAllowScriptAccess($m) |
427 | 427 | { |
428 | - if($m[1] == 'object') |
|
428 | + if ($m[1] == 'object') |
|
429 | 429 | { |
430 | 430 | $this->allowscriptaccessList[] = 1; |
431 | 431 | } |
432 | 432 | |
433 | - if($m[1] == 'param') |
|
433 | + if ($m[1] == 'param') |
|
434 | 434 | { |
435 | - if(stripos($m[0], 'allowscriptaccess')) |
|
435 | + if (stripos($m[0], 'allowscriptaccess')) |
|
436 | 436 | { |
437 | 437 | $m[0] = '<param name="allowscriptaccess" value="never"'; |
438 | - if(substr($m[0], -1) == '/') |
|
438 | + if (substr($m[0], -1) == '/') |
|
439 | 439 | { |
440 | 440 | $m[0] .= '/'; |
441 | 441 | } |
442 | - $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
|
442 | + $this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--; |
|
443 | 443 | } |
444 | 444 | } |
445 | - else if($m[1] == 'embed') |
|
445 | + else if ($m[1] == 'embed') |
|
446 | 446 | { |
447 | - if(stripos($m[0], 'allowscriptaccess')) |
|
447 | + if (stripos($m[0], 'allowscriptaccess')) |
|
448 | 448 | { |
449 | 449 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
450 | 450 | } |
@@ -458,24 +458,24 @@ discard block |
||
458 | 458 | |
459 | 459 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
460 | 460 | { |
461 | - if(!$this->document_srl) return; |
|
461 | + if (!$this->document_srl) return; |
|
462 | 462 | |
463 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
463 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
464 | 464 | |
465 | 465 | $result = $this->_checkAccessibleFromStatus(); |
466 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
466 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
467 | 467 | |
468 | 468 | $content = $this->get('content'); |
469 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
469 | + if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
470 | 470 | |
471 | 471 | // Define a link if using a rewrite module |
472 | 472 | $oContext = &Context::getInstance(); |
473 | - if($oContext->allow_rewrite) |
|
473 | + if ($oContext->allow_rewrite) |
|
474 | 474 | { |
475 | - $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content); |
|
475 | + $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2".Context::getRequestUri()."?", $content); |
|
476 | 476 | } |
477 | 477 | // To display a pop-up menu |
478 | - if($add_popup_menu) |
|
478 | + if ($add_popup_menu) |
|
479 | 479 | { |
480 | 480 | $content = sprintf( |
481 | 481 | '%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>', |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | ); |
485 | 485 | } |
486 | 486 | // If additional content information is set |
487 | - if($add_content_info) |
|
487 | + if ($add_content_info) |
|
488 | 488 | { |
489 | 489 | $memberSrl = $this->get('member_srl'); |
490 | - if($memberSrl < 0) |
|
490 | + if ($memberSrl < 0) |
|
491 | 491 | { |
492 | 492 | $memberSrl = 0; |
493 | 493 | } |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | } |
504 | 504 | else |
505 | 505 | { |
506 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
506 | + if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
507 | 507 | } |
508 | 508 | // Change the image path to a valid absolute path if resource_realpath is true |
509 | - if($resource_realpath) |
|
509 | + if ($resource_realpath) |
|
510 | 510 | { |
511 | - $content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content); |
|
511 | + $content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | return $content; |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | $content = trim(cut_str($content, $str_size, $tail)); |
558 | 558 | |
559 | 559 | // Replace back < , <, " |
560 | - $content = str_replace(array('<', '>', '"'),array('<', '>', '"'), $content); |
|
560 | + $content = str_replace(array('<', '>', '"'), array('<', '>', '"'), $content); |
|
561 | 561 | |
562 | 562 | return $content; |
563 | 563 | } |
@@ -570,13 +570,13 @@ discard block |
||
570 | 570 | function getRegdateTime() |
571 | 571 | { |
572 | 572 | $regdate = $this->get('regdate'); |
573 | - $year = substr($regdate,0,4); |
|
574 | - $month = substr($regdate,4,2); |
|
575 | - $day = substr($regdate,6,2); |
|
576 | - $hour = substr($regdate,8,2); |
|
577 | - $min = substr($regdate,10,2); |
|
578 | - $sec = substr($regdate,12,2); |
|
579 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
573 | + $year = substr($regdate, 0, 4); |
|
574 | + $month = substr($regdate, 4, 2); |
|
575 | + $day = substr($regdate, 6, 2); |
|
576 | + $hour = substr($regdate, 8, 2); |
|
577 | + $min = substr($regdate, 10, 2); |
|
578 | + $sec = substr($regdate, 12, 2); |
|
579 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | function getRegdateGM() |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | function getRegdateDT() |
588 | 588 | { |
589 | - return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
589 | + return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | function getUpdate($format = 'Y.m.d H:i:s') |
@@ -596,13 +596,13 @@ discard block |
||
596 | 596 | |
597 | 597 | function getUpdateTime() |
598 | 598 | { |
599 | - $year = substr($this->get('last_update'),0,4); |
|
600 | - $month = substr($this->get('last_update'),4,2); |
|
601 | - $day = substr($this->get('last_update'),6,2); |
|
602 | - $hour = substr($this->get('last_update'),8,2); |
|
603 | - $min = substr($this->get('last_update'),10,2); |
|
604 | - $sec = substr($this->get('last_update'),12,2); |
|
605 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
599 | + $year = substr($this->get('last_update'), 0, 4); |
|
600 | + $month = substr($this->get('last_update'), 4, 2); |
|
601 | + $day = substr($this->get('last_update'), 6, 2); |
|
602 | + $hour = substr($this->get('last_update'), 8, 2); |
|
603 | + $min = substr($this->get('last_update'), 10, 2); |
|
604 | + $sec = substr($this->get('last_update'), 12, 2); |
|
605 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | function getUpdateGM() |
@@ -612,21 +612,21 @@ discard block |
||
612 | 612 | |
613 | 613 | function getUpdateDT() |
614 | 614 | { |
615 | - return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
615 | + return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | function getPermanentUrl() |
619 | 619 | { |
620 | - return getFullUrl('','document_srl',$this->get('document_srl')); |
|
620 | + return getFullUrl('', 'document_srl', $this->get('document_srl')); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | function getTrackbackUrl() |
624 | 624 | { |
625 | - if(!$this->document_srl) return; |
|
625 | + if (!$this->document_srl) return; |
|
626 | 626 | |
627 | 627 | // Generate a key to prevent spams |
628 | 628 | $oTrackbackModel = getModel('trackback'); |
629 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
629 | + if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
@@ -636,24 +636,24 @@ discard block |
||
636 | 636 | function updateReadedCount() |
637 | 637 | { |
638 | 638 | $oDocumentController = getController('document'); |
639 | - if($oDocumentController->updateReadedCount($this)) |
|
639 | + if ($oDocumentController->updateReadedCount($this)) |
|
640 | 640 | { |
641 | 641 | $readed_count = $this->get('readed_count'); |
642 | - $this->add('readed_count', $readed_count+1); |
|
642 | + $this->add('readed_count', $readed_count + 1); |
|
643 | 643 | } |
644 | 644 | } |
645 | 645 | |
646 | 646 | function isExtraVarsExists() |
647 | 647 | { |
648 | - if(!$this->get('module_srl')) return false; |
|
648 | + if (!$this->get('module_srl')) return false; |
|
649 | 649 | $oDocumentModel = getModel('document'); |
650 | 650 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
651 | - return count($extra_keys)?true:false; |
|
651 | + return count($extra_keys) ? true : false; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | function getExtraVars() |
655 | 655 | { |
656 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
656 | + if (!$this->get('module_srl') || !$this->document_srl) return null; |
|
657 | 657 | |
658 | 658 | $oDocumentModel = getModel('document'); |
659 | 659 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | function getExtraValue($idx) |
663 | 663 | { |
664 | 664 | $extra_vars = $this->getExtraVars(); |
665 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
665 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
666 | 666 | { |
667 | 667 | return $extra_vars[$idx]->getValue(); |
668 | 668 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function getExtraValueHTML($idx) |
676 | 676 | { |
677 | 677 | $extra_vars = $this->getExtraVars(); |
678 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
678 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
679 | 679 | { |
680 | 680 | return $extra_vars[$idx]->getValueHTML(); |
681 | 681 | } |
@@ -689,16 +689,16 @@ discard block |
||
689 | 689 | { |
690 | 690 | $extra_vars = $this->getExtraVars(); |
691 | 691 | |
692 | - if($extra_vars) |
|
692 | + if ($extra_vars) |
|
693 | 693 | { |
694 | 694 | // Handle extra variable(eid) |
695 | - foreach($extra_vars as $idx => $key) |
|
695 | + foreach ($extra_vars as $idx => $key) |
|
696 | 696 | { |
697 | 697 | $extra_eid[$key->eid] = $key; |
698 | 698 | } |
699 | 699 | } |
700 | 700 | |
701 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
701 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
702 | 702 | { |
703 | 703 | return $extra_eid[$eid]->getValue(); |
704 | 704 | } |
@@ -712,12 +712,12 @@ discard block |
||
712 | 712 | { |
713 | 713 | $extra_vars = $this->getExtraVars(); |
714 | 714 | // Handle extra variable(eid) |
715 | - foreach($extra_vars as $idx => $key) |
|
715 | + foreach ($extra_vars as $idx => $key) |
|
716 | 716 | { |
717 | 717 | $extra_eid[$key->eid] = $key; |
718 | 718 | } |
719 | 719 | |
720 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
720 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
721 | 721 | { |
722 | 722 | return $extra_eid[$eid]->getValueHTML(); |
723 | 723 | } |
@@ -741,13 +741,13 @@ discard block |
||
741 | 741 | |
742 | 742 | function getComments() |
743 | 743 | { |
744 | - if(!$this->getCommentCount()) return; |
|
745 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
744 | + if (!$this->getCommentCount()) return; |
|
745 | + if (!$this->isGranted() && $this->isSecret()) return; |
|
746 | 746 | // cpage is a number of comment pages |
747 | 747 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
748 | 748 | $cpage = Context::get($cpageStr); |
749 | 749 | |
750 | - if(!$cpage) |
|
750 | + if (!$cpage) |
|
751 | 751 | { |
752 | 752 | $cpage = Context::get('cpage'); |
753 | 753 | } |
@@ -755,19 +755,19 @@ discard block |
||
755 | 755 | // Get a list of comments |
756 | 756 | $oCommentModel = getModel('comment'); |
757 | 757 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
758 | - if(!$output->toBool() || !count($output->data)) return; |
|
758 | + if (!$output->toBool() || !count($output->data)) return; |
|
759 | 759 | // Create commentItem object from a comment list |
760 | 760 | // If admin priviledge is granted on parent posts, you can read its child posts. |
761 | 761 | $accessible = array(); |
762 | 762 | $comment_list = array(); |
763 | - foreach($output->data as $key => $val) |
|
763 | + foreach ($output->data as $key => $val) |
|
764 | 764 | { |
765 | 765 | $oCommentItem = new commentItem(); |
766 | 766 | $oCommentItem->setAttribute($val); |
767 | 767 | // If permission is granted to the post, you can access it temporarily |
768 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
768 | + if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
769 | 769 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
770 | - if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
|
770 | + if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) |
|
771 | 771 | { |
772 | 772 | $oCommentItem->setAccessible(); |
773 | 773 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | // Variable setting to be displayed on the skin |
777 | 777 | Context::set($cpageStr, $output->page_navigation->cur_page); |
778 | 778 | Context::set('cpage', $output->page_navigation->cur_page); |
779 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
779 | + if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation; |
|
780 | 780 | |
781 | 781 | return $comment_list; |
782 | 782 | } |
@@ -788,9 +788,9 @@ discard block |
||
788 | 788 | |
789 | 789 | function getTrackbacks() |
790 | 790 | { |
791 | - if(!$this->document_srl) return; |
|
791 | + if (!$this->document_srl) return; |
|
792 | 792 | |
793 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
793 | + if (!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
794 | 794 | |
795 | 795 | $oTrackbackModel = getModel('trackback'); |
796 | 796 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -798,47 +798,47 @@ discard block |
||
798 | 798 | |
799 | 799 | function thumbnailExists($width = 80, $height = 0, $type = '') |
800 | 800 | { |
801 | - if(!$this->document_srl) return false; |
|
802 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
801 | + if (!$this->document_srl) return false; |
|
802 | + if (!$this->getThumbnail($width, $height, $type)) return false; |
|
803 | 803 | return true; |
804 | 804 | } |
805 | 805 | |
806 | 806 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
807 | 807 | { |
808 | 808 | // Return false if the document doesn't exist |
809 | - if(!$this->document_srl) return; |
|
809 | + if (!$this->document_srl) return; |
|
810 | 810 | |
811 | - if($this->isSecret() && !$this->isGranted()) |
|
811 | + if ($this->isSecret() && !$this->isGranted()) |
|
812 | 812 | { |
813 | 813 | return; |
814 | 814 | } |
815 | 815 | |
816 | 816 | // If not specify its height, create a square |
817 | - if(!$height) $height = $width; |
|
817 | + if (!$height) $height = $width; |
|
818 | 818 | |
819 | 819 | // Return false if neither attachement nor image files in the document |
820 | 820 | $content = $this->get('content'); |
821 | - if(!$this->get('uploaded_count')) |
|
821 | + if (!$this->get('uploaded_count')) |
|
822 | 822 | { |
823 | - if(!$content) |
|
823 | + if (!$content) |
|
824 | 824 | { |
825 | 825 | $args = new stdClass(); |
826 | 826 | $args->document_srl = $this->document_srl; |
827 | 827 | $output = executeQuery('document.getDocument', $args, array('content')); |
828 | - if($output->toBool() && $output->data) |
|
828 | + if ($output->toBool() && $output->data) |
|
829 | 829 | { |
830 | 830 | $content = $output->data->content; |
831 | 831 | $this->add('content', $content); |
832 | 832 | } |
833 | 833 | } |
834 | 834 | |
835 | - if(!preg_match("!<img!is", $content)) return; |
|
835 | + if (!preg_match("!<img!is", $content)) return; |
|
836 | 836 | } |
837 | 837 | // Get thumbnai_type information from document module's configuration |
838 | - if(!in_array($thumbnail_type, array('crop','ratio'))) |
|
838 | + if (!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
839 | 839 | { |
840 | 840 | $config = $GLOBALS['__document_config__']; |
841 | - if(!$config) |
|
841 | + if (!$config) |
|
842 | 842 | { |
843 | 843 | $oDocumentModel = getModel('document'); |
844 | 844 | $config = $oDocumentModel->getDocumentConfig(); |
@@ -848,15 +848,15 @@ discard block |
||
848 | 848 | } |
849 | 849 | |
850 | 850 | // Define thumbnail information |
851 | - $thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3)); |
|
851 | + $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3)); |
|
852 | 852 | $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); |
853 | 853 | $thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type); |
854 | 854 | $thumbnail_url = Context::getRequestUri().$thumbnail_file; |
855 | 855 | |
856 | 856 | // Return false if thumbnail file exists and its size is 0. Otherwise, return its path |
857 | - if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
857 | + if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
858 | 858 | { |
859 | - if(filesize($thumbnail_file) < 1) |
|
859 | + if (filesize($thumbnail_file) < 1) |
|
860 | 860 | { |
861 | 861 | return FALSE; |
862 | 862 | } |
@@ -874,64 +874,64 @@ discard block |
||
874 | 874 | $is_tmp_file = false; |
875 | 875 | |
876 | 876 | // Find an iamge file among attached files if exists |
877 | - if($this->hasUploadedFiles()) |
|
877 | + if ($this->hasUploadedFiles()) |
|
878 | 878 | { |
879 | 879 | $file_list = $this->getUploadedFiles(); |
880 | 880 | |
881 | 881 | $first_image = null; |
882 | - foreach($file_list as $file) |
|
882 | + foreach ($file_list as $file) |
|
883 | 883 | { |
884 | - if($file->direct_download !== 'Y') continue; |
|
884 | + if ($file->direct_download !== 'Y') continue; |
|
885 | 885 | |
886 | - if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
886 | + if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
887 | 887 | { |
888 | 888 | $source_file = $file->uploaded_filename; |
889 | 889 | break; |
890 | 890 | } |
891 | 891 | |
892 | - if($first_image) continue; |
|
892 | + if ($first_image) continue; |
|
893 | 893 | |
894 | - if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
894 | + if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
895 | 895 | { |
896 | - if(file_exists($file->uploaded_filename)) |
|
896 | + if (file_exists($file->uploaded_filename)) |
|
897 | 897 | { |
898 | 898 | $first_image = $file->uploaded_filename; |
899 | 899 | } |
900 | 900 | } |
901 | 901 | } |
902 | 902 | |
903 | - if(!$source_file && $first_image) |
|
903 | + if (!$source_file && $first_image) |
|
904 | 904 | { |
905 | 905 | $source_file = $first_image; |
906 | 906 | } |
907 | 907 | } |
908 | 908 | // If not exists, file an image file from the content |
909 | 909 | $is_tmp_file = false; |
910 | - if(!$source_file) |
|
910 | + if (!$source_file) |
|
911 | 911 | { |
912 | 912 | $random = new Password(); |
913 | 913 | |
914 | 914 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
915 | 915 | |
916 | - foreach($matches as $target_image) |
|
916 | + foreach ($matches as $target_image) |
|
917 | 917 | { |
918 | 918 | $target_src = trim($target_image[1]); |
919 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
919 | + if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
920 | 920 | |
921 | - if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
921 | + if (!preg_match('/^(http|https):\/\//i', $target_src)) |
|
922 | 922 | { |
923 | 923 | $target_src = Context::getRequestUri().$target_src; |
924 | 924 | } |
925 | 925 | |
926 | 926 | $target_src = htmlspecialchars_decode($target_src); |
927 | 927 | |
928 | - $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
928 | + $tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex'); |
|
929 | 929 | FileHandler::getRemoteFile($target_src, $tmp_file); |
930 | - if(!file_exists($tmp_file)) continue; |
|
930 | + if (!file_exists($tmp_file)) continue; |
|
931 | 931 | |
932 | 932 | $imageinfo = getimagesize($tmp_file); |
933 | 933 | list($_w, $_h) = $imageinfo; |
934 | - if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
934 | + if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
935 | 935 | FileHandler::removeFile($tmp_file); |
936 | 936 | continue; |
937 | 937 | } |
@@ -942,13 +942,13 @@ discard block |
||
942 | 942 | } |
943 | 943 | } |
944 | 944 | |
945 | - if($source_file) |
|
945 | + if ($source_file) |
|
946 | 946 | { |
947 | 947 | $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
948 | 948 | } |
949 | 949 | |
950 | 950 | // Remove source file if it was temporary |
951 | - if($is_tmp_file) |
|
951 | + if ($is_tmp_file) |
|
952 | 952 | { |
953 | 953 | FileHandler::removeFile($source_file); |
954 | 954 | } |
@@ -957,14 +957,14 @@ discard block |
||
957 | 957 | FileHandler::removeFile($thumbnail_lockfile); |
958 | 958 | |
959 | 959 | // Return the thumbnail path if it was successfully generated |
960 | - if($output) |
|
960 | + if ($output) |
|
961 | 961 | { |
962 | 962 | return $thumbnail_url; |
963 | 963 | } |
964 | 964 | // Create an empty file if thumbnail generation failed |
965 | 965 | else |
966 | 966 | { |
967 | - FileHandler::writeFile($thumbnail_file, '','w'); |
|
967 | + FileHandler::writeFile($thumbnail_file, '', 'w'); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | return; |
@@ -978,21 +978,21 @@ discard block |
||
978 | 978 | */ |
979 | 979 | function getExtraImages($time_interval = 43200) |
980 | 980 | { |
981 | - if(!$this->document_srl) return; |
|
981 | + if (!$this->document_srl) return; |
|
982 | 982 | // variables for icon list |
983 | 983 | $buffs = array(); |
984 | 984 | |
985 | 985 | $check_files = false; |
986 | 986 | |
987 | 987 | // Check if secret post is |
988 | - if($this->isSecret()) $buffs[] = "secret"; |
|
988 | + if ($this->isSecret()) $buffs[] = "secret"; |
|
989 | 989 | |
990 | 990 | // Set the latest time |
991 | - $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
|
991 | + $time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval); |
|
992 | 992 | |
993 | 993 | // Check new post |
994 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
995 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
994 | + if ($this->get('regdate') > $time_check) $buffs[] = "new"; |
|
995 | + else if ($this->get('last_update') > $time_check) $buffs[] = "update"; |
|
996 | 996 | |
997 | 997 | /* |
998 | 998 | $content = $this->get('content'); |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | */ |
1016 | 1016 | |
1017 | 1017 | // Check the attachment |
1018 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
1018 | + if ($this->hasUploadedFiles()) $buffs[] = "file"; |
|
1019 | 1019 | |
1020 | 1020 | return $buffs; |
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | function getStatus() |
1024 | 1024 | { |
1025 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
1025 | + if (!$this->get('status')) return $this->getDefaultStatus(); |
|
1026 | 1026 | return $this->get('status'); |
1027 | 1027 | } |
1028 | 1028 | |
@@ -1033,15 +1033,15 @@ discard block |
||
1033 | 1033 | */ |
1034 | 1034 | function printExtraImages($time_check = 43200) |
1035 | 1035 | { |
1036 | - if(!$this->document_srl) return; |
|
1036 | + if (!$this->document_srl) return; |
|
1037 | 1037 | // Get the icon directory |
1038 | - $path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/'); |
|
1038 | + $path = sprintf('%s%s', getUrl(), 'modules/document/tpl/icons/'); |
|
1039 | 1039 | |
1040 | 1040 | $buffs = $this->getExtraImages($time_check); |
1041 | - if(!count($buffs)) return; |
|
1041 | + if (!count($buffs)) return; |
|
1042 | 1042 | |
1043 | 1043 | $buff = array(); |
1044 | - foreach($buffs as $key => $val) |
|
1044 | + foreach ($buffs as $key => $val) |
|
1045 | 1045 | { |
1046 | 1046 | $buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val); |
1047 | 1047 | } |
@@ -1050,20 +1050,20 @@ discard block |
||
1050 | 1050 | |
1051 | 1051 | function hasUploadedFiles() |
1052 | 1052 | { |
1053 | - if(!$this->document_srl) return; |
|
1053 | + if (!$this->document_srl) return; |
|
1054 | 1054 | |
1055 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
1056 | - return $this->get('uploaded_count')? true : false; |
|
1055 | + if ($this->isSecret() && !$this->isGranted()) return false; |
|
1056 | + return $this->get('uploaded_count') ? true : false; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | function getUploadedFiles($sortIndex = 'file_srl') |
1060 | 1060 | { |
1061 | - if(!$this->document_srl) return; |
|
1061 | + if (!$this->document_srl) return; |
|
1062 | 1062 | |
1063 | - if($this->isSecret() && !$this->isGranted()) return; |
|
1064 | - if(!$this->get('uploaded_count')) return; |
|
1063 | + if ($this->isSecret() && !$this->isGranted()) return; |
|
1064 | + if (!$this->get('uploaded_count')) return; |
|
1065 | 1065 | |
1066 | - if(!$this->uploadedFiles[$sortIndex]) |
|
1066 | + if (!$this->uploadedFiles[$sortIndex]) |
|
1067 | 1067 | { |
1068 | 1068 | $oFileModel = getModel('file'); |
1069 | 1069 | $this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true); |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | function getEditor() |
1080 | 1080 | { |
1081 | 1081 | $module_srl = $this->get('module_srl'); |
1082 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
1082 | + if (!$module_srl) $module_srl = Context::get('module_srl'); |
|
1083 | 1083 | |
1084 | 1084 | $oEditorModel = getModel('editor'); |
1085 | 1085 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | { |
1095 | 1095 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
1096 | 1096 | if (!$this->allowComment()) return false; |
1097 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
1097 | + if (!$this->isGranted() && $this->isSecret()) return false; |
|
1098 | 1098 | |
1099 | 1099 | return true; |
1100 | 1100 | } |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | */ |
1106 | 1106 | function getCommentEditor() |
1107 | 1107 | { |
1108 | - if(!$this->isEnableComment()) return; |
|
1108 | + if (!$this->isEnableComment()) return; |
|
1109 | 1109 | |
1110 | 1110 | $oEditorModel = getModel('editor'); |
1111 | 1111 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1117,10 +1117,10 @@ discard block |
||
1117 | 1117 | */ |
1118 | 1118 | function getProfileImage() |
1119 | 1119 | { |
1120 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1120 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
1121 | 1121 | $oMemberModel = getModel('member'); |
1122 | 1122 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
1123 | - if(!$profile_info) return; |
|
1123 | + if (!$profile_info) return; |
|
1124 | 1124 | |
1125 | 1125 | return $profile_info->src; |
1126 | 1126 | } |
@@ -1132,21 +1132,21 @@ discard block |
||
1132 | 1132 | function getSignature() |
1133 | 1133 | { |
1134 | 1134 | // Pass if a document doesn't exist |
1135 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1135 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
1136 | 1136 | // Get signature information |
1137 | 1137 | $oMemberModel = getModel('member'); |
1138 | 1138 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
1139 | 1139 | // Check if a maximum height of signiture is set in the member module |
1140 | - if(!isset($GLOBALS['__member_signature_max_height'])) |
|
1140 | + if (!isset($GLOBALS['__member_signature_max_height'])) |
|
1141 | 1141 | { |
1142 | 1142 | $oModuleModel = getModel('module'); |
1143 | 1143 | $member_config = $oModuleModel->getModuleConfig('member'); |
1144 | 1144 | $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; |
1145 | 1145 | } |
1146 | - if($signature) |
|
1146 | + if ($signature) |
|
1147 | 1147 | { |
1148 | 1148 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
1149 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1149 | + if ($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | return $signature; |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | */ |
1160 | 1160 | function replaceResourceRealPath($matches) |
1161 | 1161 | { |
1162 | - return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
1162 | + return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | /** |
@@ -1170,19 +1170,19 @@ discard block |
||
1170 | 1170 | function _checkAccessibleFromStatus() |
1171 | 1171 | { |
1172 | 1172 | $logged_info = Context::get('logged_info'); |
1173 | - if($logged_info->is_admin == 'Y') return true; |
|
1173 | + if ($logged_info->is_admin == 'Y') return true; |
|
1174 | 1174 | |
1175 | 1175 | $status = $this->get('status'); |
1176 | - if(empty($status)) return false; |
|
1176 | + if (empty($status)) return false; |
|
1177 | 1177 | |
1178 | 1178 | $oDocumentModel = getModel('document'); |
1179 | 1179 | $configStatusList = $oDocumentModel->getStatusList(); |
1180 | 1180 | |
1181 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
1181 | + if ($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
1182 | 1182 | return true; |
1183 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1183 | + else if ($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1184 | 1184 | { |
1185 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
1185 | + if ($this->get('member_srl') == $logged_info->member_srl) |
|
1186 | 1186 | return true; |
1187 | 1187 | } |
1188 | 1188 | return false; |
@@ -79,7 +79,9 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function _loadFromDB($load_extra_vars = true) |
81 | 81 | { |
82 | - if(!$this->document_srl) return; |
|
82 | + if(!$this->document_srl) { |
|
83 | + return; |
|
84 | + } |
|
83 | 85 | |
84 | 86 | $document_item = false; |
85 | 87 | $cache_put = false; |
@@ -111,8 +113,7 @@ discard block |
||
111 | 113 | { |
112 | 114 | $oCacheHandler->put($cache_key, $document_item); |
113 | 115 | } |
114 | - } |
|
115 | - else |
|
116 | + } else |
|
116 | 117 | { |
117 | 118 | $document_item->readed_count = $output->data->readed_count; |
118 | 119 | $document_item->voted_count = $output->data->voted_count; |
@@ -159,23 +160,33 @@ discard block |
||
159 | 160 | |
160 | 161 | function isGranted() |
161 | 162 | { |
162 | - if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
163 | + if($_SESSION['own_document'][$this->document_srl]) { |
|
164 | + return $this->grant_cache = true; |
|
165 | + } |
|
163 | 166 | |
164 | 167 | if($this->grant_cache !== null) |
165 | 168 | { |
166 | 169 | return $this->grant_cache; |
167 | 170 | } |
168 | 171 | |
169 | - if(!Context::get('is_logged')) return $this->grant_cache = false; |
|
172 | + if(!Context::get('is_logged')) { |
|
173 | + return $this->grant_cache = false; |
|
174 | + } |
|
170 | 175 | |
171 | 176 | $logged_info = Context::get('logged_info'); |
172 | - if($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
177 | + if($logged_info->is_admin == 'Y') { |
|
178 | + return $this->grant_cache = true; |
|
179 | + } |
|
173 | 180 | |
174 | 181 | $oModuleModel = getModel('module'); |
175 | 182 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
176 | - if($grant->manager) return $this->grant_cache = true; |
|
183 | + if($grant->manager) { |
|
184 | + return $this->grant_cache = true; |
|
185 | + } |
|
177 | 186 | |
178 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
187 | + if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) { |
|
188 | + return $this->grant_cache = true; |
|
189 | + } |
|
179 | 190 | |
180 | 191 | return $this->grant_cache = false; |
181 | 192 | } |
@@ -194,7 +205,9 @@ discard block |
||
194 | 205 | function allowComment() |
195 | 206 | { |
196 | 207 | // init write, document is not exists. so allow comment status is true |
197 | - if(!$this->isExists()) return true; |
|
208 | + if(!$this->isExists()) { |
|
209 | + return true; |
|
210 | + } |
|
198 | 211 | |
199 | 212 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
200 | 213 | } |
@@ -209,8 +222,7 @@ discard block |
||
209 | 222 | if(!getClass('trackback')) |
210 | 223 | { |
211 | 224 | $allow_trackback_status = false; |
212 | - } |
|
213 | - else |
|
225 | + } else |
|
214 | 226 | { |
215 | 227 | // If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module. |
216 | 228 | $oModuleModel = getModel('module'); |
@@ -221,15 +233,21 @@ discard block |
||
221 | 233 | $trackback_config = new stdClass(); |
222 | 234 | } |
223 | 235 | |
224 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
225 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
226 | - else |
|
236 | + if(!isset($trackback_config->enable_trackback)) { |
|
237 | + $trackback_config->enable_trackback = 'Y'; |
|
238 | + } |
|
239 | + if($trackback_config->enable_trackback != 'Y') { |
|
240 | + $allow_trackback_status = false; |
|
241 | + } else |
|
227 | 242 | { |
228 | 243 | $module_srl = $this->get('module_srl'); |
229 | 244 | // Check settings of each module |
230 | 245 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
231 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
232 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
246 | + if($module_config->enable_trackback == 'N') { |
|
247 | + $allow_trackback_status = false; |
|
248 | + } else if($this->get('allow_trackback')=='Y' || !$this->isExists()) { |
|
249 | + $allow_trackback_status = true; |
|
250 | + } |
|
233 | 251 | } |
234 | 252 | } |
235 | 253 | } |
@@ -238,14 +256,18 @@ discard block |
||
238 | 256 | |
239 | 257 | function isLocked() |
240 | 258 | { |
241 | - if(!$this->isExists()) return false; |
|
259 | + if(!$this->isExists()) { |
|
260 | + return false; |
|
261 | + } |
|
242 | 262 | |
243 | 263 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
244 | 264 | } |
245 | 265 | |
246 | 266 | function isEditable() |
247 | 267 | { |
248 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
268 | + if($this->isGranted() || !$this->get('member_srl')) { |
|
269 | + return true; |
|
270 | + } |
|
249 | 271 | return false; |
250 | 272 | } |
251 | 273 | |
@@ -267,9 +289,14 @@ discard block |
||
267 | 289 | |
268 | 290 | function doCart() |
269 | 291 | { |
270 | - if(!$this->document_srl) return false; |
|
271 | - if($this->isCarted()) $this->removeCart(); |
|
272 | - else $this->addCart(); |
|
292 | + if(!$this->document_srl) { |
|
293 | + return false; |
|
294 | + } |
|
295 | + if($this->isCarted()) { |
|
296 | + $this->removeCart(); |
|
297 | + } else { |
|
298 | + $this->addCart(); |
|
299 | + } |
|
273 | 300 | } |
274 | 301 | |
275 | 302 | function addCart() |
@@ -295,16 +322,26 @@ discard block |
||
295 | 322 | */ |
296 | 323 | function notify($type, $content) |
297 | 324 | { |
298 | - if(!$this->document_srl) return; |
|
325 | + if(!$this->document_srl) { |
|
326 | + return; |
|
327 | + } |
|
299 | 328 | // return if it is not useNotify |
300 | - if(!$this->useNotify()) return; |
|
329 | + if(!$this->useNotify()) { |
|
330 | + return; |
|
331 | + } |
|
301 | 332 | // Pass if an author is not a logged-in user |
302 | - if(!$this->get('member_srl')) return; |
|
333 | + if(!$this->get('member_srl')) { |
|
334 | + return; |
|
335 | + } |
|
303 | 336 | // Return if the currently logged-in user is an author |
304 | 337 | $logged_info = Context::get('logged_info'); |
305 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
338 | + if($logged_info->member_srl == $this->get('member_srl')) { |
|
339 | + return; |
|
340 | + } |
|
306 | 341 | // List variables |
307 | - if($type) $title = "[".$type."] "; |
|
342 | + if($type) { |
|
343 | + $title = "[".$type."] "; |
|
344 | + } |
|
308 | 345 | $title .= cut_str(strip_tags($content), 10, '...'); |
309 | 346 | $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
310 | 347 | $receiver_srl = $this->get('member_srl'); |
@@ -331,16 +368,22 @@ discard block |
||
331 | 368 | |
332 | 369 | function isExistsHomepage() |
333 | 370 | { |
334 | - if(trim($this->get('homepage'))) return true; |
|
371 | + if(trim($this->get('homepage'))) { |
|
372 | + return true; |
|
373 | + } |
|
335 | 374 | return false; |
336 | 375 | } |
337 | 376 | |
338 | 377 | function getHomepageUrl() |
339 | 378 | { |
340 | 379 | $url = trim($this->get('homepage')); |
341 | - if(!$url) return; |
|
380 | + if(!$url) { |
|
381 | + return; |
|
382 | + } |
|
342 | 383 | |
343 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
384 | + if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) { |
|
385 | + $url = 'http://' . $url; |
|
386 | + } |
|
344 | 387 | |
345 | 388 | return $url; |
346 | 389 | } |
@@ -372,43 +415,65 @@ discard block |
||
372 | 415 | |
373 | 416 | function getTitleText($cut_size = 0, $tail='...') |
374 | 417 | { |
375 | - if(!$this->document_srl) return; |
|
418 | + if(!$this->document_srl) { |
|
419 | + return; |
|
420 | + } |
|
376 | 421 | |
377 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
378 | - else $title = $this->get('title'); |
|
422 | + if($cut_size) { |
|
423 | + $title = cut_str($this->get('title'), $cut_size, $tail); |
|
424 | + } else { |
|
425 | + $title = $this->get('title'); |
|
426 | + } |
|
379 | 427 | |
380 | 428 | return $title; |
381 | 429 | } |
382 | 430 | |
383 | 431 | function getTitle($cut_size = 0, $tail='...') |
384 | 432 | { |
385 | - if(!$this->document_srl) return; |
|
433 | + if(!$this->document_srl) { |
|
434 | + return; |
|
435 | + } |
|
386 | 436 | |
387 | 437 | $title = $this->getTitleText($cut_size, $tail); |
388 | 438 | |
389 | 439 | $attrs = array(); |
390 | 440 | $this->add('title_color', trim($this->get('title_color'))); |
391 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
392 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
441 | + if($this->get('title_bold')=='Y') { |
|
442 | + $attrs[] = "font-weight:bold;"; |
|
443 | + } |
|
444 | + if($this->get('title_color') && $this->get('title_color') != 'N') { |
|
445 | + $attrs[] = "color:#".$this->get('title_color'); |
|
446 | + } |
|
393 | 447 | |
394 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
395 | - else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
448 | + if(count($attrs)) { |
|
449 | + return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
450 | + } else { |
|
451 | + return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
452 | + } |
|
396 | 453 | } |
397 | 454 | |
398 | 455 | function getContentText($strlen = 0) |
399 | 456 | { |
400 | - if(!$this->document_srl) return; |
|
457 | + if(!$this->document_srl) { |
|
458 | + return; |
|
459 | + } |
|
401 | 460 | |
402 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
461 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
462 | + return Context::getLang('msg_is_secret'); |
|
463 | + } |
|
403 | 464 | |
404 | 465 | $result = $this->_checkAccessibleFromStatus(); |
405 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
466 | + if($result) { |
|
467 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
468 | + } |
|
406 | 469 | |
407 | 470 | $content = $this->get('content'); |
408 | 471 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
409 | 472 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
410 | 473 | |
411 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
474 | + if($strlen) { |
|
475 | + return cut_str(strip_tags($content),$strlen,'...'); |
|
476 | + } |
|
412 | 477 | |
413 | 478 | return htmlspecialchars($content); |
414 | 479 | } |
@@ -441,14 +506,12 @@ discard block |
||
441 | 506 | } |
442 | 507 | $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
443 | 508 | } |
444 | - } |
|
445 | - else if($m[1] == 'embed') |
|
509 | + } else if($m[1] == 'embed') |
|
446 | 510 | { |
447 | 511 | if(stripos($m[0], 'allowscriptaccess')) |
448 | 512 | { |
449 | 513 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
450 | - } |
|
451 | - else |
|
514 | + } else |
|
452 | 515 | { |
453 | 516 | $m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]); |
454 | 517 | } |
@@ -458,15 +521,23 @@ discard block |
||
458 | 521 | |
459 | 522 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
460 | 523 | { |
461 | - if(!$this->document_srl) return; |
|
524 | + if(!$this->document_srl) { |
|
525 | + return; |
|
526 | + } |
|
462 | 527 | |
463 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
528 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
529 | + return Context::getLang('msg_is_secret'); |
|
530 | + } |
|
464 | 531 | |
465 | 532 | $result = $this->_checkAccessibleFromStatus(); |
466 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
533 | + if($result) { |
|
534 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
535 | + } |
|
467 | 536 | |
468 | 537 | $content = $this->get('content'); |
469 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
538 | + if(!$stripEmbedTagException) { |
|
539 | + stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
540 | + } |
|
470 | 541 | |
471 | 542 | // Define a link if using a rewrite module |
472 | 543 | $oContext = &Context::getInstance(); |
@@ -500,10 +571,11 @@ discard block |
||
500 | 571 | $this->document_srl, $memberSrl |
501 | 572 | ); |
502 | 573 | // Add xe_content class although accessing content is not required |
503 | - } |
|
504 | - else |
|
574 | + } else |
|
505 | 575 | { |
506 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
576 | + if($add_xe_content_class) { |
|
577 | + $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
578 | + } |
|
507 | 579 | } |
508 | 580 | // Change the image path to a valid absolute path if resource_realpath is true |
509 | 581 | if($resource_realpath) |
@@ -622,11 +694,15 @@ discard block |
||
622 | 694 | |
623 | 695 | function getTrackbackUrl() |
624 | 696 | { |
625 | - if(!$this->document_srl) return; |
|
697 | + if(!$this->document_srl) { |
|
698 | + return; |
|
699 | + } |
|
626 | 700 | |
627 | 701 | // Generate a key to prevent spams |
628 | 702 | $oTrackbackModel = getModel('trackback'); |
629 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
703 | + if($oTrackbackModel) { |
|
704 | + return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
705 | + } |
|
630 | 706 | } |
631 | 707 | |
632 | 708 | /** |
@@ -645,7 +721,9 @@ discard block |
||
645 | 721 | |
646 | 722 | function isExtraVarsExists() |
647 | 723 | { |
648 | - if(!$this->get('module_srl')) return false; |
|
724 | + if(!$this->get('module_srl')) { |
|
725 | + return false; |
|
726 | + } |
|
649 | 727 | $oDocumentModel = getModel('document'); |
650 | 728 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
651 | 729 | return count($extra_keys)?true:false; |
@@ -653,7 +731,9 @@ discard block |
||
653 | 731 | |
654 | 732 | function getExtraVars() |
655 | 733 | { |
656 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
734 | + if(!$this->get('module_srl') || !$this->document_srl) { |
|
735 | + return null; |
|
736 | + } |
|
657 | 737 | |
658 | 738 | $oDocumentModel = getModel('document'); |
659 | 739 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -665,8 +745,7 @@ discard block |
||
665 | 745 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
666 | 746 | { |
667 | 747 | return $extra_vars[$idx]->getValue(); |
668 | - } |
|
669 | - else |
|
748 | + } else |
|
670 | 749 | { |
671 | 750 | return ''; |
672 | 751 | } |
@@ -678,8 +757,7 @@ discard block |
||
678 | 757 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
679 | 758 | { |
680 | 759 | return $extra_vars[$idx]->getValueHTML(); |
681 | - } |
|
682 | - else |
|
760 | + } else |
|
683 | 761 | { |
684 | 762 | return ''; |
685 | 763 | } |
@@ -701,8 +779,7 @@ discard block |
||
701 | 779 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
702 | 780 | { |
703 | 781 | return $extra_eid[$eid]->getValue(); |
704 | - } |
|
705 | - else |
|
782 | + } else |
|
706 | 783 | { |
707 | 784 | return ''; |
708 | 785 | } |
@@ -720,8 +797,7 @@ discard block |
||
720 | 797 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
721 | 798 | { |
722 | 799 | return $extra_eid[$eid]->getValueHTML(); |
723 | - } |
|
724 | - else |
|
800 | + } else |
|
725 | 801 | { |
726 | 802 | return ''; |
727 | 803 | } |
@@ -741,8 +817,12 @@ discard block |
||
741 | 817 | |
742 | 818 | function getComments() |
743 | 819 | { |
744 | - if(!$this->getCommentCount()) return; |
|
745 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
820 | + if(!$this->getCommentCount()) { |
|
821 | + return; |
|
822 | + } |
|
823 | + if(!$this->isGranted() && $this->isSecret()) { |
|
824 | + return; |
|
825 | + } |
|
746 | 826 | // cpage is a number of comment pages |
747 | 827 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
748 | 828 | $cpage = Context::get($cpageStr); |
@@ -755,7 +835,9 @@ discard block |
||
755 | 835 | // Get a list of comments |
756 | 836 | $oCommentModel = getModel('comment'); |
757 | 837 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
758 | - if(!$output->toBool() || !count($output->data)) return; |
|
838 | + if(!$output->toBool() || !count($output->data)) { |
|
839 | + return; |
|
840 | + } |
|
759 | 841 | // Create commentItem object from a comment list |
760 | 842 | // If admin priviledge is granted on parent posts, you can read its child posts. |
761 | 843 | $accessible = array(); |
@@ -765,7 +847,9 @@ discard block |
||
765 | 847 | $oCommentItem = new commentItem(); |
766 | 848 | $oCommentItem->setAttribute($val); |
767 | 849 | // If permission is granted to the post, you can access it temporarily |
768 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
850 | + if($oCommentItem->isGranted()) { |
|
851 | + $accessible[$val->comment_srl] = true; |
|
852 | + } |
|
769 | 853 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
770 | 854 | if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
771 | 855 | { |
@@ -776,7 +860,9 @@ discard block |
||
776 | 860 | // Variable setting to be displayed on the skin |
777 | 861 | Context::set($cpageStr, $output->page_navigation->cur_page); |
778 | 862 | Context::set('cpage', $output->page_navigation->cur_page); |
779 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
863 | + if($output->total_page>1) { |
|
864 | + $this->comment_page_navigation = $output->page_navigation; |
|
865 | + } |
|
780 | 866 | |
781 | 867 | return $comment_list; |
782 | 868 | } |
@@ -788,9 +874,13 @@ discard block |
||
788 | 874 | |
789 | 875 | function getTrackbacks() |
790 | 876 | { |
791 | - if(!$this->document_srl) return; |
|
877 | + if(!$this->document_srl) { |
|
878 | + return; |
|
879 | + } |
|
792 | 880 | |
793 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
881 | + if(!$this->allowTrackback() || !$this->get('trackback_count')) { |
|
882 | + return; |
|
883 | + } |
|
794 | 884 | |
795 | 885 | $oTrackbackModel = getModel('trackback'); |
796 | 886 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -798,15 +888,21 @@ discard block |
||
798 | 888 | |
799 | 889 | function thumbnailExists($width = 80, $height = 0, $type = '') |
800 | 890 | { |
801 | - if(!$this->document_srl) return false; |
|
802 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
891 | + if(!$this->document_srl) { |
|
892 | + return false; |
|
893 | + } |
|
894 | + if(!$this->getThumbnail($width, $height, $type)) { |
|
895 | + return false; |
|
896 | + } |
|
803 | 897 | return true; |
804 | 898 | } |
805 | 899 | |
806 | 900 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
807 | 901 | { |
808 | 902 | // Return false if the document doesn't exist |
809 | - if(!$this->document_srl) return; |
|
903 | + if(!$this->document_srl) { |
|
904 | + return; |
|
905 | + } |
|
810 | 906 | |
811 | 907 | if($this->isSecret() && !$this->isGranted()) |
812 | 908 | { |
@@ -814,7 +910,9 @@ discard block |
||
814 | 910 | } |
815 | 911 | |
816 | 912 | // If not specify its height, create a square |
817 | - if(!$height) $height = $width; |
|
913 | + if(!$height) { |
|
914 | + $height = $width; |
|
915 | + } |
|
818 | 916 | |
819 | 917 | // Return false if neither attachement nor image files in the document |
820 | 918 | $content = $this->get('content'); |
@@ -832,7 +930,9 @@ discard block |
||
832 | 930 | } |
833 | 931 | } |
834 | 932 | |
835 | - if(!preg_match("!<img!is", $content)) return; |
|
933 | + if(!preg_match("!<img!is", $content)) { |
|
934 | + return; |
|
935 | + } |
|
836 | 936 | } |
837 | 937 | // Get thumbnai_type information from document module's configuration |
838 | 938 | if(!in_array($thumbnail_type, array('crop','ratio'))) |
@@ -859,8 +959,7 @@ discard block |
||
859 | 959 | if(filesize($thumbnail_file) < 1) |
860 | 960 | { |
861 | 961 | return FALSE; |
862 | - } |
|
863 | - else |
|
962 | + } else |
|
864 | 963 | { |
865 | 964 | return $thumbnail_url; |
866 | 965 | } |
@@ -881,7 +980,9 @@ discard block |
||
881 | 980 | $first_image = null; |
882 | 981 | foreach($file_list as $file) |
883 | 982 | { |
884 | - if($file->direct_download !== 'Y') continue; |
|
983 | + if($file->direct_download !== 'Y') { |
|
984 | + continue; |
|
985 | + } |
|
885 | 986 | |
886 | 987 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
887 | 988 | { |
@@ -889,7 +990,9 @@ discard block |
||
889 | 990 | break; |
890 | 991 | } |
891 | 992 | |
892 | - if($first_image) continue; |
|
993 | + if($first_image) { |
|
994 | + continue; |
|
995 | + } |
|
893 | 996 | |
894 | 997 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
895 | 998 | { |
@@ -916,7 +1019,9 @@ discard block |
||
916 | 1019 | foreach($matches as $target_image) |
917 | 1020 | { |
918 | 1021 | $target_src = trim($target_image[1]); |
919 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
1022 | + if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) { |
|
1023 | + continue; |
|
1024 | + } |
|
920 | 1025 | |
921 | 1026 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
922 | 1027 | { |
@@ -927,7 +1032,9 @@ discard block |
||
927 | 1032 | |
928 | 1033 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
929 | 1034 | FileHandler::getRemoteFile($target_src, $tmp_file); |
930 | - if(!file_exists($tmp_file)) continue; |
|
1035 | + if(!file_exists($tmp_file)) { |
|
1036 | + continue; |
|
1037 | + } |
|
931 | 1038 | |
932 | 1039 | $imageinfo = getimagesize($tmp_file); |
933 | 1040 | list($_w, $_h) = $imageinfo; |
@@ -978,21 +1085,28 @@ discard block |
||
978 | 1085 | */ |
979 | 1086 | function getExtraImages($time_interval = 43200) |
980 | 1087 | { |
981 | - if(!$this->document_srl) return; |
|
1088 | + if(!$this->document_srl) { |
|
1089 | + return; |
|
1090 | + } |
|
982 | 1091 | // variables for icon list |
983 | 1092 | $buffs = array(); |
984 | 1093 | |
985 | 1094 | $check_files = false; |
986 | 1095 | |
987 | 1096 | // Check if secret post is |
988 | - if($this->isSecret()) $buffs[] = "secret"; |
|
1097 | + if($this->isSecret()) { |
|
1098 | + $buffs[] = "secret"; |
|
1099 | + } |
|
989 | 1100 | |
990 | 1101 | // Set the latest time |
991 | 1102 | $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
992 | 1103 | |
993 | 1104 | // Check new post |
994 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
995 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
1105 | + if($this->get('regdate')>$time_check) { |
|
1106 | + $buffs[] = "new"; |
|
1107 | + } else if($this->get('last_update')>$time_check) { |
|
1108 | + $buffs[] = "update"; |
|
1109 | + } |
|
996 | 1110 | |
997 | 1111 | /* |
998 | 1112 | $content = $this->get('content'); |
@@ -1015,14 +1129,18 @@ discard block |
||
1015 | 1129 | */ |
1016 | 1130 | |
1017 | 1131 | // Check the attachment |
1018 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
1132 | + if($this->hasUploadedFiles()) { |
|
1133 | + $buffs[] = "file"; |
|
1134 | + } |
|
1019 | 1135 | |
1020 | 1136 | return $buffs; |
1021 | 1137 | } |
1022 | 1138 | |
1023 | 1139 | function getStatus() |
1024 | 1140 | { |
1025 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
1141 | + if(!$this->get('status')) { |
|
1142 | + return $this->getDefaultStatus(); |
|
1143 | + } |
|
1026 | 1144 | return $this->get('status'); |
1027 | 1145 | } |
1028 | 1146 | |
@@ -1033,12 +1151,16 @@ discard block |
||
1033 | 1151 | */ |
1034 | 1152 | function printExtraImages($time_check = 43200) |
1035 | 1153 | { |
1036 | - if(!$this->document_srl) return; |
|
1154 | + if(!$this->document_srl) { |
|
1155 | + return; |
|
1156 | + } |
|
1037 | 1157 | // Get the icon directory |
1038 | 1158 | $path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/'); |
1039 | 1159 | |
1040 | 1160 | $buffs = $this->getExtraImages($time_check); |
1041 | - if(!count($buffs)) return; |
|
1161 | + if(!count($buffs)) { |
|
1162 | + return; |
|
1163 | + } |
|
1042 | 1164 | |
1043 | 1165 | $buff = array(); |
1044 | 1166 | foreach($buffs as $key => $val) |
@@ -1050,18 +1172,28 @@ discard block |
||
1050 | 1172 | |
1051 | 1173 | function hasUploadedFiles() |
1052 | 1174 | { |
1053 | - if(!$this->document_srl) return; |
|
1175 | + if(!$this->document_srl) { |
|
1176 | + return; |
|
1177 | + } |
|
1054 | 1178 | |
1055 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
1179 | + if($this->isSecret() && !$this->isGranted()) { |
|
1180 | + return false; |
|
1181 | + } |
|
1056 | 1182 | return $this->get('uploaded_count')? true : false; |
1057 | 1183 | } |
1058 | 1184 | |
1059 | 1185 | function getUploadedFiles($sortIndex = 'file_srl') |
1060 | 1186 | { |
1061 | - if(!$this->document_srl) return; |
|
1187 | + if(!$this->document_srl) { |
|
1188 | + return; |
|
1189 | + } |
|
1062 | 1190 | |
1063 | - if($this->isSecret() && !$this->isGranted()) return; |
|
1064 | - if(!$this->get('uploaded_count')) return; |
|
1191 | + if($this->isSecret() && !$this->isGranted()) { |
|
1192 | + return; |
|
1193 | + } |
|
1194 | + if(!$this->get('uploaded_count')) { |
|
1195 | + return; |
|
1196 | + } |
|
1065 | 1197 | |
1066 | 1198 | if(!$this->uploadedFiles[$sortIndex]) |
1067 | 1199 | { |
@@ -1079,7 +1211,9 @@ discard block |
||
1079 | 1211 | function getEditor() |
1080 | 1212 | { |
1081 | 1213 | $module_srl = $this->get('module_srl'); |
1082 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
1214 | + if(!$module_srl) { |
|
1215 | + $module_srl = Context::get('module_srl'); |
|
1216 | + } |
|
1083 | 1217 | |
1084 | 1218 | $oEditorModel = getModel('editor'); |
1085 | 1219 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1093,8 +1227,12 @@ discard block |
||
1093 | 1227 | function isEnableComment() |
1094 | 1228 | { |
1095 | 1229 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
1096 | - if (!$this->allowComment()) return false; |
|
1097 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
1230 | + if (!$this->allowComment()) { |
|
1231 | + return false; |
|
1232 | + } |
|
1233 | + if(!$this->isGranted() && $this->isSecret()) { |
|
1234 | + return false; |
|
1235 | + } |
|
1098 | 1236 | |
1099 | 1237 | return true; |
1100 | 1238 | } |
@@ -1105,7 +1243,9 @@ discard block |
||
1105 | 1243 | */ |
1106 | 1244 | function getCommentEditor() |
1107 | 1245 | { |
1108 | - if(!$this->isEnableComment()) return; |
|
1246 | + if(!$this->isEnableComment()) { |
|
1247 | + return; |
|
1248 | + } |
|
1109 | 1249 | |
1110 | 1250 | $oEditorModel = getModel('editor'); |
1111 | 1251 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1117,10 +1257,14 @@ discard block |
||
1117 | 1257 | */ |
1118 | 1258 | function getProfileImage() |
1119 | 1259 | { |
1120 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1260 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
1261 | + return; |
|
1262 | + } |
|
1121 | 1263 | $oMemberModel = getModel('member'); |
1122 | 1264 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
1123 | - if(!$profile_info) return; |
|
1265 | + if(!$profile_info) { |
|
1266 | + return; |
|
1267 | + } |
|
1124 | 1268 | |
1125 | 1269 | return $profile_info->src; |
1126 | 1270 | } |
@@ -1132,7 +1276,9 @@ discard block |
||
1132 | 1276 | function getSignature() |
1133 | 1277 | { |
1134 | 1278 | // Pass if a document doesn't exist |
1135 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
1279 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
1280 | + return; |
|
1281 | + } |
|
1136 | 1282 | // Get signature information |
1137 | 1283 | $oMemberModel = getModel('member'); |
1138 | 1284 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
@@ -1146,7 +1292,9 @@ discard block |
||
1146 | 1292 | if($signature) |
1147 | 1293 | { |
1148 | 1294 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
1149 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1295 | + if($max_signature_height) { |
|
1296 | + $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
1297 | + } |
|
1150 | 1298 | } |
1151 | 1299 | |
1152 | 1300 | return $signature; |
@@ -1170,20 +1318,25 @@ discard block |
||
1170 | 1318 | function _checkAccessibleFromStatus() |
1171 | 1319 | { |
1172 | 1320 | $logged_info = Context::get('logged_info'); |
1173 | - if($logged_info->is_admin == 'Y') return true; |
|
1321 | + if($logged_info->is_admin == 'Y') { |
|
1322 | + return true; |
|
1323 | + } |
|
1174 | 1324 | |
1175 | 1325 | $status = $this->get('status'); |
1176 | - if(empty($status)) return false; |
|
1326 | + if(empty($status)) { |
|
1327 | + return false; |
|
1328 | + } |
|
1177 | 1329 | |
1178 | 1330 | $oDocumentModel = getModel('document'); |
1179 | 1331 | $configStatusList = $oDocumentModel->getStatusList(); |
1180 | 1332 | |
1181 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
1182 | - return true; |
|
1183 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1333 | + if($status == $configStatusList['public'] || $status == $configStatusList['publish']) { |
|
1334 | + return true; |
|
1335 | + } else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
1184 | 1336 | { |
1185 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
1186 | - return true; |
|
1337 | + if($this->get('member_srl') == $logged_info->member_srl) { |
|
1338 | + return true; |
|
1339 | + } |
|
1187 | 1340 | } |
1188 | 1341 | return false; |
1189 | 1342 | } |