@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | /** |
473 | 473 | * Show pop-up menu of the selected posts |
474 | 474 | * Printing, scrap, recommendations and negative, reported the Add Features |
475 | - * @return void |
|
475 | + * @return Object|null |
|
476 | 476 | */ |
477 | 477 | function getDocumentMenu() |
478 | 478 | { |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | |
885 | 885 | /** |
886 | 886 | * Get a list for a particular module |
887 | - * @return void|Object |
|
887 | + * @return Object|null |
|
888 | 888 | */ |
889 | 889 | function getDocumentCategories() |
890 | 890 | { |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | /** |
971 | 971 | * Certain categories of information, return the template guhanhu |
972 | 972 | * Manager on the page to add information about a particular menu from the server after compiling tpl compiled a direct return html |
973 | - * @return void|Object |
|
973 | + * @return Object|null |
|
974 | 974 | */ |
975 | 975 | function getDocumentCategoryTplInfo() |
976 | 976 | { |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | * Setting sort index |
1228 | 1228 | * @param object $obj |
1229 | 1229 | * @param bool $load_extra_vars |
1230 | - * @return object |
|
1230 | + * @return stdClass |
|
1231 | 1231 | */ |
1232 | 1232 | function _setSortIndex($obj, $load_extra_vars) |
1233 | 1233 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function getDocumentExtraVarsFromDB($documentSrls) |
37 | 37 | { |
38 | - if(!is_array($documentSrls) || count($documentSrls) == 0) |
|
38 | + if (!is_array($documentSrls) || count($documentSrls) == 0) |
|
39 | 39 | { |
40 | 40 | return new Object(-1, 'msg_invalid_request'); |
41 | 41 | } |
@@ -56,52 +56,52 @@ discard block |
||
56 | 56 | $_document_list = &$GLOBALS['XE_DOCUMENT_LIST']; |
57 | 57 | |
58 | 58 | // XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings |
59 | - if(count($_document_list) <= 0) return; |
|
59 | + if (count($_document_list) <= 0) return; |
|
60 | 60 | |
61 | 61 | // Find all called the document object variable has been set extension |
62 | 62 | $document_srls = array(); |
63 | - foreach($_document_list as $key => $val) |
|
63 | + foreach ($_document_list as $key => $val) |
|
64 | 64 | { |
65 | - if(!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
65 | + if (!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
66 | 66 | $checked_documents[$val->document_srl] = true; |
67 | 67 | $document_srls[] = $val->document_srl; |
68 | 68 | } |
69 | 69 | // If the document number, return detected |
70 | - if(!count($document_srls)) return; |
|
70 | + if (!count($document_srls)) return; |
|
71 | 71 | // Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable |
72 | 72 | //$obj->document_srl = implode(',',$document_srls); |
73 | 73 | $output = $this->getDocumentExtraVarsFromDB($document_srls); |
74 | - if($output->toBool() && $output->data) |
|
74 | + if ($output->toBool() && $output->data) |
|
75 | 75 | { |
76 | - foreach($output->data as $key => $val) |
|
76 | + foreach ($output->data as $key => $val) |
|
77 | 77 | { |
78 | - if(!isset($val->value)) continue; |
|
79 | - if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
78 | + if (!isset($val->value)) continue; |
|
79 | + if (!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
80 | 80 | $extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | 84 | $user_lang_code = Context::getLangType(); |
85 | - for($i=0,$c=count($document_srls);$i<$c;$i++) |
|
85 | + for ($i = 0, $c = count($document_srls); $i < $c; $i++) |
|
86 | 86 | { |
87 | 87 | $document_srl = $document_srls[$i]; |
88 | 88 | unset($vars); |
89 | 89 | |
90 | - if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
90 | + if (!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
91 | 91 | $module_srl = $_document_list[$document_srl]->get('module_srl'); |
92 | 92 | $extra_keys = $this->getExtraKeys($module_srl); |
93 | 93 | $vars = $extra_vars[$document_srl]; |
94 | 94 | $document_lang_code = $_document_list[$document_srl]->get('lang_code'); |
95 | 95 | // Expand the variable processing |
96 | - if(count($extra_keys)) |
|
96 | + if (count($extra_keys)) |
|
97 | 97 | { |
98 | - foreach($extra_keys as $idx => $key) |
|
98 | + foreach ($extra_keys as $idx => $key) |
|
99 | 99 | { |
100 | 100 | $extra_keys[$idx] = clone($key); |
101 | 101 | $val = $vars[$idx]; |
102 | - if(isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
103 | - else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
104 | - else if(isset($val[0])) $v = $val[0]; |
|
102 | + if (isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
103 | + else if (isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
104 | + else if (isset($val[0])) $v = $val[0]; |
|
105 | 105 | else $v = null; |
106 | 106 | $extra_keys[$idx]->value = $v; |
107 | 107 | } |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | $evars = new ExtraVar($module_srl); |
112 | 112 | $evars->setExtraVarKeys($extra_keys); |
113 | 113 | // Title Processing |
114 | - if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
114 | + if ($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title', $vars[-1][$user_lang_code]); |
|
115 | 115 | // Information processing |
116 | - if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
116 | + if ($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content', $vars[-2][$user_lang_code]); |
|
117 | 117 | |
118 | - if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
|
118 | + if ($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
|
119 | 119 | { |
120 | 120 | unset($checked_documents[$document_srl]); |
121 | 121 | } |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | * @param array $columnList |
133 | 133 | * @return documentItem |
134 | 134 | */ |
135 | - function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
135 | + function getDocument($document_srl = 0, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
136 | 136 | { |
137 | - if(!$document_srl) return new documentItem(); |
|
137 | + if (!$document_srl) return new documentItem(); |
|
138 | 138 | |
139 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
139 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
140 | 140 | { |
141 | 141 | $oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
142 | 142 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
143 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
143 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
144 | 144 | } |
145 | - if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
145 | + if ($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
146 | 146 | |
147 | 147 | return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
148 | 148 | } |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | * @param array $columnList |
156 | 156 | * @return array value type is documentItem |
157 | 157 | */ |
158 | - function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
158 | + function getDocuments($document_srls, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
159 | 159 | { |
160 | - if(is_array($document_srls)) |
|
160 | + if (is_array($document_srls)) |
|
161 | 161 | { |
162 | 162 | $list_count = count($document_srls); |
163 | - $document_srls = implode(',',$document_srls); |
|
163 | + $document_srls = implode(',', $document_srls); |
|
164 | 164 | } |
165 | 165 | else |
166 | 166 | { |
@@ -173,33 +173,33 @@ discard block |
||
173 | 173 | |
174 | 174 | $output = executeQuery('document.getDocuments', $args, $columnList); |
175 | 175 | $document_list = $output->data; |
176 | - if(!$document_list) return; |
|
177 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
176 | + if (!$document_list) return; |
|
177 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
178 | 178 | |
179 | 179 | $document_count = count($document_list); |
180 | - foreach($document_list as $key => $attribute) |
|
180 | + foreach ($document_list as $key => $attribute) |
|
181 | 181 | { |
182 | 182 | $document_srl = $attribute->document_srl; |
183 | - if(!$document_srl) continue; |
|
183 | + if (!$document_srl) continue; |
|
184 | 184 | |
185 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
185 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
186 | 186 | { |
187 | 187 | $oDocument = null; |
188 | 188 | $oDocument = new documentItem(); |
189 | 189 | $oDocument->setAttribute($attribute, false); |
190 | - if($is_admin) $oDocument->setGrant(); |
|
190 | + if ($is_admin) $oDocument->setGrant(); |
|
191 | 191 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
192 | 192 | } |
193 | 193 | |
194 | 194 | $result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
195 | 195 | } |
196 | 196 | |
197 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
197 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
198 | 198 | |
199 | 199 | $output = null; |
200 | - if(count($result)) |
|
200 | + if (count($result)) |
|
201 | 201 | { |
202 | - foreach($result as $document_srl => $val) |
|
202 | + foreach ($result as $document_srl => $val) |
|
203 | 203 | { |
204 | 204 | $output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
205 | 205 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param array $columnList |
217 | 217 | * @return Object |
218 | 218 | */ |
219 | - function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) |
|
219 | + function getDocumentList($obj, $except_notice = false, $load_extra_vars = true, $columnList = array()) |
|
220 | 220 | { |
221 | 221 | $sort_check = $this->_setSortIndex($obj, $load_extra_vars); |
222 | 222 | $obj->sort_index = $sort_check->sort_index; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | // Call trigger (before) |
227 | 227 | // This trigger can be used to set an alternative output using a different search method |
228 | 228 | $output = ModuleHandler::triggerCall('document.getDocumentList', 'before', $obj); |
229 | - if($output instanceof Object && !$output->toBool()) |
|
229 | + if ($output instanceof Object && !$output->toBool()) |
|
230 | 230 | { |
231 | 231 | return $output; |
232 | 232 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | $output = $obj->use_alternate_output; |
244 | 244 | unset($obj->use_alternate_output); |
245 | 245 | } |
246 | - elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
246 | + elseif ($sort_check->isExtraVars && substr_count($obj->search_target, 'extra_vars')) |
|
247 | 247 | { |
248 | 248 | $query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
249 | - $args->sort_index = str_replace('documents.','',$args->sort_index); |
|
249 | + $args->sort_index = str_replace('documents.', '', $args->sort_index); |
|
250 | 250 | $output = executeQueryArray($query_id, $args); |
251 | 251 | } |
252 | 252 | elseif ($sort_check->isExtraVars) |
@@ -258,16 +258,16 @@ discard block |
||
258 | 258 | // document.getDocumentList query execution |
259 | 259 | // Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
260 | 260 | $groupByQuery = array('document.getDocumentListWithinComment' => 1, 'document.getDocumentListWithinTag' => 1, 'document.getDocumentListWithinExtraVars' => 1); |
261 | - if(isset($groupByQuery[$query_id])) |
|
261 | + if (isset($groupByQuery[$query_id])) |
|
262 | 262 | { |
263 | 263 | $group_args = clone($args); |
264 | 264 | $group_args->sort_index = 'documents.'.$args->sort_index; |
265 | 265 | $output = executeQueryArray($query_id, $group_args); |
266 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
266 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
267 | 267 | |
268 | - foreach($output->data as $key => $val) |
|
268 | + foreach ($output->data as $key => $val) |
|
269 | 269 | { |
270 | - if($val->document_srl) $target_srls[] = $val->document_srl; |
|
270 | + if ($val->document_srl) $target_srls[] = $val->document_srl; |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | $page_navigation = $output->page_navigation; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $virtual_number = $keys[0]; |
276 | 276 | |
277 | 277 | $target_args = new stdClass(); |
278 | - $target_args->document_srls = implode(',',$target_srls); |
|
278 | + $target_args->document_srls = implode(',', $target_srls); |
|
279 | 279 | $target_args->list_order = $args->sort_index; |
280 | 280 | $target_args->order_type = $args->order_type; |
281 | 281 | $target_args->list_count = $args->list_count; |
@@ -292,35 +292,35 @@ discard block |
||
292 | 292 | } |
293 | 293 | } |
294 | 294 | // Return if no result or an error occurs |
295 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
295 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
296 | 296 | $idx = 0; |
297 | 297 | $data = $output->data; |
298 | 298 | unset($output->data); |
299 | 299 | |
300 | - if(!isset($virtual_number)) |
|
300 | + if (!isset($virtual_number)) |
|
301 | 301 | { |
302 | 302 | $keys = array_keys($data); |
303 | 303 | $virtual_number = $keys[0]; |
304 | 304 | } |
305 | 305 | |
306 | - if($except_notice) |
|
306 | + if ($except_notice) |
|
307 | 307 | { |
308 | - foreach($data as $key => $attribute) |
|
308 | + foreach ($data as $key => $attribute) |
|
309 | 309 | { |
310 | - if($attribute->is_notice == 'Y') $virtual_number --; |
|
310 | + if ($attribute->is_notice == 'Y') $virtual_number--; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - foreach($data as $key => $attribute) |
|
314 | + foreach ($data as $key => $attribute) |
|
315 | 315 | { |
316 | - if($except_notice && $attribute->is_notice == 'Y') continue; |
|
316 | + if ($except_notice && $attribute->is_notice == 'Y') continue; |
|
317 | 317 | $document_srl = $attribute->document_srl; |
318 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
318 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
319 | 319 | { |
320 | 320 | $oDocument = null; |
321 | 321 | $oDocument = new documentItem(); |
322 | 322 | $oDocument->setAttribute($attribute, false); |
323 | - if($is_admin) $oDocument->setGrant(); |
|
323 | + if ($is_admin) $oDocument->setGrant(); |
|
324 | 324 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
325 | 325 | } |
326 | 326 | |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | $virtual_number--; |
329 | 329 | } |
330 | 330 | |
331 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
331 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
332 | 332 | |
333 | - if(count($output->data)) |
|
333 | + if (count($output->data)) |
|
334 | 334 | { |
335 | - foreach($output->data as $number => $document) |
|
335 | + foreach ($output->data as $number => $document) |
|
336 | 336 | { |
337 | 337 | $output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl]; |
338 | 338 | } |
@@ -354,16 +354,16 @@ discard block |
||
354 | 354 | { |
355 | 355 | $args = new stdClass(); |
356 | 356 | $args->module_srl = $obj->module_srl; |
357 | - $args->category_srl= $obj->category_srl; |
|
357 | + $args->category_srl = $obj->category_srl; |
|
358 | 358 | $output = executeQueryArray('document.getNoticeList', $args, $columnList); |
359 | - if(!$output->toBool()||!$output->data) return; |
|
359 | + if (!$output->toBool() || !$output->data) return; |
|
360 | 360 | |
361 | - foreach($output->data as $key => $val) |
|
361 | + foreach ($output->data as $key => $val) |
|
362 | 362 | { |
363 | 363 | $document_srl = $val->document_srl; |
364 | - if(!$document_srl) continue; |
|
364 | + if (!$document_srl) continue; |
|
365 | 365 | |
366 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
366 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
367 | 367 | { |
368 | 368 | $oDocument = null; |
369 | 369 | $oDocument = new documentItem(); |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | } |
375 | 375 | $this->setToAllDocumentExtraVars(); |
376 | 376 | |
377 | - foreach($result->data as $document_srl => $val) |
|
377 | + foreach ($result->data as $document_srl => $val) |
|
378 | 378 | { |
379 | 379 | $result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
380 | 380 | } |
@@ -390,20 +390,20 @@ discard block |
||
390 | 390 | */ |
391 | 391 | function getExtraKeys($module_srl) |
392 | 392 | { |
393 | - if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
393 | + if (!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
394 | 394 | { |
395 | 395 | $keys = false; |
396 | 396 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
397 | - if($oCacheHandler->isSupport()) |
|
397 | + if ($oCacheHandler->isSupport()) |
|
398 | 398 | { |
399 | - $object_key = 'module_document_extra_keys:' . $module_srl; |
|
399 | + $object_key = 'module_document_extra_keys:'.$module_srl; |
|
400 | 400 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
401 | 401 | $keys = $oCacheHandler->get($cache_key); |
402 | 402 | } |
403 | 403 | |
404 | 404 | $oExtraVar = ExtraVar::getInstance($module_srl); |
405 | 405 | |
406 | - if($keys === false) |
|
406 | + if ($keys === false) |
|
407 | 407 | { |
408 | 408 | $obj = new stdClass(); |
409 | 409 | $obj->module_srl = $module_srl; |
@@ -413,13 +413,13 @@ discard block |
||
413 | 413 | |
414 | 414 | // correcting index order |
415 | 415 | $isFixed = FALSE; |
416 | - if(is_array($output->data)) |
|
416 | + if (is_array($output->data)) |
|
417 | 417 | { |
418 | 418 | $prevIdx = 0; |
419 | - foreach($output->data as $no => $value) |
|
419 | + foreach ($output->data as $no => $value) |
|
420 | 420 | { |
421 | 421 | // case first |
422 | - if($prevIdx == 0 && $value->idx != 1) |
|
422 | + if ($prevIdx == 0 && $value->idx != 1) |
|
423 | 423 | { |
424 | 424 | $args = new stdClass(); |
425 | 425 | $args->module_srl = $module_srl; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | } |
434 | 434 | |
435 | 435 | // case others |
436 | - if($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
436 | + if ($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
437 | 437 | { |
438 | 438 | $args = new stdClass(); |
439 | 439 | $args->module_srl = $module_srl; |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | - if($isFixed) |
|
453 | + if ($isFixed) |
|
454 | 454 | { |
455 | 455 | $output = executeQueryArray('document.getDocumentExtraKeys', $obj); |
456 | 456 | } |
457 | 457 | |
458 | 458 | $oExtraVar->setExtraVarKeys($output->data); |
459 | 459 | $keys = $oExtraVar->getExtraVars(); |
460 | - if(!$keys) $keys = array(); |
|
460 | + if (!$keys) $keys = array(); |
|
461 | 461 | |
462 | - if($oCacheHandler->isSupport()) |
|
462 | + if ($oCacheHandler->isSupport()) |
|
463 | 463 | { |
464 | 464 | $oCacheHandler->put($cache_key, $keys); |
465 | 465 | } |
@@ -480,14 +480,14 @@ discard block |
||
480 | 480 | */ |
481 | 481 | function getExtraVars($module_srl, $document_srl) |
482 | 482 | { |
483 | - if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
483 | + if (!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
484 | 484 | { |
485 | 485 | // Extended to extract the values of variables set |
486 | 486 | $oDocument = $this->getDocument($document_srl, false); |
487 | 487 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
488 | 488 | $this->setToAllDocumentExtraVars(); |
489 | 489 | } |
490 | - if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
490 | + if (is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
491 | 491 | return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
492 | 492 | } |
493 | 493 | |
@@ -510,71 +510,71 @@ discard block |
||
510 | 510 | |
511 | 511 | $oDocumentController = getController('document'); |
512 | 512 | // Members must be a possible feature |
513 | - if($logged_info->member_srl) |
|
513 | + if ($logged_info->member_srl) |
|
514 | 514 | { |
515 | 515 | $oDocumentModel = getModel('document'); |
516 | 516 | $columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress'); |
517 | 517 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
518 | 518 | $module_srl = $oDocument->get('module_srl'); |
519 | 519 | $member_srl = $oDocument->get('member_srl'); |
520 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
520 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
521 | 521 | |
522 | 522 | $oModuleModel = getModel('module'); |
523 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
524 | - if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl) |
|
523 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
524 | + if ($document_config->use_vote_up != 'N' && $member_srl != $logged_info->member_srl) |
|
525 | 525 | { |
526 | 526 | // Add a Referral Button |
527 | 527 | $url = sprintf("doCallModuleAction('document','procDocumentVoteUp','%s')", $document_srl); |
528 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote','','javascript'); |
|
528 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote', '', 'javascript'); |
|
529 | 529 | } |
530 | 530 | |
531 | - if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl) |
|
531 | + if ($document_config->use_vote_down != 'N' && $member_srl != $logged_info->member_srl) |
|
532 | 532 | { |
533 | 533 | // Add button to negative |
534 | - $url= sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
535 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote_down','','javascript'); |
|
534 | + $url = sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
535 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote_down', '', 'javascript'); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | // Adding Report |
539 | 539 | $url = sprintf("doCallModuleAction('document','procDocumentDeclare','%s')", $document_srl); |
540 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_declare','','javascript'); |
|
540 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_declare', '', 'javascript'); |
|
541 | 541 | |
542 | 542 | // Add Bookmark button |
543 | 543 | $url = sprintf("doCallModuleAction('member','procMemberScrapDocument','%s')", $document_srl); |
544 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_scrap','','javascript'); |
|
544 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_scrap', '', 'javascript'); |
|
545 | 545 | } |
546 | 546 | // Add print button |
547 | - $url = getUrl('','module','document','act','dispDocumentPrint','document_srl',$document_srl); |
|
548 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_print','','printDocument'); |
|
547 | + $url = getUrl('', 'module', 'document', 'act', 'dispDocumentPrint', 'document_srl', $document_srl); |
|
548 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_print', '', 'printDocument'); |
|
549 | 549 | // Call a trigger (after) |
550 | 550 | ModuleHandler::triggerCall('document.getDocumentMenu', 'after', $menu_list); |
551 | - if($this->grant->manager) |
|
551 | + if ($this->grant->manager) |
|
552 | 552 | { |
553 | 553 | $str_confirm = Context::getLang('confirm_move'); |
554 | 554 | $url = sprintf("if(!confirm('%s')) return; var params = new Array(); params['document_srl']='%s'; params['mid']=current_mid;params['cur_url']=current_url; exec_xml('document', 'procDocumentAdminMoveToTrash', params)", $str_confirm, $document_srl); |
555 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_trash','','javascript'); |
|
555 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_trash', '', 'javascript'); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // If you are managing to find posts by ip |
559 | - if($logged_info->is_admin == 'Y') |
|
559 | + if ($logged_info->is_admin == 'Y') |
|
560 | 560 | { |
561 | 561 | $oDocumentModel = getModel('document'); |
562 | - $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
562 | + $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
563 | 563 | |
564 | - if($oDocument->isExists()) |
|
564 | + if ($oDocument->isExists()) |
|
565 | 565 | { |
566 | 566 | // Find a post equivalent to ip address |
567 | - $url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','ipaddress','search_keyword',$oDocument->getIpAddress()); |
|
568 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress'); |
|
567 | + $url = getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oDocument->getIpAddress()); |
|
568 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress'); |
|
569 | 569 | |
570 | 570 | $url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oDocument->getIpAddress()); |
571 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_add_ip_to_spamfilter','','javascript'); |
|
571 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_add_ip_to_spamfilter', '', 'javascript'); |
|
572 | 572 | } |
573 | 573 | } |
574 | 574 | // Changing the language of pop-up menu |
575 | 575 | $menus = Context::get('document_popup_menu_list'); |
576 | 576 | $menus_count = count($menus); |
577 | - for($i=0;$i<$menus_count;$i++) |
|
577 | + for ($i = 0; $i < $menus_count; $i++) |
|
578 | 578 | { |
579 | 579 | $menus[$i]->str = Context::getLang($menus[$i]->str); |
580 | 580 | } |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | */ |
591 | 591 | function getDocumentCount($module_srl, $search_obj = NULL) |
592 | 592 | { |
593 | - if(is_null($search_obj)) $search_obj = new stdClass(); |
|
593 | + if (is_null($search_obj)) $search_obj = new stdClass(); |
|
594 | 594 | $search_obj->module_srl = $module_srl; |
595 | 595 | |
596 | 596 | $output = executeQuery('document.getDocumentCount', $search_obj); |
597 | 597 | // Return total number of |
598 | 598 | $total_count = $output->data->count; |
599 | - return (int)$total_count; |
|
599 | + return (int) $total_count; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | function getDocumentCountByGroupStatus($search_obj = NULL) |
608 | 608 | { |
609 | 609 | $output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
610 | - if(!$output->toBool()) return array(); |
|
610 | + if (!$output->toBool()) return array(); |
|
611 | 611 | |
612 | 612 | return $output->data; |
613 | 613 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | $output = executeQuery('document.getDocumentExtraVarsCount', $args); |
627 | 627 | // Return total number of |
628 | 628 | $total_count = $output->data->count; |
629 | - return (int)$total_count; |
|
629 | + return (int) $total_count; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
@@ -643,17 +643,17 @@ discard block |
||
643 | 643 | |
644 | 644 | $this->_setSearchOption($opt, $args, $query_id, $use_division); |
645 | 645 | |
646 | - if($sort_check->isExtraVars) |
|
646 | + if ($sort_check->isExtraVars) |
|
647 | 647 | { |
648 | 648 | return 1; |
649 | 649 | } |
650 | 650 | else |
651 | 651 | { |
652 | - if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
652 | + if ($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
653 | 653 | { |
654 | - if($args->order_type === 'desc') |
|
654 | + if ($args->order_type === 'desc') |
|
655 | 655 | { |
656 | - $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
656 | + $args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
657 | 657 | } |
658 | 658 | else |
659 | 659 | { |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | } |
668 | 668 | |
669 | 669 | // Guhanhu total number of the article search page |
670 | - $output = executeQuery($query_id . 'Page', $args); |
|
670 | + $output = executeQuery($query_id.'Page', $args); |
|
671 | 671 | $count = $output->data->count; |
672 | - $page = (int)(($count-1)/$opt->list_count)+1; |
|
672 | + $page = (int) (($count - 1) / $opt->list_count) + 1; |
|
673 | 673 | return $page; |
674 | 674 | } |
675 | 675 | |
@@ -681,16 +681,16 @@ discard block |
||
681 | 681 | */ |
682 | 682 | function getCategory($category_srl, $columnList = array()) |
683 | 683 | { |
684 | - $args =new stdClass(); |
|
684 | + $args = new stdClass(); |
|
685 | 685 | $args->category_srl = $category_srl; |
686 | 686 | $output = executeQuery('document.getCategory', $args, $columnList); |
687 | 687 | |
688 | 688 | $node = $output->data; |
689 | - if(!$node) return; |
|
689 | + if (!$node) return; |
|
690 | 690 | |
691 | - if($node->group_srls) |
|
691 | + if ($node->group_srls) |
|
692 | 692 | { |
693 | - $group_srls = explode(',',$node->group_srls); |
|
693 | + $group_srls = explode(',', $node->group_srls); |
|
694 | 694 | unset($node->group_srls); |
695 | 695 | $node->group_srls = $group_srls; |
696 | 696 | } |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | { |
712 | 712 | $args = new stdClass(); |
713 | 713 | $args->category_srl = $category_srl; |
714 | - $output = executeQuery('document.getChildCategoryCount',$args); |
|
715 | - if($output->data->count > 0) return true; |
|
714 | + $output = executeQuery('document.getChildCategoryCount', $args); |
|
715 | + if ($output->data->count > 0) return true; |
|
716 | 716 | return false; |
717 | 717 | } |
718 | 718 | |
@@ -728,10 +728,10 @@ discard block |
||
728 | 728 | // Category of the target module file swollen |
729 | 729 | $filename = sprintf("%sfiles/cache/document_category/%s.php", _XE_PATH_, $module_srl); |
730 | 730 | // If the target file to the cache file regeneration category |
731 | - if(!file_exists($filename)) |
|
731 | + if (!file_exists($filename)) |
|
732 | 732 | { |
733 | 733 | $oDocumentController = getController('document'); |
734 | - if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
734 | + if (!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | include($filename); |
@@ -751,10 +751,10 @@ discard block |
||
751 | 751 | */ |
752 | 752 | function _arrangeCategory(&$document_category, $list, $depth) |
753 | 753 | { |
754 | - if(!count($list)) return; |
|
754 | + if (!count($list)) return; |
|
755 | 755 | $idx = 0; |
756 | 756 | $list_order = array(); |
757 | - foreach($list as $key => $val) |
|
757 | + foreach ($list as $key => $val) |
|
758 | 758 | { |
759 | 759 | $obj = new stdClass; |
760 | 760 | $obj->mid = $val['mid']; |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | $obj->parent_srl = $val['parent_srl']; |
764 | 764 | $obj->title = $obj->text = $val['text']; |
765 | 765 | $obj->description = $val['description']; |
766 | - $obj->expand = $val['expand']=='Y'?true:false; |
|
766 | + $obj->expand = $val['expand'] == 'Y' ? true : false; |
|
767 | 767 | $obj->color = $val['color']; |
768 | 768 | $obj->document_count = $val['document_count']; |
769 | 769 | $obj->depth = $depth; |
@@ -771,26 +771,26 @@ discard block |
||
771 | 771 | $obj->childs = array(); |
772 | 772 | $obj->grant = $val['grant']; |
773 | 773 | |
774 | - if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
774 | + if (Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
775 | 775 | else $selected = false; |
776 | 776 | |
777 | 777 | $obj->selected = $selected; |
778 | 778 | |
779 | 779 | $list_order[$idx++] = $obj->category_srl; |
780 | 780 | // If you have a parent category of child nodes apply data |
781 | - if($obj->parent_srl) |
|
781 | + if ($obj->parent_srl) |
|
782 | 782 | { |
783 | 783 | $parent_srl = $obj->parent_srl; |
784 | 784 | $document_count = $obj->document_count; |
785 | 785 | $expand = $obj->expand; |
786 | - if($selected) $expand = true; |
|
786 | + if ($selected) $expand = true; |
|
787 | 787 | |
788 | - while($parent_srl) |
|
788 | + while ($parent_srl) |
|
789 | 789 | { |
790 | 790 | $document_category[$parent_srl]->document_count += $document_count; |
791 | 791 | $document_category[$parent_srl]->childs[] = $obj->category_srl; |
792 | 792 | $document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
793 | - if($expand) $document_category[$parent_srl]->expand = $expand; |
|
793 | + if ($expand) $document_category[$parent_srl]->expand = $expand; |
|
794 | 794 | |
795 | 795 | $parent_srl = $document_category[$parent_srl]->parent_srl; |
796 | 796 | } |
@@ -798,10 +798,10 @@ discard block |
||
798 | 798 | |
799 | 799 | $document_category[$key] = $obj; |
800 | 800 | |
801 | - if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
801 | + if (count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth + 1); |
|
802 | 802 | } |
803 | 803 | $document_category[$list_order[0]]->first = true; |
804 | - $document_category[$list_order[count($list_order)-1]]->last = true; |
|
804 | + $document_category[$list_order[count($list_order) - 1]]->last = true; |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | $args->module_srl = $module_srl; |
817 | 817 | $args->category_srl = $category_srl; |
818 | 818 | $output = executeQuery('document.getCategoryDocumentCount', $args); |
819 | - return (int)$output->data->count; |
|
819 | + return (int) $output->data->count; |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -826,8 +826,8 @@ discard block |
||
826 | 826 | */ |
827 | 827 | function getCategoryXmlFile($module_srl) |
828 | 828 | { |
829 | - $xml_file = sprintf('files/cache/document_category/%s.xml.php',$module_srl); |
|
830 | - if(!file_exists($xml_file)) |
|
829 | + $xml_file = sprintf('files/cache/document_category/%s.xml.php', $module_srl); |
|
830 | + if (!file_exists($xml_file)) |
|
831 | 831 | { |
832 | 832 | $oDocumentController = getController('document'); |
833 | 833 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | */ |
843 | 843 | function getCategoryPhpFile($module_srl) |
844 | 844 | { |
845 | - $php_file = sprintf('files/cache/document_category/%s.php',$module_srl); |
|
846 | - if(!file_exists($php_file)) |
|
845 | + $php_file = sprintf('files/cache/document_category/%s.php', $module_srl); |
|
846 | + if (!file_exists($php_file)) |
|
847 | 847 | { |
848 | 848 | $oDocumentController = getController('document'); |
849 | 849 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | */ |
859 | 859 | function getMonthlyArchivedList($obj) |
860 | 860 | { |
861 | - if($obj->mid) |
|
861 | + if ($obj->mid) |
|
862 | 862 | { |
863 | 863 | $oModuleModel = getModel('module'); |
864 | 864 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -866,13 +866,13 @@ discard block |
||
866 | 866 | } |
867 | 867 | // Module_srl passed the array may be a check whether the array |
868 | 868 | $args = new stdClass; |
869 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
869 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
870 | 870 | else $args->module_srl = $obj->module_srl; |
871 | 871 | |
872 | 872 | $output = executeQuery('document.getMonthlyArchivedList', $args); |
873 | - if(!$output->toBool()||!$output->data) return $output; |
|
873 | + if (!$output->toBool() || !$output->data) return $output; |
|
874 | 874 | |
875 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
875 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
876 | 876 | |
877 | 877 | return $output; |
878 | 878 | } |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | */ |
885 | 885 | function getDailyArchivedList($obj) |
886 | 886 | { |
887 | - if($obj->mid) |
|
887 | + if ($obj->mid) |
|
888 | 888 | { |
889 | 889 | $oModuleModel = getModel('module'); |
890 | 890 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -892,14 +892,14 @@ discard block |
||
892 | 892 | } |
893 | 893 | // Module_srl passed the array may be a check whether the array |
894 | 894 | $args = new stdClass; |
895 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
895 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
896 | 896 | else $args->module_srl = $obj->module_srl; |
897 | 897 | $args->regdate = $obj->regdate; |
898 | 898 | |
899 | 899 | $output = executeQuery('document.getDailyArchivedList', $args); |
900 | - if(!$output->toBool()) return $output; |
|
900 | + if (!$output->toBool()) return $output; |
|
901 | 901 | |
902 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
902 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
903 | 903 | |
904 | 904 | return $output; |
905 | 905 | } |
@@ -910,17 +910,17 @@ discard block |
||
910 | 910 | */ |
911 | 911 | function getDocumentCategories() |
912 | 912 | { |
913 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
913 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
914 | 914 | $module_srl = Context::get('module_srl'); |
915 | - $categories= $this->getCategoryList($module_srl); |
|
915 | + $categories = $this->getCategoryList($module_srl); |
|
916 | 916 | $lang = Context::get('lang'); |
917 | 917 | // No additional category |
918 | 918 | $output = "0,0,{$lang->none_category}\n"; |
919 | - if($categories) |
|
919 | + if ($categories) |
|
920 | 920 | { |
921 | - foreach($categories as $category_srl => $category) |
|
921 | + foreach ($categories as $category_srl => $category) |
|
922 | 922 | { |
923 | - $output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title); |
|
923 | + $output .= sprintf("%d,%d,%s\n", $category_srl, $category->depth, $category->title); |
|
924 | 924 | } |
925 | 925 | } |
926 | 926 | $this->add('categories', $output); |
@@ -932,13 +932,13 @@ discard block |
||
932 | 932 | */ |
933 | 933 | function getDocumentConfig() |
934 | 934 | { |
935 | - if(!$GLOBALS['__document_config__']) |
|
935 | + if (!$GLOBALS['__document_config__']) |
|
936 | 936 | { |
937 | 937 | $oModuleModel = getModel('module'); |
938 | 938 | $config = $oModuleModel->getModuleConfig('document'); |
939 | 939 | |
940 | - if(!$config) $config = new stdClass(); |
|
941 | - if(!$config->thumbnail_type) $config->thumbnail_type = 'crop'; |
|
940 | + if (!$config) $config = new stdClass(); |
|
941 | + if (!$config->thumbnail_type) $config->thumbnail_type = 'crop'; |
|
942 | 942 | $GLOBALS['__document_config__'] = $config; |
943 | 943 | } |
944 | 944 | return $GLOBALS['__document_config__']; |
@@ -1003,11 +1003,11 @@ discard block |
||
1003 | 1003 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
1004 | 1004 | // Check permissions |
1005 | 1005 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1006 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
1006 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
1007 | 1007 | |
1008 | 1008 | $category_srl = Context::get('category_srl'); |
1009 | 1009 | $category_info = $this->getCategory($category_srl); |
1010 | - if(!$category_info) |
|
1010 | + if (!$category_info) |
|
1011 | 1011 | { |
1012 | 1012 | return new Object(-1, 'msg_invalid_request'); |
1013 | 1013 | } |
@@ -1023,14 +1023,14 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | function getDocumentSrlByAlias($mid, $alias) |
1025 | 1025 | { |
1026 | - if(!$mid || !$alias) return null; |
|
1026 | + if (!$mid || !$alias) return null; |
|
1027 | 1027 | $site_module_info = Context::get('site_module_info'); |
1028 | 1028 | $args = new stdClass; |
1029 | 1029 | $args->mid = $mid; |
1030 | 1030 | $args->alias_title = $alias; |
1031 | 1031 | $args->site_srl = $site_module_info->site_srl; |
1032 | 1032 | $output = executeQuery('document.getDocumentSrlByAlias', $args); |
1033 | - if(!$output->data) return null; |
|
1033 | + if (!$output->data) return null; |
|
1034 | 1034 | else return $output->data->document_srl; |
1035 | 1035 | } |
1036 | 1036 | |
@@ -1042,15 +1042,15 @@ discard block |
||
1042 | 1042 | */ |
1043 | 1043 | function getDocumentSrlByTitle($module_srl, $title) |
1044 | 1044 | { |
1045 | - if(!$module_srl || !$title) return null; |
|
1045 | + if (!$module_srl || !$title) return null; |
|
1046 | 1046 | $args = new stdClass; |
1047 | 1047 | $args->module_srl = $module_srl; |
1048 | 1048 | $args->title = $title; |
1049 | 1049 | $output = executeQuery('document.getDocumentSrlByTitle', $args); |
1050 | - if(!$output->data) return null; |
|
1050 | + if (!$output->data) return null; |
|
1051 | 1051 | else |
1052 | 1052 | { |
1053 | - if(is_array($output->data)) return $output->data[0]->document_srl; |
|
1053 | + if (is_array($output->data)) return $output->data[0]->document_srl; |
|
1054 | 1054 | return $output->data->document_srl; |
1055 | 1055 | } |
1056 | 1056 | } |
@@ -1062,12 +1062,12 @@ discard block |
||
1062 | 1062 | */ |
1063 | 1063 | function getAlias($document_srl) |
1064 | 1064 | { |
1065 | - if(!$document_srl) return null; |
|
1065 | + if (!$document_srl) return null; |
|
1066 | 1066 | $args = new stdClass; |
1067 | 1067 | $args->document_srl = $document_srl; |
1068 | 1068 | $output = executeQueryArray('document.getAliases', $args); |
1069 | 1069 | |
1070 | - if(!$output->data) return null; |
|
1070 | + if (!$output->data) return null; |
|
1071 | 1071 | else return $output->data[0]->alias_title; |
1072 | 1072 | } |
1073 | 1073 | |
@@ -1110,32 +1110,32 @@ discard block |
||
1110 | 1110 | { |
1111 | 1111 | // Variable check |
1112 | 1112 | $args = new stdClass; |
1113 | - $args->category_srl = $obj->category_srl?$obj->category_srl:null; |
|
1113 | + $args->category_srl = $obj->category_srl ? $obj->category_srl : null; |
|
1114 | 1114 | $args->sort_index = $obj->sort_index; |
1115 | - $args->order_type = $obj->order_type?$obj->order_type:'desc'; |
|
1116 | - $args->page = $obj->page?$obj->page:1; |
|
1117 | - $args->list_count = $obj->list_count?$obj->list_count:20; |
|
1118 | - $args->page_count = $obj->page_count?$obj->page_count:10; |
|
1115 | + $args->order_type = $obj->order_type ? $obj->order_type : 'desc'; |
|
1116 | + $args->page = $obj->page ? $obj->page : 1; |
|
1117 | + $args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
1118 | + $args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
1119 | 1119 | // Search options |
1120 | 1120 | $search_target = $obj->search_target; |
1121 | 1121 | $search_keyword = $obj->search_keyword; |
1122 | - if($search_target && $search_keyword) |
|
1122 | + if ($search_target && $search_keyword) |
|
1123 | 1123 | { |
1124 | - switch($search_target) |
|
1124 | + switch ($search_target) |
|
1125 | 1125 | { |
1126 | 1126 | case 'title' : |
1127 | 1127 | case 'content' : |
1128 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1128 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1129 | 1129 | $args->{"s_".$search_target} = $search_keyword; |
1130 | 1130 | $use_division = true; |
1131 | 1131 | break; |
1132 | 1132 | case 'title_content' : |
1133 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1133 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1134 | 1134 | $args->s_title = $search_keyword; |
1135 | 1135 | $args->s_content = $search_keyword; |
1136 | 1136 | break; |
1137 | 1137 | case 'user_id' : |
1138 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1138 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1139 | 1139 | $args->s_user_id = $search_keyword; |
1140 | 1140 | $args->sort_index = 'documents.'.$args->sort_index; |
1141 | 1141 | break; |
@@ -1143,13 +1143,13 @@ discard block |
||
1143 | 1143 | case 'nick_name' : |
1144 | 1144 | case 'email_address' : |
1145 | 1145 | case 'homepage' : |
1146 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1146 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1147 | 1147 | $args->{"s_".$search_target} = $search_keyword; |
1148 | 1148 | break; |
1149 | 1149 | case 'is_notice' : |
1150 | 1150 | case 'is_secret' : |
1151 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1152 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1151 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
1152 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1153 | 1153 | break; |
1154 | 1154 | case 'member_srl' : |
1155 | 1155 | case 'readed_count' : |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | case 'comment_count' : |
1159 | 1159 | case 'trackback_count' : |
1160 | 1160 | case 'uploaded_count' : |
1161 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
1161 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
1162 | 1162 | break; |
1163 | 1163 | case 'regdate' : |
1164 | 1164 | case 'last_update' : |
@@ -1170,9 +1170,9 @@ discard block |
||
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 | $output = executeQueryArray('document.getTrashList', $args); |
1173 | - if($output->data) |
|
1173 | + if ($output->data) |
|
1174 | 1174 | { |
1175 | - foreach($output->data as $key => $attribute) |
|
1175 | + foreach ($output->data as $key => $attribute) |
|
1176 | 1176 | { |
1177 | 1177 | $oDocument = null; |
1178 | 1178 | $oDocument = new documentItem(); |
@@ -1191,46 +1191,46 @@ discard block |
||
1191 | 1191 | { |
1192 | 1192 | $args = new stdClass; |
1193 | 1193 | $document_srl = Context::get('document_srl'); |
1194 | - if(!$document_srl) return new Object(-1,'msg_invalid_request'); |
|
1194 | + if (!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
1195 | 1195 | |
1196 | 1196 | $point = Context::get('point'); |
1197 | - if($point != -1) $point = 1; |
|
1197 | + if ($point != -1) $point = 1; |
|
1198 | 1198 | |
1199 | 1199 | $oDocumentModel = getModel('document'); |
1200 | 1200 | $columnList = array('document_srl', 'module_srl'); |
1201 | 1201 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
1202 | 1202 | $module_srl = $oDocument->get('module_srl'); |
1203 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
1203 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
1204 | 1204 | |
1205 | 1205 | $oModuleModel = getModel('module'); |
1206 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
1207 | - if($point == -1) |
|
1206 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
1207 | + if ($point == -1) |
|
1208 | 1208 | { |
1209 | - if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request'); |
|
1209 | + if ($document_config->use_vote_down != 'S') return new Object(-1, 'msg_invalid_request'); |
|
1210 | 1210 | $args->below_point = 0; |
1211 | 1211 | } |
1212 | 1212 | else |
1213 | 1213 | { |
1214 | - if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request'); |
|
1214 | + if ($document_config->use_vote_up != 'S') return new Object(-1, 'msg_invalid_request'); |
|
1215 | 1215 | $args->more_point = 0; |
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | $args->document_srl = $document_srl; |
1219 | 1219 | |
1220 | - $output = executeQueryArray('document.getVotedMemberList',$args); |
|
1221 | - if(!$output->toBool()) return $output; |
|
1220 | + $output = executeQueryArray('document.getVotedMemberList', $args); |
|
1221 | + if (!$output->toBool()) return $output; |
|
1222 | 1222 | |
1223 | 1223 | $oMemberModel = getModel('member'); |
1224 | - if($output->data) |
|
1224 | + if ($output->data) |
|
1225 | 1225 | { |
1226 | - foreach($output->data as $k => $d) |
|
1226 | + foreach ($output->data as $k => $d) |
|
1227 | 1227 | { |
1228 | 1228 | $profile_image = $oMemberModel->getProfileImage($d->member_srl); |
1229 | 1229 | $output->data[$k]->src = $profile_image->src; |
1230 | 1230 | } |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - $this->add('voted_member_list',$output->data); |
|
1233 | + $this->add('voted_member_list', $output->data); |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | /** |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | function getStatusNameList() |
1241 | 1241 | { |
1242 | 1242 | global $lang; |
1243 | - if(!isset($lang->status_name_list)) |
|
1243 | + if (!isset($lang->status_name_list)) |
|
1244 | 1244 | return array_flip($this->getStatusList()); |
1245 | 1245 | else return $lang->status_name_list; |
1246 | 1246 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | { |
1256 | 1256 | $sortIndex = $obj->sort_index; |
1257 | 1257 | $isExtraVars = false; |
1258 | - if(!in_array($sortIndex, array('list_order','regdate','last_update','update_order','readed_count','voted_count','blamed_count','comment_count','trackback_count','uploaded_count','title','category_srl'))) |
|
1258 | + if (!in_array($sortIndex, array('list_order', 'regdate', 'last_update', 'update_order', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'title', 'category_srl'))) |
|
1259 | 1259 | { |
1260 | 1260 | // get module_srl extra_vars list |
1261 | 1261 | if ($load_extra_vars) |
@@ -1270,11 +1270,11 @@ discard block |
||
1270 | 1270 | else |
1271 | 1271 | { |
1272 | 1272 | $check_array = array(); |
1273 | - foreach($extra_output->data as $val) |
|
1273 | + foreach ($extra_output->data as $val) |
|
1274 | 1274 | { |
1275 | 1275 | $check_array[] = $val->eid; |
1276 | 1276 | } |
1277 | - if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
1277 | + if (!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
1278 | 1278 | else $isExtraVars = true; |
1279 | 1279 | } |
1280 | 1280 | } |
@@ -1302,13 +1302,13 @@ discard block |
||
1302 | 1302 | { |
1303 | 1303 | // Variable check |
1304 | 1304 | $args = new stdClass(); |
1305 | - $args->category_srl = $searchOpt->category_srl?$searchOpt->category_srl:null; |
|
1305 | + $args->category_srl = $searchOpt->category_srl ? $searchOpt->category_srl : null; |
|
1306 | 1306 | $args->order_type = $searchOpt->order_type; |
1307 | - $args->page = $searchOpt->page?$searchOpt->page:1; |
|
1308 | - $args->list_count = $searchOpt->list_count?$searchOpt->list_count:20; |
|
1309 | - $args->page_count = $searchOpt->page_count?$searchOpt->page_count:10; |
|
1310 | - $args->start_date = $searchOpt->start_date?$searchOpt->start_date:null; |
|
1311 | - $args->end_date = $searchOpt->end_date?$searchOpt->end_date:null; |
|
1307 | + $args->page = $searchOpt->page ? $searchOpt->page : 1; |
|
1308 | + $args->list_count = $searchOpt->list_count ? $searchOpt->list_count : 20; |
|
1309 | + $args->page_count = $searchOpt->page_count ? $searchOpt->page_count : 10; |
|
1310 | + $args->start_date = $searchOpt->start_date ? $searchOpt->start_date : null; |
|
1311 | + $args->end_date = $searchOpt->end_date ? $searchOpt->end_date : null; |
|
1312 | 1312 | $args->member_srl = $searchOpt->member_srl; |
1313 | 1313 | |
1314 | 1314 | $logged_info = Context::get('logged_info'); |
@@ -1317,10 +1317,10 @@ discard block |
||
1317 | 1317 | |
1318 | 1318 | // Check the target and sequence alignment |
1319 | 1319 | $orderType = array('desc' => 1, 'asc' => 1); |
1320 | - if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
1320 | + if (!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
1321 | 1321 | |
1322 | 1322 | // If that came across mid module_srl instead of a direct module_srl guhaejum |
1323 | - if($searchOpt->mid) |
|
1323 | + if ($searchOpt->mid) |
|
1324 | 1324 | { |
1325 | 1325 | $oModuleModel = getModel('module'); |
1326 | 1326 | $args->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -1328,30 +1328,30 @@ discard block |
||
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | // Module_srl passed the array may be a check whether the array |
1331 | - if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
1331 | + if (is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
1332 | 1332 | else $args->module_srl = $searchOpt->module_srl; |
1333 | 1333 | |
1334 | 1334 | // Except for the test module_srl |
1335 | - if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
1335 | + if (is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
1336 | 1336 | else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
1337 | 1337 | |
1338 | 1338 | // only admin document list, temp document showing |
1339 | - if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
1339 | + if ($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
1340 | 1340 | else |
1341 | 1341 | { |
1342 | - if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
1342 | + if ($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
1343 | 1343 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
1344 | 1344 | else |
1345 | 1345 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | // Category is selected, further sub-categories until all conditions |
1349 | - if($args->category_srl) |
|
1349 | + if ($args->category_srl) |
|
1350 | 1350 | { |
1351 | 1351 | $category_list = $this->getCategoryList($args->module_srl); |
1352 | 1352 | $category_info = $category_list[$args->category_srl]; |
1353 | 1353 | $category_info->childs[] = $args->category_srl; |
1354 | - $args->category_srl = implode(',',$category_info->childs); |
|
1354 | + $args->category_srl = implode(',', $category_info->childs); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | // Used to specify the default query id (based on several search options to query id modified) |
@@ -1364,24 +1364,24 @@ discard block |
||
1364 | 1364 | $search_target = $searchOpt->search_target; |
1365 | 1365 | $search_keyword = $searchOpt->search_keyword; |
1366 | 1366 | |
1367 | - if($search_target && $search_keyword) |
|
1367 | + if ($search_target && $search_keyword) |
|
1368 | 1368 | { |
1369 | - switch($search_target) |
|
1369 | + switch ($search_target) |
|
1370 | 1370 | { |
1371 | 1371 | case 'title' : |
1372 | 1372 | case 'content' : |
1373 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1373 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1374 | 1374 | $args->{"s_".$search_target} = $search_keyword; |
1375 | 1375 | $use_division = true; |
1376 | 1376 | break; |
1377 | 1377 | case 'title_content' : |
1378 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1378 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1379 | 1379 | $args->s_title = $search_keyword; |
1380 | 1380 | $args->s_content = $search_keyword; |
1381 | 1381 | $use_division = true; |
1382 | 1382 | break; |
1383 | 1383 | case 'user_id' : |
1384 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1384 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1385 | 1385 | $args->s_user_id = $search_keyword; |
1386 | 1386 | $args->sort_index = 'documents.'.$args->sort_index; |
1387 | 1387 | break; |
@@ -1389,18 +1389,18 @@ discard block |
||
1389 | 1389 | case 'nick_name' : |
1390 | 1390 | case 'email_address' : |
1391 | 1391 | case 'homepage' : |
1392 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1392 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1393 | 1393 | $args->{"s_".$search_target} = $search_keyword; |
1394 | 1394 | break; |
1395 | 1395 | case 'is_notice' : |
1396 | - if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
1397 | - elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
1396 | + if ($search_keyword == 'N') $args->{"s_".$search_target} = 'N'; |
|
1397 | + elseif ($search_keyword == 'Y') $args->{"s_".$search_target} = 'Y'; |
|
1398 | 1398 | else $args->{"s_".$search_target} = ''; |
1399 | 1399 | break; |
1400 | 1400 | case 'is_secret' : |
1401 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1402 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1403 | - elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
1401 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
1402 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1403 | + elseif ($search_keyword == 'temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
1404 | 1404 | break; |
1405 | 1405 | case 'member_srl' : |
1406 | 1406 | case 'readed_count' : |
@@ -1408,10 +1408,10 @@ discard block |
||
1408 | 1408 | case 'comment_count' : |
1409 | 1409 | case 'trackback_count' : |
1410 | 1410 | case 'uploaded_count' : |
1411 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
1411 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
1412 | 1412 | break; |
1413 | 1413 | case 'blamed_count' : |
1414 | - $args->{"s_".$search_target} = (int)$search_keyword * -1; |
|
1414 | + $args->{"s_".$search_target} = (int) $search_keyword * -1; |
|
1415 | 1415 | break; |
1416 | 1416 | case 'regdate' : |
1417 | 1417 | case 'last_update' : |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | $use_division = true; |
1425 | 1425 | break; |
1426 | 1426 | case 'tag' : |
1427 | - $args->s_tags = str_replace(' ','%',$search_keyword); |
|
1427 | + $args->s_tags = str_replace(' ', '%', $search_keyword); |
|
1428 | 1428 | $query_id = 'document.getDocumentListWithinTag'; |
1429 | 1429 | break; |
1430 | 1430 | case 'extra_vars': |
@@ -1432,9 +1432,9 @@ discard block |
||
1432 | 1432 | $query_id = 'document.getDocumentListWithinExtraVars'; |
1433 | 1433 | break; |
1434 | 1434 | default : |
1435 | - if(strpos($search_target,'extra_vars')!==false) { |
|
1435 | + if (strpos($search_target, 'extra_vars') !== false) { |
|
1436 | 1436 | $args->var_idx = substr($search_target, strlen('extra_vars')); |
1437 | - $args->var_value = str_replace(' ','%',$search_keyword); |
|
1437 | + $args->var_value = str_replace(' ', '%', $search_keyword); |
|
1438 | 1438 | $args->sort_index = 'documents.'.$args->sort_index; |
1439 | 1439 | $query_id = 'document.getDocumentListWithExtraVars'; |
1440 | 1440 | } |
@@ -1451,18 +1451,18 @@ discard block |
||
1451 | 1451 | /** |
1452 | 1452 | * list_order asc sort of division that can be used only when |
1453 | 1453 | */ |
1454 | - if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
1454 | + if ($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
1455 | 1455 | |
1456 | 1456 | /** |
1457 | 1457 | * If it is true, use_division changed to use the document division |
1458 | 1458 | */ |
1459 | - if($use_division) |
|
1459 | + if ($use_division) |
|
1460 | 1460 | { |
1461 | 1461 | // Division begins |
1462 | - $division = (int)Context::get('division'); |
|
1462 | + $division = (int) Context::get('division'); |
|
1463 | 1463 | |
1464 | 1464 | // order by list_order and (module_srl===0 or module_srl may count), therefore case table full scan |
1465 | - if($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
1465 | + if ($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
1466 | 1466 | { |
1467 | 1467 | $listSqlID = 'document.getDocumentListUseIndex'; |
1468 | 1468 | $divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | // If you do not value the best division top |
1477 | - if(!$division) |
|
1477 | + if (!$division) |
|
1478 | 1478 | { |
1479 | 1479 | $division_args = new stdClass(); |
1480 | 1480 | $division_args->module_srl = $args->module_srl; |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | $division_args->statusList = $args->statusList; |
1486 | 1486 | |
1487 | 1487 | $output = executeQuery($divisionSqlID, $division_args, array('list_order')); |
1488 | - if($output->data) |
|
1488 | + if ($output->data) |
|
1489 | 1489 | { |
1490 | 1490 | $item = array_pop($output->data); |
1491 | 1491 | $division = $item->list_order; |
@@ -1494,10 +1494,10 @@ discard block |
||
1494 | 1494 | } |
1495 | 1495 | |
1496 | 1496 | // The last division |
1497 | - $last_division = (int)Context::get('last_division'); |
|
1497 | + $last_division = (int) Context::get('last_division'); |
|
1498 | 1498 | |
1499 | 1499 | // Division after division from the 5000 value of the specified Wanted |
1500 | - if(!$last_division) |
|
1500 | + if (!$last_division) |
|
1501 | 1501 | { |
1502 | 1502 | $last_division_args = new stdClass(); |
1503 | 1503 | $last_division_args->module_srl = $args->module_srl; |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | $last_division_args->page = 5001; |
1510 | 1510 | |
1511 | 1511 | $output = executeQuery($divisionSqlID, $last_division_args, array('list_order')); |
1512 | - if($output->data) |
|
1512 | + if ($output->data) |
|
1513 | 1513 | { |
1514 | 1514 | $item = array_pop($output->data); |
1515 | 1515 | $last_division = $item->list_order; |
@@ -1517,14 +1517,14 @@ discard block |
||
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | // Make sure that after last_division article |
1520 | - if($last_division) |
|
1520 | + if ($last_division) |
|
1521 | 1521 | { |
1522 | 1522 | $last_division_args = new stdClass(); |
1523 | 1523 | $last_division_args->module_srl = $args->module_srl; |
1524 | 1524 | $last_division_args->exclude_module_srl = $args->exclude_module_srl; |
1525 | 1525 | $last_division_args->list_order = $last_division; |
1526 | 1526 | $output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
1527 | - if($output->data->count<1) $last_division = null; |
|
1527 | + if ($output->data->count < 1) $last_division = null; |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | $args->division = $division; |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | * @param int $count |
1558 | 1558 | * @return object |
1559 | 1559 | */ |
1560 | - function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0 ) |
|
1560 | + function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0) |
|
1561 | 1561 | { |
1562 | 1562 | $args = new stdClass(); |
1563 | 1563 | $args->member_srl = $member_srl; |
@@ -1565,8 +1565,8 @@ discard block |
||
1565 | 1565 | $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
1566 | 1566 | $document_list = $output->data; |
1567 | 1567 | |
1568 | - if(!$document_list) return array(); |
|
1569 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
1568 | + if (!$document_list) return array(); |
|
1569 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
1570 | 1570 | |
1571 | 1571 | return $document_list; |
1572 | 1572 | } |
@@ -56,18 +56,24 @@ discard block |
||
56 | 56 | $_document_list = &$GLOBALS['XE_DOCUMENT_LIST']; |
57 | 57 | |
58 | 58 | // XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings |
59 | - if(count($_document_list) <= 0) return; |
|
59 | + if(count($_document_list) <= 0) { |
|
60 | + return; |
|
61 | + } |
|
60 | 62 | |
61 | 63 | // Find all called the document object variable has been set extension |
62 | 64 | $document_srls = array(); |
63 | 65 | foreach($_document_list as $key => $val) |
64 | 66 | { |
65 | - if(!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
67 | + if(!$val->document_srl || $checked_documents[$val->document_srl]) { |
|
68 | + continue; |
|
69 | + } |
|
66 | 70 | $checked_documents[$val->document_srl] = true; |
67 | 71 | $document_srls[] = $val->document_srl; |
68 | 72 | } |
69 | 73 | // If the document number, return detected |
70 | - if(!count($document_srls)) return; |
|
74 | + if(!count($document_srls)) { |
|
75 | + return; |
|
76 | + } |
|
71 | 77 | // Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable |
72 | 78 | //$obj->document_srl = implode(',',$document_srls); |
73 | 79 | $output = $this->getDocumentExtraVarsFromDB($document_srls); |
@@ -75,8 +81,12 @@ discard block |
||
75 | 81 | { |
76 | 82 | foreach($output->data as $key => $val) |
77 | 83 | { |
78 | - if(!isset($val->value)) continue; |
|
79 | - if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
84 | + if(!isset($val->value)) { |
|
85 | + continue; |
|
86 | + } |
|
87 | + if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) { |
|
88 | + $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
89 | + } |
|
80 | 90 | $extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); |
81 | 91 | } |
82 | 92 | } |
@@ -87,7 +97,9 @@ discard block |
||
87 | 97 | $document_srl = $document_srls[$i]; |
88 | 98 | unset($vars); |
89 | 99 | |
90 | - if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
100 | + if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) { |
|
101 | + continue; |
|
102 | + } |
|
91 | 103 | $module_srl = $_document_list[$document_srl]->get('module_srl'); |
92 | 104 | $extra_keys = $this->getExtraKeys($module_srl); |
93 | 105 | $vars = $extra_vars[$document_srl]; |
@@ -99,10 +111,15 @@ discard block |
||
99 | 111 | { |
100 | 112 | $extra_keys[$idx] = clone($key); |
101 | 113 | $val = $vars[$idx]; |
102 | - if(isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
103 | - else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
104 | - else if(isset($val[0])) $v = $val[0]; |
|
105 | - else $v = null; |
|
114 | + if(isset($val[$user_lang_code])) { |
|
115 | + $v = $val[$user_lang_code]; |
|
116 | + } else if(isset($val[$document_lang_code])) { |
|
117 | + $v = $val[$document_lang_code]; |
|
118 | + } else if(isset($val[0])) { |
|
119 | + $v = $val[0]; |
|
120 | + } else { |
|
121 | + $v = null; |
|
122 | + } |
|
106 | 123 | $extra_keys[$idx]->value = $v; |
107 | 124 | } |
108 | 125 | } |
@@ -111,9 +128,13 @@ discard block |
||
111 | 128 | $evars = new ExtraVar($module_srl); |
112 | 129 | $evars->setExtraVarKeys($extra_keys); |
113 | 130 | // Title Processing |
114 | - if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
131 | + if($vars[-1][$user_lang_code]) { |
|
132 | + $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
133 | + } |
|
115 | 134 | // Information processing |
116 | - if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
135 | + if($vars[-2][$user_lang_code]) { |
|
136 | + $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
137 | + } |
|
117 | 138 | |
118 | 139 | if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
119 | 140 | { |
@@ -134,15 +155,21 @@ discard block |
||
134 | 155 | */ |
135 | 156 | function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
136 | 157 | { |
137 | - if(!$document_srl) return new documentItem(); |
|
158 | + if(!$document_srl) { |
|
159 | + return new documentItem(); |
|
160 | + } |
|
138 | 161 | |
139 | 162 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
140 | 163 | { |
141 | 164 | $oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
142 | 165 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
143 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
166 | + if($load_extra_vars) { |
|
167 | + $this->setToAllDocumentExtraVars(); |
|
168 | + } |
|
169 | + } |
|
170 | + if($is_admin) { |
|
171 | + $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
144 | 172 | } |
145 | - if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
146 | 173 | |
147 | 174 | return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
148 | 175 | } |
@@ -161,8 +188,7 @@ discard block |
||
161 | 188 | { |
162 | 189 | $list_count = count($document_srls); |
163 | 190 | $document_srls = implode(',',$document_srls); |
164 | - } |
|
165 | - else |
|
191 | + } else |
|
166 | 192 | { |
167 | 193 | $list_count = 1; |
168 | 194 | } |
@@ -173,28 +199,38 @@ discard block |
||
173 | 199 | |
174 | 200 | $output = executeQuery('document.getDocuments', $args, $columnList); |
175 | 201 | $document_list = $output->data; |
176 | - if(!$document_list) return; |
|
177 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
202 | + if(!$document_list) { |
|
203 | + return; |
|
204 | + } |
|
205 | + if(!is_array($document_list)) { |
|
206 | + $document_list = array($document_list); |
|
207 | + } |
|
178 | 208 | |
179 | 209 | $document_count = count($document_list); |
180 | 210 | foreach($document_list as $key => $attribute) |
181 | 211 | { |
182 | 212 | $document_srl = $attribute->document_srl; |
183 | - if(!$document_srl) continue; |
|
213 | + if(!$document_srl) { |
|
214 | + continue; |
|
215 | + } |
|
184 | 216 | |
185 | 217 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
186 | 218 | { |
187 | 219 | $oDocument = null; |
188 | 220 | $oDocument = new documentItem(); |
189 | 221 | $oDocument->setAttribute($attribute, false); |
190 | - if($is_admin) $oDocument->setGrant(); |
|
222 | + if($is_admin) { |
|
223 | + $oDocument->setGrant(); |
|
224 | + } |
|
191 | 225 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
192 | 226 | } |
193 | 227 | |
194 | 228 | $result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
195 | 229 | } |
196 | 230 | |
197 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
231 | + if($load_extra_vars) { |
|
232 | + $this->setToAllDocumentExtraVars(); |
|
233 | + } |
|
198 | 234 | |
199 | 235 | $output = null; |
200 | 236 | if(count($result)) |
@@ -242,18 +278,15 @@ discard block |
||
242 | 278 | { |
243 | 279 | $output = $obj->use_alternate_output; |
244 | 280 | unset($obj->use_alternate_output); |
245 | - } |
|
246 | - elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
281 | + } elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
247 | 282 | { |
248 | 283 | $query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
249 | 284 | $args->sort_index = str_replace('documents.','',$args->sort_index); |
250 | 285 | $output = executeQueryArray($query_id, $args); |
251 | - } |
|
252 | - elseif ($sort_check->isExtraVars) |
|
286 | + } elseif ($sort_check->isExtraVars) |
|
253 | 287 | { |
254 | 288 | $output = executeQueryArray($query_id, $args); |
255 | - } |
|
256 | - else |
|
289 | + } else |
|
257 | 290 | { |
258 | 291 | // document.getDocumentList query execution |
259 | 292 | // Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
@@ -263,11 +296,15 @@ discard block |
||
263 | 296 | $group_args = clone($args); |
264 | 297 | $group_args->sort_index = 'documents.'.$args->sort_index; |
265 | 298 | $output = executeQueryArray($query_id, $group_args); |
266 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
299 | + if(!$output->toBool()||!count($output->data)) { |
|
300 | + return $output; |
|
301 | + } |
|
267 | 302 | |
268 | 303 | foreach($output->data as $key => $val) |
269 | 304 | { |
270 | - if($val->document_srl) $target_srls[] = $val->document_srl; |
|
305 | + if($val->document_srl) { |
|
306 | + $target_srls[] = $val->document_srl; |
|
307 | + } |
|
271 | 308 | } |
272 | 309 | |
273 | 310 | $page_navigation = $output->page_navigation; |
@@ -285,14 +322,15 @@ discard block |
||
285 | 322 | $output->total_count = $page_navigation->total_count; |
286 | 323 | $output->total_page = $page_navigation->total_page; |
287 | 324 | $output->page = $page_navigation->cur_page; |
288 | - } |
|
289 | - else |
|
325 | + } else |
|
290 | 326 | { |
291 | 327 | $output = executeQueryArray($query_id, $args, $columnList); |
292 | 328 | } |
293 | 329 | } |
294 | 330 | // Return if no result or an error occurs |
295 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
331 | + if(!$output->toBool()||!count($output->data)) { |
|
332 | + return $output; |
|
333 | + } |
|
296 | 334 | $idx = 0; |
297 | 335 | $data = $output->data; |
298 | 336 | unset($output->data); |
@@ -307,20 +345,26 @@ discard block |
||
307 | 345 | { |
308 | 346 | foreach($data as $key => $attribute) |
309 | 347 | { |
310 | - if($attribute->is_notice == 'Y') $virtual_number --; |
|
348 | + if($attribute->is_notice == 'Y') { |
|
349 | + $virtual_number --; |
|
350 | + } |
|
311 | 351 | } |
312 | 352 | } |
313 | 353 | |
314 | 354 | foreach($data as $key => $attribute) |
315 | 355 | { |
316 | - if($except_notice && $attribute->is_notice == 'Y') continue; |
|
356 | + if($except_notice && $attribute->is_notice == 'Y') { |
|
357 | + continue; |
|
358 | + } |
|
317 | 359 | $document_srl = $attribute->document_srl; |
318 | 360 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
319 | 361 | { |
320 | 362 | $oDocument = null; |
321 | 363 | $oDocument = new documentItem(); |
322 | 364 | $oDocument->setAttribute($attribute, false); |
323 | - if($is_admin) $oDocument->setGrant(); |
|
365 | + if($is_admin) { |
|
366 | + $oDocument->setGrant(); |
|
367 | + } |
|
324 | 368 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
325 | 369 | } |
326 | 370 | |
@@ -328,7 +372,9 @@ discard block |
||
328 | 372 | $virtual_number--; |
329 | 373 | } |
330 | 374 | |
331 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
375 | + if($load_extra_vars) { |
|
376 | + $this->setToAllDocumentExtraVars(); |
|
377 | + } |
|
332 | 378 | |
333 | 379 | if(count($output->data)) |
334 | 380 | { |
@@ -356,12 +402,16 @@ discard block |
||
356 | 402 | $args->module_srl = $obj->module_srl; |
357 | 403 | $args->category_srl= $obj->category_srl; |
358 | 404 | $output = executeQueryArray('document.getNoticeList', $args, $columnList); |
359 | - if(!$output->toBool()||!$output->data) return; |
|
405 | + if(!$output->toBool()||!$output->data) { |
|
406 | + return; |
|
407 | + } |
|
360 | 408 | |
361 | 409 | foreach($output->data as $key => $val) |
362 | 410 | { |
363 | 411 | $document_srl = $val->document_srl; |
364 | - if(!$document_srl) continue; |
|
412 | + if(!$document_srl) { |
|
413 | + continue; |
|
414 | + } |
|
365 | 415 | |
366 | 416 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
367 | 417 | { |
@@ -457,7 +507,9 @@ discard block |
||
457 | 507 | |
458 | 508 | $oExtraVar->setExtraVarKeys($output->data); |
459 | 509 | $keys = $oExtraVar->getExtraVars(); |
460 | - if(!$keys) $keys = array(); |
|
510 | + if(!$keys) { |
|
511 | + $keys = array(); |
|
512 | + } |
|
461 | 513 | |
462 | 514 | if($oCacheHandler->isSupport()) |
463 | 515 | { |
@@ -487,7 +539,9 @@ discard block |
||
487 | 539 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
488 | 540 | $this->setToAllDocumentExtraVars(); |
489 | 541 | } |
490 | - if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
542 | + if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) { |
|
543 | + ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
544 | + } |
|
491 | 545 | return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
492 | 546 | } |
493 | 547 | |
@@ -517,7 +571,9 @@ discard block |
||
517 | 571 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
518 | 572 | $module_srl = $oDocument->get('module_srl'); |
519 | 573 | $member_srl = $oDocument->get('member_srl'); |
520 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
574 | + if(!$module_srl) { |
|
575 | + return new Object(-1, 'msg_invalid_request'); |
|
576 | + } |
|
521 | 577 | |
522 | 578 | $oModuleModel = getModel('module'); |
523 | 579 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
@@ -590,7 +646,9 @@ discard block |
||
590 | 646 | */ |
591 | 647 | function getDocumentCount($module_srl, $search_obj = NULL) |
592 | 648 | { |
593 | - if(is_null($search_obj)) $search_obj = new stdClass(); |
|
649 | + if(is_null($search_obj)) { |
|
650 | + $search_obj = new stdClass(); |
|
651 | + } |
|
594 | 652 | $search_obj->module_srl = $module_srl; |
595 | 653 | |
596 | 654 | $output = executeQuery('document.getDocumentCount', $search_obj); |
@@ -607,7 +665,9 @@ discard block |
||
607 | 665 | function getDocumentCountByGroupStatus($search_obj = NULL) |
608 | 666 | { |
609 | 667 | $output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
610 | - if(!$output->toBool()) return array(); |
|
668 | + if(!$output->toBool()) { |
|
669 | + return array(); |
|
670 | + } |
|
611 | 671 | |
612 | 672 | return $output->data; |
613 | 673 | } |
@@ -646,21 +706,18 @@ discard block |
||
646 | 706 | if($sort_check->isExtraVars) |
647 | 707 | { |
648 | 708 | return 1; |
649 | - } |
|
650 | - else |
|
709 | + } else |
|
651 | 710 | { |
652 | 711 | if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
653 | 712 | { |
654 | 713 | if($args->order_type === 'desc') |
655 | 714 | { |
656 | 715 | $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
657 | - } |
|
658 | - else |
|
716 | + } else |
|
659 | 717 | { |
660 | 718 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
661 | 719 | } |
662 | - } |
|
663 | - else |
|
720 | + } else |
|
664 | 721 | { |
665 | 722 | return 1; |
666 | 723 | } |
@@ -686,15 +743,16 @@ discard block |
||
686 | 743 | $output = executeQuery('document.getCategory', $args, $columnList); |
687 | 744 | |
688 | 745 | $node = $output->data; |
689 | - if(!$node) return; |
|
746 | + if(!$node) { |
|
747 | + return; |
|
748 | + } |
|
690 | 749 | |
691 | 750 | if($node->group_srls) |
692 | 751 | { |
693 | 752 | $group_srls = explode(',',$node->group_srls); |
694 | 753 | unset($node->group_srls); |
695 | 754 | $node->group_srls = $group_srls; |
696 | - } |
|
697 | - else |
|
755 | + } else |
|
698 | 756 | { |
699 | 757 | unset($node->group_srls); |
700 | 758 | $node->group_srls = array(); |
@@ -712,7 +770,9 @@ discard block |
||
712 | 770 | $args = new stdClass(); |
713 | 771 | $args->category_srl = $category_srl; |
714 | 772 | $output = executeQuery('document.getChildCategoryCount',$args); |
715 | - if($output->data->count > 0) return true; |
|
773 | + if($output->data->count > 0) { |
|
774 | + return true; |
|
775 | + } |
|
716 | 776 | return false; |
717 | 777 | } |
718 | 778 | |
@@ -731,7 +791,9 @@ discard block |
||
731 | 791 | if(!file_exists($filename)) |
732 | 792 | { |
733 | 793 | $oDocumentController = getController('document'); |
734 | - if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
794 | + if(!$oDocumentController->makeCategoryFile($module_srl)) { |
|
795 | + return array(); |
|
796 | + } |
|
735 | 797 | } |
736 | 798 | |
737 | 799 | include($filename); |
@@ -751,7 +813,9 @@ discard block |
||
751 | 813 | */ |
752 | 814 | function _arrangeCategory(&$document_category, $list, $depth) |
753 | 815 | { |
754 | - if(!count($list)) return; |
|
816 | + if(!count($list)) { |
|
817 | + return; |
|
818 | + } |
|
755 | 819 | $idx = 0; |
756 | 820 | $list_order = array(); |
757 | 821 | foreach($list as $key => $val) |
@@ -771,8 +835,11 @@ discard block |
||
771 | 835 | $obj->childs = array(); |
772 | 836 | $obj->grant = $val['grant']; |
773 | 837 | |
774 | - if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
775 | - else $selected = false; |
|
838 | + if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) { |
|
839 | + $selected = true; |
|
840 | + } else { |
|
841 | + $selected = false; |
|
842 | + } |
|
776 | 843 | |
777 | 844 | $obj->selected = $selected; |
778 | 845 | |
@@ -783,14 +850,18 @@ discard block |
||
783 | 850 | $parent_srl = $obj->parent_srl; |
784 | 851 | $document_count = $obj->document_count; |
785 | 852 | $expand = $obj->expand; |
786 | - if($selected) $expand = true; |
|
853 | + if($selected) { |
|
854 | + $expand = true; |
|
855 | + } |
|
787 | 856 | |
788 | 857 | while($parent_srl) |
789 | 858 | { |
790 | 859 | $document_category[$parent_srl]->document_count += $document_count; |
791 | 860 | $document_category[$parent_srl]->childs[] = $obj->category_srl; |
792 | 861 | $document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
793 | - if($expand) $document_category[$parent_srl]->expand = $expand; |
|
862 | + if($expand) { |
|
863 | + $document_category[$parent_srl]->expand = $expand; |
|
864 | + } |
|
794 | 865 | |
795 | 866 | $parent_srl = $document_category[$parent_srl]->parent_srl; |
796 | 867 | } |
@@ -798,7 +869,9 @@ discard block |
||
798 | 869 | |
799 | 870 | $document_category[$key] = $obj; |
800 | 871 | |
801 | - if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
872 | + if(count($val['list'])) { |
|
873 | + $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
874 | + } |
|
802 | 875 | } |
803 | 876 | $document_category[$list_order[0]]->first = true; |
804 | 877 | $document_category[$list_order[count($list_order)-1]]->last = true; |
@@ -866,13 +939,20 @@ discard block |
||
866 | 939 | } |
867 | 940 | // Module_srl passed the array may be a check whether the array |
868 | 941 | $args = new stdClass; |
869 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
870 | - else $args->module_srl = $obj->module_srl; |
|
942 | + if(is_array($obj->module_srl)) { |
|
943 | + $args->module_srl = implode(',', $obj->module_srl); |
|
944 | + } else { |
|
945 | + $args->module_srl = $obj->module_srl; |
|
946 | + } |
|
871 | 947 | |
872 | 948 | $output = executeQuery('document.getMonthlyArchivedList', $args); |
873 | - if(!$output->toBool()||!$output->data) return $output; |
|
949 | + if(!$output->toBool()||!$output->data) { |
|
950 | + return $output; |
|
951 | + } |
|
874 | 952 | |
875 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
953 | + if(!is_array($output->data)) { |
|
954 | + $output->data = array($output->data); |
|
955 | + } |
|
876 | 956 | |
877 | 957 | return $output; |
878 | 958 | } |
@@ -892,14 +972,21 @@ discard block |
||
892 | 972 | } |
893 | 973 | // Module_srl passed the array may be a check whether the array |
894 | 974 | $args = new stdClass; |
895 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
896 | - else $args->module_srl = $obj->module_srl; |
|
975 | + if(is_array($obj->module_srl)) { |
|
976 | + $args->module_srl = implode(',', $obj->module_srl); |
|
977 | + } else { |
|
978 | + $args->module_srl = $obj->module_srl; |
|
979 | + } |
|
897 | 980 | $args->regdate = $obj->regdate; |
898 | 981 | |
899 | 982 | $output = executeQuery('document.getDailyArchivedList', $args); |
900 | - if(!$output->toBool()) return $output; |
|
983 | + if(!$output->toBool()) { |
|
984 | + return $output; |
|
985 | + } |
|
901 | 986 | |
902 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
987 | + if(!is_array($output->data)) { |
|
988 | + $output->data = array($output->data); |
|
989 | + } |
|
903 | 990 | |
904 | 991 | return $output; |
905 | 992 | } |
@@ -910,7 +997,9 @@ discard block |
||
910 | 997 | */ |
911 | 998 | function getDocumentCategories() |
912 | 999 | { |
913 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
1000 | + if(!Context::get('is_logged')) { |
|
1001 | + return new Object(-1,'msg_not_permitted'); |
|
1002 | + } |
|
914 | 1003 | $module_srl = Context::get('module_srl'); |
915 | 1004 | $categories= $this->getCategoryList($module_srl); |
916 | 1005 | $lang = Context::get('lang'); |
@@ -937,8 +1026,12 @@ discard block |
||
937 | 1026 | $oModuleModel = getModel('module'); |
938 | 1027 | $config = $oModuleModel->getModuleConfig('document'); |
939 | 1028 | |
940 | - if(!$config) $config = new stdClass(); |
|
941 | - if(!$config->thumbnail_type) $config->thumbnail_type = 'crop'; |
|
1029 | + if(!$config) { |
|
1030 | + $config = new stdClass(); |
|
1031 | + } |
|
1032 | + if(!$config->thumbnail_type) { |
|
1033 | + $config->thumbnail_type = 'crop'; |
|
1034 | + } |
|
942 | 1035 | $GLOBALS['__document_config__'] = $config; |
943 | 1036 | } |
944 | 1037 | return $GLOBALS['__document_config__']; |
@@ -1003,7 +1096,9 @@ discard block |
||
1003 | 1096 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
1004 | 1097 | // Check permissions |
1005 | 1098 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1006 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
1099 | + if(!$grant->manager) { |
|
1100 | + return new Object(-1,'msg_not_permitted'); |
|
1101 | + } |
|
1007 | 1102 | |
1008 | 1103 | $category_srl = Context::get('category_srl'); |
1009 | 1104 | $category_info = $this->getCategory($category_srl); |
@@ -1023,15 +1118,20 @@ discard block |
||
1023 | 1118 | */ |
1024 | 1119 | function getDocumentSrlByAlias($mid, $alias) |
1025 | 1120 | { |
1026 | - if(!$mid || !$alias) return null; |
|
1121 | + if(!$mid || !$alias) { |
|
1122 | + return null; |
|
1123 | + } |
|
1027 | 1124 | $site_module_info = Context::get('site_module_info'); |
1028 | 1125 | $args = new stdClass; |
1029 | 1126 | $args->mid = $mid; |
1030 | 1127 | $args->alias_title = $alias; |
1031 | 1128 | $args->site_srl = $site_module_info->site_srl; |
1032 | 1129 | $output = executeQuery('document.getDocumentSrlByAlias', $args); |
1033 | - if(!$output->data) return null; |
|
1034 | - else return $output->data->document_srl; |
|
1130 | + if(!$output->data) { |
|
1131 | + return null; |
|
1132 | + } else { |
|
1133 | + return $output->data->document_srl; |
|
1134 | + } |
|
1035 | 1135 | } |
1036 | 1136 | |
1037 | 1137 | /** |
@@ -1042,15 +1142,20 @@ discard block |
||
1042 | 1142 | */ |
1043 | 1143 | function getDocumentSrlByTitle($module_srl, $title) |
1044 | 1144 | { |
1045 | - if(!$module_srl || !$title) return null; |
|
1145 | + if(!$module_srl || !$title) { |
|
1146 | + return null; |
|
1147 | + } |
|
1046 | 1148 | $args = new stdClass; |
1047 | 1149 | $args->module_srl = $module_srl; |
1048 | 1150 | $args->title = $title; |
1049 | 1151 | $output = executeQuery('document.getDocumentSrlByTitle', $args); |
1050 | - if(!$output->data) return null; |
|
1051 | - else |
|
1152 | + if(!$output->data) { |
|
1153 | + return null; |
|
1154 | + } else |
|
1052 | 1155 | { |
1053 | - if(is_array($output->data)) return $output->data[0]->document_srl; |
|
1156 | + if(is_array($output->data)) { |
|
1157 | + return $output->data[0]->document_srl; |
|
1158 | + } |
|
1054 | 1159 | return $output->data->document_srl; |
1055 | 1160 | } |
1056 | 1161 | } |
@@ -1062,13 +1167,18 @@ discard block |
||
1062 | 1167 | */ |
1063 | 1168 | function getAlias($document_srl) |
1064 | 1169 | { |
1065 | - if(!$document_srl) return null; |
|
1170 | + if(!$document_srl) { |
|
1171 | + return null; |
|
1172 | + } |
|
1066 | 1173 | $args = new stdClass; |
1067 | 1174 | $args->document_srl = $document_srl; |
1068 | 1175 | $output = executeQueryArray('document.getAliases', $args); |
1069 | 1176 | |
1070 | - if(!$output->data) return null; |
|
1071 | - else return $output->data[0]->alias_title; |
|
1177 | + if(!$output->data) { |
|
1178 | + return null; |
|
1179 | + } else { |
|
1180 | + return $output->data[0]->alias_title; |
|
1181 | + } |
|
1072 | 1182 | } |
1073 | 1183 | |
1074 | 1184 | /** |
@@ -1125,17 +1235,23 @@ discard block |
||
1125 | 1235 | { |
1126 | 1236 | case 'title' : |
1127 | 1237 | case 'content' : |
1128 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1238 | + if($search_keyword) { |
|
1239 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1240 | + } |
|
1129 | 1241 | $args->{"s_".$search_target} = $search_keyword; |
1130 | 1242 | $use_division = true; |
1131 | 1243 | break; |
1132 | 1244 | case 'title_content' : |
1133 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1245 | + if($search_keyword) { |
|
1246 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1247 | + } |
|
1134 | 1248 | $args->s_title = $search_keyword; |
1135 | 1249 | $args->s_content = $search_keyword; |
1136 | 1250 | break; |
1137 | 1251 | case 'user_id' : |
1138 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1252 | + if($search_keyword) { |
|
1253 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1254 | + } |
|
1139 | 1255 | $args->s_user_id = $search_keyword; |
1140 | 1256 | $args->sort_index = 'documents.'.$args->sort_index; |
1141 | 1257 | break; |
@@ -1143,13 +1259,18 @@ discard block |
||
1143 | 1259 | case 'nick_name' : |
1144 | 1260 | case 'email_address' : |
1145 | 1261 | case 'homepage' : |
1146 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1262 | + if($search_keyword) { |
|
1263 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1264 | + } |
|
1147 | 1265 | $args->{"s_".$search_target} = $search_keyword; |
1148 | 1266 | break; |
1149 | 1267 | case 'is_notice' : |
1150 | 1268 | case 'is_secret' : |
1151 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1152 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1269 | + if($search_keyword=='N') { |
|
1270 | + $args->statusList = array($this->getConfigStatus('public')); |
|
1271 | + } elseif($search_keyword=='Y') { |
|
1272 | + $args->statusList = array($this->getConfigStatus('secret')); |
|
1273 | + } |
|
1153 | 1274 | break; |
1154 | 1275 | case 'member_srl' : |
1155 | 1276 | case 'readed_count' : |
@@ -1191,34 +1312,45 @@ discard block |
||
1191 | 1312 | { |
1192 | 1313 | $args = new stdClass; |
1193 | 1314 | $document_srl = Context::get('document_srl'); |
1194 | - if(!$document_srl) return new Object(-1,'msg_invalid_request'); |
|
1315 | + if(!$document_srl) { |
|
1316 | + return new Object(-1,'msg_invalid_request'); |
|
1317 | + } |
|
1195 | 1318 | |
1196 | 1319 | $point = Context::get('point'); |
1197 | - if($point != -1) $point = 1; |
|
1320 | + if($point != -1) { |
|
1321 | + $point = 1; |
|
1322 | + } |
|
1198 | 1323 | |
1199 | 1324 | $oDocumentModel = getModel('document'); |
1200 | 1325 | $columnList = array('document_srl', 'module_srl'); |
1201 | 1326 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
1202 | 1327 | $module_srl = $oDocument->get('module_srl'); |
1203 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
1328 | + if(!$module_srl) { |
|
1329 | + return new Object(-1, 'msg_invalid_request'); |
|
1330 | + } |
|
1204 | 1331 | |
1205 | 1332 | $oModuleModel = getModel('module'); |
1206 | 1333 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
1207 | 1334 | if($point == -1) |
1208 | 1335 | { |
1209 | - if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request'); |
|
1336 | + if($document_config->use_vote_down!='S') { |
|
1337 | + return new Object(-1, 'msg_invalid_request'); |
|
1338 | + } |
|
1210 | 1339 | $args->below_point = 0; |
1211 | - } |
|
1212 | - else |
|
1340 | + } else |
|
1213 | 1341 | { |
1214 | - if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request'); |
|
1342 | + if($document_config->use_vote_up!='S') { |
|
1343 | + return new Object(-1, 'msg_invalid_request'); |
|
1344 | + } |
|
1215 | 1345 | $args->more_point = 0; |
1216 | 1346 | } |
1217 | 1347 | |
1218 | 1348 | $args->document_srl = $document_srl; |
1219 | 1349 | |
1220 | 1350 | $output = executeQueryArray('document.getVotedMemberList',$args); |
1221 | - if(!$output->toBool()) return $output; |
|
1351 | + if(!$output->toBool()) { |
|
1352 | + return $output; |
|
1353 | + } |
|
1222 | 1354 | |
1223 | 1355 | $oMemberModel = getModel('member'); |
1224 | 1356 | if($output->data) |
@@ -1240,9 +1372,11 @@ discard block |
||
1240 | 1372 | function getStatusNameList() |
1241 | 1373 | { |
1242 | 1374 | global $lang; |
1243 | - if(!isset($lang->status_name_list)) |
|
1244 | - return array_flip($this->getStatusList()); |
|
1245 | - else return $lang->status_name_list; |
|
1375 | + if(!isset($lang->status_name_list)) { |
|
1376 | + return array_flip($this->getStatusList()); |
|
1377 | + } else { |
|
1378 | + return $lang->status_name_list; |
|
1379 | + } |
|
1246 | 1380 | } |
1247 | 1381 | |
1248 | 1382 | /** |
@@ -1266,20 +1400,22 @@ discard block |
||
1266 | 1400 | if (!$extra_output->data || !$extra_output->toBool()) |
1267 | 1401 | { |
1268 | 1402 | $sortIndex = 'list_order'; |
1269 | - } |
|
1270 | - else |
|
1403 | + } else |
|
1271 | 1404 | { |
1272 | 1405 | $check_array = array(); |
1273 | 1406 | foreach($extra_output->data as $val) |
1274 | 1407 | { |
1275 | 1408 | $check_array[] = $val->eid; |
1276 | 1409 | } |
1277 | - if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
1278 | - else $isExtraVars = true; |
|
1410 | + if(!in_array($sortIndex, $check_array)) { |
|
1411 | + $sortIndex = 'list_order'; |
|
1412 | + } else { |
|
1413 | + $isExtraVars = true; |
|
1414 | + } |
|
1279 | 1415 | } |
1416 | + } else { |
|
1417 | + $sortIndex = 'list_order'; |
|
1280 | 1418 | } |
1281 | - else |
|
1282 | - $sortIndex = 'list_order'; |
|
1283 | 1419 | } |
1284 | 1420 | $returnObj = new stdClass(); |
1285 | 1421 | $returnObj->sort_index = $sortIndex; |
@@ -1317,7 +1453,9 @@ discard block |
||
1317 | 1453 | |
1318 | 1454 | // Check the target and sequence alignment |
1319 | 1455 | $orderType = array('desc' => 1, 'asc' => 1); |
1320 | - if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
1456 | + if(!isset($orderType[$args->order_type])) { |
|
1457 | + $args->order_type = 'asc'; |
|
1458 | + } |
|
1321 | 1459 | |
1322 | 1460 | // If that came across mid module_srl instead of a direct module_srl guhaejum |
1323 | 1461 | if($searchOpt->mid) |
@@ -1328,21 +1466,29 @@ discard block |
||
1328 | 1466 | } |
1329 | 1467 | |
1330 | 1468 | // Module_srl passed the array may be a check whether the array |
1331 | - if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
1332 | - else $args->module_srl = $searchOpt->module_srl; |
|
1469 | + if(is_array($searchOpt->module_srl)) { |
|
1470 | + $args->module_srl = implode(',', $searchOpt->module_srl); |
|
1471 | + } else { |
|
1472 | + $args->module_srl = $searchOpt->module_srl; |
|
1473 | + } |
|
1333 | 1474 | |
1334 | 1475 | // Except for the test module_srl |
1335 | - if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
1336 | - else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
|
1476 | + if(is_array($searchOpt->exclude_module_srl)) { |
|
1477 | + $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
1478 | + } else { |
|
1479 | + $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
|
1480 | + } |
|
1337 | 1481 | |
1338 | 1482 | // only admin document list, temp document showing |
1339 | - if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
1340 | - else |
|
1483 | + if($searchOpt->statusList) { |
|
1484 | + $args->statusList = $searchOpt->statusList; |
|
1485 | + } else |
|
1341 | 1486 | { |
1342 | - if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
1343 | - $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
|
1344 | - else |
|
1345 | - $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
|
1487 | + if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) { |
|
1488 | + $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
|
1489 | + } else { |
|
1490 | + $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
|
1491 | + } |
|
1346 | 1492 | } |
1347 | 1493 | |
1348 | 1494 | // Category is selected, further sub-categories until all conditions |
@@ -1370,18 +1516,24 @@ discard block |
||
1370 | 1516 | { |
1371 | 1517 | case 'title' : |
1372 | 1518 | case 'content' : |
1373 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1519 | + if($search_keyword) { |
|
1520 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1521 | + } |
|
1374 | 1522 | $args->{"s_".$search_target} = $search_keyword; |
1375 | 1523 | $use_division = true; |
1376 | 1524 | break; |
1377 | 1525 | case 'title_content' : |
1378 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1526 | + if($search_keyword) { |
|
1527 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1528 | + } |
|
1379 | 1529 | $args->s_title = $search_keyword; |
1380 | 1530 | $args->s_content = $search_keyword; |
1381 | 1531 | $use_division = true; |
1382 | 1532 | break; |
1383 | 1533 | case 'user_id' : |
1384 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1534 | + if($search_keyword) { |
|
1535 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1536 | + } |
|
1385 | 1537 | $args->s_user_id = $search_keyword; |
1386 | 1538 | $args->sort_index = 'documents.'.$args->sort_index; |
1387 | 1539 | break; |
@@ -1389,18 +1541,28 @@ discard block |
||
1389 | 1541 | case 'nick_name' : |
1390 | 1542 | case 'email_address' : |
1391 | 1543 | case 'homepage' : |
1392 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1544 | + if($search_keyword) { |
|
1545 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
1546 | + } |
|
1393 | 1547 | $args->{"s_".$search_target} = $search_keyword; |
1394 | 1548 | break; |
1395 | 1549 | case 'is_notice' : |
1396 | - if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
1397 | - elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
1398 | - else $args->{"s_".$search_target} = ''; |
|
1550 | + if($search_keyword=='N') { |
|
1551 | + $args->{"s_".$search_target} = 'N'; |
|
1552 | + } elseif($search_keyword=='Y') { |
|
1553 | + $args->{"s_".$search_target} = 'Y'; |
|
1554 | + } else { |
|
1555 | + $args->{"s_".$search_target} = ''; |
|
1556 | + } |
|
1399 | 1557 | break; |
1400 | 1558 | case 'is_secret' : |
1401 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1402 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1403 | - elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
1559 | + if($search_keyword=='N') { |
|
1560 | + $args->statusList = array($this->getConfigStatus('public')); |
|
1561 | + } elseif($search_keyword=='Y') { |
|
1562 | + $args->statusList = array($this->getConfigStatus('secret')); |
|
1563 | + } elseif($search_keyword=='temp') { |
|
1564 | + $args->statusList = array($this->getConfigStatus('temp')); |
|
1565 | + } |
|
1404 | 1566 | break; |
1405 | 1567 | case 'member_srl' : |
1406 | 1568 | case 'readed_count' : |
@@ -1445,13 +1607,14 @@ discard block |
||
1445 | 1607 | if ($searchOpt->isExtraVars) |
1446 | 1608 | { |
1447 | 1609 | $query_id = 'document.getDocumentListExtraSort'; |
1448 | - } |
|
1449 | - else |
|
1610 | + } else |
|
1450 | 1611 | { |
1451 | 1612 | /** |
1452 | 1613 | * list_order asc sort of division that can be used only when |
1453 | 1614 | */ |
1454 | - if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
1615 | + if($args->sort_index != 'list_order' || $args->order_type != 'asc') { |
|
1616 | + $use_division = false; |
|
1617 | + } |
|
1455 | 1618 | |
1456 | 1619 | /** |
1457 | 1620 | * If it is true, use_division changed to use the document division |
@@ -1466,8 +1629,7 @@ discard block |
||
1466 | 1629 | { |
1467 | 1630 | $listSqlID = 'document.getDocumentListUseIndex'; |
1468 | 1631 | $divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
1469 | - } |
|
1470 | - else |
|
1632 | + } else |
|
1471 | 1633 | { |
1472 | 1634 | $listSqlID = 'document.getDocumentList'; |
1473 | 1635 | $divisionSqlID = 'document.getDocumentDivision'; |
@@ -1524,7 +1686,9 @@ discard block |
||
1524 | 1686 | $last_division_args->exclude_module_srl = $args->exclude_module_srl; |
1525 | 1687 | $last_division_args->list_order = $last_division; |
1526 | 1688 | $output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
1527 | - if($output->data->count<1) $last_division = null; |
|
1689 | + if($output->data->count<1) { |
|
1690 | + $last_division = null; |
|
1691 | + } |
|
1528 | 1692 | } |
1529 | 1693 | |
1530 | 1694 | $args->division = $division; |
@@ -1565,8 +1729,12 @@ discard block |
||
1565 | 1729 | $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
1566 | 1730 | $document_list = $output->data; |
1567 | 1731 | |
1568 | - if(!$document_list) return array(); |
|
1569 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
1732 | + if(!$document_list) { |
|
1733 | + return array(); |
|
1734 | + } |
|
1735 | + if(!is_array($document_list)) { |
|
1736 | + $document_list = array($document_list); |
|
1737 | + } |
|
1570 | 1738 | |
1571 | 1739 | return $document_list; |
1572 | 1740 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Document printing |
23 | 23 | * I make it out to find the geulman;; |
24 | - * @return void|Object |
|
24 | + * @return Object|null |
|
25 | 25 | */ |
26 | 26 | function dispDocumentPrint() |
27 | 27 | { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Selected by the administrator for the document management |
68 | - * @return void|Object |
|
68 | + * @return Object|null |
|
69 | 69 | */ |
70 | 70 | function dispDocumentManageDocument() |
71 | 71 | { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Document temp saved list |
149 | - * @return void |
|
149 | + * @return ModuleObject|null |
|
150 | 150 | */ |
151 | 151 | function dispTempSavedList() |
152 | 152 | { |
@@ -36,9 +36,13 @@ discard block |
||
36 | 36 | $oDocumentModel = getModel('document'); |
37 | 37 | // Creates an object for displaying the selected document |
38 | 38 | $oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager); |
39 | - if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request'); |
|
39 | + if(!$oDocument->isExists()) { |
|
40 | + return new Object(-1,'msg_invalid_request'); |
|
41 | + } |
|
40 | 42 | // Check permissions |
41 | - if(!$oDocument->isAccessible()) return new Object(-1,'msg_not_permitted'); |
|
43 | + if(!$oDocument->isAccessible()) { |
|
44 | + return new Object(-1,'msg_not_permitted'); |
|
45 | + } |
|
42 | 46 | // Information setting module |
43 | 47 | //Context::set('module_info', $module_info); //module_info not use in UI |
44 | 48 | // Browser title settings |
@@ -69,14 +73,18 @@ discard block |
||
69 | 73 | */ |
70 | 74 | function dispDocumentManageDocument() |
71 | 75 | { |
72 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
76 | + if(!Context::get('is_logged')) { |
|
77 | + return new Object(-1,'msg_not_permitted'); |
|
78 | + } |
|
73 | 79 | // Taken from a list of selected sessions |
74 | 80 | $flag_list = $_SESSION['document_management']; |
75 | 81 | if(count($flag_list)) |
76 | 82 | { |
77 | 83 | foreach($flag_list as $key => $val) |
78 | 84 | { |
79 | - if(!is_bool($val)) continue; |
|
85 | + if(!is_bool($val)) { |
|
86 | + continue; |
|
87 | + } |
|
80 | 88 | $document_srl_list[] = $key; |
81 | 89 | } |
82 | 90 | } |
@@ -90,7 +98,9 @@ discard block |
||
90 | 98 | |
91 | 99 | $oModuleModel = getModel('module'); |
92 | 100 | // The combination of module categories list and the list of modules |
93 | - if(count($module_list)>1) Context::set('module_list', $module_categories); |
|
101 | + if(count($module_list)>1) { |
|
102 | + Context::set('module_list', $module_categories); |
|
103 | + } |
|
94 | 104 | |
95 | 105 | $module_srl=Context::get('module_srl'); |
96 | 106 | Context::set('module_srl',$module_srl); |
@@ -122,7 +132,9 @@ discard block |
||
122 | 132 | // Get information of the current module |
123 | 133 | $current_module_info = Context::get('current_module_info'); |
124 | 134 | $current_module_srl = $current_module_info->module_srl; |
125 | - if(!$current_module_srl) return new Object(); |
|
135 | + if(!$current_module_srl) { |
|
136 | + return new Object(); |
|
137 | + } |
|
126 | 138 | } |
127 | 139 | |
128 | 140 | $oModuleModel = getModel('module'); |
@@ -134,7 +146,9 @@ discard block |
||
134 | 146 | { |
135 | 147 | $document_config = new stdClass(); |
136 | 148 | } |
137 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
149 | + if(!isset($document_config->use_history)) { |
|
150 | + $document_config->use_history = 'N'; |
|
151 | + } |
|
138 | 152 | Context::set('document_config', $document_config); |
139 | 153 | |
140 | 154 | $oTemplate = &TemplateHandler::getInstance(); |
@@ -154,7 +168,9 @@ discard block |
||
154 | 168 | |
155 | 169 | $oMemberModel = getModel('member'); |
156 | 170 | // A message appears if the user is not logged-in |
157 | - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); |
|
171 | + if(!$oMemberModel->isLogged()) { |
|
172 | + return $this->stop('msg_not_logged'); |
|
173 | + } |
|
158 | 174 | // Get the saved document (module_srl is set to member_srl instead) |
159 | 175 | $logged_info = Context::get('logged_info'); |
160 | 176 | $args = new stdClass(); |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | $oDocumentModel = getModel('document'); |
37 | 37 | // Creates an object for displaying the selected document |
38 | 38 | $oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager); |
39 | - if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request'); |
|
39 | + if (!$oDocument->isExists()) return new Object(-1, 'msg_invalid_request'); |
|
40 | 40 | // Check permissions |
41 | - if(!$oDocument->isAccessible()) return new Object(-1,'msg_not_permitted'); |
|
41 | + if (!$oDocument->isAccessible()) return new Object(-1, 'msg_not_permitted'); |
|
42 | 42 | // Information setting module |
43 | 43 | //Context::set('module_info', $module_info); //module_info not use in UI |
44 | 44 | // Browser title settings |
45 | 45 | Context::setBrowserTitle($oDocument->getTitleText()); |
46 | 46 | Context::set('oDocument', $oDocument); |
47 | 47 | |
48 | - Context::set('layout','none'); |
|
48 | + Context::set('layout', 'none'); |
|
49 | 49 | $this->setTemplatePath($this->module_path.'tpl'); |
50 | 50 | $this->setTemplateFile('print_page'); |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function dispDocumentPreview() |
58 | 58 | { |
59 | - Context::set('layout','none'); |
|
59 | + Context::set('layout', 'none'); |
|
60 | 60 | |
61 | 61 | $content = Context::get('content'); |
62 | 62 | $this->setTemplatePath($this->module_path.'tpl'); |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function dispDocumentManageDocument() |
71 | 71 | { |
72 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
72 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
73 | 73 | // Taken from a list of selected sessions |
74 | 74 | $flag_list = $_SESSION['document_management']; |
75 | - if(count($flag_list)) |
|
75 | + if (count($flag_list)) |
|
76 | 76 | { |
77 | - foreach($flag_list as $key => $val) |
|
77 | + foreach ($flag_list as $key => $val) |
|
78 | 78 | { |
79 | - if(!is_bool($val)) continue; |
|
79 | + if (!is_bool($val)) continue; |
|
80 | 80 | $document_srl_list[] = $key; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - if(count($document_srl_list)) |
|
84 | + if (count($document_srl_list)) |
|
85 | 85 | { |
86 | 86 | $oDocumentModel = getModel('document'); |
87 | 87 | $document_list = $oDocumentModel->getDocuments($document_srl_list, $this->grant->is_admin); |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | |
91 | 91 | $oModuleModel = getModel('module'); |
92 | 92 | // The combination of module categories list and the list of modules |
93 | - if(count($module_list)>1) Context::set('module_list', $module_categories); |
|
93 | + if (count($module_list) > 1) Context::set('module_list', $module_categories); |
|
94 | 94 | |
95 | - $module_srl=Context::get('module_srl'); |
|
96 | - Context::set('module_srl',$module_srl); |
|
95 | + $module_srl = Context::get('module_srl'); |
|
96 | + Context::set('module_srl', $module_srl); |
|
97 | 97 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
98 | - Context::set('mid',$module_info->mid); |
|
99 | - Context::set('browser_title',$module_info->browser_title); |
|
98 | + Context::set('mid', $module_info->mid); |
|
99 | + Context::set('browser_title', $module_info->browser_title); |
|
100 | 100 | |
101 | 101 | // Select Pop-up layout |
102 | 102 | $this->setLayoutPath('./common/tpl'); |
@@ -117,24 +117,24 @@ discard block |
||
117 | 117 | $current_module_srl = Context::get('module_srl'); |
118 | 118 | $current_module_srls = Context::get('module_srls'); |
119 | 119 | |
120 | - if(!$current_module_srl && !$current_module_srls) |
|
120 | + if (!$current_module_srl && !$current_module_srls) |
|
121 | 121 | { |
122 | 122 | // Get information of the current module |
123 | 123 | $current_module_info = Context::get('current_module_info'); |
124 | 124 | $current_module_srl = $current_module_info->module_srl; |
125 | - if(!$current_module_srl) return new Object(); |
|
125 | + if (!$current_module_srl) return new Object(); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $oModuleModel = getModel('module'); |
129 | - if($current_module_srl) |
|
129 | + if ($current_module_srl) |
|
130 | 130 | { |
131 | 131 | $document_config = $oModuleModel->getModulePartConfig('document', $current_module_srl); |
132 | 132 | } |
133 | - if(!$document_config) |
|
133 | + if (!$document_config) |
|
134 | 134 | { |
135 | 135 | $document_config = new stdClass(); |
136 | 136 | } |
137 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
137 | + if (!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
138 | 138 | Context::set('document_config', $document_config); |
139 | 139 | |
140 | 140 | $oTemplate = &TemplateHandler::getInstance(); |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | |
155 | 155 | $oMemberModel = getModel('member'); |
156 | 156 | // A message appears if the user is not logged-in |
157 | - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); |
|
157 | + if (!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); |
|
158 | 158 | // Get the saved document (module_srl is set to member_srl instead) |
159 | 159 | $logged_info = Context::get('logged_info'); |
160 | 160 | $args = new stdClass(); |
161 | 161 | $args->member_srl = $logged_info->member_srl; |
162 | 162 | $args->statusList = array($this->getConfigStatus('temp')); |
163 | - $args->page = (int)Context::get('page'); |
|
163 | + $args->page = (int) Context::get('page'); |
|
164 | 164 | $args->list_count = 10; |
165 | 165 | |
166 | 166 | $oDocumentModel = getModel('document'); |
@@ -238,6 +238,7 @@ |
||
238 | 238 | |
239 | 239 | /** |
240 | 240 | * @brief AutoSave |
241 | + * @param stdClass $args |
|
241 | 242 | */ |
242 | 243 | function doSaveDoc($args) |
243 | 244 | { |
@@ -47,20 +47,31 @@ discard block |
||
47 | 47 | { |
48 | 48 | $component = Context::get('component'); |
49 | 49 | $method = Context::get('method'); |
50 | - if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
50 | + if(!$component) { |
|
51 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
52 | + } |
|
51 | 53 | |
52 | 54 | $oEditorModel = getModel('editor'); |
53 | 55 | $oComponent = &$oEditorModel->getComponentObject($component); |
54 | - if(!$oComponent->toBool()) return $oComponent; |
|
56 | + if(!$oComponent->toBool()) { |
|
57 | + return $oComponent; |
|
58 | + } |
|
55 | 59 | |
56 | - if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
60 | + if(!method_exists($oComponent, $method)) { |
|
61 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
62 | + } |
|
57 | 63 | |
58 | 64 | //$output = call_user_method($method, $oComponent); |
59 | 65 | //$output = call_user_func(array($oComponent, $method)); |
60 | - if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
61 | - else return new Object(-1,sprintf('%s method is not exists', $method)); |
|
66 | + if(method_exists($oComponent, $method)) { |
|
67 | + $output = $oComponent->{$method}(); |
|
68 | + } else { |
|
69 | + return new Object(-1,sprintf('%s method is not exists', $method)); |
|
70 | + } |
|
62 | 71 | |
63 | - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; |
|
72 | + if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) { |
|
73 | + return $output; |
|
74 | + } |
|
64 | 75 | |
65 | 76 | $this->setError($oComponent->getError()); |
66 | 77 | $this->setMessage($oComponent->getMessage()); |
@@ -82,8 +93,11 @@ discard block |
||
82 | 93 | { |
83 | 94 | $module_srl = Context::get('target_module_srl'); |
84 | 95 | // To configure many of modules at once |
85 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
86 | - else $module_srl = array($module_srl); |
|
96 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
97 | + $module_srl = explode(',',$module_srl); |
|
98 | + } else { |
|
99 | + $module_srl = array($module_srl); |
|
100 | + } |
|
87 | 101 | |
88 | 102 | $editor_config = new stdClass; |
89 | 103 | $editor_config->editor_skin = Context::get('editor_skin'); |
@@ -98,10 +112,14 @@ discard block |
||
98 | 112 | for($i=0,$c=count($fonts);$i<$c;$i++) |
99 | 113 | { |
100 | 114 | $font = trim(str_replace(array('"','\''),'',$fonts[$i])); |
101 | - if(!$font) continue; |
|
115 | + if(!$font) { |
|
116 | + continue; |
|
117 | + } |
|
102 | 118 | $font_list[] = $font; |
103 | 119 | } |
104 | - if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
120 | + if(count($font_list)) { |
|
121 | + $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
122 | + } |
|
105 | 123 | } |
106 | 124 | $editor_config->content_font_size = Context::get('content_font_size'); |
107 | 125 | $editor_config->sel_editor_colorset = Context::get('sel_editor_colorset'); |
@@ -115,12 +133,10 @@ discard block |
||
115 | 133 | if(!$grant) |
116 | 134 | { |
117 | 135 | $editor_config->{$key} = array(); |
118 | - } |
|
119 | - else if(is_array($grant)) |
|
136 | + } else if(is_array($grant)) |
|
120 | 137 | { |
121 | 138 | $editor_config->{$key} = $grant; |
122 | - } |
|
123 | - else |
|
139 | + } else |
|
124 | 140 | { |
125 | 141 | $editor_config->{$key} = explode('|@|', $grant); |
126 | 142 | } |
@@ -129,13 +145,17 @@ discard block |
||
129 | 145 | $editor_config->editor_height = (int)Context::get('editor_height'); |
130 | 146 | $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); |
131 | 147 | $editor_config->enable_autosave = Context::get('enable_autosave'); |
132 | - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
148 | + if($editor_config->enable_autosave != 'Y') { |
|
149 | + $editor_config->enable_autosave = 'N'; |
|
150 | + } |
|
133 | 151 | |
134 | 152 | $oModuleController = getController('module'); |
135 | 153 | for($i=0;$i<count($module_srl);$i++) |
136 | 154 | { |
137 | 155 | $srl = trim($module_srl[$i]); |
138 | - if(!$srl) continue; |
|
156 | + if(!$srl) { |
|
157 | + continue; |
|
158 | + } |
|
139 | 159 | $oModuleController->insertModulePartConfig('editor',$srl,$editor_config); |
140 | 160 | } |
141 | 161 | |
@@ -151,7 +171,9 @@ discard block |
||
151 | 171 | */ |
152 | 172 | function triggerEditorComponentCompile(&$content) |
153 | 173 | { |
154 | - if(Context::getResponseMethod()!='HTML') return new Object(); |
|
174 | + if(Context::getResponseMethod()!='HTML') { |
|
175 | + return new Object(); |
|
176 | + } |
|
155 | 177 | |
156 | 178 | $module_info = Context::get('module_info'); |
157 | 179 | $module_srl = $module_info->module_srl; |
@@ -169,13 +191,14 @@ discard block |
||
169 | 191 | for($i = 0, $c = count($ini); $i < $c; $i++) |
170 | 192 | { |
171 | 193 | $file = trim($ini[$i]); |
172 | - if(!$file) continue; |
|
194 | + if(!$file) { |
|
195 | + continue; |
|
196 | + } |
|
173 | 197 | |
174 | 198 | if(substr_compare($file, '.css', -4) === 0) |
175 | 199 | { |
176 | 200 | Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
177 | - } |
|
178 | - elseif(substr_compare($file, '.js', -3) === 0) |
|
201 | + } elseif(substr_compare($file, '.js', -3) === 0) |
|
179 | 202 | { |
180 | 203 | Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
181 | 204 | } |
@@ -188,8 +211,12 @@ discard block |
||
188 | 211 | { |
189 | 212 | $buff = array(); |
190 | 213 | $buff[] = '<style> .xe_content { '; |
191 | - if($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
192 | - if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
214 | + if($content_font) { |
|
215 | + $buff[] = 'font-family:'.$content_font.';'; |
|
216 | + } |
|
217 | + if($content_font_size) { |
|
218 | + $buff[] = 'font-size:'.$content_font_size.';'; |
|
219 | + } |
|
193 | 220 | $buff[] = ' }</style>'; |
194 | 221 | Context::addHtmlHeader(implode('', $buff)); |
195 | 222 | } |
@@ -221,17 +248,23 @@ discard block |
||
221 | 248 | $xml_obj->attrs = new stdClass; |
222 | 249 | for($i=0,$c=count($m[0]);$i<$c;$i++) |
223 | 250 | { |
224 | - if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
251 | + if(!isset($xml_obj->attrs)) { |
|
252 | + $xml_obj->attrs = new stdClass; |
|
253 | + } |
|
225 | 254 | $xml_obj->attrs->{$m[1][$i]} = $m[2][$i]; |
226 | 255 | } |
227 | 256 | $xml_obj->body = $match[4]; |
228 | 257 | |
229 | - if(!$xml_obj->attrs->editor_component) return $match[0]; |
|
258 | + if(!$xml_obj->attrs->editor_component) { |
|
259 | + return $match[0]; |
|
260 | + } |
|
230 | 261 | |
231 | 262 | // Get converted codes by using component::transHTML() |
232 | 263 | $oEditorModel = getModel('editor'); |
233 | 264 | $oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0); |
234 | - if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0]; |
|
265 | + if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) { |
|
266 | + return $match[0]; |
|
267 | + } |
|
235 | 268 | |
236 | 269 | return $oComponent->transHTML($xml_obj); |
237 | 270 | } |
@@ -241,13 +274,14 @@ discard block |
||
241 | 274 | */ |
242 | 275 | function doSaveDoc($args) |
243 | 276 | { |
244 | - if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
277 | + if(!$args->document_srl) { |
|
278 | + $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
279 | + } |
|
245 | 280 | if(Context::get('is_logged')) |
246 | 281 | { |
247 | 282 | $logged_info = Context::get('logged_info'); |
248 | 283 | $args->member_srl = $logged_info->member_srl; |
249 | - } |
|
250 | - else |
|
284 | + } else |
|
251 | 285 | { |
252 | 286 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
253 | 287 | } |
@@ -307,8 +341,7 @@ discard block |
||
307 | 341 | { |
308 | 342 | $logged_info = Context::get('logged_info'); |
309 | 343 | $args->member_srl = $logged_info->member_srl; |
310 | - } |
|
311 | - else |
|
344 | + } else |
|
312 | 345 | { |
313 | 346 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
314 | 347 | } |
@@ -322,7 +355,9 @@ discard block |
||
322 | 355 | // Check if the auto-saved document already exists |
323 | 356 | $output = executeQuery('editor.getSavedDocument', $args); |
324 | 357 | $saved_doc = $output->data; |
325 | - if(!$saved_doc) return; |
|
358 | + if(!$saved_doc) { |
|
359 | + return; |
|
360 | + } |
|
326 | 361 | |
327 | 362 | $oDocumentModel = getModel('document'); |
328 | 363 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
@@ -356,14 +391,17 @@ discard block |
||
356 | 391 | $oEditorModel = getModel('editor'); |
357 | 392 | $args = new stdClass; |
358 | 393 | |
359 | - if($filter_enabled) $args->enabled = "Y"; |
|
394 | + if($filter_enabled) { |
|
395 | + $args->enabled = "Y"; |
|
396 | + } |
|
360 | 397 | |
361 | 398 | if($site_srl) |
362 | 399 | { |
363 | 400 | $args->site_srl = $site_srl; |
364 | 401 | $output = executeQuery('editor.getSiteComponentList', $args); |
402 | + } else { |
|
403 | + $output = executeQuery('editor.getComponentList', $args); |
|
365 | 404 | } |
366 | - else $output = executeQuery('editor.getComponentList', $args); |
|
367 | 405 | $db_list = $output->data; |
368 | 406 | |
369 | 407 | // Get a list of files |
@@ -377,21 +415,30 @@ discard block |
||
377 | 415 | if($logged_info->group_list && is_array($logged_info->group_list)) |
378 | 416 | { |
379 | 417 | $group_list = array_keys($logged_info->group_list); |
418 | + } else { |
|
419 | + $group_list = array(); |
|
380 | 420 | } |
381 | - else $group_list = array(); |
|
382 | 421 | } |
383 | 422 | |
384 | 423 | // Get xml information for looping DB list |
385 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
424 | + if(!is_array($db_list)) { |
|
425 | + $db_list = array($db_list); |
|
426 | + } |
|
386 | 427 | $component_list = new stdClass(); |
387 | 428 | foreach($db_list as $component) |
388 | 429 | { |
389 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
430 | + if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
431 | + continue; |
|
432 | + } |
|
390 | 433 | |
391 | 434 | $component_name = $component->component_name; |
392 | - if(!$component_name) continue; |
|
435 | + if(!$component_name) { |
|
436 | + continue; |
|
437 | + } |
|
393 | 438 | |
394 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
439 | + if(!in_array($component_name, $downloaded_list)) { |
|
440 | + continue; |
|
441 | + } |
|
395 | 442 | |
396 | 443 | unset($xml_info); |
397 | 444 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
@@ -445,8 +492,12 @@ discard block |
||
445 | 492 | // Get buttons, icons, images |
446 | 493 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
447 | 494 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
448 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
449 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
495 | + if(file_exists($icon_file)) { |
|
496 | + $component_list->{$component_name}->icon = true; |
|
497 | + } |
|
498 | + if(file_exists($component_icon_file)) { |
|
499 | + $component_list->{$component_name}->component_icon = true; |
|
500 | + } |
|
450 | 501 | } |
451 | 502 | |
452 | 503 | // Return if it checks enabled only |
@@ -461,9 +512,13 @@ discard block |
||
461 | 512 | // Get xml_info of downloaded list |
462 | 513 | foreach($downloaded_list as $component_name) |
463 | 514 | { |
464 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
515 | + if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
516 | + continue; |
|
517 | + } |
|
465 | 518 | // Pass if configured |
466 | - if($component_list->{$component_name}) continue; |
|
519 | + if($component_list->{$component_name}) { |
|
520 | + continue; |
|
521 | + } |
|
467 | 522 | // Insert data into the DB |
468 | 523 | $oEditorController = getAdminController('editor'); |
469 | 524 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -47,28 +47,28 @@ discard block |
||
47 | 47 | { |
48 | 48 | $component = Context::get('component'); |
49 | 49 | $method = Context::get('method'); |
50 | - if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
50 | + if (!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
51 | 51 | |
52 | 52 | $oEditorModel = getModel('editor'); |
53 | 53 | $oComponent = &$oEditorModel->getComponentObject($component); |
54 | - if(!$oComponent->toBool()) return $oComponent; |
|
54 | + if (!$oComponent->toBool()) return $oComponent; |
|
55 | 55 | |
56 | - if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
56 | + if (!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
57 | 57 | |
58 | 58 | //$output = call_user_method($method, $oComponent); |
59 | 59 | //$output = call_user_func(array($oComponent, $method)); |
60 | - if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
61 | - else return new Object(-1,sprintf('%s method is not exists', $method)); |
|
60 | + if (method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
61 | + else return new Object(-1, sprintf('%s method is not exists', $method)); |
|
62 | 62 | |
63 | - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; |
|
63 | + if ((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; |
|
64 | 64 | |
65 | 65 | $this->setError($oComponent->getError()); |
66 | 66 | $this->setMessage($oComponent->getMessage()); |
67 | 67 | |
68 | 68 | $vars = $oComponent->getVariables(); |
69 | - if(count($vars)) |
|
69 | + if (count($vars)) |
|
70 | 70 | { |
71 | - foreach($vars as $key => $val) |
|
71 | + foreach ($vars as $key => $val) |
|
72 | 72 | { |
73 | 73 | $this->add($key, $val); |
74 | 74 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $module_srl = Context::get('target_module_srl'); |
84 | 84 | // To configure many of modules at once |
85 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
85 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
86 | 86 | else $module_srl = array($module_srl); |
87 | 87 | |
88 | 88 | $editor_config = new stdClass; |
@@ -91,32 +91,32 @@ discard block |
||
91 | 91 | $editor_config->content_style = Context::get('content_style'); |
92 | 92 | $editor_config->comment_content_style = Context::get('comment_content_style'); |
93 | 93 | $editor_config->content_font = Context::get('content_font'); |
94 | - if($editor_config->content_font) |
|
94 | + if ($editor_config->content_font) |
|
95 | 95 | { |
96 | 96 | $font_list = array(); |
97 | - $fonts = explode(',',$editor_config->content_font); |
|
98 | - for($i=0,$c=count($fonts);$i<$c;$i++) |
|
97 | + $fonts = explode(',', $editor_config->content_font); |
|
98 | + for ($i = 0, $c = count($fonts); $i < $c; $i++) |
|
99 | 99 | { |
100 | - $font = trim(str_replace(array('"','\''),'',$fonts[$i])); |
|
101 | - if(!$font) continue; |
|
100 | + $font = trim(str_replace(array('"', '\''), '', $fonts[$i])); |
|
101 | + if (!$font) continue; |
|
102 | 102 | $font_list[] = $font; |
103 | 103 | } |
104 | - if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
104 | + if (count($font_list)) $editor_config->content_font = '"'.implode('","', $font_list).'"'; |
|
105 | 105 | } |
106 | 106 | $editor_config->content_font_size = Context::get('content_font_size'); |
107 | 107 | $editor_config->sel_editor_colorset = Context::get('sel_editor_colorset'); |
108 | 108 | $editor_config->sel_comment_editor_colorset = Context::get('sel_comment_editor_colorset'); |
109 | 109 | |
110 | - $grants = array('enable_html_grant','enable_comment_html_grant','upload_file_grant','comment_upload_file_grant','enable_default_component_grant','enable_comment_default_component_grant','enable_component_grant','enable_comment_component_grant'); |
|
110 | + $grants = array('enable_html_grant', 'enable_comment_html_grant', 'upload_file_grant', 'comment_upload_file_grant', 'enable_default_component_grant', 'enable_comment_default_component_grant', 'enable_component_grant', 'enable_comment_component_grant'); |
|
111 | 111 | |
112 | - foreach($grants as $key) |
|
112 | + foreach ($grants as $key) |
|
113 | 113 | { |
114 | 114 | $grant = Context::get($key); |
115 | - if(!$grant) |
|
115 | + if (!$grant) |
|
116 | 116 | { |
117 | 117 | $editor_config->{$key} = array(); |
118 | 118 | } |
119 | - else if(is_array($grant)) |
|
119 | + else if (is_array($grant)) |
|
120 | 120 | { |
121 | 121 | $editor_config->{$key} = $grant; |
122 | 122 | } |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - $editor_config->editor_height = (int)Context::get('editor_height'); |
|
130 | - $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); |
|
129 | + $editor_config->editor_height = (int) Context::get('editor_height'); |
|
130 | + $editor_config->comment_editor_height = (int) Context::get('comment_editor_height'); |
|
131 | 131 | $editor_config->enable_autosave = Context::get('enable_autosave'); |
132 | - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
132 | + if ($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
133 | 133 | |
134 | 134 | $oModuleController = getController('module'); |
135 | - for($i=0;$i<count($module_srl);$i++) |
|
135 | + for ($i = 0; $i < count($module_srl); $i++) |
|
136 | 136 | { |
137 | 137 | $srl = trim($module_srl[$i]); |
138 | - if(!$srl) continue; |
|
139 | - $oModuleController->insertModulePartConfig('editor',$srl,$editor_config); |
|
138 | + if (!$srl) continue; |
|
139 | + $oModuleController->insertModulePartConfig('editor', $srl, $editor_config); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | $this->setError(-1); |
@@ -151,31 +151,31 @@ discard block |
||
151 | 151 | */ |
152 | 152 | function triggerEditorComponentCompile(&$content) |
153 | 153 | { |
154 | - if(Context::getResponseMethod()!='HTML') return new Object(); |
|
154 | + if (Context::getResponseMethod() != 'HTML') return new Object(); |
|
155 | 155 | |
156 | 156 | $module_info = Context::get('module_info'); |
157 | 157 | $module_srl = $module_info->module_srl; |
158 | - if($module_srl) |
|
158 | + if ($module_srl) |
|
159 | 159 | { |
160 | 160 | $oEditorModel = getModel('editor'); |
161 | 161 | $editor_config = $oEditorModel->getEditorConfig($module_srl); |
162 | 162 | $content_style = $editor_config->content_style; |
163 | - if($content_style) |
|
163 | + if ($content_style) |
|
164 | 164 | { |
165 | - $path = _XE_PATH_ . 'modules/editor/styles/'.$content_style.'/'; |
|
166 | - if(is_dir($path) && file_exists($path . 'style.ini')) |
|
165 | + $path = _XE_PATH_.'modules/editor/styles/'.$content_style.'/'; |
|
166 | + if (is_dir($path) && file_exists($path.'style.ini')) |
|
167 | 167 | { |
168 | 168 | $ini = file($path.'style.ini'); |
169 | - for($i = 0, $c = count($ini); $i < $c; $i++) |
|
169 | + for ($i = 0, $c = count($ini); $i < $c; $i++) |
|
170 | 170 | { |
171 | 171 | $file = trim($ini[$i]); |
172 | - if(!$file) continue; |
|
172 | + if (!$file) continue; |
|
173 | 173 | |
174 | - if(substr_compare($file, '.css', -4) === 0) |
|
174 | + if (substr_compare($file, '.css', -4) === 0) |
|
175 | 175 | { |
176 | 176 | Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
177 | 177 | } |
178 | - elseif(substr_compare($file, '.js', -3) === 0) |
|
178 | + elseif (substr_compare($file, '.js', -3) === 0) |
|
179 | 179 | { |
180 | 180 | Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
181 | 181 | } |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | } |
185 | 185 | $content_font = $editor_config->content_font; |
186 | 186 | $content_font_size = $editor_config->content_font_size; |
187 | - if($content_font || $content_font_size) |
|
187 | + if ($content_font || $content_font_size) |
|
188 | 188 | { |
189 | 189 | $buff = array(); |
190 | 190 | $buff[] = '<style> .xe_content { '; |
191 | - if($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
192 | - if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
191 | + if ($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
192 | + if ($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
193 | 193 | $buff[] = ' }</style>'; |
194 | 194 | Context::addHtmlHeader(implode('', $buff)); |
195 | 195 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | function transComponent($content) |
206 | 206 | { |
207 | - $content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this,'transEditorComponent'), $content); |
|
207 | + $content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this, 'transEditorComponent'), $content); |
|
208 | 208 | return $content; |
209 | 209 | } |
210 | 210 | |
@@ -219,19 +219,19 @@ discard block |
||
219 | 219 | |
220 | 220 | $xml_obj = new stdClass; |
221 | 221 | $xml_obj->attrs = new stdClass; |
222 | - for($i=0,$c=count($m[0]);$i<$c;$i++) |
|
222 | + for ($i = 0, $c = count($m[0]); $i < $c; $i++) |
|
223 | 223 | { |
224 | - if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
224 | + if (!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
225 | 225 | $xml_obj->attrs->{$m[1][$i]} = $m[2][$i]; |
226 | 226 | } |
227 | 227 | $xml_obj->body = $match[4]; |
228 | 228 | |
229 | - if(!$xml_obj->attrs->editor_component) return $match[0]; |
|
229 | + if (!$xml_obj->attrs->editor_component) return $match[0]; |
|
230 | 230 | |
231 | 231 | // Get converted codes by using component::transHTML() |
232 | 232 | $oEditorModel = getModel('editor'); |
233 | 233 | $oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0); |
234 | - if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0]; |
|
234 | + if (!is_object($oComponent) || !method_exists($oComponent, 'transHTML')) return $match[0]; |
|
235 | 235 | |
236 | 236 | return $oComponent->transHTML($xml_obj); |
237 | 237 | } |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | */ |
242 | 242 | function doSaveDoc($args) |
243 | 243 | { |
244 | - if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
245 | - if(Context::get('is_logged')) |
|
244 | + if (!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
245 | + if (Context::get('is_logged')) |
|
246 | 246 | { |
247 | 247 | $logged_info = Context::get('logged_info'); |
248 | 248 | $args->member_srl = $logged_info->member_srl; |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | // Get the current module if module_srl doesn't exist |
256 | - if(!$args->module_srl) |
|
256 | + if (!$args->module_srl) |
|
257 | 257 | { |
258 | 258 | $args->module_srl = Context::get('module_srl'); |
259 | 259 | } |
260 | - if(!$args->module_srl) |
|
260 | + if (!$args->module_srl) |
|
261 | 261 | { |
262 | 262 | $current_module_info = Context::get('current_module_info'); |
263 | 263 | $args->module_srl = $current_module_info->module_srl; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | function deleteSavedDoc($mode = false) |
304 | 304 | { |
305 | 305 | $args = new stdClass(); |
306 | - if(Context::get('is_logged')) |
|
306 | + if (Context::get('is_logged')) |
|
307 | 307 | { |
308 | 308 | $logged_info = Context::get('logged_info'); |
309 | 309 | $args->member_srl = $logged_info->member_srl; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | } |
315 | 315 | $args->module_srl = Context::get('module_srl'); |
316 | 316 | // Get the current module if module_srl doesn't exist |
317 | - if(!$args->module_srl) |
|
317 | + if (!$args->module_srl) |
|
318 | 318 | { |
319 | 319 | $current_module_info = Context::get('current_module_info'); |
320 | 320 | $args->module_srl = $current_module_info->module_srl; |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | // Check if the auto-saved document already exists |
323 | 323 | $output = executeQuery('editor.getSavedDocument', $args); |
324 | 324 | $saved_doc = $output->data; |
325 | - if(!$saved_doc) return; |
|
325 | + if (!$saved_doc) return; |
|
326 | 326 | |
327 | 327 | $oDocumentModel = getModel('document'); |
328 | 328 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
329 | - if(!$oSaved->isExists()) |
|
329 | + if (!$oSaved->isExists()) |
|
330 | 330 | { |
331 | - if($mode) |
|
331 | + if ($mode) |
|
332 | 332 | { |
333 | 333 | $output = executeQuery('editor.getSavedDocument', $args); |
334 | 334 | $output = ModuleHandler::triggerCall('editor.deleteSavedDoc', 'after', $saved_doc); |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | $oEditorModel = getModel('editor'); |
357 | 357 | $args = new stdClass; |
358 | 358 | |
359 | - if($filter_enabled) $args->enabled = "Y"; |
|
359 | + if ($filter_enabled) $args->enabled = "Y"; |
|
360 | 360 | |
361 | - if($site_srl) |
|
361 | + if ($site_srl) |
|
362 | 362 | { |
363 | 363 | $args->site_srl = $site_srl; |
364 | 364 | $output = executeQuery('editor.getSiteComponentList', $args); |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | |
372 | 372 | // Get information about log-in status and its group |
373 | 373 | $is_logged = Context::get('is_logged'); |
374 | - if($is_logged) |
|
374 | + if ($is_logged) |
|
375 | 375 | { |
376 | 376 | $logged_info = Context::get('logged_info'); |
377 | - if($logged_info->group_list && is_array($logged_info->group_list)) |
|
377 | + if ($logged_info->group_list && is_array($logged_info->group_list)) |
|
378 | 378 | { |
379 | 379 | $group_list = array_keys($logged_info->group_list); |
380 | 380 | } |
@@ -382,30 +382,30 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | // Get xml information for looping DB list |
385 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
385 | + if (!is_array($db_list)) $db_list = array($db_list); |
|
386 | 386 | $component_list = new stdClass(); |
387 | - foreach($db_list as $component) |
|
387 | + foreach ($db_list as $component) |
|
388 | 388 | { |
389 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
389 | + if (in_array($component->component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
390 | 390 | |
391 | 391 | $component_name = $component->component_name; |
392 | - if(!$component_name) continue; |
|
392 | + if (!$component_name) continue; |
|
393 | 393 | |
394 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
394 | + if (!in_array($component_name, $downloaded_list)) continue; |
|
395 | 395 | |
396 | 396 | unset($xml_info); |
397 | 397 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
398 | 398 | $xml_info->enabled = $component->enabled; |
399 | 399 | |
400 | - if($component->extra_vars) |
|
400 | + if ($component->extra_vars) |
|
401 | 401 | { |
402 | 402 | $extra_vars = unserialize($component->extra_vars); |
403 | - if($extra_vars->target_group) |
|
403 | + if ($extra_vars->target_group) |
|
404 | 404 | { |
405 | 405 | $xml_info->target_group = $extra_vars->target_group; |
406 | 406 | } |
407 | 407 | |
408 | - if($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
408 | + if ($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
409 | 409 | { |
410 | 410 | $xml_info->mid_list = $extra_vars->mid_list; |
411 | 411 | } |
@@ -432,9 +432,9 @@ discard block |
||
432 | 432 | if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue; |
433 | 433 | }*/ |
434 | 434 | // Check the configuration of the editor component |
435 | - if($xml_info->extra_vars) |
|
435 | + if ($xml_info->extra_vars) |
|
436 | 436 | { |
437 | - foreach($xml_info->extra_vars as $key => $val) |
|
437 | + foreach ($xml_info->extra_vars as $key => $val) |
|
438 | 438 | { |
439 | 439 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
440 | 440 | } |
@@ -445,25 +445,25 @@ discard block |
||
445 | 445 | // Get buttons, icons, images |
446 | 446 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
447 | 447 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
448 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
449 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
448 | + if (file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
449 | + if (file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | // Return if it checks enabled only |
453 | - if($filter_enabled) |
|
453 | + if ($filter_enabled) |
|
454 | 454 | { |
455 | 455 | $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); |
456 | - $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list))); |
|
456 | + $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); |
|
457 | 457 | FileHandler::writeFile($cache_file, $buff); |
458 | 458 | return $component_list; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Get xml_info of downloaded list |
462 | - foreach($downloaded_list as $component_name) |
|
462 | + foreach ($downloaded_list as $component_name) |
|
463 | 463 | { |
464 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
464 | + if (in_array($component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
465 | 465 | // Pass if configured |
466 | - if($component_list->{$component_name}) continue; |
|
466 | + if ($component_list->{$component_name}) continue; |
|
467 | 467 | // Insert data into the DB |
468 | 468 | $oEditorController = getAdminController('editor'); |
469 | 469 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); |
479 | - $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list))); |
|
479 | + $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); |
|
480 | 480 | FileHandler::writeFile($cache_file, $buff); |
481 | 481 | |
482 | 482 | return $component_list; |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | $editorConfig = $oModuleModel->getModulePartConfig('editor', $obj->originModuleSrl); |
499 | 499 | |
500 | 500 | $oModuleController = getController('module'); |
501 | - if(is_array($obj->moduleSrlList)) |
|
501 | + if (is_array($obj->moduleSrlList)) |
|
502 | 502 | { |
503 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
503 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
504 | 504 | { |
505 | 505 | $oModuleController->insertModulePartConfig('editor', $moduleSrl, $editorConfig); |
506 | 506 | } |
@@ -113,6 +113,11 @@ discard block |
||
113 | 113 | Context::set('drComponentList',$drComponentInfo); |
114 | 114 | } |
115 | 115 | |
116 | + /** |
|
117 | + * @param string $drComponentName |
|
118 | + * |
|
119 | + * @return string |
|
120 | + */ |
|
116 | 121 | function getDrComponentXmlInfo($drComponentName) |
117 | 122 | { |
118 | 123 | $lang_type = Context::getLangType(); |
@@ -191,6 +196,7 @@ discard block |
||
191 | 196 | * @brief Return the editor template |
192 | 197 | * You can call upload_target_srl when modifying content |
193 | 198 | * The upload_target_srl is used for a routine to check if an attachment exists |
199 | + * @param stdClass $option |
|
194 | 200 | */ |
195 | 201 | function getEditor($upload_target_srl = 0, $option = null) |
196 | 202 | { |
@@ -486,6 +492,8 @@ discard block |
||
486 | 492 | |
487 | 493 | /** |
488 | 494 | * @brief Get information which has been auto-saved |
495 | + * @param integer $upload_target_srl |
|
496 | + * @return string |
|
489 | 497 | */ |
490 | 498 | function getSavedDoc($upload_target_srl) |
491 | 499 | { |
@@ -586,6 +594,7 @@ discard block |
||
586 | 594 | |
587 | 595 | /** |
588 | 596 | * @brief Return a component list (DB Information included) |
597 | + * @return string |
|
589 | 598 | */ |
590 | 599 | function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) |
591 | 600 | { |
@@ -34,17 +34,37 @@ discard block |
||
34 | 34 | $oModuleModel = getModel('module'); |
35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
36 | 36 | |
37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
38 | - |
|
39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
37 | + if(!is_object($editor_config)) { |
|
38 | + $editor_config = new stdClass(); |
|
39 | + } |
|
40 | + |
|
41 | + if($editor_config->enable_autosave != 'N') { |
|
42 | + $editor_config->enable_autosave = 'Y'; |
|
43 | + } |
|
44 | + if(!is_array($editor_config->enable_html_grant)) { |
|
45 | + $editor_config->enable_html_grant = array(); |
|
46 | + } |
|
47 | + if(!is_array($editor_config->enable_comment_html_grant)) { |
|
48 | + $editor_config->enable_comment_html_grant = array(); |
|
49 | + } |
|
50 | + if(!is_array($editor_config->upload_file_grant)) { |
|
51 | + $editor_config->upload_file_grant = array(); |
|
52 | + } |
|
53 | + if(!is_array($editor_config->comment_upload_file_grant)) { |
|
54 | + $editor_config->comment_upload_file_grant = array(); |
|
55 | + } |
|
56 | + if(!is_array($editor_config->enable_default_component_grant)) { |
|
57 | + $editor_config->enable_default_component_grant = array(); |
|
58 | + } |
|
59 | + if(!is_array($editor_config->enable_comment_default_component_grant)) { |
|
60 | + $editor_config->enable_comment_default_component_grant = array(); |
|
61 | + } |
|
62 | + if(!is_array($editor_config->enable_component_grant)) { |
|
63 | + $editor_config->enable_component_grant = array(); |
|
64 | + } |
|
65 | + if(!is_array($editor_config->enable_comment_component_grant)) { |
|
66 | + $editor_config->enable_comment_component_grant= array(); |
|
67 | + } |
|
48 | 68 | |
49 | 69 | if(!$editor_config->editor_height) |
50 | 70 | { |
@@ -151,8 +171,11 @@ discard block |
||
151 | 171 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
152 | 172 | |
153 | 173 | // Author information |
154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
155 | - else $author_list = $xml_doc->component->author; |
|
174 | + if(!is_array($xml_doc->component->author)) { |
|
175 | + $author_list[] = $xml_doc->component->author; |
|
176 | + } else { |
|
177 | + $author_list = $xml_doc->component->author; |
|
178 | + } |
|
156 | 179 | |
157 | 180 | for($i=0; $i < count($author_list); $i++) |
158 | 181 | { |
@@ -165,7 +188,9 @@ discard block |
||
165 | 188 | $extra_vars = $xml_doc->component->extra_vars->var; |
166 | 189 | if($extra_vars) |
167 | 190 | { |
168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
191 | + if(!is_array($extra_vars)) { |
|
192 | + $extra_vars = array($extra_vars); |
|
193 | + } |
|
169 | 194 | foreach($extra_vars as $key => $val) |
170 | 195 | { |
171 | 196 | unset($obj); |
@@ -202,10 +227,15 @@ discard block |
||
202 | 227 | { |
203 | 228 | $option->editor_sequence = $upload_target_srl; |
204 | 229 | } |
205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
206 | - else $allow_fileupload = true; |
|
230 | + if(!$option->allow_fileupload) { |
|
231 | + $allow_fileupload = false; |
|
232 | + } else { |
|
233 | + $allow_fileupload = true; |
|
234 | + } |
|
207 | 235 | // content_style setting |
208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
236 | + if(!$option->content_style) { |
|
237 | + $option->content_style = 'ckeditor_light'; |
|
238 | + } |
|
209 | 239 | Context::set('content_style', $option->content_style); |
210 | 240 | Context::set('content_style_path', $this->module_path . 'styles/' . $option->content_style); |
211 | 241 | // Default font setting |
@@ -213,27 +243,47 @@ discard block |
||
213 | 243 | Context::set('content_font_size', $option->content_font_size); |
214 | 244 | |
215 | 245 | // Option setting to allow auto-save |
216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
218 | - else $enable_autosave = true; |
|
246 | + if(!$option->enable_autosave) { |
|
247 | + $enable_autosave = false; |
|
248 | + } elseif(Context::get($option->primary_key_name)) { |
|
249 | + $enable_autosave = false; |
|
250 | + } else { |
|
251 | + $enable_autosave = true; |
|
252 | + } |
|
219 | 253 | // Option setting to allow the default editor component |
220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
221 | - else $enable_default_component = true; |
|
254 | + if(!$option->enable_default_component) { |
|
255 | + $enable_default_component = false; |
|
256 | + } else { |
|
257 | + $enable_default_component = true; |
|
258 | + } |
|
222 | 259 | // Option setting to allow other extended components |
223 | - if(!$option->enable_component) $enable_component = false; |
|
224 | - else $enable_component = true; |
|
260 | + if(!$option->enable_component) { |
|
261 | + $enable_component = false; |
|
262 | + } else { |
|
263 | + $enable_component = true; |
|
264 | + } |
|
225 | 265 | // Setting for html-mode |
226 | - if($option->disable_html) $html_mode = false; |
|
227 | - else $html_mode = true; |
|
266 | + if($option->disable_html) { |
|
267 | + $html_mode = false; |
|
268 | + } else { |
|
269 | + $html_mode = true; |
|
270 | + } |
|
228 | 271 | // Set Height |
229 | - if(!$option->height) $editor_height = 300; |
|
230 | - else $editor_height = $option->height; |
|
272 | + if(!$option->height) { |
|
273 | + $editor_height = 300; |
|
274 | + } else { |
|
275 | + $editor_height = $option->height; |
|
276 | + } |
|
231 | 277 | // Skin Setting |
232 | 278 | $skin = $option->skin; |
233 | - if(!$skin) $skin = 'ckeditor'; |
|
279 | + if(!$skin) { |
|
280 | + $skin = 'ckeditor'; |
|
281 | + } |
|
234 | 282 | |
235 | 283 | $colorset = $option->colorset; |
236 | - if(!$colorset) $colorset = 'moono'; |
|
284 | + if(!$colorset) { |
|
285 | + $colorset = 'moono'; |
|
286 | + } |
|
237 | 287 | Context::set('colorset', $colorset); |
238 | 288 | Context::set('skin', $skin); |
239 | 289 | Context::set('module_type', $option->module_type); |
@@ -258,10 +308,13 @@ discard block |
||
258 | 308 | /** |
259 | 309 | * Extract editor's unique number (in order to display multiple editors on a single page) |
260 | 310 | */ |
261 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
262 | - else |
|
311 | + if($option->editor_sequence) { |
|
312 | + $editor_sequence = $option->editor_sequence; |
|
313 | + } else |
|
263 | 314 | { |
264 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
315 | + if(!$_SESSION['_editor_sequence_']) { |
|
316 | + $_SESSION['_editor_sequence_'] = 1; |
|
317 | + } |
|
265 | 318 | $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
266 | 319 | } |
267 | 320 | |
@@ -285,7 +338,9 @@ discard block |
||
285 | 338 | $oFileController = getController('file'); |
286 | 339 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
287 | 340 | // Check if the file already exists |
288 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
341 | + if($upload_target_srl) { |
|
342 | + $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
343 | + } |
|
289 | 344 | } |
290 | 345 | Context::set('files_count', (int)$files_count); |
291 | 346 | |
@@ -377,8 +432,7 @@ discard block |
||
377 | 432 | $config->enable_html_grant = $editor_config->enable_html_grant; |
378 | 433 | $config->editor_height = $editor_config->editor_height; |
379 | 434 | $config->enable_autosave = $editor_config->enable_autosave; |
380 | - } |
|
381 | - else |
|
435 | + } else |
|
382 | 436 | { |
383 | 437 | $config->editor_skin = $editor_config->comment_editor_skin; |
384 | 438 | $config->content_style = $editor_config->comment_content_style; |
@@ -397,8 +451,7 @@ discard block |
||
397 | 451 | { |
398 | 452 | $logged_info = Context::get('logged_info'); |
399 | 453 | $group_list = $logged_info->group_list; |
400 | - } |
|
401 | - else |
|
454 | + } else |
|
402 | 455 | { |
403 | 456 | $group_list = array(); |
404 | 457 | } |
@@ -412,8 +465,9 @@ discard block |
||
412 | 465 | $option->colorset = $config->sel_editor_colorset; |
413 | 466 | // Permission check for file upload |
414 | 467 | $option->allow_fileupload = false; |
415 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
416 | - elseif(count($config->upload_file_grant)) |
|
468 | + if($logged_info->is_admin=='Y') { |
|
469 | + $option->allow_fileupload = true; |
|
470 | + } elseif(count($config->upload_file_grant)) |
|
417 | 471 | { |
418 | 472 | foreach($group_list as $group_srl => $group_info) |
419 | 473 | { |
@@ -423,12 +477,14 @@ discard block |
||
423 | 477 | break; |
424 | 478 | } |
425 | 479 | } |
480 | + } else { |
|
481 | + $option->allow_fileupload = true; |
|
426 | 482 | } |
427 | - else $option->allow_fileupload = true; |
|
428 | 483 | // Permission check for using default components |
429 | 484 | $option->enable_default_component = false; |
430 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
431 | - elseif(count($config->enable_default_component_grant)) |
|
485 | + if($logged_info->is_admin=='Y') { |
|
486 | + $option->enable_default_component = true; |
|
487 | + } elseif(count($config->enable_default_component_grant)) |
|
432 | 488 | { |
433 | 489 | foreach($group_list as $group_srl => $group_info) |
434 | 490 | { |
@@ -438,12 +494,14 @@ discard block |
||
438 | 494 | break; |
439 | 495 | } |
440 | 496 | } |
497 | + } else { |
|
498 | + $option->enable_default_component = true; |
|
441 | 499 | } |
442 | - else $option->enable_default_component = true; |
|
443 | 500 | // Permisshion check for using extended components |
444 | 501 | $option->enable_component = false; |
445 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
446 | - elseif(count($config->enable_component_grant)) |
|
502 | + if($logged_info->is_admin=='Y') { |
|
503 | + $option->enable_component = true; |
|
504 | + } elseif(count($config->enable_component_grant)) |
|
447 | 505 | { |
448 | 506 | foreach($group_list as $group_srl => $group_info) |
449 | 507 | { |
@@ -453,12 +511,14 @@ discard block |
||
453 | 511 | break; |
454 | 512 | } |
455 | 513 | } |
514 | + } else { |
|
515 | + $option->enable_component = true; |
|
456 | 516 | } |
457 | - else $option->enable_component = true; |
|
458 | 517 | // HTML editing privileges |
459 | 518 | $enable_html = false; |
460 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
461 | - elseif(count($config->enable_html_grant)) |
|
519 | + if($logged_info->is_admin=='Y') { |
|
520 | + $enable_html = true; |
|
521 | + } elseif(count($config->enable_html_grant)) |
|
462 | 522 | { |
463 | 523 | foreach($group_list as $group_srl => $group_info) |
464 | 524 | { |
@@ -468,11 +528,15 @@ discard block |
||
468 | 528 | break; |
469 | 529 | } |
470 | 530 | } |
531 | + } else { |
|
532 | + $enable_html = true; |
|
471 | 533 | } |
472 | - else $enable_html = true; |
|
473 | 534 | |
474 | - if($enable_html) $option->disable_html = false; |
|
475 | - else $option->disable_html = true; |
|
535 | + if($enable_html) { |
|
536 | + $option->disable_html = false; |
|
537 | + } else { |
|
538 | + $option->disable_html = true; |
|
539 | + } |
|
476 | 540 | // Set Height |
477 | 541 | $option->height = $config->editor_height; |
478 | 542 | // Set an option for Auto-save |
@@ -495,8 +559,7 @@ discard block |
||
495 | 559 | { |
496 | 560 | $logged_info = Context::get('logged_info'); |
497 | 561 | $auto_save_args->member_srl = $logged_info->member_srl; |
498 | - } |
|
499 | - else |
|
562 | + } else |
|
500 | 563 | { |
501 | 564 | $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
502 | 565 | } |
@@ -511,11 +574,15 @@ discard block |
||
511 | 574 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
512 | 575 | $saved_doc = $output->data; |
513 | 576 | // Return null if no result is auto-saved |
514 | - if(!$saved_doc) return; |
|
577 | + if(!$saved_doc) { |
|
578 | + return; |
|
579 | + } |
|
515 | 580 | // Check if the auto-saved document already exists |
516 | 581 | $oDocumentModel = getModel('document'); |
517 | 582 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
518 | - if($oSaved->isExists()) return; |
|
583 | + if($oSaved->isExists()) { |
|
584 | + return; |
|
585 | + } |
|
519 | 586 | // Move all the files if the auto-saved data contains document_srl and file |
520 | 587 | // Then set document_srl to editor_sequence |
521 | 588 | if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
@@ -523,8 +590,9 @@ discard block |
||
523 | 590 | $saved_doc->module_srl = $auto_save_args->module_srl; |
524 | 591 | $oFileController = getController('file'); |
525 | 592 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
593 | + } else if($upload_target_srl) { |
|
594 | + $saved_doc->document_srl = $upload_target_srl; |
|
526 | 595 | } |
527 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
528 | 596 | // Change auto-saved data |
529 | 597 | $oEditorController = getController('editor'); |
530 | 598 | $oEditorController->deleteSavedDoc(false); |
@@ -540,18 +608,24 @@ discard block |
||
540 | 608 | */ |
541 | 609 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
542 | 610 | { |
543 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
611 | + if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) { |
|
612 | + return; |
|
613 | + } |
|
544 | 614 | |
545 | 615 | if(!$this->loaded_component_list[$component][$editor_sequence]) |
546 | 616 | { |
547 | 617 | // Create an object of the component and execute |
548 | 618 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
549 | 619 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
550 | - if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
620 | + if(!file_exists($class_file)) { |
|
621 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
622 | + } |
|
551 | 623 | // Create an object after loading the class file |
552 | 624 | require_once($class_file); |
553 | 625 | $oComponent = new $component($editor_sequence, $class_path); |
554 | - if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
626 | + if(!$oComponent) { |
|
627 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
628 | + } |
|
555 | 629 | // Add configuration information |
556 | 630 | $component_info = $this->getComponent($component, $site_srl); |
557 | 631 | $oComponent->setInfo($component_info); |
@@ -578,8 +652,12 @@ discard block |
||
578 | 652 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
579 | 653 | FileHandler::makeDir($cache_path); |
580 | 654 | $cache_file = $cache_path.'component_list.' . $lang .'.'; |
581 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
582 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
655 | + if($filter_enabled) { |
|
656 | + $cache_file .= 'filter.'; |
|
657 | + } |
|
658 | + if($site_srl) { |
|
659 | + $cache_file .= $site_srl.'.'; |
|
660 | + } |
|
583 | 661 | $cache_file .= 'php'; |
584 | 662 | return $cache_file; |
585 | 663 | } |
@@ -596,14 +674,15 @@ discard block |
||
596 | 674 | $oEditorController->makeCache(false, $site_srl); |
597 | 675 | } |
598 | 676 | |
599 | - if(!file_exists($cache_file)) return; |
|
677 | + if(!file_exists($cache_file)) { |
|
678 | + return; |
|
679 | + } |
|
600 | 680 | include($cache_file); |
601 | 681 | $logged_info = Context::get('logged_info'); |
602 | 682 | if($logged_info && is_array($logged_info->group_list)) |
603 | 683 | { |
604 | 684 | $group_list = array_keys($logged_info->group_list); |
605 | - } |
|
606 | - else |
|
685 | + } else |
|
607 | 686 | { |
608 | 687 | $group_list = array(); |
609 | 688 | } |
@@ -612,39 +691,50 @@ discard block |
||
612 | 691 | { |
613 | 692 | foreach($component_list as $key => $val) |
614 | 693 | { |
615 | - if(!trim($key)) continue; |
|
694 | + if(!trim($key)) { |
|
695 | + continue; |
|
696 | + } |
|
616 | 697 | if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
617 | 698 | { |
618 | 699 | FileHandler::removeFile($cache_file); |
619 | 700 | return $this->getComponentList($filter_enabled, $site_srl); |
620 | 701 | } |
621 | - if(!$filter_enabled) continue; |
|
702 | + if(!$filter_enabled) { |
|
703 | + continue; |
|
704 | + } |
|
622 | 705 | if($val->enabled == "N") |
623 | 706 | { |
624 | 707 | unset($component_list->{$key}); |
625 | 708 | continue; |
626 | 709 | } |
627 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
710 | + if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") { |
|
711 | + continue; |
|
712 | + } |
|
628 | 713 | if($val->target_group) |
629 | 714 | { |
630 | 715 | if(!$logged_info) |
631 | 716 | { |
632 | 717 | $val->enabled = "N"; |
633 | - } |
|
634 | - else |
|
718 | + } else |
|
635 | 719 | { |
636 | 720 | $is_granted = false; |
637 | 721 | foreach($group_list as $group_srl) |
638 | 722 | { |
639 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
723 | + if(in_array($group_srl, $val->target_group)) { |
|
724 | + $is_granted = true; |
|
725 | + } |
|
726 | + } |
|
727 | + if(!$is_granted) { |
|
728 | + $val->enabled = "N"; |
|
640 | 729 | } |
641 | - if(!$is_granted) $val->enabled = "N"; |
|
642 | 730 | } |
643 | 731 | } |
644 | 732 | if($val->enabled != "N" && $val->mid_list) |
645 | 733 | { |
646 | 734 | $mid = Context::get('mid'); |
647 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
735 | + if(!in_array($mid, $val->mid_list)) { |
|
736 | + $val->enabled = "N"; |
|
737 | + } |
|
648 | 738 | } |
649 | 739 | if($val->enabled == "N") |
650 | 740 | { |
@@ -668,8 +758,7 @@ discard block |
||
668 | 758 | { |
669 | 759 | $args->site_srl = $site_srl; |
670 | 760 | $output = executeQuery('editor.getSiteComponent', $args); |
671 | - } |
|
672 | - else |
|
761 | + } else |
|
673 | 762 | { |
674 | 763 | $output = executeQuery('editor.getComponent', $args); |
675 | 764 | } |
@@ -752,8 +841,7 @@ discard block |
||
752 | 841 | $component_info->homepage = $xml_doc->component->link->body; |
753 | 842 | $component_info->license = $xml_doc->component->license->body; |
754 | 843 | $component_info->license_link = $xml_doc->component->license->attrs->link; |
755 | - } |
|
756 | - else |
|
844 | + } else |
|
757 | 845 | { |
758 | 846 | sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); |
759 | 847 | $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
@@ -770,8 +858,11 @@ discard block |
||
770 | 858 | |
771 | 859 | // Author information |
772 | 860 | $author_list = array(); |
773 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
774 | - else $author_list = $xml_doc->component->author; |
|
861 | + if(!is_array($xml_doc->component->author)) { |
|
862 | + $author_list[] = $xml_doc->component->author; |
|
863 | + } else { |
|
864 | + $author_list = $xml_doc->component->author; |
|
865 | + } |
|
775 | 866 | |
776 | 867 | for($i = 0; $i < count($author_list); $i++) |
777 | 868 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function getEditorConfig($module_srl = null) |
25 | 25 | { |
26 | - if(!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
26 | + if (!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
27 | 27 | { |
28 | 28 | // Get trackback settings of the selected module |
29 | 29 | $oModuleModel = getModel('module'); |
@@ -34,55 +34,55 @@ discard block |
||
34 | 34 | $oModuleModel = getModel('module'); |
35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
36 | 36 | |
37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
37 | + if (!is_object($editor_config)) $editor_config = new stdClass(); |
|
38 | 38 | |
39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
39 | + if ($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | + if (!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | + if (!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | + if (!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | + if (!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | + if (!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | + if (!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | + if (!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | + if (!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant = array(); |
|
48 | 48 | |
49 | - if(!$editor_config->editor_height) |
|
49 | + if (!$editor_config->editor_height) |
|
50 | 50 | { |
51 | 51 | $editor_config->editor_height = ($editor_default_config->editor_height) ? $editor_default_config->editor_height : 500; |
52 | 52 | } |
53 | - if(!$editor_config->comment_editor_height) |
|
53 | + if (!$editor_config->comment_editor_height) |
|
54 | 54 | { |
55 | 55 | $editor_config->comment_editor_height = ($editor_default_config->comment_editor_height) ? $editor_default_config->comment_editor_height : 120; |
56 | 56 | } |
57 | - if(!$editor_config->editor_skin) |
|
57 | + if (!$editor_config->editor_skin) |
|
58 | 58 | { |
59 | 59 | $editor_config->editor_skin = ($editor_default_config->editor_skin) ? $editor_default_config->editor_skin : 'ckeditor'; |
60 | 60 | } |
61 | - if(!$editor_config->comment_editor_skin) |
|
61 | + if (!$editor_config->comment_editor_skin) |
|
62 | 62 | { |
63 | 63 | $editor_config->comment_editor_skin = ($editor_default_config->comment_editor_skin) ? $editor_default_config->comment_editor_skin : 'ckeditor'; |
64 | 64 | } |
65 | - if(!$editor_config->content_style) |
|
65 | + if (!$editor_config->content_style) |
|
66 | 66 | { |
67 | 67 | $editor_config->content_style = ($editor_default_config->content_style) ? $editor_default_config->content_style : 'ckeditor_light'; |
68 | 68 | } |
69 | - if(!$editor_config->content_font && $editor_default_config->content_font) |
|
69 | + if (!$editor_config->content_font && $editor_default_config->content_font) |
|
70 | 70 | { |
71 | 71 | $editor_config->content_font = $editor_default_config->content_font; |
72 | 72 | } |
73 | - if(!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
73 | + if (!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
74 | 74 | { |
75 | 75 | $editor_config->content_font_size = $editor_default_config->content_font_size; |
76 | 76 | } |
77 | - if(!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
77 | + if (!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
78 | 78 | { |
79 | 79 | $editor_config->sel_editor_colorset = $editor_default_config->sel_editor_colorset; |
80 | 80 | } |
81 | - if(!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
81 | + if (!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
82 | 82 | { |
83 | 83 | $editor_config->sel_comment_editor_colorset = $editor_default_config->sel_comment_editor_colorset; |
84 | 84 | } |
85 | - if(!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
85 | + if (!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
86 | 86 | { |
87 | 87 | $editor_config->comment_content_style = $editor_default_config->comment_content_style; |
88 | 88 | } |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | |
93 | 93 | function loadDrComponents() |
94 | 94 | { |
95 | - $drComponentPath = _XE_PATH_ . 'modules/editor/skins/dreditor/drcomponents/'; |
|
95 | + $drComponentPath = _XE_PATH_.'modules/editor/skins/dreditor/drcomponents/'; |
|
96 | 96 | $drComponentList = FileHandler::readDir($drComponentPath); |
97 | 97 | |
98 | 98 | $oTemplate = &TemplateHandler::getInstance(); |
99 | 99 | |
100 | 100 | $drComponentInfo = array(); |
101 | - if($drComponentList) |
|
101 | + if ($drComponentList) |
|
102 | 102 | { |
103 | - foreach($drComponentList as $i => $drComponent) |
|
103 | + foreach ($drComponentList as $i => $drComponent) |
|
104 | 104 | { |
105 | 105 | unset($obj); |
106 | 106 | $obj = $this->getDrComponentXmlInfo($drComponent); |
107 | - Context::loadLang(sprintf('%s%s/lang/',$drComponentPath,$drComponent)); |
|
108 | - $path = sprintf('%s%s/tpl/',$drComponentPath,$drComponent); |
|
109 | - $obj->html = $oTemplate->compile($path,$drComponent); |
|
107 | + Context::loadLang(sprintf('%s%s/lang/', $drComponentPath, $drComponent)); |
|
108 | + $path = sprintf('%s%s/tpl/', $drComponentPath, $drComponent); |
|
109 | + $obj->html = $oTemplate->compile($path, $drComponent); |
|
110 | 110 | $drComponentInfo[$drComponent] = $obj; |
111 | 111 | } |
112 | 112 | } |
113 | - Context::set('drComponentList',$drComponentInfo); |
|
113 | + Context::set('drComponentList', $drComponentInfo); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | function getDrComponentXmlInfo($drComponentName) |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $xml_file = sprintf('%sinfo.xml', $component_path); |
123 | 123 | $cache_file = sprintf('./files/cache/editor/dr_%s.%s.php', $drComponentName, $lang_type); |
124 | 124 | // Return information after including it after cached xml file exists |
125 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
125 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
126 | 126 | { |
127 | 127 | include($cache_file); |
128 | 128 | return $xml_info; |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
152 | 152 | |
153 | 153 | // Author information |
154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
154 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
155 | 155 | else $author_list = $xml_doc->component->author; |
156 | 156 | |
157 | - for($i=0; $i < count($author_list); $i++) |
|
157 | + for ($i = 0; $i < count($author_list); $i++) |
|
158 | 158 | { |
159 | 159 | $buff .= sprintf('$xml_info->author['.$i.']->name = "%s";', $author_list[$i]->name->body); |
160 | 160 | $buff .= sprintf('$xml_info->author['.$i.']->email_address = "%s";', $author_list[$i]->attrs->email_address); |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | |
164 | 164 | // List extra variables (text type only in the editor component) |
165 | 165 | $extra_vars = $xml_doc->component->extra_vars->var; |
166 | - if($extra_vars) |
|
166 | + if ($extra_vars) |
|
167 | 167 | { |
168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
169 | - foreach($extra_vars as $key => $val) |
|
168 | + if (!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
169 | + foreach ($extra_vars as $key => $val) |
|
170 | 170 | { |
171 | 171 | unset($obj); |
172 | 172 | $key = $val->attrs->name; |
@@ -198,47 +198,47 @@ discard block |
||
198 | 198 | * Editor's default options |
199 | 199 | */ |
200 | 200 | // Option setting to allow file upload |
201 | - if($upload_target_srl) |
|
201 | + if ($upload_target_srl) |
|
202 | 202 | { |
203 | 203 | $option->editor_sequence = $upload_target_srl; |
204 | 204 | } |
205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
205 | + if (!$option->allow_fileupload) $allow_fileupload = false; |
|
206 | 206 | else $allow_fileupload = true; |
207 | 207 | // content_style setting |
208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
208 | + if (!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
209 | 209 | Context::set('content_style', $option->content_style); |
210 | - Context::set('content_style_path', $this->module_path . 'styles/' . $option->content_style); |
|
210 | + Context::set('content_style_path', $this->module_path.'styles/'.$option->content_style); |
|
211 | 211 | // Default font setting |
212 | 212 | Context::set('content_font', addslashes($option->content_font)); |
213 | 213 | Context::set('content_font_size', $option->content_font_size); |
214 | 214 | |
215 | 215 | // Option setting to allow auto-save |
216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
216 | + if (!$option->enable_autosave) $enable_autosave = false; |
|
217 | + elseif (Context::get($option->primary_key_name)) $enable_autosave = false; |
|
218 | 218 | else $enable_autosave = true; |
219 | 219 | // Option setting to allow the default editor component |
220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
220 | + if (!$option->enable_default_component) $enable_default_component = false; |
|
221 | 221 | else $enable_default_component = true; |
222 | 222 | // Option setting to allow other extended components |
223 | - if(!$option->enable_component) $enable_component = false; |
|
223 | + if (!$option->enable_component) $enable_component = false; |
|
224 | 224 | else $enable_component = true; |
225 | 225 | // Setting for html-mode |
226 | - if($option->disable_html) $html_mode = false; |
|
226 | + if ($option->disable_html) $html_mode = false; |
|
227 | 227 | else $html_mode = true; |
228 | 228 | // Set Height |
229 | - if(!$option->height) $editor_height = 300; |
|
229 | + if (!$option->height) $editor_height = 300; |
|
230 | 230 | else $editor_height = $option->height; |
231 | 231 | // Skin Setting |
232 | 232 | $skin = $option->skin; |
233 | - if(!$skin) $skin = 'ckeditor'; |
|
233 | + if (!$skin) $skin = 'ckeditor'; |
|
234 | 234 | |
235 | 235 | $colorset = $option->colorset; |
236 | - if(!$colorset) $colorset = 'moono'; |
|
236 | + if (!$colorset) $colorset = 'moono'; |
|
237 | 237 | Context::set('colorset', $colorset); |
238 | 238 | Context::set('skin', $skin); |
239 | 239 | Context::set('module_type', $option->module_type); |
240 | 240 | |
241 | - if($skin=='dreditor') |
|
241 | + if ($skin == 'dreditor') |
|
242 | 242 | { |
243 | 243 | $this->loadDrComponents(); |
244 | 244 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * Check the automatic backup feature (do not use if the post is edited) |
248 | 248 | */ |
249 | - if($enable_autosave) |
|
249 | + if ($enable_autosave) |
|
250 | 250 | { |
251 | 251 | // Extract auto-saved data |
252 | 252 | $saved_doc = $this->getSavedDoc($upload_target_srl); |
@@ -258,26 +258,26 @@ discard block |
||
258 | 258 | /** |
259 | 259 | * Extract editor's unique number (in order to display multiple editors on a single page) |
260 | 260 | */ |
261 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
261 | + if ($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
262 | 262 | else |
263 | 263 | { |
264 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
265 | - $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
|
264 | + if (!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
265 | + $editor_sequence = $_SESSION['_editor_sequence_']++; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Upload setting by using configuration of the file module internally |
270 | 270 | */ |
271 | 271 | $files_count = 0; |
272 | - if($allow_fileupload) |
|
272 | + if ($allow_fileupload) |
|
273 | 273 | { |
274 | 274 | $oFileModel = getModel('file'); |
275 | 275 | // Get upload configuration to set on SWFUploader |
276 | 276 | $file_config = $oFileModel->getUploadConfig(); |
277 | - $file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024; |
|
278 | - $file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024; |
|
277 | + $file_config->allowed_attach_size = $file_config->allowed_attach_size * 1024 * 1024; |
|
278 | + $file_config->allowed_filesize = $file_config->allowed_filesize * 1024 * 1024; |
|
279 | 279 | |
280 | - Context::set('file_config',$file_config); |
|
280 | + Context::set('file_config', $file_config); |
|
281 | 281 | // Configure upload status such as file size |
282 | 282 | $upload_status = $oFileModel->getUploadStatus(); |
283 | 283 | Context::set('upload_status', $upload_status); |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | $oFileController = getController('file'); |
286 | 286 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
287 | 287 | // Check if the file already exists |
288 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
288 | + if ($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
289 | 289 | } |
290 | - Context::set('files_count', (int)$files_count); |
|
290 | + Context::set('files_count', (int) $files_count); |
|
291 | 291 | |
292 | 292 | Context::set('allow_fileupload', $allow_fileupload); |
293 | 293 | // Set editor_sequence value |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | * Check editor component |
305 | 305 | */ |
306 | 306 | $site_module_info = Context::get('site_module_info'); |
307 | - $site_srl = (int)$site_module_info->site_srl; |
|
308 | - if($enable_component) |
|
307 | + $site_srl = (int) $site_module_info->site_srl; |
|
308 | + if ($enable_component) |
|
309 | 309 | { |
310 | - if(!Context::get('component_list')) |
|
310 | + if (!Context::get('component_list')) |
|
311 | 311 | { |
312 | 312 | $component_list = $this->getComponentList(true, $site_srl); |
313 | 313 | Context::set('component_list', $component_list); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
335 | 335 | $tpl_file = 'editor.html'; |
336 | 336 | |
337 | - if(!file_exists($tpl_path.$tpl_file)) |
|
337 | + if (!file_exists($tpl_path.$tpl_file)) |
|
338 | 338 | { |
339 | 339 | $skin = 'ckeditor'; |
340 | 340 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $config->module_type = $type; |
365 | 365 | |
366 | 366 | // Configurations listed according to a type |
367 | - if($type == 'document') |
|
367 | + if ($type == 'document') |
|
368 | 368 | { |
369 | 369 | $config->editor_skin = $editor_config->editor_skin; |
370 | 370 | $config->content_style = $editor_config->content_style; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $config->enable_autosave = 'N'; |
394 | 394 | } |
395 | 395 | // Check a group_list of the currently logged-in user for permission check |
396 | - if(Context::get('is_logged')) |
|
396 | + if (Context::get('is_logged')) |
|
397 | 397 | { |
398 | 398 | $logged_info = Context::get('logged_info'); |
399 | 399 | $group_list = $logged_info->group_list; |
@@ -412,12 +412,12 @@ discard block |
||
412 | 412 | $option->colorset = $config->sel_editor_colorset; |
413 | 413 | // Permission check for file upload |
414 | 414 | $option->allow_fileupload = false; |
415 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
416 | - elseif(count($config->upload_file_grant)) |
|
415 | + if ($logged_info->is_admin == 'Y') $option->allow_fileupload = true; |
|
416 | + elseif (count($config->upload_file_grant)) |
|
417 | 417 | { |
418 | - foreach($group_list as $group_srl => $group_info) |
|
418 | + foreach ($group_list as $group_srl => $group_info) |
|
419 | 419 | { |
420 | - if(in_array($group_srl, $config->upload_file_grant)) |
|
420 | + if (in_array($group_srl, $config->upload_file_grant)) |
|
421 | 421 | { |
422 | 422 | $option->allow_fileupload = true; |
423 | 423 | break; |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | else $option->allow_fileupload = true; |
428 | 428 | // Permission check for using default components |
429 | 429 | $option->enable_default_component = false; |
430 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
431 | - elseif(count($config->enable_default_component_grant)) |
|
430 | + if ($logged_info->is_admin == 'Y') $option->enable_default_component = true; |
|
431 | + elseif (count($config->enable_default_component_grant)) |
|
432 | 432 | { |
433 | - foreach($group_list as $group_srl => $group_info) |
|
433 | + foreach ($group_list as $group_srl => $group_info) |
|
434 | 434 | { |
435 | - if(in_array($group_srl, $config->enable_default_component_grant)) |
|
435 | + if (in_array($group_srl, $config->enable_default_component_grant)) |
|
436 | 436 | { |
437 | 437 | $option->enable_default_component = true; |
438 | 438 | break; |
@@ -442,12 +442,12 @@ discard block |
||
442 | 442 | else $option->enable_default_component = true; |
443 | 443 | // Permisshion check for using extended components |
444 | 444 | $option->enable_component = false; |
445 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
446 | - elseif(count($config->enable_component_grant)) |
|
445 | + if ($logged_info->is_admin == 'Y') $option->enable_component = true; |
|
446 | + elseif (count($config->enable_component_grant)) |
|
447 | 447 | { |
448 | - foreach($group_list as $group_srl => $group_info) |
|
448 | + foreach ($group_list as $group_srl => $group_info) |
|
449 | 449 | { |
450 | - if(in_array($group_srl, $config->enable_component_grant)) |
|
450 | + if (in_array($group_srl, $config->enable_component_grant)) |
|
451 | 451 | { |
452 | 452 | $option->enable_component = true; |
453 | 453 | break; |
@@ -457,12 +457,12 @@ discard block |
||
457 | 457 | else $option->enable_component = true; |
458 | 458 | // HTML editing privileges |
459 | 459 | $enable_html = false; |
460 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
461 | - elseif(count($config->enable_html_grant)) |
|
460 | + if ($logged_info->is_admin == 'Y') $enable_html = true; |
|
461 | + elseif (count($config->enable_html_grant)) |
|
462 | 462 | { |
463 | - foreach($group_list as $group_srl => $group_info) |
|
463 | + foreach ($group_list as $group_srl => $group_info) |
|
464 | 464 | { |
465 | - if(in_array($group_srl, $config->enable_html_grant)) |
|
465 | + if (in_array($group_srl, $config->enable_html_grant)) |
|
466 | 466 | { |
467 | 467 | $enable_html = true; |
468 | 468 | break; |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | } |
472 | 472 | else $enable_html = true; |
473 | 473 | |
474 | - if($enable_html) $option->disable_html = false; |
|
474 | + if ($enable_html) $option->disable_html = false; |
|
475 | 475 | else $option->disable_html = true; |
476 | 476 | // Set Height |
477 | 477 | $option->height = $config->editor_height; |
478 | 478 | // Set an option for Auto-save |
479 | - $option->enable_autosave = $config->enable_autosave=='Y'?true:false; |
|
479 | + $option->enable_autosave = $config->enable_autosave == 'Y' ? true : false; |
|
480 | 480 | // Other settings |
481 | 481 | $option->primary_key_name = $primary_key_name; |
482 | 482 | $option->content_key_name = $content_key_name; |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | { |
492 | 492 | $auto_save_args = new stdClass(); |
493 | 493 | // Find a document by using member_srl for logged-in user and ipaddress for non-logged user |
494 | - if(Context::get('is_logged')) |
|
494 | + if (Context::get('is_logged')) |
|
495 | 495 | { |
496 | 496 | $logged_info = Context::get('logged_info'); |
497 | 497 | $auto_save_args->member_srl = $logged_info->member_srl; |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | } |
503 | 503 | $auto_save_args->module_srl = Context::get('module_srl'); |
504 | 504 | // Get the current module if module_srl doesn't exist |
505 | - if(!$auto_save_args->module_srl) |
|
505 | + if (!$auto_save_args->module_srl) |
|
506 | 506 | { |
507 | 507 | $current_module_info = Context::get('current_module_info'); |
508 | 508 | $auto_save_args->module_srl = $current_module_info->module_srl; |
@@ -511,20 +511,20 @@ discard block |
||
511 | 511 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
512 | 512 | $saved_doc = $output->data; |
513 | 513 | // Return null if no result is auto-saved |
514 | - if(!$saved_doc) return; |
|
514 | + if (!$saved_doc) return; |
|
515 | 515 | // Check if the auto-saved document already exists |
516 | 516 | $oDocumentModel = getModel('document'); |
517 | 517 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
518 | - if($oSaved->isExists()) return; |
|
518 | + if ($oSaved->isExists()) return; |
|
519 | 519 | // Move all the files if the auto-saved data contains document_srl and file |
520 | 520 | // Then set document_srl to editor_sequence |
521 | - if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
521 | + if ($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
522 | 522 | { |
523 | 523 | $saved_doc->module_srl = $auto_save_args->module_srl; |
524 | 524 | $oFileController = getController('file'); |
525 | 525 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
526 | 526 | } |
527 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
527 | + else if ($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
528 | 528 | // Change auto-saved data |
529 | 529 | $oEditorController = getController('editor'); |
530 | 530 | $oEditorController->deleteSavedDoc(false); |
@@ -540,18 +540,18 @@ discard block |
||
540 | 540 | */ |
541 | 541 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
542 | 542 | { |
543 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
543 | + if (!preg_match('/^[a-zA-Z0-9_-]+$/', $component) || !preg_match('/^[0-9]+$/', $editor_sequence.$site_srl)) return; |
|
544 | 544 | |
545 | - if(!$this->loaded_component_list[$component][$editor_sequence]) |
|
545 | + if (!$this->loaded_component_list[$component][$editor_sequence]) |
|
546 | 546 | { |
547 | 547 | // Create an object of the component and execute |
548 | 548 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
549 | 549 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
550 | - if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
550 | + if (!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
551 | 551 | // Create an object after loading the class file |
552 | 552 | require_once($class_file); |
553 | 553 | $oComponent = new $component($editor_sequence, $class_path); |
554 | - if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
554 | + if (!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
555 | 555 | // Add configuration information |
556 | 556 | $component_info = $this->getComponent($component, $site_srl); |
557 | 557 | $oComponent->setInfo($component_info); |
@@ -572,14 +572,14 @@ discard block |
||
572 | 572 | /** |
573 | 573 | * @brief Return the cache file name of editor component list |
574 | 574 | */ |
575 | - function getCacheFile($filter_enabled= true, $site_srl = 0) |
|
575 | + function getCacheFile($filter_enabled = true, $site_srl = 0) |
|
576 | 576 | { |
577 | 577 | $lang = Context::getLangType(); |
578 | 578 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
579 | 579 | FileHandler::makeDir($cache_path); |
580 | - $cache_file = $cache_path.'component_list.' . $lang .'.'; |
|
581 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
582 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
580 | + $cache_file = $cache_path.'component_list.'.$lang.'.'; |
|
581 | + if ($filter_enabled) $cache_file .= 'filter.'; |
|
582 | + if ($site_srl) $cache_file .= $site_srl.'.'; |
|
583 | 583 | $cache_file .= 'php'; |
584 | 584 | return $cache_file; |
585 | 585 | } |
@@ -587,19 +587,19 @@ discard block |
||
587 | 587 | /** |
588 | 588 | * @brief Return a component list (DB Information included) |
589 | 589 | */ |
590 | - function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) |
|
590 | + function getComponentList($filter_enabled = true, $site_srl = 0, $from_db = false) |
|
591 | 591 | { |
592 | 592 | $cache_file = $this->getCacheFile(false, $site_srl); |
593 | - if($from_db || !file_exists($cache_file)) |
|
593 | + if ($from_db || !file_exists($cache_file)) |
|
594 | 594 | { |
595 | 595 | $oEditorController = getController('editor'); |
596 | 596 | $oEditorController->makeCache(false, $site_srl); |
597 | 597 | } |
598 | 598 | |
599 | - if(!file_exists($cache_file)) return; |
|
599 | + if (!file_exists($cache_file)) return; |
|
600 | 600 | include($cache_file); |
601 | 601 | $logged_info = Context::get('logged_info'); |
602 | - if($logged_info && is_array($logged_info->group_list)) |
|
602 | + if ($logged_info && is_array($logged_info->group_list)) |
|
603 | 603 | { |
604 | 604 | $group_list = array_keys($logged_info->group_list); |
605 | 605 | } |
@@ -608,45 +608,45 @@ discard block |
||
608 | 608 | $group_list = array(); |
609 | 609 | } |
610 | 610 | |
611 | - if(count($component_list)) |
|
611 | + if (count($component_list)) |
|
612 | 612 | { |
613 | - foreach($component_list as $key => $val) |
|
613 | + foreach ($component_list as $key => $val) |
|
614 | 614 | { |
615 | - if(!trim($key)) continue; |
|
616 | - if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
615 | + if (!trim($key)) continue; |
|
616 | + if (!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
617 | 617 | { |
618 | 618 | FileHandler::removeFile($cache_file); |
619 | 619 | return $this->getComponentList($filter_enabled, $site_srl); |
620 | 620 | } |
621 | - if(!$filter_enabled) continue; |
|
622 | - if($val->enabled == "N") |
|
621 | + if (!$filter_enabled) continue; |
|
622 | + if ($val->enabled == "N") |
|
623 | 623 | { |
624 | 624 | unset($component_list->{$key}); |
625 | 625 | continue; |
626 | 626 | } |
627 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
628 | - if($val->target_group) |
|
627 | + if ($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
628 | + if ($val->target_group) |
|
629 | 629 | { |
630 | - if(!$logged_info) |
|
630 | + if (!$logged_info) |
|
631 | 631 | { |
632 | 632 | $val->enabled = "N"; |
633 | 633 | } |
634 | 634 | else |
635 | 635 | { |
636 | 636 | $is_granted = false; |
637 | - foreach($group_list as $group_srl) |
|
637 | + foreach ($group_list as $group_srl) |
|
638 | 638 | { |
639 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
639 | + if (in_array($group_srl, $val->target_group)) $is_granted = true; |
|
640 | 640 | } |
641 | - if(!$is_granted) $val->enabled = "N"; |
|
641 | + if (!$is_granted) $val->enabled = "N"; |
|
642 | 642 | } |
643 | 643 | } |
644 | - if($val->enabled != "N" && $val->mid_list) |
|
644 | + if ($val->enabled != "N" && $val->mid_list) |
|
645 | 645 | { |
646 | 646 | $mid = Context::get('mid'); |
647 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
647 | + if (!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
648 | 648 | } |
649 | - if($val->enabled == "N") |
|
649 | + if ($val->enabled == "N") |
|
650 | 650 | { |
651 | 651 | unset($component_list->{$key}); |
652 | 652 | continue; |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | $args = new stdClass(); |
665 | 665 | $args->component_name = $component_name; |
666 | 666 | |
667 | - if($site_srl) |
|
667 | + if ($site_srl) |
|
668 | 668 | { |
669 | 669 | $args->site_srl = $site_srl; |
670 | 670 | $output = executeQuery('editor.getSiteComponent', $args); |
@@ -685,25 +685,25 @@ discard block |
||
685 | 685 | |
686 | 686 | $xml_info->mid_list = array(); |
687 | 687 | |
688 | - if($component->extra_vars) |
|
688 | + if ($component->extra_vars) |
|
689 | 689 | { |
690 | 690 | $extra_vars = unserialize($component->extra_vars); |
691 | 691 | |
692 | - if($extra_vars->target_group) |
|
692 | + if ($extra_vars->target_group) |
|
693 | 693 | { |
694 | 694 | $xml_info->target_group = $extra_vars->target_group; |
695 | 695 | unset($extra_vars->target_group); |
696 | 696 | } |
697 | 697 | |
698 | - if($extra_vars->mid_list) |
|
698 | + if ($extra_vars->mid_list) |
|
699 | 699 | { |
700 | 700 | $xml_info->mid_list = $extra_vars->mid_list; |
701 | 701 | unset($extra_vars->mid_list); |
702 | 702 | } |
703 | 703 | |
704 | - if($xml_info->extra_vars) |
|
704 | + if ($xml_info->extra_vars) |
|
705 | 705 | { |
706 | - foreach($xml_info->extra_vars as $key => $val) |
|
706 | + foreach ($xml_info->extra_vars as $key => $val) |
|
707 | 707 | { |
708 | 708 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
709 | 709 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | $cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); |
728 | 728 | |
729 | 729 | // Include and return xml file information if cached file exists |
730 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
730 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
731 | 731 | { |
732 | 732 | include($cache_file); |
733 | 733 | |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $component_info->component_name = $component; |
745 | 745 | $component_info->title = $xml_doc->component->title->body; |
746 | 746 | |
747 | - if($xml_doc->component->version) |
|
747 | + if ($xml_doc->component->version) |
|
748 | 748 | { |
749 | 749 | $component_info->description = str_replace('\n', "\n", $xml_doc->component->description->body); |
750 | 750 | $component_info->version = $xml_doc->component->version->body; |
@@ -770,10 +770,10 @@ discard block |
||
770 | 770 | |
771 | 771 | // Author information |
772 | 772 | $author_list = array(); |
773 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
773 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
774 | 774 | else $author_list = $xml_doc->component->author; |
775 | 775 | |
776 | - for($i = 0; $i < count($author_list); $i++) |
|
776 | + for ($i = 0; $i < count($author_list); $i++) |
|
777 | 777 | { |
778 | 778 | $author = new stdClass; |
779 | 779 | $author->name = $author_list[$i]->name->body; |
@@ -784,39 +784,39 @@ discard block |
||
784 | 784 | |
785 | 785 | // List extra variables (text type only for editor component) |
786 | 786 | $extra_vars = $xml_doc->component->extra_vars; |
787 | - if($extra_vars) |
|
787 | + if ($extra_vars) |
|
788 | 788 | { |
789 | 789 | $extra_var_groups = $extra_vars->group; |
790 | - if(!$extra_var_groups) |
|
790 | + if (!$extra_var_groups) |
|
791 | 791 | { |
792 | 792 | $extra_var_groups = $extra_vars; |
793 | 793 | } |
794 | - if(!is_array($extra_var_groups)) |
|
794 | + if (!is_array($extra_var_groups)) |
|
795 | 795 | { |
796 | 796 | $extra_var_groups = array($extra_var_groups); |
797 | 797 | } |
798 | 798 | |
799 | - foreach($extra_var_groups as $group) |
|
799 | + foreach ($extra_var_groups as $group) |
|
800 | 800 | { |
801 | 801 | $extra_vars = $group->var; |
802 | - if(!is_array($group->var)) |
|
802 | + if (!is_array($group->var)) |
|
803 | 803 | { |
804 | 804 | $extra_vars = array($group->var); |
805 | 805 | } |
806 | 806 | |
807 | - foreach($extra_vars as $key => $val) |
|
807 | + foreach ($extra_vars as $key => $val) |
|
808 | 808 | { |
809 | - if(!$val) |
|
809 | + if (!$val) |
|
810 | 810 | { |
811 | 811 | continue; |
812 | 812 | } |
813 | 813 | |
814 | 814 | $obj = new stdClass(); |
815 | - if(!$val->attrs) |
|
815 | + if (!$val->attrs) |
|
816 | 816 | { |
817 | 817 | $val->attrs = new stdClass(); |
818 | 818 | } |
819 | - if(!$val->attrs->type) |
|
819 | + if (!$val->attrs->type) |
|
820 | 820 | { |
821 | 821 | $val->attrs->type = 'text'; |
822 | 822 | } |
@@ -826,26 +826,26 @@ discard block |
||
826 | 826 | $obj->title = $val->title->body; |
827 | 827 | $obj->type = $val->attrs->type; |
828 | 828 | $obj->description = $val->description->body; |
829 | - if($obj->name) |
|
829 | + if ($obj->name) |
|
830 | 830 | { |
831 | 831 | $obj->value = $extra_vals->{$obj->name}; |
832 | 832 | } |
833 | - if(strpos($obj->value, '|@|') != FALSE) |
|
833 | + if (strpos($obj->value, '|@|') != FALSE) |
|
834 | 834 | { |
835 | 835 | $obj->value = explode('|@|', $obj->value); |
836 | 836 | } |
837 | - if($obj->type == 'mid_list' && !is_array($obj->value)) |
|
837 | + if ($obj->type == 'mid_list' && !is_array($obj->value)) |
|
838 | 838 | { |
839 | 839 | $obj->value = array($obj->value); |
840 | 840 | } |
841 | 841 | |
842 | 842 | // 'Select'type obtained from the option list. |
843 | - if($val->options && !is_array($val->options)) |
|
843 | + if ($val->options && !is_array($val->options)) |
|
844 | 844 | { |
845 | 845 | $val->options = array($val->options); |
846 | 846 | } |
847 | 847 | |
848 | - for($i = 0, $c = count($val->options); $i < $c; $i++) |
|
848 | + for ($i = 0, $c = count($val->options); $i < $c; $i++) |
|
849 | 849 | { |
850 | 850 | $obj->options[$i] = new stdClass(); |
851 | 851 | $obj->options[$i]->title = $val->options[$i]->title->body; |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | |
860 | 860 | $buff = array(); |
861 | 861 | $buff[] = '<?php if(!defined(\'__XE__\')) exit();'; |
862 | - $buff[] = '$xml_info = ' . var_export($component_info, TRUE) . ';'; |
|
862 | + $buff[] = '$xml_info = '.var_export($component_info, TRUE).';'; |
|
863 | 863 | $buff = str_replace('stdClass::__set_state', '(object)', implode(PHP_EOL, $buff)); |
864 | 864 | |
865 | 865 | FileHandler::writeFile($cache_file, $buff, 'w'); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * Delete selected files from the administrator page |
58 | 58 | * |
59 | - * @return Object |
|
59 | + * @return ModuleObject|null |
|
60 | 60 | */ |
61 | 61 | function procFileAdminDeleteChecked() |
62 | 62 | { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * Add file information for each module |
112 | 112 | * |
113 | - * @return void |
|
113 | + * @return Object|null |
|
114 | 114 | */ |
115 | 115 | function procFileAdminInsertModuleConfig() |
116 | 116 | { |
@@ -27,12 +27,16 @@ discard block |
||
27 | 27 | $args->module_srl = $module_srl; |
28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
29 | 29 | $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
30 | - if(!$output) return $output; |
|
30 | + if(!$output) { |
|
31 | + return $output; |
|
32 | + } |
|
31 | 33 | $files = $output->data; |
32 | 34 | // Remove from the DB |
33 | 35 | $args->module_srl = $module_srl; |
34 | 36 | $output = executeQuery('file.deleteModuleFiles', $args); |
35 | - if(!$output->toBool()) return $output; |
|
37 | + if(!$output->toBool()) { |
|
38 | + return $output; |
|
39 | + } |
|
36 | 40 | // Remove the file |
37 | 41 | FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
38 | 42 | FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
@@ -45,10 +49,14 @@ discard block |
||
45 | 49 | FileHandler::removeFile($uploaded_filename); |
46 | 50 | |
47 | 51 | $path_info = pathinfo($uploaded_filename); |
48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
52 | + if(!in_array($path_info['dirname'], $path)) { |
|
53 | + $path[] = $path_info['dirname']; |
|
54 | + } |
|
49 | 55 | } |
50 | 56 | // Remove a file directory of the document |
51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
57 | + for($i=0;$i<count($path);$i++) { |
|
58 | + FileHandler::removeBlankDir($path[$i]); |
|
59 | + } |
|
52 | 60 | |
53 | 61 | return $output; |
54 | 62 | } |
@@ -62,18 +70,27 @@ discard block |
||
62 | 70 | { |
63 | 71 | // An error appears if no document is selected |
64 | 72 | $cart = Context::get('cart'); |
65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
67 | - else $file_srl_list = $cart; |
|
73 | + if(!$cart) { |
|
74 | + return $this->stop('msg_file_cart_is_null'); |
|
75 | + } |
|
76 | + if(!is_array($cart)) { |
|
77 | + $file_srl_list= explode('|@|', $cart); |
|
78 | + } else { |
|
79 | + $file_srl_list = $cart; |
|
80 | + } |
|
68 | 81 | $file_count = count($file_srl_list); |
69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
82 | + if(!$file_count) { |
|
83 | + return $this->stop('msg_file_cart_is_null'); |
|
84 | + } |
|
70 | 85 | |
71 | 86 | $oFileController = getController('file'); |
72 | 87 | // Delete the post |
73 | 88 | for($i=0;$i<$file_count;$i++) |
74 | 89 | { |
75 | 90 | $file_srl = trim($file_srl_list[$i]); |
76 | - if(!$file_srl) continue; |
|
91 | + if(!$file_srl) { |
|
92 | + continue; |
|
93 | + } |
|
77 | 94 | |
78 | 95 | $oFileController->deleteFile($file_srl); |
79 | 96 | } |
@@ -117,8 +134,11 @@ discard block |
||
117 | 134 | // Get variables |
118 | 135 | $module_srl = Context::get('target_module_srl'); |
119 | 136 | // In order to configure multiple modules at once |
120 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
121 | - else $module_srl = array($module_srl); |
|
137 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
138 | + $module_srl = explode(',',$module_srl); |
|
139 | + } else { |
|
140 | + $module_srl = array($module_srl); |
|
141 | + } |
|
122 | 142 | |
123 | 143 | $download_grant = Context::get('download_grant'); |
124 | 144 | |
@@ -130,8 +150,11 @@ discard block |
||
130 | 150 | $file_config->allowed_attach_size = Context::get('allowed_attach_size'); |
131 | 151 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
132 | 152 | |
133 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
134 | - else $file_config->download_grant = $download_grant; |
|
153 | + if(!is_array($download_grant)) { |
|
154 | + $file_config->download_grant = explode('|@|',$download_grant); |
|
155 | + } else { |
|
156 | + $file_config->download_grant = $download_grant; |
|
157 | + } |
|
135 | 158 | |
136 | 159 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
137 | 160 | $userFileAllowSize = FileHandler::returnbytes($file_config->allowed_filesize.'M'); |
@@ -140,14 +163,17 @@ discard block |
||
140 | 163 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
141 | 164 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
142 | 165 | |
143 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
144 | - return new Object(-1, 'input size over than config in php.ini'); |
|
166 | + if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) { |
|
167 | + return new Object(-1, 'input size over than config in php.ini'); |
|
168 | + } |
|
145 | 169 | |
146 | 170 | $oModuleController = getController('module'); |
147 | 171 | for($i=0;$i<count($module_srl);$i++) |
148 | 172 | { |
149 | 173 | $srl = trim($module_srl[$i]); |
150 | - if(!$srl) continue; |
|
174 | + if(!$srl) { |
|
175 | + continue; |
|
176 | + } |
|
151 | 177 | $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
152 | 178 | } |
153 | 179 | |
@@ -174,8 +200,11 @@ discard block |
||
174 | 200 | |
175 | 201 | if($output->file_srl) |
176 | 202 | { |
177 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
178 | - else $_SESSION['file_management'][$output->file_srl] = true; |
|
203 | + if($_SESSION['file_management'][$output->file_srl]) { |
|
204 | + unset($_SESSION['file_management'][$output->file_srl]); |
|
205 | + } else { |
|
206 | + $_SESSION['file_management'][$output->file_srl] = true; |
|
207 | + } |
|
179 | 208 | } |
180 | 209 | } |
181 | 210 | } |
@@ -26,29 +26,29 @@ discard block |
||
26 | 26 | $args = new stdClass(); |
27 | 27 | $args->module_srl = $module_srl; |
28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
29 | - $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
|
30 | - if(!$output) return $output; |
|
29 | + $output = executeQueryArray('file.getModuleFiles', $args, $columnList); |
|
30 | + if (!$output) return $output; |
|
31 | 31 | $files = $output->data; |
32 | 32 | // Remove from the DB |
33 | 33 | $args->module_srl = $module_srl; |
34 | 34 | $output = executeQuery('file.deleteModuleFiles', $args); |
35 | - if(!$output->toBool()) return $output; |
|
35 | + if (!$output->toBool()) return $output; |
|
36 | 36 | // Remove the file |
37 | - FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
|
38 | - FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
|
37 | + FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl)); |
|
38 | + FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl)); |
|
39 | 39 | // Remove the file list obtained from the DB |
40 | 40 | $path = array(); |
41 | 41 | $cnt = count($files); |
42 | - for($i=0;$i<$cnt;$i++) |
|
42 | + for ($i = 0; $i < $cnt; $i++) |
|
43 | 43 | { |
44 | 44 | $uploaded_filename = $files[$i]->uploaded_filename; |
45 | 45 | FileHandler::removeFile($uploaded_filename); |
46 | 46 | |
47 | 47 | $path_info = pathinfo($uploaded_filename); |
48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
48 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
49 | 49 | } |
50 | 50 | // Remove a file directory of the document |
51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
51 | + for ($i = 0; $i < count($path); $i++) FileHandler::removeBlankDir($path[$i]); |
|
52 | 52 | |
53 | 53 | return $output; |
54 | 54 | } |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | { |
63 | 63 | // An error appears if no document is selected |
64 | 64 | $cart = Context::get('cart'); |
65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
65 | + if (!$cart) return $this->stop('msg_file_cart_is_null'); |
|
66 | + if (!is_array($cart)) $file_srl_list = explode('|@|', $cart); |
|
67 | 67 | else $file_srl_list = $cart; |
68 | 68 | $file_count = count($file_srl_list); |
69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
69 | + if (!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
70 | 70 | |
71 | 71 | $oFileController = getController('file'); |
72 | 72 | // Delete the post |
73 | - for($i=0;$i<$file_count;$i++) |
|
73 | + for ($i = 0; $i < $file_count; $i++) |
|
74 | 74 | { |
75 | 75 | $file_srl = trim($file_srl_list[$i]); |
76 | - if(!$file_srl) continue; |
|
76 | + if (!$file_srl) continue; |
|
77 | 77 | |
78 | 78 | $oFileController->deleteFile($file_srl); |
79 | 79 | } |
80 | 80 | |
81 | - $this->setMessage( sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count) ); |
|
81 | + $this->setMessage(sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count)); |
|
82 | 82 | |
83 | 83 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminList'); |
84 | 84 | $this->setRedirectUrl($returnUrl); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $config->allow_outlink_site = Context::get('allow_outlink_site'); |
102 | 102 | // Create module Controller object |
103 | 103 | $oModuleController = getController('module'); |
104 | - $output = $oModuleController->insertModuleConfig('file',$config); |
|
104 | + $output = $oModuleController->insertModuleConfig('file', $config); |
|
105 | 105 | |
106 | 106 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminConfig'); |
107 | 107 | return $this->setRedirectUrl($returnUrl, $output); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // Get variables |
118 | 118 | $module_srl = Context::get('target_module_srl'); |
119 | 119 | // In order to configure multiple modules at once |
120 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
120 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
121 | 121 | else $module_srl = array($module_srl); |
122 | 122 | |
123 | 123 | $download_grant = Context::get('download_grant'); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $file_config->allowed_attach_size = Context::get('allowed_attach_size'); |
131 | 131 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
132 | 132 | |
133 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
133 | + if (!is_array($download_grant)) $file_config->download_grant = explode('|@|', $download_grant); |
|
134 | 134 | else $file_config->download_grant = $download_grant; |
135 | 135 | |
136 | 136 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
141 | 141 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
142 | 142 | |
143 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
143 | + if ($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
144 | 144 | return new Object(-1, 'input size over than config in php.ini'); |
145 | 145 | |
146 | 146 | $oModuleController = getController('module'); |
147 | - for($i=0;$i<count($module_srl);$i++) |
|
147 | + for ($i = 0; $i < count($module_srl); $i++) |
|
148 | 148 | { |
149 | 149 | $srl = trim($module_srl[$i]); |
150 | - if(!$srl) continue; |
|
151 | - $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
|
150 | + if (!$srl) continue; |
|
151 | + $oModuleController->insertModulePartConfig('file', $srl, $file_config); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $this->setError(-1); |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | */ |
166 | 166 | function procFileAdminAddCart() |
167 | 167 | { |
168 | - $file_srl = (int)Context::get('file_srl'); |
|
168 | + $file_srl = (int) Context::get('file_srl'); |
|
169 | 169 | //$fileSrlList = array(500, 502); |
170 | 170 | |
171 | 171 | $oFileModel = getModel('file'); |
172 | 172 | $output = $oFileModel->getFile($file_srl); |
173 | 173 | //$output = $oFileModel->getFile($fileSrlList); |
174 | 174 | |
175 | - if($output->file_srl) |
|
175 | + if ($output->file_srl) |
|
176 | 176 | { |
177 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
177 | + if ($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
178 | 178 | else $_SESSION['file_management'][$output->file_srl] = true; |
179 | 179 | } |
180 | 180 | } |
@@ -144,7 +144,7 @@ |
||
144 | 144 | * Make search parameters from object(private) |
145 | 145 | * |
146 | 146 | * @param object $obj Original searach options |
147 | - * @param object $args Result searach options |
|
147 | + * @param stdClass $args Result searach options |
|
148 | 148 | * @return void |
149 | 149 | */ |
150 | 150 | function _makeSearchParam(&$obj, &$args) |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | $this->_makeSearchParam($obj, $args); |
69 | 69 | |
70 | 70 | // Set valid/invalid state |
71 | - if($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
72 | - elseif($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
71 | + if ($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
72 | + elseif ($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
73 | 73 | // Set multimedia/common file |
74 | - if($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
75 | - elseif($obj->direct_download == 'N') $args->direct_download= 'N'; |
|
74 | + if ($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
75 | + elseif ($obj->direct_download == 'N') $args->direct_download = 'N'; |
|
76 | 76 | // Set variables |
77 | 77 | $args->sort_index = $obj->sort_index; |
78 | - $args->page = $obj->page?$obj->page:1; |
|
79 | - $args->list_count = $obj->list_count?$obj->list_count:20; |
|
80 | - $args->page_count = $obj->page_count?$obj->page_count:10; |
|
78 | + $args->page = $obj->page ? $obj->page : 1; |
|
79 | + $args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
80 | + $args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
81 | 81 | $args->s_module_srl = $obj->module_srl; |
82 | 82 | $args->exclude_module_srl = $obj->exclude_module_srl; |
83 | 83 | // Execute the file.getFileList query |
84 | 84 | $output = executeQuery('file.getFileList', $args, $columnList); |
85 | 85 | // Return if no result or an error occurs |
86 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
86 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
87 | 87 | |
88 | 88 | $oFileModel = getModel('file'); |
89 | 89 | |
90 | - foreach($output->data as $key => $file) |
|
90 | + foreach ($output->data as $key => $file) |
|
91 | 91 | { |
92 | - if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
92 | + if ($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
93 | 93 | else $file->isCarted = false; |
94 | 94 | |
95 | 95 | $file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | */ |
133 | 133 | function getFilesCountByDate($date = '') |
134 | 134 | { |
135 | - if($date) $args->regDate = date('Ymd', strtotime($date)); |
|
135 | + if ($date) $args->regDate = date('Ymd', strtotime($date)); |
|
136 | 136 | |
137 | 137 | $output = executeQuery('file.getFilesCount', $args); |
138 | - if(!$output->toBool()) return 0; |
|
138 | + if (!$output->toBool()) return 0; |
|
139 | 139 | |
140 | 140 | return $output->data->count; |
141 | 141 | } |
@@ -150,31 +150,31 @@ discard block |
||
150 | 150 | function _makeSearchParam(&$obj, &$args) |
151 | 151 | { |
152 | 152 | // Search options |
153 | - $search_target = $obj->search_target?$obj->search_target:trim(Context::get('search_target')); |
|
154 | - $search_keyword = $obj->search_keyword?$obj->search_keyword:trim(Context::get('search_keyword')); |
|
153 | + $search_target = $obj->search_target ? $obj->search_target : trim(Context::get('search_target')); |
|
154 | + $search_keyword = $obj->search_keyword ? $obj->search_keyword : trim(Context::get('search_keyword')); |
|
155 | 155 | |
156 | - if($search_target && $search_keyword) |
|
156 | + if ($search_target && $search_keyword) |
|
157 | 157 | { |
158 | - switch($search_target) |
|
158 | + switch ($search_target) |
|
159 | 159 | { |
160 | 160 | case 'filename' : |
161 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
161 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
162 | 162 | $args->s_filename = $search_keyword; |
163 | 163 | break; |
164 | 164 | case 'filesize_more' : |
165 | - $args->s_filesize_more = (int)$search_keyword; |
|
165 | + $args->s_filesize_more = (int) $search_keyword; |
|
166 | 166 | break; |
167 | 167 | case 'filesize_mega_more' : |
168 | - $args->s_filesize_more = (int)$search_keyword * 1024 * 1024; |
|
168 | + $args->s_filesize_more = (int) $search_keyword * 1024 * 1024; |
|
169 | 169 | break; |
170 | 170 | case 'filesize_less' : |
171 | - $args->s_filesize_less = (int)$search_keyword; |
|
171 | + $args->s_filesize_less = (int) $search_keyword; |
|
172 | 172 | break; |
173 | 173 | case 'filesize_mega_less' : |
174 | - $args->s_filesize_less = (int)$search_keyword * 1024 * 1024; |
|
174 | + $args->s_filesize_less = (int) $search_keyword * 1024 * 1024; |
|
175 | 175 | break; |
176 | 176 | case 'download_count' : |
177 | - $args->s_download_count = (int)$search_keyword; |
|
177 | + $args->s_download_count = (int) $search_keyword; |
|
178 | 178 | break; |
179 | 179 | case 'regdate' : |
180 | 180 | $args->s_regdate = $search_keyword; |
@@ -68,11 +68,17 @@ discard block |
||
68 | 68 | $this->_makeSearchParam($obj, $args); |
69 | 69 | |
70 | 70 | // Set valid/invalid state |
71 | - if($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
72 | - elseif($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
71 | + if($obj->isvalid == 'Y') { |
|
72 | + $args->isvalid = 'Y'; |
|
73 | + } elseif($obj->isvalid == 'N') { |
|
74 | + $args->isvalid = 'N'; |
|
75 | + } |
|
73 | 76 | // Set multimedia/common file |
74 | - if($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
75 | - elseif($obj->direct_download == 'N') $args->direct_download= 'N'; |
|
77 | + if($obj->direct_download == 'Y') { |
|
78 | + $args->direct_download = 'Y'; |
|
79 | + } elseif($obj->direct_download == 'N') { |
|
80 | + $args->direct_download= 'N'; |
|
81 | + } |
|
76 | 82 | // Set variables |
77 | 83 | $args->sort_index = $obj->sort_index; |
78 | 84 | $args->page = $obj->page?$obj->page:1; |
@@ -83,14 +89,19 @@ discard block |
||
83 | 89 | // Execute the file.getFileList query |
84 | 90 | $output = executeQuery('file.getFileList', $args, $columnList); |
85 | 91 | // Return if no result or an error occurs |
86 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
92 | + if(!$output->toBool()||!count($output->data)) { |
|
93 | + return $output; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | $oFileModel = getModel('file'); |
89 | 97 | |
90 | 98 | foreach($output->data as $key => $file) |
91 | 99 | { |
92 | - if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
93 | - else $file->isCarted = false; |
|
100 | + if($_SESSION['file_management'][$file->file_srl]) { |
|
101 | + $file->isCarted = true; |
|
102 | + } else { |
|
103 | + $file->isCarted = false; |
|
104 | + } |
|
94 | 105 | |
95 | 106 | $file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
96 | 107 | $output->data[$key] = $file; |
@@ -132,10 +143,14 @@ discard block |
||
132 | 143 | */ |
133 | 144 | function getFilesCountByDate($date = '') |
134 | 145 | { |
135 | - if($date) $args->regDate = date('Ymd', strtotime($date)); |
|
146 | + if($date) { |
|
147 | + $args->regDate = date('Ymd', strtotime($date)); |
|
148 | + } |
|
136 | 149 | |
137 | 150 | $output = executeQuery('file.getFilesCount', $args); |
138 | - if(!$output->toBool()) return 0; |
|
151 | + if(!$output->toBool()) { |
|
152 | + return 0; |
|
153 | + } |
|
139 | 154 | |
140 | 155 | return $output->data->count; |
141 | 156 | } |
@@ -158,7 +173,9 @@ discard block |
||
158 | 173 | switch($search_target) |
159 | 174 | { |
160 | 175 | case 'filename' : |
161 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
176 | + if($search_keyword) { |
|
177 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
178 | + } |
|
162 | 179 | $args->s_filename = $search_keyword; |
163 | 180 | break; |
164 | 181 | case 'filesize_more' : |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * Image resize |
91 | 91 | * |
92 | - * @return Object |
|
92 | + * @return Object|null |
|
93 | 93 | */ |
94 | 94 | function procFileImageResize() |
95 | 95 | { |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | /** |
397 | 397 | * get file list |
398 | 398 | * |
399 | - * @return Object |
|
399 | + * @return Object|null |
|
400 | 400 | */ |
401 | 401 | function procFileGetList() |
402 | 402 | { |
@@ -29,24 +29,24 @@ discard block |
||
29 | 29 | $file_info = $_FILES['Filedata']; |
30 | 30 | |
31 | 31 | // An error appears if not a normally uploaded file |
32 | - if(!is_uploaded_file($file_info['tmp_name'])) exit(); |
|
32 | + if (!is_uploaded_file($file_info['tmp_name'])) exit(); |
|
33 | 33 | |
34 | 34 | // Basic variables setting |
35 | 35 | $oFileModel = getModel('file'); |
36 | 36 | $editor_sequence = Context::get('editor_sequence'); |
37 | 37 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
38 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
38 | + if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
39 | 39 | $module_srl = $this->module_srl; |
40 | 40 | // Exit a session if there is neither upload permission nor information |
41 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
41 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
42 | 42 | // Extract from session information if upload_target_srl is not specified |
43 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
43 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
44 | 44 | // Create if upload_target_srl is not defined in the session information |
45 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
45 | + if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
46 | 46 | |
47 | 47 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
48 | 48 | Context::setResponseMethod('JSON'); |
49 | - if($output->error != '0') $this->stop($output->message); |
|
49 | + if ($output->error != '0') $this->stop($output->message); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -61,26 +61,26 @@ discard block |
||
61 | 61 | $callback = Context::get('callback'); |
62 | 62 | $module_srl = $this->module_srl; |
63 | 63 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
64 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
64 | + if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
65 | 65 | |
66 | 66 | // Exit a session if there is neither upload permission nor information |
67 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
67 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
68 | 68 | // Extract from session information if upload_target_srl is not specified |
69 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
69 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
70 | 70 | // Create if upload_target_srl is not defined in the session information |
71 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
71 | + if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
72 | 72 | // Delete and then attempt to re-upload if file_srl is requested |
73 | 73 | $file_srl = Context::get('file_srl'); |
74 | - if($file_srl) $this->deleteFile($file_srl); |
|
74 | + if ($file_srl) $this->deleteFile($file_srl); |
|
75 | 75 | |
76 | 76 | $file_info = Context::get('Filedata'); |
77 | 77 | // An error appears if not a normally uploaded file |
78 | - if(is_uploaded_file($file_info['tmp_name'])) { |
|
78 | + if (is_uploaded_file($file_info['tmp_name'])) { |
|
79 | 79 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
80 | - Context::set('uploaded_fileinfo',$output); |
|
80 | + Context::set('uploaded_fileinfo', $output); |
|
81 | 81 | } |
82 | 82 | |
83 | - Context::set('layout','none'); |
|
83 | + Context::set('layout', 'none'); |
|
84 | 84 | |
85 | 85 | $this->setTemplatePath($this->module_path.'tpl'); |
86 | 86 | $this->setTemplateFile('iframe'); |
@@ -97,24 +97,24 @@ discard block |
||
97 | 97 | $width = Context::get('width'); |
98 | 98 | $height = Context::get('height'); |
99 | 99 | |
100 | - if(!$file_srl || !$width) |
|
100 | + if (!$file_srl || !$width) |
|
101 | 101 | { |
102 | - return new Object(-1,'msg_invalid_request'); |
|
102 | + return new Object(-1, 'msg_invalid_request'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $oFileModel = getModel('file'); |
106 | 106 | $fileInfo = $oFileModel->getFile($file_srl); |
107 | - if(!$fileInfo || $fileInfo->direct_download != 'Y') |
|
107 | + if (!$fileInfo || $fileInfo->direct_download != 'Y') |
|
108 | 108 | { |
109 | - return new Object(-1,'msg_invalid_request'); |
|
109 | + return new Object(-1, 'msg_invalid_request'); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $source_src = $fileInfo->uploaded_filename; |
113 | - $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
|
113 | + $output_src = $source_src.'.resized'.strrchr($source_src, '.'); |
|
114 | 114 | |
115 | - if(!$height) $height = $width-1; |
|
115 | + if (!$height) $height = $width - 1; |
|
116 | 116 | |
117 | - if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
|
117 | + if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio')) |
|
118 | 118 | { |
119 | 119 | $output = new stdClass(); |
120 | 120 | $output->info = getimagesize($output_src); |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | } |
123 | 123 | else |
124 | 124 | { |
125 | - return new Object(-1,'msg_invalid_request'); |
|
125 | + return new Object(-1, 'msg_invalid_request'); |
|
126 | 126 | } |
127 | 127 | |
128 | - $this->add('resized_info',$output); |
|
128 | + $this->add('resized_info', $output); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | { |
164 | 164 | $oFileModel = getModel('file'); |
165 | 165 | |
166 | - if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
166 | + if (isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
167 | 167 | |
168 | 168 | $file_srl = Context::get('file_srl'); |
169 | 169 | $sid = Context::get('sid'); |
@@ -172,26 +172,26 @@ discard block |
||
172 | 172 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
173 | 173 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
174 | 174 | // If the requested file information is incorrect, an error that file cannot be found appears |
175 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
175 | + if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found'); |
|
176 | 176 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
177 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
177 | + if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download'); |
|
178 | 178 | // File name |
179 | 179 | $filename = $file_obj->source_filename; |
180 | 180 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
181 | 181 | // Not allow the file outlink |
182 | - if($file_module_config->allow_outlink == 'N') |
|
182 | + if ($file_module_config->allow_outlink == 'N') |
|
183 | 183 | { |
184 | 184 | // Handles extension to allow outlink |
185 | - if($file_module_config->allow_outlink_format) |
|
185 | + if ($file_module_config->allow_outlink_format) |
|
186 | 186 | { |
187 | 187 | $allow_outlink_format_array = array(); |
188 | 188 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
189 | - if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
189 | + if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
190 | 190 | |
191 | - foreach($allow_outlink_format_array as $val) |
|
191 | + foreach ($allow_outlink_format_array as $val) |
|
192 | 192 | { |
193 | 193 | $val = trim($val); |
194 | - if(preg_match("/\.{$val}$/i", $filename)) |
|
194 | + if (preg_match("/\.{$val}$/i", $filename)) |
|
195 | 195 | { |
196 | 196 | $file_module_config->allow_outlink = 'Y'; |
197 | 197 | break; |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | // Sites that outlink is allowed |
202 | - if($file_module_config->allow_outlink != 'Y') |
|
202 | + if ($file_module_config->allow_outlink != 'Y') |
|
203 | 203 | { |
204 | 204 | $referer = parse_url($_SERVER["HTTP_REFERER"]); |
205 | - if($referer['host'] != $_SERVER['HTTP_HOST']) |
|
205 | + if ($referer['host'] != $_SERVER['HTTP_HOST']) |
|
206 | 206 | { |
207 | - if($file_module_config->allow_outlink_site) |
|
207 | + if ($file_module_config->allow_outlink_site) |
|
208 | 208 | { |
209 | 209 | $allow_outlink_site_array = array(); |
210 | 210 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
211 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
211 | + if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
212 | 212 | |
213 | - foreach($allow_outlink_site_array as $val) |
|
213 | + foreach ($allow_outlink_site_array as $val) |
|
214 | 214 | { |
215 | 215 | $site = parse_url(trim($val)); |
216 | - if($site['host'] == $referer['host']) |
|
216 | + if ($site['host'] == $referer['host']) |
|
217 | 217 | { |
218 | 218 | $file_module_config->allow_outlink = 'Y'; |
219 | 219 | break; |
@@ -223,49 +223,49 @@ discard block |
||
223 | 223 | } |
224 | 224 | else $file_module_config->allow_outlink = 'Y'; |
225 | 225 | } |
226 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
226 | + if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | // Check if a permission for file download is granted |
230 | 230 | $downloadGrantCount = 0; |
231 | - if(is_array($file_module_config->download_grant)) |
|
231 | + if (is_array($file_module_config->download_grant)) |
|
232 | 232 | { |
233 | - foreach($file_module_config->download_grant AS $value) |
|
234 | - if($value) $downloadGrantCount++; |
|
233 | + foreach ($file_module_config->download_grant AS $value) |
|
234 | + if ($value) $downloadGrantCount++; |
|
235 | 235 | } |
236 | 236 | |
237 | - if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
|
237 | + if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0) |
|
238 | 238 | { |
239 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
239 | + if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
240 | 240 | $logged_info = Context::get('logged_info'); |
241 | - if($logged_info->is_admin != 'Y') |
|
241 | + if ($logged_info->is_admin != 'Y') |
|
242 | 242 | { |
243 | - $oModuleModel =& getModel('module'); |
|
243 | + $oModuleModel = & getModel('module'); |
|
244 | 244 | $columnList = array('module_srl', 'site_srl'); |
245 | 245 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList); |
246 | 246 | |
247 | - if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
247 | + if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
248 | 248 | { |
249 | - $oMemberModel =& getModel('member'); |
|
249 | + $oMemberModel = & getModel('member'); |
|
250 | 250 | $member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl); |
251 | 251 | |
252 | 252 | $is_permitted = false; |
253 | - for($i=0;$i<count($file_module_config->download_grant);$i++) |
|
253 | + for ($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
254 | 254 | { |
255 | 255 | $group_srl = $file_module_config->download_grant[$i]; |
256 | - if($member_groups[$group_srl]) |
|
256 | + if ($member_groups[$group_srl]) |
|
257 | 257 | { |
258 | 258 | $is_permitted = true; |
259 | 259 | break; |
260 | 260 | } |
261 | 261 | } |
262 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
262 | + if (!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | 266 | // Call a trigger (before) |
267 | 267 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
268 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
268 | + if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download'); |
|
269 | 269 | |
270 | 270 | |
271 | 271 | // 다운로드 후 (가상) |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | $random = new Password(); |
280 | 280 | $file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex'); |
281 | - header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key)); |
|
281 | + header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key)); |
|
282 | 282 | Context::close(); |
283 | 283 | exit(); |
284 | 284 | |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | $oFileModel = getModel('file'); |
290 | 290 | $file_srl = Context::get('file_srl'); |
291 | 291 | $file_key = Context::get('file_key'); |
292 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
292 | + if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
293 | 293 | |
294 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
294 | + if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
295 | 295 | else $session_key = '__XE_FILE_KEY__'; |
296 | 296 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
297 | 297 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
298 | 298 | |
299 | 299 | $uploaded_filename = $file_obj->uploaded_filename; |
300 | 300 | |
301 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
301 | + if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
302 | 302 | |
303 | - if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
303 | + if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
304 | 304 | { |
305 | 305 | unset($_SESSION[$session_key][$file_srl]); |
306 | 306 | return $this->stop('msg_invalid_request'); |
@@ -309,34 +309,34 @@ discard block |
||
309 | 309 | $file_size = $file_obj->file_size; |
310 | 310 | $filename = $file_obj->source_filename; |
311 | 311 | |
312 | - if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
312 | + if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
313 | 313 | { |
314 | - if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
314 | + if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
315 | 315 | { |
316 | - $filename_param = 'filename="' . $filename . '"'; |
|
316 | + $filename_param = 'filename="'.$filename.'"'; |
|
317 | 317 | } |
318 | 318 | else |
319 | 319 | { |
320 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
320 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
321 | 321 | } |
322 | 322 | } |
323 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
323 | + elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
324 | 324 | { |
325 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
325 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
326 | 326 | } |
327 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
327 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
328 | 328 | { |
329 | 329 | $filename = rawurlencode($filename); |
330 | - $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
|
330 | + $filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"'; |
|
331 | 331 | } |
332 | 332 | else |
333 | 333 | { |
334 | - $filename_param = 'filename="' . $filename . '"'; |
|
334 | + $filename_param = 'filename="'.$filename.'"'; |
|
335 | 335 | } |
336 | 336 | |
337 | - if($is_android) |
|
337 | + if ($is_android) |
|
338 | 338 | { |
339 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
339 | + if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | unset($_SESSION[$session_key][$file_srl]); |
@@ -344,21 +344,21 @@ discard block |
||
344 | 344 | Context::close(); |
345 | 345 | |
346 | 346 | $fp = fopen($uploaded_filename, 'rb'); |
347 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
347 | + if (!$fp) return $this->stop('msg_file_not_found'); |
|
348 | 348 | |
349 | 349 | header("Cache-Control: "); |
350 | 350 | header("Pragma: "); |
351 | 351 | header("Content-Type: application/octet-stream"); |
352 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
352 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
353 | 353 | |
354 | - header("Content-Length: " .(string)($file_size)); |
|
355 | - header('Content-Disposition: attachment; ' . $filename_param); |
|
354 | + header("Content-Length: ".(string) ($file_size)); |
|
355 | + header('Content-Disposition: attachment; '.$filename_param); |
|
356 | 356 | header("Content-Transfer-Encoding: binary\n"); |
357 | 357 | |
358 | 358 | // if file size is lager than 10MB, use fread function (#18675748) |
359 | - if(filesize($uploaded_filename) > 1024 * 1024) |
|
359 | + if (filesize($uploaded_filename) > 1024 * 1024) |
|
360 | 360 | { |
361 | - while(!feof($fp)) echo fread($fp, 1024); |
|
361 | + while (!feof($fp)) echo fread($fp, 1024); |
|
362 | 362 | fclose($fp); |
363 | 363 | } |
364 | 364 | else |
@@ -380,36 +380,36 @@ discard block |
||
380 | 380 | $editor_sequence = Context::get('editor_sequence'); |
381 | 381 | $file_srl = Context::get('file_srl'); |
382 | 382 | $file_srls = Context::get('file_srls'); |
383 | - if($file_srls) $file_srl = $file_srls; |
|
383 | + if ($file_srls) $file_srl = $file_srls; |
|
384 | 384 | // Exit a session if there is neither upload permission nor information |
385 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
385 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
386 | 386 | |
387 | 387 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
388 | 388 | |
389 | 389 | $logged_info = Context::get('logged_info'); |
390 | 390 | $oFileModel = getModel('file'); |
391 | 391 | |
392 | - $srls = explode(',',$file_srl); |
|
393 | - if(!count($srls)) return; |
|
392 | + $srls = explode(',', $file_srl); |
|
393 | + if (!count($srls)) return; |
|
394 | 394 | |
395 | - for($i=0;$i<count($srls);$i++) |
|
395 | + for ($i = 0; $i < count($srls); $i++) |
|
396 | 396 | { |
397 | - $srl = (int)$srls[$i]; |
|
398 | - if(!$srl) continue; |
|
397 | + $srl = (int) $srls[$i]; |
|
398 | + if (!$srl) continue; |
|
399 | 399 | |
400 | 400 | $args = new stdClass; |
401 | 401 | $args->file_srl = $srl; |
402 | 402 | $output = executeQuery('file.getFile', $args); |
403 | - if(!$output->toBool()) continue; |
|
403 | + if (!$output->toBool()) continue; |
|
404 | 404 | |
405 | 405 | $file_info = $output->data; |
406 | - if(!$file_info) continue; |
|
406 | + if (!$file_info) continue; |
|
407 | 407 | |
408 | 408 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
409 | 409 | |
410 | - if(!$file_grant->is_deletable) continue; |
|
410 | + if (!$file_grant->is_deletable) continue; |
|
411 | 411 | |
412 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
412 | + if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -420,23 +420,23 @@ discard block |
||
420 | 420 | */ |
421 | 421 | function procFileGetList() |
422 | 422 | { |
423 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
423 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
424 | 424 | $fileSrls = Context::get('file_srls'); |
425 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
425 | + if ($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
426 | 426 | |
427 | 427 | global $lang; |
428 | - if(count($fileSrlList) > 0) |
|
428 | + if (count($fileSrlList) > 0) |
|
429 | 429 | { |
430 | 430 | $oFileModel = getModel('file'); |
431 | 431 | $fileList = $oFileModel->getFile($fileSrlList); |
432 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
432 | + if (!is_array($fileList)) $fileList = array($fileList); |
|
433 | 433 | |
434 | - if(is_array($fileList)) |
|
434 | + if (is_array($fileList)) |
|
435 | 435 | { |
436 | - foreach($fileList AS $key=>$value) |
|
436 | + foreach ($fileList AS $key=>$value) |
|
437 | 437 | { |
438 | 438 | $value->human_file_size = FileHandler::filesize($value->file_size); |
439 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
439 | + if ($value->isvalid == 'Y') $value->validName = $lang->is_valid; |
|
440 | 440 | else $value->validName = $lang->is_stand_by; |
441 | 441 | } |
442 | 442 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | function triggerCheckAttached(&$obj) |
459 | 459 | { |
460 | 460 | $document_srl = $obj->document_srl; |
461 | - if(!$document_srl) return new Object(); |
|
461 | + if (!$document_srl) return new Object(); |
|
462 | 462 | // Get numbers of attachments |
463 | 463 | $oFileModel = getModel('file'); |
464 | 464 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -475,10 +475,10 @@ discard block |
||
475 | 475 | function triggerAttachFiles(&$obj) |
476 | 476 | { |
477 | 477 | $document_srl = $obj->document_srl; |
478 | - if(!$document_srl) return new Object(); |
|
478 | + if (!$document_srl) return new Object(); |
|
479 | 479 | |
480 | 480 | $output = $this->setFilesValid($document_srl); |
481 | - if(!$output->toBool()) return $output; |
|
481 | + if (!$output->toBool()) return $output; |
|
482 | 482 | |
483 | 483 | return new Object(); |
484 | 484 | } |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | function triggerDeleteAttached(&$obj) |
493 | 493 | { |
494 | 494 | $document_srl = $obj->document_srl; |
495 | - if(!$document_srl) return new Object(); |
|
495 | + if (!$document_srl) return new Object(); |
|
496 | 496 | |
497 | 497 | $output = $this->deleteFiles($document_srl); |
498 | 498 | return $output; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | function triggerCommentCheckAttached(&$obj) |
508 | 508 | { |
509 | 509 | $comment_srl = $obj->comment_srl; |
510 | - if(!$comment_srl) return new Object(); |
|
510 | + if (!$comment_srl) return new Object(); |
|
511 | 511 | // Get numbers of attachments |
512 | 512 | $oFileModel = getModel('file'); |
513 | 513 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -525,10 +525,10 @@ discard block |
||
525 | 525 | { |
526 | 526 | $comment_srl = $obj->comment_srl; |
527 | 527 | $uploaded_count = $obj->uploaded_count; |
528 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
528 | + if (!$comment_srl || !$uploaded_count) return new Object(); |
|
529 | 529 | |
530 | 530 | $output = $this->setFilesValid($comment_srl); |
531 | - if(!$output->toBool()) return $output; |
|
531 | + if (!$output->toBool()) return $output; |
|
532 | 532 | |
533 | 533 | return new Object(); |
534 | 534 | } |
@@ -542,9 +542,9 @@ discard block |
||
542 | 542 | function triggerCommentDeleteAttached(&$obj) |
543 | 543 | { |
544 | 544 | $comment_srl = $obj->comment_srl; |
545 | - if(!$comment_srl) return new Object(); |
|
545 | + if (!$comment_srl) return new Object(); |
|
546 | 546 | |
547 | - if($obj->isMoveToTrash) return new Object(); |
|
547 | + if ($obj->isMoveToTrash) return new Object(); |
|
548 | 548 | |
549 | 549 | $output = $this->deleteFiles($comment_srl); |
550 | 550 | return $output; |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | function triggerDeleteModuleFiles(&$obj) |
560 | 560 | { |
561 | 561 | $module_srl = $obj->module_srl; |
562 | - if(!$module_srl) return new Object(); |
|
562 | + if (!$module_srl) return new Object(); |
|
563 | 563 | |
564 | 564 | $oFileController = getAdminController('file'); |
565 | 565 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | * @param int $upload_target_srl |
573 | 573 | * @return void |
574 | 574 | */ |
575 | - function setUploadInfo($editor_sequence, $upload_target_srl=0) |
|
575 | + function setUploadInfo($editor_sequence, $upload_target_srl = 0) |
|
576 | 576 | { |
577 | - if(!isset($_SESSION['upload_info'][$editor_sequence])) |
|
577 | + if (!isset($_SESSION['upload_info'][$editor_sequence])) |
|
578 | 578 | { |
579 | 579 | $_SESSION['upload_info'][$editor_sequence] = new stdClass(); |
580 | 580 | } |
@@ -634,36 +634,36 @@ discard block |
||
634 | 634 | $trigger_obj->module_srl = $module_srl; |
635 | 635 | $trigger_obj->upload_target_srl = $upload_target_srl; |
636 | 636 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
637 | - if(!$output->toBool()) return $output; |
|
637 | + if (!$output->toBool()) return $output; |
|
638 | 638 | |
639 | 639 | // A workaround for Firefox upload bug |
640 | - if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
640 | + if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
641 | 641 | { |
642 | 642 | $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); |
643 | 643 | } |
644 | 644 | |
645 | - if(!$manual_insert) |
|
645 | + if (!$manual_insert) |
|
646 | 646 | { |
647 | 647 | // Get the file configurations |
648 | 648 | $logged_info = Context::get('logged_info'); |
649 | - if($logged_info->is_admin != 'Y') |
|
649 | + if ($logged_info->is_admin != 'Y') |
|
650 | 650 | { |
651 | 651 | $oFileModel = getModel('file'); |
652 | 652 | $config = $oFileModel->getFileConfig($module_srl); |
653 | 653 | |
654 | 654 | // check file type |
655 | - if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
655 | + if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
656 | 656 | { |
657 | 657 | $filetypes = explode(';', $config->allowed_filetypes); |
658 | 658 | $ext = array(); |
659 | - foreach($filetypes as $item) { |
|
659 | + foreach ($filetypes as $item) { |
|
660 | 660 | $item = explode('.', $item); |
661 | 661 | $ext[] = strtolower($item[1]); |
662 | 662 | } |
663 | 663 | $uploaded_ext = explode('.', $file_info['name']); |
664 | 664 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
665 | 665 | |
666 | - if(!in_array($uploaded_ext, $ext)) |
|
666 | + if (!in_array($uploaded_ext, $ext)) |
|
667 | 667 | { |
668 | 668 | return $this->stop('msg_not_allowed_filetype'); |
669 | 669 | } |
@@ -672,63 +672,63 @@ discard block |
||
672 | 672 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
673 | 673 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
674 | 674 | // An error appears if file size exceeds a limit |
675 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
675 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
676 | 676 | // Get total file size of all attachements (from DB) |
677 | 677 | $size_args = new stdClass; |
678 | 678 | $size_args->upload_target_srl = $upload_target_srl; |
679 | 679 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
680 | - $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
|
681 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
680 | + $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']); |
|
681 | + if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 | |
685 | 685 | // https://github.com/xpressengine/xe-core/issues/1713 |
686 | - $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']); |
|
686 | + $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']); |
|
687 | 687 | $file_info['name'] = removeHackTag($file_info['name']); |
688 | - $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']); |
|
688 | + $file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']); |
|
689 | 689 | |
690 | 690 | // Get random number generator |
691 | 691 | $random = new Password(); |
692 | 692 | |
693 | 693 | // Set upload path by checking if the attachement is an image or other kinds of file |
694 | - if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
694 | + if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
695 | 695 | { |
696 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
696 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
697 | 697 | |
698 | 698 | // special character to '_' |
699 | 699 | // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter |
700 | - $ext = substr(strrchr($file_info['name'],'.'),1); |
|
700 | + $ext = substr(strrchr($file_info['name'], '.'), 1); |
|
701 | 701 | //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']); |
702 | 702 | $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
703 | 703 | $filename = $path.$_filename; |
704 | 704 | $idx = 1; |
705 | - while(file_exists($filename)) |
|
705 | + while (file_exists($filename)) |
|
706 | 706 | { |
707 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename); |
|
707 | + $filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename); |
|
708 | 708 | $idx++; |
709 | 709 | } |
710 | 710 | $direct_download = 'Y'; |
711 | 711 | } |
712 | 712 | else |
713 | 713 | { |
714 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
714 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
715 | 715 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
716 | 716 | $direct_download = 'N'; |
717 | 717 | } |
718 | 718 | // Create a directory |
719 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
719 | + if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create'); |
|
720 | 720 | |
721 | 721 | // Check uploaded file |
722 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
722 | + if (!checkUploadedFile($file_info['tmp_name'])) return new Object(-1, 'msg_file_upload_error'); |
|
723 | 723 | |
724 | 724 | // Get random number generator |
725 | 725 | $random = new Password(); |
726 | 726 | |
727 | 727 | // Move the file |
728 | - if($manual_insert) |
|
728 | + if ($manual_insert) |
|
729 | 729 | { |
730 | 730 | @copy($file_info['tmp_name'], $filename); |
731 | - if(!file_exists($filename)) |
|
731 | + if (!file_exists($filename)) |
|
732 | 732 | { |
733 | 733 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
734 | 734 | @copy($file_info['tmp_name'], $filename); |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | } |
737 | 737 | else |
738 | 738 | { |
739 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
739 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
740 | 740 | { |
741 | 741 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
742 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
742 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1, 'msg_file_upload_error'); |
|
743 | 743 | } |
744 | 744 | } |
745 | 745 | // Get member information |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | $args->sid = $random->createSecureSalt(32, 'hex'); |
761 | 761 | |
762 | 762 | $output = executeQuery('file.insertFile', $args); |
763 | - if(!$output->toBool()) return $output; |
|
763 | + if (!$output->toBool()) return $output; |
|
764 | 764 | // Call a trigger (after) |
765 | 765 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
766 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
766 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
767 | 767 | |
768 | 768 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
769 | 769 | |
@@ -806,18 +806,18 @@ discard block |
||
806 | 806 | */ |
807 | 807 | function deleteFile($file_srl) |
808 | 808 | { |
809 | - if(!$file_srl) return; |
|
809 | + if (!$file_srl) return; |
|
810 | 810 | |
811 | 811 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
812 | - if(!count($srls)) return; |
|
812 | + if (!count($srls)) return; |
|
813 | 813 | |
814 | 814 | $oDocumentController = getController('document'); |
815 | 815 | $documentSrlList = array(); |
816 | 816 | |
817 | - foreach($srls as $srl) |
|
817 | + foreach ($srls as $srl) |
|
818 | 818 | { |
819 | - $srl = (int)$srl; |
|
820 | - if(!$srl) |
|
819 | + $srl = (int) $srl; |
|
820 | + if (!$srl) |
|
821 | 821 | { |
822 | 822 | continue; |
823 | 823 | } |
@@ -826,14 +826,14 @@ discard block |
||
826 | 826 | $args->file_srl = $srl; |
827 | 827 | $output = executeQuery('file.getFile', $args); |
828 | 828 | |
829 | - if(!$output->toBool() || !$output->data) |
|
829 | + if (!$output->toBool() || !$output->data) |
|
830 | 830 | { |
831 | 831 | continue; |
832 | 832 | } |
833 | 833 | |
834 | 834 | $file_info = $output->data; |
835 | 835 | |
836 | - if($file_info->upload_target_srl) |
|
836 | + if ($file_info->upload_target_srl) |
|
837 | 837 | { |
838 | 838 | $documentSrlList[] = $file_info->upload_target_srl; |
839 | 839 | } |
@@ -844,15 +844,15 @@ discard block |
||
844 | 844 | // Call a trigger (before) |
845 | 845 | $trigger_obj = $output->data; |
846 | 846 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
847 | - if(!$output->toBool()) return $output; |
|
847 | + if (!$output->toBool()) return $output; |
|
848 | 848 | |
849 | 849 | // Remove from the DB |
850 | 850 | $output = executeQuery('file.deleteFile', $args); |
851 | - if(!$output->toBool()) return $output; |
|
851 | + if (!$output->toBool()) return $output; |
|
852 | 852 | |
853 | 853 | // Call a trigger (after) |
854 | 854 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
855 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
855 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
856 | 856 | |
857 | 857 | // If successfully deleted, remove the file |
858 | 858 | FileHandler::removeFile($uploaded_filename); |
@@ -876,28 +876,28 @@ discard block |
||
876 | 876 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
877 | 877 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
878 | 878 | // Success returned if no attachement exists |
879 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
879 | + if (!is_array($file_list) || !count($file_list)) return new Object(); |
|
880 | 880 | |
881 | 881 | // Delete the file |
882 | 882 | $path = array(); |
883 | 883 | $file_count = count($file_list); |
884 | - for($i=0;$i<$file_count;$i++) |
|
884 | + for ($i = 0; $i < $file_count; $i++) |
|
885 | 885 | { |
886 | 886 | $this->deleteFile($file_list[$i]->file_srl); |
887 | 887 | |
888 | 888 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
889 | 889 | $path_info = pathinfo($uploaded_filename); |
890 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
890 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | // Remove from the DB |
894 | 894 | $args = new stdClass(); |
895 | 895 | $args->upload_target_srl = $upload_target_srl; |
896 | 896 | $output = executeQuery('file.deleteFiles', $args); |
897 | - if(!$output->toBool()) return $output; |
|
897 | + if (!$output->toBool()) return $output; |
|
898 | 898 | |
899 | 899 | // Remove a file directory of the document |
900 | - for($i=0, $c=count($path); $i<$c; $i++) |
|
900 | + for ($i = 0, $c = count($path); $i < $c; $i++) |
|
901 | 901 | { |
902 | 902 | FileHandler::removeBlankDir($path[$i]); |
903 | 903 | } |
@@ -915,23 +915,23 @@ discard block |
||
915 | 915 | */ |
916 | 916 | function moveFile($source_srl, $target_module_srl, $target_srl) |
917 | 917 | { |
918 | - if($source_srl == $target_srl) return; |
|
918 | + if ($source_srl == $target_srl) return; |
|
919 | 919 | |
920 | 920 | $oFileModel = getModel('file'); |
921 | 921 | $file_list = $oFileModel->getFiles($source_srl); |
922 | - if(!$file_list) return; |
|
922 | + if (!$file_list) return; |
|
923 | 923 | |
924 | 924 | $file_count = count($file_list); |
925 | 925 | |
926 | - for($i=0;$i<$file_count;$i++) |
|
926 | + for ($i = 0; $i < $file_count; $i++) |
|
927 | 927 | { |
928 | 928 | unset($file_info); |
929 | 929 | $file_info = $file_list[$i]; |
930 | 930 | $old_file = $file_info->uploaded_filename; |
931 | 931 | // Determine the file path by checking if the file is an image or other kinds |
932 | - if(preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename)) |
|
932 | + if (preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename)) |
|
933 | 933 | { |
934 | - $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
|
934 | + $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl); |
|
935 | 935 | $new_file = $path.$file_info->source_filename; |
936 | 936 | } |
937 | 937 | else |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
942 | 942 | } |
943 | 943 | // Pass if a target document to move is same |
944 | - if($old_file == $new_file) continue; |
|
944 | + if ($old_file == $new_file) continue; |
|
945 | 945 | // Create a directory |
946 | 946 | FileHandler::makeDir($path); |
947 | 947 | // Move the file |
@@ -961,18 +961,18 @@ discard block |
||
961 | 961 | $vars = Context::getRequestVars(); |
962 | 962 | $logged_info = Context::get('logged_info'); |
963 | 963 | |
964 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
964 | + if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
965 | 965 | |
966 | 966 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
967 | 967 | |
968 | 968 | $oFileModel = getModel('file'); |
969 | 969 | $file_info = $oFileModel->getFile($vars->file_srl); |
970 | 970 | |
971 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
971 | + if (!$file_info) return new Object(-1, 'msg_not_founded'); |
|
972 | 972 | |
973 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
973 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
974 | 974 | |
975 | - $args = new stdClass(); |
|
975 | + $args = new stdClass(); |
|
976 | 976 | $args->file_srl = $vars->file_srl; |
977 | 977 | $args->upload_target_srl = $upload_target_srl; |
978 | 978 | |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | |
982 | 982 | $args->cover_image = 'N'; |
983 | 983 | $output = executeQuery('file.updateClearCoverImage', $args); |
984 | - if(!$output->toBool()) |
|
984 | + if (!$output->toBool()) |
|
985 | 985 | { |
986 | 986 | $oDB->rollback(); |
987 | 987 | return $output; |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | |
990 | 990 | $args->cover_image = 'Y'; |
991 | 991 | $output = executeQuery('file.updateCoverImage', $args); |
992 | - if(!$output->toBool()) |
|
992 | + if (!$output->toBool()) |
|
993 | 993 | { |
994 | 994 | $oDB->rollback(); |
995 | 995 | return $output; |
@@ -1021,9 +1021,9 @@ discard block |
||
1021 | 1021 | $fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl); |
1022 | 1022 | |
1023 | 1023 | $oModuleController = getController('module'); |
1024 | - if(is_array($obj->moduleSrlList)) |
|
1024 | + if (is_array($obj->moduleSrlList)) |
|
1025 | 1025 | { |
1026 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1026 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1027 | 1027 | { |
1028 | 1028 | $oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig); |
1029 | 1029 | } |
@@ -29,24 +29,36 @@ discard block |
||
29 | 29 | $file_info = $_FILES['Filedata']; |
30 | 30 | |
31 | 31 | // An error appears if not a normally uploaded file |
32 | - if(!is_uploaded_file($file_info['tmp_name'])) exit(); |
|
32 | + if(!is_uploaded_file($file_info['tmp_name'])) { |
|
33 | + exit(); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | // Basic variables setting |
35 | 37 | $oFileModel = getModel('file'); |
36 | 38 | $editor_sequence = Context::get('editor_sequence'); |
37 | 39 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
38 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
40 | + if(!$upload_target_srl) { |
|
41 | + $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
42 | + } |
|
39 | 43 | $module_srl = $this->module_srl; |
40 | 44 | // Exit a session if there is neither upload permission nor information |
41 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
45 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
46 | + exit(); |
|
47 | + } |
|
42 | 48 | // Extract from session information if upload_target_srl is not specified |
43 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
49 | + if(!$upload_target_srl) { |
|
50 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
51 | + } |
|
44 | 52 | // Create if upload_target_srl is not defined in the session information |
45 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
53 | + if(!$upload_target_srl) { |
|
54 | + $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
55 | + } |
|
46 | 56 | |
47 | 57 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
48 | 58 | Context::setResponseMethod('JSON'); |
49 | - if($output->error != '0') $this->stop($output->message); |
|
59 | + if($output->error != '0') { |
|
60 | + $this->stop($output->message); |
|
61 | + } |
|
50 | 62 | } |
51 | 63 | |
52 | 64 | /** |
@@ -61,17 +73,27 @@ discard block |
||
61 | 73 | $callback = Context::get('callback'); |
62 | 74 | $module_srl = $this->module_srl; |
63 | 75 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
64 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
76 | + if(!$upload_target_srl) { |
|
77 | + $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
78 | + } |
|
65 | 79 | |
66 | 80 | // Exit a session if there is neither upload permission nor information |
67 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
81 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
82 | + exit(); |
|
83 | + } |
|
68 | 84 | // Extract from session information if upload_target_srl is not specified |
69 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
85 | + if(!$upload_target_srl) { |
|
86 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
87 | + } |
|
70 | 88 | // Create if upload_target_srl is not defined in the session information |
71 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
89 | + if(!$upload_target_srl) { |
|
90 | + $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
91 | + } |
|
72 | 92 | // Delete and then attempt to re-upload if file_srl is requested |
73 | 93 | $file_srl = Context::get('file_srl'); |
74 | - if($file_srl) $this->deleteFile($file_srl); |
|
94 | + if($file_srl) { |
|
95 | + $this->deleteFile($file_srl); |
|
96 | + } |
|
75 | 97 | |
76 | 98 | $file_info = Context::get('Filedata'); |
77 | 99 | // An error appears if not a normally uploaded file |
@@ -112,15 +134,16 @@ discard block |
||
112 | 134 | $source_src = $fileInfo->uploaded_filename; |
113 | 135 | $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
114 | 136 | |
115 | - if(!$height) $height = $width-1; |
|
137 | + if(!$height) { |
|
138 | + $height = $width-1; |
|
139 | + } |
|
116 | 140 | |
117 | 141 | if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
118 | 142 | { |
119 | 143 | $output = new stdClass(); |
120 | 144 | $output->info = getimagesize($output_src); |
121 | 145 | $output->src = $output_src; |
122 | - } |
|
123 | - else |
|
146 | + } else |
|
124 | 147 | { |
125 | 148 | return new Object(-1,'msg_invalid_request'); |
126 | 149 | } |
@@ -163,7 +186,9 @@ discard block |
||
163 | 186 | { |
164 | 187 | $oFileModel = getModel('file'); |
165 | 188 | |
166 | - if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
189 | + if(isset($this->grant->access) && $this->grant->access !== true) { |
|
190 | + return new Object(-1, 'msg_not_permitted'); |
|
191 | + } |
|
167 | 192 | |
168 | 193 | $file_srl = Context::get('file_srl'); |
169 | 194 | $sid = Context::get('sid'); |
@@ -172,9 +197,13 @@ discard block |
||
172 | 197 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
173 | 198 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
174 | 199 | // If the requested file information is incorrect, an error that file cannot be found appears |
175 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
200 | + if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) { |
|
201 | + return $this->stop('msg_file_not_found'); |
|
202 | + } |
|
176 | 203 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
177 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
204 | + if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') { |
|
205 | + return $this->stop('msg_not_permitted_download'); |
|
206 | + } |
|
178 | 207 | // File name |
179 | 208 | $filename = $file_obj->source_filename; |
180 | 209 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
@@ -186,7 +215,9 @@ discard block |
||
186 | 215 | { |
187 | 216 | $allow_outlink_format_array = array(); |
188 | 217 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
189 | - if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
218 | + if(!is_array($allow_outlink_format_array)) { |
|
219 | + $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
220 | + } |
|
190 | 221 | |
191 | 222 | foreach($allow_outlink_format_array as $val) |
192 | 223 | { |
@@ -208,7 +239,9 @@ discard block |
||
208 | 239 | { |
209 | 240 | $allow_outlink_site_array = array(); |
210 | 241 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
211 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
242 | + if(!is_array($allow_outlink_site_array)) { |
|
243 | + $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
244 | + } |
|
212 | 245 | |
213 | 246 | foreach($allow_outlink_site_array as $val) |
214 | 247 | { |
@@ -220,23 +253,29 @@ discard block |
||
220 | 253 | } |
221 | 254 | } |
222 | 255 | } |
256 | + } else { |
|
257 | + $file_module_config->allow_outlink = 'Y'; |
|
223 | 258 | } |
224 | - else $file_module_config->allow_outlink = 'Y'; |
|
225 | 259 | } |
226 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
260 | + if($file_module_config->allow_outlink != 'Y') { |
|
261 | + return $this->stop('msg_not_allowed_outlink'); |
|
262 | + } |
|
227 | 263 | } |
228 | 264 | |
229 | 265 | // Check if a permission for file download is granted |
230 | 266 | $downloadGrantCount = 0; |
231 | 267 | if(is_array($file_module_config->download_grant)) |
232 | 268 | { |
233 | - foreach($file_module_config->download_grant AS $value) |
|
234 | - if($value) $downloadGrantCount++; |
|
269 | + foreach($file_module_config->download_grant AS $value) { |
|
270 | + if($value) $downloadGrantCount++; |
|
271 | + } |
|
235 | 272 | } |
236 | 273 | |
237 | 274 | if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
238 | 275 | { |
239 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
276 | + if(!Context::get('is_logged')) { |
|
277 | + return $this->stop('msg_not_permitted_download'); |
|
278 | + } |
|
240 | 279 | $logged_info = Context::get('logged_info'); |
241 | 280 | if($logged_info->is_admin != 'Y') |
242 | 281 | { |
@@ -259,13 +298,17 @@ discard block |
||
259 | 298 | break; |
260 | 299 | } |
261 | 300 | } |
262 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
301 | + if(!$is_permitted) { |
|
302 | + return $this->stop('msg_not_permitted_download'); |
|
303 | + } |
|
263 | 304 | } |
264 | 305 | } |
265 | 306 | } |
266 | 307 | // Call a trigger (before) |
267 | 308 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
268 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
309 | + if(!$output->toBool()) { |
|
310 | + return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
311 | + } |
|
269 | 312 | |
270 | 313 | |
271 | 314 | // 다운로드 후 (가상) |
@@ -289,16 +332,23 @@ discard block |
||
289 | 332 | $oFileModel = getModel('file'); |
290 | 333 | $file_srl = Context::get('file_srl'); |
291 | 334 | $file_key = Context::get('file_key'); |
292 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
335 | + if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) { |
|
336 | + $is_android = true; |
|
337 | + } |
|
293 | 338 | |
294 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
295 | - else $session_key = '__XE_FILE_KEY__'; |
|
339 | + if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) { |
|
340 | + $session_key = '__XE_FILE_KEY_AND__'; |
|
341 | + } else { |
|
342 | + $session_key = '__XE_FILE_KEY__'; |
|
343 | + } |
|
296 | 344 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
297 | 345 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
298 | 346 | |
299 | 347 | $uploaded_filename = $file_obj->uploaded_filename; |
300 | 348 | |
301 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
349 | + if(!file_exists($uploaded_filename)) { |
|
350 | + return $this->stop('msg_file_not_found'); |
|
351 | + } |
|
302 | 352 | |
303 | 353 | if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
304 | 354 | { |
@@ -314,29 +364,27 @@ discard block |
||
314 | 364 | if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
315 | 365 | { |
316 | 366 | $filename_param = 'filename="' . $filename . '"'; |
317 | - } |
|
318 | - else |
|
367 | + } else |
|
319 | 368 | { |
320 | 369 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
321 | 370 | } |
322 | - } |
|
323 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
371 | + } elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
324 | 372 | { |
325 | 373 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
326 | - } |
|
327 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
374 | + } elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
328 | 375 | { |
329 | 376 | $filename = rawurlencode($filename); |
330 | 377 | $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
331 | - } |
|
332 | - else |
|
378 | + } else |
|
333 | 379 | { |
334 | 380 | $filename_param = 'filename="' . $filename . '"'; |
335 | 381 | } |
336 | 382 | |
337 | 383 | if($is_android) |
338 | 384 | { |
339 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
385 | + if($_SESSION['__XE_FILE_KEY__'][$file_srl]) { |
|
386 | + $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
387 | + } |
|
340 | 388 | } |
341 | 389 | |
342 | 390 | unset($_SESSION[$session_key][$file_srl]); |
@@ -344,7 +392,9 @@ discard block |
||
344 | 392 | Context::close(); |
345 | 393 | |
346 | 394 | $fp = fopen($uploaded_filename, 'rb'); |
347 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
395 | + if(!$fp) { |
|
396 | + return $this->stop('msg_file_not_found'); |
|
397 | + } |
|
348 | 398 | |
349 | 399 | header("Cache-Control: "); |
350 | 400 | header("Pragma: "); |
@@ -358,10 +408,11 @@ discard block |
||
358 | 408 | // if file size is lager than 10MB, use fread function (#18675748) |
359 | 409 | if(filesize($uploaded_filename) > 1024 * 1024) |
360 | 410 | { |
361 | - while(!feof($fp)) echo fread($fp, 1024); |
|
411 | + while(!feof($fp)) { |
|
412 | + echo fread($fp, 1024); |
|
413 | + } |
|
362 | 414 | fclose($fp); |
363 | - } |
|
364 | - else |
|
415 | + } else |
|
365 | 416 | { |
366 | 417 | fpassthru($fp); |
367 | 418 | } |
@@ -380,9 +431,13 @@ discard block |
||
380 | 431 | $editor_sequence = Context::get('editor_sequence'); |
381 | 432 | $file_srl = Context::get('file_srl'); |
382 | 433 | $file_srls = Context::get('file_srls'); |
383 | - if($file_srls) $file_srl = $file_srls; |
|
434 | + if($file_srls) { |
|
435 | + $file_srl = $file_srls; |
|
436 | + } |
|
384 | 437 | // Exit a session if there is neither upload permission nor information |
385 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
438 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
439 | + exit(); |
|
440 | + } |
|
386 | 441 | |
387 | 442 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
388 | 443 | |
@@ -390,26 +445,38 @@ discard block |
||
390 | 445 | $oFileModel = getModel('file'); |
391 | 446 | |
392 | 447 | $srls = explode(',',$file_srl); |
393 | - if(!count($srls)) return; |
|
448 | + if(!count($srls)) { |
|
449 | + return; |
|
450 | + } |
|
394 | 451 | |
395 | 452 | for($i=0;$i<count($srls);$i++) |
396 | 453 | { |
397 | 454 | $srl = (int)$srls[$i]; |
398 | - if(!$srl) continue; |
|
455 | + if(!$srl) { |
|
456 | + continue; |
|
457 | + } |
|
399 | 458 | |
400 | 459 | $args = new stdClass; |
401 | 460 | $args->file_srl = $srl; |
402 | 461 | $output = executeQuery('file.getFile', $args); |
403 | - if(!$output->toBool()) continue; |
|
462 | + if(!$output->toBool()) { |
|
463 | + continue; |
|
464 | + } |
|
404 | 465 | |
405 | 466 | $file_info = $output->data; |
406 | - if(!$file_info) continue; |
|
467 | + if(!$file_info) { |
|
468 | + continue; |
|
469 | + } |
|
407 | 470 | |
408 | 471 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
409 | 472 | |
410 | - if(!$file_grant->is_deletable) continue; |
|
473 | + if(!$file_grant->is_deletable) { |
|
474 | + continue; |
|
475 | + } |
|
411 | 476 | |
412 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
477 | + if($upload_target_srl && $file_srl) { |
|
478 | + $output = $this->deleteFile($file_srl); |
|
479 | + } |
|
413 | 480 | } |
414 | 481 | } |
415 | 482 | |
@@ -420,28 +487,36 @@ discard block |
||
420 | 487 | */ |
421 | 488 | function procFileGetList() |
422 | 489 | { |
423 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
490 | + if(!Context::get('is_logged')) { |
|
491 | + return new Object(-1,'msg_not_permitted'); |
|
492 | + } |
|
424 | 493 | $fileSrls = Context::get('file_srls'); |
425 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
494 | + if($fileSrls) { |
|
495 | + $fileSrlList = explode(',', $fileSrls); |
|
496 | + } |
|
426 | 497 | |
427 | 498 | global $lang; |
428 | 499 | if(count($fileSrlList) > 0) |
429 | 500 | { |
430 | 501 | $oFileModel = getModel('file'); |
431 | 502 | $fileList = $oFileModel->getFile($fileSrlList); |
432 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
503 | + if(!is_array($fileList)) { |
|
504 | + $fileList = array($fileList); |
|
505 | + } |
|
433 | 506 | |
434 | 507 | if(is_array($fileList)) |
435 | 508 | { |
436 | 509 | foreach($fileList AS $key=>$value) |
437 | 510 | { |
438 | 511 | $value->human_file_size = FileHandler::filesize($value->file_size); |
439 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
440 | - else $value->validName = $lang->is_stand_by; |
|
512 | + if($value->isvalid=='Y') { |
|
513 | + $value->validName = $lang->is_valid; |
|
514 | + } else { |
|
515 | + $value->validName = $lang->is_stand_by; |
|
516 | + } |
|
441 | 517 | } |
442 | 518 | } |
443 | - } |
|
444 | - else |
|
519 | + } else |
|
445 | 520 | { |
446 | 521 | $fileList = array(); |
447 | 522 | $this->setMessage($lang->no_files); |
@@ -458,7 +533,9 @@ discard block |
||
458 | 533 | function triggerCheckAttached(&$obj) |
459 | 534 | { |
460 | 535 | $document_srl = $obj->document_srl; |
461 | - if(!$document_srl) return new Object(); |
|
536 | + if(!$document_srl) { |
|
537 | + return new Object(); |
|
538 | + } |
|
462 | 539 | // Get numbers of attachments |
463 | 540 | $oFileModel = getModel('file'); |
464 | 541 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -475,10 +552,14 @@ discard block |
||
475 | 552 | function triggerAttachFiles(&$obj) |
476 | 553 | { |
477 | 554 | $document_srl = $obj->document_srl; |
478 | - if(!$document_srl) return new Object(); |
|
555 | + if(!$document_srl) { |
|
556 | + return new Object(); |
|
557 | + } |
|
479 | 558 | |
480 | 559 | $output = $this->setFilesValid($document_srl); |
481 | - if(!$output->toBool()) return $output; |
|
560 | + if(!$output->toBool()) { |
|
561 | + return $output; |
|
562 | + } |
|
482 | 563 | |
483 | 564 | return new Object(); |
484 | 565 | } |
@@ -492,7 +573,9 @@ discard block |
||
492 | 573 | function triggerDeleteAttached(&$obj) |
493 | 574 | { |
494 | 575 | $document_srl = $obj->document_srl; |
495 | - if(!$document_srl) return new Object(); |
|
576 | + if(!$document_srl) { |
|
577 | + return new Object(); |
|
578 | + } |
|
496 | 579 | |
497 | 580 | $output = $this->deleteFiles($document_srl); |
498 | 581 | return $output; |
@@ -507,7 +590,9 @@ discard block |
||
507 | 590 | function triggerCommentCheckAttached(&$obj) |
508 | 591 | { |
509 | 592 | $comment_srl = $obj->comment_srl; |
510 | - if(!$comment_srl) return new Object(); |
|
593 | + if(!$comment_srl) { |
|
594 | + return new Object(); |
|
595 | + } |
|
511 | 596 | // Get numbers of attachments |
512 | 597 | $oFileModel = getModel('file'); |
513 | 598 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -525,10 +610,14 @@ discard block |
||
525 | 610 | { |
526 | 611 | $comment_srl = $obj->comment_srl; |
527 | 612 | $uploaded_count = $obj->uploaded_count; |
528 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
613 | + if(!$comment_srl || !$uploaded_count) { |
|
614 | + return new Object(); |
|
615 | + } |
|
529 | 616 | |
530 | 617 | $output = $this->setFilesValid($comment_srl); |
531 | - if(!$output->toBool()) return $output; |
|
618 | + if(!$output->toBool()) { |
|
619 | + return $output; |
|
620 | + } |
|
532 | 621 | |
533 | 622 | return new Object(); |
534 | 623 | } |
@@ -542,9 +631,13 @@ discard block |
||
542 | 631 | function triggerCommentDeleteAttached(&$obj) |
543 | 632 | { |
544 | 633 | $comment_srl = $obj->comment_srl; |
545 | - if(!$comment_srl) return new Object(); |
|
634 | + if(!$comment_srl) { |
|
635 | + return new Object(); |
|
636 | + } |
|
546 | 637 | |
547 | - if($obj->isMoveToTrash) return new Object(); |
|
638 | + if($obj->isMoveToTrash) { |
|
639 | + return new Object(); |
|
640 | + } |
|
548 | 641 | |
549 | 642 | $output = $this->deleteFiles($comment_srl); |
550 | 643 | return $output; |
@@ -559,7 +652,9 @@ discard block |
||
559 | 652 | function triggerDeleteModuleFiles(&$obj) |
560 | 653 | { |
561 | 654 | $module_srl = $obj->module_srl; |
562 | - if(!$module_srl) return new Object(); |
|
655 | + if(!$module_srl) { |
|
656 | + return new Object(); |
|
657 | + } |
|
563 | 658 | |
564 | 659 | $oFileController = getAdminController('file'); |
565 | 660 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -634,7 +729,9 @@ discard block |
||
634 | 729 | $trigger_obj->module_srl = $module_srl; |
635 | 730 | $trigger_obj->upload_target_srl = $upload_target_srl; |
636 | 731 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
637 | - if(!$output->toBool()) return $output; |
|
732 | + if(!$output->toBool()) { |
|
733 | + return $output; |
|
734 | + } |
|
638 | 735 | |
639 | 736 | // A workaround for Firefox upload bug |
640 | 737 | if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
@@ -672,13 +769,17 @@ discard block |
||
672 | 769 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
673 | 770 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
674 | 771 | // An error appears if file size exceeds a limit |
675 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
772 | + if($allowed_filesize < filesize($file_info['tmp_name'])) { |
|
773 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
774 | + } |
|
676 | 775 | // Get total file size of all attachements (from DB) |
677 | 776 | $size_args = new stdClass; |
678 | 777 | $size_args->upload_target_srl = $upload_target_srl; |
679 | 778 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
680 | 779 | $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
681 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
780 | + if($attached_size > $allowed_attach_size) { |
|
781 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
782 | + } |
|
682 | 783 | } |
683 | 784 | } |
684 | 785 | |
@@ -708,18 +809,21 @@ discard block |
||
708 | 809 | $idx++; |
709 | 810 | } |
710 | 811 | $direct_download = 'Y'; |
711 | - } |
|
712 | - else |
|
812 | + } else |
|
713 | 813 | { |
714 | 814 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
715 | 815 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
716 | 816 | $direct_download = 'N'; |
717 | 817 | } |
718 | 818 | // Create a directory |
719 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
819 | + if(!FileHandler::makeDir($path)) { |
|
820 | + return new Object(-1,'msg_not_permitted_create'); |
|
821 | + } |
|
720 | 822 | |
721 | 823 | // Check uploaded file |
722 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
824 | + if(!checkUploadedFile($file_info['tmp_name'])) { |
|
825 | + return new Object(-1,'msg_file_upload_error'); |
|
826 | + } |
|
723 | 827 | |
724 | 828 | // Get random number generator |
725 | 829 | $random = new Password(); |
@@ -733,13 +837,14 @@ discard block |
||
733 | 837 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
734 | 838 | @copy($file_info['tmp_name'], $filename); |
735 | 839 | } |
736 | - } |
|
737 | - else |
|
840 | + } else |
|
738 | 841 | { |
739 | 842 | if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
740 | 843 | { |
741 | 844 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
742 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
845 | + if(!@move_uploaded_file($file_info['tmp_name'], $filename)) { |
|
846 | + return new Object(-1,'msg_file_upload_error'); |
|
847 | + } |
|
743 | 848 | } |
744 | 849 | } |
745 | 850 | // Get member information |
@@ -760,10 +865,14 @@ discard block |
||
760 | 865 | $args->sid = $random->createSecureSalt(32, 'hex'); |
761 | 866 | |
762 | 867 | $output = executeQuery('file.insertFile', $args); |
763 | - if(!$output->toBool()) return $output; |
|
868 | + if(!$output->toBool()) { |
|
869 | + return $output; |
|
870 | + } |
|
764 | 871 | // Call a trigger (after) |
765 | 872 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
766 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
873 | + if(!$trigger_output->toBool()) { |
|
874 | + return $trigger_output; |
|
875 | + } |
|
767 | 876 | |
768 | 877 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
769 | 878 | |
@@ -806,10 +915,14 @@ discard block |
||
806 | 915 | */ |
807 | 916 | function deleteFile($file_srl) |
808 | 917 | { |
809 | - if(!$file_srl) return; |
|
918 | + if(!$file_srl) { |
|
919 | + return; |
|
920 | + } |
|
810 | 921 | |
811 | 922 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
812 | - if(!count($srls)) return; |
|
923 | + if(!count($srls)) { |
|
924 | + return; |
|
925 | + } |
|
813 | 926 | |
814 | 927 | $oDocumentController = getController('document'); |
815 | 928 | $documentSrlList = array(); |
@@ -844,15 +957,21 @@ discard block |
||
844 | 957 | // Call a trigger (before) |
845 | 958 | $trigger_obj = $output->data; |
846 | 959 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
847 | - if(!$output->toBool()) return $output; |
|
960 | + if(!$output->toBool()) { |
|
961 | + return $output; |
|
962 | + } |
|
848 | 963 | |
849 | 964 | // Remove from the DB |
850 | 965 | $output = executeQuery('file.deleteFile', $args); |
851 | - if(!$output->toBool()) return $output; |
|
966 | + if(!$output->toBool()) { |
|
967 | + return $output; |
|
968 | + } |
|
852 | 969 | |
853 | 970 | // Call a trigger (after) |
854 | 971 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
855 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
972 | + if(!$trigger_output->toBool()) { |
|
973 | + return $trigger_output; |
|
974 | + } |
|
856 | 975 | |
857 | 976 | // If successfully deleted, remove the file |
858 | 977 | FileHandler::removeFile($uploaded_filename); |
@@ -876,7 +995,9 @@ discard block |
||
876 | 995 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
877 | 996 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
878 | 997 | // Success returned if no attachement exists |
879 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
998 | + if(!is_array($file_list)||!count($file_list)) { |
|
999 | + return new Object(); |
|
1000 | + } |
|
880 | 1001 | |
881 | 1002 | // Delete the file |
882 | 1003 | $path = array(); |
@@ -887,14 +1008,18 @@ discard block |
||
887 | 1008 | |
888 | 1009 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
889 | 1010 | $path_info = pathinfo($uploaded_filename); |
890 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
1011 | + if(!in_array($path_info['dirname'], $path)) { |
|
1012 | + $path[] = $path_info['dirname']; |
|
1013 | + } |
|
891 | 1014 | } |
892 | 1015 | |
893 | 1016 | // Remove from the DB |
894 | 1017 | $args = new stdClass(); |
895 | 1018 | $args->upload_target_srl = $upload_target_srl; |
896 | 1019 | $output = executeQuery('file.deleteFiles', $args); |
897 | - if(!$output->toBool()) return $output; |
|
1020 | + if(!$output->toBool()) { |
|
1021 | + return $output; |
|
1022 | + } |
|
898 | 1023 | |
899 | 1024 | // Remove a file directory of the document |
900 | 1025 | for($i=0, $c=count($path); $i<$c; $i++) |
@@ -915,11 +1040,15 @@ discard block |
||
915 | 1040 | */ |
916 | 1041 | function moveFile($source_srl, $target_module_srl, $target_srl) |
917 | 1042 | { |
918 | - if($source_srl == $target_srl) return; |
|
1043 | + if($source_srl == $target_srl) { |
|
1044 | + return; |
|
1045 | + } |
|
919 | 1046 | |
920 | 1047 | $oFileModel = getModel('file'); |
921 | 1048 | $file_list = $oFileModel->getFiles($source_srl); |
922 | - if(!$file_list) return; |
|
1049 | + if(!$file_list) { |
|
1050 | + return; |
|
1051 | + } |
|
923 | 1052 | |
924 | 1053 | $file_count = count($file_list); |
925 | 1054 | |
@@ -933,15 +1062,16 @@ discard block |
||
933 | 1062 | { |
934 | 1063 | $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
935 | 1064 | $new_file = $path.$file_info->source_filename; |
936 | - } |
|
937 | - else |
|
1065 | + } else |
|
938 | 1066 | { |
939 | 1067 | $path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl); |
940 | 1068 | $random = new Password(); |
941 | 1069 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
942 | 1070 | } |
943 | 1071 | // Pass if a target document to move is same |
944 | - if($old_file == $new_file) continue; |
|
1072 | + if($old_file == $new_file) { |
|
1073 | + continue; |
|
1074 | + } |
|
945 | 1075 | // Create a directory |
946 | 1076 | FileHandler::makeDir($path); |
947 | 1077 | // Move the file |
@@ -961,16 +1091,22 @@ discard block |
||
961 | 1091 | $vars = Context::getRequestVars(); |
962 | 1092 | $logged_info = Context::get('logged_info'); |
963 | 1093 | |
964 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
1094 | + if(!$vars->editor_sequence) { |
|
1095 | + return new Object(-1, 'msg_invalid_request'); |
|
1096 | + } |
|
965 | 1097 | |
966 | 1098 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
967 | 1099 | |
968 | 1100 | $oFileModel = getModel('file'); |
969 | 1101 | $file_info = $oFileModel->getFile($vars->file_srl); |
970 | 1102 | |
971 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
1103 | + if(!$file_info) { |
|
1104 | + return new Object(-1, 'msg_not_founded'); |
|
1105 | + } |
|
972 | 1106 | |
973 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
1107 | + if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) { |
|
1108 | + return new Object(-1, 'msg_not_permitted'); |
|
1109 | + } |
|
974 | 1110 | |
975 | 1111 | $args = new stdClass(); |
976 | 1112 | $args->file_srl = $vars->file_srl; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * Get file configurations |
114 | 114 | * |
115 | 115 | * @param int $module_srl If set this, returns specific module's configuration. Otherwise returns global configuration. |
116 | - * @return object Returns configuration. |
|
116 | + * @return stdClass Returns configuration. |
|
117 | 117 | */ |
118 | 118 | function getFileConfig($module_srl = null) |
119 | 119 | { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * Return configurations of the attachement (it automatically checks if an administrator is) |
233 | 233 | * |
234 | - * @return object Returns a file configuration of current module. If user is admin, returns PHP's max file size and allow all file types. |
|
234 | + * @return stdClass Returns a file configuration of current module. If user is admin, returns PHP's max file size and allow all file types. |
|
235 | 235 | */ |
236 | 236 | function getUploadConfig() |
237 | 237 | { |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * Return file configuration of the module |
286 | 286 | * |
287 | 287 | * @param int $module_srl The sequence of module to get configuration |
288 | - * @return object |
|
288 | + * @return stdClass |
|
289 | 289 | */ |
290 | 290 | function getFileModuleConfig($module_srl) |
291 | 291 | { |
@@ -29,24 +29,24 @@ discard block |
||
29 | 29 | $mid = Context::get('mid'); |
30 | 30 | $editor_sequence = Context::get('editor_sequence'); |
31 | 31 | $upload_target_srl = Context::get('upload_target_srl'); |
32 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
32 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
33 | 33 | |
34 | - if($upload_target_srl) |
|
34 | + if ($upload_target_srl) |
|
35 | 35 | { |
36 | 36 | $tmp_files = $this->getFiles($upload_target_srl); |
37 | 37 | $file_count = count($tmp_files); |
38 | 38 | |
39 | - for($i=0;$i<$file_count;$i++) |
|
39 | + for ($i = 0; $i < $file_count; $i++) |
|
40 | 40 | { |
41 | 41 | $file_info = $tmp_files[$i]; |
42 | - if(!$file_info->file_srl) continue; |
|
42 | + if (!$file_info->file_srl) continue; |
|
43 | 43 | |
44 | 44 | $obj = new stdClass; |
45 | 45 | $obj->file_srl = $file_info->file_srl; |
46 | 46 | $obj->source_filename = $file_info->source_filename; |
47 | 47 | $obj->file_size = $file_info->file_size; |
48 | 48 | $obj->disp_file_size = FileHandler::filesize($file_info->file_size); |
49 | - if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
49 | + if ($file_info->direct_download == 'N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
50 | 50 | else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
51 | 51 | $obj->direct_download = $file_info->direct_download; |
52 | 52 | $obj->cover_image = ($file_info->cover_image === 'Y') ? true : false; |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | //$config = $oModuleModel->getModuleInfoByMid($mid); //perhaps config varialbles not used |
67 | 67 | |
68 | 68 | $file_config = $this->getUploadConfig(); |
69 | - $left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size; |
|
69 | + $left_size = $file_config->allowed_attach_size * 1024 * 1024 - $attached_size; |
|
70 | 70 | // Settings of required information |
71 | 71 | $attached_size = FileHandler::filesize($attached_size); |
72 | - $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size*1024*1024); |
|
73 | - $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize*1024*1024); |
|
72 | + $allowed_attach_size = FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024); |
|
73 | + $allowed_filesize = FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024); |
|
74 | 74 | $allowed_filetypes = $file_config->allowed_filetypes; |
75 | - $this->add("files",$files); |
|
76 | - $this->add("editor_sequence",$editor_sequence); |
|
77 | - $this->add("upload_target_srl",$upload_target_srl); |
|
78 | - $this->add("upload_status",$upload_status); |
|
79 | - $this->add("left_size",$left_size); |
|
75 | + $this->add("files", $files); |
|
76 | + $this->add("editor_sequence", $editor_sequence); |
|
77 | + $this->add("upload_target_srl", $upload_target_srl); |
|
78 | + $this->add("upload_status", $upload_status); |
|
79 | + $this->add("left_size", $left_size); |
|
80 | 80 | $this->add('attached_size', $attached_size); |
81 | 81 | $this->add('allowed_attach_size', $allowed_attach_size); |
82 | 82 | $this->add('allowed_filesize', $allowed_filesize); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $args = new stdClass(); |
95 | 95 | $args->upload_target_srl = $upload_target_srl; |
96 | 96 | $output = executeQuery('file.getFilesCount', $args); |
97 | - return (int)$output->data->count; |
|
97 | + return (int) $output->data->count; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param string $sid |
105 | 105 | * @return string Returns a url |
106 | 106 | */ |
107 | - function getDownloadUrl($file_srl, $sid, $module_srl="") |
|
107 | + function getDownloadUrl($file_srl, $sid, $module_srl = "") |
|
108 | 108 | { |
109 | 109 | return sprintf('?module=%s&act=%s&file_srl=%s&sid=%s&module_srl=%s', 'file', 'procFileDownload', $file_srl, $sid, $module_srl); |
110 | 110 | } |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | |
123 | 123 | $file_module_config = $oModuleModel->getModuleConfig('file'); |
124 | 124 | |
125 | - if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
126 | - if(!$file_config) $file_config = $file_module_config; |
|
125 | + if ($module_srl) $file_config = $oModuleModel->getModulePartConfig('file', $module_srl); |
|
126 | + if (!$file_config) $file_config = $file_module_config; |
|
127 | 127 | |
128 | 128 | $config = new stdClass(); |
129 | 129 | |
130 | - if($file_config) |
|
130 | + if ($file_config) |
|
131 | 131 | { |
132 | 132 | $config->allowed_filesize = $file_config->allowed_filesize; |
133 | 133 | $config->allowed_attach_size = $file_config->allowed_attach_size; |
@@ -138,31 +138,31 @@ discard block |
||
138 | 138 | $config->allow_outlink_format = $file_config->allow_outlink_format; |
139 | 139 | } |
140 | 140 | // Property for all files comes first than each property |
141 | - if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
142 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
143 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
144 | - if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
145 | - if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
146 | - if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
147 | - if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
141 | + if (!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
142 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
143 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
144 | + if (!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
145 | + if (!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
146 | + if (!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
147 | + if (!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
148 | 148 | // Default setting if not exists |
149 | - if(!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
150 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
151 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
152 | - if(!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
153 | - if(!$config->download_grant) $config->download_grant = array(); |
|
149 | + if (!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
150 | + if (!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
151 | + if (!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
152 | + if (!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
153 | + if (!$config->download_grant) $config->download_grant = array(); |
|
154 | 154 | |
155 | 155 | $size = ini_get('upload_max_filesize'); |
156 | 156 | $unit = strtolower($size[strlen($size) - 1]); |
157 | - $size = (float)$size; |
|
158 | - if($unit == 'g') $size *= 1024; |
|
159 | - if($unit == 'k') $size /= 1024; |
|
157 | + $size = (float) $size; |
|
158 | + if ($unit == 'g') $size *= 1024; |
|
159 | + if ($unit == 'k') $size /= 1024; |
|
160 | 160 | |
161 | - if($config->allowed_filesize > $size) |
|
161 | + if ($config->allowed_filesize > $size) |
|
162 | 162 | { |
163 | 163 | $config->allowed_filesize = $size; |
164 | 164 | } |
165 | - if($config->allowed_attach_size > $size) |
|
165 | + if ($config->allowed_attach_size > $size) |
|
166 | 166 | { |
167 | 167 | $config->allowed_attach_size = $size; |
168 | 168 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | $args = new stdClass(); |
183 | 183 | $args->file_srl = $file_srl; |
184 | 184 | $output = executeQueryArray('file.getFile', $args, $columnList); |
185 | - if(!$output->toBool()) return $output; |
|
185 | + if (!$output->toBool()) return $output; |
|
186 | 186 | |
187 | 187 | // old version compatibility |
188 | - if(count($output->data) == 1) |
|
188 | + if (count($output->data) == 1) |
|
189 | 189 | { |
190 | 190 | $file = $output->data[0]; |
191 | 191 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | { |
197 | 197 | $fileList = array(); |
198 | 198 | |
199 | - if(is_array($output->data)) |
|
199 | + if (is_array($output->data)) |
|
200 | 200 | { |
201 | - foreach($output->data as $key=>$value) |
|
201 | + foreach ($output->data as $key=>$value) |
|
202 | 202 | { |
203 | 203 | $file = $value; |
204 | 204 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | $args = new stdClass(); |
223 | 223 | $args->upload_target_srl = $upload_target_srl; |
224 | 224 | $args->sort_index = $sortIndex; |
225 | - if($ckValid) $args->isvalid = 'Y'; |
|
225 | + if ($ckValid) $args->isvalid = 'Y'; |
|
226 | 226 | $output = executeQuery('file.getFiles', $args, $columnList); |
227 | - if(!$output->data) return; |
|
227 | + if (!$output->data) return; |
|
228 | 228 | |
229 | 229 | $file_list = $output->data; |
230 | 230 | |
231 | - if($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
231 | + if ($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
232 | 232 | |
233 | 233 | $file_count = count($file_list); |
234 | - for($i=0;$i<$file_count;$i++) |
|
234 | + for ($i = 0; $i < $file_count; $i++) |
|
235 | 235 | { |
236 | 236 | $file = $file_list[$i]; |
237 | 237 | $file->source_filename = stripslashes($file->source_filename); |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | |
255 | 255 | $module_srl = Context::get('module_srl'); |
256 | 256 | // Get the current module if module_srl doesn't exist |
257 | - if(!$module_srl) |
|
257 | + if (!$module_srl) |
|
258 | 258 | { |
259 | 259 | $current_module_info = Context::get('current_module_info'); |
260 | 260 | $module_srl = $current_module_info->module_srl; |
261 | 261 | } |
262 | 262 | $file_config = $this->getFileConfig($module_srl); |
263 | 263 | |
264 | - if($logged_info->is_admin == 'Y') |
|
264 | + if ($logged_info->is_admin == 'Y') |
|
265 | 265 | { |
266 | 266 | $iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size')); |
267 | 267 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | '%s : %s/ %s<br /> %s : %s (%s : %s)', |
288 | 288 | Context::getLang('allowed_attach_size'), |
289 | 289 | FileHandler::filesize($attached_size), |
290 | - FileHandler::filesize($file_config->allowed_attach_size*1024*1024), |
|
290 | + FileHandler::filesize($file_config->allowed_attach_size * 1024 * 1024), |
|
291 | 291 | Context::getLang('allowed_filesize'), |
292 | - FileHandler::filesize($file_config->allowed_filesize*1024*1024), |
|
292 | + FileHandler::filesize($file_config->allowed_filesize * 1024 * 1024), |
|
293 | 293 | Context::getLang('allowed_filetypes'), |
294 | 294 | $file_config->allowed_filetypes |
295 | 295 | ); |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | */ |
317 | 317 | function getFileGrant($file_info, $member_info) |
318 | 318 | { |
319 | - if(!$file_info) return null; |
|
319 | + if (!$file_info) return null; |
|
320 | 320 | |
321 | - if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
321 | + if ($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
|
322 | 322 | { |
323 | 323 | $file_grant->is_deletable = true; |
324 | 324 | return $file_grant; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $oDocumentModel = getModel('document'); |
331 | 331 | $oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl); |
332 | - if($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
332 | + if ($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
333 | 333 | |
334 | 334 | $file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager); |
335 | 335 |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | $mid = Context::get('mid'); |
30 | 30 | $editor_sequence = Context::get('editor_sequence'); |
31 | 31 | $upload_target_srl = Context::get('upload_target_srl'); |
32 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
32 | + if(!$upload_target_srl) { |
|
33 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | if($upload_target_srl) |
35 | 37 | { |
@@ -39,22 +41,26 @@ discard block |
||
39 | 41 | for($i=0;$i<$file_count;$i++) |
40 | 42 | { |
41 | 43 | $file_info = $tmp_files[$i]; |
42 | - if(!$file_info->file_srl) continue; |
|
44 | + if(!$file_info->file_srl) { |
|
45 | + continue; |
|
46 | + } |
|
43 | 47 | |
44 | 48 | $obj = new stdClass; |
45 | 49 | $obj->file_srl = $file_info->file_srl; |
46 | 50 | $obj->source_filename = $file_info->source_filename; |
47 | 51 | $obj->file_size = $file_info->file_size; |
48 | 52 | $obj->disp_file_size = FileHandler::filesize($file_info->file_size); |
49 | - if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
50 | - else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
|
53 | + if($file_info->direct_download=='N') { |
|
54 | + $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl); |
|
55 | + } else { |
|
56 | + $obj->download_url = str_replace('./', '', $file_info->uploaded_filename); |
|
57 | + } |
|
51 | 58 | $obj->direct_download = $file_info->direct_download; |
52 | 59 | $obj->cover_image = ($file_info->cover_image === 'Y') ? true : false; |
53 | 60 | $files[] = $obj; |
54 | 61 | $attached_size += $file_info->file_size; |
55 | 62 | } |
56 | - } |
|
57 | - else |
|
63 | + } else |
|
58 | 64 | { |
59 | 65 | $upload_target_srl = 0; |
60 | 66 | $attached_size = 0; |
@@ -122,8 +128,12 @@ discard block |
||
122 | 128 | |
123 | 129 | $file_module_config = $oModuleModel->getModuleConfig('file'); |
124 | 130 | |
125 | - if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
126 | - if(!$file_config) $file_config = $file_module_config; |
|
131 | + if($module_srl) { |
|
132 | + $file_config = $oModuleModel->getModulePartConfig('file',$module_srl); |
|
133 | + } |
|
134 | + if(!$file_config) { |
|
135 | + $file_config = $file_module_config; |
|
136 | + } |
|
127 | 137 | |
128 | 138 | $config = new stdClass(); |
129 | 139 | |
@@ -138,25 +148,53 @@ discard block |
||
138 | 148 | $config->allow_outlink_format = $file_config->allow_outlink_format; |
139 | 149 | } |
140 | 150 | // Property for all files comes first than each property |
141 | - if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
142 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
143 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
144 | - if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink; |
|
145 | - if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
146 | - if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
147 | - if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant; |
|
151 | + if(!$config->allowed_filesize) { |
|
152 | + $config->allowed_filesize = $file_module_config->allowed_filesize; |
|
153 | + } |
|
154 | + if(!$config->allowed_attach_size) { |
|
155 | + $config->allowed_attach_size = $file_module_config->allowed_attach_size; |
|
156 | + } |
|
157 | + if(!$config->allowed_filetypes) { |
|
158 | + $config->allowed_filetypes = $file_module_config->allowed_filetypes; |
|
159 | + } |
|
160 | + if(!$config->allow_outlink) { |
|
161 | + $config->allow_outlink = $file_module_config->allow_outlink; |
|
162 | + } |
|
163 | + if(!$config->allow_outlink_site) { |
|
164 | + $config->allow_outlink_site = $file_module_config->allow_outlink_site; |
|
165 | + } |
|
166 | + if(!$config->allow_outlink_format) { |
|
167 | + $config->allow_outlink_format = $file_module_config->allow_outlink_format; |
|
168 | + } |
|
169 | + if(!$config->download_grant) { |
|
170 | + $config->download_grant = $file_module_config->download_grant; |
|
171 | + } |
|
148 | 172 | // Default setting if not exists |
149 | - if(!$config->allowed_filesize) $config->allowed_filesize = '2'; |
|
150 | - if(!$config->allowed_attach_size) $config->allowed_attach_size = '3'; |
|
151 | - if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*'; |
|
152 | - if(!$config->allow_outlink) $config->allow_outlink = 'Y'; |
|
153 | - if(!$config->download_grant) $config->download_grant = array(); |
|
173 | + if(!$config->allowed_filesize) { |
|
174 | + $config->allowed_filesize = '2'; |
|
175 | + } |
|
176 | + if(!$config->allowed_attach_size) { |
|
177 | + $config->allowed_attach_size = '3'; |
|
178 | + } |
|
179 | + if(!$config->allowed_filetypes) { |
|
180 | + $config->allowed_filetypes = '*.*'; |
|
181 | + } |
|
182 | + if(!$config->allow_outlink) { |
|
183 | + $config->allow_outlink = 'Y'; |
|
184 | + } |
|
185 | + if(!$config->download_grant) { |
|
186 | + $config->download_grant = array(); |
|
187 | + } |
|
154 | 188 | |
155 | 189 | $size = ini_get('upload_max_filesize'); |
156 | 190 | $unit = strtolower($size[strlen($size) - 1]); |
157 | 191 | $size = (float)$size; |
158 | - if($unit == 'g') $size *= 1024; |
|
159 | - if($unit == 'k') $size /= 1024; |
|
192 | + if($unit == 'g') { |
|
193 | + $size *= 1024; |
|
194 | + } |
|
195 | + if($unit == 'k') { |
|
196 | + $size /= 1024; |
|
197 | + } |
|
160 | 198 | |
161 | 199 | if($config->allowed_filesize > $size) |
162 | 200 | { |
@@ -182,7 +220,9 @@ discard block |
||
182 | 220 | $args = new stdClass(); |
183 | 221 | $args->file_srl = $file_srl; |
184 | 222 | $output = executeQueryArray('file.getFile', $args, $columnList); |
185 | - if(!$output->toBool()) return $output; |
|
223 | + if(!$output->toBool()) { |
|
224 | + return $output; |
|
225 | + } |
|
186 | 226 | |
187 | 227 | // old version compatibility |
188 | 228 | if(count($output->data) == 1) |
@@ -191,8 +231,7 @@ discard block |
||
191 | 231 | $file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
192 | 232 | |
193 | 233 | return $file; |
194 | - } |
|
195 | - else |
|
234 | + } else |
|
196 | 235 | { |
197 | 236 | $fileList = array(); |
198 | 237 | |
@@ -222,13 +261,19 @@ discard block |
||
222 | 261 | $args = new stdClass(); |
223 | 262 | $args->upload_target_srl = $upload_target_srl; |
224 | 263 | $args->sort_index = $sortIndex; |
225 | - if($ckValid) $args->isvalid = 'Y'; |
|
264 | + if($ckValid) { |
|
265 | + $args->isvalid = 'Y'; |
|
266 | + } |
|
226 | 267 | $output = executeQuery('file.getFiles', $args, $columnList); |
227 | - if(!$output->data) return; |
|
268 | + if(!$output->data) { |
|
269 | + return; |
|
270 | + } |
|
228 | 271 | |
229 | 272 | $file_list = $output->data; |
230 | 273 | |
231 | - if($file_list && !is_array($file_list)) $file_list = array($file_list); |
|
274 | + if($file_list && !is_array($file_list)) { |
|
275 | + $file_list = array($file_list); |
|
276 | + } |
|
232 | 277 | |
233 | 278 | $file_count = count($file_list); |
234 | 279 | for($i=0;$i<$file_count;$i++) |
@@ -316,7 +361,9 @@ discard block |
||
316 | 361 | */ |
317 | 362 | function getFileGrant($file_info, $member_info) |
318 | 363 | { |
319 | - if(!$file_info) return null; |
|
364 | + if(!$file_info) { |
|
365 | + return null; |
|
366 | + } |
|
320 | 367 | |
321 | 368 | if($_SESSION['__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl]) |
322 | 369 | { |
@@ -329,7 +376,9 @@ discard block |
||
329 | 376 | |
330 | 377 | $oDocumentModel = getModel('document'); |
331 | 378 | $oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl); |
332 | - if($oDocument->isExists()) $document_grant = $oDocument->isGranted(); |
|
379 | + if($oDocument->isExists()) { |
|
380 | + $document_grant = $oDocument->isGranted(); |
|
381 | + } |
|
333 | 382 | |
334 | 383 | $file_grant->is_deletable = ($document_grant || $member_info->is_admin == 'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager); |
335 | 384 |
@@ -216,6 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Merge item |
219 | + * @param string $filename |
|
219 | 220 | * @return void |
220 | 221 | */ |
221 | 222 | function mergeItems($filename) |
@@ -310,6 +311,11 @@ discard block |
||
310 | 311 | return $this->key; |
311 | 312 | } |
312 | 313 | |
314 | + /** |
|
315 | + * @param string $str |
|
316 | + * |
|
317 | + * @return string |
|
318 | + */ |
|
313 | 319 | function _addTagCRTail($str) { |
314 | 320 | $str = preg_replace('/<\/([^>]*)></i', "</$1>\r\n<", $str); |
315 | 321 | return $str; |
@@ -99,7 +99,9 @@ discard block |
||
99 | 99 | $this->filename = $filename; |
100 | 100 | |
101 | 101 | $this->startTag = $startTag; |
102 | - if($endTag) $this->endTag = $endTag; |
|
102 | + if($endTag) { |
|
103 | + $this->endTag = $endTag; |
|
104 | + } |
|
103 | 105 | $this->itemStartTag = $itemTag; |
104 | 106 | $this->itemEndTag = $itemEndTag; |
105 | 107 | |
@@ -108,7 +110,9 @@ discard block |
||
108 | 110 | $this->cache_path = './files/cache/importer/'.$this->key; |
109 | 111 | $this->cache_index_file = $this->cache_path.'/index'; |
110 | 112 | |
111 | - if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
113 | + if(!is_dir($this->cache_path)) { |
|
114 | + FileHandler::makeDir($this->cache_path); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | return $this->openFile(); |
114 | 118 | } |
@@ -124,18 +128,25 @@ discard block |
||
124 | 128 | // If local file |
125 | 129 | if(strncasecmp('http://', $this->filename, 7) !== 0) |
126 | 130 | { |
127 | - if(!file_exists($this->filename)) return new Object(-1,'msg_no_xml_file'); |
|
131 | + if(!file_exists($this->filename)) { |
|
132 | + return new Object(-1,'msg_no_xml_file'); |
|
133 | + } |
|
128 | 134 | $this->fd = fopen($this->filename,"r"); |
129 | 135 | // If remote file |
130 | - } |
|
131 | - else |
|
136 | + } else |
|
132 | 137 | { |
133 | 138 | $url_info = parse_url($this->filename); |
134 | - if(!$url_info['port']) $url_info['port'] = 80; |
|
135 | - if(!$url_info['path']) $url_info['path'] = '/'; |
|
139 | + if(!$url_info['port']) { |
|
140 | + $url_info['port'] = 80; |
|
141 | + } |
|
142 | + if(!$url_info['path']) { |
|
143 | + $url_info['path'] = '/'; |
|
144 | + } |
|
136 | 145 | |
137 | 146 | $this->fd = @fsockopen($url_info['host'], $url_info['port']); |
138 | - if(!$this->fd) return new Object(-1,'msg_no_xml_file'); |
|
147 | + if(!$this->fd) { |
|
148 | + return new Object(-1,'msg_no_xml_file'); |
|
149 | + } |
|
139 | 150 | // If the file name contains Korean, do urlencode(iconv required) |
140 | 151 | $path = $url_info['path']; |
141 | 152 | if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) |
@@ -155,9 +166,13 @@ discard block |
||
155 | 166 | while(!feof($this->fd)) |
156 | 167 | { |
157 | 168 | $buff .= $str = fgets($this->fd, 1024); |
158 | - if(!trim($str)) break; |
|
169 | + if(!trim($str)) { |
|
170 | + break; |
|
171 | + } |
|
172 | + } |
|
173 | + if(preg_match('/404 Not Found/i',$buff)) { |
|
174 | + return new Object(-1,'msg_no_xml_file'); |
|
159 | 175 | } |
160 | - if(preg_match('/404 Not Found/i',$buff)) return new Object(-1,'msg_no_xml_file'); |
|
161 | 176 | } |
162 | 177 | |
163 | 178 | if($this->startTag) |
@@ -174,8 +189,7 @@ discard block |
||
174 | 189 | break; |
175 | 190 | } |
176 | 191 | } |
177 | - } |
|
178 | - else |
|
192 | + } else |
|
179 | 193 | { |
180 | 194 | $this->isStarted = true; |
181 | 195 | $this->isFinished = false; |
@@ -231,7 +245,9 @@ discard block |
||
231 | 245 | while(!feof($index_fd)) |
232 | 246 | { |
233 | 247 | $target_file = trim(fgets($index_fd,1024)); |
234 | - if(!file_exists($target_file)) continue; |
|
248 | + if(!file_exists($target_file)) { |
|
249 | + continue; |
|
250 | + } |
|
235 | 251 | $buff = FileHandler::readFile($target_file); |
236 | 252 | fwrite($fd, FileHandler::readFile($target_file)); |
237 | 253 | |
@@ -247,7 +263,9 @@ discard block |
||
247 | 263 | */ |
248 | 264 | function getItem() |
249 | 265 | { |
250 | - if($this->isFinished()) return; |
|
266 | + if($this->isFinished()) { |
|
267 | + return; |
|
268 | + } |
|
251 | 269 | |
252 | 270 | while(!feof($this->fd)) |
253 | 271 | { |
@@ -257,8 +275,7 @@ discard block |
||
257 | 275 | $this->buff = substr($this->buff, $startPos); |
258 | 276 | $this->buff = preg_replace("/\>/",">\r\n",$this->buff,1); |
259 | 277 | break; |
260 | - } |
|
261 | - elseif($this->endTag) |
|
278 | + } elseif($this->endTag) |
|
262 | 279 | { |
263 | 280 | $endPos = strpos($this->buff, $this->endTag); |
264 | 281 | if($endPos !== false) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->filename = $filename; |
100 | 100 | |
101 | 101 | $this->startTag = $startTag; |
102 | - if($endTag) $this->endTag = $endTag; |
|
102 | + if ($endTag) $this->endTag = $endTag; |
|
103 | 103 | $this->itemStartTag = $itemTag; |
104 | 104 | $this->itemEndTag = $itemEndTag; |
105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->cache_path = './files/cache/importer/'.$this->key; |
109 | 109 | $this->cache_index_file = $this->cache_path.'/index'; |
110 | 110 | |
111 | - if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
111 | + if (!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
112 | 112 | |
113 | 113 | return $this->openFile(); |
114 | 114 | } |
@@ -120,55 +120,55 @@ discard block |
||
120 | 120 | function openFile() |
121 | 121 | { |
122 | 122 | FileHandler::removeFile($this->cache_index_file); |
123 | - $this->index_fd = fopen($this->cache_index_file,"a"); |
|
123 | + $this->index_fd = fopen($this->cache_index_file, "a"); |
|
124 | 124 | // If local file |
125 | - if(strncasecmp('http://', $this->filename, 7) !== 0) |
|
125 | + if (strncasecmp('http://', $this->filename, 7) !== 0) |
|
126 | 126 | { |
127 | - if(!file_exists($this->filename)) return new Object(-1,'msg_no_xml_file'); |
|
128 | - $this->fd = fopen($this->filename,"r"); |
|
127 | + if (!file_exists($this->filename)) return new Object(-1, 'msg_no_xml_file'); |
|
128 | + $this->fd = fopen($this->filename, "r"); |
|
129 | 129 | // If remote file |
130 | 130 | } |
131 | 131 | else |
132 | 132 | { |
133 | 133 | $url_info = parse_url($this->filename); |
134 | - if(!$url_info['port']) $url_info['port'] = 80; |
|
135 | - if(!$url_info['path']) $url_info['path'] = '/'; |
|
134 | + if (!$url_info['port']) $url_info['port'] = 80; |
|
135 | + if (!$url_info['path']) $url_info['path'] = '/'; |
|
136 | 136 | |
137 | 137 | $this->fd = @fsockopen($url_info['host'], $url_info['port']); |
138 | - if(!$this->fd) return new Object(-1,'msg_no_xml_file'); |
|
138 | + if (!$this->fd) return new Object(-1, 'msg_no_xml_file'); |
|
139 | 139 | // If the file name contains Korean, do urlencode(iconv required) |
140 | 140 | $path = $url_info['path']; |
141 | - if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) |
|
141 | + if (preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path) && function_exists('iconv')) |
|
142 | 142 | { |
143 | - $path_list = explode('/',$path); |
|
143 | + $path_list = explode('/', $path); |
|
144 | 144 | $cnt = count($path_list); |
145 | - $filename = $path_list[$cnt-1]; |
|
146 | - $filename = urlencode(iconv("UTF-8","EUC-KR",$filename)); |
|
147 | - $path_list[$cnt-1] = $filename; |
|
148 | - $path = implode('/',$path_list); |
|
145 | + $filename = $path_list[$cnt - 1]; |
|
146 | + $filename = urlencode(iconv("UTF-8", "EUC-KR", $filename)); |
|
147 | + $path_list[$cnt - 1] = $filename; |
|
148 | + $path = implode('/', $path_list); |
|
149 | 149 | $url_info['path'] = $path; |
150 | 150 | } |
151 | 151 | |
152 | 152 | $header = sprintf("GET %s?%s HTTP/1.0\r\nHost: %s\r\nReferer: %s://%s\r\nConnection: Close\r\n\r\n", $url_info['path'], $url_info['query'], $url_info['host'], $url_info['scheme'], $url_info['host']); |
153 | 153 | @fwrite($this->fd, $header); |
154 | 154 | $buff = ''; |
155 | - while(!feof($this->fd)) |
|
155 | + while (!feof($this->fd)) |
|
156 | 156 | { |
157 | 157 | $buff .= $str = fgets($this->fd, 1024); |
158 | - if(!trim($str)) break; |
|
158 | + if (!trim($str)) break; |
|
159 | 159 | } |
160 | - if(preg_match('/404 Not Found/i',$buff)) return new Object(-1,'msg_no_xml_file'); |
|
160 | + if (preg_match('/404 Not Found/i', $buff)) return new Object(-1, 'msg_no_xml_file'); |
|
161 | 161 | } |
162 | 162 | |
163 | - if($this->startTag) |
|
163 | + if ($this->startTag) |
|
164 | 164 | { |
165 | - while(!feof($this->fd)) |
|
165 | + while (!feof($this->fd)) |
|
166 | 166 | { |
167 | 167 | $str = fgets($this->fd, 1024); |
168 | 168 | $pos = strpos($str, $this->startTag); |
169 | - if($pos !== false) |
|
169 | + if ($pos !== false) |
|
170 | 170 | { |
171 | - $this->buff = substr($this->buff, $pos+strlen($this->startTag)); |
|
171 | + $this->buff = substr($this->buff, $pos + strlen($this->startTag)); |
|
172 | 172 | $this->isStarted = true; |
173 | 173 | $this->isFinished = false; |
174 | 174 | break; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | FileHandler::removeDir($this->cache_path.$this->key); |
210 | 210 | $this->index = 0; |
211 | - while(!$this->isFinished()) |
|
211 | + while (!$this->isFinished()) |
|
212 | 212 | { |
213 | 213 | $this->getItem(); |
214 | 214 | } |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | |
225 | 225 | $filename = sprintf('%s/%s', $this->cache_path, $filename); |
226 | 226 | |
227 | - $index_fd = fopen($this->cache_index_file,"r"); |
|
228 | - $fd = fopen($filename,'w'); |
|
227 | + $index_fd = fopen($this->cache_index_file, "r"); |
|
228 | + $fd = fopen($filename, 'w'); |
|
229 | 229 | |
230 | 230 | fwrite($fd, '<items>'); |
231 | - while(!feof($index_fd)) |
|
231 | + while (!feof($index_fd)) |
|
232 | 232 | { |
233 | - $target_file = trim(fgets($index_fd,1024)); |
|
234 | - if(!file_exists($target_file)) continue; |
|
233 | + $target_file = trim(fgets($index_fd, 1024)); |
|
234 | + if (!file_exists($target_file)) continue; |
|
235 | 235 | $buff = FileHandler::readFile($target_file); |
236 | 236 | fwrite($fd, FileHandler::readFile($target_file)); |
237 | 237 | |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function getItem() |
249 | 249 | { |
250 | - if($this->isFinished()) return; |
|
250 | + if ($this->isFinished()) return; |
|
251 | 251 | |
252 | - while(!feof($this->fd)) |
|
252 | + while (!feof($this->fd)) |
|
253 | 253 | { |
254 | 254 | $startPos = strpos($this->buff, $this->itemStartTag); |
255 | - if($startPos !== false) |
|
255 | + if ($startPos !== false) |
|
256 | 256 | { |
257 | 257 | $this->buff = substr($this->buff, $startPos); |
258 | - $this->buff = preg_replace("/\>/",">\r\n",$this->buff,1); |
|
258 | + $this->buff = preg_replace("/\>/", ">\r\n", $this->buff, 1); |
|
259 | 259 | break; |
260 | 260 | } |
261 | - elseif($this->endTag) |
|
261 | + elseif ($this->endTag) |
|
262 | 262 | { |
263 | 263 | $endPos = strpos($this->buff, $this->endTag); |
264 | - if($endPos !== false) |
|
264 | + if ($endPos !== false) |
|
265 | 265 | { |
266 | 266 | $this->closeFile(); |
267 | 267 | return; |
@@ -271,21 +271,21 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | $startPos = strpos($this->buff, $this->itemStartTag); |
274 | - if($startPos === false) |
|
274 | + if ($startPos === false) |
|
275 | 275 | { |
276 | 276 | $this->closeFile(); |
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | - $filename = sprintf('%s/%s.xml',$this->cache_path, $this->index++); |
|
280 | + $filename = sprintf('%s/%s.xml', $this->cache_path, $this->index++); |
|
281 | 281 | fwrite($this->index_fd, $filename."\r\n"); |
282 | 282 | |
283 | - $fd = fopen($filename,'w'); |
|
283 | + $fd = fopen($filename, 'w'); |
|
284 | 284 | |
285 | - while(!feof($this->fd)) |
|
285 | + while (!feof($this->fd)) |
|
286 | 286 | { |
287 | 287 | $endPos = strpos($this->buff, $this->itemEndTag); |
288 | - if($endPos !== false) |
|
288 | + if ($endPos !== false) |
|
289 | 289 | { |
290 | 290 | $endPos += strlen($this->itemEndTag); |
291 | 291 | $buff = substr($this->buff, 0, $endPos); |