@@ -26,12 +26,12 @@ |
||
26 | 26 | $current_module_srl = Context::get('module_srl'); |
27 | 27 | $current_module_srls = Context::get('module_srls'); |
28 | 28 | |
29 | - if(!$current_module_srl && !$current_module_srls) |
|
29 | + if (!$current_module_srl && !$current_module_srls) |
|
30 | 30 | { |
31 | 31 | // Get information of the current module |
32 | 32 | $current_module_info = Context::get('current_module_info'); |
33 | 33 | $current_module_srl = $current_module_info->module_srl; |
34 | - if(!$current_module_srl) return new BaseObject(); |
|
34 | + if (!$current_module_srl) return new BaseObject(); |
|
35 | 35 | } |
36 | 36 | // Get file configurations of the module |
37 | 37 | $oFileModel = getModel('file'); |
@@ -31,7 +31,9 @@ |
||
31 | 31 | // Get information of the current module |
32 | 32 | $current_module_info = Context::get('current_module_info'); |
33 | 33 | $current_module_srl = $current_module_info->module_srl; |
34 | - if(!$current_module_srl) return new BaseObject(); |
|
34 | + if(!$current_module_srl) { |
|
35 | + return new BaseObject(); |
|
36 | + } |
|
35 | 37 | } |
36 | 38 | // Get file configurations of the module |
37 | 39 | $oFileModel = getModel('file'); |
@@ -29,30 +29,30 @@ 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 | - $this->add('file_srl',$output->get('file_srl')); |
|
50 | - $this->add('file_size',$output->get('file_size')); |
|
51 | - $this->add('direct_download',$output->get('direct_download')); |
|
52 | - $this->add('source_filename',$output->get('source_filename')); |
|
53 | - $this->add('download_url',$output->get('uploaded_filename')); |
|
54 | - $this->add('upload_target_srl',$output->get('upload_target_srl')); |
|
55 | - if($output->error != '0') $this->stop($output->message); |
|
49 | + $this->add('file_srl', $output->get('file_srl')); |
|
50 | + $this->add('file_size', $output->get('file_size')); |
|
51 | + $this->add('direct_download', $output->get('direct_download')); |
|
52 | + $this->add('source_filename', $output->get('source_filename')); |
|
53 | + $this->add('download_url', $output->get('uploaded_filename')); |
|
54 | + $this->add('upload_target_srl', $output->get('upload_target_srl')); |
|
55 | + if ($output->error != '0') $this->stop($output->message); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -67,24 +67,24 @@ discard block |
||
67 | 67 | $callback = Context::get('callback'); |
68 | 68 | $module_srl = $this->module_srl; |
69 | 69 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
70 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
70 | + if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
71 | 71 | |
72 | 72 | // Exit a session if there is neither upload permission nor information |
73 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
73 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
74 | 74 | // Extract from session information if upload_target_srl is not specified |
75 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
75 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
76 | 76 | // Create if upload_target_srl is not defined in the session information |
77 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
77 | + if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
78 | 78 | |
79 | 79 | // Delete and then attempt to re-upload if file_srl is requested |
80 | 80 | $file_srl = Context::get('file_srl'); |
81 | - if($file_srl) |
|
81 | + if ($file_srl) |
|
82 | 82 | { |
83 | 83 | $oFileModel = getModel('file'); |
84 | 84 | $logged_info = Context::get('logged_info'); |
85 | 85 | $file_info = $oFileModel->getFile($file_srl); |
86 | 86 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
87 | - if($file_info->file_srl == $file_srl && $file_grant->is_deletable) |
|
87 | + if ($file_info->file_srl == $file_srl && $file_grant->is_deletable) |
|
88 | 88 | { |
89 | 89 | $this->deleteFile($file_srl); |
90 | 90 | } |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | |
93 | 93 | $file_info = Context::get('Filedata'); |
94 | 94 | // An error appears if not a normally uploaded file |
95 | - if(is_uploaded_file($file_info['tmp_name'])) { |
|
95 | + if (is_uploaded_file($file_info['tmp_name'])) { |
|
96 | 96 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
97 | - Context::set('uploaded_fileinfo',$output); |
|
97 | + Context::set('uploaded_fileinfo', $output); |
|
98 | 98 | } |
99 | 99 | |
100 | - Context::set('layout','none'); |
|
100 | + Context::set('layout', 'none'); |
|
101 | 101 | |
102 | 102 | $this->setTemplatePath($this->module_path.'tpl'); |
103 | 103 | $this->setTemplateFile('iframe'); |
@@ -114,24 +114,24 @@ discard block |
||
114 | 114 | $width = Context::get('width'); |
115 | 115 | $height = Context::get('height'); |
116 | 116 | |
117 | - if(!$file_srl || !$width) |
|
117 | + if (!$file_srl || !$width) |
|
118 | 118 | { |
119 | - return new BaseObject(-1,'msg_invalid_request'); |
|
119 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $oFileModel = getModel('file'); |
123 | 123 | $fileInfo = $oFileModel->getFile($file_srl); |
124 | - if(!$fileInfo || $fileInfo->direct_download != 'Y') |
|
124 | + if (!$fileInfo || $fileInfo->direct_download != 'Y') |
|
125 | 125 | { |
126 | - return new BaseObject(-1,'msg_invalid_request'); |
|
126 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $source_src = $fileInfo->uploaded_filename; |
130 | - $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
|
130 | + $output_src = $source_src.'.resized'.strrchr($source_src, '.'); |
|
131 | 131 | |
132 | - if(!$height) $height = $width-1; |
|
132 | + if (!$height) $height = $width - 1; |
|
133 | 133 | |
134 | - if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
|
134 | + if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio')) |
|
135 | 135 | { |
136 | 136 | $output = new stdClass(); |
137 | 137 | $output->info = getimagesize($output_src); |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
142 | - return new BaseObject(-1,'msg_invalid_request'); |
|
142 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
143 | 143 | } |
144 | 144 | |
145 | - $this->add('resized_info',$output); |
|
145 | + $this->add('resized_info', $output); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $oFileModel = getModel('file'); |
182 | 182 | |
183 | - if(isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted'); |
|
183 | + if (isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted'); |
|
184 | 184 | |
185 | 185 | $file_srl = Context::get('file_srl'); |
186 | 186 | $sid = Context::get('sid'); |
@@ -189,26 +189,26 @@ discard block |
||
189 | 189 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
190 | 190 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
191 | 191 | // If the requested file information is incorrect, an error that file cannot be found appears |
192 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
192 | + if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found'); |
|
193 | 193 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
194 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
194 | + if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download'); |
|
195 | 195 | // File name |
196 | 196 | $filename = $file_obj->source_filename; |
197 | 197 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
198 | 198 | // Not allow the file outlink |
199 | - if($file_module_config->allow_outlink == 'N') |
|
199 | + if ($file_module_config->allow_outlink == 'N') |
|
200 | 200 | { |
201 | 201 | // Handles extension to allow outlink |
202 | - if($file_module_config->allow_outlink_format) |
|
202 | + if ($file_module_config->allow_outlink_format) |
|
203 | 203 | { |
204 | 204 | $allow_outlink_format_array = array(); |
205 | 205 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
206 | - if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
206 | + if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
207 | 207 | |
208 | - foreach($allow_outlink_format_array as $val) |
|
208 | + foreach ($allow_outlink_format_array as $val) |
|
209 | 209 | { |
210 | 210 | $val = trim($val); |
211 | - if(preg_match("/\.{$val}$/i", $filename)) |
|
211 | + if (preg_match("/\.{$val}$/i", $filename)) |
|
212 | 212 | { |
213 | 213 | $file_module_config->allow_outlink = 'Y'; |
214 | 214 | break; |
@@ -216,21 +216,21 @@ discard block |
||
216 | 216 | } |
217 | 217 | } |
218 | 218 | // Sites that outlink is allowed |
219 | - if($file_module_config->allow_outlink != 'Y') |
|
219 | + if ($file_module_config->allow_outlink != 'Y') |
|
220 | 220 | { |
221 | 221 | $referer = parse_url($_SERVER["HTTP_REFERER"]); |
222 | - if($referer['host'] != $_SERVER['HTTP_HOST']) |
|
222 | + if ($referer['host'] != $_SERVER['HTTP_HOST']) |
|
223 | 223 | { |
224 | - if($file_module_config->allow_outlink_site) |
|
224 | + if ($file_module_config->allow_outlink_site) |
|
225 | 225 | { |
226 | 226 | $allow_outlink_site_array = array(); |
227 | 227 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
228 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
228 | + if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
229 | 229 | |
230 | - foreach($allow_outlink_site_array as $val) |
|
230 | + foreach ($allow_outlink_site_array as $val) |
|
231 | 231 | { |
232 | 232 | $site = parse_url(trim($val)); |
233 | - if($site['host'] == $referer['host']) |
|
233 | + if ($site['host'] == $referer['host']) |
|
234 | 234 | { |
235 | 235 | $file_module_config->allow_outlink = 'Y'; |
236 | 236 | break; |
@@ -240,49 +240,49 @@ discard block |
||
240 | 240 | } |
241 | 241 | else $file_module_config->allow_outlink = 'Y'; |
242 | 242 | } |
243 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
243 | + if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Check if a permission for file download is granted |
247 | 247 | $downloadGrantCount = 0; |
248 | - if(is_array($file_module_config->download_grant)) |
|
248 | + if (is_array($file_module_config->download_grant)) |
|
249 | 249 | { |
250 | - foreach($file_module_config->download_grant AS $value) |
|
251 | - if($value) $downloadGrantCount++; |
|
250 | + foreach ($file_module_config->download_grant AS $value) |
|
251 | + if ($value) $downloadGrantCount++; |
|
252 | 252 | } |
253 | 253 | |
254 | - if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
|
254 | + if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0) |
|
255 | 255 | { |
256 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
256 | + if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
257 | 257 | $logged_info = Context::get('logged_info'); |
258 | - if($logged_info->is_admin != 'Y') |
|
258 | + if ($logged_info->is_admin != 'Y') |
|
259 | 259 | { |
260 | - $oModuleModel =& getModel('module'); |
|
260 | + $oModuleModel = & getModel('module'); |
|
261 | 261 | $columnList = array('module_srl', 'site_srl'); |
262 | 262 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList); |
263 | 263 | |
264 | - if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
264 | + if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
265 | 265 | { |
266 | - $oMemberModel =& getModel('member'); |
|
266 | + $oMemberModel = & getModel('member'); |
|
267 | 267 | $member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl); |
268 | 268 | |
269 | 269 | $is_permitted = false; |
270 | - for($i=0;$i<count($file_module_config->download_grant);$i++) |
|
270 | + for ($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
271 | 271 | { |
272 | 272 | $group_srl = $file_module_config->download_grant[$i]; |
273 | - if($member_groups[$group_srl]) |
|
273 | + if ($member_groups[$group_srl]) |
|
274 | 274 | { |
275 | 275 | $is_permitted = true; |
276 | 276 | break; |
277 | 277 | } |
278 | 278 | } |
279 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
279 | + if (!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | } |
283 | 283 | // Call a trigger (before) |
284 | 284 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
285 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
285 | + if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download'); |
|
286 | 286 | |
287 | 287 | |
288 | 288 | // 다운로드 후 (가상) |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | $random = new Password(); |
297 | 297 | $file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex'); |
298 | - header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key)); |
|
298 | + header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key)); |
|
299 | 299 | Context::close(); |
300 | 300 | exit(); |
301 | 301 | |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | $oFileModel = getModel('file'); |
307 | 307 | $file_srl = Context::get('file_srl'); |
308 | 308 | $file_key = Context::get('file_key'); |
309 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
309 | + if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
310 | 310 | |
311 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
311 | + if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
312 | 312 | else $session_key = '__XE_FILE_KEY__'; |
313 | 313 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
314 | 314 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
315 | 315 | |
316 | 316 | $uploaded_filename = $file_obj->uploaded_filename; |
317 | 317 | |
318 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
318 | + if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
319 | 319 | |
320 | - if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
320 | + if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
321 | 321 | { |
322 | 322 | unset($_SESSION[$session_key][$file_srl]); |
323 | 323 | return $this->stop('msg_invalid_request'); |
@@ -326,34 +326,34 @@ discard block |
||
326 | 326 | $file_size = $file_obj->file_size; |
327 | 327 | $filename = $file_obj->source_filename; |
328 | 328 | |
329 | - if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
329 | + if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
330 | 330 | { |
331 | - if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
331 | + if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
332 | 332 | { |
333 | - $filename_param = 'filename="' . $filename . '"'; |
|
333 | + $filename_param = 'filename="'.$filename.'"'; |
|
334 | 334 | } |
335 | 335 | else |
336 | 336 | { |
337 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
337 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
338 | 338 | } |
339 | 339 | } |
340 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
340 | + elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
341 | 341 | { |
342 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
342 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
343 | 343 | } |
344 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
344 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
345 | 345 | { |
346 | 346 | $filename = rawurlencode($filename); |
347 | - $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
|
347 | + $filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"'; |
|
348 | 348 | } |
349 | 349 | else |
350 | 350 | { |
351 | - $filename_param = 'filename="' . $filename . '"'; |
|
351 | + $filename_param = 'filename="'.$filename.'"'; |
|
352 | 352 | } |
353 | 353 | |
354 | - if($is_android) |
|
354 | + if ($is_android) |
|
355 | 355 | { |
356 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
356 | + if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | unset($_SESSION[$session_key][$file_srl]); |
@@ -361,21 +361,21 @@ discard block |
||
361 | 361 | Context::close(); |
362 | 362 | |
363 | 363 | $fp = fopen($uploaded_filename, 'rb'); |
364 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
364 | + if (!$fp) return $this->stop('msg_file_not_found'); |
|
365 | 365 | |
366 | 366 | header("Cache-Control: "); |
367 | 367 | header("Pragma: "); |
368 | 368 | header("Content-Type: application/octet-stream"); |
369 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
369 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
370 | 370 | |
371 | - header("Content-Length: " .(string)($file_size)); |
|
372 | - header('Content-Disposition: attachment; ' . $filename_param); |
|
371 | + header("Content-Length: ".(string) ($file_size)); |
|
372 | + header('Content-Disposition: attachment; '.$filename_param); |
|
373 | 373 | header("Content-Transfer-Encoding: binary\n"); |
374 | 374 | |
375 | 375 | // if file size is lager than 10MB, use fread function (#18675748) |
376 | - if($file_size > 1024 * 1024) |
|
376 | + if ($file_size > 1024 * 1024) |
|
377 | 377 | { |
378 | - while(!feof($fp)) echo fread($fp, 1024); |
|
378 | + while (!feof($fp)) echo fread($fp, 1024); |
|
379 | 379 | fclose($fp); |
380 | 380 | } |
381 | 381 | else |
@@ -397,36 +397,36 @@ discard block |
||
397 | 397 | $editor_sequence = Context::get('editor_sequence'); |
398 | 398 | $file_srl = Context::get('file_srl'); |
399 | 399 | $file_srls = Context::get('file_srls'); |
400 | - if($file_srls) $file_srl = $file_srls; |
|
400 | + if ($file_srls) $file_srl = $file_srls; |
|
401 | 401 | // Exit a session if there is neither upload permission nor information |
402 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
402 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
403 | 403 | |
404 | 404 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
405 | 405 | |
406 | 406 | $logged_info = Context::get('logged_info'); |
407 | 407 | $oFileModel = getModel('file'); |
408 | 408 | |
409 | - $srls = explode(',',$file_srl); |
|
410 | - if(!count($srls)) return; |
|
409 | + $srls = explode(',', $file_srl); |
|
410 | + if (!count($srls)) return; |
|
411 | 411 | |
412 | - for($i=0;$i<count($srls);$i++) |
|
412 | + for ($i = 0; $i < count($srls); $i++) |
|
413 | 413 | { |
414 | - $srl = (int)$srls[$i]; |
|
415 | - if(!$srl) continue; |
|
414 | + $srl = (int) $srls[$i]; |
|
415 | + if (!$srl) continue; |
|
416 | 416 | |
417 | 417 | $args = new stdClass; |
418 | 418 | $args->file_srl = $srl; |
419 | 419 | $output = executeQuery('file.getFile', $args); |
420 | - if(!$output->toBool()) continue; |
|
420 | + if (!$output->toBool()) continue; |
|
421 | 421 | |
422 | 422 | $file_info = $output->data; |
423 | - if(!$file_info) continue; |
|
423 | + if (!$file_info) continue; |
|
424 | 424 | |
425 | 425 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
426 | 426 | |
427 | - if(!$file_grant->is_deletable) continue; |
|
427 | + if (!$file_grant->is_deletable) continue; |
|
428 | 428 | |
429 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
429 | + if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -437,32 +437,32 @@ discard block |
||
437 | 437 | */ |
438 | 438 | function procFileGetList() |
439 | 439 | { |
440 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
440 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
441 | 441 | |
442 | 442 | $oModuleModel = getModel('module'); |
443 | 443 | |
444 | 444 | $logged_info = Context::get('logged_info'); |
445 | - if($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info)) |
|
445 | + if ($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info)) |
|
446 | 446 | { |
447 | 447 | return new BaseObject(-1, 'msg_not_permitted'); |
448 | 448 | } |
449 | 449 | |
450 | 450 | $fileSrls = Context::get('file_srls'); |
451 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
451 | + if ($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
452 | 452 | |
453 | 453 | global $lang; |
454 | - if(count($fileSrlList) > 0) |
|
454 | + if (count($fileSrlList) > 0) |
|
455 | 455 | { |
456 | 456 | $oFileModel = getModel('file'); |
457 | 457 | $fileList = $oFileModel->getFile($fileSrlList); |
458 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
458 | + if (!is_array($fileList)) $fileList = array($fileList); |
|
459 | 459 | |
460 | - if(is_array($fileList)) |
|
460 | + if (is_array($fileList)) |
|
461 | 461 | { |
462 | - foreach($fileList AS $key=>$value) |
|
462 | + foreach ($fileList AS $key=>$value) |
|
463 | 463 | { |
464 | 464 | $value->human_file_size = FileHandler::filesize($value->file_size); |
465 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
465 | + if ($value->isvalid == 'Y') $value->validName = $lang->is_valid; |
|
466 | 466 | else $value->validName = $lang->is_stand_by; |
467 | 467 | } |
468 | 468 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | function triggerCheckAttached(&$obj) |
485 | 485 | { |
486 | 486 | $document_srl = $obj->document_srl; |
487 | - if(!$document_srl) return new BaseObject(); |
|
487 | + if (!$document_srl) return new BaseObject(); |
|
488 | 488 | // Get numbers of attachments |
489 | 489 | $oFileModel = getModel('file'); |
490 | 490 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | function triggerAttachFiles(&$obj) |
502 | 502 | { |
503 | 503 | $document_srl = $obj->document_srl; |
504 | - if(!$document_srl) return new BaseObject(); |
|
504 | + if (!$document_srl) return new BaseObject(); |
|
505 | 505 | |
506 | 506 | $output = $this->setFilesValid($document_srl); |
507 | - if(!$output->toBool()) return $output; |
|
507 | + if (!$output->toBool()) return $output; |
|
508 | 508 | |
509 | 509 | return new BaseObject(); |
510 | 510 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | function triggerDeleteAttached(&$obj) |
519 | 519 | { |
520 | 520 | $document_srl = $obj->document_srl; |
521 | - if(!$document_srl) return new BaseObject(); |
|
521 | + if (!$document_srl) return new BaseObject(); |
|
522 | 522 | |
523 | 523 | $output = $this->deleteFiles($document_srl); |
524 | 524 | return $output; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | function triggerCommentCheckAttached(&$obj) |
534 | 534 | { |
535 | 535 | $comment_srl = $obj->comment_srl; |
536 | - if(!$comment_srl) return new BaseObject(); |
|
536 | + if (!$comment_srl) return new BaseObject(); |
|
537 | 537 | // Get numbers of attachments |
538 | 538 | $oFileModel = getModel('file'); |
539 | 539 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | { |
552 | 552 | $comment_srl = $obj->comment_srl; |
553 | 553 | $uploaded_count = $obj->uploaded_count; |
554 | - if(!$comment_srl || !$uploaded_count) return new BaseObject(); |
|
554 | + if (!$comment_srl || !$uploaded_count) return new BaseObject(); |
|
555 | 555 | |
556 | 556 | $output = $this->setFilesValid($comment_srl); |
557 | - if(!$output->toBool()) return $output; |
|
557 | + if (!$output->toBool()) return $output; |
|
558 | 558 | |
559 | 559 | return new BaseObject(); |
560 | 560 | } |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | function triggerCommentDeleteAttached(&$obj) |
569 | 569 | { |
570 | 570 | $comment_srl = $obj->comment_srl; |
571 | - if(!$comment_srl) return new BaseObject(); |
|
571 | + if (!$comment_srl) return new BaseObject(); |
|
572 | 572 | |
573 | - if($obj->isMoveToTrash) return new BaseObject(); |
|
573 | + if ($obj->isMoveToTrash) return new BaseObject(); |
|
574 | 574 | |
575 | 575 | $output = $this->deleteFiles($comment_srl); |
576 | 576 | return $output; |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | function triggerDeleteModuleFiles(&$obj) |
586 | 586 | { |
587 | 587 | $module_srl = $obj->module_srl; |
588 | - if(!$module_srl) return new BaseObject(); |
|
588 | + if (!$module_srl) return new BaseObject(); |
|
589 | 589 | |
590 | 590 | $oFileController = getAdminController('file'); |
591 | 591 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | * @param int $upload_target_srl |
599 | 599 | * @return void |
600 | 600 | */ |
601 | - function setUploadInfo($editor_sequence, $upload_target_srl=0) |
|
601 | + function setUploadInfo($editor_sequence, $upload_target_srl = 0) |
|
602 | 602 | { |
603 | - if(!isset($_SESSION['upload_info'][$editor_sequence])) |
|
603 | + if (!isset($_SESSION['upload_info'][$editor_sequence])) |
|
604 | 604 | { |
605 | 605 | $_SESSION['upload_info'][$editor_sequence] = new stdClass(); |
606 | 606 | } |
@@ -660,36 +660,36 @@ discard block |
||
660 | 660 | $trigger_obj->module_srl = $module_srl; |
661 | 661 | $trigger_obj->upload_target_srl = $upload_target_srl; |
662 | 662 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
663 | - if(!$output->toBool()) return $output; |
|
663 | + if (!$output->toBool()) return $output; |
|
664 | 664 | |
665 | 665 | // A workaround for Firefox upload bug |
666 | - if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
666 | + if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
667 | 667 | { |
668 | 668 | $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); |
669 | 669 | } |
670 | 670 | |
671 | - if(!$manual_insert) |
|
671 | + if (!$manual_insert) |
|
672 | 672 | { |
673 | 673 | // Get the file configurations |
674 | 674 | $logged_info = Context::get('logged_info'); |
675 | - if($logged_info->is_admin != 'Y') |
|
675 | + if ($logged_info->is_admin != 'Y') |
|
676 | 676 | { |
677 | 677 | $oFileModel = getModel('file'); |
678 | 678 | $config = $oFileModel->getFileConfig($module_srl); |
679 | 679 | |
680 | 680 | // check file type |
681 | - if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
681 | + if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
682 | 682 | { |
683 | 683 | $filetypes = explode(';', $config->allowed_filetypes); |
684 | 684 | $ext = array(); |
685 | - foreach($filetypes as $item) { |
|
685 | + foreach ($filetypes as $item) { |
|
686 | 686 | $item = explode('.', $item); |
687 | 687 | $ext[] = strtolower($item[1]); |
688 | 688 | } |
689 | 689 | $uploaded_ext = explode('.', $file_info['name']); |
690 | 690 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
691 | 691 | |
692 | - if(!in_array($uploaded_ext, $ext)) |
|
692 | + if (!in_array($uploaded_ext, $ext)) |
|
693 | 693 | { |
694 | 694 | return $this->stop('msg_not_allowed_filetype'); |
695 | 695 | } |
@@ -698,63 +698,63 @@ discard block |
||
698 | 698 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
699 | 699 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
700 | 700 | // An error appears if file size exceeds a limit |
701 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
701 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
702 | 702 | // Get total file size of all attachements (from DB) |
703 | 703 | $size_args = new stdClass; |
704 | 704 | $size_args->upload_target_srl = $upload_target_srl; |
705 | 705 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
706 | - $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
|
707 | - if($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
706 | + $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']); |
|
707 | + if ($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
708 | 708 | } |
709 | 709 | } |
710 | 710 | |
711 | 711 | // https://github.com/xpressengine/xe-core/issues/1713 |
712 | - $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']); |
|
712 | + $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']); |
|
713 | 713 | $file_info['name'] = removeHackTag($file_info['name']); |
714 | - $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']); |
|
714 | + $file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']); |
|
715 | 715 | |
716 | 716 | // Get random number generator |
717 | 717 | $random = new Password(); |
718 | 718 | |
719 | 719 | // Set upload path by checking if the attachement is an image or other kinds of file |
720 | - if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
720 | + if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
721 | 721 | { |
722 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
722 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
723 | 723 | |
724 | 724 | // special character to '_' |
725 | 725 | // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter |
726 | - $ext = substr(strrchr($file_info['name'],'.'),1); |
|
726 | + $ext = substr(strrchr($file_info['name'], '.'), 1); |
|
727 | 727 | //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']); |
728 | 728 | $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
729 | 729 | $filename = $path.$_filename; |
730 | 730 | $idx = 1; |
731 | - while(file_exists($filename)) |
|
731 | + while (file_exists($filename)) |
|
732 | 732 | { |
733 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename); |
|
733 | + $filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename); |
|
734 | 734 | $idx++; |
735 | 735 | } |
736 | 736 | $direct_download = 'Y'; |
737 | 737 | } |
738 | 738 | else |
739 | 739 | { |
740 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
740 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
741 | 741 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
742 | 742 | $direct_download = 'N'; |
743 | 743 | } |
744 | 744 | // Create a directory |
745 | - if(!FileHandler::makeDir($path)) return new BaseObject(-1,'msg_not_permitted_create'); |
|
745 | + if (!FileHandler::makeDir($path)) return new BaseObject(-1, 'msg_not_permitted_create'); |
|
746 | 746 | |
747 | 747 | // Check uploaded file |
748 | - if(!checkUploadedFile($file_info['tmp_name'])) return new BaseObject(-1,'msg_file_upload_error'); |
|
748 | + if (!checkUploadedFile($file_info['tmp_name'])) return new BaseObject(-1, 'msg_file_upload_error'); |
|
749 | 749 | |
750 | 750 | // Get random number generator |
751 | 751 | $random = new Password(); |
752 | 752 | |
753 | 753 | // Move the file |
754 | - if($manual_insert) |
|
754 | + if ($manual_insert) |
|
755 | 755 | { |
756 | 756 | @copy($file_info['tmp_name'], $filename); |
757 | - if(!file_exists($filename)) |
|
757 | + if (!file_exists($filename)) |
|
758 | 758 | { |
759 | 759 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
760 | 760 | @copy($file_info['tmp_name'], $filename); |
@@ -762,10 +762,10 @@ discard block |
||
762 | 762 | } |
763 | 763 | else |
764 | 764 | { |
765 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
765 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
766 | 766 | { |
767 | 767 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
768 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new BaseObject(-1,'msg_file_upload_error'); |
|
768 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new BaseObject(-1, 'msg_file_upload_error'); |
|
769 | 769 | } |
770 | 770 | } |
771 | 771 | // Get member information |
@@ -786,10 +786,10 @@ discard block |
||
786 | 786 | $args->sid = $random->createSecureSalt(32, 'hex'); |
787 | 787 | |
788 | 788 | $output = executeQuery('file.insertFile', $args); |
789 | - if(!$output->toBool()) return $output; |
|
789 | + if (!$output->toBool()) return $output; |
|
790 | 790 | // Call a trigger (after) |
791 | 791 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
792 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
792 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
793 | 793 | |
794 | 794 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
795 | 795 | |
@@ -832,18 +832,18 @@ discard block |
||
832 | 832 | */ |
833 | 833 | function deleteFile($file_srl) |
834 | 834 | { |
835 | - if(!$file_srl) return; |
|
835 | + if (!$file_srl) return; |
|
836 | 836 | |
837 | 837 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
838 | - if(!count($srls)) return; |
|
838 | + if (!count($srls)) return; |
|
839 | 839 | |
840 | 840 | $oDocumentController = getController('document'); |
841 | 841 | $documentSrlList = array(); |
842 | 842 | |
843 | - foreach($srls as $srl) |
|
843 | + foreach ($srls as $srl) |
|
844 | 844 | { |
845 | - $srl = (int)$srl; |
|
846 | - if(!$srl) |
|
845 | + $srl = (int) $srl; |
|
846 | + if (!$srl) |
|
847 | 847 | { |
848 | 848 | continue; |
849 | 849 | } |
@@ -852,14 +852,14 @@ discard block |
||
852 | 852 | $args->file_srl = $srl; |
853 | 853 | $output = executeQuery('file.getFile', $args); |
854 | 854 | |
855 | - if(!$output->toBool() || !$output->data) |
|
855 | + if (!$output->toBool() || !$output->data) |
|
856 | 856 | { |
857 | 857 | continue; |
858 | 858 | } |
859 | 859 | |
860 | 860 | $file_info = $output->data; |
861 | 861 | |
862 | - if($file_info->upload_target_srl) |
|
862 | + if ($file_info->upload_target_srl) |
|
863 | 863 | { |
864 | 864 | $documentSrlList[] = $file_info->upload_target_srl; |
865 | 865 | } |
@@ -870,15 +870,15 @@ discard block |
||
870 | 870 | // Call a trigger (before) |
871 | 871 | $trigger_obj = $output->data; |
872 | 872 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
873 | - if(!$output->toBool()) return $output; |
|
873 | + if (!$output->toBool()) return $output; |
|
874 | 874 | |
875 | 875 | // Remove from the DB |
876 | 876 | $output = executeQuery('file.deleteFile', $args); |
877 | - if(!$output->toBool()) return $output; |
|
877 | + if (!$output->toBool()) return $output; |
|
878 | 878 | |
879 | 879 | // Call a trigger (after) |
880 | 880 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
881 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
881 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
882 | 882 | |
883 | 883 | // If successfully deleted, remove the file |
884 | 884 | FileHandler::removeFile($uploaded_filename); |
@@ -902,28 +902,28 @@ discard block |
||
902 | 902 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
903 | 903 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
904 | 904 | // Success returned if no attachement exists |
905 | - if(!is_array($file_list)||!count($file_list)) return new BaseObject(); |
|
905 | + if (!is_array($file_list) || !count($file_list)) return new BaseObject(); |
|
906 | 906 | |
907 | 907 | // Delete the file |
908 | 908 | $path = array(); |
909 | 909 | $file_count = count($file_list); |
910 | - for($i=0;$i<$file_count;$i++) |
|
910 | + for ($i = 0; $i < $file_count; $i++) |
|
911 | 911 | { |
912 | 912 | $this->deleteFile($file_list[$i]->file_srl); |
913 | 913 | |
914 | 914 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
915 | 915 | $path_info = pathinfo($uploaded_filename); |
916 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
916 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | // Remove from the DB |
920 | 920 | $args = new stdClass(); |
921 | 921 | $args->upload_target_srl = $upload_target_srl; |
922 | 922 | $output = executeQuery('file.deleteFiles', $args); |
923 | - if(!$output->toBool()) return $output; |
|
923 | + if (!$output->toBool()) return $output; |
|
924 | 924 | |
925 | 925 | // Remove a file directory of the document |
926 | - for($i=0, $c=count($path); $i<$c; $i++) |
|
926 | + for ($i = 0, $c = count($path); $i < $c; $i++) |
|
927 | 927 | { |
928 | 928 | FileHandler::removeBlankDir($path[$i]); |
929 | 929 | } |
@@ -941,23 +941,23 @@ discard block |
||
941 | 941 | */ |
942 | 942 | function moveFile($source_srl, $target_module_srl, $target_srl) |
943 | 943 | { |
944 | - if($source_srl == $target_srl) return; |
|
944 | + if ($source_srl == $target_srl) return; |
|
945 | 945 | |
946 | 946 | $oFileModel = getModel('file'); |
947 | 947 | $file_list = $oFileModel->getFiles($source_srl); |
948 | - if(!$file_list) return; |
|
948 | + if (!$file_list) return; |
|
949 | 949 | |
950 | 950 | $file_count = count($file_list); |
951 | 951 | |
952 | - for($i=0;$i<$file_count;$i++) |
|
952 | + for ($i = 0; $i < $file_count; $i++) |
|
953 | 953 | { |
954 | 954 | unset($file_info); |
955 | 955 | $file_info = $file_list[$i]; |
956 | 956 | $old_file = $file_info->uploaded_filename; |
957 | 957 | // Determine the file path by checking if the file is an image or other kinds |
958 | - if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename)) |
|
958 | + if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename)) |
|
959 | 959 | { |
960 | - $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
|
960 | + $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl); |
|
961 | 961 | $new_file = $path.$file_info->source_filename; |
962 | 962 | } |
963 | 963 | else |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
968 | 968 | } |
969 | 969 | // Pass if a target document to move is same |
970 | - if($old_file == $new_file) continue; |
|
970 | + if ($old_file == $new_file) continue; |
|
971 | 971 | // Create a directory |
972 | 972 | FileHandler::makeDir($path); |
973 | 973 | // Move the file |
@@ -987,18 +987,18 @@ discard block |
||
987 | 987 | $vars = Context::getRequestVars(); |
988 | 988 | $logged_info = Context::get('logged_info'); |
989 | 989 | |
990 | - if(!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request'); |
|
990 | + if (!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request'); |
|
991 | 991 | |
992 | 992 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
993 | 993 | |
994 | 994 | $oFileModel = getModel('file'); |
995 | 995 | $file_info = $oFileModel->getFile($vars->file_srl); |
996 | 996 | |
997 | - if(!$file_info) return new BaseObject(-1, 'msg_not_founded'); |
|
997 | + if (!$file_info) return new BaseObject(-1, 'msg_not_founded'); |
|
998 | 998 | |
999 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted'); |
|
999 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted'); |
|
1000 | 1000 | |
1001 | - $args = new stdClass(); |
|
1001 | + $args = new stdClass(); |
|
1002 | 1002 | $args->file_srl = $vars->file_srl; |
1003 | 1003 | $args->upload_target_srl = $upload_target_srl; |
1004 | 1004 | |
@@ -1007,18 +1007,18 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | $args->cover_image = 'N'; |
1009 | 1009 | $output = executeQuery('file.updateClearCoverImage', $args); |
1010 | - if(!$output->toBool()) |
|
1010 | + if (!$output->toBool()) |
|
1011 | 1011 | { |
1012 | 1012 | $oDB->rollback(); |
1013 | 1013 | return $output; |
1014 | 1014 | } |
1015 | 1015 | |
1016 | - if($file_info->cover_image != 'Y') |
|
1016 | + if ($file_info->cover_image != 'Y') |
|
1017 | 1017 | { |
1018 | 1018 | |
1019 | 1019 | $args->cover_image = 'Y'; |
1020 | 1020 | $output = executeQuery('file.updateCoverImage', $args); |
1021 | - if(!$output->toBool()) |
|
1021 | + if (!$output->toBool()) |
|
1022 | 1022 | { |
1023 | 1023 | $oDB->rollback(); |
1024 | 1024 | return $output; |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | |
1029 | 1029 | $oDB->commit(); |
1030 | 1030 | |
1031 | - $this->add('is_cover',$args->cover_image); |
|
1031 | + $this->add('is_cover', $args->cover_image); |
|
1032 | 1032 | |
1033 | 1033 | // 썸네일 삭제 |
1034 | 1034 | $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($upload_target_srl, 3)); |
@@ -1054,9 +1054,9 @@ discard block |
||
1054 | 1054 | $fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl); |
1055 | 1055 | |
1056 | 1056 | $oModuleController = getController('module'); |
1057 | - if(is_array($obj->moduleSrlList)) |
|
1057 | + if (is_array($obj->moduleSrlList)) |
|
1058 | 1058 | { |
1059 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1059 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
1060 | 1060 | { |
1061 | 1061 | $oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig); |
1062 | 1062 | } |
@@ -29,20 +29,30 @@ 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'); |
@@ -52,7 +62,9 @@ discard block |
||
52 | 62 | $this->add('source_filename',$output->get('source_filename')); |
53 | 63 | $this->add('download_url',$output->get('uploaded_filename')); |
54 | 64 | $this->add('upload_target_srl',$output->get('upload_target_srl')); |
55 | - if($output->error != '0') $this->stop($output->message); |
|
65 | + if($output->error != '0') { |
|
66 | + $this->stop($output->message); |
|
67 | + } |
|
56 | 68 | } |
57 | 69 | |
58 | 70 | /** |
@@ -67,14 +79,22 @@ discard block |
||
67 | 79 | $callback = Context::get('callback'); |
68 | 80 | $module_srl = $this->module_srl; |
69 | 81 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
70 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
82 | + if(!$upload_target_srl) { |
|
83 | + $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
84 | + } |
|
71 | 85 | |
72 | 86 | // Exit a session if there is neither upload permission nor information |
73 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
87 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
88 | + exit(); |
|
89 | + } |
|
74 | 90 | // Extract from session information if upload_target_srl is not specified |
75 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
91 | + if(!$upload_target_srl) { |
|
92 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
93 | + } |
|
76 | 94 | // Create if upload_target_srl is not defined in the session information |
77 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
95 | + if(!$upload_target_srl) { |
|
96 | + $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
97 | + } |
|
78 | 98 | |
79 | 99 | // Delete and then attempt to re-upload if file_srl is requested |
80 | 100 | $file_srl = Context::get('file_srl'); |
@@ -129,15 +149,16 @@ discard block |
||
129 | 149 | $source_src = $fileInfo->uploaded_filename; |
130 | 150 | $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
131 | 151 | |
132 | - if(!$height) $height = $width-1; |
|
152 | + if(!$height) { |
|
153 | + $height = $width-1; |
|
154 | + } |
|
133 | 155 | |
134 | 156 | if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
135 | 157 | { |
136 | 158 | $output = new stdClass(); |
137 | 159 | $output->info = getimagesize($output_src); |
138 | 160 | $output->src = $output_src; |
139 | - } |
|
140 | - else |
|
161 | + } else |
|
141 | 162 | { |
142 | 163 | return new BaseObject(-1,'msg_invalid_request'); |
143 | 164 | } |
@@ -180,7 +201,9 @@ discard block |
||
180 | 201 | { |
181 | 202 | $oFileModel = getModel('file'); |
182 | 203 | |
183 | - if(isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted'); |
|
204 | + if(isset($this->grant->access) && $this->grant->access !== true) { |
|
205 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
206 | + } |
|
184 | 207 | |
185 | 208 | $file_srl = Context::get('file_srl'); |
186 | 209 | $sid = Context::get('sid'); |
@@ -189,9 +212,13 @@ discard block |
||
189 | 212 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
190 | 213 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
191 | 214 | // If the requested file information is incorrect, an error that file cannot be found appears |
192 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
215 | + if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) { |
|
216 | + return $this->stop('msg_file_not_found'); |
|
217 | + } |
|
193 | 218 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
194 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
219 | + if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') { |
|
220 | + return $this->stop('msg_not_permitted_download'); |
|
221 | + } |
|
195 | 222 | // File name |
196 | 223 | $filename = $file_obj->source_filename; |
197 | 224 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
@@ -203,7 +230,9 @@ discard block |
||
203 | 230 | { |
204 | 231 | $allow_outlink_format_array = array(); |
205 | 232 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
206 | - if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
233 | + if(!is_array($allow_outlink_format_array)) { |
|
234 | + $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
235 | + } |
|
207 | 236 | |
208 | 237 | foreach($allow_outlink_format_array as $val) |
209 | 238 | { |
@@ -225,7 +254,9 @@ discard block |
||
225 | 254 | { |
226 | 255 | $allow_outlink_site_array = array(); |
227 | 256 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
228 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
257 | + if(!is_array($allow_outlink_site_array)) { |
|
258 | + $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
259 | + } |
|
229 | 260 | |
230 | 261 | foreach($allow_outlink_site_array as $val) |
231 | 262 | { |
@@ -237,23 +268,29 @@ discard block |
||
237 | 268 | } |
238 | 269 | } |
239 | 270 | } |
271 | + } else { |
|
272 | + $file_module_config->allow_outlink = 'Y'; |
|
240 | 273 | } |
241 | - else $file_module_config->allow_outlink = 'Y'; |
|
242 | 274 | } |
243 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
275 | + if($file_module_config->allow_outlink != 'Y') { |
|
276 | + return $this->stop('msg_not_allowed_outlink'); |
|
277 | + } |
|
244 | 278 | } |
245 | 279 | |
246 | 280 | // Check if a permission for file download is granted |
247 | 281 | $downloadGrantCount = 0; |
248 | 282 | if(is_array($file_module_config->download_grant)) |
249 | 283 | { |
250 | - foreach($file_module_config->download_grant AS $value) |
|
251 | - if($value) $downloadGrantCount++; |
|
284 | + foreach($file_module_config->download_grant AS $value) { |
|
285 | + if($value) $downloadGrantCount++; |
|
286 | + } |
|
252 | 287 | } |
253 | 288 | |
254 | 289 | if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
255 | 290 | { |
256 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
291 | + if(!Context::get('is_logged')) { |
|
292 | + return $this->stop('msg_not_permitted_download'); |
|
293 | + } |
|
257 | 294 | $logged_info = Context::get('logged_info'); |
258 | 295 | if($logged_info->is_admin != 'Y') |
259 | 296 | { |
@@ -276,13 +313,17 @@ discard block |
||
276 | 313 | break; |
277 | 314 | } |
278 | 315 | } |
279 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
316 | + if(!$is_permitted) { |
|
317 | + return $this->stop('msg_not_permitted_download'); |
|
318 | + } |
|
280 | 319 | } |
281 | 320 | } |
282 | 321 | } |
283 | 322 | // Call a trigger (before) |
284 | 323 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
285 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
324 | + if(!$output->toBool()) { |
|
325 | + return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
326 | + } |
|
286 | 327 | |
287 | 328 | |
288 | 329 | // 다운로드 후 (가상) |
@@ -306,16 +347,23 @@ discard block |
||
306 | 347 | $oFileModel = getModel('file'); |
307 | 348 | $file_srl = Context::get('file_srl'); |
308 | 349 | $file_key = Context::get('file_key'); |
309 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
350 | + if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) { |
|
351 | + $is_android = true; |
|
352 | + } |
|
310 | 353 | |
311 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
312 | - else $session_key = '__XE_FILE_KEY__'; |
|
354 | + if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) { |
|
355 | + $session_key = '__XE_FILE_KEY_AND__'; |
|
356 | + } else { |
|
357 | + $session_key = '__XE_FILE_KEY__'; |
|
358 | + } |
|
313 | 359 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
314 | 360 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
315 | 361 | |
316 | 362 | $uploaded_filename = $file_obj->uploaded_filename; |
317 | 363 | |
318 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
364 | + if(!file_exists($uploaded_filename)) { |
|
365 | + return $this->stop('msg_file_not_found'); |
|
366 | + } |
|
319 | 367 | |
320 | 368 | if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
321 | 369 | { |
@@ -331,29 +379,27 @@ discard block |
||
331 | 379 | if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
332 | 380 | { |
333 | 381 | $filename_param = 'filename="' . $filename . '"'; |
334 | - } |
|
335 | - else |
|
382 | + } else |
|
336 | 383 | { |
337 | 384 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
338 | 385 | } |
339 | - } |
|
340 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
386 | + } elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
341 | 387 | { |
342 | 388 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
343 | - } |
|
344 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
389 | + } elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
345 | 390 | { |
346 | 391 | $filename = rawurlencode($filename); |
347 | 392 | $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
348 | - } |
|
349 | - else |
|
393 | + } else |
|
350 | 394 | { |
351 | 395 | $filename_param = 'filename="' . $filename . '"'; |
352 | 396 | } |
353 | 397 | |
354 | 398 | if($is_android) |
355 | 399 | { |
356 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
400 | + if($_SESSION['__XE_FILE_KEY__'][$file_srl]) { |
|
401 | + $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
402 | + } |
|
357 | 403 | } |
358 | 404 | |
359 | 405 | unset($_SESSION[$session_key][$file_srl]); |
@@ -361,7 +407,9 @@ discard block |
||
361 | 407 | Context::close(); |
362 | 408 | |
363 | 409 | $fp = fopen($uploaded_filename, 'rb'); |
364 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
410 | + if(!$fp) { |
|
411 | + return $this->stop('msg_file_not_found'); |
|
412 | + } |
|
365 | 413 | |
366 | 414 | header("Cache-Control: "); |
367 | 415 | header("Pragma: "); |
@@ -375,10 +423,11 @@ discard block |
||
375 | 423 | // if file size is lager than 10MB, use fread function (#18675748) |
376 | 424 | if($file_size > 1024 * 1024) |
377 | 425 | { |
378 | - while(!feof($fp)) echo fread($fp, 1024); |
|
426 | + while(!feof($fp)) { |
|
427 | + echo fread($fp, 1024); |
|
428 | + } |
|
379 | 429 | fclose($fp); |
380 | - } |
|
381 | - else |
|
430 | + } else |
|
382 | 431 | { |
383 | 432 | fpassthru($fp); |
384 | 433 | } |
@@ -397,9 +446,13 @@ discard block |
||
397 | 446 | $editor_sequence = Context::get('editor_sequence'); |
398 | 447 | $file_srl = Context::get('file_srl'); |
399 | 448 | $file_srls = Context::get('file_srls'); |
400 | - if($file_srls) $file_srl = $file_srls; |
|
449 | + if($file_srls) { |
|
450 | + $file_srl = $file_srls; |
|
451 | + } |
|
401 | 452 | // Exit a session if there is neither upload permission nor information |
402 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
453 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
454 | + exit(); |
|
455 | + } |
|
403 | 456 | |
404 | 457 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
405 | 458 | |
@@ -407,26 +460,38 @@ discard block |
||
407 | 460 | $oFileModel = getModel('file'); |
408 | 461 | |
409 | 462 | $srls = explode(',',$file_srl); |
410 | - if(!count($srls)) return; |
|
463 | + if(!count($srls)) { |
|
464 | + return; |
|
465 | + } |
|
411 | 466 | |
412 | 467 | for($i=0;$i<count($srls);$i++) |
413 | 468 | { |
414 | 469 | $srl = (int)$srls[$i]; |
415 | - if(!$srl) continue; |
|
470 | + if(!$srl) { |
|
471 | + continue; |
|
472 | + } |
|
416 | 473 | |
417 | 474 | $args = new stdClass; |
418 | 475 | $args->file_srl = $srl; |
419 | 476 | $output = executeQuery('file.getFile', $args); |
420 | - if(!$output->toBool()) continue; |
|
477 | + if(!$output->toBool()) { |
|
478 | + continue; |
|
479 | + } |
|
421 | 480 | |
422 | 481 | $file_info = $output->data; |
423 | - if(!$file_info) continue; |
|
482 | + if(!$file_info) { |
|
483 | + continue; |
|
484 | + } |
|
424 | 485 | |
425 | 486 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
426 | 487 | |
427 | - if(!$file_grant->is_deletable) continue; |
|
488 | + if(!$file_grant->is_deletable) { |
|
489 | + continue; |
|
490 | + } |
|
428 | 491 | |
429 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
492 | + if($upload_target_srl && $file_srl) { |
|
493 | + $output = $this->deleteFile($file_srl); |
|
494 | + } |
|
430 | 495 | } |
431 | 496 | } |
432 | 497 | |
@@ -437,7 +502,9 @@ discard block |
||
437 | 502 | */ |
438 | 503 | function procFileGetList() |
439 | 504 | { |
440 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
505 | + if(!Context::get('is_logged')) { |
|
506 | + return new BaseObject(-1,'msg_not_permitted'); |
|
507 | + } |
|
441 | 508 | |
442 | 509 | $oModuleModel = getModel('module'); |
443 | 510 | |
@@ -448,26 +515,32 @@ discard block |
||
448 | 515 | } |
449 | 516 | |
450 | 517 | $fileSrls = Context::get('file_srls'); |
451 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
518 | + if($fileSrls) { |
|
519 | + $fileSrlList = explode(',', $fileSrls); |
|
520 | + } |
|
452 | 521 | |
453 | 522 | global $lang; |
454 | 523 | if(count($fileSrlList) > 0) |
455 | 524 | { |
456 | 525 | $oFileModel = getModel('file'); |
457 | 526 | $fileList = $oFileModel->getFile($fileSrlList); |
458 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
527 | + if(!is_array($fileList)) { |
|
528 | + $fileList = array($fileList); |
|
529 | + } |
|
459 | 530 | |
460 | 531 | if(is_array($fileList)) |
461 | 532 | { |
462 | 533 | foreach($fileList AS $key=>$value) |
463 | 534 | { |
464 | 535 | $value->human_file_size = FileHandler::filesize($value->file_size); |
465 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
466 | - else $value->validName = $lang->is_stand_by; |
|
536 | + if($value->isvalid=='Y') { |
|
537 | + $value->validName = $lang->is_valid; |
|
538 | + } else { |
|
539 | + $value->validName = $lang->is_stand_by; |
|
540 | + } |
|
467 | 541 | } |
468 | 542 | } |
469 | - } |
|
470 | - else |
|
543 | + } else |
|
471 | 544 | { |
472 | 545 | $fileList = array(); |
473 | 546 | $this->setMessage($lang->no_files); |
@@ -484,7 +557,9 @@ discard block |
||
484 | 557 | function triggerCheckAttached(&$obj) |
485 | 558 | { |
486 | 559 | $document_srl = $obj->document_srl; |
487 | - if(!$document_srl) return new BaseObject(); |
|
560 | + if(!$document_srl) { |
|
561 | + return new BaseObject(); |
|
562 | + } |
|
488 | 563 | // Get numbers of attachments |
489 | 564 | $oFileModel = getModel('file'); |
490 | 565 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -501,10 +576,14 @@ discard block |
||
501 | 576 | function triggerAttachFiles(&$obj) |
502 | 577 | { |
503 | 578 | $document_srl = $obj->document_srl; |
504 | - if(!$document_srl) return new BaseObject(); |
|
579 | + if(!$document_srl) { |
|
580 | + return new BaseObject(); |
|
581 | + } |
|
505 | 582 | |
506 | 583 | $output = $this->setFilesValid($document_srl); |
507 | - if(!$output->toBool()) return $output; |
|
584 | + if(!$output->toBool()) { |
|
585 | + return $output; |
|
586 | + } |
|
508 | 587 | |
509 | 588 | return new BaseObject(); |
510 | 589 | } |
@@ -518,7 +597,9 @@ discard block |
||
518 | 597 | function triggerDeleteAttached(&$obj) |
519 | 598 | { |
520 | 599 | $document_srl = $obj->document_srl; |
521 | - if(!$document_srl) return new BaseObject(); |
|
600 | + if(!$document_srl) { |
|
601 | + return new BaseObject(); |
|
602 | + } |
|
522 | 603 | |
523 | 604 | $output = $this->deleteFiles($document_srl); |
524 | 605 | return $output; |
@@ -533,7 +614,9 @@ discard block |
||
533 | 614 | function triggerCommentCheckAttached(&$obj) |
534 | 615 | { |
535 | 616 | $comment_srl = $obj->comment_srl; |
536 | - if(!$comment_srl) return new BaseObject(); |
|
617 | + if(!$comment_srl) { |
|
618 | + return new BaseObject(); |
|
619 | + } |
|
537 | 620 | // Get numbers of attachments |
538 | 621 | $oFileModel = getModel('file'); |
539 | 622 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -551,10 +634,14 @@ discard block |
||
551 | 634 | { |
552 | 635 | $comment_srl = $obj->comment_srl; |
553 | 636 | $uploaded_count = $obj->uploaded_count; |
554 | - if(!$comment_srl || !$uploaded_count) return new BaseObject(); |
|
637 | + if(!$comment_srl || !$uploaded_count) { |
|
638 | + return new BaseObject(); |
|
639 | + } |
|
555 | 640 | |
556 | 641 | $output = $this->setFilesValid($comment_srl); |
557 | - if(!$output->toBool()) return $output; |
|
642 | + if(!$output->toBool()) { |
|
643 | + return $output; |
|
644 | + } |
|
558 | 645 | |
559 | 646 | return new BaseObject(); |
560 | 647 | } |
@@ -568,9 +655,13 @@ discard block |
||
568 | 655 | function triggerCommentDeleteAttached(&$obj) |
569 | 656 | { |
570 | 657 | $comment_srl = $obj->comment_srl; |
571 | - if(!$comment_srl) return new BaseObject(); |
|
658 | + if(!$comment_srl) { |
|
659 | + return new BaseObject(); |
|
660 | + } |
|
572 | 661 | |
573 | - if($obj->isMoveToTrash) return new BaseObject(); |
|
662 | + if($obj->isMoveToTrash) { |
|
663 | + return new BaseObject(); |
|
664 | + } |
|
574 | 665 | |
575 | 666 | $output = $this->deleteFiles($comment_srl); |
576 | 667 | return $output; |
@@ -585,7 +676,9 @@ discard block |
||
585 | 676 | function triggerDeleteModuleFiles(&$obj) |
586 | 677 | { |
587 | 678 | $module_srl = $obj->module_srl; |
588 | - if(!$module_srl) return new BaseObject(); |
|
679 | + if(!$module_srl) { |
|
680 | + return new BaseObject(); |
|
681 | + } |
|
589 | 682 | |
590 | 683 | $oFileController = getAdminController('file'); |
591 | 684 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -660,7 +753,9 @@ discard block |
||
660 | 753 | $trigger_obj->module_srl = $module_srl; |
661 | 754 | $trigger_obj->upload_target_srl = $upload_target_srl; |
662 | 755 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
663 | - if(!$output->toBool()) return $output; |
|
756 | + if(!$output->toBool()) { |
|
757 | + return $output; |
|
758 | + } |
|
664 | 759 | |
665 | 760 | // A workaround for Firefox upload bug |
666 | 761 | if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
@@ -698,13 +793,17 @@ discard block |
||
698 | 793 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
699 | 794 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
700 | 795 | // An error appears if file size exceeds a limit |
701 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
796 | + if($allowed_filesize < filesize($file_info['tmp_name'])) { |
|
797 | + return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
798 | + } |
|
702 | 799 | // Get total file size of all attachements (from DB) |
703 | 800 | $size_args = new stdClass; |
704 | 801 | $size_args->upload_target_srl = $upload_target_srl; |
705 | 802 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
706 | 803 | $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
707 | - if($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
804 | + if($attached_size > $allowed_attach_size) { |
|
805 | + return new BaseObject(-1, 'msg_exceeds_limit_size'); |
|
806 | + } |
|
708 | 807 | } |
709 | 808 | } |
710 | 809 | |
@@ -734,18 +833,21 @@ discard block |
||
734 | 833 | $idx++; |
735 | 834 | } |
736 | 835 | $direct_download = 'Y'; |
737 | - } |
|
738 | - else |
|
836 | + } else |
|
739 | 837 | { |
740 | 838 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
741 | 839 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
742 | 840 | $direct_download = 'N'; |
743 | 841 | } |
744 | 842 | // Create a directory |
745 | - if(!FileHandler::makeDir($path)) return new BaseObject(-1,'msg_not_permitted_create'); |
|
843 | + if(!FileHandler::makeDir($path)) { |
|
844 | + return new BaseObject(-1,'msg_not_permitted_create'); |
|
845 | + } |
|
746 | 846 | |
747 | 847 | // Check uploaded file |
748 | - if(!checkUploadedFile($file_info['tmp_name'])) return new BaseObject(-1,'msg_file_upload_error'); |
|
848 | + if(!checkUploadedFile($file_info['tmp_name'])) { |
|
849 | + return new BaseObject(-1,'msg_file_upload_error'); |
|
850 | + } |
|
749 | 851 | |
750 | 852 | // Get random number generator |
751 | 853 | $random = new Password(); |
@@ -759,13 +861,14 @@ discard block |
||
759 | 861 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
760 | 862 | @copy($file_info['tmp_name'], $filename); |
761 | 863 | } |
762 | - } |
|
763 | - else |
|
864 | + } else |
|
764 | 865 | { |
765 | 866 | if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
766 | 867 | { |
767 | 868 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
768 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new BaseObject(-1,'msg_file_upload_error'); |
|
869 | + if(!@move_uploaded_file($file_info['tmp_name'], $filename)) { |
|
870 | + return new BaseObject(-1,'msg_file_upload_error'); |
|
871 | + } |
|
769 | 872 | } |
770 | 873 | } |
771 | 874 | // Get member information |
@@ -786,10 +889,14 @@ discard block |
||
786 | 889 | $args->sid = $random->createSecureSalt(32, 'hex'); |
787 | 890 | |
788 | 891 | $output = executeQuery('file.insertFile', $args); |
789 | - if(!$output->toBool()) return $output; |
|
892 | + if(!$output->toBool()) { |
|
893 | + return $output; |
|
894 | + } |
|
790 | 895 | // Call a trigger (after) |
791 | 896 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
792 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
897 | + if(!$trigger_output->toBool()) { |
|
898 | + return $trigger_output; |
|
899 | + } |
|
793 | 900 | |
794 | 901 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
795 | 902 | |
@@ -832,10 +939,14 @@ discard block |
||
832 | 939 | */ |
833 | 940 | function deleteFile($file_srl) |
834 | 941 | { |
835 | - if(!$file_srl) return; |
|
942 | + if(!$file_srl) { |
|
943 | + return; |
|
944 | + } |
|
836 | 945 | |
837 | 946 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
838 | - if(!count($srls)) return; |
|
947 | + if(!count($srls)) { |
|
948 | + return; |
|
949 | + } |
|
839 | 950 | |
840 | 951 | $oDocumentController = getController('document'); |
841 | 952 | $documentSrlList = array(); |
@@ -870,15 +981,21 @@ discard block |
||
870 | 981 | // Call a trigger (before) |
871 | 982 | $trigger_obj = $output->data; |
872 | 983 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
873 | - if(!$output->toBool()) return $output; |
|
984 | + if(!$output->toBool()) { |
|
985 | + return $output; |
|
986 | + } |
|
874 | 987 | |
875 | 988 | // Remove from the DB |
876 | 989 | $output = executeQuery('file.deleteFile', $args); |
877 | - if(!$output->toBool()) return $output; |
|
990 | + if(!$output->toBool()) { |
|
991 | + return $output; |
|
992 | + } |
|
878 | 993 | |
879 | 994 | // Call a trigger (after) |
880 | 995 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
881 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
996 | + if(!$trigger_output->toBool()) { |
|
997 | + return $trigger_output; |
|
998 | + } |
|
882 | 999 | |
883 | 1000 | // If successfully deleted, remove the file |
884 | 1001 | FileHandler::removeFile($uploaded_filename); |
@@ -902,7 +1019,9 @@ discard block |
||
902 | 1019 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
903 | 1020 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
904 | 1021 | // Success returned if no attachement exists |
905 | - if(!is_array($file_list)||!count($file_list)) return new BaseObject(); |
|
1022 | + if(!is_array($file_list)||!count($file_list)) { |
|
1023 | + return new BaseObject(); |
|
1024 | + } |
|
906 | 1025 | |
907 | 1026 | // Delete the file |
908 | 1027 | $path = array(); |
@@ -913,14 +1032,18 @@ discard block |
||
913 | 1032 | |
914 | 1033 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
915 | 1034 | $path_info = pathinfo($uploaded_filename); |
916 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
1035 | + if(!in_array($path_info['dirname'], $path)) { |
|
1036 | + $path[] = $path_info['dirname']; |
|
1037 | + } |
|
917 | 1038 | } |
918 | 1039 | |
919 | 1040 | // Remove from the DB |
920 | 1041 | $args = new stdClass(); |
921 | 1042 | $args->upload_target_srl = $upload_target_srl; |
922 | 1043 | $output = executeQuery('file.deleteFiles', $args); |
923 | - if(!$output->toBool()) return $output; |
|
1044 | + if(!$output->toBool()) { |
|
1045 | + return $output; |
|
1046 | + } |
|
924 | 1047 | |
925 | 1048 | // Remove a file directory of the document |
926 | 1049 | for($i=0, $c=count($path); $i<$c; $i++) |
@@ -941,11 +1064,15 @@ discard block |
||
941 | 1064 | */ |
942 | 1065 | function moveFile($source_srl, $target_module_srl, $target_srl) |
943 | 1066 | { |
944 | - if($source_srl == $target_srl) return; |
|
1067 | + if($source_srl == $target_srl) { |
|
1068 | + return; |
|
1069 | + } |
|
945 | 1070 | |
946 | 1071 | $oFileModel = getModel('file'); |
947 | 1072 | $file_list = $oFileModel->getFiles($source_srl); |
948 | - if(!$file_list) return; |
|
1073 | + if(!$file_list) { |
|
1074 | + return; |
|
1075 | + } |
|
949 | 1076 | |
950 | 1077 | $file_count = count($file_list); |
951 | 1078 | |
@@ -959,15 +1086,16 @@ discard block |
||
959 | 1086 | { |
960 | 1087 | $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
961 | 1088 | $new_file = $path.$file_info->source_filename; |
962 | - } |
|
963 | - else |
|
1089 | + } else |
|
964 | 1090 | { |
965 | 1091 | $path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl); |
966 | 1092 | $random = new Password(); |
967 | 1093 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
968 | 1094 | } |
969 | 1095 | // Pass if a target document to move is same |
970 | - if($old_file == $new_file) continue; |
|
1096 | + if($old_file == $new_file) { |
|
1097 | + continue; |
|
1098 | + } |
|
971 | 1099 | // Create a directory |
972 | 1100 | FileHandler::makeDir($path); |
973 | 1101 | // Move the file |
@@ -987,16 +1115,22 @@ discard block |
||
987 | 1115 | $vars = Context::getRequestVars(); |
988 | 1116 | $logged_info = Context::get('logged_info'); |
989 | 1117 | |
990 | - if(!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request'); |
|
1118 | + if(!$vars->editor_sequence) { |
|
1119 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
1120 | + } |
|
991 | 1121 | |
992 | 1122 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
993 | 1123 | |
994 | 1124 | $oFileModel = getModel('file'); |
995 | 1125 | $file_info = $oFileModel->getFile($vars->file_srl); |
996 | 1126 | |
997 | - if(!$file_info) return new BaseObject(-1, 'msg_not_founded'); |
|
1127 | + if(!$file_info) { |
|
1128 | + return new BaseObject(-1, 'msg_not_founded'); |
|
1129 | + } |
|
998 | 1130 | |
999 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted'); |
|
1131 | + if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) { |
|
1132 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
1133 | + } |
|
1000 | 1134 | |
1001 | 1135 | $args = new stdClass(); |
1002 | 1136 | $args->file_srl = $vars->file_srl; |
@@ -19,20 +19,20 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function triggerArrangeTag(&$obj) |
21 | 21 | { |
22 | - if(!$obj->tags) return new BaseObject(); |
|
22 | + if (!$obj->tags) return new BaseObject(); |
|
23 | 23 | // tags by variable |
24 | 24 | $tag_list = explode(',', $obj->tags); |
25 | 25 | $tag_count = count($tag_list); |
26 | 26 | $tag_list = array_unique($tag_list); |
27 | - if(!count($tag_list)) return new BaseObject(); |
|
27 | + if (!count($tag_list)) return new BaseObject(); |
|
28 | 28 | |
29 | - foreach($tag_list as $tag) |
|
29 | + foreach ($tag_list as $tag) |
|
30 | 30 | { |
31 | - if(!trim($tag)) continue; |
|
31 | + if (!trim($tag)) continue; |
|
32 | 32 | $arranged_tag_list[] = trim($tag); |
33 | 33 | } |
34 | - if(!count($arranged_tag_list)) $obj->tags = null; |
|
35 | - else $obj->tags = implode(',',$arranged_tag_list); |
|
34 | + if (!count($arranged_tag_list)) $obj->tags = null; |
|
35 | + else $obj->tags = implode(',', $arranged_tag_list); |
|
36 | 36 | return new BaseObject(); |
37 | 37 | } |
38 | 38 | |
@@ -45,24 +45,24 @@ discard block |
||
45 | 45 | $module_srl = $obj->module_srl; |
46 | 46 | $document_srl = $obj->document_srl; |
47 | 47 | $tags = $obj->tags; |
48 | - if(!$document_srl) return new BaseObject(); |
|
48 | + if (!$document_srl) return new BaseObject(); |
|
49 | 49 | // Remove all tags that article |
50 | 50 | $output = $this->triggerDeleteTag($obj); |
51 | - if(!$output->toBool()) return $output; |
|
51 | + if (!$output->toBool()) return $output; |
|
52 | 52 | // Re-enter the tag |
53 | 53 | $args = new stdClass(); |
54 | 54 | $args->module_srl = $module_srl; |
55 | 55 | $args->document_srl = $document_srl; |
56 | 56 | |
57 | - $tag_list = explode(',',$tags); |
|
57 | + $tag_list = explode(',', $tags); |
|
58 | 58 | $tag_count = count($tag_list); |
59 | - for($i=0;$i<$tag_count;$i++) |
|
59 | + for ($i = 0; $i < $tag_count; $i++) |
|
60 | 60 | { |
61 | 61 | unset($args->tag); |
62 | 62 | $args->tag = trim($tag_list[$i]); |
63 | - if(!$args->tag) continue; |
|
63 | + if (!$args->tag) continue; |
|
64 | 64 | $output = executeQuery('tag.insertTag', $args); |
65 | - if(!$output->toBool()) return $output; |
|
65 | + if (!$output->toBool()) return $output; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | return new BaseObject(); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | function triggerDeleteTag(&$obj) |
76 | 76 | { |
77 | 77 | $document_srl = $obj->document_srl; |
78 | - if(!$document_srl) return new BaseObject(); |
|
78 | + if (!$document_srl) return new BaseObject(); |
|
79 | 79 | |
80 | 80 | $args = new stdClass(); |
81 | 81 | $args->document_srl = $document_srl; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | function triggerDeleteModuleTags(&$obj) |
89 | 89 | { |
90 | 90 | $module_srl = $obj->module_srl; |
91 | - if(!$module_srl) return new BaseObject(); |
|
91 | + if (!$module_srl) return new BaseObject(); |
|
92 | 92 | |
93 | 93 | $oTagController = getAdminController('tag'); |
94 | 94 | return $oTagController->deleteModuleTags($module_srl); |
@@ -19,20 +19,29 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function triggerArrangeTag(&$obj) |
21 | 21 | { |
22 | - if(!$obj->tags) return new BaseObject(); |
|
22 | + if(!$obj->tags) { |
|
23 | + return new BaseObject(); |
|
24 | + } |
|
23 | 25 | // tags by variable |
24 | 26 | $tag_list = explode(',', $obj->tags); |
25 | 27 | $tag_count = count($tag_list); |
26 | 28 | $tag_list = array_unique($tag_list); |
27 | - if(!count($tag_list)) return new BaseObject(); |
|
29 | + if(!count($tag_list)) { |
|
30 | + return new BaseObject(); |
|
31 | + } |
|
28 | 32 | |
29 | 33 | foreach($tag_list as $tag) |
30 | 34 | { |
31 | - if(!trim($tag)) continue; |
|
35 | + if(!trim($tag)) { |
|
36 | + continue; |
|
37 | + } |
|
32 | 38 | $arranged_tag_list[] = trim($tag); |
33 | 39 | } |
34 | - if(!count($arranged_tag_list)) $obj->tags = null; |
|
35 | - else $obj->tags = implode(',',$arranged_tag_list); |
|
40 | + if(!count($arranged_tag_list)) { |
|
41 | + $obj->tags = null; |
|
42 | + } else { |
|
43 | + $obj->tags = implode(',',$arranged_tag_list); |
|
44 | + } |
|
36 | 45 | return new BaseObject(); |
37 | 46 | } |
38 | 47 | |
@@ -45,10 +54,14 @@ discard block |
||
45 | 54 | $module_srl = $obj->module_srl; |
46 | 55 | $document_srl = $obj->document_srl; |
47 | 56 | $tags = $obj->tags; |
48 | - if(!$document_srl) return new BaseObject(); |
|
57 | + if(!$document_srl) { |
|
58 | + return new BaseObject(); |
|
59 | + } |
|
49 | 60 | // Remove all tags that article |
50 | 61 | $output = $this->triggerDeleteTag($obj); |
51 | - if(!$output->toBool()) return $output; |
|
62 | + if(!$output->toBool()) { |
|
63 | + return $output; |
|
64 | + } |
|
52 | 65 | // Re-enter the tag |
53 | 66 | $args = new stdClass(); |
54 | 67 | $args->module_srl = $module_srl; |
@@ -60,9 +73,13 @@ discard block |
||
60 | 73 | { |
61 | 74 | unset($args->tag); |
62 | 75 | $args->tag = trim($tag_list[$i]); |
63 | - if(!$args->tag) continue; |
|
76 | + if(!$args->tag) { |
|
77 | + continue; |
|
78 | + } |
|
64 | 79 | $output = executeQuery('tag.insertTag', $args); |
65 | - if(!$output->toBool()) return $output; |
|
80 | + if(!$output->toBool()) { |
|
81 | + return $output; |
|
82 | + } |
|
66 | 83 | } |
67 | 84 | |
68 | 85 | return new BaseObject(); |
@@ -75,7 +92,9 @@ discard block |
||
75 | 92 | function triggerDeleteTag(&$obj) |
76 | 93 | { |
77 | 94 | $document_srl = $obj->document_srl; |
78 | - if(!$document_srl) return new BaseObject(); |
|
95 | + if(!$document_srl) { |
|
96 | + return new BaseObject(); |
|
97 | + } |
|
79 | 98 | |
80 | 99 | $args = new stdClass(); |
81 | 100 | $args->document_srl = $document_srl; |
@@ -88,7 +107,9 @@ discard block |
||
88 | 107 | function triggerDeleteModuleTags(&$obj) |
89 | 108 | { |
90 | 109 | $module_srl = $obj->module_srl; |
91 | - if(!$module_srl) return new BaseObject(); |
|
110 | + if(!$module_srl) { |
|
111 | + return new BaseObject(); |
|
112 | + } |
|
92 | 113 | |
93 | 114 | $oTagController = getAdminController('tag'); |
94 | 115 | return $oTagController->deleteModuleTags($module_srl); |
@@ -28,29 +28,29 @@ discard block |
||
28 | 28 | $current_module_srl = Context::get('module_srl'); |
29 | 29 | $site_module_info = Context::get('site_module_info'); |
30 | 30 | |
31 | - if(is_array($current_module_srl)) |
|
31 | + if (is_array($current_module_srl)) |
|
32 | 32 | { |
33 | 33 | unset($current_module_srl); |
34 | 34 | } |
35 | - if(!$current_module_srl) { |
|
35 | + if (!$current_module_srl) { |
|
36 | 36 | $current_module_info = Context::get('current_module_info'); |
37 | 37 | $current_module_srl = $current_module_info->module_srl; |
38 | 38 | } |
39 | 39 | |
40 | - if(!$current_module_srl) return new BaseObject(); |
|
40 | + if (!$current_module_srl) return new BaseObject(); |
|
41 | 41 | // Imported rss settings of the selected module |
42 | 42 | $oRssModel = getModel('rss'); |
43 | 43 | $rss_config = $oRssModel->getRssModuleConfig($current_module_srl); |
44 | 44 | |
45 | - if($rss_config->open_rss != 'N') |
|
45 | + if ($rss_config->open_rss != 'N') |
|
46 | 46 | { |
47 | 47 | Context::set('rss_url', $oRssModel->getModuleFeedUrl(Context::get('vid'), Context::get('mid'), 'rss')); |
48 | 48 | Context::set('atom_url', $oRssModel->getModuleFeedUrl(Context::get('vid'), Context::get('mid'), 'atom')); |
49 | 49 | } |
50 | 50 | |
51 | - if(Context::isInstalled() && $site_module_info->mid == Context::get('mid') && $total_config->use_total_feed != 'N') |
|
51 | + if (Context::isInstalled() && $site_module_info->mid == Context::get('mid') && $total_config->use_total_feed != 'N') |
|
52 | 52 | { |
53 | - if(Context::isAllowRewrite() && !Context::get('vid')) |
|
53 | + if (Context::isAllowRewrite() && !Context::get('vid')) |
|
54 | 54 | { |
55 | 55 | $request_uri = Context::getRequestUri(); |
56 | 56 | Context::set('general_rss_url', $request_uri.'rss'); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | } |
59 | 59 | else |
60 | 60 | { |
61 | - Context::set('general_rss_url', getUrl('','module','rss','act','rss')); |
|
62 | - Context::set('general_atom_url', getUrl('','module','rss','act','atom')); |
|
61 | + Context::set('general_rss_url', getUrl('', 'module', 'rss', 'act', 'rss')); |
|
62 | + Context::set('general_atom_url', getUrl('', 'module', 'rss', 'act', 'atom')); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | $rssConfig = $oModuleModel->getModulePartConfig('rss', $obj->originModuleSrl); |
73 | 73 | |
74 | 74 | $oModuleController = getController('module'); |
75 | - if(is_array($obj->moduleSrlList)) |
|
75 | + if (is_array($obj->moduleSrlList)) |
|
76 | 76 | { |
77 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
77 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
78 | 78 | { |
79 | 79 | $oModuleController->insertModulePartConfig('rss', $moduleSrl, $rssConfig); |
80 | 80 | } |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | $current_module_srl = $current_module_info->module_srl; |
38 | 38 | } |
39 | 39 | |
40 | - if(!$current_module_srl) return new BaseObject(); |
|
40 | + if(!$current_module_srl) { |
|
41 | + return new BaseObject(); |
|
42 | + } |
|
41 | 43 | // Imported rss settings of the selected module |
42 | 44 | $oRssModel = getModel('rss'); |
43 | 45 | $rss_config = $oRssModel->getRssModuleConfig($current_module_srl); |
@@ -55,8 +57,7 @@ discard block |
||
55 | 57 | $request_uri = Context::getRequestUri(); |
56 | 58 | Context::set('general_rss_url', $request_uri.'rss'); |
57 | 59 | Context::set('general_atom_url', $request_uri.'atom'); |
58 | - } |
|
59 | - else |
|
60 | + } else |
|
60 | 61 | { |
61 | 62 | Context::set('general_rss_url', getUrl('','module','rss','act','rss')); |
62 | 63 | Context::set('general_atom_url', getUrl('','module','rss','act','atom')); |
@@ -30,24 +30,24 @@ discard block |
||
30 | 30 | $oModuleModel = getModel('module'); |
31 | 31 | $oModuleController = getController('module'); |
32 | 32 | // Get the content and information for the current requested module if the method is not called from another module |
33 | - if(!$document_list) |
|
33 | + if (!$document_list) |
|
34 | 34 | { |
35 | 35 | $site_module_info = Context::get('site_module_info'); |
36 | 36 | $site_srl = $site_module_info->site_srl; |
37 | 37 | $mid = Context::getRequestVars()->mid; // The target module id, if absent, then all |
38 | - $start_date = (int)Context::get('start_date'); |
|
39 | - $end_date = (int)Context::get('end_date'); |
|
38 | + $start_date = (int) Context::get('start_date'); |
|
39 | + $end_date = (int) Context::get('end_date'); |
|
40 | 40 | |
41 | 41 | $module_srls = array(); |
42 | 42 | $rss_config = array(); |
43 | 43 | $total_config = ''; |
44 | 44 | $total_config = $oModuleModel->getModuleConfig('rss'); |
45 | 45 | // If one is specified, extract only for this mid |
46 | - if($mid) |
|
46 | + if ($mid) |
|
47 | 47 | { |
48 | 48 | $module_srl = $this->module_info->module_srl; |
49 | 49 | $config = $oModuleModel->getModulePartConfig('rss', $module_srl); |
50 | - if($config->open_rss && $config->open_rss != 'N') |
|
50 | + if ($config->open_rss && $config->open_rss != 'N') |
|
51 | 51 | { |
52 | 52 | $module_srls[] = $module_srl; |
53 | 53 | $open_rss_config[$module_srl] = $config->open_rss; |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | } |
57 | 57 | else |
58 | 58 | { |
59 | - if($total_config->use_total_feed != 'N') |
|
59 | + if ($total_config->use_total_feed != 'N') |
|
60 | 60 | { |
61 | 61 | $rss_config = $oModuleModel->getModulePartConfigs('rss', $site_srl); |
62 | - if($rss_config) |
|
62 | + if ($rss_config) |
|
63 | 63 | { |
64 | - foreach($rss_config as $module_srl => $config) |
|
64 | + foreach ($rss_config as $module_srl => $config) |
|
65 | 65 | { |
66 | - if($config && $config->open_rss != 'N' && $config->open_total_feed != 'T_N') |
|
66 | + if ($config && $config->open_rss != 'N' && $config->open_total_feed != 'T_N') |
|
67 | 67 | { |
68 | 68 | $module_srls[] = $module_srl; |
69 | 69 | $open_rss_config[$module_srl] = $config->open_rss; |
@@ -73,39 +73,39 @@ discard block |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - if(!count($module_srls) && !$add_description) return $this->dispError(); |
|
76 | + if (!count($module_srls) && !$add_description) return $this->dispError(); |
|
77 | 77 | |
78 | 78 | $info = new stdClass; |
79 | 79 | $args = new stdClass; |
80 | 80 | |
81 | - if($module_srls) |
|
81 | + if ($module_srls) |
|
82 | 82 | { |
83 | - $args->module_srl = implode(',',$module_srls); |
|
83 | + $args->module_srl = implode(',', $module_srls); |
|
84 | 84 | //$module_list = $oModuleModel->getMidList($args); //perhaps module_list varialbles not use |
85 | 85 | |
86 | 86 | $args->search_target = 'is_secret'; |
87 | 87 | $args->search_keyword = 'N'; |
88 | - $args->page = (int)Context::get('page'); |
|
88 | + $args->page = (int) Context::get('page'); |
|
89 | 89 | $args->list_count = 15; |
90 | - if($total_config->feed_document_count) $args->list_count = $total_config->feed_document_count; |
|
91 | - if(!$args->page || $args->page < 1) $args->page = 1; |
|
92 | - if($start_date || $start_date != 0) $args->start_date = $start_date; |
|
93 | - if($end_date || $end_date != 0) $args->end_date = $end_date; |
|
94 | - if($start_date == 0) unset($start_date); |
|
95 | - if($end_date == 0) unset($end_date); |
|
90 | + if ($total_config->feed_document_count) $args->list_count = $total_config->feed_document_count; |
|
91 | + if (!$args->page || $args->page < 1) $args->page = 1; |
|
92 | + if ($start_date || $start_date != 0) $args->start_date = $start_date; |
|
93 | + if ($end_date || $end_date != 0) $args->end_date = $end_date; |
|
94 | + if ($start_date == 0) unset($start_date); |
|
95 | + if ($end_date == 0) unset($end_date); |
|
96 | 96 | |
97 | 97 | $args->sort_index = 'list_order'; |
98 | 98 | $args->order_type = 'asc'; |
99 | 99 | $output = $oDocumentModel->getDocumentList($args); |
100 | 100 | $document_list = $output->data; |
101 | 101 | // Extract the feed title and information with Context::getBrowserTitle |
102 | - if($mid) |
|
102 | + if ($mid) |
|
103 | 103 | { |
104 | 104 | $info->title = Context::getBrowserTitle(); |
105 | 105 | $oModuleController->replaceDefinedLangCode($info->title); |
106 | 106 | |
107 | - $info->title = str_replace('\'', ''',$info->title); |
|
108 | - if($config->feed_description) |
|
107 | + $info->title = str_replace('\'', ''', $info->title); |
|
108 | + if ($config->feed_description) |
|
109 | 109 | { |
110 | 110 | $info->description = str_replace('\'', ''', htmlspecialchars($config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
111 | 111 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | { |
114 | 114 | $info->description = str_replace('\'', ''', htmlspecialchars($this->module_info->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
115 | 115 | } |
116 | - $info->link = getUrl('','mid',$mid); |
|
116 | + $info->link = getUrl('', 'mid', $mid); |
|
117 | 117 | $info->feed_copyright = str_replace('\'', ''', htmlspecialchars($feed_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
118 | - if(!$info->feed_copyright) |
|
118 | + if (!$info->feed_copyright) |
|
119 | 119 | { |
120 | 120 | $info->feed_copyright = str_replace('\'', ''', htmlspecialchars($total_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
121 | 121 | } |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if(!$info->title) |
|
126 | + if (!$info->title) |
|
127 | 127 | { |
128 | - if($rss_title) $info->title = $rss_title; |
|
129 | - else if($total_config->feed_title) $info->title = $total_config->feed_title; |
|
128 | + if ($rss_title) $info->title = $rss_title; |
|
129 | + else if ($total_config->feed_title) $info->title = $total_config->feed_title; |
|
130 | 130 | else |
131 | 131 | { |
132 | 132 | $site_module_info = Context::get('site_module_info'); |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | $info->link = Context::getRequestUri(); |
140 | 140 | $info->feed_copyright = str_replace('\'', ''', htmlspecialchars($total_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
141 | 141 | } |
142 | - if($add_description) $info->description .= "\r\n".$add_description; |
|
142 | + if ($add_description) $info->description .= "\r\n".$add_description; |
|
143 | 143 | |
144 | - if($total_config->image) $info->image = Context::getRequestUri().str_replace('\'', ''', htmlspecialchars($total_config->image, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
145 | - switch(Context::get('format')) |
|
144 | + if ($total_config->image) $info->image = Context::getRequestUri().str_replace('\'', ''', htmlspecialchars($total_config->image, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
145 | + switch (Context::get('format')) |
|
146 | 146 | { |
147 | 147 | case 'atom': |
148 | 148 | $info->date = date('Y-m-d\TH:i:sP'); |
149 | - if($mid) { $info->id = getUrl('','mid',$mid,'act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } |
|
150 | - else { $info->id = getUrl('','module','rss','act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } |
|
149 | + if ($mid) { $info->id = getUrl('', 'mid', $mid, 'act', 'atom', 'page', Context::get('page'), 'start_date', Context::get('start_date'), 'end_date', Context::get('end_date')); } |
|
150 | + else { $info->id = getUrl('', 'module', 'rss', 'act', 'atom', 'page', Context::get('page'), 'start_date', Context::get('start_date'), 'end_date', Context::get('end_date')); } |
|
151 | 151 | break; |
152 | 152 | case 'rss1.0': |
153 | 153 | $info->date = date('Y-m-d\TH:i:sP'); |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | break; |
158 | 158 | } |
159 | 159 | |
160 | - if($_SERVER['HTTPS']=='on') $proctcl = 'https://'; |
|
160 | + if ($_SERVER['HTTPS'] == 'on') $proctcl = 'https://'; |
|
161 | 161 | else $proctcl = 'http://'; |
162 | 162 | |
163 | 163 | $temp_link = explode('/', $info->link); |
164 | - if($temp_link[0]=='' && $info->link) |
|
164 | + if ($temp_link[0] == '' && $info->link) |
|
165 | 165 | { |
166 | 166 | $info->link = $proctcl.$_SERVER['HTTP_HOST'].$info->link; |
167 | 167 | } |
168 | 168 | |
169 | 169 | $temp_id = explode('/', $info->id); |
170 | - if($temp_id[0]=='' && $info->id) |
|
170 | + if ($temp_id[0] == '' && $info->id) |
|
171 | 171 | { |
172 | 172 | $info->id = $proctcl.$_SERVER['HTTP_HOST'].$info->id; |
173 | 173 | } |
174 | 174 | |
175 | - $info->language = str_replace('jp','ja',Context::getLangType()); |
|
175 | + $info->language = str_replace('jp', 'ja', Context::getLangType()); |
|
176 | 176 | // Set the variables used in the RSS output |
177 | 177 | Context::set('info', $info); |
178 | 178 | Context::set('feed_config', $config); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | function dispError() |
229 | 229 | { |
230 | 230 | // Prepare the output message |
231 | - $this->rss(null, null, Context::getLang('msg_rss_is_disabled') ); |
|
231 | + $this->rss(null, null, Context::getLang('msg_rss_is_disabled')); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | $current_module_srl = Context::get('module_srl'); |
244 | 244 | $current_module_srls = Context::get('module_srls'); |
245 | 245 | |
246 | - if(!$current_module_srl && !$current_module_srls) |
|
246 | + if (!$current_module_srl && !$current_module_srls) |
|
247 | 247 | { |
248 | 248 | // Get information of the selected module |
249 | 249 | $current_module_info = Context::get('current_module_info'); |
250 | 250 | $current_module_srl = $current_module_info->module_srl; |
251 | - if(!$current_module_srl) return new BaseObject(); |
|
251 | + if (!$current_module_srl) return new BaseObject(); |
|
252 | 252 | } |
253 | 253 | // Get teh RSS configurations for the selected module |
254 | 254 | $oRssModel = getModel('rss'); |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | $open_rss_config[$module_srl] = $config->open_rss; |
54 | 54 | } |
55 | 55 | // If mid is not selected, then get all |
56 | - } |
|
57 | - else |
|
56 | + } else |
|
58 | 57 | { |
59 | 58 | if($total_config->use_total_feed != 'N') |
60 | 59 | { |
@@ -73,7 +72,9 @@ discard block |
||
73 | 72 | } |
74 | 73 | } |
75 | 74 | |
76 | - if(!count($module_srls) && !$add_description) return $this->dispError(); |
|
75 | + if(!count($module_srls) && !$add_description) { |
|
76 | + return $this->dispError(); |
|
77 | + } |
|
77 | 78 | |
78 | 79 | $info = new stdClass; |
79 | 80 | $args = new stdClass; |
@@ -87,12 +88,24 @@ discard block |
||
87 | 88 | $args->search_keyword = 'N'; |
88 | 89 | $args->page = (int)Context::get('page'); |
89 | 90 | $args->list_count = 15; |
90 | - if($total_config->feed_document_count) $args->list_count = $total_config->feed_document_count; |
|
91 | - if(!$args->page || $args->page < 1) $args->page = 1; |
|
92 | - if($start_date || $start_date != 0) $args->start_date = $start_date; |
|
93 | - if($end_date || $end_date != 0) $args->end_date = $end_date; |
|
94 | - if($start_date == 0) unset($start_date); |
|
95 | - if($end_date == 0) unset($end_date); |
|
91 | + if($total_config->feed_document_count) { |
|
92 | + $args->list_count = $total_config->feed_document_count; |
|
93 | + } |
|
94 | + if(!$args->page || $args->page < 1) { |
|
95 | + $args->page = 1; |
|
96 | + } |
|
97 | + if($start_date || $start_date != 0) { |
|
98 | + $args->start_date = $start_date; |
|
99 | + } |
|
100 | + if($end_date || $end_date != 0) { |
|
101 | + $args->end_date = $end_date; |
|
102 | + } |
|
103 | + if($start_date == 0) { |
|
104 | + unset($start_date); |
|
105 | + } |
|
106 | + if($end_date == 0) { |
|
107 | + unset($end_date); |
|
108 | + } |
|
96 | 109 | |
97 | 110 | $args->sort_index = 'list_order'; |
98 | 111 | $args->order_type = 'asc'; |
@@ -108,8 +121,7 @@ discard block |
||
108 | 121 | if($config->feed_description) |
109 | 122 | { |
110 | 123 | $info->description = str_replace('\'', ''', htmlspecialchars($config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
111 | - } |
|
112 | - else |
|
124 | + } else |
|
113 | 125 | { |
114 | 126 | $info->description = str_replace('\'', ''', htmlspecialchars($this->module_info->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
115 | 127 | } |
@@ -125,9 +137,11 @@ discard block |
||
125 | 137 | |
126 | 138 | if(!$info->title) |
127 | 139 | { |
128 | - if($rss_title) $info->title = $rss_title; |
|
129 | - else if($total_config->feed_title) $info->title = $total_config->feed_title; |
|
130 | - else |
|
140 | + if($rss_title) { |
|
141 | + $info->title = $rss_title; |
|
142 | + } else if($total_config->feed_title) { |
|
143 | + $info->title = $total_config->feed_title; |
|
144 | + } else |
|
131 | 145 | { |
132 | 146 | $site_module_info = Context::get('site_module_info'); |
133 | 147 | $info->title = $site_module_info->browser_title; |
@@ -139,15 +153,18 @@ discard block |
||
139 | 153 | $info->link = Context::getRequestUri(); |
140 | 154 | $info->feed_copyright = str_replace('\'', ''', htmlspecialchars($total_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
141 | 155 | } |
142 | - if($add_description) $info->description .= "\r\n".$add_description; |
|
156 | + if($add_description) { |
|
157 | + $info->description .= "\r\n".$add_description; |
|
158 | + } |
|
143 | 159 | |
144 | - if($total_config->image) $info->image = Context::getRequestUri().str_replace('\'', ''', htmlspecialchars($total_config->image, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
160 | + if($total_config->image) { |
|
161 | + $info->image = Context::getRequestUri().str_replace('\'', ''', htmlspecialchars($total_config->image, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
162 | + } |
|
145 | 163 | switch(Context::get('format')) |
146 | 164 | { |
147 | 165 | case 'atom': |
148 | 166 | $info->date = date('Y-m-d\TH:i:sP'); |
149 | - if($mid) { $info->id = getUrl('','mid',$mid,'act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } |
|
150 | - else { $info->id = getUrl('','module','rss','act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } |
|
167 | + if($mid) { $info->id = getUrl('','mid',$mid,'act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } else { $info->id = getUrl('','module','rss','act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } |
|
151 | 168 | break; |
152 | 169 | case 'rss1.0': |
153 | 170 | $info->date = date('Y-m-d\TH:i:sP'); |
@@ -157,8 +174,11 @@ discard block |
||
157 | 174 | break; |
158 | 175 | } |
159 | 176 | |
160 | - if($_SERVER['HTTPS']=='on') $proctcl = 'https://'; |
|
161 | - else $proctcl = 'http://'; |
|
177 | + if($_SERVER['HTTPS']=='on') { |
|
178 | + $proctcl = 'https://'; |
|
179 | + } else { |
|
180 | + $proctcl = 'http://'; |
|
181 | + } |
|
162 | 182 | |
163 | 183 | $temp_link = explode('/', $info->link); |
164 | 184 | if($temp_link[0]=='' && $info->link) |
@@ -248,7 +268,9 @@ discard block |
||
248 | 268 | // Get information of the selected module |
249 | 269 | $current_module_info = Context::get('current_module_info'); |
250 | 270 | $current_module_srl = $current_module_info->module_srl; |
251 | - if(!$current_module_srl) return new BaseObject(); |
|
271 | + if(!$current_module_srl) { |
|
272 | + return new BaseObject(); |
|
273 | + } |
|
252 | 274 | } |
253 | 275 | // Get teh RSS configurations for the selected module |
254 | 276 | $oRssModel = getModel('rss'); |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | $component = Context::get('component'); |
28 | 28 | |
29 | 29 | $site_module_info = Context::get('site_module_info'); |
30 | - $site_srl = (int)$site_module_info->site_srl; |
|
30 | + $site_srl = (int) $site_module_info->site_srl; |
|
31 | 31 | // Get compoenet object |
32 | 32 | $oEditorModel = getModel('editor'); |
33 | 33 | $oComponent = &$oEditorModel->getComponentObject($component, $editor_sequence, $site_srl); |
34 | - if(!$oComponent->toBool()) |
|
34 | + if (!$oComponent->toBool()) |
|
35 | 35 | { |
36 | 36 | Context::set('message', sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
37 | 37 | $this->setTemplatePath($this->module_path.'tpl'); |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | $component_name = Context::get('component_name'); |
59 | 59 | |
60 | 60 | $site_module_info = Context::get('site_module_info'); |
61 | - $site_srl = (int)$site_module_info->site_srl; |
|
61 | + $site_srl = (int) $site_module_info->site_srl; |
|
62 | 62 | |
63 | 63 | $oEditorModel = getModel('editor'); |
64 | 64 | $component = $oEditorModel->getComponent($component_name, $site_srl); |
65 | 65 | |
66 | - if(!$component->component_name) { |
|
66 | + if (!$component->component_name) { |
|
67 | 67 | $this->stop('msg_invalid_request'); |
68 | 68 | return; |
69 | 69 | } |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | $current_module_srl = Context::get('module_srl'); |
84 | 84 | $current_module_srls = Context::get('module_srls'); |
85 | 85 | |
86 | - if(!$current_module_srl && !$current_module_srls) |
|
86 | + if (!$current_module_srl && !$current_module_srls) |
|
87 | 87 | { |
88 | 88 | // Get information of the current module |
89 | 89 | $current_module_info = Context::get('current_module_info'); |
90 | 90 | $current_module_srl = $current_module_info->module_srl; |
91 | - if(!$current_module_srl) return new BaseObject(); |
|
91 | + if (!$current_module_srl) return new BaseObject(); |
|
92 | 92 | } |
93 | 93 | // Get editors settings |
94 | 94 | $oEditorModel = getModel('editor'); |
@@ -101,17 +101,17 @@ discard block |
||
101 | 101 | $editor_skin_list = FileHandler::readDir(_XE_PATH_.'modules/editor/skins'); |
102 | 102 | Context::set('editor_skin_list', $editor_skin_list); |
103 | 103 | |
104 | - $skin_info = $oModuleModel->loadSkinInfo($this->module_path,$editor_config->editor_skin); |
|
104 | + $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $editor_config->editor_skin); |
|
105 | 105 | Context::set('editor_colorset_list', $skin_info->colorset); |
106 | - $skin_info = $oModuleModel->loadSkinInfo($this->module_path,$editor_config->comment_editor_skin); |
|
106 | + $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $editor_config->comment_editor_skin); |
|
107 | 107 | Context::set('editor_comment_colorset_list', $skin_info->colorset); |
108 | 108 | |
109 | 109 | $contents = FileHandler::readDir(_XE_PATH_.'modules/editor/styles'); |
110 | 110 | $content_style_list = array(); |
111 | - for($i=0,$c=count($contents);$i<$c;$i++) |
|
111 | + for ($i = 0, $c = count($contents); $i < $c; $i++) |
|
112 | 112 | { |
113 | 113 | $style = $contents[$i]; |
114 | - $info = $oModuleModel->loadSkinInfo($this->module_path,$style,'styles'); |
|
114 | + $info = $oModuleModel->loadSkinInfo($this->module_path, $style, 'styles'); |
|
115 | 115 | $content_style_list[$style] = new stdClass(); |
116 | 116 | $content_style_list[$style]->title = $info->title; |
117 | 117 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | { |
149 | 149 | $skin = Context::get('skin'); |
150 | 150 | $oModuleModel = getModel('module'); |
151 | - $skin_info = $oModuleModel->loadSkinInfo($this->module_path,$skin); |
|
151 | + $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $skin); |
|
152 | 152 | $colorset = $skin_info->colorset; |
153 | 153 | Context::set('colorset', $colorset); |
154 | 154 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | $mode = Context::get('mode'); |
162 | 162 | |
163 | - if($mode != 'main') |
|
163 | + if ($mode != 'main') |
|
164 | 164 | { |
165 | 165 | $option_com = new stdClass(); |
166 | 166 | $option_com->allow_fileupload = false; |
@@ -36,8 +36,7 @@ discard block |
||
36 | 36 | Context::set('message', sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
37 | 37 | $this->setTemplatePath($this->module_path.'tpl'); |
38 | 38 | $this->setTemplateFile('component_not_founded'); |
39 | - } |
|
40 | - else |
|
39 | + } else |
|
41 | 40 | { |
42 | 41 | // Get the result after executing a method to display popup url of the component |
43 | 42 | $popup_content = $oComponent->getPopupContent(); |
@@ -88,7 +87,9 @@ discard block |
||
88 | 87 | // Get information of the current module |
89 | 88 | $current_module_info = Context::get('current_module_info'); |
90 | 89 | $current_module_srl = $current_module_info->module_srl; |
91 | - if(!$current_module_srl) return new BaseObject(); |
|
90 | + if(!$current_module_srl) { |
|
91 | + return new BaseObject(); |
|
92 | + } |
|
92 | 93 | } |
93 | 94 | // Get editors settings |
94 | 95 | $oEditorModel = getModel('editor'); |
@@ -178,8 +179,7 @@ discard block |
||
178 | 179 | $option_com->content_style = $config->comment_content_style; |
179 | 180 | $option_com->colorset = $config->sel_comment_editor_colorset; |
180 | 181 | $editor = $oEditorModel->getEditor(0, $option_com); |
181 | - } |
|
182 | - else |
|
182 | + } else |
|
183 | 183 | { |
184 | 184 | $option = new stdClass(); |
185 | 185 | $option->allow_fileupload = false; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | $this->editor_sequence = $editor_sequence; |
21 | 21 | $this->component_path = $component_path; |
22 | - $this->emoticon_path = sprintf('%s%s/images',preg_replace('/^\.\//i','',$this->component_path),'tpl','images'); |
|
22 | + $this->emoticon_path = sprintf('%s%s/images', preg_replace('/^\.\//i', '', $this->component_path), 'tpl', 'images'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | function getEmoticonList() |
29 | 29 | { |
30 | 30 | $emoticon = Context::get('emoticon'); |
31 | - if(!$emoticon || !preg_match("/^([a-z0-9\_]+)$/i",$emoticon)) return new BaseObject(-1,'msg_invalid_request'); |
|
31 | + if (!$emoticon || !preg_match("/^([a-z0-9\_]+)$/i", $emoticon)) return new BaseObject(-1, 'msg_invalid_request'); |
|
32 | 32 | |
33 | 33 | $list = $this->getEmoticons($emoticon); |
34 | 34 | |
35 | - $this->add('emoticons', implode("\n",$list)); |
|
35 | + $this->add('emoticons', implode("\n", $list)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | $output = array(); |
45 | 45 | |
46 | 46 | $oDir = dir($emoticon_path); |
47 | - while($file = $oDir->read()) |
|
47 | + while ($file = $oDir->read()) |
|
48 | 48 | { |
49 | - if(substr($file,0,1)=='.') continue; |
|
50 | - if(preg_match('/\.(jpg|jpeg|gif|png)$/i',$file)) $output[] = sprintf("%s/%s", $path, str_replace($this->emoticon_path,'',$file)); |
|
49 | + if (substr($file, 0, 1) == '.') continue; |
|
50 | + if (preg_match('/\.(jpg|jpeg|gif|png)$/i', $file)) $output[] = sprintf("%s/%s", $path, str_replace($this->emoticon_path, '', $file)); |
|
51 | 51 | } |
52 | 52 | $oDir->close(); |
53 | - if(count($output)) asort($output); |
|
53 | + if (count($output)) asort($output); |
|
54 | 54 | return $output; |
55 | 55 | } |
56 | 56 | |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | // Bringing a list of emoticons directory |
63 | 63 | $emoticon_dirs = FileHandler::readDir($this->emoticon_path); |
64 | 64 | $emoticon_list = array(); |
65 | - if($emoticon_dirs) |
|
65 | + if ($emoticon_dirs) |
|
66 | 66 | { |
67 | - foreach($emoticon_dirs as $emoticon) |
|
67 | + foreach ($emoticon_dirs as $emoticon) |
|
68 | 68 | { |
69 | - if(preg_match("/^([a-z0-9\_]+)$/i", $emoticon)) $emoticon_list[] = $emoticon; |
|
69 | + if (preg_match("/^([a-z0-9\_]+)$/i", $emoticon)) $emoticon_list[] = $emoticon; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | Context::set('emoticon_list', $emoticon_list); |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | $src = $xml_obj->attrs->src; |
90 | 90 | $alt = $xml_obj->attrs->alt; |
91 | 91 | |
92 | - if(!$alt) |
|
92 | + if (!$alt) |
|
93 | 93 | { |
94 | - $tmp_arr = explode('/',$src); |
|
94 | + $tmp_arr = explode('/', $src); |
|
95 | 95 | $alt = array_pop($tmp_arr); |
96 | 96 | } |
97 | 97 | |
98 | - $src = str_replace(array('&','"'), array('&','&qout;'), $src); |
|
99 | - if(!$alt) $alt = $src; |
|
98 | + $src = str_replace(array('&', '"'), array('&', '&qout;'), $src); |
|
99 | + if (!$alt) $alt = $src; |
|
100 | 100 | |
101 | 101 | $attr_output = array(); |
102 | 102 | $attr_output = array("src=\"".$src."\""); |
103 | 103 | |
104 | - if($alt) |
|
104 | + if ($alt) |
|
105 | 105 | { |
106 | 106 | $attr_output[] = "alt=\"".$alt."\""; |
107 | 107 | } |
108 | 108 | |
109 | - $code = sprintf("<img %s style=\"border:0px\" />", implode(" ",$attr_output)); |
|
109 | + $code = sprintf("<img %s style=\"border:0px\" />", implode(" ", $attr_output)); |
|
110 | 110 | |
111 | 111 | return $code; |
112 | 112 | } |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | function getEmoticonList() |
29 | 29 | { |
30 | 30 | $emoticon = Context::get('emoticon'); |
31 | - if(!$emoticon || !preg_match("/^([a-z0-9\_]+)$/i",$emoticon)) return new BaseObject(-1,'msg_invalid_request'); |
|
31 | + if(!$emoticon || !preg_match("/^([a-z0-9\_]+)$/i",$emoticon)) { |
|
32 | + return new BaseObject(-1,'msg_invalid_request'); |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $list = $this->getEmoticons($emoticon); |
34 | 36 | |
@@ -46,11 +48,17 @@ discard block |
||
46 | 48 | $oDir = dir($emoticon_path); |
47 | 49 | while($file = $oDir->read()) |
48 | 50 | { |
49 | - if(substr($file,0,1)=='.') continue; |
|
50 | - if(preg_match('/\.(jpg|jpeg|gif|png)$/i',$file)) $output[] = sprintf("%s/%s", $path, str_replace($this->emoticon_path,'',$file)); |
|
51 | + if(substr($file,0,1)=='.') { |
|
52 | + continue; |
|
53 | + } |
|
54 | + if(preg_match('/\.(jpg|jpeg|gif|png)$/i',$file)) { |
|
55 | + $output[] = sprintf("%s/%s", $path, str_replace($this->emoticon_path,'',$file)); |
|
56 | + } |
|
51 | 57 | } |
52 | 58 | $oDir->close(); |
53 | - if(count($output)) asort($output); |
|
59 | + if(count($output)) { |
|
60 | + asort($output); |
|
61 | + } |
|
54 | 62 | return $output; |
55 | 63 | } |
56 | 64 | |
@@ -66,7 +74,9 @@ discard block |
||
66 | 74 | { |
67 | 75 | foreach($emoticon_dirs as $emoticon) |
68 | 76 | { |
69 | - if(preg_match("/^([a-z0-9\_]+)$/i", $emoticon)) $emoticon_list[] = $emoticon; |
|
77 | + if(preg_match("/^([a-z0-9\_]+)$/i", $emoticon)) { |
|
78 | + $emoticon_list[] = $emoticon; |
|
79 | + } |
|
70 | 80 | } |
71 | 81 | } |
72 | 82 | Context::set('emoticon_list', $emoticon_list); |
@@ -96,7 +106,9 @@ discard block |
||
96 | 106 | } |
97 | 107 | |
98 | 108 | $src = str_replace(array('&','"'), array('&','&qout;'), $src); |
99 | - if(!$alt) $alt = $src; |
|
109 | + if(!$alt) { |
|
110 | + $alt = $src; |
|
111 | + } |
|
100 | 112 | |
101 | 113 | $attr_output = array(); |
102 | 114 | $attr_output = array("src=\"".$src."\""); |
@@ -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', getScriptPath() . ltrim($this->module_path, './') . 'styles/' . $option->content_style); |
|
210 | + Context::set('content_style_path', getScriptPath().ltrim($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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
550 | + if (!file_exists($class_file)) return new BaseObject(-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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
554 | + if (!$oComponent) return new BaseObject(-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); |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | } |
676 | 676 | $component = $output->data; |
677 | 677 | |
678 | - if(!$output->data) return false; |
|
678 | + if (!$output->data) return false; |
|
679 | 679 | |
680 | 680 | $component_name = $component->component_name; |
681 | 681 | |
@@ -687,25 +687,25 @@ discard block |
||
687 | 687 | |
688 | 688 | $xml_info->mid_list = array(); |
689 | 689 | |
690 | - if($component->extra_vars) |
|
690 | + if ($component->extra_vars) |
|
691 | 691 | { |
692 | 692 | $extra_vars = unserialize($component->extra_vars); |
693 | 693 | |
694 | - if($extra_vars->target_group) |
|
694 | + if ($extra_vars->target_group) |
|
695 | 695 | { |
696 | 696 | $xml_info->target_group = $extra_vars->target_group; |
697 | 697 | unset($extra_vars->target_group); |
698 | 698 | } |
699 | 699 | |
700 | - if($extra_vars->mid_list) |
|
700 | + if ($extra_vars->mid_list) |
|
701 | 701 | { |
702 | 702 | $xml_info->mid_list = $extra_vars->mid_list; |
703 | 703 | unset($extra_vars->mid_list); |
704 | 704 | } |
705 | 705 | |
706 | - if($xml_info->extra_vars) |
|
706 | + if ($xml_info->extra_vars) |
|
707 | 707 | { |
708 | - foreach($xml_info->extra_vars as $key => $val) |
|
708 | + foreach ($xml_info->extra_vars as $key => $val) |
|
709 | 709 | { |
710 | 710 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
711 | 711 | } |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | $cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); |
730 | 730 | |
731 | 731 | // Include and return xml file information if cached file exists |
732 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
732 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
733 | 733 | { |
734 | 734 | include($cache_file); |
735 | 735 | |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $component_info->component_name = $component; |
747 | 747 | $component_info->title = $xml_doc->component->title->body; |
748 | 748 | |
749 | - if($xml_doc->component->version) |
|
749 | + if ($xml_doc->component->version) |
|
750 | 750 | { |
751 | 751 | $component_info->description = str_replace('\n', "\n", $xml_doc->component->description->body); |
752 | 752 | $component_info->version = $xml_doc->component->version->body; |
@@ -772,10 +772,10 @@ discard block |
||
772 | 772 | |
773 | 773 | // Author information |
774 | 774 | $author_list = array(); |
775 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
775 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
776 | 776 | else $author_list = $xml_doc->component->author; |
777 | 777 | |
778 | - for($i = 0; $i < count($author_list); $i++) |
|
778 | + for ($i = 0; $i < count($author_list); $i++) |
|
779 | 779 | { |
780 | 780 | $author = new stdClass; |
781 | 781 | $author->name = $author_list[$i]->name->body; |
@@ -786,39 +786,39 @@ discard block |
||
786 | 786 | |
787 | 787 | // List extra variables (text type only for editor component) |
788 | 788 | $extra_vars = $xml_doc->component->extra_vars; |
789 | - if($extra_vars) |
|
789 | + if ($extra_vars) |
|
790 | 790 | { |
791 | 791 | $extra_var_groups = $extra_vars->group; |
792 | - if(!$extra_var_groups) |
|
792 | + if (!$extra_var_groups) |
|
793 | 793 | { |
794 | 794 | $extra_var_groups = $extra_vars; |
795 | 795 | } |
796 | - if(!is_array($extra_var_groups)) |
|
796 | + if (!is_array($extra_var_groups)) |
|
797 | 797 | { |
798 | 798 | $extra_var_groups = array($extra_var_groups); |
799 | 799 | } |
800 | 800 | |
801 | - foreach($extra_var_groups as $group) |
|
801 | + foreach ($extra_var_groups as $group) |
|
802 | 802 | { |
803 | 803 | $extra_vars = $group->var; |
804 | - if(!is_array($group->var)) |
|
804 | + if (!is_array($group->var)) |
|
805 | 805 | { |
806 | 806 | $extra_vars = array($group->var); |
807 | 807 | } |
808 | 808 | |
809 | - foreach($extra_vars as $key => $val) |
|
809 | + foreach ($extra_vars as $key => $val) |
|
810 | 810 | { |
811 | - if(!$val) |
|
811 | + if (!$val) |
|
812 | 812 | { |
813 | 813 | continue; |
814 | 814 | } |
815 | 815 | |
816 | 816 | $obj = new stdClass(); |
817 | - if(!$val->attrs) |
|
817 | + if (!$val->attrs) |
|
818 | 818 | { |
819 | 819 | $val->attrs = new stdClass(); |
820 | 820 | } |
821 | - if(!$val->attrs->type) |
|
821 | + if (!$val->attrs->type) |
|
822 | 822 | { |
823 | 823 | $val->attrs->type = 'text'; |
824 | 824 | } |
@@ -828,26 +828,26 @@ discard block |
||
828 | 828 | $obj->title = $val->title->body; |
829 | 829 | $obj->type = $val->attrs->type; |
830 | 830 | $obj->description = $val->description->body; |
831 | - if($obj->name) |
|
831 | + if ($obj->name) |
|
832 | 832 | { |
833 | 833 | $obj->value = $extra_vals->{$obj->name}; |
834 | 834 | } |
835 | - if(strpos($obj->value, '|@|') != FALSE) |
|
835 | + if (strpos($obj->value, '|@|') != FALSE) |
|
836 | 836 | { |
837 | 837 | $obj->value = explode('|@|', $obj->value); |
838 | 838 | } |
839 | - if($obj->type == 'mid_list' && !is_array($obj->value)) |
|
839 | + if ($obj->type == 'mid_list' && !is_array($obj->value)) |
|
840 | 840 | { |
841 | 841 | $obj->value = array($obj->value); |
842 | 842 | } |
843 | 843 | |
844 | 844 | // 'Select'type obtained from the option list. |
845 | - if($val->options && !is_array($val->options)) |
|
845 | + if ($val->options && !is_array($val->options)) |
|
846 | 846 | { |
847 | 847 | $val->options = array($val->options); |
848 | 848 | } |
849 | 849 | |
850 | - for($i = 0, $c = count($val->options); $i < $c; $i++) |
|
850 | + for ($i = 0, $c = count($val->options); $i < $c; $i++) |
|
851 | 851 | { |
852 | 852 | $obj->options[$i] = new stdClass(); |
853 | 853 | $obj->options[$i]->title = $val->options[$i]->title->body; |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | |
862 | 862 | $buff = array(); |
863 | 863 | $buff[] = '<?php if(!defined(\'__XE__\')) exit();'; |
864 | - $buff[] = '$xml_info = ' . var_export($component_info, TRUE) . ';'; |
|
864 | + $buff[] = '$xml_info = '.var_export($component_info, TRUE).';'; |
|
865 | 865 | $buff = str_replace('stdClass::__set_state', '(object)', implode(PHP_EOL, $buff)); |
866 | 866 | |
867 | 867 | FileHandler::writeFile($cache_file, $buff, 'w'); |
@@ -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', getScriptPath() . ltrim($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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
620 | + if(!file_exists($class_file)) { |
|
621 | + return new BaseObject(-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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
626 | + if(!$oComponent) { |
|
627 | + return new BaseObject(-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,14 +758,15 @@ 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 | } |
676 | 765 | $component = $output->data; |
677 | 766 | |
678 | - if(!$output->data) return false; |
|
767 | + if(!$output->data) { |
|
768 | + return false; |
|
769 | + } |
|
679 | 770 | |
680 | 771 | $component_name = $component->component_name; |
681 | 772 | |
@@ -754,8 +845,7 @@ discard block |
||
754 | 845 | $component_info->homepage = $xml_doc->component->link->body; |
755 | 846 | $component_info->license = $xml_doc->component->license->body; |
756 | 847 | $component_info->license_link = $xml_doc->component->license->attrs->link; |
757 | - } |
|
758 | - else |
|
848 | + } else |
|
759 | 849 | { |
760 | 850 | sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); |
761 | 851 | $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
@@ -772,8 +862,11 @@ discard block |
||
772 | 862 | |
773 | 863 | // Author information |
774 | 864 | $author_list = array(); |
775 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
776 | - else $author_list = $xml_doc->component->author; |
|
865 | + if(!is_array($xml_doc->component->author)) { |
|
866 | + $author_list[] = $xml_doc->component->author; |
|
867 | + } else { |
|
868 | + $author_list = $xml_doc->component->author; |
|
869 | + } |
|
777 | 870 | |
778 | 871 | for($i = 0; $i < count($author_list); $i++) |
779 | 872 | { |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | $enables = Context::get('enables'); |
24 | 24 | $component_names = Context::get('component_names'); |
25 | 25 | |
26 | - if(!is_array($component_names)) $component_names = array(); |
|
27 | - if(!is_array($enables)) $enables = array(); |
|
26 | + if (!is_array($component_names)) $component_names = array(); |
|
27 | + if (!is_array($enables)) $enables = array(); |
|
28 | 28 | |
29 | 29 | $unables = array_diff($component_names, $enables); |
30 | 30 | $componentList = array(); |
31 | 31 | |
32 | - foreach($enables as $component_name) |
|
32 | + foreach ($enables as $component_name) |
|
33 | 33 | { |
34 | 34 | $componentList[$component_name] = 'Y'; |
35 | 35 | } |
36 | - foreach($unables as $component_name) |
|
36 | + foreach ($unables as $component_name) |
|
37 | 37 | { |
38 | 38 | $componentList[$component_name] = 'N'; |
39 | 39 | } |
40 | 40 | |
41 | - $output = $this->editorListOrder($component_names,$site_module_info->site_srl); |
|
42 | - if(!$output->toBool()) return new BaseObject(); |
|
41 | + $output = $this->editorListOrder($component_names, $site_module_info->site_srl); |
|
42 | + if (!$output->toBool()) return new BaseObject(); |
|
43 | 43 | |
44 | - $output = $this->editorCheckUse($componentList,$site_module_info->site_srl); |
|
45 | - if(!$output->toBool()) return new BaseObject(); |
|
44 | + $output = $this->editorCheckUse($componentList, $site_module_info->site_srl); |
|
45 | + if (!$output->toBool()) return new BaseObject(); |
|
46 | 46 | |
47 | 47 | $oEditorController = getController('editor'); |
48 | 48 | $oEditorController->removeCache($site_module_info->site_srl); |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | $args = new stdClass(); |
58 | 58 | $args->site_srl = $site_srl; |
59 | 59 | |
60 | - foreach($componentList as $componentName => $value) |
|
60 | + foreach ($componentList as $componentName => $value) |
|
61 | 61 | { |
62 | 62 | $args->component_name = $componentName; |
63 | 63 | $args->enabled = $value; |
64 | - if($site_srl == 0) |
|
64 | + if ($site_srl == 0) |
|
65 | 65 | { |
66 | 66 | $output = executeQuery('editor.updateComponent', $args); |
67 | 67 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $output = executeQuery('editor.updateSiteComponent', $args); |
71 | 71 | } |
72 | 72 | } |
73 | - if(!$output->toBool()) return new BaseObject(); |
|
73 | + if (!$output->toBool()) return new BaseObject(); |
|
74 | 74 | |
75 | 75 | unset($componentList); |
76 | 76 | return $output; |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | $args = new stdClass(); |
85 | 85 | $args->site_srl = $site_srl; |
86 | 86 | $list_order_num = '30'; |
87 | - if(is_array($component_names)) |
|
87 | + if (is_array($component_names)) |
|
88 | 88 | { |
89 | - foreach($component_names as $name) |
|
89 | + foreach ($component_names as $name) |
|
90 | 90 | { |
91 | 91 | $args->list_order = $list_order_num; |
92 | 92 | $args->component_name = $name; |
93 | - if($site_srl == 0) |
|
93 | + if ($site_srl == 0) |
|
94 | 94 | { |
95 | 95 | $output = executeQuery('editor.updateComponent', $args); |
96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $output = executeQuery('editor.updateSiteComponent', $args); |
100 | 100 | } |
101 | 101 | |
102 | - if(!$output->toBool()) return new BaseObject(); |
|
102 | + if (!$output->toBool()) return new BaseObject(); |
|
103 | 103 | $list_order_num++; |
104 | 104 | } |
105 | 105 | } |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | $args = new stdClass; |
125 | 125 | $args->component_name = $component_name; |
126 | 126 | $args->extra_vars = serialize($extra_vars); |
127 | - $args->site_srl = (int)$site_module_info->site_srl; |
|
127 | + $args->site_srl = (int) $site_module_info->site_srl; |
|
128 | 128 | |
129 | - if(!$args->site_srl) $output = executeQuery('editor.updateComponent', $args); |
|
129 | + if (!$args->site_srl) $output = executeQuery('editor.updateComponent', $args); |
|
130 | 130 | else $output = executeQuery('editor.updateSiteComponent', $args); |
131 | - if(!$output->toBool()) return $output; |
|
131 | + if (!$output->toBool()) return $output; |
|
132 | 132 | |
133 | 133 | $oEditorController = getController('editor'); |
134 | 134 | $oEditorController->removeCache($args->site_srl); |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | $configVars = Context::getRequestVars(); |
147 | 147 | |
148 | 148 | $config = new stdClass; |
149 | - if($configVars->font_defined != 'Y') $config->font_defined = $configVars->font_defined = 'N'; |
|
149 | + if ($configVars->font_defined != 'Y') $config->font_defined = $configVars->font_defined = 'N'; |
|
150 | 150 | else $config->font_defined = 'Y'; |
151 | 151 | |
152 | - if($config->font_defined == 'Y') |
|
152 | + if ($config->font_defined == 'Y') |
|
153 | 153 | $config->content_font = $configVars->content_font_defined; |
154 | 154 | else |
155 | 155 | $config->content_font = $configVars->content_font; |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | $config->comment_editor_height = $configVars->comment_editor_height; |
161 | 161 | $config->content_style = $configVars->content_style; |
162 | 162 | |
163 | - $config->content_font_size= $configVars->content_font_size.'px'; |
|
164 | - $config->sel_editor_colorset= $configVars->sel_editor_colorset; |
|
165 | - $config->sel_comment_editor_colorset= $configVars->sel_comment_editor_colorset; |
|
163 | + $config->content_font_size = $configVars->content_font_size.'px'; |
|
164 | + $config->sel_editor_colorset = $configVars->sel_editor_colorset; |
|
165 | + $config->sel_comment_editor_colorset = $configVars->sel_comment_editor_colorset; |
|
166 | 166 | |
167 | - $oModuleController->insertModuleConfig('editor',$config); |
|
167 | + $oModuleController->insertModuleConfig('editor', $config); |
|
168 | 168 | $this->setRedirectUrl(Context::get('error_return_url')); |
169 | 169 | } |
170 | 170 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | function insertComponent($component_name, $enabled = false, $site_srl = 0) |
175 | 175 | { |
176 | - if($enabled) $enabled = 'Y'; |
|
176 | + if ($enabled) $enabled = 'Y'; |
|
177 | 177 | else $enabled = 'N'; |
178 | 178 | |
179 | 179 | $args = new stdClass; |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | $args->enabled = $enabled; |
182 | 182 | $args->site_srl = $site_srl; |
183 | 183 | // Check if the component exists |
184 | - if(!$site_srl) $output = executeQuery('editor.isComponentInserted', $args); |
|
184 | + if (!$site_srl) $output = executeQuery('editor.isComponentInserted', $args); |
|
185 | 185 | else $output = executeQuery('editor.isSiteComponentInserted', $args); |
186 | - if($output->data->count) return new BaseObject(-1, 'msg_component_is_not_founded'); |
|
186 | + if ($output->data->count) return new BaseObject(-1, 'msg_component_is_not_founded'); |
|
187 | 187 | // Inert a component |
188 | 188 | $args->list_order = getNextSequence(); |
189 | - if(!$site_srl) $output = executeQuery('editor.insertComponent', $args); |
|
189 | + if (!$site_srl) $output = executeQuery('editor.insertComponent', $args); |
|
190 | 190 | else $output = executeQuery('editor.insertSiteComponent', $args); |
191 | 191 | |
192 | 192 | $oEditorController = getController('editor'); |
@@ -23,8 +23,12 @@ discard block |
||
23 | 23 | $enables = Context::get('enables'); |
24 | 24 | $component_names = Context::get('component_names'); |
25 | 25 | |
26 | - if(!is_array($component_names)) $component_names = array(); |
|
27 | - if(!is_array($enables)) $enables = array(); |
|
26 | + if(!is_array($component_names)) { |
|
27 | + $component_names = array(); |
|
28 | + } |
|
29 | + if(!is_array($enables)) { |
|
30 | + $enables = array(); |
|
31 | + } |
|
28 | 32 | |
29 | 33 | $unables = array_diff($component_names, $enables); |
30 | 34 | $componentList = array(); |
@@ -39,10 +43,14 @@ discard block |
||
39 | 43 | } |
40 | 44 | |
41 | 45 | $output = $this->editorListOrder($component_names,$site_module_info->site_srl); |
42 | - if(!$output->toBool()) return new BaseObject(); |
|
46 | + if(!$output->toBool()) { |
|
47 | + return new BaseObject(); |
|
48 | + } |
|
43 | 49 | |
44 | 50 | $output = $this->editorCheckUse($componentList,$site_module_info->site_srl); |
45 | - if(!$output->toBool()) return new BaseObject(); |
|
51 | + if(!$output->toBool()) { |
|
52 | + return new BaseObject(); |
|
53 | + } |
|
46 | 54 | |
47 | 55 | $oEditorController = getController('editor'); |
48 | 56 | $oEditorController->removeCache($site_module_info->site_srl); |
@@ -64,13 +72,14 @@ discard block |
||
64 | 72 | if($site_srl == 0) |
65 | 73 | { |
66 | 74 | $output = executeQuery('editor.updateComponent', $args); |
67 | - } |
|
68 | - else |
|
75 | + } else |
|
69 | 76 | { |
70 | 77 | $output = executeQuery('editor.updateSiteComponent', $args); |
71 | 78 | } |
72 | 79 | } |
73 | - if(!$output->toBool()) return new BaseObject(); |
|
80 | + if(!$output->toBool()) { |
|
81 | + return new BaseObject(); |
|
82 | + } |
|
74 | 83 | |
75 | 84 | unset($componentList); |
76 | 85 | return $output; |
@@ -93,13 +102,14 @@ discard block |
||
93 | 102 | if($site_srl == 0) |
94 | 103 | { |
95 | 104 | $output = executeQuery('editor.updateComponent', $args); |
96 | - } |
|
97 | - else |
|
105 | + } else |
|
98 | 106 | { |
99 | 107 | $output = executeQuery('editor.updateSiteComponent', $args); |
100 | 108 | } |
101 | 109 | |
102 | - if(!$output->toBool()) return new BaseObject(); |
|
110 | + if(!$output->toBool()) { |
|
111 | + return new BaseObject(); |
|
112 | + } |
|
103 | 113 | $list_order_num++; |
104 | 114 | } |
105 | 115 | } |
@@ -126,9 +136,14 @@ discard block |
||
126 | 136 | $args->extra_vars = serialize($extra_vars); |
127 | 137 | $args->site_srl = (int)$site_module_info->site_srl; |
128 | 138 | |
129 | - if(!$args->site_srl) $output = executeQuery('editor.updateComponent', $args); |
|
130 | - else $output = executeQuery('editor.updateSiteComponent', $args); |
|
131 | - if(!$output->toBool()) return $output; |
|
139 | + if(!$args->site_srl) { |
|
140 | + $output = executeQuery('editor.updateComponent', $args); |
|
141 | + } else { |
|
142 | + $output = executeQuery('editor.updateSiteComponent', $args); |
|
143 | + } |
|
144 | + if(!$output->toBool()) { |
|
145 | + return $output; |
|
146 | + } |
|
132 | 147 | |
133 | 148 | $oEditorController = getController('editor'); |
134 | 149 | $oEditorController->removeCache($args->site_srl); |
@@ -146,13 +161,17 @@ discard block |
||
146 | 161 | $configVars = Context::getRequestVars(); |
147 | 162 | |
148 | 163 | $config = new stdClass; |
149 | - if($configVars->font_defined != 'Y') $config->font_defined = $configVars->font_defined = 'N'; |
|
150 | - else $config->font_defined = 'Y'; |
|
164 | + if($configVars->font_defined != 'Y') { |
|
165 | + $config->font_defined = $configVars->font_defined = 'N'; |
|
166 | + } else { |
|
167 | + $config->font_defined = 'Y'; |
|
168 | + } |
|
151 | 169 | |
152 | - if($config->font_defined == 'Y') |
|
153 | - $config->content_font = $configVars->content_font_defined; |
|
154 | - else |
|
155 | - $config->content_font = $configVars->content_font; |
|
170 | + if($config->font_defined == 'Y') { |
|
171 | + $config->content_font = $configVars->content_font_defined; |
|
172 | + } else { |
|
173 | + $config->content_font = $configVars->content_font; |
|
174 | + } |
|
156 | 175 | |
157 | 176 | $config->editor_skin = $configVars->editor_skin; |
158 | 177 | $config->editor_height = $configVars->editor_height; |
@@ -173,21 +192,32 @@ discard block |
||
173 | 192 | */ |
174 | 193 | function insertComponent($component_name, $enabled = false, $site_srl = 0) |
175 | 194 | { |
176 | - if($enabled) $enabled = 'Y'; |
|
177 | - else $enabled = 'N'; |
|
195 | + if($enabled) { |
|
196 | + $enabled = 'Y'; |
|
197 | + } else { |
|
198 | + $enabled = 'N'; |
|
199 | + } |
|
178 | 200 | |
179 | 201 | $args = new stdClass; |
180 | 202 | $args->component_name = $component_name; |
181 | 203 | $args->enabled = $enabled; |
182 | 204 | $args->site_srl = $site_srl; |
183 | 205 | // Check if the component exists |
184 | - if(!$site_srl) $output = executeQuery('editor.isComponentInserted', $args); |
|
185 | - else $output = executeQuery('editor.isSiteComponentInserted', $args); |
|
186 | - if($output->data->count) return new BaseObject(-1, 'msg_component_is_not_founded'); |
|
206 | + if(!$site_srl) { |
|
207 | + $output = executeQuery('editor.isComponentInserted', $args); |
|
208 | + } else { |
|
209 | + $output = executeQuery('editor.isSiteComponentInserted', $args); |
|
210 | + } |
|
211 | + if($output->data->count) { |
|
212 | + return new BaseObject(-1, 'msg_component_is_not_founded'); |
|
213 | + } |
|
187 | 214 | // Inert a component |
188 | 215 | $args->list_order = getNextSequence(); |
189 | - if(!$site_srl) $output = executeQuery('editor.insertComponent', $args); |
|
190 | - else $output = executeQuery('editor.insertSiteComponent', $args); |
|
216 | + if(!$site_srl) { |
|
217 | + $output = executeQuery('editor.insertComponent', $args); |
|
218 | + } else { |
|
219 | + $output = executeQuery('editor.insertSiteComponent', $args); |
|
220 | + } |
|
191 | 221 | |
192 | 222 | $oEditorController = getController('editor'); |
193 | 223 | $oEditorController->removeCache($site_srl); |