@@ -351,6 +351,7 @@ |
||
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Return status by key |
| 354 | + * @param string $key |
|
| 354 | 355 | * @return string |
| 355 | 356 | */ |
| 356 | 357 | function getConfigStatus($key) |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * Search option to use in admin page |
| 18 | 18 | * @var array |
| 19 | 19 | */ |
| 20 | - var $search_option = array('title','content','title_content','user_name',); // /< Search options |
|
| 20 | + var $search_option = array('title', 'content', 'title_content', 'user_name',); // /< Search options |
|
| 21 | 21 | /** |
| 22 | 22 | * Status list |
| 23 | 23 | * @var array |
@@ -34,22 +34,22 @@ discard block |
||
| 34 | 34 | $oModuleController = getController('module'); |
| 35 | 35 | |
| 36 | 36 | $oDB = &DB::getInstance(); |
| 37 | - $oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order")); |
|
| 38 | - $oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order")); |
|
| 39 | - $oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count")); |
|
| 40 | - $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); |
|
| 41 | - $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
| 42 | - $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
| 43 | - $oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count")); |
|
| 44 | - $oDB->addIndex("document_aliases", "idx_module_title", array("module_srl","alias_title"), true); |
|
| 45 | - $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true); |
|
| 37 | + $oDB->addIndex("documents", "idx_module_list_order", array("module_srl", "list_order")); |
|
| 38 | + $oDB->addIndex("documents", "idx_module_update_order", array("module_srl", "update_order")); |
|
| 39 | + $oDB->addIndex("documents", "idx_module_readed_count", array("module_srl", "readed_count")); |
|
| 40 | + $oDB->addIndex("documents", "idx_module_voted_count", array("module_srl", "voted_count")); |
|
| 41 | + $oDB->addIndex("documents", "idx_module_notice", array("module_srl", "is_notice")); |
|
| 42 | + $oDB->addIndex("documents", "idx_module_document_srl", array("module_srl", "document_srl")); |
|
| 43 | + $oDB->addIndex("documents", "idx_module_blamed_count", array("module_srl", "blamed_count")); |
|
| 44 | + $oDB->addIndex("document_aliases", "idx_module_title", array("module_srl", "alias_title"), true); |
|
| 45 | + $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl", "document_srl", "var_idx", "lang_code"), true); |
|
| 46 | 46 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
| 47 | 47 | $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
| 48 | 48 | |
| 49 | 49 | // 2009. 01. 29 Added a trigger for additional setup |
| 50 | 50 | $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
| 51 | 51 | |
| 52 | - if(!is_dir('./files/cache/tmp')) |
|
| 52 | + if (!is_dir('./files/cache/tmp')) |
|
| 53 | 53 | { |
| 54 | 54 | FileHandler::makeDir('./files/cache/tmp'); |
| 55 | 55 | } |
@@ -67,71 +67,71 @@ discard block |
||
| 67 | 67 | $oModuleModel = getModel('module'); |
| 68 | 68 | $oModuleController = getController('module'); |
| 69 | 69 | $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
| 70 | - if($oModuleModel->needUpdate($version_update_id)) |
|
| 70 | + if ($oModuleModel->needUpdate($version_update_id)) |
|
| 71 | 71 | { |
| 72 | 72 | // 2007. 7. 25: Add a column(notify_message) for notification |
| 73 | - if(!$oDB->isColumnExists("documents","notify_message")) return true; |
|
| 73 | + if (!$oDB->isColumnExists("documents", "notify_message")) return true; |
|
| 74 | 74 | |
| 75 | 75 | // 2007. 8. 23: create a clustered index in the document table |
| 76 | - if(!$oDB->isIndexExists("documents","idx_module_list_order")) return true; |
|
| 77 | - if(!$oDB->isIndexExists("documents","idx_module_update_order")) return true; |
|
| 78 | - if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true; |
|
| 79 | - if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true; |
|
| 76 | + if (!$oDB->isIndexExists("documents", "idx_module_list_order")) return true; |
|
| 77 | + if (!$oDB->isIndexExists("documents", "idx_module_update_order")) return true; |
|
| 78 | + if (!$oDB->isIndexExists("documents", "idx_module_readed_count")) return true; |
|
| 79 | + if (!$oDB->isIndexExists("documents", "idx_module_voted_count")) return true; |
|
| 80 | 80 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
| 81 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true; |
|
| 81 | + if (!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true; |
|
| 82 | 82 | // 2007. 10. 25 add parent_srl, expand to the document category |
| 83 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) return true; |
|
| 84 | - if(!$oDB->isColumnExists("document_categories","expand")) return true; |
|
| 85 | - if(!$oDB->isColumnExists("document_categories","group_srls")) return true; |
|
| 83 | + if (!$oDB->isColumnExists("document_categories", "parent_srl")) return true; |
|
| 84 | + if (!$oDB->isColumnExists("document_categories", "expand")) return true; |
|
| 85 | + if (!$oDB->isColumnExists("document_categories", "group_srls")) return true; |
|
| 86 | 86 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
| 87 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) return true; |
|
| 87 | + if (!$oDB->isIndexExists("documents", "idx_module_notice")) return true; |
|
| 88 | 88 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
| 89 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) return true; |
|
| 89 | + if (!$oDB->isIndexExists("documents", "idx_module_document_srl")) return true; |
|
| 90 | 90 | |
| 91 | 91 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
| 92 | - if(!$oDB->isColumnExists("documents","extra_vars")) return true; |
|
| 92 | + if (!$oDB->isColumnExists("documents", "extra_vars")) return true; |
|
| 93 | 93 | // 2008. 04. 23 Add a column(blamed_count) |
| 94 | - if(!$oDB->isColumnExists("documents", "blamed_count")) return true; |
|
| 95 | - if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) return true; |
|
| 96 | - if(!$oDB->isColumnExists("document_voted_log", "point")) return true; |
|
| 94 | + if (!$oDB->isColumnExists("documents", "blamed_count")) return true; |
|
| 95 | + if (!$oDB->isIndexExists("documents", "idx_module_blamed_count")) return true; |
|
| 96 | + if (!$oDB->isColumnExists("document_voted_log", "point")) return true; |
|
| 97 | 97 | // 2008-12-15 Add a column(color) |
| 98 | - if(!$oDB->isColumnExists("document_categories", "color")) return true; |
|
| 98 | + if (!$oDB->isColumnExists("document_categories", "color")) return true; |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
| 102 | 102 | */ |
| 103 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) return true; |
|
| 103 | + if (!$oDB->isColumnExists("document_extra_vars", "lang_code")) return true; |
|
| 104 | 104 | |
| 105 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true; |
|
| 105 | + if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true; |
|
| 106 | 106 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
| 107 | - if(!$oDB->isColumnExists("documents","lang_code")) return true; |
|
| 107 | + if (!$oDB->isColumnExists("documents", "lang_code")) return true; |
|
| 108 | 108 | // 2009. 03. 11 check the index in the document_extra_vars table |
| 109 | - if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true; |
|
| 109 | + if (!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true; |
|
| 110 | 110 | |
| 111 | 111 | // 2009. 03. 19: Add a column(eid) if not exist in the table |
| 112 | - if(!$oDB->isColumnExists("document_extra_keys","eid")) return true; |
|
| 113 | - if(!$oDB->isColumnExists("document_extra_vars","eid")) return true; |
|
| 112 | + if (!$oDB->isColumnExists("document_extra_keys", "eid")) return true; |
|
| 113 | + if (!$oDB->isColumnExists("document_extra_vars", "eid")) return true; |
|
| 114 | 114 | |
| 115 | 115 | // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table |
| 116 | - if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true; |
|
| 116 | + if (!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true; |
|
| 117 | 117 | |
| 118 | 118 | //2011. 04. 07 adding description column to document categories |
| 119 | - if(!$oDB->isColumnExists("document_categories","description")) return true; |
|
| 119 | + if (!$oDB->isColumnExists("document_categories", "description")) return true; |
|
| 120 | 120 | |
| 121 | 121 | //2011. 05. 23 adding status column to document |
| 122 | - if(!$oDB->isColumnExists('documents', 'status')) return true; |
|
| 122 | + if (!$oDB->isColumnExists('documents', 'status')) return true; |
|
| 123 | 123 | |
| 124 | 124 | //2011. 06. 07 check comment status update |
| 125 | - if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true; |
|
| 125 | + if ($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true; |
|
| 126 | 126 | |
| 127 | 127 | // 2011. 10. 25 status index check |
| 128 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) return true; |
|
| 128 | + if (!$oDB->isIndexExists("documents", "idx_module_status")) return true; |
|
| 129 | 129 | |
| 130 | 130 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
| 131 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true; |
|
| 131 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true; |
|
| 132 | 132 | |
| 133 | 133 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
| 134 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true; |
|
| 134 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true; |
|
| 135 | 135 | |
| 136 | 136 | $oModuleController->insertUpdatedLog($version_update_id); |
| 137 | 137 | } |
@@ -149,101 +149,101 @@ discard block |
||
| 149 | 149 | $oModuleModel = getModel('module'); |
| 150 | 150 | $oModuleController = getController('module'); |
| 151 | 151 | $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
| 152 | - if($oModuleModel->needUpdate($version_update_id)) |
|
| 152 | + if ($oModuleModel->needUpdate($version_update_id)) |
|
| 153 | 153 | { |
| 154 | 154 | // 2007. 7. 25: Add a column(notify_message) for notification |
| 155 | - if(!$oDB->isColumnExists("documents","notify_message")) |
|
| 155 | + if (!$oDB->isColumnExists("documents", "notify_message")) |
|
| 156 | 156 | { |
| 157 | - $oDB->addColumn('documents',"notify_message","char",1); |
|
| 157 | + $oDB->addColumn('documents', "notify_message", "char", 1); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // 2007. 8. 23: create a clustered index in the document table |
| 161 | - if(!$oDB->isIndexExists("documents","idx_module_list_order")) |
|
| 161 | + if (!$oDB->isIndexExists("documents", "idx_module_list_order")) |
|
| 162 | 162 | { |
| 163 | - $oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order")); |
|
| 163 | + $oDB->addIndex("documents", "idx_module_list_order", array("module_srl", "list_order")); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if(!$oDB->isIndexExists("documents","idx_module_update_order")) |
|
| 166 | + if (!$oDB->isIndexExists("documents", "idx_module_update_order")) |
|
| 167 | 167 | { |
| 168 | - $oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order")); |
|
| 168 | + $oDB->addIndex("documents", "idx_module_update_order", array("module_srl", "update_order")); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if(!$oDB->isIndexExists("documents","idx_module_readed_count")) |
|
| 171 | + if (!$oDB->isIndexExists("documents", "idx_module_readed_count")) |
|
| 172 | 172 | { |
| 173 | - $oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count")); |
|
| 173 | + $oDB->addIndex("documents", "idx_module_readed_count", array("module_srl", "readed_count")); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if(!$oDB->isIndexExists("documents","idx_module_voted_count")) |
|
| 176 | + if (!$oDB->isIndexExists("documents", "idx_module_voted_count")) |
|
| 177 | 177 | { |
| 178 | - $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); |
|
| 178 | + $oDB->addIndex("documents", "idx_module_voted_count", array("module_srl", "voted_count")); |
|
| 179 | 179 | } |
| 180 | 180 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
| 181 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) |
|
| 181 | + if (!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) |
|
| 182 | 182 | $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
| 183 | 183 | // 2007. 10. 25 add columns(parent_srl, expand) |
| 184 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0); |
|
| 185 | - if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N"); |
|
| 186 | - if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text"); |
|
| 184 | + if (!$oDB->isColumnExists("document_categories", "parent_srl")) $oDB->addColumn('document_categories', "parent_srl", "number", 12, 0); |
|
| 185 | + if (!$oDB->isColumnExists("document_categories", "expand")) $oDB->addColumn('document_categories', "expand", "char", 1, "N"); |
|
| 186 | + if (!$oDB->isColumnExists("document_categories", "group_srls")) $oDB->addColumn('document_categories', "group_srls", "text"); |
|
| 187 | 187 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
| 188 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
| 188 | + if (!$oDB->isIndexExists("documents", "idx_module_notice")) $oDB->addIndex("documents", "idx_module_notice", array("module_srl", "is_notice")); |
|
| 189 | 189 | |
| 190 | 190 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
| 191 | - if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text'); |
|
| 191 | + if (!$oDB->isColumnExists("documents", "extra_vars")) $oDB->addColumn('documents', 'extra_vars', 'text'); |
|
| 192 | 192 | |
| 193 | 193 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
| 194 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
| 194 | + if (!$oDB->isIndexExists("documents", "idx_module_document_srl")) $oDB->addIndex("documents", "idx_module_document_srl", array("module_srl", "document_srl")); |
|
| 195 | 195 | // 2008. 04. 23 Add a column(blamed count) |
| 196 | - if(!$oDB->isColumnExists("documents", "blamed_count")) |
|
| 196 | + if (!$oDB->isColumnExists("documents", "blamed_count")) |
|
| 197 | 197 | { |
| 198 | 198 | $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true); |
| 199 | 199 | $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) |
|
| 202 | + if (!$oDB->isIndexExists("documents", "idx_module_blamed_count")) |
|
| 203 | 203 | { |
| 204 | 204 | $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if(!$oDB->isColumnExists("document_voted_log", "point")) |
|
| 207 | + if (!$oDB->isColumnExists("document_voted_log", "point")) |
|
| 208 | 208 | $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); |
| 209 | 209 | |
| 210 | 210 | |
| 211 | - if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7); |
|
| 211 | + if (!$oDB->isColumnExists("document_categories", "color")) $oDB->addColumn('document_categories', "color", "char", 7); |
|
| 212 | 212 | |
| 213 | 213 | // 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
| 214 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10); |
|
| 214 | + if (!$oDB->isColumnExists("document_extra_vars", "lang_code")) $oDB->addColumn('document_extra_vars', "lang_code", "varchar", 10); |
|
| 215 | 215 | |
| 216 | 216 | // 2009. 01. 29 Added a trigger for additional setup |
| 217 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) |
|
| 217 | + if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) |
|
| 218 | 218 | $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
| 219 | 219 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
| 220 | - if(!$oDB->isColumnExists("documents","lang_code")) |
|
| 220 | + if (!$oDB->isColumnExists("documents", "lang_code")) |
|
| 221 | 221 | { |
| 222 | 222 | $db_info = Context::getDBInfo(); |
| 223 | - $oDB->addColumn('documents',"lang_code","varchar",10, $db_info->lang_code); |
|
| 223 | + $oDB->addColumn('documents', "lang_code", "varchar", 10, $db_info->lang_code); |
|
| 224 | 224 | $obj->lang_code = $db_info->lang_type; |
| 225 | 225 | executeQuery('document.updateDocumentsLangCode', $obj); |
| 226 | 226 | } |
| 227 | 227 | // 2009. 03. 11 Check the index in the document_extra_vars table |
| 228 | - if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) |
|
| 228 | + if (!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) |
|
| 229 | 229 | { |
| 230 | - $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true); |
|
| 230 | + $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl", "document_srl", "var_idx", "lang_code"), true); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) |
|
| 233 | + if ($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) |
|
| 234 | 234 | { |
| 235 | 235 | $oDB->dropIndex("document_extra_vars", "unique_module_vars", true); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // 2009. 03. 19: Add a column(eid) |
| 239 | 239 | // 2009. 04. 12: Fixed the issue(#17922959) that changes another column values when adding eid column |
| 240 | - if(!$oDB->isColumnExists("document_extra_keys","eid")) |
|
| 240 | + if (!$oDB->isColumnExists("document_extra_keys", "eid")) |
|
| 241 | 241 | { |
| 242 | - $oDB->addColumn("document_extra_keys","eid","varchar",40); |
|
| 242 | + $oDB->addColumn("document_extra_keys", "eid", "varchar", 40); |
|
| 243 | 243 | |
| 244 | 244 | $output = executeQuery('document.getGroupsExtraKeys', $obj); |
| 245 | - if($output->toBool() && $output->data && count($output->data)) { |
|
| 246 | - foreach($output->data as $extra_keys) { |
|
| 245 | + if ($output->toBool() && $output->data && count($output->data)) { |
|
| 246 | + foreach ($output->data as $extra_keys) { |
|
| 247 | 247 | $args->module_srl = $extra_keys->module_srl; |
| 248 | 248 | $args->var_idx = $extra_keys->idx; |
| 249 | 249 | $args->new_eid = "extra_vars".$extra_keys->idx; |
@@ -252,14 +252,14 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - if(!$oDB->isColumnExists("document_extra_vars","eid")) |
|
| 255 | + if (!$oDB->isColumnExists("document_extra_vars", "eid")) |
|
| 256 | 256 | { |
| 257 | - $oDB->addColumn("document_extra_vars","eid","varchar",40); |
|
| 257 | + $oDB->addColumn("document_extra_vars", "eid", "varchar", 40); |
|
| 258 | 258 | $obj->var_idx = '-1,-2'; |
| 259 | 259 | $output = executeQuery('document.getGroupsExtraVars', $obj); |
| 260 | - if($output->toBool() && $output->data && count($output->data)) |
|
| 260 | + if ($output->toBool() && $output->data && count($output->data)) |
|
| 261 | 261 | { |
| 262 | - foreach($output->data as $extra_vars) |
|
| 262 | + foreach ($output->data as $extra_vars) |
|
| 263 | 263 | { |
| 264 | 264 | $args->module_srl = $extra_vars->module_srl; |
| 265 | 265 | $args->var_idx = $extra_vars->idx; |
@@ -270,16 +270,16 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table |
| 273 | - if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) |
|
| 273 | + if (!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) |
|
| 274 | 274 | { |
| 275 | - $oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl","module_srl","var_idx"), false); |
|
| 275 | + $oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl", "module_srl", "var_idx"), false); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | //2011. 04. 07 adding description column to document categories |
| 279 | - if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0); |
|
| 279 | + if (!$oDB->isColumnExists("document_categories", "description")) $oDB->addColumn('document_categories', "description", "varchar", 200, 0); |
|
| 280 | 280 | |
| 281 | 281 | //2011. 05. 23 adding status column to document |
| 282 | - if(!$oDB->isColumnExists('documents', 'status')) |
|
| 282 | + if (!$oDB->isColumnExists('documents', 'status')) |
|
| 283 | 283 | { |
| 284 | 284 | $oDB->addColumn('documents', 'status', 'varchar', 20, 'PUBLIC'); |
| 285 | 285 | $args->is_secret = 'Y'; |
@@ -287,11 +287,11 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | // 2011. 09. 08 drop column document is_secret |
| 290 | - if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) |
|
| 290 | + if ($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) |
|
| 291 | 291 | $oDB->dropColumn('documents', 'is_secret'); |
| 292 | 292 | |
| 293 | 293 | //2011. 06. 07 merge column, allow_comment and lock_comment |
| 294 | - if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) |
|
| 294 | + if ($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) |
|
| 295 | 295 | { |
| 296 | 296 | $oDB->addColumn('documents', 'comment_status', 'varchar', 20, 'ALLOW'); |
| 297 | 297 | |
@@ -313,23 +313,23 @@ discard block |
||
| 313 | 313 | $output = executeQuery('document.updateDocumentCommentStatus', $args); |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
| 316 | + if ($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
| 317 | 317 | $oDB->dropColumn('documents', 'allow_comment'); |
| 318 | 318 | |
| 319 | - if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
| 319 | + if ($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
| 320 | 320 | $oDB->dropColumn('documents', 'lock_comment'); |
| 321 | 321 | |
| 322 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) |
|
| 323 | - $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); |
|
| 322 | + if (!$oDB->isIndexExists("documents", "idx_module_status")) |
|
| 323 | + $oDB->addIndex("documents", "idx_module_status", array("module_srl", "status")); |
|
| 324 | 324 | |
| 325 | 325 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
| 326 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) |
|
| 326 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) |
|
| 327 | 327 | { |
| 328 | 328 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
| 332 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) |
|
| 332 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) |
|
| 333 | 333 | { |
| 334 | 334 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after'); |
| 335 | 335 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $oModuleController->insertUpdatedLog($version_update_id); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - return new Object(0,'success_updated'); |
|
| 340 | + return new Object(0, 'success_updated'); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | function recompileCache() |
| 348 | 348 | { |
| 349 | - if(!is_dir('./files/cache/tmp')) |
|
| 349 | + if (!is_dir('./files/cache/tmp')) |
|
| 350 | 350 | { |
| 351 | 351 | FileHandler::makeDir('./files/cache/tmp'); |
| 352 | 352 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | function getConfigStatus($key) |
| 378 | 378 | { |
| 379 | - if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key]; |
|
| 379 | + if (array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key]; |
|
| 380 | 380 | else $this->getDefaultStatus(); |
| 381 | 381 | } |
| 382 | 382 | } |
@@ -70,68 +70,126 @@ discard block |
||
| 70 | 70 | if($oModuleModel->needUpdate($version_update_id)) |
| 71 | 71 | { |
| 72 | 72 | // 2007. 7. 25: Add a column(notify_message) for notification |
| 73 | - if(!$oDB->isColumnExists("documents","notify_message")) return true; |
|
| 73 | + if(!$oDB->isColumnExists("documents","notify_message")) { |
|
| 74 | + return true; |
|
| 75 | + } |
|
| 74 | 76 | |
| 75 | 77 | // 2007. 8. 23: create a clustered index in the document table |
| 76 | - if(!$oDB->isIndexExists("documents","idx_module_list_order")) return true; |
|
| 77 | - if(!$oDB->isIndexExists("documents","idx_module_update_order")) return true; |
|
| 78 | - if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true; |
|
| 79 | - if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true; |
|
| 78 | + if(!$oDB->isIndexExists("documents","idx_module_list_order")) { |
|
| 79 | + return true; |
|
| 80 | + } |
|
| 81 | + if(!$oDB->isIndexExists("documents","idx_module_update_order")) { |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | + if(!$oDB->isIndexExists("documents","idx_module_readed_count")) { |
|
| 85 | + return true; |
|
| 86 | + } |
|
| 87 | + if(!$oDB->isIndexExists("documents","idx_module_voted_count")) { |
|
| 88 | + return true; |
|
| 89 | + } |
|
| 80 | 90 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
| 81 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true; |
|
| 91 | + if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) { |
|
| 92 | + return true; |
|
| 93 | + } |
|
| 82 | 94 | // 2007. 10. 25 add parent_srl, expand to the document category |
| 83 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) return true; |
|
| 84 | - if(!$oDB->isColumnExists("document_categories","expand")) return true; |
|
| 85 | - if(!$oDB->isColumnExists("document_categories","group_srls")) return true; |
|
| 95 | + if(!$oDB->isColumnExists("document_categories","parent_srl")) { |
|
| 96 | + return true; |
|
| 97 | + } |
|
| 98 | + if(!$oDB->isColumnExists("document_categories","expand")) { |
|
| 99 | + return true; |
|
| 100 | + } |
|
| 101 | + if(!$oDB->isColumnExists("document_categories","group_srls")) { |
|
| 102 | + return true; |
|
| 103 | + } |
|
| 86 | 104 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
| 87 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) return true; |
|
| 105 | + if(!$oDB->isIndexExists("documents","idx_module_notice")) { |
|
| 106 | + return true; |
|
| 107 | + } |
|
| 88 | 108 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
| 89 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) return true; |
|
| 109 | + if(!$oDB->isIndexExists("documents","idx_module_document_srl")) { |
|
| 110 | + return true; |
|
| 111 | + } |
|
| 90 | 112 | |
| 91 | 113 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
| 92 | - if(!$oDB->isColumnExists("documents","extra_vars")) return true; |
|
| 114 | + if(!$oDB->isColumnExists("documents","extra_vars")) { |
|
| 115 | + return true; |
|
| 116 | + } |
|
| 93 | 117 | // 2008. 04. 23 Add a column(blamed_count) |
| 94 | - if(!$oDB->isColumnExists("documents", "blamed_count")) return true; |
|
| 95 | - if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) return true; |
|
| 96 | - if(!$oDB->isColumnExists("document_voted_log", "point")) return true; |
|
| 118 | + if(!$oDB->isColumnExists("documents", "blamed_count")) { |
|
| 119 | + return true; |
|
| 120 | + } |
|
| 121 | + if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) { |
|
| 122 | + return true; |
|
| 123 | + } |
|
| 124 | + if(!$oDB->isColumnExists("document_voted_log", "point")) { |
|
| 125 | + return true; |
|
| 126 | + } |
|
| 97 | 127 | // 2008-12-15 Add a column(color) |
| 98 | - if(!$oDB->isColumnExists("document_categories", "color")) return true; |
|
| 128 | + if(!$oDB->isColumnExists("document_categories", "color")) { |
|
| 129 | + return true; |
|
| 130 | + } |
|
| 99 | 131 | |
| 100 | 132 | /** |
| 101 | 133 | * 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
| 102 | 134 | */ |
| 103 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) return true; |
|
| 135 | + if(!$oDB->isColumnExists("document_extra_vars","lang_code")) { |
|
| 136 | + return true; |
|
| 137 | + } |
|
| 104 | 138 | |
| 105 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true; |
|
| 139 | + if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) { |
|
| 140 | + return true; |
|
| 141 | + } |
|
| 106 | 142 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
| 107 | - if(!$oDB->isColumnExists("documents","lang_code")) return true; |
|
| 143 | + if(!$oDB->isColumnExists("documents","lang_code")) { |
|
| 144 | + return true; |
|
| 145 | + } |
|
| 108 | 146 | // 2009. 03. 11 check the index in the document_extra_vars table |
| 109 | - if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true; |
|
| 147 | + if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) { |
|
| 148 | + return true; |
|
| 149 | + } |
|
| 110 | 150 | |
| 111 | 151 | // 2009. 03. 19: Add a column(eid) if not exist in the table |
| 112 | - if(!$oDB->isColumnExists("document_extra_keys","eid")) return true; |
|
| 113 | - if(!$oDB->isColumnExists("document_extra_vars","eid")) return true; |
|
| 152 | + if(!$oDB->isColumnExists("document_extra_keys","eid")) { |
|
| 153 | + return true; |
|
| 154 | + } |
|
| 155 | + if(!$oDB->isColumnExists("document_extra_vars","eid")) { |
|
| 156 | + return true; |
|
| 157 | + } |
|
| 114 | 158 | |
| 115 | 159 | // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table |
| 116 | - if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true; |
|
| 160 | + if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) { |
|
| 161 | + return true; |
|
| 162 | + } |
|
| 117 | 163 | |
| 118 | 164 | //2011. 04. 07 adding description column to document categories |
| 119 | - if(!$oDB->isColumnExists("document_categories","description")) return true; |
|
| 165 | + if(!$oDB->isColumnExists("document_categories","description")) { |
|
| 166 | + return true; |
|
| 167 | + } |
|
| 120 | 168 | |
| 121 | 169 | //2011. 05. 23 adding status column to document |
| 122 | - if(!$oDB->isColumnExists('documents', 'status')) return true; |
|
| 170 | + if(!$oDB->isColumnExists('documents', 'status')) { |
|
| 171 | + return true; |
|
| 172 | + } |
|
| 123 | 173 | |
| 124 | 174 | //2011. 06. 07 check comment status update |
| 125 | - if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true; |
|
| 175 | + if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) { |
|
| 176 | + return true; |
|
| 177 | + } |
|
| 126 | 178 | |
| 127 | 179 | // 2011. 10. 25 status index check |
| 128 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) return true; |
|
| 180 | + if(!$oDB->isIndexExists("documents", "idx_module_status")) { |
|
| 181 | + return true; |
|
| 182 | + } |
|
| 129 | 183 | |
| 130 | 184 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
| 131 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true; |
|
| 185 | + if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) { |
|
| 186 | + return true; |
|
| 187 | + } |
|
| 132 | 188 | |
| 133 | 189 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
| 134 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true; |
|
| 190 | + if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) { |
|
| 191 | + return true; |
|
| 192 | + } |
|
| 135 | 193 | |
| 136 | 194 | $oModuleController->insertUpdatedLog($version_update_id); |
| 137 | 195 | } |
@@ -178,20 +236,33 @@ discard block |
||
| 178 | 236 | $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); |
| 179 | 237 | } |
| 180 | 238 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
| 181 | - if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) |
|
| 182 | - $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
|
| 239 | + if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) { |
|
| 240 | + $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
|
| 241 | + } |
|
| 183 | 242 | // 2007. 10. 25 add columns(parent_srl, expand) |
| 184 | - if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0); |
|
| 185 | - if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N"); |
|
| 186 | - if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text"); |
|
| 243 | + if(!$oDB->isColumnExists("document_categories","parent_srl")) { |
|
| 244 | + $oDB->addColumn('document_categories',"parent_srl","number",12,0); |
|
| 245 | + } |
|
| 246 | + if(!$oDB->isColumnExists("document_categories","expand")) { |
|
| 247 | + $oDB->addColumn('document_categories',"expand","char",1,"N"); |
|
| 248 | + } |
|
| 249 | + if(!$oDB->isColumnExists("document_categories","group_srls")) { |
|
| 250 | + $oDB->addColumn('document_categories',"group_srls","text"); |
|
| 251 | + } |
|
| 187 | 252 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
| 188 | - if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
| 253 | + if(!$oDB->isIndexExists("documents","idx_module_notice")) { |
|
| 254 | + $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
|
| 255 | + } |
|
| 189 | 256 | |
| 190 | 257 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
| 191 | - if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text'); |
|
| 258 | + if(!$oDB->isColumnExists("documents","extra_vars")) { |
|
| 259 | + $oDB->addColumn('documents','extra_vars','text'); |
|
| 260 | + } |
|
| 192 | 261 | |
| 193 | 262 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
| 194 | - if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
| 263 | + if(!$oDB->isIndexExists("documents","idx_module_document_srl")) { |
|
| 264 | + $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
|
| 265 | + } |
|
| 195 | 266 | // 2008. 04. 23 Add a column(blamed count) |
| 196 | 267 | if(!$oDB->isColumnExists("documents", "blamed_count")) |
| 197 | 268 | { |
@@ -204,18 +275,24 @@ discard block |
||
| 204 | 275 | $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); |
| 205 | 276 | } |
| 206 | 277 | |
| 207 | - if(!$oDB->isColumnExists("document_voted_log", "point")) |
|
| 208 | - $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); |
|
| 278 | + if(!$oDB->isColumnExists("document_voted_log", "point")) { |
|
| 279 | + $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); |
|
| 280 | + } |
|
| 209 | 281 | |
| 210 | 282 | |
| 211 | - if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7); |
|
| 283 | + if(!$oDB->isColumnExists("document_categories","color")) { |
|
| 284 | + $oDB->addColumn('document_categories',"color","char",7); |
|
| 285 | + } |
|
| 212 | 286 | |
| 213 | 287 | // 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
| 214 | - if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10); |
|
| 288 | + if(!$oDB->isColumnExists("document_extra_vars","lang_code")) { |
|
| 289 | + $oDB->addColumn('document_extra_vars',"lang_code","varchar",10); |
|
| 290 | + } |
|
| 215 | 291 | |
| 216 | 292 | // 2009. 01. 29 Added a trigger for additional setup |
| 217 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) |
|
| 218 | - $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
|
| 293 | + if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) { |
|
| 294 | + $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
|
| 295 | + } |
|
| 219 | 296 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
| 220 | 297 | if(!$oDB->isColumnExists("documents","lang_code")) |
| 221 | 298 | { |
@@ -276,7 +353,9 @@ discard block |
||
| 276 | 353 | } |
| 277 | 354 | |
| 278 | 355 | //2011. 04. 07 adding description column to document categories |
| 279 | - if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0); |
|
| 356 | + if(!$oDB->isColumnExists("document_categories","description")) { |
|
| 357 | + $oDB->addColumn('document_categories',"description","varchar",200,0); |
|
| 358 | + } |
|
| 280 | 359 | |
| 281 | 360 | //2011. 05. 23 adding status column to document |
| 282 | 361 | if(!$oDB->isColumnExists('documents', 'status')) |
@@ -287,8 +366,9 @@ discard block |
||
| 287 | 366 | } |
| 288 | 367 | |
| 289 | 368 | // 2011. 09. 08 drop column document is_secret |
| 290 | - if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) |
|
| 291 | - $oDB->dropColumn('documents', 'is_secret'); |
|
| 369 | + if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) { |
|
| 370 | + $oDB->dropColumn('documents', 'is_secret'); |
|
| 371 | + } |
|
| 292 | 372 | |
| 293 | 373 | //2011. 06. 07 merge column, allow_comment and lock_comment |
| 294 | 374 | if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) |
@@ -313,14 +393,17 @@ discard block |
||
| 313 | 393 | $output = executeQuery('document.updateDocumentCommentStatus', $args); |
| 314 | 394 | } |
| 315 | 395 | |
| 316 | - if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
| 317 | - $oDB->dropColumn('documents', 'allow_comment'); |
|
| 396 | + if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) { |
|
| 397 | + $oDB->dropColumn('documents', 'allow_comment'); |
|
| 398 | + } |
|
| 318 | 399 | |
| 319 | - if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
|
| 320 | - $oDB->dropColumn('documents', 'lock_comment'); |
|
| 400 | + if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) { |
|
| 401 | + $oDB->dropColumn('documents', 'lock_comment'); |
|
| 402 | + } |
|
| 321 | 403 | |
| 322 | - if(!$oDB->isIndexExists("documents", "idx_module_status")) |
|
| 323 | - $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); |
|
| 404 | + if(!$oDB->isIndexExists("documents", "idx_module_status")) { |
|
| 405 | + $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); |
|
| 406 | + } |
|
| 324 | 407 | |
| 325 | 408 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
| 326 | 409 | if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) |
@@ -376,8 +459,11 @@ discard block |
||
| 376 | 459 | */ |
| 377 | 460 | function getConfigStatus($key) |
| 378 | 461 | { |
| 379 | - if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key]; |
|
| 380 | - else $this->getDefaultStatus(); |
|
| 462 | + if(array_key_exists(strtolower($key), $this->statusList)) { |
|
| 463 | + return $this->statusList[$key]; |
|
| 464 | + } else { |
|
| 465 | + $this->getDefaultStatus(); |
|
| 466 | + } |
|
| 381 | 467 | } |
| 382 | 468 | } |
| 383 | 469 | /* End of file document.class.php */ |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | /** |
| 714 | 714 | * Move the doc into the trash |
| 715 | - * @param object $obj |
|
| 715 | + * @param stdClass $obj |
|
| 716 | 716 | * @return object |
| 717 | 717 | */ |
| 718 | 718 | function moveDocumentToTrash($obj) |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | * @param mixed $value |
| 1018 | 1018 | * @param int $eid |
| 1019 | 1019 | * @param string $lang_code |
| 1020 | - * @return Object|void |
|
| 1020 | + * @return Object|null |
|
| 1021 | 1021 | */ |
| 1022 | 1022 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
| 1023 | 1023 | { |
@@ -1807,7 +1807,7 @@ discard block |
||
| 1807 | 1807 | * Occasionally the xml file is not generated after menu is configued on the admin page \n |
| 1808 | 1808 | * The administrator can manually update the file in this case \n |
| 1809 | 1809 | * Although the issue is not currently reproduced, it is unnecessay to remove. |
| 1810 | - * @return void |
|
| 1810 | + * @return Object|null |
|
| 1811 | 1811 | */ |
| 1812 | 1812 | function procDocumentMakeXmlFile() |
| 1813 | 1813 | { |
@@ -2139,7 +2139,7 @@ discard block |
||
| 2139 | 2139 | |
| 2140 | 2140 | /** |
| 2141 | 2141 | * Saved in the session when an administrator selects a post |
| 2142 | - * @return void|Object |
|
| 2142 | + * @return Object|null |
|
| 2143 | 2143 | */ |
| 2144 | 2144 | function procDocumentAddCart() |
| 2145 | 2145 | { |
@@ -2212,7 +2212,7 @@ discard block |
||
| 2212 | 2212 | |
| 2213 | 2213 | /** |
| 2214 | 2214 | * Move/ Delete the document in the seession |
| 2215 | - * @return void|Object |
|
| 2215 | + * @return Object|null |
|
| 2216 | 2216 | */ |
| 2217 | 2217 | function procDocumentManageCheckedDocument() |
| 2218 | 2218 | { |
@@ -2374,7 +2374,7 @@ discard block |
||
| 2374 | 2374 | |
| 2375 | 2375 | /** |
| 2376 | 2376 | * Document temporary save |
| 2377 | - * @return void|Object |
|
| 2377 | + * @return Object|null |
|
| 2378 | 2378 | */ |
| 2379 | 2379 | function procDocumentTempSave() |
| 2380 | 2380 | { |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | |
| 2441 | 2441 | /** |
| 2442 | 2442 | * Return Document List for exec_xml |
| 2443 | - * @return void|Object |
|
| 2443 | + * @return Object|null |
|
| 2444 | 2444 | */ |
| 2445 | 2445 | function procDocumentGetList() |
| 2446 | 2446 | { |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | if(!$obj->email_address) $obj->email_address = ''; |
| 220 | 220 | if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 221 | 221 | |
| 222 | - // can modify regdate only manager |
|
| 223 | - $grant = Context::get('grant'); |
|
| 222 | + // can modify regdate only manager |
|
| 223 | + $grant = Context::get('grant'); |
|
| 224 | 224 | if(!$grant->manager) |
| 225 | 225 | { |
| 226 | 226 | unset($obj->regdate); |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
| 423 | 423 | |
| 424 | 424 | // can modify regdate only manager |
| 425 | - $grant = Context::get('grant'); |
|
| 425 | + $grant = Context::get('grant'); |
|
| 426 | 426 | if(!$grant->manager) |
| 427 | 427 | { |
| 428 | 428 | unset($obj->regdate); |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function procDocumentVoteUp() |
| 26 | 26 | { |
| 27 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 27 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 28 | 28 | |
| 29 | 29 | $document_srl = Context::get('target_srl'); |
| 30 | - if(!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 30 | + if (!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 31 | 31 | |
| 32 | 32 | $oDocumentModel = getModel('document'); |
| 33 | 33 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 34 | 34 | $module_srl = $oDocument->get('module_srl'); |
| 35 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 35 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 36 | 36 | |
| 37 | 37 | $oModuleModel = getModel('module'); |
| 38 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 39 | - if($document_config->use_vote_up=='N') return new Object(-1, 'msg_invalid_request'); |
|
| 38 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 39 | + if ($document_config->use_vote_up == 'N') return new Object(-1, 'msg_invalid_request'); |
|
| 40 | 40 | |
| 41 | 41 | $point = 1; |
| 42 | 42 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | function procDocumentVoteDown() |
| 71 | 71 | { |
| 72 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 72 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 73 | 73 | |
| 74 | 74 | $document_srl = Context::get('target_srl'); |
| 75 | - if(!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 75 | + if (!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 76 | 76 | |
| 77 | 77 | $oDocumentModel = getModel('document'); |
| 78 | 78 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 79 | 79 | $module_srl = $oDocument->get('module_srl'); |
| 80 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 80 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 81 | 81 | |
| 82 | 82 | $oModuleModel = getModel('module'); |
| 83 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 84 | - if($document_config->use_vote_down=='N') return new Object(-1, 'msg_invalid_request'); |
|
| 83 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 84 | + if ($document_config->use_vote_down == 'N') return new Object(-1, 'msg_invalid_request'); |
|
| 85 | 85 | |
| 86 | 86 | $point = -1; |
| 87 | 87 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | function procDocumentDeclare() |
| 97 | 97 | { |
| 98 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 98 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 99 | 99 | |
| 100 | 100 | $document_srl = Context::get('target_srl'); |
| 101 | - if(!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 101 | + if (!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 102 | 102 | |
| 103 | 103 | return $this->declaredDocument($document_srl); |
| 104 | 104 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $args->history_srl = $history_srl; |
| 141 | 141 | $args->module_srl = $module_srl; |
| 142 | 142 | $args->document_srl = $document_srl; |
| 143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 143 | + if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 144 | 144 | executeQuery("document.deleteHistory", $args); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | function triggerDeleteModuleDocuments(&$obj) |
| 153 | 153 | { |
| 154 | 154 | $module_srl = $obj->module_srl; |
| 155 | - if(!$module_srl) return new Object(); |
|
| 155 | + if (!$module_srl) return new Object(); |
|
| 156 | 156 | // Delete the document |
| 157 | 157 | $oDocumentAdminController = getAdminController('document'); |
| 158 | 158 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
| 159 | - if(!$output->toBool()) return $output; |
|
| 159 | + if (!$output->toBool()) return $output; |
|
| 160 | 160 | // Delete the category |
| 161 | 161 | $oDocumentController = getController('document'); |
| 162 | 162 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
| 163 | - if(!$output->toBool()) return $output; |
|
| 163 | + if (!$output->toBool()) return $output; |
|
| 164 | 164 | // Delete extra key and variable, because module deleted |
| 165 | 165 | $this->deleteDocumentExtraKeys($module_srl); |
| 166 | 166 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | function insertDocument($obj, $manual_inserted = false, $isRestore = false, $isLatest = true) |
| 195 | 195 | { |
| 196 | - if(!$manual_inserted && !checkCSRF()) |
|
| 196 | + if (!$manual_inserted && !checkCSRF()) |
|
| 197 | 197 | { |
| 198 | 198 | return new Object(-1, 'msg_invalid_request'); |
| 199 | 199 | } |
@@ -202,32 +202,32 @@ discard block |
||
| 202 | 202 | $oDB = &DB::getInstance(); |
| 203 | 203 | $oDB->begin(); |
| 204 | 204 | // List variables |
| 205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 209 | - if($obj->homepage) |
|
| 205 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 206 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 207 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 208 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
| 209 | + if ($obj->homepage) |
|
| 210 | 210 | { |
| 211 | 211 | $obj->homepage = removeHackTag($obj->homepage); |
| 212 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
| 212 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
| 213 | 213 | { |
| 214 | 214 | $obj->homepage = 'http://'.$obj->homepage; |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
| 220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 218 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 219 | + if (!$obj->email_address) $obj->email_address = ''; |
|
| 220 | + if (!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 221 | 221 | |
| 222 | 222 | // can modify regdate only manager |
| 223 | 223 | $grant = Context::get('grant'); |
| 224 | - if(!$grant->manager) |
|
| 224 | + if (!$grant->manager) |
|
| 225 | 225 | { |
| 226 | 226 | unset($obj->regdate); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
| 230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 230 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 231 | 231 | // Remove the columns for automatic saving |
| 232 | 232 | unset($obj->_saved_doc_srl); |
| 233 | 233 | unset($obj->_saved_doc_title); |
@@ -235,34 +235,34 @@ discard block |
||
| 235 | 235 | unset($obj->_saved_doc_message); |
| 236 | 236 | // Call a trigger (before) |
| 237 | 237 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
| 238 | - if(!$output->toBool()) return $output; |
|
| 238 | + if (!$output->toBool()) return $output; |
|
| 239 | 239 | // Register it if no given document_srl exists |
| 240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
| 241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new Object(-1, 'msg_not_permitted'); |
|
| 240 | + if (!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
| 241 | + elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new Object(-1, 'msg_not_permitted'); |
|
| 242 | 242 | |
| 243 | 243 | $oDocumentModel = getModel('document'); |
| 244 | 244 | // Set to 0 if the category_srl doesn't exist |
| 245 | - if($obj->category_srl) |
|
| 245 | + if ($obj->category_srl) |
|
| 246 | 246 | { |
| 247 | 247 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
| 248 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
| 248 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
| 249 | 249 | { |
| 250 | 250 | return new Object(-1, 'msg_not_permitted'); |
| 251 | 251 | } |
| 252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 252 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 253 | 253 | } |
| 254 | 254 | // Set the read counts and update order. |
| 255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
| 256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 255 | + if (!$obj->readed_count) $obj->readed_count = 0; |
|
| 256 | + if ($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 257 | 257 | else $obj->update_order = $obj->list_order; |
| 258 | 258 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
| 259 | - if($obj->password && !$obj->password_is_hashed) |
|
| 259 | + if ($obj->password && !$obj->password_is_hashed) |
|
| 260 | 260 | { |
| 261 | 261 | $obj->password = getModel('member')->hashPassword($obj->password); |
| 262 | 262 | } |
| 263 | 263 | // Insert member's information only if the member is logged-in and not manually registered. |
| 264 | 264 | $logged_info = Context::get('logged_info'); |
| 265 | - if(Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
| 265 | + if (Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
| 266 | 266 | { |
| 267 | 267 | $obj->member_srl = $logged_info->member_srl; |
| 268 | 268 | |
@@ -276,61 +276,61 @@ discard block |
||
| 276 | 276 | // If the tile is empty, extract string from the contents. |
| 277 | 277 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 278 | 278 | settype($obj->title, "string"); |
| 279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 279 | + if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...'); |
|
| 280 | 280 | // If no tile extracted from the contents, leave it untitled. |
| 281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 281 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 282 | 282 | // Remove XE's own tags from the contents. |
| 283 | 283 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 284 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 284 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 285 | 285 | { |
| 286 | - if($obj->use_html != 'Y') |
|
| 286 | + if ($obj->use_html != 'Y') |
|
| 287 | 287 | { |
| 288 | 288 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 289 | 289 | } |
| 290 | 290 | $obj->content = nl2br($obj->content); |
| 291 | 291 | } |
| 292 | 292 | // Remove iframe and script if not a top adminisrator in the session. |
| 293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
| 293 | + if ($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
| 294 | 294 | // An error appears if both log-in info and user name don't exist. |
| 295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new Object(-1,'msg_invalid_request'); |
|
| 295 | + if (!$logged_info->member_srl && !$obj->nick_name) return new Object(-1, 'msg_invalid_request'); |
|
| 296 | 296 | |
| 297 | 297 | $obj->lang_code = Context::getLangType(); |
| 298 | 298 | // Insert data into the DB |
| 299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
| 299 | + if (!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
| 300 | 300 | $output = executeQuery('document.insertDocument', $obj); |
| 301 | - if(!$output->toBool()) |
|
| 301 | + if (!$output->toBool()) |
|
| 302 | 302 | { |
| 303 | 303 | $oDB->rollback(); |
| 304 | 304 | return $output; |
| 305 | 305 | } |
| 306 | 306 | // Insert extra variables if the document successfully inserted. |
| 307 | 307 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
| 308 | - if(count($extra_keys)) |
|
| 308 | + if (count($extra_keys)) |
|
| 309 | 309 | { |
| 310 | - foreach($extra_keys as $idx => $extra_item) |
|
| 310 | + foreach ($extra_keys as $idx => $extra_item) |
|
| 311 | 311 | { |
| 312 | 312 | $value = NULL; |
| 313 | - if(isset($obj->{'extra_vars'.$idx})) |
|
| 313 | + if (isset($obj->{'extra_vars'.$idx})) |
|
| 314 | 314 | { |
| 315 | 315 | $tmp = $obj->{'extra_vars'.$idx}; |
| 316 | - if(is_array($tmp)) |
|
| 316 | + if (is_array($tmp)) |
|
| 317 | 317 | $value = implode('|@|', $tmp); |
| 318 | 318 | else |
| 319 | 319 | $value = trim($tmp); |
| 320 | 320 | } |
| 321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 322 | - if($value == NULL) continue; |
|
| 321 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 322 | + if ($value == NULL) continue; |
|
| 323 | 323 | |
| 324 | 324 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | // Update the category if the category_srl exists. |
| 328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 328 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 329 | 329 | // Call a trigger (after) |
| 330 | - if($output->toBool()) |
|
| 330 | + if ($output->toBool()) |
|
| 331 | 331 | { |
| 332 | 332 | $trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj); |
| 333 | - if(!$trigger_output->toBool()) |
|
| 333 | + if (!$trigger_output->toBool()) |
|
| 334 | 334 | { |
| 335 | 335 | $oDB->rollback(); |
| 336 | 336 | return $trigger_output; |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | $oDB->commit(); |
| 342 | 342 | |
| 343 | 343 | // return |
| 344 | - if(!$manual_inserted) |
|
| 344 | + if (!$manual_inserted) |
|
| 345 | 345 | { |
| 346 | 346 | $this->addGrant($obj->document_srl); |
| 347 | 347 | } |
| 348 | - $output->add('document_srl',$obj->document_srl); |
|
| 349 | - $output->add('category_srl',$obj->category_srl); |
|
| 348 | + $output->add('document_srl', $obj->document_srl); |
|
| 349 | + $output->add('category_srl', $obj->category_srl); |
|
| 350 | 350 | |
| 351 | 351 | return $output; |
| 352 | 352 | } |
@@ -362,41 +362,41 @@ discard block |
||
| 362 | 362 | { |
| 363 | 363 | $logged_info = Context::get('logged_info'); |
| 364 | 364 | |
| 365 | - if(!$manual_updated && !checkCSRF()) |
|
| 365 | + if (!$manual_updated && !checkCSRF()) |
|
| 366 | 366 | { |
| 367 | 367 | return new Object(-1, 'msg_invalid_request'); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new Object(-1,'msg_invalied_request'); |
|
| 371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
| 372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
| 370 | + if (!$source_obj->document_srl || !$obj->document_srl) return new Object(-1, 'msg_invalied_request'); |
|
| 371 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
| 372 | + if (!$obj->status) $obj->status = 'PUBLIC'; |
|
| 373 | 373 | |
| 374 | 374 | // Call a trigger (before) |
| 375 | 375 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
| 376 | - if(!$output->toBool()) return $output; |
|
| 376 | + if (!$output->toBool()) return $output; |
|
| 377 | 377 | |
| 378 | 378 | // begin transaction |
| 379 | 379 | $oDB = &DB::getInstance(); |
| 380 | 380 | $oDB->begin(); |
| 381 | 381 | |
| 382 | 382 | $oModuleModel = getModel('module'); |
| 383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
| 383 | + if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
| 384 | 384 | $module_srl = $obj->module_srl; |
| 385 | 385 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
| 386 | - if(!$document_config) |
|
| 386 | + if (!$document_config) |
|
| 387 | 387 | { |
| 388 | 388 | $document_config = new stdClass(); |
| 389 | 389 | } |
| 390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 390 | + if (!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 391 | 391 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
| 392 | 392 | |
| 393 | - if($bUseHistory) |
|
| 393 | + if ($bUseHistory) |
|
| 394 | 394 | { |
| 395 | 395 | $args = new stdClass; |
| 396 | 396 | $args->history_srl = getNextSequence(); |
| 397 | 397 | $args->document_srl = $obj->document_srl; |
| 398 | 398 | $args->module_srl = $module_srl; |
| 399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
| 399 | + if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
| 400 | 400 | $args->nick_name = $source_obj->get('nick_name'); |
| 401 | 401 | $args->member_srl = $source_obj->get('member_srl'); |
| 402 | 402 | $args->regdate = $source_obj->get('last_update'); |
@@ -408,30 +408,30 @@ discard block |
||
| 408 | 408 | $obj->ipaddress = $source_obj->get('ipaddress'); |
| 409 | 409 | } |
| 410 | 410 | // List variables |
| 411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 415 | - if($obj->homepage) |
|
| 411 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 412 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 413 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 414 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
| 415 | + if ($obj->homepage) |
|
| 416 | 416 | { |
| 417 | 417 | $obj->homepage = removeHackTag($obj->homepage); |
| 418 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
| 418 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
| 419 | 419 | { |
| 420 | 420 | $obj->homepage = 'http://'.$obj->homepage; |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 424 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 425 | 425 | |
| 426 | 426 | // can modify regdate only manager |
| 427 | 427 | $grant = Context::get('grant'); |
| 428 | - if(!$grant->manager) |
|
| 428 | + if (!$grant->manager) |
|
| 429 | 429 | { |
| 430 | 430 | unset($obj->regdate); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Serialize the $extra_vars |
| 434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 434 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 435 | 435 | // Remove the columns for automatic saving |
| 436 | 436 | unset($obj->_saved_doc_srl); |
| 437 | 437 | unset($obj->_saved_doc_title); |
@@ -440,23 +440,23 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | $oDocumentModel = getModel('document'); |
| 442 | 442 | // Set the category_srl to 0 if the changed category is not exsiting. |
| 443 | - if($source_obj->get('category_srl')!=$obj->category_srl) |
|
| 443 | + if ($source_obj->get('category_srl') != $obj->category_srl) |
|
| 444 | 444 | { |
| 445 | 445 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
| 446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 446 | + if (!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 447 | 447 | } |
| 448 | 448 | // Change the update order |
| 449 | 449 | $obj->update_order = getNextSequence() * -1; |
| 450 | 450 | // Hash the password if it exists |
| 451 | - if($obj->password) |
|
| 451 | + if ($obj->password) |
|
| 452 | 452 | { |
| 453 | 453 | $obj->password = getModel('member')->hashPassword($obj->password); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | // If an author is identical to the modifier or history is used, use the logged-in user's information. |
| 457 | - if(Context::get('is_logged') && !$manual_updated) |
|
| 457 | + if (Context::get('is_logged') && !$manual_updated) |
|
| 458 | 458 | { |
| 459 | - if($source_obj->get('member_srl')==$logged_info->member_srl) |
|
| 459 | + if ($source_obj->get('member_srl') == $logged_info->member_srl) |
|
| 460 | 460 | { |
| 461 | 461 | $obj->member_srl = $logged_info->member_srl; |
| 462 | 462 | $obj->user_name = htmlspecialchars_decode($logged_info->user_name); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // For the document written by logged-in user however no nick_name exists |
| 470 | - if($source_obj->get('member_srl')&& !$obj->nick_name) |
|
| 470 | + if ($source_obj->get('member_srl') && !$obj->nick_name) |
|
| 471 | 471 | { |
| 472 | 472 | $obj->member_srl = $source_obj->get('member_srl'); |
| 473 | 473 | $obj->user_name = $source_obj->get('user_name'); |
@@ -478,24 +478,24 @@ discard block |
||
| 478 | 478 | // If the tile is empty, extract string from the contents. |
| 479 | 479 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 480 | 480 | settype($obj->title, "string"); |
| 481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 481 | + if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
| 482 | 482 | // If no tile extracted from the contents, leave it untitled. |
| 483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 483 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 484 | 484 | // Remove XE's own tags from the contents. |
| 485 | 485 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 486 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 486 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
| 487 | 487 | { |
| 488 | - if($obj->use_html != 'Y') |
|
| 488 | + if ($obj->use_html != 'Y') |
|
| 489 | 489 | { |
| 490 | 490 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 491 | 491 | } |
| 492 | 492 | $obj->content = nl2br($obj->content); |
| 493 | 493 | } |
| 494 | 494 | // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. |
| 495 | - if($source_obj->get('lang_code') != Context::getLangType()) |
|
| 495 | + if ($source_obj->get('lang_code') != Context::getLangType()) |
|
| 496 | 496 | { |
| 497 | 497 | // Change not extra vars but language code of the original document if document's lang_code doesn't exist. |
| 498 | - if(!$source_obj->get('lang_code')) |
|
| 498 | + if (!$source_obj->get('lang_code')) |
|
| 499 | 499 | { |
| 500 | 500 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
| 501 | 501 | $lang_code_args->lang_code = Context::getLangType(); |
@@ -515,59 +515,59 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | // Remove iframe and script if not a top adminisrator in the session. |
| 518 | - if($logged_info->is_admin != 'Y') |
|
| 518 | + if ($logged_info->is_admin != 'Y') |
|
| 519 | 519 | { |
| 520 | 520 | $obj->content = removeHackTag($obj->content); |
| 521 | 521 | } |
| 522 | 522 | // if temporary document, regdate is now setting |
| 523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 523 | + if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 524 | 524 | |
| 525 | 525 | // Insert data into the DB |
| 526 | 526 | $output = executeQuery('document.updateDocument', $obj); |
| 527 | - if(!$output->toBool()) |
|
| 527 | + if (!$output->toBool()) |
|
| 528 | 528 | { |
| 529 | 529 | $oDB->rollback(); |
| 530 | 530 | return $output; |
| 531 | 531 | } |
| 532 | 532 | // Remove all extra variables |
| 533 | - if(Context::get('act')!='procFileDelete') |
|
| 533 | + if (Context::get('act') != 'procFileDelete') |
|
| 534 | 534 | { |
| 535 | 535 | $this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType()); |
| 536 | 536 | // Insert extra variables if the document successfully inserted. |
| 537 | 537 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
| 538 | - if(count($extra_keys)) |
|
| 538 | + if (count($extra_keys)) |
|
| 539 | 539 | { |
| 540 | - foreach($extra_keys as $idx => $extra_item) |
|
| 540 | + foreach ($extra_keys as $idx => $extra_item) |
|
| 541 | 541 | { |
| 542 | 542 | $value = NULL; |
| 543 | - if(isset($obj->{'extra_vars'.$idx})) |
|
| 543 | + if (isset($obj->{'extra_vars'.$idx})) |
|
| 544 | 544 | { |
| 545 | 545 | $tmp = $obj->{'extra_vars'.$idx}; |
| 546 | - if(is_array($tmp)) |
|
| 546 | + if (is_array($tmp)) |
|
| 547 | 547 | $value = implode('|@|', $tmp); |
| 548 | 548 | else |
| 549 | 549 | $value = trim($tmp); |
| 550 | 550 | } |
| 551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 552 | - if($value == NULL) continue; |
|
| 551 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 552 | + if ($value == NULL) continue; |
|
| 553 | 553 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | // Inert extra vars for multi-language support of title and contents. |
| 557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 557 | + if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 558 | + if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 559 | 559 | } |
| 560 | 560 | // Update the category if the category_srl exists. |
| 561 | - if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
| 561 | + if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
| 562 | 562 | { |
| 563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 563 | + if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 564 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 565 | 565 | } |
| 566 | 566 | // Call a trigger (after) |
| 567 | - if($output->toBool()) |
|
| 567 | + if ($output->toBool()) |
|
| 568 | 568 | { |
| 569 | 569 | $trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj); |
| 570 | - if(!$trigger_output->toBool()) |
|
| 570 | + if (!$trigger_output->toBool()) |
|
| 571 | 571 | { |
| 572 | 572 | $oDB->rollback(); |
| 573 | 573 | return $trigger_output; |
@@ -577,15 +577,15 @@ discard block |
||
| 577 | 577 | // commit |
| 578 | 578 | $oDB->commit(); |
| 579 | 579 | // Remove the thumbnail file |
| 580 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
| 580 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
| 581 | 581 | |
| 582 | - $output->add('document_srl',$obj->document_srl); |
|
| 582 | + $output->add('document_srl', $obj->document_srl); |
|
| 583 | 583 | //remove from cache |
| 584 | 584 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 585 | - if($oCacheHandler->isSupport()) |
|
| 585 | + if ($oCacheHandler->isSupport()) |
|
| 586 | 586 | { |
| 587 | 587 | //remove document item from cache |
| 588 | - $cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl; |
|
| 588 | + $cache_key = 'document_item:'.getNumberingPath($obj->document_srl).$obj->document_srl; |
|
| 589 | 589 | $oCacheHandler->delete($cache_key); |
| 590 | 590 | } |
| 591 | 591 | |
@@ -606,33 +606,33 @@ discard block |
||
| 606 | 606 | $trigger_obj = new stdClass(); |
| 607 | 607 | $trigger_obj->document_srl = $document_srl; |
| 608 | 608 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
| 609 | - if(!$output->toBool()) return $output; |
|
| 609 | + if (!$output->toBool()) return $output; |
|
| 610 | 610 | |
| 611 | 611 | // begin transaction |
| 612 | 612 | $oDB = &DB::getInstance(); |
| 613 | 613 | $oDB->begin(); |
| 614 | 614 | |
| 615 | - if(!$isEmptyTrash) |
|
| 615 | + if (!$isEmptyTrash) |
|
| 616 | 616 | { |
| 617 | 617 | // get model object of the document |
| 618 | 618 | $oDocumentModel = getModel('document'); |
| 619 | 619 | // Check if the documnet exists |
| 620 | 620 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
| 621 | 621 | } |
| 622 | - else if($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists'); |
|
| 622 | + else if ($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists'); |
|
| 623 | 623 | |
| 624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document'); |
|
| 624 | + if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document'); |
|
| 625 | 625 | // Check if a permossion is granted |
| 626 | - if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted'); |
|
| 626 | + if (!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted'); |
|
| 627 | 627 | |
| 628 | 628 | //if empty trash, document already deleted, therefore document not delete |
| 629 | 629 | $args = new stdClass(); |
| 630 | 630 | $args->document_srl = $document_srl; |
| 631 | - if(!$isEmptyTrash) |
|
| 631 | + if (!$isEmptyTrash) |
|
| 632 | 632 | { |
| 633 | 633 | // Delete the document |
| 634 | 634 | $output = executeQuery('document.deleteDocument', $args); |
| 635 | - if(!$output->toBool()) |
|
| 635 | + if (!$output->toBool()) |
|
| 636 | 636 | { |
| 637 | 637 | $oDB->rollback(); |
| 638 | 638 | return $output; |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | $this->deleteDocumentHistory(null, $document_srl, null); |
| 645 | 645 | // Update category information if the category_srl exists. |
| 646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 646 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
| 647 | 647 | // Delete a declared list |
| 648 | 648 | executeQuery('document.deleteDeclared', $args); |
| 649 | 649 | // Delete extra variable |
@@ -651,11 +651,11 @@ discard block |
||
| 651 | 651 | |
| 652 | 652 | //this |
| 653 | 653 | // Call a trigger (after) |
| 654 | - if($output->toBool()) |
|
| 654 | + if ($output->toBool()) |
|
| 655 | 655 | { |
| 656 | 656 | $trigger_obj = $oDocument->getObjectVars(); |
| 657 | 657 | $trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj); |
| 658 | - if(!$trigger_output->toBool()) |
|
| 658 | + if (!$trigger_output->toBool()) |
|
| 659 | 659 | { |
| 660 | 660 | $oDB->rollback(); |
| 661 | 661 | return $trigger_output; |
@@ -667,16 +667,16 @@ discard block |
||
| 667 | 667 | $this->_deleteDocumentVotedLog($args); |
| 668 | 668 | |
| 669 | 669 | // Remove the thumbnail file |
| 670 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3))); |
|
| 670 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3))); |
|
| 671 | 671 | |
| 672 | 672 | // commit |
| 673 | 673 | $oDB->commit(); |
| 674 | 674 | |
| 675 | 675 | //remove from cache |
| 676 | 676 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 677 | - if($oCacheHandler->isSupport()) |
|
| 677 | + if ($oCacheHandler->isSupport()) |
|
| 678 | 678 | { |
| 679 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 679 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 680 | 680 | $oCacheHandler->delete($cache_key); |
| 681 | 681 | } |
| 682 | 682 | |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | { |
| 724 | 724 | $trash_args = new stdClass(); |
| 725 | 725 | // Get trash_srl if a given trash_srl doesn't exist |
| 726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 726 | + if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 727 | 727 | else $trash_args->trash_srl = $obj->trash_srl; |
| 728 | 728 | // Get its module_srl which the document belongs to |
| 729 | 729 | $oDocumentModel = getModel('document'); |
@@ -732,12 +732,12 @@ discard block |
||
| 732 | 732 | $trash_args->module_srl = $oDocument->get('module_srl'); |
| 733 | 733 | $obj->module_srl = $oDocument->get('module_srl'); |
| 734 | 734 | // Cannot throw data from the trash to the trash |
| 735 | - if($trash_args->module_srl == 0) return false; |
|
| 735 | + if ($trash_args->module_srl == 0) return false; |
|
| 736 | 736 | // Data setting |
| 737 | 737 | $trash_args->document_srl = $obj->document_srl; |
| 738 | 738 | $trash_args->description = $obj->description; |
| 739 | 739 | // Insert member's information only if the member is logged-in and not manually registered. |
| 740 | - if(Context::get('is_logged')&&!$manual_inserted) |
|
| 740 | + if (Context::get('is_logged') && !$manual_inserted) |
|
| 741 | 741 | { |
| 742 | 742 | $logged_info = Context::get('logged_info'); |
| 743 | 743 | $trash_args->member_srl = $logged_info->member_srl; |
@@ -773,14 +773,14 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | $oTrashAdminController = getAdminController('trash'); |
| 775 | 775 | $output = $oTrashAdminController->insertTrash($oTrashVO); |
| 776 | - if(!$output->toBool()) |
|
| 776 | + if (!$output->toBool()) |
|
| 777 | 777 | { |
| 778 | 778 | $oDB->rollback(); |
| 779 | 779 | return $output; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | $output = executeQuery('document.deleteDocument', $trash_args); |
| 783 | - if(!$output->toBool()) |
|
| 783 | + if (!$output->toBool()) |
|
| 784 | 784 | { |
| 785 | 785 | $oDB->rollback(); |
| 786 | 786 | return $output; |
@@ -793,12 +793,12 @@ discard block |
||
| 793 | 793 | }*/ |
| 794 | 794 | |
| 795 | 795 | // update category |
| 796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 796 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
| 797 | 797 | |
| 798 | 798 | // remove thumbnails |
| 799 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
| 799 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
| 800 | 800 | // Set the attachment to be invalid state |
| 801 | - if($oDocument->hasUploadedFiles()) |
|
| 801 | + if ($oDocument->hasUploadedFiles()) |
|
| 802 | 802 | { |
| 803 | 803 | $args = new stdClass(); |
| 804 | 804 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -806,10 +806,10 @@ discard block |
||
| 806 | 806 | executeQuery('file.updateFileValid', $args); |
| 807 | 807 | } |
| 808 | 808 | // Call a trigger (after) |
| 809 | - if($output->toBool()) |
|
| 809 | + if ($output->toBool()) |
|
| 810 | 810 | { |
| 811 | 811 | $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj); |
| 812 | - if(!$trigger_output->toBool()) |
|
| 812 | + if (!$trigger_output->toBool()) |
|
| 813 | 813 | { |
| 814 | 814 | $oDB->rollback(); |
| 815 | 815 | return $trigger_output; |
@@ -821,9 +821,9 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | // Clear cache |
| 823 | 823 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 824 | - if($oCacheHandler->isSupport()) |
|
| 824 | + if ($oCacheHandler->isSupport()) |
|
| 825 | 825 | { |
| 826 | - $cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl; |
|
| 826 | + $cache_key = 'document_item:'.getNumberingPath($oDocument->document_srl).$oDocument->document_srl; |
|
| 827 | 827 | $oCacheHandler->delete($cache_key); |
| 828 | 828 | } |
| 829 | 829 | |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | function updateReadedCount(&$oDocument) |
| 839 | 839 | { |
| 840 | 840 | // Pass if Crawler access |
| 841 | - if(isCrawler()) return false; |
|
| 841 | + if (isCrawler()) return false; |
|
| 842 | 842 | |
| 843 | 843 | $document_srl = $oDocument->document_srl; |
| 844 | 844 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,19 +846,19 @@ discard block |
||
| 846 | 846 | |
| 847 | 847 | // Call a trigger when the read count is updated (before) |
| 848 | 848 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
| 849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 849 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 850 | 850 | |
| 851 | 851 | // Pass if read count is increaded on the session information |
| 852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
| 852 | + if ($_SESSION['readed_document'][$document_srl]) return false; |
|
| 853 | 853 | |
| 854 | 854 | // Pass if the author's IP address is as same as visitor's. |
| 855 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 855 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 856 | 856 | { |
| 857 | 857 | $_SESSION['readed_document'][$document_srl] = true; |
| 858 | 858 | return false; |
| 859 | 859 | } |
| 860 | 860 | // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. |
| 861 | - if($member_srl && $logged_info->member_srl == $member_srl) |
|
| 861 | + if ($member_srl && $logged_info->member_srl == $member_srl) |
|
| 862 | 862 | { |
| 863 | 863 | $_SESSION['readed_document'][$document_srl] = true; |
| 864 | 864 | return false; |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | |
| 875 | 875 | // Call a trigger when the read count is updated (after) |
| 876 | 876 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); |
| 877 | - if(!$trigger_output->toBool()) |
|
| 877 | + if (!$trigger_output->toBool()) |
|
| 878 | 878 | { |
| 879 | 879 | $oDB->rollback(); |
| 880 | 880 | return $trigger_output; |
@@ -883,15 +883,15 @@ discard block |
||
| 883 | 883 | $oDB->commit(); |
| 884 | 884 | |
| 885 | 885 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 886 | - if($oCacheHandler->isSupport()) |
|
| 886 | + if ($oCacheHandler->isSupport()) |
|
| 887 | 887 | { |
| 888 | 888 | //remove document item from cache |
| 889 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 889 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 890 | 890 | $oCacheHandler->delete($cache_key); |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | // Register session |
| 894 | - if(!$_SESSION['banned_document'][$document_srl]) |
|
| 894 | + if (!$_SESSION['banned_document'][$document_srl]) |
|
| 895 | 895 | { |
| 896 | 896 | $_SESSION['readed_document'][$document_srl] = true; |
| 897 | 897 | } |
@@ -914,21 +914,21 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
| 916 | 916 | { |
| 917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1,'msg_invalid_request'); |
|
| 917 | + if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1, 'msg_invalid_request'); |
|
| 918 | 918 | |
| 919 | 919 | $obj = new stdClass(); |
| 920 | 920 | $obj->module_srl = $module_srl; |
| 921 | 921 | $obj->var_idx = $var_idx; |
| 922 | 922 | $obj->var_name = $var_name; |
| 923 | 923 | $obj->var_type = $var_type; |
| 924 | - $obj->var_is_required = $var_is_required=='Y'?'Y':'N'; |
|
| 925 | - $obj->var_search = $var_search=='Y'?'Y':'N'; |
|
| 924 | + $obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N'; |
|
| 925 | + $obj->var_search = $var_search == 'Y' ? 'Y' : 'N'; |
|
| 926 | 926 | $obj->var_default = $var_default; |
| 927 | 927 | $obj->var_desc = $var_desc; |
| 928 | 928 | $obj->eid = $eid; |
| 929 | 929 | |
| 930 | 930 | $output = executeQuery('document.getDocumentExtraKeys', $obj); |
| 931 | - if(!$output->data) |
|
| 931 | + if (!$output->data) |
|
| 932 | 932 | { |
| 933 | 933 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
| 934 | 934 | } |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 943 | - if($oCacheHandler->isSupport()) |
|
| 943 | + if ($oCacheHandler->isSupport()) |
|
| 944 | 944 | { |
| 945 | 945 | $object_key = 'module_document_extra_keys:'.$module_srl; |
| 946 | 946 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -958,42 +958,42 @@ discard block |
||
| 958 | 958 | */ |
| 959 | 959 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
| 960 | 960 | { |
| 961 | - if(!$module_srl) return new Object(-1,'msg_invalid_request'); |
|
| 961 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 962 | 962 | $obj = new stdClass(); |
| 963 | 963 | $obj->module_srl = $module_srl; |
| 964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 964 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 965 | 965 | |
| 966 | 966 | $oDB = DB::getInstance(); |
| 967 | 967 | $oDB->begin(); |
| 968 | 968 | |
| 969 | 969 | $output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj); |
| 970 | - if(!$output->toBool()) |
|
| 970 | + if (!$output->toBool()) |
|
| 971 | 971 | { |
| 972 | 972 | $oDB->rollback(); |
| 973 | 973 | return $output; |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | - if($var_idx != NULL) |
|
| 976 | + if ($var_idx != NULL) |
|
| 977 | 977 | { |
| 978 | 978 | $output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj); |
| 979 | - if(!$output->toBool()) |
|
| 979 | + if (!$output->toBool()) |
|
| 980 | 980 | { |
| 981 | 981 | $oDB->rollback(); |
| 982 | 982 | return $output; |
| 983 | 983 | } |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
| 987 | - if(!$output->toBool()) |
|
| 986 | + $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
| 987 | + if (!$output->toBool()) |
|
| 988 | 988 | { |
| 989 | 989 | $oDB->rollback(); |
| 990 | 990 | return $output; |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | - if($var_idx != NULL) |
|
| 993 | + if ($var_idx != NULL) |
|
| 994 | 994 | { |
| 995 | 995 | $output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj); |
| 996 | - if(!$output->toBool()) |
|
| 996 | + if (!$output->toBool()) |
|
| 997 | 997 | { |
| 998 | 998 | $oDB->rollback(); |
| 999 | 999 | return $output; |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | $oDB->commit(); |
| 1004 | 1004 | |
| 1005 | 1005 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 1006 | - if($oCacheHandler->isSupport()) |
|
| 1006 | + if ($oCacheHandler->isSupport()) |
|
| 1007 | 1007 | { |
| 1008 | 1008 | $object_key = 'module_document_extra_keys:'.$module_srl; |
| 1009 | 1009 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -1025,8 +1025,8 @@ discard block |
||
| 1025 | 1025 | */ |
| 1026 | 1026 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
| 1027 | 1027 | { |
| 1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1,'msg_invalid_request'); |
|
| 1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
| 1028 | + if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1, 'msg_invalid_request'); |
|
| 1029 | + if (!$lang_code) $lang_code = Context::getLangType(); |
|
| 1030 | 1030 | |
| 1031 | 1031 | $obj = new stdClass; |
| 1032 | 1032 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1052,10 @@ discard block |
||
| 1052 | 1052 | { |
| 1053 | 1053 | $obj = new stdClass(); |
| 1054 | 1054 | $obj->module_srl = $module_srl; |
| 1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
| 1055 | + if (!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1056 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1057 | + if (!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1058 | + if (!is_null($eid)) $obj->eid = $eid; |
|
| 1059 | 1059 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
| 1060 | 1060 | return $output; |
| 1061 | 1061 | } |
@@ -1069,10 +1069,10 @@ discard block |
||
| 1069 | 1069 | */ |
| 1070 | 1070 | function updateVotedCount($document_srl, $point = 1) |
| 1071 | 1071 | { |
| 1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
| 1072 | + if ($point > 0) $failed_voted = 'failed_voted'; |
|
| 1073 | 1073 | else $failed_voted = 'failed_blamed'; |
| 1074 | 1074 | // Return fail if session already has information about votes |
| 1075 | - if($_SESSION['voted_document'][$document_srl]) |
|
| 1075 | + if ($_SESSION['voted_document'][$document_srl]) |
|
| 1076 | 1076 | { |
| 1077 | 1077 | return new Object(-1, $failed_voted); |
| 1078 | 1078 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | $oDocumentModel = getModel('document'); |
| 1081 | 1081 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 1082 | 1082 | // Pass if the author's IP address is as same as visitor's. |
| 1083 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 1083 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 1084 | 1084 | { |
| 1085 | 1085 | $_SESSION['voted_document'][$document_srl] = true; |
| 1086 | 1086 | return new Object(-1, $failed_voted); |
@@ -1091,10 +1091,10 @@ discard block |
||
| 1091 | 1091 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
| 1092 | 1092 | |
| 1093 | 1093 | // Check if document's author is a member. |
| 1094 | - if($oDocument->get('member_srl')) |
|
| 1094 | + if ($oDocument->get('member_srl')) |
|
| 1095 | 1095 | { |
| 1096 | 1096 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
| 1097 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1097 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1098 | 1098 | { |
| 1099 | 1099 | $_SESSION['voted_document'][$document_srl] = true; |
| 1100 | 1100 | return new Object(-1, $failed_voted); |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | |
| 1104 | 1104 | // Use member_srl for logged-in members and IP address for non-members. |
| 1105 | 1105 | $args = new stdClass; |
| 1106 | - if($member_srl) |
|
| 1106 | + if ($member_srl) |
|
| 1107 | 1107 | { |
| 1108 | 1108 | $args->member_srl = $member_srl; |
| 1109 | 1109 | } |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | $args->document_srl = $document_srl; |
| 1115 | 1115 | $output = executeQuery('document.getDocumentVotedLogInfo', $args); |
| 1116 | 1116 | // Pass after registering a session if log information has vote-up logs |
| 1117 | - if($output->data->count) |
|
| 1117 | + if ($output->data->count) |
|
| 1118 | 1118 | { |
| 1119 | 1119 | $_SESSION['voted_document'][$document_srl] = true; |
| 1120 | 1120 | return new Object(-1, $failed_voted); |
@@ -1125,7 +1125,7 @@ discard block |
||
| 1125 | 1125 | $oDB->begin(); |
| 1126 | 1126 | |
| 1127 | 1127 | // Update the voted count |
| 1128 | - if($point < 0) |
|
| 1128 | + if ($point < 0) |
|
| 1129 | 1129 | { |
| 1130 | 1130 | $args->blamed_count = $oDocument->get('blamed_count') + $point; |
| 1131 | 1131 | $output = executeQuery('document.updateBlamedCount', $args); |
@@ -1135,11 +1135,11 @@ discard block |
||
| 1135 | 1135 | $args->voted_count = $oDocument->get('voted_count') + $point; |
| 1136 | 1136 | $output = executeQuery('document.updateVotedCount', $args); |
| 1137 | 1137 | } |
| 1138 | - if(!$output->toBool()) return $output; |
|
| 1138 | + if (!$output->toBool()) return $output; |
|
| 1139 | 1139 | // Leave logs |
| 1140 | 1140 | $args->point = $point; |
| 1141 | 1141 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
| 1142 | - if(!$output->toBool()) return $output; |
|
| 1142 | + if (!$output->toBool()) return $output; |
|
| 1143 | 1143 | |
| 1144 | 1144 | $obj = new stdClass; |
| 1145 | 1145 | $obj->member_srl = $oDocument->get('member_srl'); |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | $obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count'); |
| 1151 | 1151 | $obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count; |
| 1152 | 1152 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj); |
| 1153 | - if(!$trigger_output->toBool()) |
|
| 1153 | + if (!$trigger_output->toBool()) |
|
| 1154 | 1154 | { |
| 1155 | 1155 | $oDB->rollback(); |
| 1156 | 1156 | return $trigger_output; |
@@ -1159,10 +1159,10 @@ discard block |
||
| 1159 | 1159 | $oDB->commit(); |
| 1160 | 1160 | |
| 1161 | 1161 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1162 | - if($oCacheHandler->isSupport()) |
|
| 1162 | + if ($oCacheHandler->isSupport()) |
|
| 1163 | 1163 | { |
| 1164 | 1164 | //remove document item from cache |
| 1165 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1165 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 1166 | 1166 | $oCacheHandler->delete($cache_key); |
| 1167 | 1167 | } |
| 1168 | 1168 | |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | |
| 1172 | 1172 | // Return result |
| 1173 | 1173 | $output = new Object(); |
| 1174 | - if($point > 0) |
|
| 1174 | + if ($point > 0) |
|
| 1175 | 1175 | { |
| 1176 | 1176 | $output->setMessage('success_voted'); |
| 1177 | 1177 | $output->add('voted_count', $obj->after_point); |
@@ -1193,13 +1193,13 @@ discard block |
||
| 1193 | 1193 | function declaredDocument($document_srl) |
| 1194 | 1194 | { |
| 1195 | 1195 | // Fail if session information already has a reported document |
| 1196 | - if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared'); |
|
| 1196 | + if ($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared'); |
|
| 1197 | 1197 | |
| 1198 | 1198 | // Check if previously reported |
| 1199 | 1199 | $args = new stdClass(); |
| 1200 | 1200 | $args->document_srl = $document_srl; |
| 1201 | 1201 | $output = executeQuery('document.getDeclaredDocument', $args); |
| 1202 | - if(!$output->toBool()) return $output; |
|
| 1202 | + if (!$output->toBool()) return $output; |
|
| 1203 | 1203 | |
| 1204 | 1204 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
| 1205 | 1205 | |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | |
| 1210 | 1210 | // Call a trigger (before) |
| 1211 | 1211 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj); |
| 1212 | - if(!$trigger_output->toBool()) |
|
| 1212 | + if (!$trigger_output->toBool()) |
|
| 1213 | 1213 | { |
| 1214 | 1214 | return $trigger_output; |
| 1215 | 1215 | } |
@@ -1219,19 +1219,19 @@ discard block |
||
| 1219 | 1219 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 1220 | 1220 | |
| 1221 | 1221 | // Pass if the author's IP address is as same as visitor's. |
| 1222 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
| 1222 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
| 1223 | 1223 | $_SESSION['declared_document'][$document_srl] = true; |
| 1224 | 1224 | return new Object(-1, 'failed_declared'); |
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | // Check if document's author is a member. |
| 1228 | - if($oDocument->get('member_srl')) |
|
| 1228 | + if ($oDocument->get('member_srl')) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | // Create a member model object |
| 1231 | 1231 | $oMemberModel = getModel('member'); |
| 1232 | 1232 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
| 1233 | 1233 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
| 1234 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1234 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
| 1235 | 1235 | { |
| 1236 | 1236 | $_SESSION['declared_document'][$document_srl] = true; |
| 1237 | 1237 | return new Object(-1, 'failed_declared'); |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | |
| 1241 | 1241 | // Use member_srl for logged-in members and IP address for non-members. |
| 1242 | 1242 | $args = new stdClass; |
| 1243 | - if($member_srl) |
|
| 1243 | + if ($member_srl) |
|
| 1244 | 1244 | { |
| 1245 | 1245 | $args->member_srl = $member_srl; |
| 1246 | 1246 | } |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | $output = executeQuery('document.getDocumentDeclaredLogInfo', $args); |
| 1254 | 1254 | |
| 1255 | 1255 | // Pass after registering a sesson if reported/declared documents are in the logs. |
| 1256 | - if($output->data->count) |
|
| 1256 | + if ($output->data->count) |
|
| 1257 | 1257 | { |
| 1258 | 1258 | $_SESSION['declared_document'][$document_srl] = true; |
| 1259 | 1259 | return new Object(-1, 'failed_declared'); |
@@ -1264,23 +1264,23 @@ discard block |
||
| 1264 | 1264 | $oDB->begin(); |
| 1265 | 1265 | |
| 1266 | 1266 | // Add the declared document |
| 1267 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1267 | + if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1268 | 1268 | else $output = executeQuery('document.insertDeclaredDocument', $args); |
| 1269 | - if(!$output->toBool()) return $output; |
|
| 1269 | + if (!$output->toBool()) return $output; |
|
| 1270 | 1270 | // Leave logs |
| 1271 | 1271 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
| 1272 | - if(!$output->toBool()) |
|
| 1272 | + if (!$output->toBool()) |
|
| 1273 | 1273 | { |
| 1274 | 1274 | $oDB->rollback(); |
| 1275 | 1275 | return $output; |
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | - $this->add('declared_count', $declared_count+1); |
|
| 1278 | + $this->add('declared_count', $declared_count + 1); |
|
| 1279 | 1279 | |
| 1280 | 1280 | // Call a trigger (after) |
| 1281 | 1281 | $trigger_obj->declared_count = $declared_count + 1; |
| 1282 | 1282 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj); |
| 1283 | - if(!$trigger_output->toBool()) |
|
| 1283 | + if (!$trigger_output->toBool()) |
|
| 1284 | 1284 | { |
| 1285 | 1285 | $oDB->rollback(); |
| 1286 | 1286 | return $trigger_output; |
@@ -1310,16 +1310,16 @@ discard block |
||
| 1310 | 1310 | $args->document_srl = $document_srl; |
| 1311 | 1311 | $args->comment_count = $comment_count; |
| 1312 | 1312 | |
| 1313 | - if($comment_inserted) |
|
| 1313 | + if ($comment_inserted) |
|
| 1314 | 1314 | { |
| 1315 | - $args->update_order = -1*getNextSequence(); |
|
| 1315 | + $args->update_order = -1 * getNextSequence(); |
|
| 1316 | 1316 | $args->last_updater = $last_updater; |
| 1317 | 1317 | |
| 1318 | 1318 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1319 | - if($oCacheHandler->isSupport()) |
|
| 1319 | + if ($oCacheHandler->isSupport()) |
|
| 1320 | 1320 | { |
| 1321 | 1321 | //remove document item from cache |
| 1322 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1322 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 1323 | 1323 | $oCacheHandler->delete($cache_key); |
| 1324 | 1324 | } |
| 1325 | 1325 | } |
@@ -1340,10 +1340,10 @@ discard block |
||
| 1340 | 1340 | $args->trackback_count = $trackback_count; |
| 1341 | 1341 | |
| 1342 | 1342 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1343 | - if($oCacheHandler->isSupport()) |
|
| 1343 | + if ($oCacheHandler->isSupport()) |
|
| 1344 | 1344 | { |
| 1345 | 1345 | //remove document item from cache |
| 1346 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1346 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
| 1347 | 1347 | $oCacheHandler->delete($cache_key); |
| 1348 | 1348 | } |
| 1349 | 1349 | |
@@ -1358,14 +1358,14 @@ discard block |
||
| 1358 | 1358 | function insertCategory($obj) |
| 1359 | 1359 | { |
| 1360 | 1360 | // Sort the order to display if a child category is added |
| 1361 | - if($obj->parent_srl) |
|
| 1361 | + if ($obj->parent_srl) |
|
| 1362 | 1362 | { |
| 1363 | 1363 | // Get its parent category |
| 1364 | 1364 | $oDocumentModel = getModel('document'); |
| 1365 | 1365 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
| 1366 | 1366 | $obj->list_order = $parent_category->list_order; |
| 1367 | - $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
|
| 1368 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1367 | + $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1); |
|
| 1368 | + if (!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | else |
| 1371 | 1371 | { |
@@ -1373,7 +1373,7 @@ discard block |
||
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | $output = executeQuery('document.insertCategory', $obj); |
| 1376 | - if($output->toBool()) |
|
| 1376 | + if ($output->toBool()) |
|
| 1377 | 1377 | { |
| 1378 | 1378 | $output->add('category_srl', $obj->category_srl); |
| 1379 | 1379 | $this->makeCategoryFile($obj->module_srl); |
@@ -1407,13 +1407,13 @@ discard block |
||
| 1407 | 1407 | { |
| 1408 | 1408 | // Create a document model object |
| 1409 | 1409 | $oDocumentModel = getModel('document'); |
| 1410 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
| 1410 | + if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl); |
|
| 1411 | 1411 | |
| 1412 | 1412 | $args = new stdClass; |
| 1413 | 1413 | $args->category_srl = $category_srl; |
| 1414 | 1414 | $args->document_count = $document_count; |
| 1415 | 1415 | $output = executeQuery('document.updateCategoryCount', $args); |
| 1416 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1416 | + if ($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1417 | 1417 | |
| 1418 | 1418 | return $output; |
| 1419 | 1419 | } |
@@ -1426,7 +1426,7 @@ discard block |
||
| 1426 | 1426 | function updateCategory($obj) |
| 1427 | 1427 | { |
| 1428 | 1428 | $output = executeQuery('document.updateCategory', $obj); |
| 1429 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1429 | + if ($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1430 | 1430 | return $output; |
| 1431 | 1431 | } |
| 1432 | 1432 | |
@@ -1443,32 +1443,32 @@ discard block |
||
| 1443 | 1443 | $category_info = $oDocumentModel->getCategory($category_srl); |
| 1444 | 1444 | // Display an error that the category cannot be deleted if it has a child |
| 1445 | 1445 | $output = executeQuery('document.getChildCategoryCount', $args); |
| 1446 | - if(!$output->toBool()) return $output; |
|
| 1447 | - if($output->data->count>0) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1446 | + if (!$output->toBool()) return $output; |
|
| 1447 | + if ($output->data->count > 0) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1448 | 1448 | // Delete a category information |
| 1449 | 1449 | $output = executeQuery('document.deleteCategory', $args); |
| 1450 | - if(!$output->toBool()) return $output; |
|
| 1450 | + if (!$output->toBool()) return $output; |
|
| 1451 | 1451 | |
| 1452 | 1452 | $this->makeCategoryFile($category_info->module_srl); |
| 1453 | 1453 | // remvove cache |
| 1454 | 1454 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1455 | - if($oCacheHandler->isSupport()) |
|
| 1455 | + if ($oCacheHandler->isSupport()) |
|
| 1456 | 1456 | { |
| 1457 | 1457 | $page = 0; |
| 1458 | - while(true) { |
|
| 1458 | + while (true) { |
|
| 1459 | 1459 | $args = new stdClass(); |
| 1460 | 1460 | $args->category_srl = $category_srl; |
| 1461 | 1461 | $args->list_count = 100; |
| 1462 | 1462 | $args->page = ++$page; |
| 1463 | 1463 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
| 1464 | 1464 | |
| 1465 | - if($output->data == array()) |
|
| 1465 | + if ($output->data == array()) |
|
| 1466 | 1466 | break; |
| 1467 | 1467 | |
| 1468 | - foreach($output->data as $val) |
|
| 1468 | + foreach ($output->data as $val) |
|
| 1469 | 1469 | { |
| 1470 | 1470 | //remove document item from cache |
| 1471 | - $cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl; |
|
| 1471 | + $cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl; |
|
| 1472 | 1472 | $oCacheHandler->delete($cache_key); |
| 1473 | 1473 | } |
| 1474 | 1474 | } |
@@ -1515,18 +1515,18 @@ discard block |
||
| 1515 | 1515 | // Seek a full list of categories |
| 1516 | 1516 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1517 | 1517 | $category_srl_list = array_keys($category_list); |
| 1518 | - if(count($category_srl_list)<2) return new Object(); |
|
| 1518 | + if (count($category_srl_list) < 2) return new Object(); |
|
| 1519 | 1519 | |
| 1520 | 1520 | $prev_category = NULL; |
| 1521 | - foreach($category_list as $key => $val) |
|
| 1521 | + foreach ($category_list as $key => $val) |
|
| 1522 | 1522 | { |
| 1523 | - if($key==$category_srl) break; |
|
| 1523 | + if ($key == $category_srl) break; |
|
| 1524 | 1524 | $prev_category = $val; |
| 1525 | 1525 | } |
| 1526 | 1526 | // Return if the previous category doesn't exist |
| 1527 | - if(!$prev_category) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1527 | + if (!$prev_category) return new Object(-1, Context::getLang('msg_category_not_moved')); |
|
| 1528 | 1528 | // Return if the selected category is the top level |
| 1529 | - if($category_srl_list[0]==$category_srl) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1529 | + if ($category_srl_list[0] == $category_srl) return new Object(-1, Context::getLang('msg_category_not_moved')); |
|
| 1530 | 1530 | // Information of the selected category |
| 1531 | 1531 | $cur_args = new stdClass; |
| 1532 | 1532 | $cur_args->category_srl = $category_srl; |
@@ -1562,15 +1562,15 @@ discard block |
||
| 1562 | 1562 | // Seek a full list of categories |
| 1563 | 1563 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1564 | 1564 | $category_srl_list = array_keys($category_list); |
| 1565 | - if(count($category_srl_list)<2) return new Object(); |
|
| 1565 | + if (count($category_srl_list) < 2) return new Object(); |
|
| 1566 | 1566 | |
| 1567 | - for($i=0;$i<count($category_srl_list);$i++) |
|
| 1567 | + for ($i = 0; $i < count($category_srl_list); $i++) |
|
| 1568 | 1568 | { |
| 1569 | - if($category_srl_list[$i]==$category_srl) break; |
|
| 1569 | + if ($category_srl_list[$i] == $category_srl) break; |
|
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | - $next_category_srl = $category_srl_list[$i+1]; |
|
| 1573 | - if(!$category_list[$next_category_srl]) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1572 | + $next_category_srl = $category_srl_list[$i + 1]; |
|
| 1573 | + if (!$category_list[$next_category_srl]) return new Object(-1, Context::getLang('msg_category_not_moved')); |
|
| 1574 | 1574 | $next_category = $category_list[$next_category_srl]; |
| 1575 | 1575 | // Information of the selected category |
| 1576 | 1576 | $cur_args = new stdClass; |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | { |
| 1598 | 1598 | $oDocumentModel = getModel('document'); |
| 1599 | 1599 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
| 1600 | - if(!count($extra_keys)) return; |
|
| 1600 | + if (!count($extra_keys)) return; |
|
| 1601 | 1601 | |
| 1602 | 1602 | $js_code = array(); |
| 1603 | 1603 | $js_code[] = '<script>//<![CDATA['; |
@@ -1607,16 +1607,16 @@ discard block |
||
| 1607 | 1607 | |
| 1608 | 1608 | $logged_info = Context::get('logged_info'); |
| 1609 | 1609 | |
| 1610 | - foreach($extra_keys as $idx => $val) |
|
| 1610 | + foreach ($extra_keys as $idx => $val) |
|
| 1611 | 1611 | { |
| 1612 | 1612 | $idx = $val->idx; |
| 1613 | - if($val->type == 'kr_zip') |
|
| 1613 | + if ($val->type == 'kr_zip') |
|
| 1614 | 1614 | { |
| 1615 | 1615 | $idx .= '[]'; |
| 1616 | 1616 | } |
| 1617 | 1617 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
| 1618 | 1618 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
| 1619 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1619 | + if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | $js_code[] = '})(jQuery);'; |
@@ -1634,12 +1634,12 @@ discard block |
||
| 1634 | 1634 | function procDocumentInsertCategory($args = null) |
| 1635 | 1635 | { |
| 1636 | 1636 | // List variables |
| 1637 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
| 1637 | + if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid'); |
|
| 1638 | 1638 | $args->title = $args->category_title; |
| 1639 | 1639 | $args->description = $args->category_description; |
| 1640 | 1640 | $args->color = $args->category_color; |
| 1641 | 1641 | |
| 1642 | - if(!$args->module_srl && $args->mid) |
|
| 1642 | + if (!$args->module_srl && $args->mid) |
|
| 1643 | 1643 | { |
| 1644 | 1644 | $mid = $args->mid; |
| 1645 | 1645 | unset($args->mid); |
@@ -1650,28 +1650,28 @@ discard block |
||
| 1650 | 1650 | $columnList = array('module_srl', 'module'); |
| 1651 | 1651 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1652 | 1652 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1653 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1653 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1654 | 1654 | |
| 1655 | - if($args->expand !="Y") $args->expand = "N"; |
|
| 1656 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
| 1655 | + if ($args->expand != "Y") $args->expand = "N"; |
|
| 1656 | + if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls); |
|
| 1657 | 1657 | else $args->group_srls = implode(',', $args->group_srls); |
| 1658 | - $args->parent_srl = (int)$args->parent_srl; |
|
| 1658 | + $args->parent_srl = (int) $args->parent_srl; |
|
| 1659 | 1659 | |
| 1660 | 1660 | $oDocumentModel = getModel('document'); |
| 1661 | 1661 | |
| 1662 | 1662 | $oDB = &DB::getInstance(); |
| 1663 | 1663 | $oDB->begin(); |
| 1664 | 1664 | // Check if already exists |
| 1665 | - if($args->category_srl) |
|
| 1665 | + if ($args->category_srl) |
|
| 1666 | 1666 | { |
| 1667 | 1667 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1668 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1668 | + if ($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1669 | 1669 | } |
| 1670 | 1670 | // Update if exists |
| 1671 | - if($args->category_srl) |
|
| 1671 | + if ($args->category_srl) |
|
| 1672 | 1672 | { |
| 1673 | 1673 | $output = $this->updateCategory($args); |
| 1674 | - if(!$output->toBool()) |
|
| 1674 | + if (!$output->toBool()) |
|
| 1675 | 1675 | { |
| 1676 | 1676 | $oDB->rollback(); |
| 1677 | 1677 | return $output; |
@@ -1681,7 +1681,7 @@ discard block |
||
| 1681 | 1681 | else |
| 1682 | 1682 | { |
| 1683 | 1683 | $output = $this->insertCategory($args); |
| 1684 | - if(!$output->toBool()) |
|
| 1684 | + if (!$output->toBool()) |
|
| 1685 | 1685 | { |
| 1686 | 1686 | $oDB->rollback(); |
| 1687 | 1687 | return $output; |
@@ -1720,11 +1720,11 @@ discard block |
||
| 1720 | 1720 | $columnList = array('module_srl', 'module'); |
| 1721 | 1721 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
| 1722 | 1722 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1723 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1723 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1724 | 1724 | |
| 1725 | 1725 | // First child of the parent_category_srl |
| 1726 | 1726 | $source_args = new stdClass; |
| 1727 | - if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
| 1727 | + if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
| 1728 | 1728 | { |
| 1729 | 1729 | $parent_category = $oDocumentModel->getCategory($parent_category_srl); |
| 1730 | 1730 | |
@@ -1733,30 +1733,30 @@ discard block |
||
| 1733 | 1733 | $args->parent_srl = $parent_category_srl; |
| 1734 | 1734 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
| 1735 | 1735 | |
| 1736 | - if(!$output->toBool()) return $output; |
|
| 1737 | - $args->list_order = (int)$output->data->list_order; |
|
| 1738 | - if(!$args->list_order) $args->list_order = 0; |
|
| 1736 | + if (!$output->toBool()) return $output; |
|
| 1737 | + $args->list_order = (int) $output->data->list_order; |
|
| 1738 | + if (!$args->list_order) $args->list_order = 0; |
|
| 1739 | 1739 | $args->list_order--; |
| 1740 | 1740 | |
| 1741 | 1741 | $source_args->category_srl = $source_category_srl; |
| 1742 | 1742 | $source_args->parent_srl = $parent_category_srl; |
| 1743 | 1743 | $source_args->list_order = $args->list_order; |
| 1744 | 1744 | $output = $this->updateCategory($source_args); |
| 1745 | - if(!$output->toBool()) return $output; |
|
| 1745 | + if (!$output->toBool()) return $output; |
|
| 1746 | 1746 | // Sibling of the $target_category_srl |
| 1747 | 1747 | } |
| 1748 | - else if($target_category_srl > 0) |
|
| 1748 | + else if ($target_category_srl > 0) |
|
| 1749 | 1749 | { |
| 1750 | 1750 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
| 1751 | 1751 | // Move all siblings of the $target_category down |
| 1752 | - $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
|
| 1753 | - if(!$output->toBool()) return $output; |
|
| 1752 | + $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1); |
|
| 1753 | + if (!$output->toBool()) return $output; |
|
| 1754 | 1754 | |
| 1755 | 1755 | $source_args->category_srl = $source_category_srl; |
| 1756 | 1756 | $source_args->parent_srl = $target_category->parent_srl; |
| 1757 | - $source_args->list_order = $target_category->list_order+1; |
|
| 1757 | + $source_args->list_order = $target_category->list_order + 1; |
|
| 1758 | 1758 | $output = $this->updateCategory($source_args); |
| 1759 | - if(!$output->toBool()) return $output; |
|
| 1759 | + if (!$output->toBool()) return $output; |
|
| 1760 | 1760 | } |
| 1761 | 1761 | // Re-generate the xml file |
| 1762 | 1762 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1772,7 +1772,7 @@ discard block |
||
| 1772 | 1772 | function procDocumentDeleteCategory() |
| 1773 | 1773 | { |
| 1774 | 1774 | // List variables |
| 1775 | - $args = Context::gets('module_srl','category_srl'); |
|
| 1775 | + $args = Context::gets('module_srl', 'category_srl'); |
|
| 1776 | 1776 | |
| 1777 | 1777 | $oDB = &DB::getInstance(); |
| 1778 | 1778 | $oDB->begin(); |
@@ -1781,17 +1781,17 @@ discard block |
||
| 1781 | 1781 | $columnList = array('module_srl', 'module'); |
| 1782 | 1782 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1783 | 1783 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1784 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1784 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1785 | 1785 | |
| 1786 | 1786 | $oDocumentModel = getModel('document'); |
| 1787 | 1787 | // Get original information |
| 1788 | 1788 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1789 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 1789 | + if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 1790 | 1790 | // Display an error that the category cannot be deleted if it has a child node |
| 1791 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1791 | + if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1792 | 1792 | // Remove from the DB |
| 1793 | 1793 | $output = $this->deleteCategory($args->category_srl); |
| 1794 | - if(!$output->toBool()) |
|
| 1794 | + if (!$output->toBool()) |
|
| 1795 | 1795 | { |
| 1796 | 1796 | $oDB->rollback(); |
| 1797 | 1797 | return $output; |
@@ -1822,11 +1822,11 @@ discard block |
||
| 1822 | 1822 | $columnList = array('module_srl', 'module'); |
| 1823 | 1823 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1824 | 1824 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1825 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1825 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1826 | 1826 | |
| 1827 | 1827 | $xml_file = $this->makeCategoryFile($module_srl); |
| 1828 | 1828 | // Set return value |
| 1829 | - $this->add('xml_file',$xml_file); |
|
| 1829 | + $this->add('xml_file', $xml_file); |
|
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | /** |
@@ -1837,14 +1837,14 @@ discard block |
||
| 1837 | 1837 | function makeCategoryFile($module_srl) |
| 1838 | 1838 | { |
| 1839 | 1839 | // Return if there is no information you need for creating a cache file |
| 1840 | - if(!$module_srl) return false; |
|
| 1840 | + if (!$module_srl) return false; |
|
| 1841 | 1841 | // Get module information (to obtain mid) |
| 1842 | 1842 | $oModuleModel = getModel('module'); |
| 1843 | 1843 | $columnList = array('module_srl', 'mid', 'site_srl'); |
| 1844 | 1844 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1845 | 1845 | $mid = $module_info->mid; |
| 1846 | 1846 | |
| 1847 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 1847 | + if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 1848 | 1848 | // Cache file's name |
| 1849 | 1849 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
| 1850 | 1850 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1856,17 +1856,17 @@ discard block |
||
| 1856 | 1856 | |
| 1857 | 1857 | $category_list = $output->data; |
| 1858 | 1858 | |
| 1859 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
| 1859 | + if (!is_array($category_list)) $category_list = array($category_list); |
|
| 1860 | 1860 | |
| 1861 | 1861 | $category_count = count($category_list); |
| 1862 | - for($i=0;$i<$category_count;$i++) |
|
| 1862 | + for ($i = 0; $i < $category_count; $i++) |
|
| 1863 | 1863 | { |
| 1864 | 1864 | $category_srl = $category_list[$i]->category_srl; |
| 1865 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 1865 | + if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 1866 | 1866 | $list[$category_srl] = $category_list[$i]; |
| 1867 | 1867 | } |
| 1868 | 1868 | // Create the xml file without node data if no data is obtained |
| 1869 | - if(!$list) |
|
| 1869 | + if (!$list) |
|
| 1870 | 1870 | { |
| 1871 | 1871 | $xml_buff = "<root />"; |
| 1872 | 1872 | FileHandler::writeFile($xml_file, $xml_buff); |
@@ -1874,12 +1874,12 @@ discard block |
||
| 1874 | 1874 | return $xml_file; |
| 1875 | 1875 | } |
| 1876 | 1876 | // Change to an array if only a single data is obtained |
| 1877 | - if(!is_array($list)) $list = array($list); |
|
| 1877 | + if (!is_array($list)) $list = array($list); |
|
| 1878 | 1878 | // Create a tree for loop |
| 1879 | - foreach($list as $category_srl => $node) |
|
| 1879 | + foreach ($list as $category_srl => $node) |
|
| 1880 | 1880 | { |
| 1881 | 1881 | $node->mid = $mid; |
| 1882 | - $parent_srl = (int)$node->parent_srl; |
|
| 1882 | + $parent_srl = (int) $node->parent_srl; |
|
| 1883 | 1883 | $tree[$parent_srl][$category_srl] = $node; |
| 1884 | 1884 | } |
| 1885 | 1885 | // A common header to set permissions and groups of the cache file |
@@ -1953,13 +1953,13 @@ discard block |
||
| 1953 | 1953 | */ |
| 1954 | 1954 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
| 1955 | 1955 | { |
| 1956 | - if(!$source_node) return; |
|
| 1956 | + if (!$source_node) return; |
|
| 1957 | 1957 | |
| 1958 | - foreach($source_node as $category_srl => $node) |
|
| 1958 | + foreach ($source_node as $category_srl => $node) |
|
| 1959 | 1959 | { |
| 1960 | 1960 | $child_buff = ""; |
| 1961 | 1961 | // Get data of the child nodes |
| 1962 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 1962 | + if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 1963 | 1963 | // List variables |
| 1964 | 1964 | $expand = $node->expand; |
| 1965 | 1965 | $group_srls = $node->group_srls; |
@@ -1969,27 +1969,27 @@ discard block |
||
| 1969 | 1969 | $color = $node->color; |
| 1970 | 1970 | $description = $node->description; |
| 1971 | 1971 | // If node->group_srls value exists |
| 1972 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
| 1972 | + if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls); |
|
| 1973 | 1973 | else $group_check_code = "true"; |
| 1974 | 1974 | |
| 1975 | 1975 | $title = $node->title; |
| 1976 | 1976 | $oModuleAdminModel = getAdminModel('module'); |
| 1977 | 1977 | |
| 1978 | 1978 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
| 1979 | - if(count($langs)) |
|
| 1979 | + if (count($langs)) |
|
| 1980 | 1980 | { |
| 1981 | - foreach($langs as $key => $val) |
|
| 1981 | + foreach ($langs as $key => $val) |
|
| 1982 | 1982 | { |
| 1983 | - $xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1983 | + $xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1984 | 1984 | } |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
| 1988 | - if(count($langx)) |
|
| 1988 | + if (count($langx)) |
|
| 1989 | 1989 | { |
| 1990 | - foreach($langx as $key => $val) |
|
| 1990 | + foreach ($langx as $key => $val) |
|
| 1991 | 1991 | { |
| 1992 | - $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1992 | + $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1993 | 1993 | } |
| 1994 | 1994 | } |
| 1995 | 1995 | |
@@ -2002,7 +2002,7 @@ discard block |
||
| 2002 | 2002 | $category_srl, |
| 2003 | 2003 | $group_check_code, |
| 2004 | 2004 | $category_srl, |
| 2005 | - getUrl('','mid',$node->mid,'category',$category_srl), |
|
| 2005 | + getUrl('', 'mid', $node->mid, 'category', $category_srl), |
|
| 2006 | 2006 | $expand, |
| 2007 | 2007 | htmlspecialchars($color, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), |
| 2008 | 2008 | $group_check_code, |
@@ -2010,8 +2010,8 @@ discard block |
||
| 2010 | 2010 | $node->document_count |
| 2011 | 2011 | ); |
| 2012 | 2012 | |
| 2013 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2014 | - else $buff .= sprintf('<node %s />', $attribute); |
|
| 2013 | + if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2014 | + else $buff .= sprintf('<node %s />', $attribute); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | return $buff; |
| 2017 | 2017 | } |
@@ -2030,13 +2030,13 @@ discard block |
||
| 2030 | 2030 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
| 2031 | 2031 | { |
| 2032 | 2032 | $output = array("buff"=>"", "category_srl_list"=>array()); |
| 2033 | - if(!$source_node) return $output; |
|
| 2033 | + if (!$source_node) return $output; |
|
| 2034 | 2034 | |
| 2035 | 2035 | // Set to an arraty for looping and then generate php script codes to be included |
| 2036 | - foreach($source_node as $category_srl => $node) |
|
| 2036 | + foreach ($source_node as $category_srl => $node) |
|
| 2037 | 2037 | { |
| 2038 | 2038 | // Get data from child nodes first if exist. |
| 2039 | - if($category_srl && $tree[$category_srl]){ |
|
| 2039 | + if ($category_srl && $tree[$category_srl]) { |
|
| 2040 | 2040 | $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff); |
| 2041 | 2041 | } else { |
| 2042 | 2042 | $child_output = array("buff"=>"", "category_srl_list"=>array()); |
@@ -2047,14 +2047,14 @@ discard block |
||
| 2047 | 2047 | $output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']); |
| 2048 | 2048 | |
| 2049 | 2049 | // If node->group_srls value exists |
| 2050 | - if($node->group_srls) { |
|
| 2051 | - $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls); |
|
| 2050 | + if ($node->group_srls) { |
|
| 2051 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls); |
|
| 2052 | 2052 | } else { |
| 2053 | 2053 | $group_check_code = "true"; |
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | 2056 | // List variables |
| 2057 | - $selected = '"' . implode('","', $child_output['category_srl_list']) . '"'; |
|
| 2057 | + $selected = '"'.implode('","', $child_output['category_srl_list']).'"'; |
|
| 2058 | 2058 | $child_buff = $child_output['buff']; |
| 2059 | 2059 | $expand = $node->expand; |
| 2060 | 2060 | |
@@ -2063,32 +2063,32 @@ discard block |
||
| 2063 | 2063 | $oModuleAdminModel = getAdminModel('module'); |
| 2064 | 2064 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
| 2065 | 2065 | |
| 2066 | - if(count($langs)) |
|
| 2066 | + if (count($langs)) |
|
| 2067 | 2067 | { |
| 2068 | - foreach($langs as $key => $val) |
|
| 2068 | + foreach ($langs as $key => $val) |
|
| 2069 | 2069 | { |
| 2070 | 2070 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 2071 | 2071 | $php_header_buff .= sprintf( |
| 2072 | 2072 | '$_titles[%d]["%s"] = "%s"; ', |
| 2073 | 2073 | $category_srl, |
| 2074 | 2074 | $key, |
| 2075 | - str_replace('"','\\"', $val) |
|
| 2075 | + str_replace('"', '\\"', $val) |
|
| 2076 | 2076 | ); |
| 2077 | 2077 | } |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
| 2081 | 2081 | |
| 2082 | - if(count($langx)) |
|
| 2082 | + if (count($langx)) |
|
| 2083 | 2083 | { |
| 2084 | - foreach($langx as $key => $val) |
|
| 2084 | + foreach ($langx as $key => $val) |
|
| 2085 | 2085 | { |
| 2086 | 2086 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 2087 | 2087 | $php_header_buff .= sprintf( |
| 2088 | 2088 | '$_descriptions[%d]["%s"] = "%s"; ', |
| 2089 | 2089 | $category_srl, |
| 2090 | 2090 | $key, |
| 2091 | - str_replace('"','\\"', $val) |
|
| 2091 | + str_replace('"', '\\"', $val) |
|
| 2092 | 2092 | ); |
| 2093 | 2093 | } |
| 2094 | 2094 | } |
@@ -2112,7 +2112,7 @@ discard block |
||
| 2112 | 2112 | ); |
| 2113 | 2113 | |
| 2114 | 2114 | // Generate buff data |
| 2115 | - $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
| 2115 | + $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
| 2116 | 2116 | } |
| 2117 | 2117 | |
| 2118 | 2118 | return $output; |
@@ -2129,7 +2129,7 @@ discard block |
||
| 2129 | 2129 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
| 2130 | 2130 | { |
| 2131 | 2131 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
| 2132 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2132 | + if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2133 | 2133 | |
| 2134 | 2134 | $obj = new stdClass(); |
| 2135 | 2135 | $obj->url = $url; |
@@ -2147,68 +2147,68 @@ discard block |
||
| 2147 | 2147 | */ |
| 2148 | 2148 | function procDocumentAddCart() |
| 2149 | 2149 | { |
| 2150 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2150 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2151 | 2151 | |
| 2152 | 2152 | // Get document_srl |
| 2153 | - $srls = explode(',',Context::get('srls')); |
|
| 2154 | - for($i = 0; $i < count($srls); $i++) |
|
| 2153 | + $srls = explode(',', Context::get('srls')); |
|
| 2154 | + for ($i = 0; $i < count($srls); $i++) |
|
| 2155 | 2155 | { |
| 2156 | 2156 | $srl = trim($srls[$i]); |
| 2157 | 2157 | |
| 2158 | - if(!$srl) continue; |
|
| 2158 | + if (!$srl) continue; |
|
| 2159 | 2159 | |
| 2160 | 2160 | $document_srls[] = $srl; |
| 2161 | 2161 | } |
| 2162 | - if(!count($document_srls)) return; |
|
| 2162 | + if (!count($document_srls)) return; |
|
| 2163 | 2163 | |
| 2164 | 2164 | // Get module_srl of the documents |
| 2165 | 2165 | $args = new stdClass; |
| 2166 | 2166 | $args->list_count = count($document_srls); |
| 2167 | - $args->document_srls = implode(',',$document_srls); |
|
| 2167 | + $args->document_srls = implode(',', $document_srls); |
|
| 2168 | 2168 | $args->order_type = 'asc'; |
| 2169 | 2169 | $output = executeQueryArray('document.getDocuments', $args); |
| 2170 | - if(!$output->data) return new Object(); |
|
| 2170 | + if (!$output->data) return new Object(); |
|
| 2171 | 2171 | |
| 2172 | 2172 | unset($document_srls); |
| 2173 | - foreach($output->data as $key => $val) |
|
| 2173 | + foreach ($output->data as $key => $val) |
|
| 2174 | 2174 | { |
| 2175 | 2175 | $document_srls[$val->module_srl][] = $val->document_srl; |
| 2176 | 2176 | } |
| 2177 | - if(!$document_srls || !count($document_srls)) return new Object(); |
|
| 2177 | + if (!$document_srls || !count($document_srls)) return new Object(); |
|
| 2178 | 2178 | |
| 2179 | 2179 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
| 2180 | 2180 | $oModuleModel = getModel('module'); |
| 2181 | 2181 | $module_srls = array_keys($document_srls); |
| 2182 | - for($i=0;$i<count($module_srls);$i++) |
|
| 2182 | + for ($i = 0; $i < count($module_srls); $i++) |
|
| 2183 | 2183 | { |
| 2184 | 2184 | $module_srl = $module_srls[$i]; |
| 2185 | 2185 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 2186 | 2186 | $logged_info = Context::get('logged_info'); |
| 2187 | - if($logged_info->is_admin != 'Y') |
|
| 2187 | + if ($logged_info->is_admin != 'Y') |
|
| 2188 | 2188 | { |
| 2189 | - if(!$module_info) |
|
| 2189 | + if (!$module_info) |
|
| 2190 | 2190 | { |
| 2191 | 2191 | unset($document_srls[$module_srl]); |
| 2192 | 2192 | continue; |
| 2193 | 2193 | } |
| 2194 | 2194 | $grant = $oModuleModel->getGrant($module_info, $logged_info); |
| 2195 | - if(!$grant->manager) |
|
| 2195 | + if (!$grant->manager) |
|
| 2196 | 2196 | { |
| 2197 | 2197 | unset($document_srls[$module_srl]); |
| 2198 | 2198 | continue; |
| 2199 | 2199 | } |
| 2200 | 2200 | } |
| 2201 | 2201 | } |
| 2202 | - if(!count($document_srls)) return new Object(); |
|
| 2202 | + if (!count($document_srls)) return new Object(); |
|
| 2203 | 2203 | |
| 2204 | - foreach($document_srls as $module_srl => $documents) |
|
| 2204 | + foreach ($document_srls as $module_srl => $documents) |
|
| 2205 | 2205 | { |
| 2206 | 2206 | $cnt = count($documents); |
| 2207 | - for($i=0;$i<$cnt;$i++) |
|
| 2207 | + for ($i = 0; $i < $cnt; $i++) |
|
| 2208 | 2208 | { |
| 2209 | - $document_srl = (int)trim($documents[$i]); |
|
| 2210 | - if(!$document_srls) continue; |
|
| 2211 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2209 | + $document_srl = (int) trim($documents[$i]); |
|
| 2210 | + if (!$document_srls) continue; |
|
| 2211 | + if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2212 | 2212 | else $_SESSION['document_management'][$document_srl] = true; |
| 2213 | 2213 | } |
| 2214 | 2214 | } |
@@ -2221,9 +2221,9 @@ discard block |
||
| 2221 | 2221 | function procDocumentManageCheckedDocument() |
| 2222 | 2222 | { |
| 2223 | 2223 | @set_time_limit(0); |
| 2224 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 2224 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2225 | 2225 | |
| 2226 | - if(!checkCSRF()) |
|
| 2226 | + if (!checkCSRF()) |
|
| 2227 | 2227 | { |
| 2228 | 2228 | return new Object(-1, 'msg_invalid_request'); |
| 2229 | 2229 | } |
@@ -2231,44 +2231,44 @@ discard block |
||
| 2231 | 2231 | $type = Context::get('type'); |
| 2232 | 2232 | $target_module = Context::get('target_module'); |
| 2233 | 2233 | $module_srl = Context::get('module_srl'); |
| 2234 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2234 | + if ($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2235 | 2235 | $category_srl = Context::get('target_category'); |
| 2236 | 2236 | $message_content = Context::get('message_content'); |
| 2237 | - if($message_content) $message_content = nl2br($message_content); |
|
| 2237 | + if ($message_content) $message_content = nl2br($message_content); |
|
| 2238 | 2238 | |
| 2239 | 2239 | $cart = Context::get('cart'); |
| 2240 | - if(!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2240 | + if (!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2241 | 2241 | else $document_srl_list = $cart; |
| 2242 | 2242 | |
| 2243 | 2243 | $document_srl_count = count($document_srl_list); |
| 2244 | 2244 | |
| 2245 | 2245 | $oDocumentModel = getModel('document'); |
| 2246 | 2246 | $document_items = array(); |
| 2247 | - foreach($document_srl_list as $document_srl) |
|
| 2247 | + foreach ($document_srl_list as $document_srl) |
|
| 2248 | 2248 | { |
| 2249 | 2249 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 2250 | 2250 | $document_items[] = $oDocument; |
| 2251 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2251 | + if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | // Send a message |
| 2255 | - if($message_content) |
|
| 2255 | + if ($message_content) |
|
| 2256 | 2256 | { |
| 2257 | 2257 | |
| 2258 | 2258 | $oCommunicationController = getController('communication'); |
| 2259 | 2259 | |
| 2260 | 2260 | $logged_info = Context::get('logged_info'); |
| 2261 | 2261 | |
| 2262 | - $title = cut_str($message_content,10,'...'); |
|
| 2262 | + $title = cut_str($message_content, 10, '...'); |
|
| 2263 | 2263 | $sender_member_srl = $logged_info->member_srl; |
| 2264 | 2264 | |
| 2265 | - foreach($document_items as $oDocument) |
|
| 2265 | + foreach ($document_items as $oDocument) |
|
| 2266 | 2266 | { |
| 2267 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
| 2267 | + if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue; |
|
| 2268 | 2268 | |
| 2269 | - if($type=='move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2269 | + if ($type == 'move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2270 | 2270 | else $purl = ""; |
| 2271 | - $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
| 2271 | + $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
| 2272 | 2272 | |
| 2273 | 2273 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
| 2274 | 2274 | } |
@@ -2278,54 +2278,54 @@ discard block |
||
| 2278 | 2278 | $oSpamController->setAvoidLog(); |
| 2279 | 2279 | |
| 2280 | 2280 | $oDocumentAdminController = getAdminController('document'); |
| 2281 | - if($type == 'move') |
|
| 2281 | + if ($type == 'move') |
|
| 2282 | 2282 | { |
| 2283 | - if(!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2283 | + if (!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2284 | 2284 | |
| 2285 | 2285 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2286 | - if(!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2286 | + if (!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2287 | 2287 | |
| 2288 | 2288 | $msg_code = 'success_moved'; |
| 2289 | 2289 | |
| 2290 | 2290 | } |
| 2291 | - else if($type == 'copy') |
|
| 2291 | + else if ($type == 'copy') |
|
| 2292 | 2292 | { |
| 2293 | - if(!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2293 | + if (!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2294 | 2294 | |
| 2295 | 2295 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2296 | - if(!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2296 | + if (!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2297 | 2297 | |
| 2298 | 2298 | $msg_code = 'success_copied'; |
| 2299 | 2299 | } |
| 2300 | - else if($type =='delete') |
|
| 2300 | + else if ($type == 'delete') |
|
| 2301 | 2301 | { |
| 2302 | 2302 | $oDB = &DB::getInstance(); |
| 2303 | 2303 | $oDB->begin(); |
| 2304 | - for($i=0;$i<$document_srl_count;$i++) |
|
| 2304 | + for ($i = 0; $i < $document_srl_count; $i++) |
|
| 2305 | 2305 | { |
| 2306 | 2306 | $document_srl = $document_srl_list[$i]; |
| 2307 | 2307 | $output = $this->deleteDocument($document_srl, true); |
| 2308 | - if(!$output->toBool()) return new Object(-1, 'fail_to_delete'); |
|
| 2308 | + if (!$output->toBool()) return new Object(-1, 'fail_to_delete'); |
|
| 2309 | 2309 | } |
| 2310 | 2310 | $oDB->commit(); |
| 2311 | 2311 | $msg_code = 'success_deleted'; |
| 2312 | 2312 | } |
| 2313 | - else if($type == 'trash') |
|
| 2313 | + else if ($type == 'trash') |
|
| 2314 | 2314 | { |
| 2315 | 2315 | $args = new stdClass(); |
| 2316 | 2316 | $args->description = $message_content; |
| 2317 | 2317 | |
| 2318 | 2318 | $oDB = &DB::getInstance(); |
| 2319 | 2319 | $oDB->begin(); |
| 2320 | - for($i=0;$i<$document_srl_count;$i++) { |
|
| 2320 | + for ($i = 0; $i < $document_srl_count; $i++) { |
|
| 2321 | 2321 | $args->document_srl = $document_srl_list[$i]; |
| 2322 | 2322 | $output = $this->moveDocumentToTrash($args); |
| 2323 | - if(!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash'); |
|
| 2323 | + if (!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash'); |
|
| 2324 | 2324 | } |
| 2325 | 2325 | $oDB->commit(); |
| 2326 | 2326 | $msg_code = 'success_trashed'; |
| 2327 | 2327 | } |
| 2328 | - else if($type == 'cancelDeclare') |
|
| 2328 | + else if ($type == 'cancelDeclare') |
|
| 2329 | 2329 | { |
| 2330 | 2330 | $args->document_srl = $document_srl_list; |
| 2331 | 2331 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2347,27 +2347,27 @@ discard block |
||
| 2347 | 2347 | function procDocumentInsertModuleConfig() |
| 2348 | 2348 | { |
| 2349 | 2349 | $module_srl = Context::get('target_module_srl'); |
| 2350 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 2350 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
| 2351 | 2351 | else $module_srl = array($module_srl); |
| 2352 | 2352 | |
| 2353 | 2353 | $document_config = new stdClass(); |
| 2354 | 2354 | $document_config->use_history = Context::get('use_history'); |
| 2355 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2355 | + if (!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2356 | 2356 | |
| 2357 | 2357 | $document_config->use_vote_up = Context::get('use_vote_up'); |
| 2358 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2358 | + if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2359 | 2359 | |
| 2360 | 2360 | $document_config->use_vote_down = Context::get('use_vote_down'); |
| 2361 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2361 | + if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2362 | 2362 | |
| 2363 | 2363 | $document_config->use_status = Context::get('use_status'); |
| 2364 | 2364 | |
| 2365 | 2365 | $oModuleController = getController('module'); |
| 2366 | - for($i=0;$i<count($module_srl);$i++) |
|
| 2366 | + for ($i = 0; $i < count($module_srl); $i++) |
|
| 2367 | 2367 | { |
| 2368 | 2368 | $srl = trim($module_srl[$i]); |
| 2369 | - if(!$srl) continue; |
|
| 2370 | - $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
|
| 2369 | + if (!$srl) continue; |
|
| 2370 | + $output = $oModuleController->insertModulePartConfig('document', $srl, $document_config); |
|
| 2371 | 2371 | } |
| 2372 | 2372 | $this->setError(-1); |
| 2373 | 2373 | $this->setMessage('success_updated', 'info'); |
@@ -2383,7 +2383,7 @@ discard block |
||
| 2383 | 2383 | function procDocumentTempSave() |
| 2384 | 2384 | { |
| 2385 | 2385 | // Check login information |
| 2386 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); |
|
| 2386 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); |
|
| 2387 | 2387 | $module_info = Context::get('module_info'); |
| 2388 | 2388 | $logged_info = Context::get('logged_info'); |
| 2389 | 2389 | |
@@ -2395,7 +2395,7 @@ discard block |
||
| 2395 | 2395 | unset($obj->is_notice); |
| 2396 | 2396 | |
| 2397 | 2397 | // Extract from beginning part of contents in the guestbook |
| 2398 | - if(!$obj->title) |
|
| 2398 | + if (!$obj->title) |
|
| 2399 | 2399 | { |
| 2400 | 2400 | $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
| 2401 | 2401 | } |
@@ -2406,13 +2406,13 @@ discard block |
||
| 2406 | 2406 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
| 2407 | 2407 | |
| 2408 | 2408 | // Update if already exists |
| 2409 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 2409 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 2410 | 2410 | { |
| 2411 | - if($oDocument->get('module_srl') != $obj->module_srl) |
|
| 2411 | + if ($oDocument->get('module_srl') != $obj->module_srl) |
|
| 2412 | 2412 | { |
| 2413 | 2413 | return new Object(-1, 'msg_invalid_request'); |
| 2414 | 2414 | } |
| 2415 | - if(!$oDocument->isGranted()) |
|
| 2415 | + if (!$oDocument->isGranted()) |
|
| 2416 | 2416 | { |
| 2417 | 2417 | return new Object(-1, 'msg_invalid_request'); |
| 2418 | 2418 | } |
@@ -2430,7 +2430,7 @@ discard block |
||
| 2430 | 2430 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
| 2431 | 2431 | } |
| 2432 | 2432 | // Set the attachment to be invalid state |
| 2433 | - if($oDocument->hasUploadedFiles()) |
|
| 2433 | + if ($oDocument->hasUploadedFiles()) |
|
| 2434 | 2434 | { |
| 2435 | 2435 | $args = new stdClass; |
| 2436 | 2436 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -2448,11 +2448,11 @@ discard block |
||
| 2448 | 2448 | */ |
| 2449 | 2449 | function procDocumentGetList() |
| 2450 | 2450 | { |
| 2451 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 2451 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2452 | 2452 | $documentSrls = Context::get('document_srls'); |
| 2453 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2453 | + if ($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2454 | 2454 | |
| 2455 | - if(count($documentSrlList) > 0) |
|
| 2455 | + if (count($documentSrlList) > 0) |
|
| 2456 | 2456 | { |
| 2457 | 2457 | $oDocumentModel = getModel('document'); |
| 2458 | 2458 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
@@ -2476,10 +2476,10 @@ discard block |
||
| 2476 | 2476 | */ |
| 2477 | 2477 | function _checkCommentStatusForOldVersion(&$obj) |
| 2478 | 2478 | { |
| 2479 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2480 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2479 | + if (!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2480 | + if (!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2481 | 2481 | |
| 2482 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2482 | + if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2483 | 2483 | else $obj->commentStatus = 'DENY'; |
| 2484 | 2484 | } |
| 2485 | 2485 | |
@@ -2490,8 +2490,8 @@ discard block |
||
| 2490 | 2490 | */ |
| 2491 | 2491 | function _checkDocumentStatusForOldVersion(&$obj) |
| 2492 | 2492 | { |
| 2493 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2494 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2493 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2494 | + if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2495 | 2495 | } |
| 2496 | 2496 | |
| 2497 | 2497 | public function updateUploaedCount($documentSrlList) |
@@ -2499,10 +2499,10 @@ discard block |
||
| 2499 | 2499 | $oDocumentModel = getModel('document'); |
| 2500 | 2500 | $oFileModel = getModel('file'); |
| 2501 | 2501 | |
| 2502 | - if(is_array($documentSrlList)) |
|
| 2502 | + if (is_array($documentSrlList)) |
|
| 2503 | 2503 | { |
| 2504 | 2504 | $documentSrlList = array_unique($documentSrlList); |
| 2505 | - foreach($documentSrlList AS $key => $documentSrl) |
|
| 2505 | + foreach ($documentSrlList AS $key => $documentSrl) |
|
| 2506 | 2506 | { |
| 2507 | 2507 | $fileCount = $oFileModel->getFilesCount($documentSrl); |
| 2508 | 2508 | $args = new stdClass(); |
@@ -2523,14 +2523,14 @@ discard block |
||
| 2523 | 2523 | $oDocumentModel = getModel('document'); |
| 2524 | 2524 | $documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl); |
| 2525 | 2525 | |
| 2526 | - if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
| 2526 | + if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
| 2527 | 2527 | { |
| 2528 | - $oDocumentController=getController('document'); |
|
| 2529 | - foreach($obj->moduleSrlList AS $key=>$value) |
|
| 2528 | + $oDocumentController = getController('document'); |
|
| 2529 | + foreach ($obj->moduleSrlList AS $key=>$value) |
|
| 2530 | 2530 | { |
| 2531 | - foreach($documentExtraKeys AS $extraItem) |
|
| 2531 | + foreach ($documentExtraKeys AS $extraItem) |
|
| 2532 | 2532 | { |
| 2533 | - $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ; |
|
| 2533 | + $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid); |
|
| 2534 | 2534 | } |
| 2535 | 2535 | } |
| 2536 | 2536 | } |
@@ -2542,9 +2542,9 @@ discard block |
||
| 2542 | 2542 | $documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl); |
| 2543 | 2543 | |
| 2544 | 2544 | $oModuleController = getController('module'); |
| 2545 | - if(is_array($obj->moduleSrlList)) |
|
| 2545 | + if (is_array($obj->moduleSrlList)) |
|
| 2546 | 2546 | { |
| 2547 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 2547 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 2548 | 2548 | { |
| 2549 | 2549 | $oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig); |
| 2550 | 2550 | } |
@@ -24,19 +24,27 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function procDocumentVoteUp() |
| 26 | 26 | { |
| 27 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 27 | + if(!Context::get('is_logged')) { |
|
| 28 | + return new Object(-1, 'msg_invalid_request'); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | $document_srl = Context::get('target_srl'); |
| 30 | - if(!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 32 | + if(!$document_srl) { |
|
| 33 | + return new Object(-1, 'msg_invalid_request'); |
|
| 34 | + } |
|
| 31 | 35 | |
| 32 | 36 | $oDocumentModel = getModel('document'); |
| 33 | 37 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 34 | 38 | $module_srl = $oDocument->get('module_srl'); |
| 35 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 39 | + if(!$module_srl) { |
|
| 40 | + return new Object(-1, 'msg_invalid_request'); |
|
| 41 | + } |
|
| 36 | 42 | |
| 37 | 43 | $oModuleModel = getModel('module'); |
| 38 | 44 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
| 39 | - if($document_config->use_vote_up=='N') return new Object(-1, 'msg_invalid_request'); |
|
| 45 | + if($document_config->use_vote_up=='N') { |
|
| 46 | + return new Object(-1, 'msg_invalid_request'); |
|
| 47 | + } |
|
| 40 | 48 | |
| 41 | 49 | $point = 1; |
| 42 | 50 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +77,27 @@ discard block |
||
| 69 | 77 | */ |
| 70 | 78 | function procDocumentVoteDown() |
| 71 | 79 | { |
| 72 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 80 | + if(!Context::get('is_logged')) { |
|
| 81 | + return new Object(-1, 'msg_invalid_request'); |
|
| 82 | + } |
|
| 73 | 83 | |
| 74 | 84 | $document_srl = Context::get('target_srl'); |
| 75 | - if(!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 85 | + if(!$document_srl) { |
|
| 86 | + return new Object(-1, 'msg_invalid_request'); |
|
| 87 | + } |
|
| 76 | 88 | |
| 77 | 89 | $oDocumentModel = getModel('document'); |
| 78 | 90 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 79 | 91 | $module_srl = $oDocument->get('module_srl'); |
| 80 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 92 | + if(!$module_srl) { |
|
| 93 | + return new Object(-1, 'msg_invalid_request'); |
|
| 94 | + } |
|
| 81 | 95 | |
| 82 | 96 | $oModuleModel = getModel('module'); |
| 83 | 97 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
| 84 | - if($document_config->use_vote_down=='N') return new Object(-1, 'msg_invalid_request'); |
|
| 98 | + if($document_config->use_vote_down=='N') { |
|
| 99 | + return new Object(-1, 'msg_invalid_request'); |
|
| 100 | + } |
|
| 85 | 101 | |
| 86 | 102 | $point = -1; |
| 87 | 103 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +111,14 @@ discard block |
||
| 95 | 111 | */ |
| 96 | 112 | function procDocumentDeclare() |
| 97 | 113 | { |
| 98 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); |
|
| 114 | + if(!Context::get('is_logged')) { |
|
| 115 | + return new Object(-1, 'msg_invalid_request'); |
|
| 116 | + } |
|
| 99 | 117 | |
| 100 | 118 | $document_srl = Context::get('target_srl'); |
| 101 | - if(!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 119 | + if(!$document_srl) { |
|
| 120 | + return new Object(-1, 'msg_invalid_request'); |
|
| 121 | + } |
|
| 102 | 122 | |
| 103 | 123 | return $this->declaredDocument($document_srl); |
| 104 | 124 | } |
@@ -140,7 +160,9 @@ discard block |
||
| 140 | 160 | $args->history_srl = $history_srl; |
| 141 | 161 | $args->module_srl = $module_srl; |
| 142 | 162 | $args->document_srl = $document_srl; |
| 143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 163 | + if(!$args->history_srl && !$args->module_srl && !$args->document_srl) { |
|
| 164 | + return; |
|
| 165 | + } |
|
| 144 | 166 | executeQuery("document.deleteHistory", $args); |
| 145 | 167 | } |
| 146 | 168 | |
@@ -152,15 +174,21 @@ discard block |
||
| 152 | 174 | function triggerDeleteModuleDocuments(&$obj) |
| 153 | 175 | { |
| 154 | 176 | $module_srl = $obj->module_srl; |
| 155 | - if(!$module_srl) return new Object(); |
|
| 177 | + if(!$module_srl) { |
|
| 178 | + return new Object(); |
|
| 179 | + } |
|
| 156 | 180 | // Delete the document |
| 157 | 181 | $oDocumentAdminController = getAdminController('document'); |
| 158 | 182 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
| 159 | - if(!$output->toBool()) return $output; |
|
| 183 | + if(!$output->toBool()) { |
|
| 184 | + return $output; |
|
| 185 | + } |
|
| 160 | 186 | // Delete the category |
| 161 | 187 | $oDocumentController = getController('document'); |
| 162 | 188 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
| 163 | - if(!$output->toBool()) return $output; |
|
| 189 | + if(!$output->toBool()) { |
|
| 190 | + return $output; |
|
| 191 | + } |
|
| 164 | 192 | // Delete extra key and variable, because module deleted |
| 165 | 193 | $this->deleteDocumentExtraKeys($module_srl); |
| 166 | 194 | |
@@ -202,10 +230,18 @@ discard block |
||
| 202 | 230 | $oDB = &DB::getInstance(); |
| 203 | 231 | $oDB->begin(); |
| 204 | 232 | // List variables |
| 205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 233 | + if($obj->comment_status) { |
|
| 234 | + $obj->commentStatus = $obj->comment_status; |
|
| 235 | + } |
|
| 236 | + if(!$obj->commentStatus) { |
|
| 237 | + $obj->commentStatus = 'DENY'; |
|
| 238 | + } |
|
| 239 | + if($obj->commentStatus == 'DENY') { |
|
| 240 | + $this->_checkCommentStatusForOldVersion($obj); |
|
| 241 | + } |
|
| 242 | + if($obj->allow_trackback!='Y') { |
|
| 243 | + $obj->allow_trackback = 'N'; |
|
| 244 | + } |
|
| 209 | 245 | if($obj->homepage) |
| 210 | 246 | { |
| 211 | 247 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -215,9 +251,15 @@ discard block |
||
| 215 | 251 | } |
| 216 | 252 | } |
| 217 | 253 | |
| 218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
| 220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 254 | + if($obj->notify_message != 'Y') { |
|
| 255 | + $obj->notify_message = 'N'; |
|
| 256 | + } |
|
| 257 | + if(!$obj->email_address) { |
|
| 258 | + $obj->email_address = ''; |
|
| 259 | + } |
|
| 260 | + if(!$isRestore) { |
|
| 261 | + $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
| 262 | + } |
|
| 221 | 263 | |
| 222 | 264 | // can modify regdate only manager |
| 223 | 265 | $grant = Context::get('grant'); |
@@ -227,7 +269,9 @@ discard block |
||
| 227 | 269 | } |
| 228 | 270 | |
| 229 | 271 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
| 230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 272 | + if(!is_string($obj->extra_vars)) { |
|
| 273 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
| 274 | + } |
|
| 231 | 275 | // Remove the columns for automatic saving |
| 232 | 276 | unset($obj->_saved_doc_srl); |
| 233 | 277 | unset($obj->_saved_doc_title); |
@@ -235,10 +279,15 @@ discard block |
||
| 235 | 279 | unset($obj->_saved_doc_message); |
| 236 | 280 | // Call a trigger (before) |
| 237 | 281 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
| 238 | - if(!$output->toBool()) return $output; |
|
| 282 | + if(!$output->toBool()) { |
|
| 283 | + return $output; |
|
| 284 | + } |
|
| 239 | 285 | // Register it if no given document_srl exists |
| 240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
| 241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new Object(-1, 'msg_not_permitted'); |
|
| 286 | + if(!$obj->document_srl) { |
|
| 287 | + $obj->document_srl = getNextSequence(); |
|
| 288 | + } elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) { |
|
| 289 | + return new Object(-1, 'msg_not_permitted'); |
|
| 290 | + } |
|
| 242 | 291 | |
| 243 | 292 | $oDocumentModel = getModel('document'); |
| 244 | 293 | // Set to 0 if the category_srl doesn't exist |
@@ -249,12 +298,19 @@ discard block |
||
| 249 | 298 | { |
| 250 | 299 | return new Object(-1, 'msg_not_permitted'); |
| 251 | 300 | } |
| 252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 301 | + if(count($category_list) > 0 && !$category_list[$obj->category_srl]) { |
|
| 302 | + $obj->category_srl = 0; |
|
| 303 | + } |
|
| 253 | 304 | } |
| 254 | 305 | // Set the read counts and update order. |
| 255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
| 256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 257 | - else $obj->update_order = $obj->list_order; |
|
| 306 | + if(!$obj->readed_count) { |
|
| 307 | + $obj->readed_count = 0; |
|
| 308 | + } |
|
| 309 | + if($isLatest) { |
|
| 310 | + $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
| 311 | + } else { |
|
| 312 | + $obj->update_order = $obj->list_order; |
|
| 313 | + } |
|
| 258 | 314 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
| 259 | 315 | if($obj->password && !$obj->password_is_hashed) |
| 260 | 316 | { |
@@ -276,9 +332,13 @@ discard block |
||
| 276 | 332 | // If the tile is empty, extract string from the contents. |
| 277 | 333 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 278 | 334 | settype($obj->title, "string"); |
| 279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 335 | + if($obj->title == '') { |
|
| 336 | + $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 337 | + } |
|
| 280 | 338 | // If no tile extracted from the contents, leave it untitled. |
| 281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 339 | + if($obj->title == '') { |
|
| 340 | + $obj->title = 'Untitled'; |
|
| 341 | + } |
|
| 282 | 342 | // Remove XE's own tags from the contents. |
| 283 | 343 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 284 | 344 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -290,13 +350,19 @@ discard block |
||
| 290 | 350 | $obj->content = nl2br($obj->content); |
| 291 | 351 | } |
| 292 | 352 | // Remove iframe and script if not a top adminisrator in the session. |
| 293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
| 353 | + if($logged_info->is_admin != 'Y') { |
|
| 354 | + $obj->content = removeHackTag($obj->content); |
|
| 355 | + } |
|
| 294 | 356 | // An error appears if both log-in info and user name don't exist. |
| 295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new Object(-1,'msg_invalid_request'); |
|
| 357 | + if(!$logged_info->member_srl && !$obj->nick_name) { |
|
| 358 | + return new Object(-1,'msg_invalid_request'); |
|
| 359 | + } |
|
| 296 | 360 | |
| 297 | 361 | $obj->lang_code = Context::getLangType(); |
| 298 | 362 | // Insert data into the DB |
| 299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
| 363 | + if(!$obj->status) { |
|
| 364 | + $this->_checkDocumentStatusForOldVersion($obj); |
|
| 365 | + } |
|
| 300 | 366 | $output = executeQuery('document.insertDocument', $obj); |
| 301 | 367 | if(!$output->toBool()) |
| 302 | 368 | { |
@@ -313,19 +379,25 @@ discard block |
||
| 313 | 379 | if(isset($obj->{'extra_vars'.$idx})) |
| 314 | 380 | { |
| 315 | 381 | $tmp = $obj->{'extra_vars'.$idx}; |
| 316 | - if(is_array($tmp)) |
|
| 317 | - $value = implode('|@|', $tmp); |
|
| 318 | - else |
|
| 319 | - $value = trim($tmp); |
|
| 382 | + if(is_array($tmp)) { |
|
| 383 | + $value = implode('|@|', $tmp); |
|
| 384 | + } else { |
|
| 385 | + $value = trim($tmp); |
|
| 386 | + } |
|
| 387 | + } else if(isset($obj->{$extra_item->name})) { |
|
| 388 | + $value = trim($obj->{$extra_item->name}); |
|
| 389 | + } |
|
| 390 | + if($value == NULL) { |
|
| 391 | + continue; |
|
| 320 | 392 | } |
| 321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 322 | - if($value == NULL) continue; |
|
| 323 | 393 | |
| 324 | 394 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 325 | 395 | } |
| 326 | 396 | } |
| 327 | 397 | // Update the category if the category_srl exists. |
| 328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 398 | + if($obj->category_srl) { |
|
| 399 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 400 | + } |
|
| 329 | 401 | // Call a trigger (after) |
| 330 | 402 | if($output->toBool()) |
| 331 | 403 | { |
@@ -367,27 +439,39 @@ discard block |
||
| 367 | 439 | return new Object(-1, 'msg_invalid_request'); |
| 368 | 440 | } |
| 369 | 441 | |
| 370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new Object(-1,'msg_invalied_request'); |
|
| 371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
| 372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
| 442 | + if(!$source_obj->document_srl || !$obj->document_srl) { |
|
| 443 | + return new Object(-1,'msg_invalied_request'); |
|
| 444 | + } |
|
| 445 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
| 446 | + $obj->status = 'SECRET'; |
|
| 447 | + } |
|
| 448 | + if(!$obj->status) { |
|
| 449 | + $obj->status = 'PUBLIC'; |
|
| 450 | + } |
|
| 373 | 451 | |
| 374 | 452 | // Call a trigger (before) |
| 375 | 453 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
| 376 | - if(!$output->toBool()) return $output; |
|
| 454 | + if(!$output->toBool()) { |
|
| 455 | + return $output; |
|
| 456 | + } |
|
| 377 | 457 | |
| 378 | 458 | // begin transaction |
| 379 | 459 | $oDB = &DB::getInstance(); |
| 380 | 460 | $oDB->begin(); |
| 381 | 461 | |
| 382 | 462 | $oModuleModel = getModel('module'); |
| 383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
| 463 | + if(!$obj->module_srl) { |
|
| 464 | + $obj->module_srl = $source_obj->get('module_srl'); |
|
| 465 | + } |
|
| 384 | 466 | $module_srl = $obj->module_srl; |
| 385 | 467 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
| 386 | 468 | if(!$document_config) |
| 387 | 469 | { |
| 388 | 470 | $document_config = new stdClass(); |
| 389 | 471 | } |
| 390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
| 472 | + if(!isset($document_config->use_history)) { |
|
| 473 | + $document_config->use_history = 'N'; |
|
| 474 | + } |
|
| 391 | 475 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
| 392 | 476 | |
| 393 | 477 | if($bUseHistory) |
@@ -396,22 +480,31 @@ discard block |
||
| 396 | 480 | $args->history_srl = getNextSequence(); |
| 397 | 481 | $args->document_srl = $obj->document_srl; |
| 398 | 482 | $args->module_srl = $module_srl; |
| 399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
| 483 | + if($document_config->use_history == 'Y') { |
|
| 484 | + $args->content = $source_obj->get('content'); |
|
| 485 | + } |
|
| 400 | 486 | $args->nick_name = $source_obj->get('nick_name'); |
| 401 | 487 | $args->member_srl = $source_obj->get('member_srl'); |
| 402 | 488 | $args->regdate = $source_obj->get('last_update'); |
| 403 | 489 | $args->ipaddress = $source_obj->get('ipaddress'); |
| 404 | 490 | $output = executeQuery("document.insertHistory", $args); |
| 405 | - } |
|
| 406 | - else |
|
| 491 | + } else |
|
| 407 | 492 | { |
| 408 | 493 | $obj->ipaddress = $source_obj->get('ipaddress'); |
| 409 | 494 | } |
| 410 | 495 | // List variables |
| 411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
| 412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
| 413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
| 414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
| 496 | + if($obj->comment_status) { |
|
| 497 | + $obj->commentStatus = $obj->comment_status; |
|
| 498 | + } |
|
| 499 | + if(!$obj->commentStatus) { |
|
| 500 | + $obj->commentStatus = 'DENY'; |
|
| 501 | + } |
|
| 502 | + if($obj->commentStatus == 'DENY') { |
|
| 503 | + $this->_checkCommentStatusForOldVersion($obj); |
|
| 504 | + } |
|
| 505 | + if($obj->allow_trackback!='Y') { |
|
| 506 | + $obj->allow_trackback = 'N'; |
|
| 507 | + } |
|
| 415 | 508 | if($obj->homepage) |
| 416 | 509 | { |
| 417 | 510 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -421,7 +514,9 @@ discard block |
||
| 421 | 514 | } |
| 422 | 515 | } |
| 423 | 516 | |
| 424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
| 517 | + if($obj->notify_message != 'Y') { |
|
| 518 | + $obj->notify_message = 'N'; |
|
| 519 | + } |
|
| 425 | 520 | |
| 426 | 521 | // can modify regdate only manager |
| 427 | 522 | $grant = Context::get('grant'); |
@@ -431,7 +526,9 @@ discard block |
||
| 431 | 526 | } |
| 432 | 527 | |
| 433 | 528 | // Serialize the $extra_vars |
| 434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
| 529 | + if(!is_string($obj->extra_vars)) { |
|
| 530 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
| 531 | + } |
|
| 435 | 532 | // Remove the columns for automatic saving |
| 436 | 533 | unset($obj->_saved_doc_srl); |
| 437 | 534 | unset($obj->_saved_doc_title); |
@@ -443,7 +540,9 @@ discard block |
||
| 443 | 540 | if($source_obj->get('category_srl')!=$obj->category_srl) |
| 444 | 541 | { |
| 445 | 542 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
| 446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
| 543 | + if(!$category_list[$obj->category_srl]) { |
|
| 544 | + $obj->category_srl = 0; |
|
| 545 | + } |
|
| 447 | 546 | } |
| 448 | 547 | // Change the update order |
| 449 | 548 | $obj->update_order = getNextSequence() * -1; |
@@ -478,9 +577,13 @@ discard block |
||
| 478 | 577 | // If the tile is empty, extract string from the contents. |
| 479 | 578 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 480 | 579 | settype($obj->title, "string"); |
| 481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 580 | + if($obj->title == '') { |
|
| 581 | + $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 582 | + } |
|
| 482 | 583 | // If no tile extracted from the contents, leave it untitled. |
| 483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 584 | + if($obj->title == '') { |
|
| 585 | + $obj->title = 'Untitled'; |
|
| 586 | + } |
|
| 484 | 587 | // Remove XE's own tags from the contents. |
| 485 | 588 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 486 | 589 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -500,8 +603,7 @@ discard block |
||
| 500 | 603 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
| 501 | 604 | $lang_code_args->lang_code = Context::getLangType(); |
| 502 | 605 | $output = executeQuery('document.updateDocumentsLangCode', $lang_code_args); |
| 503 | - } |
|
| 504 | - else |
|
| 606 | + } else |
|
| 505 | 607 | { |
| 506 | 608 | $extra_content = new stdClass; |
| 507 | 609 | $extra_content->title = $obj->title; |
@@ -520,7 +622,9 @@ discard block |
||
| 520 | 622 | $obj->content = removeHackTag($obj->content); |
| 521 | 623 | } |
| 522 | 624 | // if temporary document, regdate is now setting |
| 523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 625 | + if($source_obj->get('status') == $this->getConfigStatus('temp')) { |
|
| 626 | + $obj->regdate = date('YmdHis'); |
|
| 627 | + } |
|
| 524 | 628 | |
| 525 | 629 | // Insert data into the DB |
| 526 | 630 | $output = executeQuery('document.updateDocument', $obj); |
@@ -543,25 +647,37 @@ discard block |
||
| 543 | 647 | if(isset($obj->{'extra_vars'.$idx})) |
| 544 | 648 | { |
| 545 | 649 | $tmp = $obj->{'extra_vars'.$idx}; |
| 546 | - if(is_array($tmp)) |
|
| 547 | - $value = implode('|@|', $tmp); |
|
| 548 | - else |
|
| 549 | - $value = trim($tmp); |
|
| 650 | + if(is_array($tmp)) { |
|
| 651 | + $value = implode('|@|', $tmp); |
|
| 652 | + } else { |
|
| 653 | + $value = trim($tmp); |
|
| 654 | + } |
|
| 655 | + } else if(isset($obj->{$extra_item->name})) { |
|
| 656 | + $value = trim($obj->{$extra_item->name}); |
|
| 657 | + } |
|
| 658 | + if($value == NULL) { |
|
| 659 | + continue; |
|
| 550 | 660 | } |
| 551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 552 | - if($value == NULL) continue; |
|
| 553 | 661 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 554 | 662 | } |
| 555 | 663 | } |
| 556 | 664 | // Inert extra vars for multi-language support of title and contents. |
| 557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 665 | + if($extra_content->title) { |
|
| 666 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 667 | + } |
|
| 668 | + if($extra_content->content) { |
|
| 669 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 670 | + } |
|
| 559 | 671 | } |
| 560 | 672 | // Update the category if the category_srl exists. |
| 561 | 673 | if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
| 562 | 674 | { |
| 563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 675 | + if($source_obj->get('category_srl') != $obj->category_srl) { |
|
| 676 | + $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 677 | + } |
|
| 678 | + if($obj->category_srl) { |
|
| 679 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 680 | + } |
|
| 565 | 681 | } |
| 566 | 682 | // Call a trigger (after) |
| 567 | 683 | if($output->toBool()) |
@@ -606,7 +722,9 @@ discard block |
||
| 606 | 722 | $trigger_obj = new stdClass(); |
| 607 | 723 | $trigger_obj->document_srl = $document_srl; |
| 608 | 724 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
| 609 | - if(!$output->toBool()) return $output; |
|
| 725 | + if(!$output->toBool()) { |
|
| 726 | + return $output; |
|
| 727 | + } |
|
| 610 | 728 | |
| 611 | 729 | // begin transaction |
| 612 | 730 | $oDB = &DB::getInstance(); |
@@ -618,12 +736,17 @@ discard block |
||
| 618 | 736 | $oDocumentModel = getModel('document'); |
| 619 | 737 | // Check if the documnet exists |
| 620 | 738 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
| 739 | + } else if($isEmptyTrash && $oDocument == null) { |
|
| 740 | + return new Object(-1, 'document is not exists'); |
|
| 621 | 741 | } |
| 622 | - else if($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists'); |
|
| 623 | 742 | |
| 624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document'); |
|
| 743 | + if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) { |
|
| 744 | + return new Object(-1, 'msg_invalid_document'); |
|
| 745 | + } |
|
| 625 | 746 | // Check if a permossion is granted |
| 626 | - if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted'); |
|
| 747 | + if(!$oDocument->isGranted()) { |
|
| 748 | + return new Object(-1, 'msg_not_permitted'); |
|
| 749 | + } |
|
| 627 | 750 | |
| 628 | 751 | //if empty trash, document already deleted, therefore document not delete |
| 629 | 752 | $args = new stdClass(); |
@@ -643,7 +766,9 @@ discard block |
||
| 643 | 766 | |
| 644 | 767 | $this->deleteDocumentHistory(null, $document_srl, null); |
| 645 | 768 | // Update category information if the category_srl exists. |
| 646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 769 | + if($oDocument->get('category_srl')) { |
|
| 770 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 771 | + } |
|
| 647 | 772 | // Delete a declared list |
| 648 | 773 | executeQuery('document.deleteDeclared', $args); |
| 649 | 774 | // Delete extra variable |
@@ -723,8 +848,11 @@ discard block |
||
| 723 | 848 | { |
| 724 | 849 | $trash_args = new stdClass(); |
| 725 | 850 | // Get trash_srl if a given trash_srl doesn't exist |
| 726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 727 | - else $trash_args->trash_srl = $obj->trash_srl; |
|
| 851 | + if(!$obj->trash_srl) { |
|
| 852 | + $trash_args->trash_srl = getNextSequence(); |
|
| 853 | + } else { |
|
| 854 | + $trash_args->trash_srl = $obj->trash_srl; |
|
| 855 | + } |
|
| 728 | 856 | // Get its module_srl which the document belongs to |
| 729 | 857 | $oDocumentModel = getModel('document'); |
| 730 | 858 | $oDocument = $oDocumentModel->getDocument($obj->document_srl); |
@@ -732,7 +860,9 @@ discard block |
||
| 732 | 860 | $trash_args->module_srl = $oDocument->get('module_srl'); |
| 733 | 861 | $obj->module_srl = $oDocument->get('module_srl'); |
| 734 | 862 | // Cannot throw data from the trash to the trash |
| 735 | - if($trash_args->module_srl == 0) return false; |
|
| 863 | + if($trash_args->module_srl == 0) { |
|
| 864 | + return false; |
|
| 865 | + } |
|
| 736 | 866 | // Data setting |
| 737 | 867 | $trash_args->document_srl = $obj->document_srl; |
| 738 | 868 | $trash_args->description = $obj->description; |
@@ -793,7 +923,9 @@ discard block |
||
| 793 | 923 | }*/ |
| 794 | 924 | |
| 795 | 925 | // update category |
| 796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 926 | + if($oDocument->get('category_srl')) { |
|
| 927 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 928 | + } |
|
| 797 | 929 | |
| 798 | 930 | // remove thumbnails |
| 799 | 931 | FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
@@ -838,7 +970,9 @@ discard block |
||
| 838 | 970 | function updateReadedCount(&$oDocument) |
| 839 | 971 | { |
| 840 | 972 | // Pass if Crawler access |
| 841 | - if(isCrawler()) return false; |
|
| 973 | + if(isCrawler()) { |
|
| 974 | + return false; |
|
| 975 | + } |
|
| 842 | 976 | |
| 843 | 977 | $document_srl = $oDocument->document_srl; |
| 844 | 978 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,10 +980,14 @@ discard block |
||
| 846 | 980 | |
| 847 | 981 | // Call a trigger when the read count is updated (before) |
| 848 | 982 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
| 849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 983 | + if(!$trigger_output->toBool()) { |
|
| 984 | + return $trigger_output; |
|
| 985 | + } |
|
| 850 | 986 | |
| 851 | 987 | // Pass if read count is increaded on the session information |
| 852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
| 988 | + if($_SESSION['readed_document'][$document_srl]) { |
|
| 989 | + return false; |
|
| 990 | + } |
|
| 853 | 991 | |
| 854 | 992 | // Pass if the author's IP address is as same as visitor's. |
| 855 | 993 | if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
@@ -914,7 +1052,9 @@ discard block |
||
| 914 | 1052 | */ |
| 915 | 1053 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
| 916 | 1054 | { |
| 917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1,'msg_invalid_request'); |
|
| 1055 | + if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) { |
|
| 1056 | + return new Object(-1,'msg_invalid_request'); |
|
| 1057 | + } |
|
| 918 | 1058 | |
| 919 | 1059 | $obj = new stdClass(); |
| 920 | 1060 | $obj->module_srl = $module_srl; |
@@ -931,8 +1071,7 @@ discard block |
||
| 931 | 1071 | if(!$output->data) |
| 932 | 1072 | { |
| 933 | 1073 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
| 934 | - } |
|
| 935 | - else |
|
| 1074 | + } else |
|
| 936 | 1075 | { |
| 937 | 1076 | $output = executeQuery('document.updateDocumentExtraKey', $obj); |
| 938 | 1077 | // Update the extra var(eid) |
@@ -958,10 +1097,14 @@ discard block |
||
| 958 | 1097 | */ |
| 959 | 1098 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
| 960 | 1099 | { |
| 961 | - if(!$module_srl) return new Object(-1,'msg_invalid_request'); |
|
| 1100 | + if(!$module_srl) { |
|
| 1101 | + return new Object(-1,'msg_invalid_request'); |
|
| 1102 | + } |
|
| 962 | 1103 | $obj = new stdClass(); |
| 963 | 1104 | $obj->module_srl = $module_srl; |
| 964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1105 | + if(!is_null($var_idx)) { |
|
| 1106 | + $obj->var_idx = $var_idx; |
|
| 1107 | + } |
|
| 965 | 1108 | |
| 966 | 1109 | $oDB = DB::getInstance(); |
| 967 | 1110 | $oDB->begin(); |
@@ -1025,8 +1168,12 @@ discard block |
||
| 1025 | 1168 | */ |
| 1026 | 1169 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
| 1027 | 1170 | { |
| 1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1,'msg_invalid_request'); |
|
| 1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
| 1171 | + if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) { |
|
| 1172 | + return new Object(-1,'msg_invalid_request'); |
|
| 1173 | + } |
|
| 1174 | + if(!$lang_code) { |
|
| 1175 | + $lang_code = Context::getLangType(); |
|
| 1176 | + } |
|
| 1030 | 1177 | |
| 1031 | 1178 | $obj = new stdClass; |
| 1032 | 1179 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1199,18 @@ discard block |
||
| 1052 | 1199 | { |
| 1053 | 1200 | $obj = new stdClass(); |
| 1054 | 1201 | $obj->module_srl = $module_srl; |
| 1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
| 1202 | + if(!is_null($document_srl)) { |
|
| 1203 | + $obj->document_srl = $document_srl; |
|
| 1204 | + } |
|
| 1205 | + if(!is_null($var_idx)) { |
|
| 1206 | + $obj->var_idx = $var_idx; |
|
| 1207 | + } |
|
| 1208 | + if(!is_null($lang_code)) { |
|
| 1209 | + $obj->lang_code = $lang_code; |
|
| 1210 | + } |
|
| 1211 | + if(!is_null($eid)) { |
|
| 1212 | + $obj->eid = $eid; |
|
| 1213 | + } |
|
| 1059 | 1214 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
| 1060 | 1215 | return $output; |
| 1061 | 1216 | } |
@@ -1069,8 +1224,11 @@ discard block |
||
| 1069 | 1224 | */ |
| 1070 | 1225 | function updateVotedCount($document_srl, $point = 1) |
| 1071 | 1226 | { |
| 1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
| 1073 | - else $failed_voted = 'failed_blamed'; |
|
| 1227 | + if($point > 0) { |
|
| 1228 | + $failed_voted = 'failed_voted'; |
|
| 1229 | + } else { |
|
| 1230 | + $failed_voted = 'failed_blamed'; |
|
| 1231 | + } |
|
| 1074 | 1232 | // Return fail if session already has information about votes |
| 1075 | 1233 | if($_SESSION['voted_document'][$document_srl]) |
| 1076 | 1234 | { |
@@ -1106,8 +1264,7 @@ discard block |
||
| 1106 | 1264 | if($member_srl) |
| 1107 | 1265 | { |
| 1108 | 1266 | $args->member_srl = $member_srl; |
| 1109 | - } |
|
| 1110 | - else |
|
| 1267 | + } else |
|
| 1111 | 1268 | { |
| 1112 | 1269 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 1113 | 1270 | } |
@@ -1129,17 +1286,20 @@ discard block |
||
| 1129 | 1286 | { |
| 1130 | 1287 | $args->blamed_count = $oDocument->get('blamed_count') + $point; |
| 1131 | 1288 | $output = executeQuery('document.updateBlamedCount', $args); |
| 1132 | - } |
|
| 1133 | - else |
|
| 1289 | + } else |
|
| 1134 | 1290 | { |
| 1135 | 1291 | $args->voted_count = $oDocument->get('voted_count') + $point; |
| 1136 | 1292 | $output = executeQuery('document.updateVotedCount', $args); |
| 1137 | 1293 | } |
| 1138 | - if(!$output->toBool()) return $output; |
|
| 1294 | + if(!$output->toBool()) { |
|
| 1295 | + return $output; |
|
| 1296 | + } |
|
| 1139 | 1297 | // Leave logs |
| 1140 | 1298 | $args->point = $point; |
| 1141 | 1299 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
| 1142 | - if(!$output->toBool()) return $output; |
|
| 1300 | + if(!$output->toBool()) { |
|
| 1301 | + return $output; |
|
| 1302 | + } |
|
| 1143 | 1303 | |
| 1144 | 1304 | $obj = new stdClass; |
| 1145 | 1305 | $obj->member_srl = $oDocument->get('member_srl'); |
@@ -1175,8 +1335,7 @@ discard block |
||
| 1175 | 1335 | { |
| 1176 | 1336 | $output->setMessage('success_voted'); |
| 1177 | 1337 | $output->add('voted_count', $obj->after_point); |
| 1178 | - } |
|
| 1179 | - else |
|
| 1338 | + } else |
|
| 1180 | 1339 | { |
| 1181 | 1340 | $output->setMessage('success_blamed'); |
| 1182 | 1341 | $output->add('blamed_count', $obj->after_point); |
@@ -1193,13 +1352,17 @@ discard block |
||
| 1193 | 1352 | function declaredDocument($document_srl) |
| 1194 | 1353 | { |
| 1195 | 1354 | // Fail if session information already has a reported document |
| 1196 | - if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared'); |
|
| 1355 | + if($_SESSION['declared_document'][$document_srl]) { |
|
| 1356 | + return new Object(-1, 'failed_declared'); |
|
| 1357 | + } |
|
| 1197 | 1358 | |
| 1198 | 1359 | // Check if previously reported |
| 1199 | 1360 | $args = new stdClass(); |
| 1200 | 1361 | $args->document_srl = $document_srl; |
| 1201 | 1362 | $output = executeQuery('document.getDeclaredDocument', $args); |
| 1202 | - if(!$output->toBool()) return $output; |
|
| 1363 | + if(!$output->toBool()) { |
|
| 1364 | + return $output; |
|
| 1365 | + } |
|
| 1203 | 1366 | |
| 1204 | 1367 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
| 1205 | 1368 | |
@@ -1243,8 +1406,7 @@ discard block |
||
| 1243 | 1406 | if($member_srl) |
| 1244 | 1407 | { |
| 1245 | 1408 | $args->member_srl = $member_srl; |
| 1246 | - } |
|
| 1247 | - else |
|
| 1409 | + } else |
|
| 1248 | 1410 | { |
| 1249 | 1411 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 1250 | 1412 | } |
@@ -1264,9 +1426,14 @@ discard block |
||
| 1264 | 1426 | $oDB->begin(); |
| 1265 | 1427 | |
| 1266 | 1428 | // Add the declared document |
| 1267 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1268 | - else $output = executeQuery('document.insertDeclaredDocument', $args); |
|
| 1269 | - if(!$output->toBool()) return $output; |
|
| 1429 | + if($declared_count > 0) { |
|
| 1430 | + $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1431 | + } else { |
|
| 1432 | + $output = executeQuery('document.insertDeclaredDocument', $args); |
|
| 1433 | + } |
|
| 1434 | + if(!$output->toBool()) { |
|
| 1435 | + return $output; |
|
| 1436 | + } |
|
| 1270 | 1437 | // Leave logs |
| 1271 | 1438 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
| 1272 | 1439 | if(!$output->toBool()) |
@@ -1365,9 +1532,10 @@ discard block |
||
| 1365 | 1532 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
| 1366 | 1533 | $obj->list_order = $parent_category->list_order; |
| 1367 | 1534 | $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
| 1368 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1369 | - } |
|
| 1370 | - else |
|
| 1535 | + if(!$obj->category_srl) { |
|
| 1536 | + $obj->category_srl = getNextSequence(); |
|
| 1537 | + } |
|
| 1538 | + } else |
|
| 1371 | 1539 | { |
| 1372 | 1540 | $obj->list_order = $obj->category_srl = getNextSequence(); |
| 1373 | 1541 | } |
@@ -1407,13 +1575,17 @@ discard block |
||
| 1407 | 1575 | { |
| 1408 | 1576 | // Create a document model object |
| 1409 | 1577 | $oDocumentModel = getModel('document'); |
| 1410 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
| 1578 | + if(!$document_count) { |
|
| 1579 | + $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
| 1580 | + } |
|
| 1411 | 1581 | |
| 1412 | 1582 | $args = new stdClass; |
| 1413 | 1583 | $args->category_srl = $category_srl; |
| 1414 | 1584 | $args->document_count = $document_count; |
| 1415 | 1585 | $output = executeQuery('document.updateCategoryCount', $args); |
| 1416 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1586 | + if($output->toBool()) { |
|
| 1587 | + $this->makeCategoryFile($module_srl); |
|
| 1588 | + } |
|
| 1417 | 1589 | |
| 1418 | 1590 | return $output; |
| 1419 | 1591 | } |
@@ -1426,7 +1598,9 @@ discard block |
||
| 1426 | 1598 | function updateCategory($obj) |
| 1427 | 1599 | { |
| 1428 | 1600 | $output = executeQuery('document.updateCategory', $obj); |
| 1429 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1601 | + if($output->toBool()) { |
|
| 1602 | + $this->makeCategoryFile($obj->module_srl); |
|
| 1603 | + } |
|
| 1430 | 1604 | return $output; |
| 1431 | 1605 | } |
| 1432 | 1606 | |
@@ -1443,11 +1617,17 @@ discard block |
||
| 1443 | 1617 | $category_info = $oDocumentModel->getCategory($category_srl); |
| 1444 | 1618 | // Display an error that the category cannot be deleted if it has a child |
| 1445 | 1619 | $output = executeQuery('document.getChildCategoryCount', $args); |
| 1446 | - if(!$output->toBool()) return $output; |
|
| 1447 | - if($output->data->count>0) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1620 | + if(!$output->toBool()) { |
|
| 1621 | + return $output; |
|
| 1622 | + } |
|
| 1623 | + if($output->data->count>0) { |
|
| 1624 | + return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1625 | + } |
|
| 1448 | 1626 | // Delete a category information |
| 1449 | 1627 | $output = executeQuery('document.deleteCategory', $args); |
| 1450 | - if(!$output->toBool()) return $output; |
|
| 1628 | + if(!$output->toBool()) { |
|
| 1629 | + return $output; |
|
| 1630 | + } |
|
| 1451 | 1631 | |
| 1452 | 1632 | $this->makeCategoryFile($category_info->module_srl); |
| 1453 | 1633 | // remvove cache |
@@ -1462,8 +1642,9 @@ discard block |
||
| 1462 | 1642 | $args->page = ++$page; |
| 1463 | 1643 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
| 1464 | 1644 | |
| 1465 | - if($output->data == array()) |
|
| 1466 | - break; |
|
| 1645 | + if($output->data == array()) { |
|
| 1646 | + break; |
|
| 1647 | + } |
|
| 1467 | 1648 | |
| 1468 | 1649 | foreach($output->data as $val) |
| 1469 | 1650 | { |
@@ -1515,18 +1696,26 @@ discard block |
||
| 1515 | 1696 | // Seek a full list of categories |
| 1516 | 1697 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1517 | 1698 | $category_srl_list = array_keys($category_list); |
| 1518 | - if(count($category_srl_list)<2) return new Object(); |
|
| 1699 | + if(count($category_srl_list)<2) { |
|
| 1700 | + return new Object(); |
|
| 1701 | + } |
|
| 1519 | 1702 | |
| 1520 | 1703 | $prev_category = NULL; |
| 1521 | 1704 | foreach($category_list as $key => $val) |
| 1522 | 1705 | { |
| 1523 | - if($key==$category_srl) break; |
|
| 1706 | + if($key==$category_srl) { |
|
| 1707 | + break; |
|
| 1708 | + } |
|
| 1524 | 1709 | $prev_category = $val; |
| 1525 | 1710 | } |
| 1526 | 1711 | // Return if the previous category doesn't exist |
| 1527 | - if(!$prev_category) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1712 | + if(!$prev_category) { |
|
| 1713 | + return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1714 | + } |
|
| 1528 | 1715 | // Return if the selected category is the top level |
| 1529 | - if($category_srl_list[0]==$category_srl) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1716 | + if($category_srl_list[0]==$category_srl) { |
|
| 1717 | + return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1718 | + } |
|
| 1530 | 1719 | // Information of the selected category |
| 1531 | 1720 | $cur_args = new stdClass; |
| 1532 | 1721 | $cur_args->category_srl = $category_srl; |
@@ -1562,15 +1751,21 @@ discard block |
||
| 1562 | 1751 | // Seek a full list of categories |
| 1563 | 1752 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1564 | 1753 | $category_srl_list = array_keys($category_list); |
| 1565 | - if(count($category_srl_list)<2) return new Object(); |
|
| 1754 | + if(count($category_srl_list)<2) { |
|
| 1755 | + return new Object(); |
|
| 1756 | + } |
|
| 1566 | 1757 | |
| 1567 | 1758 | for($i=0;$i<count($category_srl_list);$i++) |
| 1568 | 1759 | { |
| 1569 | - if($category_srl_list[$i]==$category_srl) break; |
|
| 1760 | + if($category_srl_list[$i]==$category_srl) { |
|
| 1761 | + break; |
|
| 1762 | + } |
|
| 1570 | 1763 | } |
| 1571 | 1764 | |
| 1572 | 1765 | $next_category_srl = $category_srl_list[$i+1]; |
| 1573 | - if(!$category_list[$next_category_srl]) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1766 | + if(!$category_list[$next_category_srl]) { |
|
| 1767 | + return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1768 | + } |
|
| 1574 | 1769 | $next_category = $category_list[$next_category_srl]; |
| 1575 | 1770 | // Information of the selected category |
| 1576 | 1771 | $cur_args = new stdClass; |
@@ -1597,7 +1792,9 @@ discard block |
||
| 1597 | 1792 | { |
| 1598 | 1793 | $oDocumentModel = getModel('document'); |
| 1599 | 1794 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
| 1600 | - if(!count($extra_keys)) return; |
|
| 1795 | + if(!count($extra_keys)) { |
|
| 1796 | + return; |
|
| 1797 | + } |
|
| 1601 | 1798 | |
| 1602 | 1799 | $js_code = array(); |
| 1603 | 1800 | $js_code[] = '<script>//<![CDATA['; |
@@ -1616,7 +1813,9 @@ discard block |
||
| 1616 | 1813 | } |
| 1617 | 1814 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
| 1618 | 1815 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
| 1619 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1816 | + if($val->is_required == 'Y') { |
|
| 1817 | + $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1818 | + } |
|
| 1620 | 1819 | } |
| 1621 | 1820 | |
| 1622 | 1821 | $js_code[] = '})(jQuery);'; |
@@ -1634,7 +1833,9 @@ discard block |
||
| 1634 | 1833 | function procDocumentInsertCategory($args = null) |
| 1635 | 1834 | { |
| 1636 | 1835 | // List variables |
| 1637 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
| 1836 | + if(!$args) { |
|
| 1837 | + $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
| 1838 | + } |
|
| 1638 | 1839 | $args->title = $args->category_title; |
| 1639 | 1840 | $args->description = $args->category_description; |
| 1640 | 1841 | $args->color = $args->category_color; |
@@ -1650,11 +1851,18 @@ discard block |
||
| 1650 | 1851 | $columnList = array('module_srl', 'module'); |
| 1651 | 1852 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1652 | 1853 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1653 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1854 | + if(!$grant->manager) { |
|
| 1855 | + return new Object(-1,'msg_not_permitted'); |
|
| 1856 | + } |
|
| 1654 | 1857 | |
| 1655 | - if($args->expand !="Y") $args->expand = "N"; |
|
| 1656 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
| 1657 | - else $args->group_srls = implode(',', $args->group_srls); |
|
| 1858 | + if($args->expand !="Y") { |
|
| 1859 | + $args->expand = "N"; |
|
| 1860 | + } |
|
| 1861 | + if(!is_array($args->group_srls)) { |
|
| 1862 | + $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
| 1863 | + } else { |
|
| 1864 | + $args->group_srls = implode(',', $args->group_srls); |
|
| 1865 | + } |
|
| 1658 | 1866 | $args->parent_srl = (int)$args->parent_srl; |
| 1659 | 1867 | |
| 1660 | 1868 | $oDocumentModel = getModel('document'); |
@@ -1665,7 +1873,9 @@ discard block |
||
| 1665 | 1873 | if($args->category_srl) |
| 1666 | 1874 | { |
| 1667 | 1875 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1668 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1876 | + if($category_info->category_srl != $args->category_srl) { |
|
| 1877 | + $args->category_srl = null; |
|
| 1878 | + } |
|
| 1669 | 1879 | } |
| 1670 | 1880 | // Update if exists |
| 1671 | 1881 | if($args->category_srl) |
@@ -1677,8 +1887,7 @@ discard block |
||
| 1677 | 1887 | return $output; |
| 1678 | 1888 | } |
| 1679 | 1889 | // Insert if not exist |
| 1680 | - } |
|
| 1681 | - else |
|
| 1890 | + } else |
|
| 1682 | 1891 | { |
| 1683 | 1892 | $output = $this->insertCategory($args); |
| 1684 | 1893 | if(!$output->toBool()) |
@@ -1720,7 +1929,9 @@ discard block |
||
| 1720 | 1929 | $columnList = array('module_srl', 'module'); |
| 1721 | 1930 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
| 1722 | 1931 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1723 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1932 | + if(!$grant->manager) { |
|
| 1933 | + return new Object(-1,'msg_not_permitted'); |
|
| 1934 | + } |
|
| 1724 | 1935 | |
| 1725 | 1936 | // First child of the parent_category_srl |
| 1726 | 1937 | $source_args = new stdClass; |
@@ -1733,30 +1944,39 @@ discard block |
||
| 1733 | 1944 | $args->parent_srl = $parent_category_srl; |
| 1734 | 1945 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
| 1735 | 1946 | |
| 1736 | - if(!$output->toBool()) return $output; |
|
| 1947 | + if(!$output->toBool()) { |
|
| 1948 | + return $output; |
|
| 1949 | + } |
|
| 1737 | 1950 | $args->list_order = (int)$output->data->list_order; |
| 1738 | - if(!$args->list_order) $args->list_order = 0; |
|
| 1951 | + if(!$args->list_order) { |
|
| 1952 | + $args->list_order = 0; |
|
| 1953 | + } |
|
| 1739 | 1954 | $args->list_order--; |
| 1740 | 1955 | |
| 1741 | 1956 | $source_args->category_srl = $source_category_srl; |
| 1742 | 1957 | $source_args->parent_srl = $parent_category_srl; |
| 1743 | 1958 | $source_args->list_order = $args->list_order; |
| 1744 | 1959 | $output = $this->updateCategory($source_args); |
| 1745 | - if(!$output->toBool()) return $output; |
|
| 1960 | + if(!$output->toBool()) { |
|
| 1961 | + return $output; |
|
| 1962 | + } |
|
| 1746 | 1963 | // Sibling of the $target_category_srl |
| 1747 | - } |
|
| 1748 | - else if($target_category_srl > 0) |
|
| 1964 | + } else if($target_category_srl > 0) |
|
| 1749 | 1965 | { |
| 1750 | 1966 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
| 1751 | 1967 | // Move all siblings of the $target_category down |
| 1752 | 1968 | $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
| 1753 | - if(!$output->toBool()) return $output; |
|
| 1969 | + if(!$output->toBool()) { |
|
| 1970 | + return $output; |
|
| 1971 | + } |
|
| 1754 | 1972 | |
| 1755 | 1973 | $source_args->category_srl = $source_category_srl; |
| 1756 | 1974 | $source_args->parent_srl = $target_category->parent_srl; |
| 1757 | 1975 | $source_args->list_order = $target_category->list_order+1; |
| 1758 | 1976 | $output = $this->updateCategory($source_args); |
| 1759 | - if(!$output->toBool()) return $output; |
|
| 1977 | + if(!$output->toBool()) { |
|
| 1978 | + return $output; |
|
| 1979 | + } |
|
| 1760 | 1980 | } |
| 1761 | 1981 | // Re-generate the xml file |
| 1762 | 1982 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1781,14 +2001,20 @@ discard block |
||
| 1781 | 2001 | $columnList = array('module_srl', 'module'); |
| 1782 | 2002 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1783 | 2003 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1784 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 2004 | + if(!$grant->manager) { |
|
| 2005 | + return new Object(-1,'msg_not_permitted'); |
|
| 2006 | + } |
|
| 1785 | 2007 | |
| 1786 | 2008 | $oDocumentModel = getModel('document'); |
| 1787 | 2009 | // Get original information |
| 1788 | 2010 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1789 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 2011 | + if($category_info->parent_srl) { |
|
| 2012 | + $parent_srl = $category_info->parent_srl; |
|
| 2013 | + } |
|
| 1790 | 2014 | // Display an error that the category cannot be deleted if it has a child node |
| 1791 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 2015 | + if($oDocumentModel->getCategoryChlidCount($args->category_srl)) { |
|
| 2016 | + return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 2017 | + } |
|
| 1792 | 2018 | // Remove from the DB |
| 1793 | 2019 | $output = $this->deleteCategory($args->category_srl); |
| 1794 | 2020 | if(!$output->toBool()) |
@@ -1822,7 +2048,9 @@ discard block |
||
| 1822 | 2048 | $columnList = array('module_srl', 'module'); |
| 1823 | 2049 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1824 | 2050 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1825 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 2051 | + if(!$grant->manager) { |
|
| 2052 | + return new Object(-1,'msg_not_permitted'); |
|
| 2053 | + } |
|
| 1826 | 2054 | |
| 1827 | 2055 | $xml_file = $this->makeCategoryFile($module_srl); |
| 1828 | 2056 | // Set return value |
@@ -1837,14 +2065,18 @@ discard block |
||
| 1837 | 2065 | function makeCategoryFile($module_srl) |
| 1838 | 2066 | { |
| 1839 | 2067 | // Return if there is no information you need for creating a cache file |
| 1840 | - if(!$module_srl) return false; |
|
| 2068 | + if(!$module_srl) { |
|
| 2069 | + return false; |
|
| 2070 | + } |
|
| 1841 | 2071 | // Get module information (to obtain mid) |
| 1842 | 2072 | $oModuleModel = getModel('module'); |
| 1843 | 2073 | $columnList = array('module_srl', 'mid', 'site_srl'); |
| 1844 | 2074 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1845 | 2075 | $mid = $module_info->mid; |
| 1846 | 2076 | |
| 1847 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 2077 | + if(!is_dir('./files/cache/document_category')) { |
|
| 2078 | + FileHandler::makeDir('./files/cache/document_category'); |
|
| 2079 | + } |
|
| 1848 | 2080 | // Cache file's name |
| 1849 | 2081 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
| 1850 | 2082 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1856,13 +2088,17 @@ discard block |
||
| 1856 | 2088 | |
| 1857 | 2089 | $category_list = $output->data; |
| 1858 | 2090 | |
| 1859 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
| 2091 | + if(!is_array($category_list)) { |
|
| 2092 | + $category_list = array($category_list); |
|
| 2093 | + } |
|
| 1860 | 2094 | |
| 1861 | 2095 | $category_count = count($category_list); |
| 1862 | 2096 | for($i=0;$i<$category_count;$i++) |
| 1863 | 2097 | { |
| 1864 | 2098 | $category_srl = $category_list[$i]->category_srl; |
| 1865 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 2099 | + if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) { |
|
| 2100 | + $category_list[$i]->group_srls = ''; |
|
| 2101 | + } |
|
| 1866 | 2102 | $list[$category_srl] = $category_list[$i]; |
| 1867 | 2103 | } |
| 1868 | 2104 | // Create the xml file without node data if no data is obtained |
@@ -1874,7 +2110,9 @@ discard block |
||
| 1874 | 2110 | return $xml_file; |
| 1875 | 2111 | } |
| 1876 | 2112 | // Change to an array if only a single data is obtained |
| 1877 | - if(!is_array($list)) $list = array($list); |
|
| 2113 | + if(!is_array($list)) { |
|
| 2114 | + $list = array($list); |
|
| 2115 | + } |
|
| 1878 | 2116 | // Create a tree for loop |
| 1879 | 2117 | foreach($list as $category_srl => $node) |
| 1880 | 2118 | { |
@@ -1953,13 +2191,17 @@ discard block |
||
| 1953 | 2191 | */ |
| 1954 | 2192 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
| 1955 | 2193 | { |
| 1956 | - if(!$source_node) return; |
|
| 2194 | + if(!$source_node) { |
|
| 2195 | + return; |
|
| 2196 | + } |
|
| 1957 | 2197 | |
| 1958 | 2198 | foreach($source_node as $category_srl => $node) |
| 1959 | 2199 | { |
| 1960 | 2200 | $child_buff = ""; |
| 1961 | 2201 | // Get data of the child nodes |
| 1962 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 2202 | + if($category_srl && $tree[$category_srl]) { |
|
| 2203 | + $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 2204 | + } |
|
| 1963 | 2205 | // List variables |
| 1964 | 2206 | $expand = $node->expand; |
| 1965 | 2207 | $group_srls = $node->group_srls; |
@@ -1969,8 +2211,11 @@ discard block |
||
| 1969 | 2211 | $color = $node->color; |
| 1970 | 2212 | $description = $node->description; |
| 1971 | 2213 | // If node->group_srls value exists |
| 1972 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
| 1973 | - else $group_check_code = "true"; |
|
| 2214 | + if($group_srls) { |
|
| 2215 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
| 2216 | + } else { |
|
| 2217 | + $group_check_code = "true"; |
|
| 2218 | + } |
|
| 1974 | 2219 | |
| 1975 | 2220 | $title = $node->title; |
| 1976 | 2221 | $oModuleAdminModel = getAdminModel('module'); |
@@ -2010,8 +2255,11 @@ discard block |
||
| 2010 | 2255 | $node->document_count |
| 2011 | 2256 | ); |
| 2012 | 2257 | |
| 2013 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2014 | - else $buff .= sprintf('<node %s />', $attribute); |
|
| 2258 | + if($child_buff) { |
|
| 2259 | + $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2260 | + } else { |
|
| 2261 | + $buff .= sprintf('<node %s />', $attribute); |
|
| 2262 | + } |
|
| 2015 | 2263 | } |
| 2016 | 2264 | return $buff; |
| 2017 | 2265 | } |
@@ -2030,7 +2278,9 @@ discard block |
||
| 2030 | 2278 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
| 2031 | 2279 | { |
| 2032 | 2280 | $output = array("buff"=>"", "category_srl_list"=>array()); |
| 2033 | - if(!$source_node) return $output; |
|
| 2281 | + if(!$source_node) { |
|
| 2282 | + return $output; |
|
| 2283 | + } |
|
| 2034 | 2284 | |
| 2035 | 2285 | // Set to an arraty for looping and then generate php script codes to be included |
| 2036 | 2286 | foreach($source_node as $category_srl => $node) |
@@ -2129,7 +2379,9 @@ discard block |
||
| 2129 | 2379 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
| 2130 | 2380 | { |
| 2131 | 2381 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
| 2132 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2382 | + if(!is_array($document_popup_menu_list)) { |
|
| 2383 | + $document_popup_menu_list = array(); |
|
| 2384 | + } |
|
| 2133 | 2385 | |
| 2134 | 2386 | $obj = new stdClass(); |
| 2135 | 2387 | $obj->url = $url; |
@@ -2147,7 +2399,9 @@ discard block |
||
| 2147 | 2399 | */ |
| 2148 | 2400 | function procDocumentAddCart() |
| 2149 | 2401 | { |
| 2150 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2402 | + if(!Context::get('is_logged')) { |
|
| 2403 | + return new Object(-1, 'msg_not_permitted'); |
|
| 2404 | + } |
|
| 2151 | 2405 | |
| 2152 | 2406 | // Get document_srl |
| 2153 | 2407 | $srls = explode(',',Context::get('srls')); |
@@ -2155,11 +2409,15 @@ discard block |
||
| 2155 | 2409 | { |
| 2156 | 2410 | $srl = trim($srls[$i]); |
| 2157 | 2411 | |
| 2158 | - if(!$srl) continue; |
|
| 2412 | + if(!$srl) { |
|
| 2413 | + continue; |
|
| 2414 | + } |
|
| 2159 | 2415 | |
| 2160 | 2416 | $document_srls[] = $srl; |
| 2161 | 2417 | } |
| 2162 | - if(!count($document_srls)) return; |
|
| 2418 | + if(!count($document_srls)) { |
|
| 2419 | + return; |
|
| 2420 | + } |
|
| 2163 | 2421 | |
| 2164 | 2422 | // Get module_srl of the documents |
| 2165 | 2423 | $args = new stdClass; |
@@ -2167,14 +2425,18 @@ discard block |
||
| 2167 | 2425 | $args->document_srls = implode(',',$document_srls); |
| 2168 | 2426 | $args->order_type = 'asc'; |
| 2169 | 2427 | $output = executeQueryArray('document.getDocuments', $args); |
| 2170 | - if(!$output->data) return new Object(); |
|
| 2428 | + if(!$output->data) { |
|
| 2429 | + return new Object(); |
|
| 2430 | + } |
|
| 2171 | 2431 | |
| 2172 | 2432 | unset($document_srls); |
| 2173 | 2433 | foreach($output->data as $key => $val) |
| 2174 | 2434 | { |
| 2175 | 2435 | $document_srls[$val->module_srl][] = $val->document_srl; |
| 2176 | 2436 | } |
| 2177 | - if(!$document_srls || !count($document_srls)) return new Object(); |
|
| 2437 | + if(!$document_srls || !count($document_srls)) { |
|
| 2438 | + return new Object(); |
|
| 2439 | + } |
|
| 2178 | 2440 | |
| 2179 | 2441 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
| 2180 | 2442 | $oModuleModel = getModel('module'); |
@@ -2199,7 +2461,9 @@ discard block |
||
| 2199 | 2461 | } |
| 2200 | 2462 | } |
| 2201 | 2463 | } |
| 2202 | - if(!count($document_srls)) return new Object(); |
|
| 2464 | + if(!count($document_srls)) { |
|
| 2465 | + return new Object(); |
|
| 2466 | + } |
|
| 2203 | 2467 | |
| 2204 | 2468 | foreach($document_srls as $module_srl => $documents) |
| 2205 | 2469 | { |
@@ -2207,9 +2471,14 @@ discard block |
||
| 2207 | 2471 | for($i=0;$i<$cnt;$i++) |
| 2208 | 2472 | { |
| 2209 | 2473 | $document_srl = (int)trim($documents[$i]); |
| 2210 | - if(!$document_srls) continue; |
|
| 2211 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2212 | - else $_SESSION['document_management'][$document_srl] = true; |
|
| 2474 | + if(!$document_srls) { |
|
| 2475 | + continue; |
|
| 2476 | + } |
|
| 2477 | + if($_SESSION['document_management'][$document_srl]) { |
|
| 2478 | + unset($_SESSION['document_management'][$document_srl]); |
|
| 2479 | + } else { |
|
| 2480 | + $_SESSION['document_management'][$document_srl] = true; |
|
| 2481 | + } |
|
| 2213 | 2482 | } |
| 2214 | 2483 | } |
| 2215 | 2484 | } |
@@ -2221,7 +2490,9 @@ discard block |
||
| 2221 | 2490 | function procDocumentManageCheckedDocument() |
| 2222 | 2491 | { |
| 2223 | 2492 | @set_time_limit(0); |
| 2224 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 2493 | + if(!Context::get('is_logged')) { |
|
| 2494 | + return new Object(-1,'msg_not_permitted'); |
|
| 2495 | + } |
|
| 2225 | 2496 | |
| 2226 | 2497 | if(!checkCSRF()) |
| 2227 | 2498 | { |
@@ -2231,14 +2502,21 @@ discard block |
||
| 2231 | 2502 | $type = Context::get('type'); |
| 2232 | 2503 | $target_module = Context::get('target_module'); |
| 2233 | 2504 | $module_srl = Context::get('module_srl'); |
| 2234 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2505 | + if($target_module && !$module_srl) { |
|
| 2506 | + $module_srl = $target_module; |
|
| 2507 | + } |
|
| 2235 | 2508 | $category_srl = Context::get('target_category'); |
| 2236 | 2509 | $message_content = Context::get('message_content'); |
| 2237 | - if($message_content) $message_content = nl2br($message_content); |
|
| 2510 | + if($message_content) { |
|
| 2511 | + $message_content = nl2br($message_content); |
|
| 2512 | + } |
|
| 2238 | 2513 | |
| 2239 | 2514 | $cart = Context::get('cart'); |
| 2240 | - if(!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2241 | - else $document_srl_list = $cart; |
|
| 2515 | + if(!is_array($cart)) { |
|
| 2516 | + $document_srl_list = explode('|@|', $cart); |
|
| 2517 | + } else { |
|
| 2518 | + $document_srl_list = $cart; |
|
| 2519 | + } |
|
| 2242 | 2520 | |
| 2243 | 2521 | $document_srl_count = count($document_srl_list); |
| 2244 | 2522 | |
@@ -2248,7 +2526,9 @@ discard block |
||
| 2248 | 2526 | { |
| 2249 | 2527 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 2250 | 2528 | $document_items[] = $oDocument; |
| 2251 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2529 | + if(!$oDocument->isGranted()) { |
|
| 2530 | + return $this->stop('msg_not_permitted'); |
|
| 2531 | + } |
|
| 2252 | 2532 | } |
| 2253 | 2533 | |
| 2254 | 2534 | // Send a message |
@@ -2264,10 +2544,15 @@ discard block |
||
| 2264 | 2544 | |
| 2265 | 2545 | foreach($document_items as $oDocument) |
| 2266 | 2546 | { |
| 2267 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
| 2547 | + if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) { |
|
| 2548 | + continue; |
|
| 2549 | + } |
|
| 2268 | 2550 | |
| 2269 | - if($type=='move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2270 | - else $purl = ""; |
|
| 2551 | + if($type=='move') { |
|
| 2552 | + $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2553 | + } else { |
|
| 2554 | + $purl = ""; |
|
| 2555 | + } |
|
| 2271 | 2556 | $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
| 2272 | 2557 | |
| 2273 | 2558 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
@@ -2280,24 +2565,30 @@ discard block |
||
| 2280 | 2565 | $oDocumentAdminController = getAdminController('document'); |
| 2281 | 2566 | if($type == 'move') |
| 2282 | 2567 | { |
| 2283 | - if(!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2568 | + if(!$module_srl) { |
|
| 2569 | + return new Object(-1, 'fail_to_move'); |
|
| 2570 | + } |
|
| 2284 | 2571 | |
| 2285 | 2572 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2286 | - if(!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2573 | + if(!$output->toBool()) { |
|
| 2574 | + return new Object(-1, 'fail_to_move'); |
|
| 2575 | + } |
|
| 2287 | 2576 | |
| 2288 | 2577 | $msg_code = 'success_moved'; |
| 2289 | 2578 | |
| 2290 | - } |
|
| 2291 | - else if($type == 'copy') |
|
| 2579 | + } else if($type == 'copy') |
|
| 2292 | 2580 | { |
| 2293 | - if(!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2581 | + if(!$module_srl) { |
|
| 2582 | + return new Object(-1, 'fail_to_move'); |
|
| 2583 | + } |
|
| 2294 | 2584 | |
| 2295 | 2585 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2296 | - if(!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2586 | + if(!$output->toBool()) { |
|
| 2587 | + return new Object(-1, 'fail_to_move'); |
|
| 2588 | + } |
|
| 2297 | 2589 | |
| 2298 | 2590 | $msg_code = 'success_copied'; |
| 2299 | - } |
|
| 2300 | - else if($type =='delete') |
|
| 2591 | + } else if($type =='delete') |
|
| 2301 | 2592 | { |
| 2302 | 2593 | $oDB = &DB::getInstance(); |
| 2303 | 2594 | $oDB->begin(); |
@@ -2305,12 +2596,13 @@ discard block |
||
| 2305 | 2596 | { |
| 2306 | 2597 | $document_srl = $document_srl_list[$i]; |
| 2307 | 2598 | $output = $this->deleteDocument($document_srl, true); |
| 2308 | - if(!$output->toBool()) return new Object(-1, 'fail_to_delete'); |
|
| 2599 | + if(!$output->toBool()) { |
|
| 2600 | + return new Object(-1, 'fail_to_delete'); |
|
| 2601 | + } |
|
| 2309 | 2602 | } |
| 2310 | 2603 | $oDB->commit(); |
| 2311 | 2604 | $msg_code = 'success_deleted'; |
| 2312 | - } |
|
| 2313 | - else if($type == 'trash') |
|
| 2605 | + } else if($type == 'trash') |
|
| 2314 | 2606 | { |
| 2315 | 2607 | $args = new stdClass(); |
| 2316 | 2608 | $args->description = $message_content; |
@@ -2320,12 +2612,13 @@ discard block |
||
| 2320 | 2612 | for($i=0;$i<$document_srl_count;$i++) { |
| 2321 | 2613 | $args->document_srl = $document_srl_list[$i]; |
| 2322 | 2614 | $output = $this->moveDocumentToTrash($args); |
| 2323 | - if(!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash'); |
|
| 2615 | + if(!$output || !$output->toBool()) { |
|
| 2616 | + return new Object(-1, 'fail_to_trash'); |
|
| 2617 | + } |
|
| 2324 | 2618 | } |
| 2325 | 2619 | $oDB->commit(); |
| 2326 | 2620 | $msg_code = 'success_trashed'; |
| 2327 | - } |
|
| 2328 | - else if($type == 'cancelDeclare') |
|
| 2621 | + } else if($type == 'cancelDeclare') |
|
| 2329 | 2622 | { |
| 2330 | 2623 | $args->document_srl = $document_srl_list; |
| 2331 | 2624 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2347,18 +2640,27 @@ discard block |
||
| 2347 | 2640 | function procDocumentInsertModuleConfig() |
| 2348 | 2641 | { |
| 2349 | 2642 | $module_srl = Context::get('target_module_srl'); |
| 2350 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 2351 | - else $module_srl = array($module_srl); |
|
| 2643 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
| 2644 | + $module_srl = explode(',',$module_srl); |
|
| 2645 | + } else { |
|
| 2646 | + $module_srl = array($module_srl); |
|
| 2647 | + } |
|
| 2352 | 2648 | |
| 2353 | 2649 | $document_config = new stdClass(); |
| 2354 | 2650 | $document_config->use_history = Context::get('use_history'); |
| 2355 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2651 | + if(!$document_config->use_history) { |
|
| 2652 | + $document_config->use_history = 'N'; |
|
| 2653 | + } |
|
| 2356 | 2654 | |
| 2357 | 2655 | $document_config->use_vote_up = Context::get('use_vote_up'); |
| 2358 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2656 | + if(!$document_config->use_vote_up) { |
|
| 2657 | + $document_config->use_vote_up = 'Y'; |
|
| 2658 | + } |
|
| 2359 | 2659 | |
| 2360 | 2660 | $document_config->use_vote_down = Context::get('use_vote_down'); |
| 2361 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2661 | + if(!$document_config->use_vote_down) { |
|
| 2662 | + $document_config->use_vote_down = 'Y'; |
|
| 2663 | + } |
|
| 2362 | 2664 | |
| 2363 | 2665 | $document_config->use_status = Context::get('use_status'); |
| 2364 | 2666 | |
@@ -2366,7 +2668,9 @@ discard block |
||
| 2366 | 2668 | for($i=0;$i<count($module_srl);$i++) |
| 2367 | 2669 | { |
| 2368 | 2670 | $srl = trim($module_srl[$i]); |
| 2369 | - if(!$srl) continue; |
|
| 2671 | + if(!$srl) { |
|
| 2672 | + continue; |
|
| 2673 | + } |
|
| 2370 | 2674 | $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
| 2371 | 2675 | } |
| 2372 | 2676 | $this->setError(-1); |
@@ -2383,7 +2687,9 @@ discard block |
||
| 2383 | 2687 | function procDocumentTempSave() |
| 2384 | 2688 | { |
| 2385 | 2689 | // Check login information |
| 2386 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); |
|
| 2690 | + if(!Context::get('is_logged')) { |
|
| 2691 | + return new Object(-1, 'msg_not_logged'); |
|
| 2692 | + } |
|
| 2387 | 2693 | $module_info = Context::get('module_info'); |
| 2388 | 2694 | $logged_info = Context::get('logged_info'); |
| 2389 | 2695 | |
@@ -2421,8 +2727,7 @@ discard block |
||
| 2421 | 2727 | $output = $oDocumentController->updateDocument($oDocument, $obj); |
| 2422 | 2728 | $msg_code = 'success_updated'; |
| 2423 | 2729 | // Otherwise, get a new |
| 2424 | - } |
|
| 2425 | - else |
|
| 2730 | + } else |
|
| 2426 | 2731 | { |
| 2427 | 2732 | $output = $oDocumentController->insertDocument($obj); |
| 2428 | 2733 | $msg_code = 'success_registed'; |
@@ -2448,17 +2753,20 @@ discard block |
||
| 2448 | 2753 | */ |
| 2449 | 2754 | function procDocumentGetList() |
| 2450 | 2755 | { |
| 2451 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 2756 | + if(!Context::get('is_logged')) { |
|
| 2757 | + return new Object(-1,'msg_not_permitted'); |
|
| 2758 | + } |
|
| 2452 | 2759 | $documentSrls = Context::get('document_srls'); |
| 2453 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2760 | + if($documentSrls) { |
|
| 2761 | + $documentSrlList = explode(',', $documentSrls); |
|
| 2762 | + } |
|
| 2454 | 2763 | |
| 2455 | 2764 | if(count($documentSrlList) > 0) |
| 2456 | 2765 | { |
| 2457 | 2766 | $oDocumentModel = getModel('document'); |
| 2458 | 2767 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
| 2459 | 2768 | $documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList); |
| 2460 | - } |
|
| 2461 | - else |
|
| 2769 | + } else |
|
| 2462 | 2770 | { |
| 2463 | 2771 | global $lang; |
| 2464 | 2772 | $documentList = array(); |
@@ -2476,11 +2784,18 @@ discard block |
||
| 2476 | 2784 | */ |
| 2477 | 2785 | function _checkCommentStatusForOldVersion(&$obj) |
| 2478 | 2786 | { |
| 2479 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2480 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2787 | + if(!isset($obj->allow_comment)) { |
|
| 2788 | + $obj->allow_comment = 'N'; |
|
| 2789 | + } |
|
| 2790 | + if(!isset($obj->lock_comment)) { |
|
| 2791 | + $obj->lock_comment = 'N'; |
|
| 2792 | + } |
|
| 2481 | 2793 | |
| 2482 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2483 | - else $obj->commentStatus = 'DENY'; |
|
| 2794 | + if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') { |
|
| 2795 | + $obj->commentStatus = 'ALLOW'; |
|
| 2796 | + } else { |
|
| 2797 | + $obj->commentStatus = 'DENY'; |
|
| 2798 | + } |
|
| 2484 | 2799 | } |
| 2485 | 2800 | |
| 2486 | 2801 | /** |
@@ -2490,8 +2805,12 @@ discard block |
||
| 2490 | 2805 | */ |
| 2491 | 2806 | function _checkDocumentStatusForOldVersion(&$obj) |
| 2492 | 2807 | { |
| 2493 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2494 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2808 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
| 2809 | + $obj->status = $this->getConfigStatus('secret'); |
|
| 2810 | + } |
|
| 2811 | + if(!$obj->status && $obj->is_secret != 'Y') { |
|
| 2812 | + $obj->status = $this->getConfigStatus('public'); |
|
| 2813 | + } |
|
| 2495 | 2814 | } |
| 2496 | 2815 | |
| 2497 | 2816 | public function updateUploaedCount($documentSrlList) |
@@ -1106,8 +1106,7 @@ |
||
| 1106 | 1106 | |
| 1107 | 1107 | /** |
| 1108 | 1108 | * Check accessible by document status |
| 1109 | - * @param array $matches |
|
| 1110 | - * @return mixed |
|
| 1109 | + * @return boolean |
|
| 1111 | 1110 | */ |
| 1112 | 1111 | function _checkAccessibleFromStatus() |
| 1113 | 1112 | { |
@@ -79,7 +79,9 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | function _loadFromDB($load_extra_vars = true) |
| 81 | 81 | { |
| 82 | - if(!$this->document_srl) return; |
|
| 82 | + if(!$this->document_srl) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 83 | 85 | |
| 84 | 86 | $document_item = false; |
| 85 | 87 | $cache_put = false; |
@@ -111,8 +113,7 @@ discard block |
||
| 111 | 113 | { |
| 112 | 114 | $oCacheHandler->put($cache_key, $document_item); |
| 113 | 115 | } |
| 114 | - } |
|
| 115 | - else |
|
| 116 | + } else |
|
| 116 | 117 | { |
| 117 | 118 | $document_item->readed_count = $output->data->readed_count; |
| 118 | 119 | $document_item->voted_count = $output->data->voted_count; |
@@ -159,23 +160,33 @@ discard block |
||
| 159 | 160 | |
| 160 | 161 | function isGranted() |
| 161 | 162 | { |
| 162 | - if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
| 163 | + if($_SESSION['own_document'][$this->document_srl]) { |
|
| 164 | + return $this->grant_cache = true; |
|
| 165 | + } |
|
| 163 | 166 | |
| 164 | 167 | if($this->grant_cache !== null) |
| 165 | 168 | { |
| 166 | 169 | return $this->grant_cache; |
| 167 | 170 | } |
| 168 | 171 | |
| 169 | - if(!Context::get('is_logged')) return $this->grant_cache = false; |
|
| 172 | + if(!Context::get('is_logged')) { |
|
| 173 | + return $this->grant_cache = false; |
|
| 174 | + } |
|
| 170 | 175 | |
| 171 | 176 | $logged_info = Context::get('logged_info'); |
| 172 | - if($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
| 177 | + if($logged_info->is_admin == 'Y') { |
|
| 178 | + return $this->grant_cache = true; |
|
| 179 | + } |
|
| 173 | 180 | |
| 174 | 181 | $oModuleModel = getModel('module'); |
| 175 | 182 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
| 176 | - if($grant->manager) return $this->grant_cache = true; |
|
| 183 | + if($grant->manager) { |
|
| 184 | + return $this->grant_cache = true; |
|
| 185 | + } |
|
| 177 | 186 | |
| 178 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
| 187 | + if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) { |
|
| 188 | + return $this->grant_cache = true; |
|
| 189 | + } |
|
| 179 | 190 | |
| 180 | 191 | return $this->grant_cache = false; |
| 181 | 192 | } |
@@ -194,7 +205,9 @@ discard block |
||
| 194 | 205 | function allowComment() |
| 195 | 206 | { |
| 196 | 207 | // init write, document is not exists. so allow comment status is true |
| 197 | - if(!$this->isExists()) return true; |
|
| 208 | + if(!$this->isExists()) { |
|
| 209 | + return true; |
|
| 210 | + } |
|
| 198 | 211 | |
| 199 | 212 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
| 200 | 213 | } |
@@ -209,8 +222,7 @@ discard block |
||
| 209 | 222 | if(!getClass('trackback')) |
| 210 | 223 | { |
| 211 | 224 | $allow_trackback_status = false; |
| 212 | - } |
|
| 213 | - else |
|
| 225 | + } else |
|
| 214 | 226 | { |
| 215 | 227 | // If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module. |
| 216 | 228 | $oModuleModel = getModel('module'); |
@@ -221,15 +233,21 @@ discard block |
||
| 221 | 233 | $trackback_config = new stdClass(); |
| 222 | 234 | } |
| 223 | 235 | |
| 224 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 225 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 226 | - else |
|
| 236 | + if(!isset($trackback_config->enable_trackback)) { |
|
| 237 | + $trackback_config->enable_trackback = 'Y'; |
|
| 238 | + } |
|
| 239 | + if($trackback_config->enable_trackback != 'Y') { |
|
| 240 | + $allow_trackback_status = false; |
|
| 241 | + } else |
|
| 227 | 242 | { |
| 228 | 243 | $module_srl = $this->get('module_srl'); |
| 229 | 244 | // Check settings of each module |
| 230 | 245 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
| 231 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 232 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 246 | + if($module_config->enable_trackback == 'N') { |
|
| 247 | + $allow_trackback_status = false; |
|
| 248 | + } else if($this->get('allow_trackback')=='Y' || !$this->isExists()) { |
|
| 249 | + $allow_trackback_status = true; |
|
| 250 | + } |
|
| 233 | 251 | } |
| 234 | 252 | } |
| 235 | 253 | } |
@@ -238,14 +256,18 @@ discard block |
||
| 238 | 256 | |
| 239 | 257 | function isLocked() |
| 240 | 258 | { |
| 241 | - if(!$this->isExists()) return false; |
|
| 259 | + if(!$this->isExists()) { |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 242 | 262 | |
| 243 | 263 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
| 244 | 264 | } |
| 245 | 265 | |
| 246 | 266 | function isEditable() |
| 247 | 267 | { |
| 248 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 268 | + if($this->isGranted() || !$this->get('member_srl')) { |
|
| 269 | + return true; |
|
| 270 | + } |
|
| 249 | 271 | return false; |
| 250 | 272 | } |
| 251 | 273 | |
@@ -267,9 +289,14 @@ discard block |
||
| 267 | 289 | |
| 268 | 290 | function doCart() |
| 269 | 291 | { |
| 270 | - if(!$this->document_srl) return false; |
|
| 271 | - if($this->isCarted()) $this->removeCart(); |
|
| 272 | - else $this->addCart(); |
|
| 292 | + if(!$this->document_srl) { |
|
| 293 | + return false; |
|
| 294 | + } |
|
| 295 | + if($this->isCarted()) { |
|
| 296 | + $this->removeCart(); |
|
| 297 | + } else { |
|
| 298 | + $this->addCart(); |
|
| 299 | + } |
|
| 273 | 300 | } |
| 274 | 301 | |
| 275 | 302 | function addCart() |
@@ -295,16 +322,26 @@ discard block |
||
| 295 | 322 | */ |
| 296 | 323 | function notify($type, $content) |
| 297 | 324 | { |
| 298 | - if(!$this->document_srl) return; |
|
| 325 | + if(!$this->document_srl) { |
|
| 326 | + return; |
|
| 327 | + } |
|
| 299 | 328 | // return if it is not useNotify |
| 300 | - if(!$this->useNotify()) return; |
|
| 329 | + if(!$this->useNotify()) { |
|
| 330 | + return; |
|
| 331 | + } |
|
| 301 | 332 | // Pass if an author is not a logged-in user |
| 302 | - if(!$this->get('member_srl')) return; |
|
| 333 | + if(!$this->get('member_srl')) { |
|
| 334 | + return; |
|
| 335 | + } |
|
| 303 | 336 | // Return if the currently logged-in user is an author |
| 304 | 337 | $logged_info = Context::get('logged_info'); |
| 305 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 338 | + if($logged_info->member_srl == $this->get('member_srl')) { |
|
| 339 | + return; |
|
| 340 | + } |
|
| 306 | 341 | // List variables |
| 307 | - if($type) $title = "[".$type."] "; |
|
| 342 | + if($type) { |
|
| 343 | + $title = "[".$type."] "; |
|
| 344 | + } |
|
| 308 | 345 | $title .= cut_str(strip_tags($content), 10, '...'); |
| 309 | 346 | $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
| 310 | 347 | $receiver_srl = $this->get('member_srl'); |
@@ -331,16 +368,22 @@ discard block |
||
| 331 | 368 | |
| 332 | 369 | function isExistsHomepage() |
| 333 | 370 | { |
| 334 | - if(trim($this->get('homepage'))) return true; |
|
| 371 | + if(trim($this->get('homepage'))) { |
|
| 372 | + return true; |
|
| 373 | + } |
|
| 335 | 374 | return false; |
| 336 | 375 | } |
| 337 | 376 | |
| 338 | 377 | function getHomepageUrl() |
| 339 | 378 | { |
| 340 | 379 | $url = trim($this->get('homepage')); |
| 341 | - if(!$url) return; |
|
| 380 | + if(!$url) { |
|
| 381 | + return; |
|
| 382 | + } |
|
| 342 | 383 | |
| 343 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
| 384 | + if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) { |
|
| 385 | + $url = 'http://' . $url; |
|
| 386 | + } |
|
| 344 | 387 | |
| 345 | 388 | return $url; |
| 346 | 389 | } |
@@ -372,43 +415,65 @@ discard block |
||
| 372 | 415 | |
| 373 | 416 | function getTitleText($cut_size = 0, $tail='...') |
| 374 | 417 | { |
| 375 | - if(!$this->document_srl) return; |
|
| 418 | + if(!$this->document_srl) { |
|
| 419 | + return; |
|
| 420 | + } |
|
| 376 | 421 | |
| 377 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 378 | - else $title = $this->get('title'); |
|
| 422 | + if($cut_size) { |
|
| 423 | + $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 424 | + } else { |
|
| 425 | + $title = $this->get('title'); |
|
| 426 | + } |
|
| 379 | 427 | |
| 380 | 428 | return $title; |
| 381 | 429 | } |
| 382 | 430 | |
| 383 | 431 | function getTitle($cut_size = 0, $tail='...') |
| 384 | 432 | { |
| 385 | - if(!$this->document_srl) return; |
|
| 433 | + if(!$this->document_srl) { |
|
| 434 | + return; |
|
| 435 | + } |
|
| 386 | 436 | |
| 387 | 437 | $title = $this->getTitleText($cut_size, $tail); |
| 388 | 438 | |
| 389 | 439 | $attrs = array(); |
| 390 | 440 | $this->add('title_color', trim($this->get('title_color'))); |
| 391 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
| 392 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 441 | + if($this->get('title_bold')=='Y') { |
|
| 442 | + $attrs[] = "font-weight:bold;"; |
|
| 443 | + } |
|
| 444 | + if($this->get('title_color') && $this->get('title_color') != 'N') { |
|
| 445 | + $attrs[] = "color:#".$this->get('title_color'); |
|
| 446 | + } |
|
| 393 | 447 | |
| 394 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 395 | - else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
| 448 | + if(count($attrs)) { |
|
| 449 | + return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 450 | + } else { |
|
| 451 | + return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
| 452 | + } |
|
| 396 | 453 | } |
| 397 | 454 | |
| 398 | 455 | function getContentText($strlen = 0) |
| 399 | 456 | { |
| 400 | - if(!$this->document_srl) return; |
|
| 457 | + if(!$this->document_srl) { |
|
| 458 | + return; |
|
| 459 | + } |
|
| 401 | 460 | |
| 402 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 461 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
| 462 | + return Context::getLang('msg_is_secret'); |
|
| 463 | + } |
|
| 403 | 464 | |
| 404 | 465 | $result = $this->_checkAccessibleFromStatus(); |
| 405 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 466 | + if($result) { |
|
| 467 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
| 468 | + } |
|
| 406 | 469 | |
| 407 | 470 | $content = $this->get('content'); |
| 408 | 471 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
| 409 | 472 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
| 410 | 473 | |
| 411 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
| 474 | + if($strlen) { |
|
| 475 | + return cut_str(strip_tags($content),$strlen,'...'); |
|
| 476 | + } |
|
| 412 | 477 | |
| 413 | 478 | return htmlspecialchars($content); |
| 414 | 479 | } |
@@ -441,14 +506,12 @@ discard block |
||
| 441 | 506 | } |
| 442 | 507 | $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
| 443 | 508 | } |
| 444 | - } |
|
| 445 | - else if($m[1] == 'embed') |
|
| 509 | + } else if($m[1] == 'embed') |
|
| 446 | 510 | { |
| 447 | 511 | if(stripos($m[0], 'allowscriptaccess')) |
| 448 | 512 | { |
| 449 | 513 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
| 450 | - } |
|
| 451 | - else |
|
| 514 | + } else |
|
| 452 | 515 | { |
| 453 | 516 | $m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]); |
| 454 | 517 | } |
@@ -458,15 +521,23 @@ discard block |
||
| 458 | 521 | |
| 459 | 522 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
| 460 | 523 | { |
| 461 | - if(!$this->document_srl) return; |
|
| 524 | + if(!$this->document_srl) { |
|
| 525 | + return; |
|
| 526 | + } |
|
| 462 | 527 | |
| 463 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 528 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
| 529 | + return Context::getLang('msg_is_secret'); |
|
| 530 | + } |
|
| 464 | 531 | |
| 465 | 532 | $result = $this->_checkAccessibleFromStatus(); |
| 466 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 533 | + if($result) { |
|
| 534 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
| 535 | + } |
|
| 467 | 536 | |
| 468 | 537 | $content = $this->get('content'); |
| 469 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 538 | + if(!$stripEmbedTagException) { |
|
| 539 | + stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 540 | + } |
|
| 470 | 541 | |
| 471 | 542 | // Define a link if using a rewrite module |
| 472 | 543 | $oContext = &Context::getInstance(); |
@@ -500,10 +571,11 @@ discard block |
||
| 500 | 571 | $this->document_srl, $memberSrl |
| 501 | 572 | ); |
| 502 | 573 | // Add xe_content class although accessing content is not required |
| 503 | - } |
|
| 504 | - else |
|
| 574 | + } else |
|
| 505 | 575 | { |
| 506 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 576 | + if($add_xe_content_class) { |
|
| 577 | + $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 578 | + } |
|
| 507 | 579 | } |
| 508 | 580 | // Change the image path to a valid absolute path if resource_realpath is true |
| 509 | 581 | if($resource_realpath) |
@@ -622,11 +694,15 @@ discard block |
||
| 622 | 694 | |
| 623 | 695 | function getTrackbackUrl() |
| 624 | 696 | { |
| 625 | - if(!$this->document_srl) return; |
|
| 697 | + if(!$this->document_srl) { |
|
| 698 | + return; |
|
| 699 | + } |
|
| 626 | 700 | |
| 627 | 701 | // Generate a key to prevent spams |
| 628 | 702 | $oTrackbackModel = getModel('trackback'); |
| 629 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 703 | + if($oTrackbackModel) { |
|
| 704 | + return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 705 | + } |
|
| 630 | 706 | } |
| 631 | 707 | |
| 632 | 708 | /** |
@@ -645,7 +721,9 @@ discard block |
||
| 645 | 721 | |
| 646 | 722 | function isExtraVarsExists() |
| 647 | 723 | { |
| 648 | - if(!$this->get('module_srl')) return false; |
|
| 724 | + if(!$this->get('module_srl')) { |
|
| 725 | + return false; |
|
| 726 | + } |
|
| 649 | 727 | $oDocumentModel = getModel('document'); |
| 650 | 728 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
| 651 | 729 | return count($extra_keys)?true:false; |
@@ -653,7 +731,9 @@ discard block |
||
| 653 | 731 | |
| 654 | 732 | function getExtraVars() |
| 655 | 733 | { |
| 656 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 734 | + if(!$this->get('module_srl') || !$this->document_srl) { |
|
| 735 | + return null; |
|
| 736 | + } |
|
| 657 | 737 | |
| 658 | 738 | $oDocumentModel = getModel('document'); |
| 659 | 739 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -665,8 +745,7 @@ discard block |
||
| 665 | 745 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
| 666 | 746 | { |
| 667 | 747 | return $extra_vars[$idx]->getValue(); |
| 668 | - } |
|
| 669 | - else |
|
| 748 | + } else |
|
| 670 | 749 | { |
| 671 | 750 | return ''; |
| 672 | 751 | } |
@@ -678,8 +757,7 @@ discard block |
||
| 678 | 757 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
| 679 | 758 | { |
| 680 | 759 | return $extra_vars[$idx]->getValueHTML(); |
| 681 | - } |
|
| 682 | - else |
|
| 760 | + } else |
|
| 683 | 761 | { |
| 684 | 762 | return ''; |
| 685 | 763 | } |
@@ -701,8 +779,7 @@ discard block |
||
| 701 | 779 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
| 702 | 780 | { |
| 703 | 781 | return $extra_eid[$eid]->getValue(); |
| 704 | - } |
|
| 705 | - else |
|
| 782 | + } else |
|
| 706 | 783 | { |
| 707 | 784 | return ''; |
| 708 | 785 | } |
@@ -720,8 +797,7 @@ discard block |
||
| 720 | 797 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
| 721 | 798 | { |
| 722 | 799 | return $extra_eid[$eid]->getValueHTML(); |
| 723 | - } |
|
| 724 | - else |
|
| 800 | + } else |
|
| 725 | 801 | { |
| 726 | 802 | return ''; |
| 727 | 803 | } |
@@ -741,8 +817,12 @@ discard block |
||
| 741 | 817 | |
| 742 | 818 | function getComments() |
| 743 | 819 | { |
| 744 | - if(!$this->getCommentCount()) return; |
|
| 745 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
| 820 | + if(!$this->getCommentCount()) { |
|
| 821 | + return; |
|
| 822 | + } |
|
| 823 | + if(!$this->isGranted() && $this->isSecret()) { |
|
| 824 | + return; |
|
| 825 | + } |
|
| 746 | 826 | // cpage is a number of comment pages |
| 747 | 827 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
| 748 | 828 | $cpage = Context::get($cpageStr); |
@@ -755,7 +835,9 @@ discard block |
||
| 755 | 835 | // Get a list of comments |
| 756 | 836 | $oCommentModel = getModel('comment'); |
| 757 | 837 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
| 758 | - if(!$output->toBool() || !count($output->data)) return; |
|
| 838 | + if(!$output->toBool() || !count($output->data)) { |
|
| 839 | + return; |
|
| 840 | + } |
|
| 759 | 841 | // Create commentItem object from a comment list |
| 760 | 842 | // If admin priviledge is granted on parent posts, you can read its child posts. |
| 761 | 843 | $accessible = array(); |
@@ -765,7 +847,9 @@ discard block |
||
| 765 | 847 | $oCommentItem = new commentItem(); |
| 766 | 848 | $oCommentItem->setAttribute($val); |
| 767 | 849 | // If permission is granted to the post, you can access it temporarily |
| 768 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 850 | + if($oCommentItem->isGranted()) { |
|
| 851 | + $accessible[$val->comment_srl] = true; |
|
| 852 | + } |
|
| 769 | 853 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
| 770 | 854 | if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
| 771 | 855 | { |
@@ -776,7 +860,9 @@ discard block |
||
| 776 | 860 | // Variable setting to be displayed on the skin |
| 777 | 861 | Context::set($cpageStr, $output->page_navigation->cur_page); |
| 778 | 862 | Context::set('cpage', $output->page_navigation->cur_page); |
| 779 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
| 863 | + if($output->total_page>1) { |
|
| 864 | + $this->comment_page_navigation = $output->page_navigation; |
|
| 865 | + } |
|
| 780 | 866 | |
| 781 | 867 | return $comment_list; |
| 782 | 868 | } |
@@ -788,9 +874,13 @@ discard block |
||
| 788 | 874 | |
| 789 | 875 | function getTrackbacks() |
| 790 | 876 | { |
| 791 | - if(!$this->document_srl) return; |
|
| 877 | + if(!$this->document_srl) { |
|
| 878 | + return; |
|
| 879 | + } |
|
| 792 | 880 | |
| 793 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 881 | + if(!$this->allowTrackback() || !$this->get('trackback_count')) { |
|
| 882 | + return; |
|
| 883 | + } |
|
| 794 | 884 | |
| 795 | 885 | $oTrackbackModel = getModel('trackback'); |
| 796 | 886 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -798,15 +888,21 @@ discard block |
||
| 798 | 888 | |
| 799 | 889 | function thumbnailExists($width = 80, $height = 0, $type = '') |
| 800 | 890 | { |
| 801 | - if(!$this->document_srl) return false; |
|
| 802 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
| 891 | + if(!$this->document_srl) { |
|
| 892 | + return false; |
|
| 893 | + } |
|
| 894 | + if(!$this->getThumbnail($width, $height, $type)) { |
|
| 895 | + return false; |
|
| 896 | + } |
|
| 803 | 897 | return true; |
| 804 | 898 | } |
| 805 | 899 | |
| 806 | 900 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
| 807 | 901 | { |
| 808 | 902 | // Return false if the document doesn't exist |
| 809 | - if(!$this->document_srl) return; |
|
| 903 | + if(!$this->document_srl) { |
|
| 904 | + return; |
|
| 905 | + } |
|
| 810 | 906 | |
| 811 | 907 | if($this->isSecret() && !$this->isGranted()) |
| 812 | 908 | { |
@@ -814,7 +910,9 @@ discard block |
||
| 814 | 910 | } |
| 815 | 911 | |
| 816 | 912 | // If not specify its height, create a square |
| 817 | - if(!$height) $height = $width; |
|
| 913 | + if(!$height) { |
|
| 914 | + $height = $width; |
|
| 915 | + } |
|
| 818 | 916 | |
| 819 | 917 | // Return false if neither attachement nor image files in the document |
| 820 | 918 | $content = $this->get('content'); |
@@ -832,7 +930,9 @@ discard block |
||
| 832 | 930 | } |
| 833 | 931 | } |
| 834 | 932 | |
| 835 | - if(!preg_match("!<img!is", $content)) return; |
|
| 933 | + if(!preg_match("!<img!is", $content)) { |
|
| 934 | + return; |
|
| 935 | + } |
|
| 836 | 936 | } |
| 837 | 937 | // Get thumbnai_type information from document module's configuration |
| 838 | 938 | if(!in_array($thumbnail_type, array('crop','ratio'))) |
@@ -859,8 +959,7 @@ discard block |
||
| 859 | 959 | if(filesize($thumbnail_file) < 1) |
| 860 | 960 | { |
| 861 | 961 | return FALSE; |
| 862 | - } |
|
| 863 | - else |
|
| 962 | + } else |
|
| 864 | 963 | { |
| 865 | 964 | return $thumbnail_url; |
| 866 | 965 | } |
@@ -881,7 +980,9 @@ discard block |
||
| 881 | 980 | $first_image = null; |
| 882 | 981 | foreach($file_list as $file) |
| 883 | 982 | { |
| 884 | - if($file->direct_download !== 'Y') continue; |
|
| 983 | + if($file->direct_download !== 'Y') { |
|
| 984 | + continue; |
|
| 985 | + } |
|
| 885 | 986 | |
| 886 | 987 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
| 887 | 988 | { |
@@ -889,7 +990,9 @@ discard block |
||
| 889 | 990 | break; |
| 890 | 991 | } |
| 891 | 992 | |
| 892 | - if($first_image) continue; |
|
| 993 | + if($first_image) { |
|
| 994 | + continue; |
|
| 995 | + } |
|
| 893 | 996 | |
| 894 | 997 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
| 895 | 998 | { |
@@ -916,7 +1019,9 @@ discard block |
||
| 916 | 1019 | foreach($matches as $target_image) |
| 917 | 1020 | { |
| 918 | 1021 | $target_src = trim($target_image[1]); |
| 919 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 1022 | + if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) { |
|
| 1023 | + continue; |
|
| 1024 | + } |
|
| 920 | 1025 | |
| 921 | 1026 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
| 922 | 1027 | { |
@@ -927,7 +1032,9 @@ discard block |
||
| 927 | 1032 | |
| 928 | 1033 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
| 929 | 1034 | FileHandler::getRemoteFile($target_src, $tmp_file); |
| 930 | - if(!file_exists($tmp_file)) continue; |
|
| 1035 | + if(!file_exists($tmp_file)) { |
|
| 1036 | + continue; |
|
| 1037 | + } |
|
| 931 | 1038 | |
| 932 | 1039 | $imageinfo = getimagesize($tmp_file); |
| 933 | 1040 | list($_w, $_h) = $imageinfo; |
@@ -978,21 +1085,28 @@ discard block |
||
| 978 | 1085 | */ |
| 979 | 1086 | function getExtraImages($time_interval = 43200) |
| 980 | 1087 | { |
| 981 | - if(!$this->document_srl) return; |
|
| 1088 | + if(!$this->document_srl) { |
|
| 1089 | + return; |
|
| 1090 | + } |
|
| 982 | 1091 | // variables for icon list |
| 983 | 1092 | $buffs = array(); |
| 984 | 1093 | |
| 985 | 1094 | $check_files = false; |
| 986 | 1095 | |
| 987 | 1096 | // Check if secret post is |
| 988 | - if($this->isSecret()) $buffs[] = "secret"; |
|
| 1097 | + if($this->isSecret()) { |
|
| 1098 | + $buffs[] = "secret"; |
|
| 1099 | + } |
|
| 989 | 1100 | |
| 990 | 1101 | // Set the latest time |
| 991 | 1102 | $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
| 992 | 1103 | |
| 993 | 1104 | // Check new post |
| 994 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
| 995 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
| 1105 | + if($this->get('regdate')>$time_check) { |
|
| 1106 | + $buffs[] = "new"; |
|
| 1107 | + } else if($this->get('last_update')>$time_check) { |
|
| 1108 | + $buffs[] = "update"; |
|
| 1109 | + } |
|
| 996 | 1110 | |
| 997 | 1111 | /* |
| 998 | 1112 | $content = $this->get('content'); |
@@ -1015,14 +1129,18 @@ discard block |
||
| 1015 | 1129 | */ |
| 1016 | 1130 | |
| 1017 | 1131 | // Check the attachment |
| 1018 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1132 | + if($this->hasUploadedFiles()) { |
|
| 1133 | + $buffs[] = "file"; |
|
| 1134 | + } |
|
| 1019 | 1135 | |
| 1020 | 1136 | return $buffs; |
| 1021 | 1137 | } |
| 1022 | 1138 | |
| 1023 | 1139 | function getStatus() |
| 1024 | 1140 | { |
| 1025 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
| 1141 | + if(!$this->get('status')) { |
|
| 1142 | + return $this->getDefaultStatus(); |
|
| 1143 | + } |
|
| 1026 | 1144 | return $this->get('status'); |
| 1027 | 1145 | } |
| 1028 | 1146 | |
@@ -1033,12 +1151,16 @@ discard block |
||
| 1033 | 1151 | */ |
| 1034 | 1152 | function printExtraImages($time_check = 43200) |
| 1035 | 1153 | { |
| 1036 | - if(!$this->document_srl) return; |
|
| 1154 | + if(!$this->document_srl) { |
|
| 1155 | + return; |
|
| 1156 | + } |
|
| 1037 | 1157 | // Get the icon directory |
| 1038 | 1158 | $path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/'); |
| 1039 | 1159 | |
| 1040 | 1160 | $buffs = $this->getExtraImages($time_check); |
| 1041 | - if(!count($buffs)) return; |
|
| 1161 | + if(!count($buffs)) { |
|
| 1162 | + return; |
|
| 1163 | + } |
|
| 1042 | 1164 | |
| 1043 | 1165 | $buff = array(); |
| 1044 | 1166 | foreach($buffs as $key => $val) |
@@ -1050,18 +1172,28 @@ discard block |
||
| 1050 | 1172 | |
| 1051 | 1173 | function hasUploadedFiles() |
| 1052 | 1174 | { |
| 1053 | - if(!$this->document_srl) return; |
|
| 1175 | + if(!$this->document_srl) { |
|
| 1176 | + return; |
|
| 1177 | + } |
|
| 1054 | 1178 | |
| 1055 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
| 1179 | + if($this->isSecret() && !$this->isGranted()) { |
|
| 1180 | + return false; |
|
| 1181 | + } |
|
| 1056 | 1182 | return $this->get('uploaded_count')? true : false; |
| 1057 | 1183 | } |
| 1058 | 1184 | |
| 1059 | 1185 | function getUploadedFiles($sortIndex = 'file_srl') |
| 1060 | 1186 | { |
| 1061 | - if(!$this->document_srl) return; |
|
| 1187 | + if(!$this->document_srl) { |
|
| 1188 | + return; |
|
| 1189 | + } |
|
| 1062 | 1190 | |
| 1063 | - if($this->isSecret() && !$this->isGranted()) return; |
|
| 1064 | - if(!$this->get('uploaded_count')) return; |
|
| 1191 | + if($this->isSecret() && !$this->isGranted()) { |
|
| 1192 | + return; |
|
| 1193 | + } |
|
| 1194 | + if(!$this->get('uploaded_count')) { |
|
| 1195 | + return; |
|
| 1196 | + } |
|
| 1065 | 1197 | |
| 1066 | 1198 | if(!$this->uploadedFiles[$sortIndex]) |
| 1067 | 1199 | { |
@@ -1079,7 +1211,9 @@ discard block |
||
| 1079 | 1211 | function getEditor() |
| 1080 | 1212 | { |
| 1081 | 1213 | $module_srl = $this->get('module_srl'); |
| 1082 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1214 | + if(!$module_srl) { |
|
| 1215 | + $module_srl = Context::get('module_srl'); |
|
| 1216 | + } |
|
| 1083 | 1217 | |
| 1084 | 1218 | $oEditorModel = getModel('editor'); |
| 1085 | 1219 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1093,8 +1227,12 @@ discard block |
||
| 1093 | 1227 | function isEnableComment() |
| 1094 | 1228 | { |
| 1095 | 1229 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
| 1096 | - if (!$this->allowComment()) return false; |
|
| 1097 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
| 1230 | + if (!$this->allowComment()) { |
|
| 1231 | + return false; |
|
| 1232 | + } |
|
| 1233 | + if(!$this->isGranted() && $this->isSecret()) { |
|
| 1234 | + return false; |
|
| 1235 | + } |
|
| 1098 | 1236 | |
| 1099 | 1237 | return true; |
| 1100 | 1238 | } |
@@ -1105,7 +1243,9 @@ discard block |
||
| 1105 | 1243 | */ |
| 1106 | 1244 | function getCommentEditor() |
| 1107 | 1245 | { |
| 1108 | - if(!$this->isEnableComment()) return; |
|
| 1246 | + if(!$this->isEnableComment()) { |
|
| 1247 | + return; |
|
| 1248 | + } |
|
| 1109 | 1249 | |
| 1110 | 1250 | $oEditorModel = getModel('editor'); |
| 1111 | 1251 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1117,10 +1257,14 @@ discard block |
||
| 1117 | 1257 | */ |
| 1118 | 1258 | function getProfileImage() |
| 1119 | 1259 | { |
| 1120 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1260 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
| 1261 | + return; |
|
| 1262 | + } |
|
| 1121 | 1263 | $oMemberModel = getModel('member'); |
| 1122 | 1264 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
| 1123 | - if(!$profile_info) return; |
|
| 1265 | + if(!$profile_info) { |
|
| 1266 | + return; |
|
| 1267 | + } |
|
| 1124 | 1268 | |
| 1125 | 1269 | return $profile_info->src; |
| 1126 | 1270 | } |
@@ -1132,7 +1276,9 @@ discard block |
||
| 1132 | 1276 | function getSignature() |
| 1133 | 1277 | { |
| 1134 | 1278 | // Pass if a document doesn't exist |
| 1135 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1279 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
| 1280 | + return; |
|
| 1281 | + } |
|
| 1136 | 1282 | // Get signature information |
| 1137 | 1283 | $oMemberModel = getModel('member'); |
| 1138 | 1284 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
@@ -1146,7 +1292,9 @@ discard block |
||
| 1146 | 1292 | if($signature) |
| 1147 | 1293 | { |
| 1148 | 1294 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
| 1149 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1295 | + if($max_signature_height) { |
|
| 1296 | + $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1297 | + } |
|
| 1150 | 1298 | } |
| 1151 | 1299 | |
| 1152 | 1300 | return $signature; |
@@ -1170,20 +1318,25 @@ discard block |
||
| 1170 | 1318 | function _checkAccessibleFromStatus() |
| 1171 | 1319 | { |
| 1172 | 1320 | $logged_info = Context::get('logged_info'); |
| 1173 | - if($logged_info->is_admin == 'Y') return true; |
|
| 1321 | + if($logged_info->is_admin == 'Y') { |
|
| 1322 | + return true; |
|
| 1323 | + } |
|
| 1174 | 1324 | |
| 1175 | 1325 | $status = $this->get('status'); |
| 1176 | - if(empty($status)) return false; |
|
| 1326 | + if(empty($status)) { |
|
| 1327 | + return false; |
|
| 1328 | + } |
|
| 1177 | 1329 | |
| 1178 | 1330 | $oDocumentModel = getModel('document'); |
| 1179 | 1331 | $configStatusList = $oDocumentModel->getStatusList(); |
| 1180 | 1332 | |
| 1181 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1182 | - return true; |
|
| 1183 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1333 | + if($status == $configStatusList['public'] || $status == $configStatusList['publish']) { |
|
| 1334 | + return true; |
|
| 1335 | + } else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1184 | 1336 | { |
| 1185 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
| 1186 | - return true; |
|
| 1337 | + if($this->get('member_srl') == $logged_info->member_srl) { |
|
| 1338 | + return true; |
|
| 1339 | + } |
|
| 1187 | 1340 | } |
| 1188 | 1341 | return false; |
| 1189 | 1342 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | function _loadFromDB($load_extra_vars = true) |
| 81 | 81 | { |
| 82 | - if(!$this->document_srl) return; |
|
| 82 | + if (!$this->document_srl) return; |
|
| 83 | 83 | |
| 84 | 84 | $document_item = false; |
| 85 | 85 | $cache_put = false; |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | // cache controll |
| 90 | 90 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 91 | - if($oCacheHandler->isSupport()) |
|
| 91 | + if ($oCacheHandler->isSupport()) |
|
| 92 | 92 | { |
| 93 | - $cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl; |
|
| 93 | + $cache_key = 'document_item:'.getNumberingPath($this->document_srl).$this->document_srl; |
|
| 94 | 94 | $document_item = $oCacheHandler->get($cache_key); |
| 95 | - if($document_item !== false) |
|
| 95 | + if ($document_item !== false) |
|
| 96 | 96 | { |
| 97 | 97 | $columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count'); |
| 98 | 98 | } |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | $args->document_srl = $this->document_srl; |
| 103 | 103 | $output = executeQuery('document.getDocument', $args, $columnList); |
| 104 | 104 | |
| 105 | - if($document_item === false) |
|
| 105 | + if ($document_item === false) |
|
| 106 | 106 | { |
| 107 | 107 | $document_item = $output->data; |
| 108 | 108 | |
| 109 | 109 | //insert in cache |
| 110 | - if($document_item && $oCacheHandler->isSupport()) |
|
| 110 | + if ($document_item && $oCacheHandler->isSupport()) |
|
| 111 | 111 | { |
| 112 | 112 | $oCacheHandler->put($cache_key, $document_item); |
| 113 | 113 | } |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | $this->setAttribute($document_item, $load_extra_vars); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - function setAttribute($attribute, $load_extra_vars=true) |
|
| 127 | + function setAttribute($attribute, $load_extra_vars = true) |
|
| 128 | 128 | { |
| 129 | - if(!$attribute->document_srl) |
|
| 129 | + if (!$attribute->document_srl) |
|
| 130 | 130 | { |
| 131 | 131 | $this->document_srl = null; |
| 132 | 132 | return; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $this->adds($attribute); |
| 137 | 137 | |
| 138 | 138 | // Tags |
| 139 | - if($this->get('tags')) |
|
| 139 | + if ($this->get('tags')) |
|
| 140 | 140 | { |
| 141 | 141 | $tag_list = explode(',', $this->get('tags')); |
| 142 | 142 | $tag_list = array_map('trim', $tag_list); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $oDocumentModel = getModel('document'); |
| 147 | - if($load_extra_vars) |
|
| 147 | + if ($load_extra_vars) |
|
| 148 | 148 | { |
| 149 | 149 | $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this; |
| 150 | 150 | $oDocumentModel->setToAllDocumentExtraVars(); |
@@ -159,23 +159,23 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | function isGranted() |
| 161 | 161 | { |
| 162 | - if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
| 162 | + if ($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true; |
|
| 163 | 163 | |
| 164 | - if($this->grant_cache !== null) |
|
| 164 | + if ($this->grant_cache !== null) |
|
| 165 | 165 | { |
| 166 | 166 | return $this->grant_cache; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if(!Context::get('is_logged')) return $this->grant_cache = false; |
|
| 169 | + if (!Context::get('is_logged')) return $this->grant_cache = false; |
|
| 170 | 170 | |
| 171 | 171 | $logged_info = Context::get('logged_info'); |
| 172 | - if($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
| 172 | + if ($logged_info->is_admin == 'Y') return $this->grant_cache = true; |
|
| 173 | 173 | |
| 174 | 174 | $oModuleModel = getModel('module'); |
| 175 | 175 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
| 176 | - if($grant->manager) return $this->grant_cache = true; |
|
| 176 | + if ($grant->manager) return $this->grant_cache = true; |
|
| 177 | 177 | |
| 178 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
| 178 | + if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) return $this->grant_cache = true; |
|
| 179 | 179 | |
| 180 | 180 | return $this->grant_cache = false; |
| 181 | 181 | } |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | function isAccessible() |
| 190 | 190 | { |
| 191 | - return $_SESSION['accessible'][$this->document_srl]==true?true:false; |
|
| 191 | + return $_SESSION['accessible'][$this->document_srl] == true ?true:false; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | function allowComment() |
| 195 | 195 | { |
| 196 | 196 | // init write, document is not exists. so allow comment status is true |
| 197 | - if(!$this->isExists()) return true; |
|
| 197 | + if (!$this->isExists()) return true; |
|
| 198 | 198 | |
| 199 | 199 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
| 200 | 200 | } |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | function allowTrackback() |
| 203 | 203 | { |
| 204 | 204 | static $allow_trackback_status = null; |
| 205 | - if(is_null($allow_trackback_status)) |
|
| 205 | + if (is_null($allow_trackback_status)) |
|
| 206 | 206 | { |
| 207 | 207 | |
| 208 | 208 | // Check the tarckback module exist |
| 209 | - if(!getClass('trackback')) |
|
| 209 | + if (!getClass('trackback')) |
|
| 210 | 210 | { |
| 211 | 211 | $allow_trackback_status = false; |
| 212 | 212 | } |
@@ -216,20 +216,20 @@ discard block |
||
| 216 | 216 | $oModuleModel = getModel('module'); |
| 217 | 217 | $trackback_config = $oModuleModel->getModuleConfig('trackback'); |
| 218 | 218 | |
| 219 | - if(!$trackback_config) |
|
| 219 | + if (!$trackback_config) |
|
| 220 | 220 | { |
| 221 | 221 | $trackback_config = new stdClass(); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 225 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 224 | + if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 225 | + if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 226 | 226 | else |
| 227 | 227 | { |
| 228 | 228 | $module_srl = $this->get('module_srl'); |
| 229 | 229 | // Check settings of each module |
| 230 | 230 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
| 231 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 232 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 231 | + if ($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 232 | + else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | } |
@@ -238,14 +238,14 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | function isLocked() |
| 240 | 240 | { |
| 241 | - if(!$this->isExists()) return false; |
|
| 241 | + if (!$this->isExists()) return false; |
|
| 242 | 242 | |
| 243 | 243 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | function isEditable() |
| 247 | 247 | { |
| 248 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 248 | + if ($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 249 | 249 | return false; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -262,13 +262,13 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | function useNotify() |
| 264 | 264 | { |
| 265 | - return $this->get('notify_message')=='Y' ? true : false; |
|
| 265 | + return $this->get('notify_message') == 'Y' ? true : false; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | function doCart() |
| 269 | 269 | { |
| 270 | - if(!$this->document_srl) return false; |
|
| 271 | - if($this->isCarted()) $this->removeCart(); |
|
| 270 | + if (!$this->document_srl) return false; |
|
| 271 | + if ($this->isCarted()) $this->removeCart(); |
|
| 272 | 272 | else $this->addCart(); |
| 273 | 273 | } |
| 274 | 274 | |
@@ -295,18 +295,18 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | function notify($type, $content) |
| 297 | 297 | { |
| 298 | - if(!$this->document_srl) return; |
|
| 298 | + if (!$this->document_srl) return; |
|
| 299 | 299 | // return if it is not useNotify |
| 300 | - if(!$this->useNotify()) return; |
|
| 300 | + if (!$this->useNotify()) return; |
|
| 301 | 301 | // Pass if an author is not a logged-in user |
| 302 | - if(!$this->get('member_srl')) return; |
|
| 302 | + if (!$this->get('member_srl')) return; |
|
| 303 | 303 | // Return if the currently logged-in user is an author |
| 304 | 304 | $logged_info = Context::get('logged_info'); |
| 305 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 305 | + if ($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 306 | 306 | // List variables |
| 307 | - if($type) $title = "[".$type."] "; |
|
| 307 | + if ($type) $title = "[".$type."] "; |
|
| 308 | 308 | $title .= cut_str(strip_tags($content), 10, '...'); |
| 309 | - $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
|
| 309 | + $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl)); |
|
| 310 | 310 | $receiver_srl = $this->get('member_srl'); |
| 311 | 311 | $sender_member_srl = $logged_info->member_srl; |
| 312 | 312 | // Send a message |
@@ -321,26 +321,26 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | function getIpAddress() |
| 323 | 323 | { |
| 324 | - if($this->isGranted()) |
|
| 324 | + if ($this->isGranted()) |
|
| 325 | 325 | { |
| 326 | 326 | return $this->get('ipaddress'); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - return '*' . strstr($this->get('ipaddress'), '.'); |
|
| 329 | + return '*'.strstr($this->get('ipaddress'), '.'); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | function isExistsHomepage() |
| 333 | 333 | { |
| 334 | - if(trim($this->get('homepage'))) return true; |
|
| 334 | + if (trim($this->get('homepage'))) return true; |
|
| 335 | 335 | return false; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | function getHomepageUrl() |
| 339 | 339 | { |
| 340 | 340 | $url = trim($this->get('homepage')); |
| 341 | - if(!$url) return; |
|
| 341 | + if (!$url) return; |
|
| 342 | 342 | |
| 343 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
| 343 | + if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://'.$url; |
|
| 344 | 344 | |
| 345 | 345 | return $url; |
| 346 | 346 | } |
@@ -370,52 +370,52 @@ discard block |
||
| 370 | 370 | return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - function getTitleText($cut_size = 0, $tail='...') |
|
| 373 | + function getTitleText($cut_size = 0, $tail = '...') |
|
| 374 | 374 | { |
| 375 | - if(!$this->document_srl) return; |
|
| 375 | + if (!$this->document_srl) return; |
|
| 376 | 376 | |
| 377 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 377 | + if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 378 | 378 | else $title = $this->get('title'); |
| 379 | 379 | |
| 380 | 380 | return $title; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - function getTitle($cut_size = 0, $tail='...') |
|
| 383 | + function getTitle($cut_size = 0, $tail = '...') |
|
| 384 | 384 | { |
| 385 | - if(!$this->document_srl) return; |
|
| 385 | + if (!$this->document_srl) return; |
|
| 386 | 386 | |
| 387 | 387 | $title = $this->getTitleText($cut_size, $tail); |
| 388 | 388 | |
| 389 | 389 | $attrs = array(); |
| 390 | 390 | $this->add('title_color', trim($this->get('title_color'))); |
| 391 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
| 392 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 391 | + if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;"; |
|
| 392 | + if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 393 | 393 | |
| 394 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 394 | + if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 395 | 395 | else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function getContentText($strlen = 0) |
| 399 | 399 | { |
| 400 | - if(!$this->document_srl) return; |
|
| 400 | + if (!$this->document_srl) return; |
|
| 401 | 401 | |
| 402 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 402 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 403 | 403 | |
| 404 | 404 | $result = $this->_checkAccessibleFromStatus(); |
| 405 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 405 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 406 | 406 | |
| 407 | 407 | $content = $this->get('content'); |
| 408 | 408 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
| 409 | 409 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
| 410 | 410 | |
| 411 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
| 411 | + if ($strlen) return cut_str(strip_tags($content), $strlen, '...'); |
|
| 412 | 412 | |
| 413 | 413 | return htmlspecialchars($content); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | function _addAllowScriptAccess($m) |
| 417 | 417 | { |
| 418 | - if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
| 418 | + if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
| 419 | 419 | { |
| 420 | 420 | $m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>'; |
| 421 | 421 | } |
@@ -425,26 +425,26 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | function _checkAllowScriptAccess($m) |
| 427 | 427 | { |
| 428 | - if($m[1] == 'object') |
|
| 428 | + if ($m[1] == 'object') |
|
| 429 | 429 | { |
| 430 | 430 | $this->allowscriptaccessList[] = 1; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if($m[1] == 'param') |
|
| 433 | + if ($m[1] == 'param') |
|
| 434 | 434 | { |
| 435 | - if(stripos($m[0], 'allowscriptaccess')) |
|
| 435 | + if (stripos($m[0], 'allowscriptaccess')) |
|
| 436 | 436 | { |
| 437 | 437 | $m[0] = '<param name="allowscriptaccess" value="never"'; |
| 438 | - if(substr($m[0], -1) == '/') |
|
| 438 | + if (substr($m[0], -1) == '/') |
|
| 439 | 439 | { |
| 440 | 440 | $m[0] .= '/'; |
| 441 | 441 | } |
| 442 | - $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
|
| 442 | + $this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--; |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | - else if($m[1] == 'embed') |
|
| 445 | + else if ($m[1] == 'embed') |
|
| 446 | 446 | { |
| 447 | - if(stripos($m[0], 'allowscriptaccess')) |
|
| 447 | + if (stripos($m[0], 'allowscriptaccess')) |
|
| 448 | 448 | { |
| 449 | 449 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
| 450 | 450 | } |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | |
| 459 | 459 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
| 460 | 460 | { |
| 461 | - if(!$this->document_srl) return; |
|
| 461 | + if (!$this->document_srl) return; |
|
| 462 | 462 | |
| 463 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 463 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 464 | 464 | |
| 465 | 465 | $result = $this->_checkAccessibleFromStatus(); |
| 466 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 466 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 467 | 467 | |
| 468 | 468 | $content = $this->get('content'); |
| 469 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 469 | + if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 470 | 470 | |
| 471 | 471 | // Define a link if using a rewrite module |
| 472 | 472 | $oContext = &Context::getInstance(); |
| 473 | - if($oContext->allow_rewrite) |
|
| 473 | + if ($oContext->allow_rewrite) |
|
| 474 | 474 | { |
| 475 | - $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content); |
|
| 475 | + $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2".Context::getRequestUri()."?", $content); |
|
| 476 | 476 | } |
| 477 | 477 | // To display a pop-up menu |
| 478 | - if($add_popup_menu) |
|
| 478 | + if ($add_popup_menu) |
|
| 479 | 479 | { |
| 480 | 480 | $content = sprintf( |
| 481 | 481 | '%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>', |
@@ -484,10 +484,10 @@ discard block |
||
| 484 | 484 | ); |
| 485 | 485 | } |
| 486 | 486 | // If additional content information is set |
| 487 | - if($add_content_info) |
|
| 487 | + if ($add_content_info) |
|
| 488 | 488 | { |
| 489 | 489 | $memberSrl = $this->get('member_srl'); |
| 490 | - if($memberSrl < 0) |
|
| 490 | + if ($memberSrl < 0) |
|
| 491 | 491 | { |
| 492 | 492 | $memberSrl = 0; |
| 493 | 493 | } |
@@ -503,12 +503,12 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | else |
| 505 | 505 | { |
| 506 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 506 | + if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 507 | 507 | } |
| 508 | 508 | // Change the image path to a valid absolute path if resource_realpath is true |
| 509 | - if($resource_realpath) |
|
| 509 | + if ($resource_realpath) |
|
| 510 | 510 | { |
| 511 | - $content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content); |
|
| 511 | + $content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | return $content; |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $content = trim(cut_str($content, $str_size, $tail)); |
| 558 | 558 | |
| 559 | 559 | // Replace back < , <, " |
| 560 | - $content = str_replace(array('<', '>', '"'),array('<', '>', '"'), $content); |
|
| 560 | + $content = str_replace(array('<', '>', '"'), array('<', '>', '"'), $content); |
|
| 561 | 561 | |
| 562 | 562 | return $content; |
| 563 | 563 | } |
@@ -570,13 +570,13 @@ discard block |
||
| 570 | 570 | function getRegdateTime() |
| 571 | 571 | { |
| 572 | 572 | $regdate = $this->get('regdate'); |
| 573 | - $year = substr($regdate,0,4); |
|
| 574 | - $month = substr($regdate,4,2); |
|
| 575 | - $day = substr($regdate,6,2); |
|
| 576 | - $hour = substr($regdate,8,2); |
|
| 577 | - $min = substr($regdate,10,2); |
|
| 578 | - $sec = substr($regdate,12,2); |
|
| 579 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
| 573 | + $year = substr($regdate, 0, 4); |
|
| 574 | + $month = substr($regdate, 4, 2); |
|
| 575 | + $day = substr($regdate, 6, 2); |
|
| 576 | + $hour = substr($regdate, 8, 2); |
|
| 577 | + $min = substr($regdate, 10, 2); |
|
| 578 | + $sec = substr($regdate, 12, 2); |
|
| 579 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | function getRegdateGM() |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | |
| 587 | 587 | function getRegdateDT() |
| 588 | 588 | { |
| 589 | - return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
| 589 | + return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | function getUpdate($format = 'Y.m.d H:i:s') |
@@ -596,13 +596,13 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | function getUpdateTime() |
| 598 | 598 | { |
| 599 | - $year = substr($this->get('last_update'),0,4); |
|
| 600 | - $month = substr($this->get('last_update'),4,2); |
|
| 601 | - $day = substr($this->get('last_update'),6,2); |
|
| 602 | - $hour = substr($this->get('last_update'),8,2); |
|
| 603 | - $min = substr($this->get('last_update'),10,2); |
|
| 604 | - $sec = substr($this->get('last_update'),12,2); |
|
| 605 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
| 599 | + $year = substr($this->get('last_update'), 0, 4); |
|
| 600 | + $month = substr($this->get('last_update'), 4, 2); |
|
| 601 | + $day = substr($this->get('last_update'), 6, 2); |
|
| 602 | + $hour = substr($this->get('last_update'), 8, 2); |
|
| 603 | + $min = substr($this->get('last_update'), 10, 2); |
|
| 604 | + $sec = substr($this->get('last_update'), 12, 2); |
|
| 605 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | function getUpdateGM() |
@@ -612,21 +612,21 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | function getUpdateDT() |
| 614 | 614 | { |
| 615 | - return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
| 615 | + return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | function getPermanentUrl() |
| 619 | 619 | { |
| 620 | - return getFullUrl('','document_srl',$this->get('document_srl')); |
|
| 620 | + return getFullUrl('', 'document_srl', $this->get('document_srl')); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | function getTrackbackUrl() |
| 624 | 624 | { |
| 625 | - if(!$this->document_srl) return; |
|
| 625 | + if (!$this->document_srl) return; |
|
| 626 | 626 | |
| 627 | 627 | // Generate a key to prevent spams |
| 628 | 628 | $oTrackbackModel = getModel('trackback'); |
| 629 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 629 | + if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | /** |
@@ -636,24 +636,24 @@ discard block |
||
| 636 | 636 | function updateReadedCount() |
| 637 | 637 | { |
| 638 | 638 | $oDocumentController = getController('document'); |
| 639 | - if($oDocumentController->updateReadedCount($this)) |
|
| 639 | + if ($oDocumentController->updateReadedCount($this)) |
|
| 640 | 640 | { |
| 641 | 641 | $readed_count = $this->get('readed_count'); |
| 642 | - $this->add('readed_count', $readed_count+1); |
|
| 642 | + $this->add('readed_count', $readed_count + 1); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | function isExtraVarsExists() |
| 647 | 647 | { |
| 648 | - if(!$this->get('module_srl')) return false; |
|
| 648 | + if (!$this->get('module_srl')) return false; |
|
| 649 | 649 | $oDocumentModel = getModel('document'); |
| 650 | 650 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
| 651 | - return count($extra_keys)?true:false; |
|
| 651 | + return count($extra_keys) ?true:false; |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | function getExtraVars() |
| 655 | 655 | { |
| 656 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 656 | + if (!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 657 | 657 | |
| 658 | 658 | $oDocumentModel = getModel('document'); |
| 659 | 659 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | function getExtraValue($idx) |
| 663 | 663 | { |
| 664 | 664 | $extra_vars = $this->getExtraVars(); |
| 665 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
| 665 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
| 666 | 666 | { |
| 667 | 667 | return $extra_vars[$idx]->getValue(); |
| 668 | 668 | } |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | function getExtraValueHTML($idx) |
| 676 | 676 | { |
| 677 | 677 | $extra_vars = $this->getExtraVars(); |
| 678 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
| 678 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
| 679 | 679 | { |
| 680 | 680 | return $extra_vars[$idx]->getValueHTML(); |
| 681 | 681 | } |
@@ -689,16 +689,16 @@ discard block |
||
| 689 | 689 | { |
| 690 | 690 | $extra_vars = $this->getExtraVars(); |
| 691 | 691 | |
| 692 | - if($extra_vars) |
|
| 692 | + if ($extra_vars) |
|
| 693 | 693 | { |
| 694 | 694 | // Handle extra variable(eid) |
| 695 | - foreach($extra_vars as $idx => $key) |
|
| 695 | + foreach ($extra_vars as $idx => $key) |
|
| 696 | 696 | { |
| 697 | 697 | $extra_eid[$key->eid] = $key; |
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
| 701 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
| 702 | 702 | { |
| 703 | 703 | return $extra_eid[$eid]->getValue(); |
| 704 | 704 | } |
@@ -712,12 +712,12 @@ discard block |
||
| 712 | 712 | { |
| 713 | 713 | $extra_vars = $this->getExtraVars(); |
| 714 | 714 | // Handle extra variable(eid) |
| 715 | - foreach($extra_vars as $idx => $key) |
|
| 715 | + foreach ($extra_vars as $idx => $key) |
|
| 716 | 716 | { |
| 717 | 717 | $extra_eid[$key->eid] = $key; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
| 720 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
| 721 | 721 | { |
| 722 | 722 | return $extra_eid[$eid]->getValueHTML(); |
| 723 | 723 | } |
@@ -741,13 +741,13 @@ discard block |
||
| 741 | 741 | |
| 742 | 742 | function getComments() |
| 743 | 743 | { |
| 744 | - if(!$this->getCommentCount()) return; |
|
| 745 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
| 744 | + if (!$this->getCommentCount()) return; |
|
| 745 | + if (!$this->isGranted() && $this->isSecret()) return; |
|
| 746 | 746 | // cpage is a number of comment pages |
| 747 | 747 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
| 748 | 748 | $cpage = Context::get($cpageStr); |
| 749 | 749 | |
| 750 | - if(!$cpage) |
|
| 750 | + if (!$cpage) |
|
| 751 | 751 | { |
| 752 | 752 | $cpage = Context::get('cpage'); |
| 753 | 753 | } |
@@ -755,19 +755,19 @@ discard block |
||
| 755 | 755 | // Get a list of comments |
| 756 | 756 | $oCommentModel = getModel('comment'); |
| 757 | 757 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
| 758 | - if(!$output->toBool() || !count($output->data)) return; |
|
| 758 | + if (!$output->toBool() || !count($output->data)) return; |
|
| 759 | 759 | // Create commentItem object from a comment list |
| 760 | 760 | // If admin priviledge is granted on parent posts, you can read its child posts. |
| 761 | 761 | $accessible = array(); |
| 762 | 762 | $comment_list = array(); |
| 763 | - foreach($output->data as $key => $val) |
|
| 763 | + foreach ($output->data as $key => $val) |
|
| 764 | 764 | { |
| 765 | 765 | $oCommentItem = new commentItem(); |
| 766 | 766 | $oCommentItem->setAttribute($val); |
| 767 | 767 | // If permission is granted to the post, you can access it temporarily |
| 768 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 768 | + if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 769 | 769 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
| 770 | - if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
|
| 770 | + if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) |
|
| 771 | 771 | { |
| 772 | 772 | $oCommentItem->setAccessible(); |
| 773 | 773 | } |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | // Variable setting to be displayed on the skin |
| 777 | 777 | Context::set($cpageStr, $output->page_navigation->cur_page); |
| 778 | 778 | Context::set('cpage', $output->page_navigation->cur_page); |
| 779 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
| 779 | + if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation; |
|
| 780 | 780 | |
| 781 | 781 | return $comment_list; |
| 782 | 782 | } |
@@ -788,9 +788,9 @@ discard block |
||
| 788 | 788 | |
| 789 | 789 | function getTrackbacks() |
| 790 | 790 | { |
| 791 | - if(!$this->document_srl) return; |
|
| 791 | + if (!$this->document_srl) return; |
|
| 792 | 792 | |
| 793 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 793 | + if (!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 794 | 794 | |
| 795 | 795 | $oTrackbackModel = getModel('trackback'); |
| 796 | 796 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -798,47 +798,47 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | function thumbnailExists($width = 80, $height = 0, $type = '') |
| 800 | 800 | { |
| 801 | - if(!$this->document_srl) return false; |
|
| 802 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
| 801 | + if (!$this->document_srl) return false; |
|
| 802 | + if (!$this->getThumbnail($width, $height, $type)) return false; |
|
| 803 | 803 | return true; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
| 807 | 807 | { |
| 808 | 808 | // Return false if the document doesn't exist |
| 809 | - if(!$this->document_srl) return; |
|
| 809 | + if (!$this->document_srl) return; |
|
| 810 | 810 | |
| 811 | - if($this->isSecret() && !$this->isGranted()) |
|
| 811 | + if ($this->isSecret() && !$this->isGranted()) |
|
| 812 | 812 | { |
| 813 | 813 | return; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | // If not specify its height, create a square |
| 817 | - if(!$height) $height = $width; |
|
| 817 | + if (!$height) $height = $width; |
|
| 818 | 818 | |
| 819 | 819 | // Return false if neither attachement nor image files in the document |
| 820 | 820 | $content = $this->get('content'); |
| 821 | - if(!$this->get('uploaded_count')) |
|
| 821 | + if (!$this->get('uploaded_count')) |
|
| 822 | 822 | { |
| 823 | - if(!$content) |
|
| 823 | + if (!$content) |
|
| 824 | 824 | { |
| 825 | 825 | $args = new stdClass(); |
| 826 | 826 | $args->document_srl = $this->document_srl; |
| 827 | 827 | $output = executeQuery('document.getDocument', $args, array('content')); |
| 828 | - if($output->toBool() && $output->data) |
|
| 828 | + if ($output->toBool() && $output->data) |
|
| 829 | 829 | { |
| 830 | 830 | $content = $output->data->content; |
| 831 | 831 | $this->add('content', $content); |
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - if(!preg_match("!<img!is", $content)) return; |
|
| 835 | + if (!preg_match("!<img!is", $content)) return; |
|
| 836 | 836 | } |
| 837 | 837 | // Get thumbnai_type information from document module's configuration |
| 838 | - if(!in_array($thumbnail_type, array('crop','ratio'))) |
|
| 838 | + if (!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
| 839 | 839 | { |
| 840 | 840 | $config = $GLOBALS['__document_config__']; |
| 841 | - if(!$config) |
|
| 841 | + if (!$config) |
|
| 842 | 842 | { |
| 843 | 843 | $oDocumentModel = getModel('document'); |
| 844 | 844 | $config = $oDocumentModel->getDocumentConfig(); |
@@ -848,15 +848,15 @@ discard block |
||
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | // Define thumbnail information |
| 851 | - $thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3)); |
|
| 851 | + $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3)); |
|
| 852 | 852 | $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); |
| 853 | 853 | $thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type); |
| 854 | 854 | $thumbnail_url = Context::getRequestUri().$thumbnail_file; |
| 855 | 855 | |
| 856 | 856 | // Return false if thumbnail file exists and its size is 0. Otherwise, return its path |
| 857 | - if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 857 | + if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 858 | 858 | { |
| 859 | - if(filesize($thumbnail_file) < 1) |
|
| 859 | + if (filesize($thumbnail_file) < 1) |
|
| 860 | 860 | { |
| 861 | 861 | return FALSE; |
| 862 | 862 | } |
@@ -874,64 +874,64 @@ discard block |
||
| 874 | 874 | $is_tmp_file = false; |
| 875 | 875 | |
| 876 | 876 | // Find an iamge file among attached files if exists |
| 877 | - if($this->hasUploadedFiles()) |
|
| 877 | + if ($this->hasUploadedFiles()) |
|
| 878 | 878 | { |
| 879 | 879 | $file_list = $this->getUploadedFiles(); |
| 880 | 880 | |
| 881 | 881 | $first_image = null; |
| 882 | - foreach($file_list as $file) |
|
| 882 | + foreach ($file_list as $file) |
|
| 883 | 883 | { |
| 884 | - if($file->direct_download !== 'Y') continue; |
|
| 884 | + if ($file->direct_download !== 'Y') continue; |
|
| 885 | 885 | |
| 886 | - if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 886 | + if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 887 | 887 | { |
| 888 | 888 | $source_file = $file->uploaded_filename; |
| 889 | 889 | break; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if($first_image) continue; |
|
| 892 | + if ($first_image) continue; |
|
| 893 | 893 | |
| 894 | - if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 894 | + if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 895 | 895 | { |
| 896 | - if(file_exists($file->uploaded_filename)) |
|
| 896 | + if (file_exists($file->uploaded_filename)) |
|
| 897 | 897 | { |
| 898 | 898 | $first_image = $file->uploaded_filename; |
| 899 | 899 | } |
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - if(!$source_file && $first_image) |
|
| 903 | + if (!$source_file && $first_image) |
|
| 904 | 904 | { |
| 905 | 905 | $source_file = $first_image; |
| 906 | 906 | } |
| 907 | 907 | } |
| 908 | 908 | // If not exists, file an image file from the content |
| 909 | 909 | $is_tmp_file = false; |
| 910 | - if(!$source_file) |
|
| 910 | + if (!$source_file) |
|
| 911 | 911 | { |
| 912 | 912 | $random = new Password(); |
| 913 | 913 | |
| 914 | 914 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
| 915 | 915 | |
| 916 | - foreach($matches as $target_image) |
|
| 916 | + foreach ($matches as $target_image) |
|
| 917 | 917 | { |
| 918 | 918 | $target_src = trim($target_image[1]); |
| 919 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 919 | + if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 920 | 920 | |
| 921 | - if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
| 921 | + if (!preg_match('/^(http|https):\/\//i', $target_src)) |
|
| 922 | 922 | { |
| 923 | 923 | $target_src = Context::getRequestUri().$target_src; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | $target_src = htmlspecialchars_decode($target_src); |
| 927 | 927 | |
| 928 | - $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
| 928 | + $tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex'); |
|
| 929 | 929 | FileHandler::getRemoteFile($target_src, $tmp_file); |
| 930 | - if(!file_exists($tmp_file)) continue; |
|
| 930 | + if (!file_exists($tmp_file)) continue; |
|
| 931 | 931 | |
| 932 | 932 | $imageinfo = getimagesize($tmp_file); |
| 933 | 933 | list($_w, $_h) = $imageinfo; |
| 934 | - if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 934 | + if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 935 | 935 | FileHandler::removeFile($tmp_file); |
| 936 | 936 | continue; |
| 937 | 937 | } |
@@ -942,13 +942,13 @@ discard block |
||
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - if($source_file) |
|
| 945 | + if ($source_file) |
|
| 946 | 946 | { |
| 947 | 947 | $output_file = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | // Remove source file if it was temporary |
| 951 | - if($is_tmp_file) |
|
| 951 | + if ($is_tmp_file) |
|
| 952 | 952 | { |
| 953 | 953 | FileHandler::removeFile($source_file); |
| 954 | 954 | } |
@@ -957,14 +957,14 @@ discard block |
||
| 957 | 957 | FileHandler::removeFile($thumbnail_lockfile); |
| 958 | 958 | |
| 959 | 959 | // Return the thumbnail path if it was successfully generated |
| 960 | - if($output_file) |
|
| 960 | + if ($output_file) |
|
| 961 | 961 | { |
| 962 | 962 | return $thumbnail_url; |
| 963 | 963 | } |
| 964 | 964 | // Create an empty file if thumbnail generation failed |
| 965 | 965 | else |
| 966 | 966 | { |
| 967 | - FileHandler::writeFile($thumbnail_file, '','w'); |
|
| 967 | + FileHandler::writeFile($thumbnail_file, '', 'w'); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | return; |
@@ -978,21 +978,21 @@ discard block |
||
| 978 | 978 | */ |
| 979 | 979 | function getExtraImages($time_interval = 43200) |
| 980 | 980 | { |
| 981 | - if(!$this->document_srl) return; |
|
| 981 | + if (!$this->document_srl) return; |
|
| 982 | 982 | // variables for icon list |
| 983 | 983 | $buffs = array(); |
| 984 | 984 | |
| 985 | 985 | $check_files = false; |
| 986 | 986 | |
| 987 | 987 | // Check if secret post is |
| 988 | - if($this->isSecret()) $buffs[] = "secret"; |
|
| 988 | + if ($this->isSecret()) $buffs[] = "secret"; |
|
| 989 | 989 | |
| 990 | 990 | // Set the latest time |
| 991 | - $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
|
| 991 | + $time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval); |
|
| 992 | 992 | |
| 993 | 993 | // Check new post |
| 994 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
| 995 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
| 994 | + if ($this->get('regdate') > $time_check) $buffs[] = "new"; |
|
| 995 | + else if ($this->get('last_update') > $time_check) $buffs[] = "update"; |
|
| 996 | 996 | |
| 997 | 997 | /* |
| 998 | 998 | $content = $this->get('content'); |
@@ -1015,14 +1015,14 @@ discard block |
||
| 1015 | 1015 | */ |
| 1016 | 1016 | |
| 1017 | 1017 | // Check the attachment |
| 1018 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1018 | + if ($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1019 | 1019 | |
| 1020 | 1020 | return $buffs; |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | function getStatus() |
| 1024 | 1024 | { |
| 1025 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
| 1025 | + if (!$this->get('status')) return $this->getDefaultStatus(); |
|
| 1026 | 1026 | return $this->get('status'); |
| 1027 | 1027 | } |
| 1028 | 1028 | |
@@ -1033,15 +1033,15 @@ discard block |
||
| 1033 | 1033 | */ |
| 1034 | 1034 | function printExtraImages($time_check = 43200) |
| 1035 | 1035 | { |
| 1036 | - if(!$this->document_srl) return; |
|
| 1036 | + if (!$this->document_srl) return; |
|
| 1037 | 1037 | // Get the icon directory |
| 1038 | - $path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/'); |
|
| 1038 | + $path = sprintf('%s%s', getUrl(), 'modules/document/tpl/icons/'); |
|
| 1039 | 1039 | |
| 1040 | 1040 | $buffs = $this->getExtraImages($time_check); |
| 1041 | - if(!count($buffs)) return; |
|
| 1041 | + if (!count($buffs)) return; |
|
| 1042 | 1042 | |
| 1043 | 1043 | $buff = array(); |
| 1044 | - foreach($buffs as $key => $val) |
|
| 1044 | + foreach ($buffs as $key => $val) |
|
| 1045 | 1045 | { |
| 1046 | 1046 | $buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val); |
| 1047 | 1047 | } |
@@ -1050,20 +1050,20 @@ discard block |
||
| 1050 | 1050 | |
| 1051 | 1051 | function hasUploadedFiles() |
| 1052 | 1052 | { |
| 1053 | - if(!$this->document_srl) return; |
|
| 1053 | + if (!$this->document_srl) return; |
|
| 1054 | 1054 | |
| 1055 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
| 1056 | - return $this->get('uploaded_count')? true : false; |
|
| 1055 | + if ($this->isSecret() && !$this->isGranted()) return false; |
|
| 1056 | + return $this->get('uploaded_count') ? true : false; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | function getUploadedFiles($sortIndex = 'file_srl') |
| 1060 | 1060 | { |
| 1061 | - if(!$this->document_srl) return; |
|
| 1061 | + if (!$this->document_srl) return; |
|
| 1062 | 1062 | |
| 1063 | - if($this->isSecret() && !$this->isGranted()) return; |
|
| 1064 | - if(!$this->get('uploaded_count')) return; |
|
| 1063 | + if ($this->isSecret() && !$this->isGranted()) return; |
|
| 1064 | + if (!$this->get('uploaded_count')) return; |
|
| 1065 | 1065 | |
| 1066 | - if(!$this->uploadedFiles[$sortIndex]) |
|
| 1066 | + if (!$this->uploadedFiles[$sortIndex]) |
|
| 1067 | 1067 | { |
| 1068 | 1068 | $oFileModel = getModel('file'); |
| 1069 | 1069 | $this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true); |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | function getEditor() |
| 1080 | 1080 | { |
| 1081 | 1081 | $module_srl = $this->get('module_srl'); |
| 1082 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1082 | + if (!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1083 | 1083 | |
| 1084 | 1084 | $oEditorModel = getModel('editor'); |
| 1085 | 1085 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | { |
| 1095 | 1095 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
| 1096 | 1096 | if (!$this->allowComment()) return false; |
| 1097 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
| 1097 | + if (!$this->isGranted() && $this->isSecret()) return false; |
|
| 1098 | 1098 | |
| 1099 | 1099 | return true; |
| 1100 | 1100 | } |
@@ -1105,7 +1105,7 @@ discard block |
||
| 1105 | 1105 | */ |
| 1106 | 1106 | function getCommentEditor() |
| 1107 | 1107 | { |
| 1108 | - if(!$this->isEnableComment()) return; |
|
| 1108 | + if (!$this->isEnableComment()) return; |
|
| 1109 | 1109 | |
| 1110 | 1110 | $oEditorModel = getModel('editor'); |
| 1111 | 1111 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1117,10 +1117,10 @@ discard block |
||
| 1117 | 1117 | */ |
| 1118 | 1118 | function getProfileImage() |
| 1119 | 1119 | { |
| 1120 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1120 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1121 | 1121 | $oMemberModel = getModel('member'); |
| 1122 | 1122 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
| 1123 | - if(!$profile_info) return; |
|
| 1123 | + if (!$profile_info) return; |
|
| 1124 | 1124 | |
| 1125 | 1125 | return $profile_info->src; |
| 1126 | 1126 | } |
@@ -1132,21 +1132,21 @@ discard block |
||
| 1132 | 1132 | function getSignature() |
| 1133 | 1133 | { |
| 1134 | 1134 | // Pass if a document doesn't exist |
| 1135 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1135 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1136 | 1136 | // Get signature information |
| 1137 | 1137 | $oMemberModel = getModel('member'); |
| 1138 | 1138 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
| 1139 | 1139 | // Check if a maximum height of signiture is set in the member module |
| 1140 | - if(!isset($GLOBALS['__member_signature_max_height'])) |
|
| 1140 | + if (!isset($GLOBALS['__member_signature_max_height'])) |
|
| 1141 | 1141 | { |
| 1142 | 1142 | $oModuleModel = getModel('module'); |
| 1143 | 1143 | $member_config = $oModuleModel->getModuleConfig('member'); |
| 1144 | 1144 | $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; |
| 1145 | 1145 | } |
| 1146 | - if($signature) |
|
| 1146 | + if ($signature) |
|
| 1147 | 1147 | { |
| 1148 | 1148 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
| 1149 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1149 | + if ($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | return $signature; |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | */ |
| 1160 | 1160 | function replaceResourceRealPath($matches) |
| 1161 | 1161 | { |
| 1162 | - return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
| 1162 | + return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | /** |
@@ -1170,19 +1170,19 @@ discard block |
||
| 1170 | 1170 | function _checkAccessibleFromStatus() |
| 1171 | 1171 | { |
| 1172 | 1172 | $logged_info = Context::get('logged_info'); |
| 1173 | - if($logged_info->is_admin == 'Y') return true; |
|
| 1173 | + if ($logged_info->is_admin == 'Y') return true; |
|
| 1174 | 1174 | |
| 1175 | 1175 | $status = $this->get('status'); |
| 1176 | - if(empty($status)) return false; |
|
| 1176 | + if (empty($status)) return false; |
|
| 1177 | 1177 | |
| 1178 | 1178 | $oDocumentModel = getModel('document'); |
| 1179 | 1179 | $configStatusList = $oDocumentModel->getStatusList(); |
| 1180 | 1180 | |
| 1181 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1181 | + if ($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1182 | 1182 | return true; |
| 1183 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1183 | + else if ($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1184 | 1184 | { |
| 1185 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
| 1185 | + if ($this->get('member_srl') == $logged_info->member_srl) |
|
| 1186 | 1186 | return true; |
| 1187 | 1187 | } |
| 1188 | 1188 | return false; |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | /** |
| 473 | 473 | * Show pop-up menu of the selected posts |
| 474 | 474 | * Printing, scrap, recommendations and negative, reported the Add Features |
| 475 | - * @return void |
|
| 475 | + * @return Object|null |
|
| 476 | 476 | */ |
| 477 | 477 | function getDocumentMenu() |
| 478 | 478 | { |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | /** |
| 886 | 886 | * Get a list for a particular module |
| 887 | - * @return void|Object |
|
| 887 | + * @return Object|null |
|
| 888 | 888 | */ |
| 889 | 889 | function getDocumentCategories() |
| 890 | 890 | { |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | /** |
| 971 | 971 | * Certain categories of information, return the template guhanhu |
| 972 | 972 | * Manager on the page to add information about a particular menu from the server after compiling tpl compiled a direct return html |
| 973 | - * @return void|Object |
|
| 973 | + * @return Object|null |
|
| 974 | 974 | */ |
| 975 | 975 | function getDocumentCategoryTplInfo() |
| 976 | 976 | { |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | * Setting sort index |
| 1228 | 1228 | * @param object $obj |
| 1229 | 1229 | * @param bool $load_extra_vars |
| 1230 | - * @return object |
|
| 1230 | + * @return stdClass |
|
| 1231 | 1231 | */ |
| 1232 | 1232 | function _setSortIndex($obj, $load_extra_vars) |
| 1233 | 1233 | { |
@@ -56,18 +56,24 @@ discard block |
||
| 56 | 56 | $_document_list = &$GLOBALS['XE_DOCUMENT_LIST']; |
| 57 | 57 | |
| 58 | 58 | // XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings |
| 59 | - if(count($_document_list) <= 0) return; |
|
| 59 | + if(count($_document_list) <= 0) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 60 | 62 | |
| 61 | 63 | // Find all called the document object variable has been set extension |
| 62 | 64 | $document_srls = array(); |
| 63 | 65 | foreach($_document_list as $key => $val) |
| 64 | 66 | { |
| 65 | - if(!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
| 67 | + if(!$val->document_srl || $checked_documents[$val->document_srl]) { |
|
| 68 | + continue; |
|
| 69 | + } |
|
| 66 | 70 | $checked_documents[$val->document_srl] = true; |
| 67 | 71 | $document_srls[] = $val->document_srl; |
| 68 | 72 | } |
| 69 | 73 | // If the document number, return detected |
| 70 | - if(!count($document_srls)) return; |
|
| 74 | + if(!count($document_srls)) { |
|
| 75 | + return; |
|
| 76 | + } |
|
| 71 | 77 | // Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable |
| 72 | 78 | //$obj->document_srl = implode(',',$document_srls); |
| 73 | 79 | $output = $this->getDocumentExtraVarsFromDB($document_srls); |
@@ -75,8 +81,12 @@ discard block |
||
| 75 | 81 | { |
| 76 | 82 | foreach($output->data as $key => $val) |
| 77 | 83 | { |
| 78 | - if(!isset($val->value)) continue; |
|
| 79 | - if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 84 | + if(!isset($val->value)) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) { |
|
| 88 | + $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 89 | + } |
|
| 80 | 90 | $extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); |
| 81 | 91 | } |
| 82 | 92 | } |
@@ -87,7 +97,9 @@ discard block |
||
| 87 | 97 | $document_srl = $document_srls[$i]; |
| 88 | 98 | unset($vars); |
| 89 | 99 | |
| 90 | - if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
| 100 | + if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) { |
|
| 101 | + continue; |
|
| 102 | + } |
|
| 91 | 103 | $module_srl = $_document_list[$document_srl]->get('module_srl'); |
| 92 | 104 | $extra_keys = $this->getExtraKeys($module_srl); |
| 93 | 105 | $vars = $extra_vars[$document_srl]; |
@@ -99,10 +111,15 @@ discard block |
||
| 99 | 111 | { |
| 100 | 112 | $extra_keys[$idx] = clone($key); |
| 101 | 113 | $val = $vars[$idx]; |
| 102 | - if(isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
| 103 | - else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
| 104 | - else if(isset($val[0])) $v = $val[0]; |
|
| 105 | - else $v = null; |
|
| 114 | + if(isset($val[$user_lang_code])) { |
|
| 115 | + $v = $val[$user_lang_code]; |
|
| 116 | + } else if(isset($val[$document_lang_code])) { |
|
| 117 | + $v = $val[$document_lang_code]; |
|
| 118 | + } else if(isset($val[0])) { |
|
| 119 | + $v = $val[0]; |
|
| 120 | + } else { |
|
| 121 | + $v = null; |
|
| 122 | + } |
|
| 106 | 123 | $extra_keys[$idx]->value = $v; |
| 107 | 124 | } |
| 108 | 125 | } |
@@ -111,9 +128,13 @@ discard block |
||
| 111 | 128 | $evars = new ExtraVar($module_srl); |
| 112 | 129 | $evars->setExtraVarKeys($extra_keys); |
| 113 | 130 | // Title Processing |
| 114 | - if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
| 131 | + if($vars[-1][$user_lang_code]) { |
|
| 132 | + $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
| 133 | + } |
|
| 115 | 134 | // Information processing |
| 116 | - if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
| 135 | + if($vars[-2][$user_lang_code]) { |
|
| 136 | + $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
| 137 | + } |
|
| 117 | 138 | |
| 118 | 139 | if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
| 119 | 140 | { |
@@ -134,15 +155,21 @@ discard block |
||
| 134 | 155 | */ |
| 135 | 156 | function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
| 136 | 157 | { |
| 137 | - if(!$document_srl) return new documentItem(); |
|
| 158 | + if(!$document_srl) { |
|
| 159 | + return new documentItem(); |
|
| 160 | + } |
|
| 138 | 161 | |
| 139 | 162 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 140 | 163 | { |
| 141 | 164 | $oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
| 142 | 165 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 143 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 166 | + if($load_extra_vars) { |
|
| 167 | + $this->setToAllDocumentExtraVars(); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + if($is_admin) { |
|
| 171 | + $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 144 | 172 | } |
| 145 | - if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 146 | 173 | |
| 147 | 174 | return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 148 | 175 | } |
@@ -161,8 +188,7 @@ discard block |
||
| 161 | 188 | { |
| 162 | 189 | $list_count = count($document_srls); |
| 163 | 190 | $document_srls = implode(',',$document_srls); |
| 164 | - } |
|
| 165 | - else |
|
| 191 | + } else |
|
| 166 | 192 | { |
| 167 | 193 | $list_count = 1; |
| 168 | 194 | } |
@@ -173,28 +199,38 @@ discard block |
||
| 173 | 199 | |
| 174 | 200 | $output = executeQuery('document.getDocuments', $args, $columnList); |
| 175 | 201 | $document_list = $output->data; |
| 176 | - if(!$document_list) return; |
|
| 177 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 202 | + if(!$document_list) { |
|
| 203 | + return; |
|
| 204 | + } |
|
| 205 | + if(!is_array($document_list)) { |
|
| 206 | + $document_list = array($document_list); |
|
| 207 | + } |
|
| 178 | 208 | |
| 179 | 209 | $document_count = count($document_list); |
| 180 | 210 | foreach($document_list as $key => $attribute) |
| 181 | 211 | { |
| 182 | 212 | $document_srl = $attribute->document_srl; |
| 183 | - if(!$document_srl) continue; |
|
| 213 | + if(!$document_srl) { |
|
| 214 | + continue; |
|
| 215 | + } |
|
| 184 | 216 | |
| 185 | 217 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 186 | 218 | { |
| 187 | 219 | $oDocument = null; |
| 188 | 220 | $oDocument = new documentItem(); |
| 189 | 221 | $oDocument->setAttribute($attribute, false); |
| 190 | - if($is_admin) $oDocument->setGrant(); |
|
| 222 | + if($is_admin) { |
|
| 223 | + $oDocument->setGrant(); |
|
| 224 | + } |
|
| 191 | 225 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 192 | 226 | } |
| 193 | 227 | |
| 194 | 228 | $result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 195 | 229 | } |
| 196 | 230 | |
| 197 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 231 | + if($load_extra_vars) { |
|
| 232 | + $this->setToAllDocumentExtraVars(); |
|
| 233 | + } |
|
| 198 | 234 | |
| 199 | 235 | $output = null; |
| 200 | 236 | if(count($result)) |
@@ -242,18 +278,15 @@ discard block |
||
| 242 | 278 | { |
| 243 | 279 | $output = $obj->use_alternate_output; |
| 244 | 280 | unset($obj->use_alternate_output); |
| 245 | - } |
|
| 246 | - elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
| 281 | + } elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
| 247 | 282 | { |
| 248 | 283 | $query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
| 249 | 284 | $args->sort_index = str_replace('documents.','',$args->sort_index); |
| 250 | 285 | $output = executeQueryArray($query_id, $args); |
| 251 | - } |
|
| 252 | - elseif ($sort_check->isExtraVars) |
|
| 286 | + } elseif ($sort_check->isExtraVars) |
|
| 253 | 287 | { |
| 254 | 288 | $output = executeQueryArray($query_id, $args); |
| 255 | - } |
|
| 256 | - else |
|
| 289 | + } else |
|
| 257 | 290 | { |
| 258 | 291 | // document.getDocumentList query execution |
| 259 | 292 | // Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
@@ -263,11 +296,15 @@ discard block |
||
| 263 | 296 | $group_args = clone($args); |
| 264 | 297 | $group_args->sort_index = 'documents.'.$args->sort_index; |
| 265 | 298 | $output = executeQueryArray($query_id, $group_args); |
| 266 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 299 | + if(!$output->toBool()||!count($output->data)) { |
|
| 300 | + return $output; |
|
| 301 | + } |
|
| 267 | 302 | |
| 268 | 303 | foreach($output->data as $key => $val) |
| 269 | 304 | { |
| 270 | - if($val->document_srl) $target_srls[] = $val->document_srl; |
|
| 305 | + if($val->document_srl) { |
|
| 306 | + $target_srls[] = $val->document_srl; |
|
| 307 | + } |
|
| 271 | 308 | } |
| 272 | 309 | |
| 273 | 310 | $page_navigation = $output->page_navigation; |
@@ -285,14 +322,15 @@ discard block |
||
| 285 | 322 | $output->total_count = $page_navigation->total_count; |
| 286 | 323 | $output->total_page = $page_navigation->total_page; |
| 287 | 324 | $output->page = $page_navigation->cur_page; |
| 288 | - } |
|
| 289 | - else |
|
| 325 | + } else |
|
| 290 | 326 | { |
| 291 | 327 | $output = executeQueryArray($query_id, $args, $columnList); |
| 292 | 328 | } |
| 293 | 329 | } |
| 294 | 330 | // Return if no result or an error occurs |
| 295 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 331 | + if(!$output->toBool()||!count($output->data)) { |
|
| 332 | + return $output; |
|
| 333 | + } |
|
| 296 | 334 | $idx = 0; |
| 297 | 335 | $data = $output->data; |
| 298 | 336 | unset($output->data); |
@@ -307,20 +345,26 @@ discard block |
||
| 307 | 345 | { |
| 308 | 346 | foreach($data as $key => $attribute) |
| 309 | 347 | { |
| 310 | - if($attribute->is_notice == 'Y') $virtual_number --; |
|
| 348 | + if($attribute->is_notice == 'Y') { |
|
| 349 | + $virtual_number --; |
|
| 350 | + } |
|
| 311 | 351 | } |
| 312 | 352 | } |
| 313 | 353 | |
| 314 | 354 | foreach($data as $key => $attribute) |
| 315 | 355 | { |
| 316 | - if($except_notice && $attribute->is_notice == 'Y') continue; |
|
| 356 | + if($except_notice && $attribute->is_notice == 'Y') { |
|
| 357 | + continue; |
|
| 358 | + } |
|
| 317 | 359 | $document_srl = $attribute->document_srl; |
| 318 | 360 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 319 | 361 | { |
| 320 | 362 | $oDocument = null; |
| 321 | 363 | $oDocument = new documentItem(); |
| 322 | 364 | $oDocument->setAttribute($attribute, false); |
| 323 | - if($is_admin) $oDocument->setGrant(); |
|
| 365 | + if($is_admin) { |
|
| 366 | + $oDocument->setGrant(); |
|
| 367 | + } |
|
| 324 | 368 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 325 | 369 | } |
| 326 | 370 | |
@@ -328,7 +372,9 @@ discard block |
||
| 328 | 372 | $virtual_number--; |
| 329 | 373 | } |
| 330 | 374 | |
| 331 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 375 | + if($load_extra_vars) { |
|
| 376 | + $this->setToAllDocumentExtraVars(); |
|
| 377 | + } |
|
| 332 | 378 | |
| 333 | 379 | if(count($output->data)) |
| 334 | 380 | { |
@@ -356,12 +402,16 @@ discard block |
||
| 356 | 402 | $args->module_srl = $obj->module_srl; |
| 357 | 403 | $args->category_srl= $obj->category_srl; |
| 358 | 404 | $output = executeQueryArray('document.getNoticeList', $args, $columnList); |
| 359 | - if(!$output->toBool()||!$output->data) return; |
|
| 405 | + if(!$output->toBool()||!$output->data) { |
|
| 406 | + return; |
|
| 407 | + } |
|
| 360 | 408 | |
| 361 | 409 | foreach($output->data as $key => $val) |
| 362 | 410 | { |
| 363 | 411 | $document_srl = $val->document_srl; |
| 364 | - if(!$document_srl) continue; |
|
| 412 | + if(!$document_srl) { |
|
| 413 | + continue; |
|
| 414 | + } |
|
| 365 | 415 | |
| 366 | 416 | if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
| 367 | 417 | { |
@@ -457,7 +507,9 @@ discard block |
||
| 457 | 507 | |
| 458 | 508 | $oExtraVar->setExtraVarKeys($output->data); |
| 459 | 509 | $keys = $oExtraVar->getExtraVars(); |
| 460 | - if(!$keys) $keys = array(); |
|
| 510 | + if(!$keys) { |
|
| 511 | + $keys = array(); |
|
| 512 | + } |
|
| 461 | 513 | |
| 462 | 514 | if($oCacheHandler->isSupport()) |
| 463 | 515 | { |
@@ -487,7 +539,9 @@ discard block |
||
| 487 | 539 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 488 | 540 | $this->setToAllDocumentExtraVars(); |
| 489 | 541 | } |
| 490 | - if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 542 | + if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) { |
|
| 543 | + ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 544 | + } |
|
| 491 | 545 | return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
| 492 | 546 | } |
| 493 | 547 | |
@@ -517,7 +571,9 @@ discard block |
||
| 517 | 571 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 518 | 572 | $module_srl = $oDocument->get('module_srl'); |
| 519 | 573 | $member_srl = $oDocument->get('member_srl'); |
| 520 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 574 | + if(!$module_srl) { |
|
| 575 | + return new Object(-1, 'msg_invalid_request'); |
|
| 576 | + } |
|
| 521 | 577 | |
| 522 | 578 | $oModuleModel = getModel('module'); |
| 523 | 579 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
@@ -590,7 +646,9 @@ discard block |
||
| 590 | 646 | */ |
| 591 | 647 | function getDocumentCount($module_srl, $search_obj = NULL) |
| 592 | 648 | { |
| 593 | - if(is_null($search_obj)) $search_obj = new stdClass(); |
|
| 649 | + if(is_null($search_obj)) { |
|
| 650 | + $search_obj = new stdClass(); |
|
| 651 | + } |
|
| 594 | 652 | $search_obj->module_srl = $module_srl; |
| 595 | 653 | |
| 596 | 654 | $output = executeQuery('document.getDocumentCount', $search_obj); |
@@ -607,7 +665,9 @@ discard block |
||
| 607 | 665 | function getDocumentCountByGroupStatus($search_obj = NULL) |
| 608 | 666 | { |
| 609 | 667 | $output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
| 610 | - if(!$output->toBool()) return array(); |
|
| 668 | + if(!$output->toBool()) { |
|
| 669 | + return array(); |
|
| 670 | + } |
|
| 611 | 671 | |
| 612 | 672 | return $output->data; |
| 613 | 673 | } |
@@ -646,34 +706,29 @@ discard block |
||
| 646 | 706 | if($sort_check->isExtraVars) |
| 647 | 707 | { |
| 648 | 708 | return 1; |
| 649 | - } |
|
| 650 | - else |
|
| 709 | + } else |
|
| 651 | 710 | { |
| 652 | 711 | if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
| 653 | 712 | { |
| 654 | 713 | if($args->order_type === 'desc') |
| 655 | 714 | { |
| 656 | 715 | $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 657 | - } |
|
| 658 | - else |
|
| 716 | + } else |
|
| 659 | 717 | { |
| 660 | 718 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 661 | 719 | } |
| 662 | - } |
|
| 663 | - elseif($sort_check->sort_index === 'regdate') |
|
| 720 | + } elseif($sort_check->sort_index === 'regdate') |
|
| 664 | 721 | { |
| 665 | 722 | |
| 666 | 723 | if($args->order_type === 'asc') |
| 667 | 724 | { |
| 668 | 725 | $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 669 | - } |
|
| 670 | - else |
|
| 726 | + } else |
|
| 671 | 727 | { |
| 672 | 728 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 673 | 729 | } |
| 674 | 730 | |
| 675 | - } |
|
| 676 | - else |
|
| 731 | + } else |
|
| 677 | 732 | { |
| 678 | 733 | return 1; |
| 679 | 734 | } |
@@ -699,15 +754,16 @@ discard block |
||
| 699 | 754 | $output = executeQuery('document.getCategory', $args, $columnList); |
| 700 | 755 | |
| 701 | 756 | $node = $output->data; |
| 702 | - if(!$node) return; |
|
| 757 | + if(!$node) { |
|
| 758 | + return; |
|
| 759 | + } |
|
| 703 | 760 | |
| 704 | 761 | if($node->group_srls) |
| 705 | 762 | { |
| 706 | 763 | $group_srls = explode(',',$node->group_srls); |
| 707 | 764 | unset($node->group_srls); |
| 708 | 765 | $node->group_srls = $group_srls; |
| 709 | - } |
|
| 710 | - else |
|
| 766 | + } else |
|
| 711 | 767 | { |
| 712 | 768 | unset($node->group_srls); |
| 713 | 769 | $node->group_srls = array(); |
@@ -725,7 +781,9 @@ discard block |
||
| 725 | 781 | $args = new stdClass(); |
| 726 | 782 | $args->category_srl = $category_srl; |
| 727 | 783 | $output = executeQuery('document.getChildCategoryCount',$args); |
| 728 | - if($output->data->count > 0) return true; |
|
| 784 | + if($output->data->count > 0) { |
|
| 785 | + return true; |
|
| 786 | + } |
|
| 729 | 787 | return false; |
| 730 | 788 | } |
| 731 | 789 | |
@@ -744,7 +802,9 @@ discard block |
||
| 744 | 802 | if(!file_exists($filename)) |
| 745 | 803 | { |
| 746 | 804 | $oDocumentController = getController('document'); |
| 747 | - if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
| 805 | + if(!$oDocumentController->makeCategoryFile($module_srl)) { |
|
| 806 | + return array(); |
|
| 807 | + } |
|
| 748 | 808 | } |
| 749 | 809 | |
| 750 | 810 | include($filename); |
@@ -764,7 +824,9 @@ discard block |
||
| 764 | 824 | */ |
| 765 | 825 | function _arrangeCategory(&$document_category, $list, $depth) |
| 766 | 826 | { |
| 767 | - if(!count($list)) return; |
|
| 827 | + if(!count($list)) { |
|
| 828 | + return; |
|
| 829 | + } |
|
| 768 | 830 | $idx = 0; |
| 769 | 831 | $list_order = array(); |
| 770 | 832 | foreach($list as $key => $val) |
@@ -784,8 +846,11 @@ discard block |
||
| 784 | 846 | $obj->childs = array(); |
| 785 | 847 | $obj->grant = $val['grant']; |
| 786 | 848 | |
| 787 | - if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
| 788 | - else $selected = false; |
|
| 849 | + if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) { |
|
| 850 | + $selected = true; |
|
| 851 | + } else { |
|
| 852 | + $selected = false; |
|
| 853 | + } |
|
| 789 | 854 | |
| 790 | 855 | $obj->selected = $selected; |
| 791 | 856 | |
@@ -796,14 +861,18 @@ discard block |
||
| 796 | 861 | $parent_srl = $obj->parent_srl; |
| 797 | 862 | $document_count = $obj->document_count; |
| 798 | 863 | $expand = $obj->expand; |
| 799 | - if($selected) $expand = true; |
|
| 864 | + if($selected) { |
|
| 865 | + $expand = true; |
|
| 866 | + } |
|
| 800 | 867 | |
| 801 | 868 | while($parent_srl) |
| 802 | 869 | { |
| 803 | 870 | $document_category[$parent_srl]->document_count += $document_count; |
| 804 | 871 | $document_category[$parent_srl]->childs[] = $obj->category_srl; |
| 805 | 872 | $document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
| 806 | - if($expand) $document_category[$parent_srl]->expand = $expand; |
|
| 873 | + if($expand) { |
|
| 874 | + $document_category[$parent_srl]->expand = $expand; |
|
| 875 | + } |
|
| 807 | 876 | |
| 808 | 877 | $parent_srl = $document_category[$parent_srl]->parent_srl; |
| 809 | 878 | } |
@@ -811,7 +880,9 @@ discard block |
||
| 811 | 880 | |
| 812 | 881 | $document_category[$key] = $obj; |
| 813 | 882 | |
| 814 | - if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
| 883 | + if(count($val['list'])) { |
|
| 884 | + $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
| 885 | + } |
|
| 815 | 886 | } |
| 816 | 887 | $document_category[$list_order[0]]->first = true; |
| 817 | 888 | $document_category[$list_order[count($list_order)-1]]->last = true; |
@@ -879,13 +950,20 @@ discard block |
||
| 879 | 950 | } |
| 880 | 951 | // Module_srl passed the array may be a check whether the array |
| 881 | 952 | $args = new stdClass; |
| 882 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 883 | - else $args->module_srl = $obj->module_srl; |
|
| 953 | + if(is_array($obj->module_srl)) { |
|
| 954 | + $args->module_srl = implode(',', $obj->module_srl); |
|
| 955 | + } else { |
|
| 956 | + $args->module_srl = $obj->module_srl; |
|
| 957 | + } |
|
| 884 | 958 | |
| 885 | 959 | $output = executeQuery('document.getMonthlyArchivedList', $args); |
| 886 | - if(!$output->toBool()||!$output->data) return $output; |
|
| 960 | + if(!$output->toBool()||!$output->data) { |
|
| 961 | + return $output; |
|
| 962 | + } |
|
| 887 | 963 | |
| 888 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 964 | + if(!is_array($output->data)) { |
|
| 965 | + $output->data = array($output->data); |
|
| 966 | + } |
|
| 889 | 967 | |
| 890 | 968 | return $output; |
| 891 | 969 | } |
@@ -905,14 +983,21 @@ discard block |
||
| 905 | 983 | } |
| 906 | 984 | // Module_srl passed the array may be a check whether the array |
| 907 | 985 | $args = new stdClass; |
| 908 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 909 | - else $args->module_srl = $obj->module_srl; |
|
| 986 | + if(is_array($obj->module_srl)) { |
|
| 987 | + $args->module_srl = implode(',', $obj->module_srl); |
|
| 988 | + } else { |
|
| 989 | + $args->module_srl = $obj->module_srl; |
|
| 990 | + } |
|
| 910 | 991 | $args->regdate = $obj->regdate; |
| 911 | 992 | |
| 912 | 993 | $output = executeQuery('document.getDailyArchivedList', $args); |
| 913 | - if(!$output->toBool()) return $output; |
|
| 994 | + if(!$output->toBool()) { |
|
| 995 | + return $output; |
|
| 996 | + } |
|
| 914 | 997 | |
| 915 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 998 | + if(!is_array($output->data)) { |
|
| 999 | + $output->data = array($output->data); |
|
| 1000 | + } |
|
| 916 | 1001 | |
| 917 | 1002 | return $output; |
| 918 | 1003 | } |
@@ -923,7 +1008,9 @@ discard block |
||
| 923 | 1008 | */ |
| 924 | 1009 | function getDocumentCategories() |
| 925 | 1010 | { |
| 926 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 1011 | + if(!Context::get('is_logged')) { |
|
| 1012 | + return new Object(-1,'msg_not_permitted'); |
|
| 1013 | + } |
|
| 927 | 1014 | $module_srl = Context::get('module_srl'); |
| 928 | 1015 | $categories= $this->getCategoryList($module_srl); |
| 929 | 1016 | $lang = Context::get('lang'); |
@@ -950,8 +1037,12 @@ discard block |
||
| 950 | 1037 | $oModuleModel = getModel('module'); |
| 951 | 1038 | $config = $oModuleModel->getModuleConfig('document'); |
| 952 | 1039 | |
| 953 | - if(!$config) $config = new stdClass(); |
|
| 954 | - if(!$config->thumbnail_type) $config->thumbnail_type = 'crop'; |
|
| 1040 | + if(!$config) { |
|
| 1041 | + $config = new stdClass(); |
|
| 1042 | + } |
|
| 1043 | + if(!$config->thumbnail_type) { |
|
| 1044 | + $config->thumbnail_type = 'crop'; |
|
| 1045 | + } |
|
| 955 | 1046 | $GLOBALS['__document_config__'] = $config; |
| 956 | 1047 | } |
| 957 | 1048 | return $GLOBALS['__document_config__']; |
@@ -1016,7 +1107,9 @@ discard block |
||
| 1016 | 1107 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 1017 | 1108 | // Check permissions |
| 1018 | 1109 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1019 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1110 | + if(!$grant->manager) { |
|
| 1111 | + return new Object(-1,'msg_not_permitted'); |
|
| 1112 | + } |
|
| 1020 | 1113 | |
| 1021 | 1114 | $category_srl = Context::get('category_srl'); |
| 1022 | 1115 | $category_info = $this->getCategory($category_srl); |
@@ -1036,15 +1129,20 @@ discard block |
||
| 1036 | 1129 | */ |
| 1037 | 1130 | function getDocumentSrlByAlias($mid, $alias) |
| 1038 | 1131 | { |
| 1039 | - if(!$mid || !$alias) return null; |
|
| 1132 | + if(!$mid || !$alias) { |
|
| 1133 | + return null; |
|
| 1134 | + } |
|
| 1040 | 1135 | $site_module_info = Context::get('site_module_info'); |
| 1041 | 1136 | $args = new stdClass; |
| 1042 | 1137 | $args->mid = $mid; |
| 1043 | 1138 | $args->alias_title = $alias; |
| 1044 | 1139 | $args->site_srl = $site_module_info->site_srl; |
| 1045 | 1140 | $output = executeQuery('document.getDocumentSrlByAlias', $args); |
| 1046 | - if(!$output->data) return null; |
|
| 1047 | - else return $output->data->document_srl; |
|
| 1141 | + if(!$output->data) { |
|
| 1142 | + return null; |
|
| 1143 | + } else { |
|
| 1144 | + return $output->data->document_srl; |
|
| 1145 | + } |
|
| 1048 | 1146 | } |
| 1049 | 1147 | |
| 1050 | 1148 | /** |
@@ -1055,15 +1153,20 @@ discard block |
||
| 1055 | 1153 | */ |
| 1056 | 1154 | function getDocumentSrlByTitle($module_srl, $title) |
| 1057 | 1155 | { |
| 1058 | - if(!$module_srl || !$title) return null; |
|
| 1156 | + if(!$module_srl || !$title) { |
|
| 1157 | + return null; |
|
| 1158 | + } |
|
| 1059 | 1159 | $args = new stdClass; |
| 1060 | 1160 | $args->module_srl = $module_srl; |
| 1061 | 1161 | $args->title = $title; |
| 1062 | 1162 | $output = executeQuery('document.getDocumentSrlByTitle', $args); |
| 1063 | - if(!$output->data) return null; |
|
| 1064 | - else |
|
| 1163 | + if(!$output->data) { |
|
| 1164 | + return null; |
|
| 1165 | + } else |
|
| 1065 | 1166 | { |
| 1066 | - if(is_array($output->data)) return $output->data[0]->document_srl; |
|
| 1167 | + if(is_array($output->data)) { |
|
| 1168 | + return $output->data[0]->document_srl; |
|
| 1169 | + } |
|
| 1067 | 1170 | return $output->data->document_srl; |
| 1068 | 1171 | } |
| 1069 | 1172 | } |
@@ -1075,13 +1178,18 @@ discard block |
||
| 1075 | 1178 | */ |
| 1076 | 1179 | function getAlias($document_srl) |
| 1077 | 1180 | { |
| 1078 | - if(!$document_srl) return null; |
|
| 1181 | + if(!$document_srl) { |
|
| 1182 | + return null; |
|
| 1183 | + } |
|
| 1079 | 1184 | $args = new stdClass; |
| 1080 | 1185 | $args->document_srl = $document_srl; |
| 1081 | 1186 | $output = executeQueryArray('document.getAliases', $args); |
| 1082 | 1187 | |
| 1083 | - if(!$output->data) return null; |
|
| 1084 | - else return $output->data[0]->alias_title; |
|
| 1188 | + if(!$output->data) { |
|
| 1189 | + return null; |
|
| 1190 | + } else { |
|
| 1191 | + return $output->data[0]->alias_title; |
|
| 1192 | + } |
|
| 1085 | 1193 | } |
| 1086 | 1194 | |
| 1087 | 1195 | /** |
@@ -1138,17 +1246,23 @@ discard block |
||
| 1138 | 1246 | { |
| 1139 | 1247 | case 'title' : |
| 1140 | 1248 | case 'content' : |
| 1141 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1249 | + if($search_keyword) { |
|
| 1250 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1251 | + } |
|
| 1142 | 1252 | $args->{"s_".$search_target} = $search_keyword; |
| 1143 | 1253 | $use_division = true; |
| 1144 | 1254 | break; |
| 1145 | 1255 | case 'title_content' : |
| 1146 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1256 | + if($search_keyword) { |
|
| 1257 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1258 | + } |
|
| 1147 | 1259 | $args->s_title = $search_keyword; |
| 1148 | 1260 | $args->s_content = $search_keyword; |
| 1149 | 1261 | break; |
| 1150 | 1262 | case 'user_id' : |
| 1151 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1263 | + if($search_keyword) { |
|
| 1264 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1265 | + } |
|
| 1152 | 1266 | $args->s_user_id = $search_keyword; |
| 1153 | 1267 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1154 | 1268 | break; |
@@ -1156,13 +1270,18 @@ discard block |
||
| 1156 | 1270 | case 'nick_name' : |
| 1157 | 1271 | case 'email_address' : |
| 1158 | 1272 | case 'homepage' : |
| 1159 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1273 | + if($search_keyword) { |
|
| 1274 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1275 | + } |
|
| 1160 | 1276 | $args->{"s_".$search_target} = $search_keyword; |
| 1161 | 1277 | break; |
| 1162 | 1278 | case 'is_notice' : |
| 1163 | 1279 | case 'is_secret' : |
| 1164 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1165 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1280 | + if($search_keyword=='N') { |
|
| 1281 | + $args->statusList = array($this->getConfigStatus('public')); |
|
| 1282 | + } elseif($search_keyword=='Y') { |
|
| 1283 | + $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1284 | + } |
|
| 1166 | 1285 | break; |
| 1167 | 1286 | case 'member_srl' : |
| 1168 | 1287 | case 'readed_count' : |
@@ -1204,34 +1323,45 @@ discard block |
||
| 1204 | 1323 | { |
| 1205 | 1324 | $args = new stdClass; |
| 1206 | 1325 | $document_srl = Context::get('document_srl'); |
| 1207 | - if(!$document_srl) return new Object(-1,'msg_invalid_request'); |
|
| 1326 | + if(!$document_srl) { |
|
| 1327 | + return new Object(-1,'msg_invalid_request'); |
|
| 1328 | + } |
|
| 1208 | 1329 | |
| 1209 | 1330 | $point = Context::get('point'); |
| 1210 | - if($point != -1) $point = 1; |
|
| 1331 | + if($point != -1) { |
|
| 1332 | + $point = 1; |
|
| 1333 | + } |
|
| 1211 | 1334 | |
| 1212 | 1335 | $oDocumentModel = getModel('document'); |
| 1213 | 1336 | $columnList = array('document_srl', 'module_srl'); |
| 1214 | 1337 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 1215 | 1338 | $module_srl = $oDocument->get('module_srl'); |
| 1216 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 1339 | + if(!$module_srl) { |
|
| 1340 | + return new Object(-1, 'msg_invalid_request'); |
|
| 1341 | + } |
|
| 1217 | 1342 | |
| 1218 | 1343 | $oModuleModel = getModel('module'); |
| 1219 | 1344 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
| 1220 | 1345 | if($point == -1) |
| 1221 | 1346 | { |
| 1222 | - if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request'); |
|
| 1347 | + if($document_config->use_vote_down!='S') { |
|
| 1348 | + return new Object(-1, 'msg_invalid_request'); |
|
| 1349 | + } |
|
| 1223 | 1350 | $args->below_point = 0; |
| 1224 | - } |
|
| 1225 | - else |
|
| 1351 | + } else |
|
| 1226 | 1352 | { |
| 1227 | - if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request'); |
|
| 1353 | + if($document_config->use_vote_up!='S') { |
|
| 1354 | + return new Object(-1, 'msg_invalid_request'); |
|
| 1355 | + } |
|
| 1228 | 1356 | $args->more_point = 0; |
| 1229 | 1357 | } |
| 1230 | 1358 | |
| 1231 | 1359 | $args->document_srl = $document_srl; |
| 1232 | 1360 | |
| 1233 | 1361 | $output = executeQueryArray('document.getVotedMemberList',$args); |
| 1234 | - if(!$output->toBool()) return $output; |
|
| 1362 | + if(!$output->toBool()) { |
|
| 1363 | + return $output; |
|
| 1364 | + } |
|
| 1235 | 1365 | |
| 1236 | 1366 | $oMemberModel = getModel('member'); |
| 1237 | 1367 | if($output->data) |
@@ -1253,9 +1383,11 @@ discard block |
||
| 1253 | 1383 | function getStatusNameList() |
| 1254 | 1384 | { |
| 1255 | 1385 | global $lang; |
| 1256 | - if(!isset($lang->status_name_list)) |
|
| 1257 | - return array_flip($this->getStatusList()); |
|
| 1258 | - else return $lang->status_name_list; |
|
| 1386 | + if(!isset($lang->status_name_list)) { |
|
| 1387 | + return array_flip($this->getStatusList()); |
|
| 1388 | + } else { |
|
| 1389 | + return $lang->status_name_list; |
|
| 1390 | + } |
|
| 1259 | 1391 | } |
| 1260 | 1392 | |
| 1261 | 1393 | /** |
@@ -1279,20 +1411,22 @@ discard block |
||
| 1279 | 1411 | if (!$extra_output->data || !$extra_output->toBool()) |
| 1280 | 1412 | { |
| 1281 | 1413 | $sortIndex = 'list_order'; |
| 1282 | - } |
|
| 1283 | - else |
|
| 1414 | + } else |
|
| 1284 | 1415 | { |
| 1285 | 1416 | $check_array = array(); |
| 1286 | 1417 | foreach($extra_output->data as $val) |
| 1287 | 1418 | { |
| 1288 | 1419 | $check_array[] = $val->eid; |
| 1289 | 1420 | } |
| 1290 | - if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
| 1291 | - else $isExtraVars = true; |
|
| 1421 | + if(!in_array($sortIndex, $check_array)) { |
|
| 1422 | + $sortIndex = 'list_order'; |
|
| 1423 | + } else { |
|
| 1424 | + $isExtraVars = true; |
|
| 1425 | + } |
|
| 1292 | 1426 | } |
| 1427 | + } else { |
|
| 1428 | + $sortIndex = 'list_order'; |
|
| 1293 | 1429 | } |
| 1294 | - else |
|
| 1295 | - $sortIndex = 'list_order'; |
|
| 1296 | 1430 | } |
| 1297 | 1431 | $returnObj = new stdClass(); |
| 1298 | 1432 | $returnObj->sort_index = $sortIndex; |
@@ -1330,7 +1464,9 @@ discard block |
||
| 1330 | 1464 | |
| 1331 | 1465 | // Check the target and sequence alignment |
| 1332 | 1466 | $orderType = array('desc' => 1, 'asc' => 1); |
| 1333 | - if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
| 1467 | + if(!isset($orderType[$args->order_type])) { |
|
| 1468 | + $args->order_type = 'asc'; |
|
| 1469 | + } |
|
| 1334 | 1470 | |
| 1335 | 1471 | // If that came across mid module_srl instead of a direct module_srl guhaejum |
| 1336 | 1472 | if($searchOpt->mid) |
@@ -1341,21 +1477,29 @@ discard block |
||
| 1341 | 1477 | } |
| 1342 | 1478 | |
| 1343 | 1479 | // Module_srl passed the array may be a check whether the array |
| 1344 | - if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1345 | - else $args->module_srl = $searchOpt->module_srl; |
|
| 1480 | + if(is_array($searchOpt->module_srl)) { |
|
| 1481 | + $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1482 | + } else { |
|
| 1483 | + $args->module_srl = $searchOpt->module_srl; |
|
| 1484 | + } |
|
| 1346 | 1485 | |
| 1347 | 1486 | // Except for the test module_srl |
| 1348 | - if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1349 | - else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
|
| 1487 | + if(is_array($searchOpt->exclude_module_srl)) { |
|
| 1488 | + $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1489 | + } else { |
|
| 1490 | + $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
|
| 1491 | + } |
|
| 1350 | 1492 | |
| 1351 | 1493 | // only admin document list, temp document showing |
| 1352 | - if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
| 1353 | - else |
|
| 1494 | + if($searchOpt->statusList) { |
|
| 1495 | + $args->statusList = $searchOpt->statusList; |
|
| 1496 | + } else |
|
| 1354 | 1497 | { |
| 1355 | - if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
| 1356 | - $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
|
| 1357 | - else |
|
| 1358 | - $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
|
| 1498 | + if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) { |
|
| 1499 | + $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
|
| 1500 | + } else { |
|
| 1501 | + $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
|
| 1502 | + } |
|
| 1359 | 1503 | } |
| 1360 | 1504 | |
| 1361 | 1505 | // Category is selected, further sub-categories until all conditions |
@@ -1383,18 +1527,24 @@ discard block |
||
| 1383 | 1527 | { |
| 1384 | 1528 | case 'title' : |
| 1385 | 1529 | case 'content' : |
| 1386 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1530 | + if($search_keyword) { |
|
| 1531 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1532 | + } |
|
| 1387 | 1533 | $args->{"s_".$search_target} = $search_keyword; |
| 1388 | 1534 | $use_division = true; |
| 1389 | 1535 | break; |
| 1390 | 1536 | case 'title_content' : |
| 1391 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1537 | + if($search_keyword) { |
|
| 1538 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1539 | + } |
|
| 1392 | 1540 | $args->s_title = $search_keyword; |
| 1393 | 1541 | $args->s_content = $search_keyword; |
| 1394 | 1542 | $use_division = true; |
| 1395 | 1543 | break; |
| 1396 | 1544 | case 'user_id' : |
| 1397 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1545 | + if($search_keyword) { |
|
| 1546 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1547 | + } |
|
| 1398 | 1548 | $args->s_user_id = $search_keyword; |
| 1399 | 1549 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1400 | 1550 | break; |
@@ -1402,18 +1552,28 @@ discard block |
||
| 1402 | 1552 | case 'nick_name' : |
| 1403 | 1553 | case 'email_address' : |
| 1404 | 1554 | case 'homepage' : |
| 1405 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1555 | + if($search_keyword) { |
|
| 1556 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1557 | + } |
|
| 1406 | 1558 | $args->{"s_".$search_target} = $search_keyword; |
| 1407 | 1559 | break; |
| 1408 | 1560 | case 'is_notice' : |
| 1409 | - if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
| 1410 | - elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
| 1411 | - else $args->{"s_".$search_target} = ''; |
|
| 1561 | + if($search_keyword=='N') { |
|
| 1562 | + $args->{"s_".$search_target} = 'N'; |
|
| 1563 | + } elseif($search_keyword=='Y') { |
|
| 1564 | + $args->{"s_".$search_target} = 'Y'; |
|
| 1565 | + } else { |
|
| 1566 | + $args->{"s_".$search_target} = ''; |
|
| 1567 | + } |
|
| 1412 | 1568 | break; |
| 1413 | 1569 | case 'is_secret' : |
| 1414 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1415 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1416 | - elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1570 | + if($search_keyword=='N') { |
|
| 1571 | + $args->statusList = array($this->getConfigStatus('public')); |
|
| 1572 | + } elseif($search_keyword=='Y') { |
|
| 1573 | + $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1574 | + } elseif($search_keyword=='temp') { |
|
| 1575 | + $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1576 | + } |
|
| 1417 | 1577 | break; |
| 1418 | 1578 | case 'member_srl' : |
| 1419 | 1579 | case 'readed_count' : |
@@ -1458,13 +1618,14 @@ discard block |
||
| 1458 | 1618 | if ($searchOpt->isExtraVars) |
| 1459 | 1619 | { |
| 1460 | 1620 | $query_id = 'document.getDocumentListExtraSort'; |
| 1461 | - } |
|
| 1462 | - else |
|
| 1621 | + } else |
|
| 1463 | 1622 | { |
| 1464 | 1623 | /** |
| 1465 | 1624 | * list_order asc sort of division that can be used only when |
| 1466 | 1625 | */ |
| 1467 | - if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
| 1626 | + if($args->sort_index != 'list_order' || $args->order_type != 'asc') { |
|
| 1627 | + $use_division = false; |
|
| 1628 | + } |
|
| 1468 | 1629 | |
| 1469 | 1630 | /** |
| 1470 | 1631 | * If it is true, use_division changed to use the document division |
@@ -1479,8 +1640,7 @@ discard block |
||
| 1479 | 1640 | { |
| 1480 | 1641 | $listSqlID = 'document.getDocumentListUseIndex'; |
| 1481 | 1642 | $divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
| 1482 | - } |
|
| 1483 | - else |
|
| 1643 | + } else |
|
| 1484 | 1644 | { |
| 1485 | 1645 | $listSqlID = 'document.getDocumentList'; |
| 1486 | 1646 | $divisionSqlID = 'document.getDocumentDivision'; |
@@ -1537,7 +1697,9 @@ discard block |
||
| 1537 | 1697 | $last_division_args->exclude_module_srl = $args->exclude_module_srl; |
| 1538 | 1698 | $last_division_args->list_order = $last_division; |
| 1539 | 1699 | $output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
| 1540 | - if($output->data->count<1) $last_division = null; |
|
| 1700 | + if($output->data->count<1) { |
|
| 1701 | + $last_division = null; |
|
| 1702 | + } |
|
| 1541 | 1703 | } |
| 1542 | 1704 | |
| 1543 | 1705 | $args->division = $division; |
@@ -1578,8 +1740,12 @@ discard block |
||
| 1578 | 1740 | $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
| 1579 | 1741 | $document_list = $output->data; |
| 1580 | 1742 | |
| 1581 | - if(!$document_list) return array(); |
|
| 1582 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 1743 | + if(!$document_list) { |
|
| 1744 | + return array(); |
|
| 1745 | + } |
|
| 1746 | + if(!is_array($document_list)) { |
|
| 1747 | + $document_list = array($document_list); |
|
| 1748 | + } |
|
| 1583 | 1749 | |
| 1584 | 1750 | return $document_list; |
| 1585 | 1751 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function getDocumentExtraVarsFromDB($documentSrls) |
| 37 | 37 | { |
| 38 | - if(!is_array($documentSrls) || count($documentSrls) == 0) |
|
| 38 | + if (!is_array($documentSrls) || count($documentSrls) == 0) |
|
| 39 | 39 | { |
| 40 | 40 | return new Object(-1, 'msg_invalid_request'); |
| 41 | 41 | } |
@@ -56,52 +56,52 @@ discard block |
||
| 56 | 56 | $_document_list = &$GLOBALS['XE_DOCUMENT_LIST']; |
| 57 | 57 | |
| 58 | 58 | // XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings |
| 59 | - if(count($_document_list) <= 0) return; |
|
| 59 | + if (count($_document_list) <= 0) return; |
|
| 60 | 60 | |
| 61 | 61 | // Find all called the document object variable has been set extension |
| 62 | 62 | $document_srls = array(); |
| 63 | - foreach($_document_list as $key => $val) |
|
| 63 | + foreach ($_document_list as $key => $val) |
|
| 64 | 64 | { |
| 65 | - if(!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
| 65 | + if (!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
| 66 | 66 | $checked_documents[$val->document_srl] = true; |
| 67 | 67 | $document_srls[] = $val->document_srl; |
| 68 | 68 | } |
| 69 | 69 | // If the document number, return detected |
| 70 | - if(!count($document_srls)) return; |
|
| 70 | + if (!count($document_srls)) return; |
|
| 71 | 71 | // Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable |
| 72 | 72 | //$obj->document_srl = implode(',',$document_srls); |
| 73 | 73 | $output = $this->getDocumentExtraVarsFromDB($document_srls); |
| 74 | - if($output->toBool() && $output->data) |
|
| 74 | + if ($output->toBool() && $output->data) |
|
| 75 | 75 | { |
| 76 | - foreach($output->data as $key => $val) |
|
| 76 | + foreach ($output->data as $key => $val) |
|
| 77 | 77 | { |
| 78 | - if(!isset($val->value)) continue; |
|
| 79 | - if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 78 | + if (!isset($val->value)) continue; |
|
| 79 | + if (!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
| 80 | 80 | $extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $user_lang_code = Context::getLangType(); |
| 85 | - for($i=0,$c=count($document_srls);$i<$c;$i++) |
|
| 85 | + for ($i = 0, $c = count($document_srls); $i < $c; $i++) |
|
| 86 | 86 | { |
| 87 | 87 | $document_srl = $document_srls[$i]; |
| 88 | 88 | unset($vars); |
| 89 | 89 | |
| 90 | - if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
| 90 | + if (!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
| 91 | 91 | $module_srl = $_document_list[$document_srl]->get('module_srl'); |
| 92 | 92 | $extra_keys = $this->getExtraKeys($module_srl); |
| 93 | 93 | $vars = $extra_vars[$document_srl]; |
| 94 | 94 | $document_lang_code = $_document_list[$document_srl]->get('lang_code'); |
| 95 | 95 | // Expand the variable processing |
| 96 | - if(count($extra_keys)) |
|
| 96 | + if (count($extra_keys)) |
|
| 97 | 97 | { |
| 98 | - foreach($extra_keys as $idx => $key) |
|
| 98 | + foreach ($extra_keys as $idx => $key) |
|
| 99 | 99 | { |
| 100 | 100 | $extra_keys[$idx] = clone($key); |
| 101 | 101 | $val = $vars[$idx]; |
| 102 | - if(isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
| 103 | - else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
| 104 | - else if(isset($val[0])) $v = $val[0]; |
|
| 102 | + if (isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
| 103 | + else if (isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
| 104 | + else if (isset($val[0])) $v = $val[0]; |
|
| 105 | 105 | else $v = null; |
| 106 | 106 | $extra_keys[$idx]->value = $v; |
| 107 | 107 | } |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | $evars = new ExtraVar($module_srl); |
| 112 | 112 | $evars->setExtraVarKeys($extra_keys); |
| 113 | 113 | // Title Processing |
| 114 | - if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
| 114 | + if ($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title', $vars[-1][$user_lang_code]); |
|
| 115 | 115 | // Information processing |
| 116 | - if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
| 116 | + if ($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content', $vars[-2][$user_lang_code]); |
|
| 117 | 117 | |
| 118 | - if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
|
| 118 | + if ($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
|
| 119 | 119 | { |
| 120 | 120 | unset($checked_documents[$document_srl]); |
| 121 | 121 | } |
@@ -132,17 +132,17 @@ discard block |
||
| 132 | 132 | * @param array $columnList |
| 133 | 133 | * @return documentItem |
| 134 | 134 | */ |
| 135 | - function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
| 135 | + function getDocument($document_srl = 0, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
| 136 | 136 | { |
| 137 | - if(!$document_srl) return new documentItem(); |
|
| 137 | + if (!$document_srl) return new documentItem(); |
|
| 138 | 138 | |
| 139 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 139 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 140 | 140 | { |
| 141 | 141 | $oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
| 142 | 142 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 143 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 143 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 144 | 144 | } |
| 145 | - if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 145 | + if ($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
| 146 | 146 | |
| 147 | 147 | return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 148 | 148 | } |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | * @param array $columnList |
| 156 | 156 | * @return array value type is documentItem |
| 157 | 157 | */ |
| 158 | - function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
| 158 | + function getDocuments($document_srls, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
| 159 | 159 | { |
| 160 | - if(is_array($document_srls)) |
|
| 160 | + if (is_array($document_srls)) |
|
| 161 | 161 | { |
| 162 | 162 | $list_count = count($document_srls); |
| 163 | - $document_srls = implode(',',$document_srls); |
|
| 163 | + $document_srls = implode(',', $document_srls); |
|
| 164 | 164 | } |
| 165 | 165 | else |
| 166 | 166 | { |
@@ -173,33 +173,33 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $output = executeQuery('document.getDocuments', $args, $columnList); |
| 175 | 175 | $document_list = $output->data; |
| 176 | - if(!$document_list) return; |
|
| 177 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 176 | + if (!$document_list) return; |
|
| 177 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
| 178 | 178 | |
| 179 | 179 | $document_count = count($document_list); |
| 180 | - foreach($document_list as $key => $attribute) |
|
| 180 | + foreach ($document_list as $key => $attribute) |
|
| 181 | 181 | { |
| 182 | 182 | $document_srl = $attribute->document_srl; |
| 183 | - if(!$document_srl) continue; |
|
| 183 | + if (!$document_srl) continue; |
|
| 184 | 184 | |
| 185 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 185 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 186 | 186 | { |
| 187 | 187 | $oDocument = null; |
| 188 | 188 | $oDocument = new documentItem(); |
| 189 | 189 | $oDocument->setAttribute($attribute, false); |
| 190 | - if($is_admin) $oDocument->setGrant(); |
|
| 190 | + if ($is_admin) $oDocument->setGrant(); |
|
| 191 | 191 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 197 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 198 | 198 | |
| 199 | 199 | $output = null; |
| 200 | - if(count($result)) |
|
| 200 | + if (count($result)) |
|
| 201 | 201 | { |
| 202 | - foreach($result as $document_srl => $val) |
|
| 202 | + foreach ($result as $document_srl => $val) |
|
| 203 | 203 | { |
| 204 | 204 | $output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 205 | 205 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param array $columnList |
| 217 | 217 | * @return Object |
| 218 | 218 | */ |
| 219 | - function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) |
|
| 219 | + function getDocumentList($obj, $except_notice = false, $load_extra_vars = true, $columnList = array()) |
|
| 220 | 220 | { |
| 221 | 221 | $sort_check = $this->_setSortIndex($obj, $load_extra_vars); |
| 222 | 222 | $obj->sort_index = $sort_check->sort_index; |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | // Call trigger (before) |
| 227 | 227 | // This trigger can be used to set an alternative output using a different search method |
| 228 | 228 | $output = ModuleHandler::triggerCall('document.getDocumentList', 'before', $obj); |
| 229 | - if($output instanceof Object && !$output->toBool()) |
|
| 229 | + if ($output instanceof Object && !$output->toBool()) |
|
| 230 | 230 | { |
| 231 | 231 | return $output; |
| 232 | 232 | } |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | $output = $obj->use_alternate_output; |
| 244 | 244 | unset($obj->use_alternate_output); |
| 245 | 245 | } |
| 246 | - elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
| 246 | + elseif ($sort_check->isExtraVars && substr_count($obj->search_target, 'extra_vars')) |
|
| 247 | 247 | { |
| 248 | 248 | $query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
| 249 | - $args->sort_index = str_replace('documents.','',$args->sort_index); |
|
| 249 | + $args->sort_index = str_replace('documents.', '', $args->sort_index); |
|
| 250 | 250 | $output = executeQueryArray($query_id, $args); |
| 251 | 251 | } |
| 252 | 252 | elseif ($sort_check->isExtraVars) |
@@ -258,16 +258,16 @@ discard block |
||
| 258 | 258 | // document.getDocumentList query execution |
| 259 | 259 | // Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
| 260 | 260 | $groupByQuery = array('document.getDocumentListWithinComment' => 1, 'document.getDocumentListWithinTag' => 1, 'document.getDocumentListWithinExtraVars' => 1); |
| 261 | - if(isset($groupByQuery[$query_id])) |
|
| 261 | + if (isset($groupByQuery[$query_id])) |
|
| 262 | 262 | { |
| 263 | 263 | $group_args = clone($args); |
| 264 | 264 | $group_args->sort_index = 'documents.'.$args->sort_index; |
| 265 | 265 | $output = executeQueryArray($query_id, $group_args); |
| 266 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 266 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
| 267 | 267 | |
| 268 | - foreach($output->data as $key => $val) |
|
| 268 | + foreach ($output->data as $key => $val) |
|
| 269 | 269 | { |
| 270 | - if($val->document_srl) $target_srls[] = $val->document_srl; |
|
| 270 | + if ($val->document_srl) $target_srls[] = $val->document_srl; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $page_navigation = $output->page_navigation; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $virtual_number = $keys[0]; |
| 276 | 276 | |
| 277 | 277 | $target_args = new stdClass(); |
| 278 | - $target_args->document_srls = implode(',',$target_srls); |
|
| 278 | + $target_args->document_srls = implode(',', $target_srls); |
|
| 279 | 279 | $target_args->list_order = $args->sort_index; |
| 280 | 280 | $target_args->order_type = $args->order_type; |
| 281 | 281 | $target_args->list_count = $args->list_count; |
@@ -292,35 +292,35 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | // Return if no result or an error occurs |
| 295 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 295 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
| 296 | 296 | $idx = 0; |
| 297 | 297 | $data = $output->data; |
| 298 | 298 | unset($output->data); |
| 299 | 299 | |
| 300 | - if(!isset($virtual_number)) |
|
| 300 | + if (!isset($virtual_number)) |
|
| 301 | 301 | { |
| 302 | 302 | $keys = array_keys($data); |
| 303 | 303 | $virtual_number = $keys[0]; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if($except_notice) |
|
| 306 | + if ($except_notice) |
|
| 307 | 307 | { |
| 308 | - foreach($data as $key => $attribute) |
|
| 308 | + foreach ($data as $key => $attribute) |
|
| 309 | 309 | { |
| 310 | - if($attribute->is_notice == 'Y') $virtual_number --; |
|
| 310 | + if ($attribute->is_notice == 'Y') $virtual_number--; |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - foreach($data as $key => $attribute) |
|
| 314 | + foreach ($data as $key => $attribute) |
|
| 315 | 315 | { |
| 316 | - if($except_notice && $attribute->is_notice == 'Y') continue; |
|
| 316 | + if ($except_notice && $attribute->is_notice == 'Y') continue; |
|
| 317 | 317 | $document_srl = $attribute->document_srl; |
| 318 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 318 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 319 | 319 | { |
| 320 | 320 | $oDocument = null; |
| 321 | 321 | $oDocument = new documentItem(); |
| 322 | 322 | $oDocument->setAttribute($attribute, false); |
| 323 | - if($is_admin) $oDocument->setGrant(); |
|
| 323 | + if ($is_admin) $oDocument->setGrant(); |
|
| 324 | 324 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -328,11 +328,11 @@ discard block |
||
| 328 | 328 | $virtual_number--; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 331 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
| 332 | 332 | |
| 333 | - if(count($output->data)) |
|
| 333 | + if (count($output->data)) |
|
| 334 | 334 | { |
| 335 | - foreach($output->data as $number => $document) |
|
| 335 | + foreach ($output->data as $number => $document) |
|
| 336 | 336 | { |
| 337 | 337 | $output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl]; |
| 338 | 338 | } |
@@ -354,16 +354,16 @@ discard block |
||
| 354 | 354 | { |
| 355 | 355 | $args = new stdClass(); |
| 356 | 356 | $args->module_srl = $obj->module_srl; |
| 357 | - $args->category_srl= $obj->category_srl; |
|
| 357 | + $args->category_srl = $obj->category_srl; |
|
| 358 | 358 | $output = executeQueryArray('document.getNoticeList', $args, $columnList); |
| 359 | - if(!$output->toBool()||!$output->data) return; |
|
| 359 | + if (!$output->toBool() || !$output->data) return; |
|
| 360 | 360 | |
| 361 | - foreach($output->data as $key => $val) |
|
| 361 | + foreach ($output->data as $key => $val) |
|
| 362 | 362 | { |
| 363 | 363 | $document_srl = $val->document_srl; |
| 364 | - if(!$document_srl) continue; |
|
| 364 | + if (!$document_srl) continue; |
|
| 365 | 365 | |
| 366 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 366 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
| 367 | 367 | { |
| 368 | 368 | $oDocument = null; |
| 369 | 369 | $oDocument = new documentItem(); |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | $this->setToAllDocumentExtraVars(); |
| 376 | 376 | |
| 377 | - foreach($result->data as $document_srl => $val) |
|
| 377 | + foreach ($result->data as $document_srl => $val) |
|
| 378 | 378 | { |
| 379 | 379 | $result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
| 380 | 380 | } |
@@ -390,20 +390,20 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | function getExtraKeys($module_srl) |
| 392 | 392 | { |
| 393 | - if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
| 393 | + if (!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
| 394 | 394 | { |
| 395 | 395 | $keys = false; |
| 396 | 396 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
| 397 | - if($oCacheHandler->isSupport()) |
|
| 397 | + if ($oCacheHandler->isSupport()) |
|
| 398 | 398 | { |
| 399 | - $object_key = 'module_document_extra_keys:' . $module_srl; |
|
| 399 | + $object_key = 'module_document_extra_keys:'.$module_srl; |
|
| 400 | 400 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
| 401 | 401 | $keys = $oCacheHandler->get($cache_key); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | $oExtraVar = ExtraVar::getInstance($module_srl); |
| 405 | 405 | |
| 406 | - if($keys === false) |
|
| 406 | + if ($keys === false) |
|
| 407 | 407 | { |
| 408 | 408 | $obj = new stdClass(); |
| 409 | 409 | $obj->module_srl = $module_srl; |
@@ -413,13 +413,13 @@ discard block |
||
| 413 | 413 | |
| 414 | 414 | // correcting index order |
| 415 | 415 | $isFixed = FALSE; |
| 416 | - if(is_array($output->data)) |
|
| 416 | + if (is_array($output->data)) |
|
| 417 | 417 | { |
| 418 | 418 | $prevIdx = 0; |
| 419 | - foreach($output->data as $no => $value) |
|
| 419 | + foreach ($output->data as $no => $value) |
|
| 420 | 420 | { |
| 421 | 421 | // case first |
| 422 | - if($prevIdx == 0 && $value->idx != 1) |
|
| 422 | + if ($prevIdx == 0 && $value->idx != 1) |
|
| 423 | 423 | { |
| 424 | 424 | $args = new stdClass(); |
| 425 | 425 | $args->module_srl = $module_srl; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // case others |
| 436 | - if($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
| 436 | + if ($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
| 437 | 437 | { |
| 438 | 438 | $args = new stdClass(); |
| 439 | 439 | $args->module_srl = $module_srl; |
@@ -450,16 +450,16 @@ discard block |
||
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if($isFixed) |
|
| 453 | + if ($isFixed) |
|
| 454 | 454 | { |
| 455 | 455 | $output = executeQueryArray('document.getDocumentExtraKeys', $obj); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | $oExtraVar->setExtraVarKeys($output->data); |
| 459 | 459 | $keys = $oExtraVar->getExtraVars(); |
| 460 | - if(!$keys) $keys = array(); |
|
| 460 | + if (!$keys) $keys = array(); |
|
| 461 | 461 | |
| 462 | - if($oCacheHandler->isSupport()) |
|
| 462 | + if ($oCacheHandler->isSupport()) |
|
| 463 | 463 | { |
| 464 | 464 | $oCacheHandler->put($cache_key, $keys); |
| 465 | 465 | } |
@@ -480,14 +480,14 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | function getExtraVars($module_srl, $document_srl) |
| 482 | 482 | { |
| 483 | - if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
| 483 | + if (!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
| 484 | 484 | { |
| 485 | 485 | // Extended to extract the values of variables set |
| 486 | 486 | $oDocument = $this->getDocument($document_srl, false); |
| 487 | 487 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
| 488 | 488 | $this->setToAllDocumentExtraVars(); |
| 489 | 489 | } |
| 490 | - if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 490 | + if (is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
| 491 | 491 | return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
| 492 | 492 | } |
| 493 | 493 | |
@@ -510,71 +510,71 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | $oDocumentController = getController('document'); |
| 512 | 512 | // Members must be a possible feature |
| 513 | - if($logged_info->member_srl) |
|
| 513 | + if ($logged_info->member_srl) |
|
| 514 | 514 | { |
| 515 | 515 | $oDocumentModel = getModel('document'); |
| 516 | 516 | $columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress'); |
| 517 | 517 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 518 | 518 | $module_srl = $oDocument->get('module_srl'); |
| 519 | 519 | $member_srl = $oDocument->get('member_srl'); |
| 520 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 520 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 521 | 521 | |
| 522 | 522 | $oModuleModel = getModel('module'); |
| 523 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 524 | - if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl) |
|
| 523 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 524 | + if ($document_config->use_vote_up != 'N' && $member_srl != $logged_info->member_srl) |
|
| 525 | 525 | { |
| 526 | 526 | // Add a Referral Button |
| 527 | 527 | $url = sprintf("doCallModuleAction('document','procDocumentVoteUp','%s')", $document_srl); |
| 528 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote','','javascript'); |
|
| 528 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote', '', 'javascript'); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl) |
|
| 531 | + if ($document_config->use_vote_down != 'N' && $member_srl != $logged_info->member_srl) |
|
| 532 | 532 | { |
| 533 | 533 | // Add button to negative |
| 534 | - $url= sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
| 535 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote_down','','javascript'); |
|
| 534 | + $url = sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
| 535 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote_down', '', 'javascript'); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | // Adding Report |
| 539 | 539 | $url = sprintf("doCallModuleAction('document','procDocumentDeclare','%s')", $document_srl); |
| 540 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_declare','','javascript'); |
|
| 540 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_declare', '', 'javascript'); |
|
| 541 | 541 | |
| 542 | 542 | // Add Bookmark button |
| 543 | 543 | $url = sprintf("doCallModuleAction('member','procMemberScrapDocument','%s')", $document_srl); |
| 544 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_scrap','','javascript'); |
|
| 544 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_scrap', '', 'javascript'); |
|
| 545 | 545 | } |
| 546 | 546 | // Add print button |
| 547 | - $url = getUrl('','module','document','act','dispDocumentPrint','document_srl',$document_srl); |
|
| 548 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_print','','printDocument'); |
|
| 547 | + $url = getUrl('', 'module', 'document', 'act', 'dispDocumentPrint', 'document_srl', $document_srl); |
|
| 548 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_print', '', 'printDocument'); |
|
| 549 | 549 | // Call a trigger (after) |
| 550 | 550 | ModuleHandler::triggerCall('document.getDocumentMenu', 'after', $menu_list); |
| 551 | - if($this->grant->manager) |
|
| 551 | + if ($this->grant->manager) |
|
| 552 | 552 | { |
| 553 | 553 | $str_confirm = Context::getLang('confirm_move'); |
| 554 | 554 | $url = sprintf("if(!confirm('%s')) return; var params = new Array(); params['document_srl']='%s'; params['mid']=current_mid;params['cur_url']=current_url; exec_xml('document', 'procDocumentAdminMoveToTrash', params)", $str_confirm, $document_srl); |
| 555 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_trash','','javascript'); |
|
| 555 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_trash', '', 'javascript'); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | // If you are managing to find posts by ip |
| 559 | - if($logged_info->is_admin == 'Y') |
|
| 559 | + if ($logged_info->is_admin == 'Y') |
|
| 560 | 560 | { |
| 561 | 561 | $oDocumentModel = getModel('document'); |
| 562 | - $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
| 562 | + $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
| 563 | 563 | |
| 564 | - if($oDocument->isExists()) |
|
| 564 | + if ($oDocument->isExists()) |
|
| 565 | 565 | { |
| 566 | 566 | // Find a post equivalent to ip address |
| 567 | - $url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','ipaddress','search_keyword',$oDocument->getIpAddress()); |
|
| 568 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress'); |
|
| 567 | + $url = getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oDocument->getIpAddress()); |
|
| 568 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress'); |
|
| 569 | 569 | |
| 570 | 570 | $url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oDocument->getIpAddress()); |
| 571 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_add_ip_to_spamfilter','','javascript'); |
|
| 571 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_add_ip_to_spamfilter', '', 'javascript'); |
|
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | // Changing the language of pop-up menu |
| 575 | 575 | $menus = Context::get('document_popup_menu_list'); |
| 576 | 576 | $menus_count = count($menus); |
| 577 | - for($i=0;$i<$menus_count;$i++) |
|
| 577 | + for ($i = 0; $i < $menus_count; $i++) |
|
| 578 | 578 | { |
| 579 | 579 | $menus[$i]->str = Context::getLang($menus[$i]->str); |
| 580 | 580 | } |
@@ -590,13 +590,13 @@ discard block |
||
| 590 | 590 | */ |
| 591 | 591 | function getDocumentCount($module_srl, $search_obj = NULL) |
| 592 | 592 | { |
| 593 | - if(is_null($search_obj)) $search_obj = new stdClass(); |
|
| 593 | + if (is_null($search_obj)) $search_obj = new stdClass(); |
|
| 594 | 594 | $search_obj->module_srl = $module_srl; |
| 595 | 595 | |
| 596 | 596 | $output = executeQuery('document.getDocumentCount', $search_obj); |
| 597 | 597 | // Return total number of |
| 598 | 598 | $total_count = $output->data->count; |
| 599 | - return (int)$total_count; |
|
| 599 | + return (int) $total_count; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | function getDocumentCountByGroupStatus($search_obj = NULL) |
| 608 | 608 | { |
| 609 | 609 | $output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
| 610 | - if(!$output->toBool()) return array(); |
|
| 610 | + if (!$output->toBool()) return array(); |
|
| 611 | 611 | |
| 612 | 612 | return $output->data; |
| 613 | 613 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | $output = executeQuery('document.getDocumentExtraVarsCount', $args); |
| 627 | 627 | // Return total number of |
| 628 | 628 | $total_count = $output->data->count; |
| 629 | - return (int)$total_count; |
|
| 629 | + return (int) $total_count; |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | /** |
@@ -643,29 +643,29 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | $this->_setSearchOption($opt, $args, $query_id, $use_division); |
| 645 | 645 | |
| 646 | - if($sort_check->isExtraVars) |
|
| 646 | + if ($sort_check->isExtraVars) |
|
| 647 | 647 | { |
| 648 | 648 | return 1; |
| 649 | 649 | } |
| 650 | 650 | else |
| 651 | 651 | { |
| 652 | - if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
| 652 | + if ($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
| 653 | 653 | { |
| 654 | - if($args->order_type === 'desc') |
|
| 654 | + if ($args->order_type === 'desc') |
|
| 655 | 655 | { |
| 656 | - $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 656 | + $args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 657 | 657 | } |
| 658 | 658 | else |
| 659 | 659 | { |
| 660 | 660 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | - elseif($sort_check->sort_index === 'regdate') |
|
| 663 | + elseif ($sort_check->sort_index === 'regdate') |
|
| 664 | 664 | { |
| 665 | 665 | |
| 666 | - if($args->order_type === 'asc') |
|
| 666 | + if ($args->order_type === 'asc') |
|
| 667 | 667 | { |
| 668 | - $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 668 | + $args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
| 669 | 669 | } |
| 670 | 670 | else |
| 671 | 671 | { |
@@ -680,9 +680,9 @@ discard block |
||
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | // Guhanhu total number of the article search page |
| 683 | - $output = executeQuery($query_id . 'Page', $args); |
|
| 683 | + $output = executeQuery($query_id.'Page', $args); |
|
| 684 | 684 | $count = $output->data->count; |
| 685 | - $page = (int)(($count-1)/$opt->list_count)+1; |
|
| 685 | + $page = (int) (($count - 1) / $opt->list_count) + 1; |
|
| 686 | 686 | return $page; |
| 687 | 687 | } |
| 688 | 688 | |
@@ -694,16 +694,16 @@ discard block |
||
| 694 | 694 | */ |
| 695 | 695 | function getCategory($category_srl, $columnList = array()) |
| 696 | 696 | { |
| 697 | - $args =new stdClass(); |
|
| 697 | + $args = new stdClass(); |
|
| 698 | 698 | $args->category_srl = $category_srl; |
| 699 | 699 | $output = executeQuery('document.getCategory', $args, $columnList); |
| 700 | 700 | |
| 701 | 701 | $node = $output->data; |
| 702 | - if(!$node) return; |
|
| 702 | + if (!$node) return; |
|
| 703 | 703 | |
| 704 | - if($node->group_srls) |
|
| 704 | + if ($node->group_srls) |
|
| 705 | 705 | { |
| 706 | - $group_srls = explode(',',$node->group_srls); |
|
| 706 | + $group_srls = explode(',', $node->group_srls); |
|
| 707 | 707 | unset($node->group_srls); |
| 708 | 708 | $node->group_srls = $group_srls; |
| 709 | 709 | } |
@@ -724,8 +724,8 @@ discard block |
||
| 724 | 724 | { |
| 725 | 725 | $args = new stdClass(); |
| 726 | 726 | $args->category_srl = $category_srl; |
| 727 | - $output = executeQuery('document.getChildCategoryCount',$args); |
|
| 728 | - if($output->data->count > 0) return true; |
|
| 727 | + $output = executeQuery('document.getChildCategoryCount', $args); |
|
| 728 | + if ($output->data->count > 0) return true; |
|
| 729 | 729 | return false; |
| 730 | 730 | } |
| 731 | 731 | |
@@ -741,10 +741,10 @@ discard block |
||
| 741 | 741 | // Category of the target module file swollen |
| 742 | 742 | $filename = sprintf("%sfiles/cache/document_category/%s.php", _XE_PATH_, $module_srl); |
| 743 | 743 | // If the target file to the cache file regeneration category |
| 744 | - if(!file_exists($filename)) |
|
| 744 | + if (!file_exists($filename)) |
|
| 745 | 745 | { |
| 746 | 746 | $oDocumentController = getController('document'); |
| 747 | - if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
| 747 | + if (!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | include($filename); |
@@ -764,10 +764,10 @@ discard block |
||
| 764 | 764 | */ |
| 765 | 765 | function _arrangeCategory(&$document_category, $list, $depth) |
| 766 | 766 | { |
| 767 | - if(!count($list)) return; |
|
| 767 | + if (!count($list)) return; |
|
| 768 | 768 | $idx = 0; |
| 769 | 769 | $list_order = array(); |
| 770 | - foreach($list as $key => $val) |
|
| 770 | + foreach ($list as $key => $val) |
|
| 771 | 771 | { |
| 772 | 772 | $obj = new stdClass; |
| 773 | 773 | $obj->mid = $val['mid']; |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | $obj->parent_srl = $val['parent_srl']; |
| 777 | 777 | $obj->title = $obj->text = $val['text']; |
| 778 | 778 | $obj->description = $val['description']; |
| 779 | - $obj->expand = $val['expand']=='Y'?true:false; |
|
| 779 | + $obj->expand = $val['expand'] == 'Y' ?true:false; |
|
| 780 | 780 | $obj->color = $val['color']; |
| 781 | 781 | $obj->document_count = $val['document_count']; |
| 782 | 782 | $obj->depth = $depth; |
@@ -784,26 +784,26 @@ discard block |
||
| 784 | 784 | $obj->childs = array(); |
| 785 | 785 | $obj->grant = $val['grant']; |
| 786 | 786 | |
| 787 | - if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
| 787 | + if (Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
| 788 | 788 | else $selected = false; |
| 789 | 789 | |
| 790 | 790 | $obj->selected = $selected; |
| 791 | 791 | |
| 792 | 792 | $list_order[$idx++] = $obj->category_srl; |
| 793 | 793 | // If you have a parent category of child nodes apply data |
| 794 | - if($obj->parent_srl) |
|
| 794 | + if ($obj->parent_srl) |
|
| 795 | 795 | { |
| 796 | 796 | $parent_srl = $obj->parent_srl; |
| 797 | 797 | $document_count = $obj->document_count; |
| 798 | 798 | $expand = $obj->expand; |
| 799 | - if($selected) $expand = true; |
|
| 799 | + if ($selected) $expand = true; |
|
| 800 | 800 | |
| 801 | - while($parent_srl) |
|
| 801 | + while ($parent_srl) |
|
| 802 | 802 | { |
| 803 | 803 | $document_category[$parent_srl]->document_count += $document_count; |
| 804 | 804 | $document_category[$parent_srl]->childs[] = $obj->category_srl; |
| 805 | 805 | $document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
| 806 | - if($expand) $document_category[$parent_srl]->expand = $expand; |
|
| 806 | + if ($expand) $document_category[$parent_srl]->expand = $expand; |
|
| 807 | 807 | |
| 808 | 808 | $parent_srl = $document_category[$parent_srl]->parent_srl; |
| 809 | 809 | } |
@@ -811,10 +811,10 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | $document_category[$key] = $obj; |
| 813 | 813 | |
| 814 | - if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
| 814 | + if (count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth + 1); |
|
| 815 | 815 | } |
| 816 | 816 | $document_category[$list_order[0]]->first = true; |
| 817 | - $document_category[$list_order[count($list_order)-1]]->last = true; |
|
| 817 | + $document_category[$list_order[count($list_order) - 1]]->last = true; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $args->module_srl = $module_srl; |
| 830 | 830 | $args->category_srl = $category_srl; |
| 831 | 831 | $output = executeQuery('document.getCategoryDocumentCount', $args); |
| 832 | - return (int)$output->data->count; |
|
| 832 | + return (int) $output->data->count; |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
@@ -839,8 +839,8 @@ discard block |
||
| 839 | 839 | */ |
| 840 | 840 | function getCategoryXmlFile($module_srl) |
| 841 | 841 | { |
| 842 | - $xml_file = sprintf('files/cache/document_category/%s.xml.php',$module_srl); |
|
| 843 | - if(!file_exists($xml_file)) |
|
| 842 | + $xml_file = sprintf('files/cache/document_category/%s.xml.php', $module_srl); |
|
| 843 | + if (!file_exists($xml_file)) |
|
| 844 | 844 | { |
| 845 | 845 | $oDocumentController = getController('document'); |
| 846 | 846 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -855,8 +855,8 @@ discard block |
||
| 855 | 855 | */ |
| 856 | 856 | function getCategoryPhpFile($module_srl) |
| 857 | 857 | { |
| 858 | - $php_file = sprintf('files/cache/document_category/%s.php',$module_srl); |
|
| 859 | - if(!file_exists($php_file)) |
|
| 858 | + $php_file = sprintf('files/cache/document_category/%s.php', $module_srl); |
|
| 859 | + if (!file_exists($php_file)) |
|
| 860 | 860 | { |
| 861 | 861 | $oDocumentController = getController('document'); |
| 862 | 862 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | */ |
| 872 | 872 | function getMonthlyArchivedList($obj) |
| 873 | 873 | { |
| 874 | - if($obj->mid) |
|
| 874 | + if ($obj->mid) |
|
| 875 | 875 | { |
| 876 | 876 | $oModuleModel = getModel('module'); |
| 877 | 877 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -879,13 +879,13 @@ discard block |
||
| 879 | 879 | } |
| 880 | 880 | // Module_srl passed the array may be a check whether the array |
| 881 | 881 | $args = new stdClass; |
| 882 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 882 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 883 | 883 | else $args->module_srl = $obj->module_srl; |
| 884 | 884 | |
| 885 | 885 | $output = executeQuery('document.getMonthlyArchivedList', $args); |
| 886 | - if(!$output->toBool()||!$output->data) return $output; |
|
| 886 | + if (!$output->toBool() || !$output->data) return $output; |
|
| 887 | 887 | |
| 888 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 888 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
| 889 | 889 | |
| 890 | 890 | return $output; |
| 891 | 891 | } |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | */ |
| 898 | 898 | function getDailyArchivedList($obj) |
| 899 | 899 | { |
| 900 | - if($obj->mid) |
|
| 900 | + if ($obj->mid) |
|
| 901 | 901 | { |
| 902 | 902 | $oModuleModel = getModel('module'); |
| 903 | 903 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -905,14 +905,14 @@ discard block |
||
| 905 | 905 | } |
| 906 | 906 | // Module_srl passed the array may be a check whether the array |
| 907 | 907 | $args = new stdClass; |
| 908 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 908 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
| 909 | 909 | else $args->module_srl = $obj->module_srl; |
| 910 | 910 | $args->regdate = $obj->regdate; |
| 911 | 911 | |
| 912 | 912 | $output = executeQuery('document.getDailyArchivedList', $args); |
| 913 | - if(!$output->toBool()) return $output; |
|
| 913 | + if (!$output->toBool()) return $output; |
|
| 914 | 914 | |
| 915 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
| 915 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
| 916 | 916 | |
| 917 | 917 | return $output; |
| 918 | 918 | } |
@@ -923,17 +923,17 @@ discard block |
||
| 923 | 923 | */ |
| 924 | 924 | function getDocumentCategories() |
| 925 | 925 | { |
| 926 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 926 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 927 | 927 | $module_srl = Context::get('module_srl'); |
| 928 | - $categories= $this->getCategoryList($module_srl); |
|
| 928 | + $categories = $this->getCategoryList($module_srl); |
|
| 929 | 929 | $lang = Context::get('lang'); |
| 930 | 930 | // No additional category |
| 931 | 931 | $output = "0,0,{$lang->none_category}\n"; |
| 932 | - if($categories) |
|
| 932 | + if ($categories) |
|
| 933 | 933 | { |
| 934 | - foreach($categories as $category_srl => $category) |
|
| 934 | + foreach ($categories as $category_srl => $category) |
|
| 935 | 935 | { |
| 936 | - $output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title); |
|
| 936 | + $output .= sprintf("%d,%d,%s\n", $category_srl, $category->depth, $category->title); |
|
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | 939 | $this->add('categories', $output); |
@@ -945,13 +945,13 @@ discard block |
||
| 945 | 945 | */ |
| 946 | 946 | function getDocumentConfig() |
| 947 | 947 | { |
| 948 | - if(!$GLOBALS['__document_config__']) |
|
| 948 | + if (!$GLOBALS['__document_config__']) |
|
| 949 | 949 | { |
| 950 | 950 | $oModuleModel = getModel('module'); |
| 951 | 951 | $config = $oModuleModel->getModuleConfig('document'); |
| 952 | 952 | |
| 953 | - if(!$config) $config = new stdClass(); |
|
| 954 | - if(!$config->thumbnail_type) $config->thumbnail_type = 'crop'; |
|
| 953 | + if (!$config) $config = new stdClass(); |
|
| 954 | + if (!$config->thumbnail_type) $config->thumbnail_type = 'crop'; |
|
| 955 | 955 | $GLOBALS['__document_config__'] = $config; |
| 956 | 956 | } |
| 957 | 957 | return $GLOBALS['__document_config__']; |
@@ -1016,11 +1016,11 @@ discard block |
||
| 1016 | 1016 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 1017 | 1017 | // Check permissions |
| 1018 | 1018 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1019 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1019 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1020 | 1020 | |
| 1021 | 1021 | $category_srl = Context::get('category_srl'); |
| 1022 | 1022 | $category_info = $this->getCategory($category_srl); |
| 1023 | - if(!$category_info) |
|
| 1023 | + if (!$category_info) |
|
| 1024 | 1024 | { |
| 1025 | 1025 | return new Object(-1, 'msg_invalid_request'); |
| 1026 | 1026 | } |
@@ -1036,14 +1036,14 @@ discard block |
||
| 1036 | 1036 | */ |
| 1037 | 1037 | function getDocumentSrlByAlias($mid, $alias) |
| 1038 | 1038 | { |
| 1039 | - if(!$mid || !$alias) return null; |
|
| 1039 | + if (!$mid || !$alias) return null; |
|
| 1040 | 1040 | $site_module_info = Context::get('site_module_info'); |
| 1041 | 1041 | $args = new stdClass; |
| 1042 | 1042 | $args->mid = $mid; |
| 1043 | 1043 | $args->alias_title = $alias; |
| 1044 | 1044 | $args->site_srl = $site_module_info->site_srl; |
| 1045 | 1045 | $output = executeQuery('document.getDocumentSrlByAlias', $args); |
| 1046 | - if(!$output->data) return null; |
|
| 1046 | + if (!$output->data) return null; |
|
| 1047 | 1047 | else return $output->data->document_srl; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
@@ -1055,15 +1055,15 @@ discard block |
||
| 1055 | 1055 | */ |
| 1056 | 1056 | function getDocumentSrlByTitle($module_srl, $title) |
| 1057 | 1057 | { |
| 1058 | - if(!$module_srl || !$title) return null; |
|
| 1058 | + if (!$module_srl || !$title) return null; |
|
| 1059 | 1059 | $args = new stdClass; |
| 1060 | 1060 | $args->module_srl = $module_srl; |
| 1061 | 1061 | $args->title = $title; |
| 1062 | 1062 | $output = executeQuery('document.getDocumentSrlByTitle', $args); |
| 1063 | - if(!$output->data) return null; |
|
| 1063 | + if (!$output->data) return null; |
|
| 1064 | 1064 | else |
| 1065 | 1065 | { |
| 1066 | - if(is_array($output->data)) return $output->data[0]->document_srl; |
|
| 1066 | + if (is_array($output->data)) return $output->data[0]->document_srl; |
|
| 1067 | 1067 | return $output->data->document_srl; |
| 1068 | 1068 | } |
| 1069 | 1069 | } |
@@ -1075,12 +1075,12 @@ discard block |
||
| 1075 | 1075 | */ |
| 1076 | 1076 | function getAlias($document_srl) |
| 1077 | 1077 | { |
| 1078 | - if(!$document_srl) return null; |
|
| 1078 | + if (!$document_srl) return null; |
|
| 1079 | 1079 | $args = new stdClass; |
| 1080 | 1080 | $args->document_srl = $document_srl; |
| 1081 | 1081 | $output = executeQueryArray('document.getAliases', $args); |
| 1082 | 1082 | |
| 1083 | - if(!$output->data) return null; |
|
| 1083 | + if (!$output->data) return null; |
|
| 1084 | 1084 | else return $output->data[0]->alias_title; |
| 1085 | 1085 | } |
| 1086 | 1086 | |
@@ -1123,32 +1123,32 @@ discard block |
||
| 1123 | 1123 | { |
| 1124 | 1124 | // Variable check |
| 1125 | 1125 | $args = new stdClass; |
| 1126 | - $args->category_srl = $obj->category_srl?$obj->category_srl:null; |
|
| 1126 | + $args->category_srl = $obj->category_srl ? $obj->category_srl : null; |
|
| 1127 | 1127 | $args->sort_index = $obj->sort_index; |
| 1128 | - $args->order_type = $obj->order_type?$obj->order_type:'desc'; |
|
| 1129 | - $args->page = $obj->page?$obj->page:1; |
|
| 1130 | - $args->list_count = $obj->list_count?$obj->list_count:20; |
|
| 1131 | - $args->page_count = $obj->page_count?$obj->page_count:10; |
|
| 1128 | + $args->order_type = $obj->order_type ? $obj->order_type : 'desc'; |
|
| 1129 | + $args->page = $obj->page ? $obj->page : 1; |
|
| 1130 | + $args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
| 1131 | + $args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
| 1132 | 1132 | // Search options |
| 1133 | 1133 | $search_target = $obj->search_target; |
| 1134 | 1134 | $search_keyword = $obj->search_keyword; |
| 1135 | - if($search_target && $search_keyword) |
|
| 1135 | + if ($search_target && $search_keyword) |
|
| 1136 | 1136 | { |
| 1137 | - switch($search_target) |
|
| 1137 | + switch ($search_target) |
|
| 1138 | 1138 | { |
| 1139 | 1139 | case 'title' : |
| 1140 | 1140 | case 'content' : |
| 1141 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1141 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1142 | 1142 | $args->{"s_".$search_target} = $search_keyword; |
| 1143 | 1143 | $use_division = true; |
| 1144 | 1144 | break; |
| 1145 | 1145 | case 'title_content' : |
| 1146 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1146 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1147 | 1147 | $args->s_title = $search_keyword; |
| 1148 | 1148 | $args->s_content = $search_keyword; |
| 1149 | 1149 | break; |
| 1150 | 1150 | case 'user_id' : |
| 1151 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1151 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1152 | 1152 | $args->s_user_id = $search_keyword; |
| 1153 | 1153 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1154 | 1154 | break; |
@@ -1156,13 +1156,13 @@ discard block |
||
| 1156 | 1156 | case 'nick_name' : |
| 1157 | 1157 | case 'email_address' : |
| 1158 | 1158 | case 'homepage' : |
| 1159 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1159 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1160 | 1160 | $args->{"s_".$search_target} = $search_keyword; |
| 1161 | 1161 | break; |
| 1162 | 1162 | case 'is_notice' : |
| 1163 | 1163 | case 'is_secret' : |
| 1164 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1165 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1164 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1165 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1166 | 1166 | break; |
| 1167 | 1167 | case 'member_srl' : |
| 1168 | 1168 | case 'readed_count' : |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | case 'comment_count' : |
| 1172 | 1172 | case 'trackback_count' : |
| 1173 | 1173 | case 'uploaded_count' : |
| 1174 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
| 1174 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
| 1175 | 1175 | break; |
| 1176 | 1176 | case 'regdate' : |
| 1177 | 1177 | case 'last_update' : |
@@ -1183,9 +1183,9 @@ discard block |
||
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | $output = executeQueryArray('document.getTrashList', $args); |
| 1186 | - if($output->data) |
|
| 1186 | + if ($output->data) |
|
| 1187 | 1187 | { |
| 1188 | - foreach($output->data as $key => $attribute) |
|
| 1188 | + foreach ($output->data as $key => $attribute) |
|
| 1189 | 1189 | { |
| 1190 | 1190 | $oDocument = null; |
| 1191 | 1191 | $oDocument = new documentItem(); |
@@ -1204,46 +1204,46 @@ discard block |
||
| 1204 | 1204 | { |
| 1205 | 1205 | $args = new stdClass; |
| 1206 | 1206 | $document_srl = Context::get('document_srl'); |
| 1207 | - if(!$document_srl) return new Object(-1,'msg_invalid_request'); |
|
| 1207 | + if (!$document_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 1208 | 1208 | |
| 1209 | 1209 | $point = Context::get('point'); |
| 1210 | - if($point != -1) $point = 1; |
|
| 1210 | + if ($point != -1) $point = 1; |
|
| 1211 | 1211 | |
| 1212 | 1212 | $oDocumentModel = getModel('document'); |
| 1213 | 1213 | $columnList = array('document_srl', 'module_srl'); |
| 1214 | 1214 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
| 1215 | 1215 | $module_srl = $oDocument->get('module_srl'); |
| 1216 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 1216 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 1217 | 1217 | |
| 1218 | 1218 | $oModuleModel = getModel('module'); |
| 1219 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
| 1220 | - if($point == -1) |
|
| 1219 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
| 1220 | + if ($point == -1) |
|
| 1221 | 1221 | { |
| 1222 | - if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request'); |
|
| 1222 | + if ($document_config->use_vote_down != 'S') return new Object(-1, 'msg_invalid_request'); |
|
| 1223 | 1223 | $args->below_point = 0; |
| 1224 | 1224 | } |
| 1225 | 1225 | else |
| 1226 | 1226 | { |
| 1227 | - if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request'); |
|
| 1227 | + if ($document_config->use_vote_up != 'S') return new Object(-1, 'msg_invalid_request'); |
|
| 1228 | 1228 | $args->more_point = 0; |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | $args->document_srl = $document_srl; |
| 1232 | 1232 | |
| 1233 | - $output = executeQueryArray('document.getVotedMemberList',$args); |
|
| 1234 | - if(!$output->toBool()) return $output; |
|
| 1233 | + $output = executeQueryArray('document.getVotedMemberList', $args); |
|
| 1234 | + if (!$output->toBool()) return $output; |
|
| 1235 | 1235 | |
| 1236 | 1236 | $oMemberModel = getModel('member'); |
| 1237 | - if($output->data) |
|
| 1237 | + if ($output->data) |
|
| 1238 | 1238 | { |
| 1239 | - foreach($output->data as $k => $d) |
|
| 1239 | + foreach ($output->data as $k => $d) |
|
| 1240 | 1240 | { |
| 1241 | 1241 | $profile_image = $oMemberModel->getProfileImage($d->member_srl); |
| 1242 | 1242 | $output->data[$k]->src = $profile_image->src; |
| 1243 | 1243 | } |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - $this->add('voted_member_list',$output->data); |
|
| 1246 | + $this->add('voted_member_list', $output->data); |
|
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | /** |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | function getStatusNameList() |
| 1254 | 1254 | { |
| 1255 | 1255 | global $lang; |
| 1256 | - if(!isset($lang->status_name_list)) |
|
| 1256 | + if (!isset($lang->status_name_list)) |
|
| 1257 | 1257 | return array_flip($this->getStatusList()); |
| 1258 | 1258 | else return $lang->status_name_list; |
| 1259 | 1259 | } |
@@ -1268,7 +1268,7 @@ discard block |
||
| 1268 | 1268 | { |
| 1269 | 1269 | $sortIndex = $obj->sort_index; |
| 1270 | 1270 | $isExtraVars = false; |
| 1271 | - if(!in_array($sortIndex, array('list_order','regdate','last_update','update_order','readed_count','voted_count','blamed_count','comment_count','trackback_count','uploaded_count','title','category_srl'))) |
|
| 1271 | + if (!in_array($sortIndex, array('list_order', 'regdate', 'last_update', 'update_order', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'title', 'category_srl'))) |
|
| 1272 | 1272 | { |
| 1273 | 1273 | // get module_srl extra_vars list |
| 1274 | 1274 | if ($load_extra_vars) |
@@ -1283,11 +1283,11 @@ discard block |
||
| 1283 | 1283 | else |
| 1284 | 1284 | { |
| 1285 | 1285 | $check_array = array(); |
| 1286 | - foreach($extra_output->data as $val) |
|
| 1286 | + foreach ($extra_output->data as $val) |
|
| 1287 | 1287 | { |
| 1288 | 1288 | $check_array[] = $val->eid; |
| 1289 | 1289 | } |
| 1290 | - if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
| 1290 | + if (!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
| 1291 | 1291 | else $isExtraVars = true; |
| 1292 | 1292 | } |
| 1293 | 1293 | } |
@@ -1315,13 +1315,13 @@ discard block |
||
| 1315 | 1315 | { |
| 1316 | 1316 | // Variable check |
| 1317 | 1317 | $args = new stdClass(); |
| 1318 | - $args->category_srl = $searchOpt->category_srl?$searchOpt->category_srl:null; |
|
| 1318 | + $args->category_srl = $searchOpt->category_srl ? $searchOpt->category_srl : null; |
|
| 1319 | 1319 | $args->order_type = $searchOpt->order_type; |
| 1320 | - $args->page = $searchOpt->page?$searchOpt->page:1; |
|
| 1321 | - $args->list_count = $searchOpt->list_count?$searchOpt->list_count:20; |
|
| 1322 | - $args->page_count = $searchOpt->page_count?$searchOpt->page_count:10; |
|
| 1323 | - $args->start_date = $searchOpt->start_date?$searchOpt->start_date:null; |
|
| 1324 | - $args->end_date = $searchOpt->end_date?$searchOpt->end_date:null; |
|
| 1320 | + $args->page = $searchOpt->page ? $searchOpt->page : 1; |
|
| 1321 | + $args->list_count = $searchOpt->list_count ? $searchOpt->list_count : 20; |
|
| 1322 | + $args->page_count = $searchOpt->page_count ? $searchOpt->page_count : 10; |
|
| 1323 | + $args->start_date = $searchOpt->start_date ? $searchOpt->start_date : null; |
|
| 1324 | + $args->end_date = $searchOpt->end_date ? $searchOpt->end_date : null; |
|
| 1325 | 1325 | $args->member_srl = $searchOpt->member_srl; |
| 1326 | 1326 | |
| 1327 | 1327 | $logged_info = Context::get('logged_info'); |
@@ -1330,10 +1330,10 @@ discard block |
||
| 1330 | 1330 | |
| 1331 | 1331 | // Check the target and sequence alignment |
| 1332 | 1332 | $orderType = array('desc' => 1, 'asc' => 1); |
| 1333 | - if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
| 1333 | + if (!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
| 1334 | 1334 | |
| 1335 | 1335 | // If that came across mid module_srl instead of a direct module_srl guhaejum |
| 1336 | - if($searchOpt->mid) |
|
| 1336 | + if ($searchOpt->mid) |
|
| 1337 | 1337 | { |
| 1338 | 1338 | $oModuleModel = getModel('module'); |
| 1339 | 1339 | $args->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -1341,30 +1341,30 @@ discard block |
||
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | // Module_srl passed the array may be a check whether the array |
| 1344 | - if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1344 | + if (is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
| 1345 | 1345 | else $args->module_srl = $searchOpt->module_srl; |
| 1346 | 1346 | |
| 1347 | 1347 | // Except for the test module_srl |
| 1348 | - if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1348 | + if (is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
| 1349 | 1349 | else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
| 1350 | 1350 | |
| 1351 | 1351 | // only admin document list, temp document showing |
| 1352 | - if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
| 1352 | + if ($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
| 1353 | 1353 | else |
| 1354 | 1354 | { |
| 1355 | - if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
| 1355 | + if ($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
| 1356 | 1356 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
| 1357 | 1357 | else |
| 1358 | 1358 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | // Category is selected, further sub-categories until all conditions |
| 1362 | - if($args->category_srl) |
|
| 1362 | + if ($args->category_srl) |
|
| 1363 | 1363 | { |
| 1364 | 1364 | $category_list = $this->getCategoryList($args->module_srl); |
| 1365 | 1365 | $category_info = $category_list[$args->category_srl]; |
| 1366 | 1366 | $category_info->childs[] = $args->category_srl; |
| 1367 | - $args->category_srl = implode(',',$category_info->childs); |
|
| 1367 | + $args->category_srl = implode(',', $category_info->childs); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | // Used to specify the default query id (based on several search options to query id modified) |
@@ -1377,24 +1377,24 @@ discard block |
||
| 1377 | 1377 | $search_target = $searchOpt->search_target; |
| 1378 | 1378 | $search_keyword = $searchOpt->search_keyword; |
| 1379 | 1379 | |
| 1380 | - if($search_target && $search_keyword) |
|
| 1380 | + if ($search_target && $search_keyword) |
|
| 1381 | 1381 | { |
| 1382 | - switch($search_target) |
|
| 1382 | + switch ($search_target) |
|
| 1383 | 1383 | { |
| 1384 | 1384 | case 'title' : |
| 1385 | 1385 | case 'content' : |
| 1386 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1386 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1387 | 1387 | $args->{"s_".$search_target} = $search_keyword; |
| 1388 | 1388 | $use_division = true; |
| 1389 | 1389 | break; |
| 1390 | 1390 | case 'title_content' : |
| 1391 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1391 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1392 | 1392 | $args->s_title = $search_keyword; |
| 1393 | 1393 | $args->s_content = $search_keyword; |
| 1394 | 1394 | $use_division = true; |
| 1395 | 1395 | break; |
| 1396 | 1396 | case 'user_id' : |
| 1397 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1397 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1398 | 1398 | $args->s_user_id = $search_keyword; |
| 1399 | 1399 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1400 | 1400 | break; |
@@ -1402,18 +1402,18 @@ discard block |
||
| 1402 | 1402 | case 'nick_name' : |
| 1403 | 1403 | case 'email_address' : |
| 1404 | 1404 | case 'homepage' : |
| 1405 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 1405 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 1406 | 1406 | $args->{"s_".$search_target} = $search_keyword; |
| 1407 | 1407 | break; |
| 1408 | 1408 | case 'is_notice' : |
| 1409 | - if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
| 1410 | - elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
| 1409 | + if ($search_keyword == 'N') $args->{"s_".$search_target} = 'N'; |
|
| 1410 | + elseif ($search_keyword == 'Y') $args->{"s_".$search_target} = 'Y'; |
|
| 1411 | 1411 | else $args->{"s_".$search_target} = ''; |
| 1412 | 1412 | break; |
| 1413 | 1413 | case 'is_secret' : |
| 1414 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1415 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1416 | - elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1414 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
| 1415 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
| 1416 | + elseif ($search_keyword == 'temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
| 1417 | 1417 | break; |
| 1418 | 1418 | case 'member_srl' : |
| 1419 | 1419 | case 'readed_count' : |
@@ -1421,10 +1421,10 @@ discard block |
||
| 1421 | 1421 | case 'comment_count' : |
| 1422 | 1422 | case 'trackback_count' : |
| 1423 | 1423 | case 'uploaded_count' : |
| 1424 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
| 1424 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
| 1425 | 1425 | break; |
| 1426 | 1426 | case 'blamed_count' : |
| 1427 | - $args->{"s_".$search_target} = (int)$search_keyword * -1; |
|
| 1427 | + $args->{"s_".$search_target} = (int) $search_keyword * -1; |
|
| 1428 | 1428 | break; |
| 1429 | 1429 | case 'regdate' : |
| 1430 | 1430 | case 'last_update' : |
@@ -1437,7 +1437,7 @@ discard block |
||
| 1437 | 1437 | $use_division = true; |
| 1438 | 1438 | break; |
| 1439 | 1439 | case 'tag' : |
| 1440 | - $args->s_tags = str_replace(' ','%',$search_keyword); |
|
| 1440 | + $args->s_tags = str_replace(' ', '%', $search_keyword); |
|
| 1441 | 1441 | $query_id = 'document.getDocumentListWithinTag'; |
| 1442 | 1442 | break; |
| 1443 | 1443 | case 'extra_vars': |
@@ -1445,9 +1445,9 @@ discard block |
||
| 1445 | 1445 | $query_id = 'document.getDocumentListWithinExtraVars'; |
| 1446 | 1446 | break; |
| 1447 | 1447 | default : |
| 1448 | - if(strpos($search_target,'extra_vars')!==false) { |
|
| 1448 | + if (strpos($search_target, 'extra_vars') !== false) { |
|
| 1449 | 1449 | $args->var_idx = substr($search_target, strlen('extra_vars')); |
| 1450 | - $args->var_value = str_replace(' ','%',$search_keyword); |
|
| 1450 | + $args->var_value = str_replace(' ', '%', $search_keyword); |
|
| 1451 | 1451 | $args->sort_index = 'documents.'.$args->sort_index; |
| 1452 | 1452 | $query_id = 'document.getDocumentListWithExtraVars'; |
| 1453 | 1453 | } |
@@ -1464,18 +1464,18 @@ discard block |
||
| 1464 | 1464 | /** |
| 1465 | 1465 | * list_order asc sort of division that can be used only when |
| 1466 | 1466 | */ |
| 1467 | - if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
| 1467 | + if ($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
| 1468 | 1468 | |
| 1469 | 1469 | /** |
| 1470 | 1470 | * If it is true, use_division changed to use the document division |
| 1471 | 1471 | */ |
| 1472 | - if($use_division) |
|
| 1472 | + if ($use_division) |
|
| 1473 | 1473 | { |
| 1474 | 1474 | // Division begins |
| 1475 | - $division = (int)Context::get('division'); |
|
| 1475 | + $division = (int) Context::get('division'); |
|
| 1476 | 1476 | |
| 1477 | 1477 | // order by list_order and (module_srl===0 or module_srl may count), therefore case table full scan |
| 1478 | - if($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
| 1478 | + if ($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
| 1479 | 1479 | { |
| 1480 | 1480 | $listSqlID = 'document.getDocumentListUseIndex'; |
| 1481 | 1481 | $divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
@@ -1487,7 +1487,7 @@ discard block |
||
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | 1489 | // If you do not value the best division top |
| 1490 | - if(!$division) |
|
| 1490 | + if (!$division) |
|
| 1491 | 1491 | { |
| 1492 | 1492 | $division_args = new stdClass(); |
| 1493 | 1493 | $division_args->module_srl = $args->module_srl; |
@@ -1498,7 +1498,7 @@ discard block |
||
| 1498 | 1498 | $division_args->statusList = $args->statusList; |
| 1499 | 1499 | |
| 1500 | 1500 | $output = executeQuery($divisionSqlID, $division_args, array('list_order')); |
| 1501 | - if($output->data) |
|
| 1501 | + if ($output->data) |
|
| 1502 | 1502 | { |
| 1503 | 1503 | $item = array_pop($output->data); |
| 1504 | 1504 | $division = $item->list_order; |
@@ -1507,10 +1507,10 @@ discard block |
||
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | 1509 | // The last division |
| 1510 | - $last_division = (int)Context::get('last_division'); |
|
| 1510 | + $last_division = (int) Context::get('last_division'); |
|
| 1511 | 1511 | |
| 1512 | 1512 | // Division after division from the 5000 value of the specified Wanted |
| 1513 | - if(!$last_division) |
|
| 1513 | + if (!$last_division) |
|
| 1514 | 1514 | { |
| 1515 | 1515 | $last_division_args = new stdClass(); |
| 1516 | 1516 | $last_division_args->module_srl = $args->module_srl; |
@@ -1522,7 +1522,7 @@ discard block |
||
| 1522 | 1522 | $last_division_args->page = 5001; |
| 1523 | 1523 | |
| 1524 | 1524 | $output = executeQuery($divisionSqlID, $last_division_args, array('list_order')); |
| 1525 | - if($output->data) |
|
| 1525 | + if ($output->data) |
|
| 1526 | 1526 | { |
| 1527 | 1527 | $item = array_pop($output->data); |
| 1528 | 1528 | $last_division = $item->list_order; |
@@ -1530,14 +1530,14 @@ discard block |
||
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | // Make sure that after last_division article |
| 1533 | - if($last_division) |
|
| 1533 | + if ($last_division) |
|
| 1534 | 1534 | { |
| 1535 | 1535 | $last_division_args = new stdClass(); |
| 1536 | 1536 | $last_division_args->module_srl = $args->module_srl; |
| 1537 | 1537 | $last_division_args->exclude_module_srl = $args->exclude_module_srl; |
| 1538 | 1538 | $last_division_args->list_order = $last_division; |
| 1539 | 1539 | $output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
| 1540 | - if($output->data->count<1) $last_division = null; |
|
| 1540 | + if ($output->data->count < 1) $last_division = null; |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | $args->division = $division; |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | * @param int $count |
| 1571 | 1571 | * @return object |
| 1572 | 1572 | */ |
| 1573 | - function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0 ) |
|
| 1573 | + function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0) |
|
| 1574 | 1574 | { |
| 1575 | 1575 | $args = new stdClass(); |
| 1576 | 1576 | $args->member_srl = $member_srl; |
@@ -1578,8 +1578,8 @@ discard block |
||
| 1578 | 1578 | $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
| 1579 | 1579 | $document_list = $output->data; |
| 1580 | 1580 | |
| 1581 | - if(!$document_list) return array(); |
|
| 1582 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
| 1581 | + if (!$document_list) return array(); |
|
| 1582 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
| 1583 | 1583 | |
| 1584 | 1584 | return $document_list; |
| 1585 | 1585 | } |
@@ -238,6 +238,7 @@ |
||
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | 240 | * @brief AutoSave |
| 241 | + * @param stdClass $args |
|
| 241 | 242 | */ |
| 242 | 243 | function doSaveDoc($args) |
| 243 | 244 | { |
@@ -47,28 +47,28 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $component = Context::get('component'); |
| 49 | 49 | $method = Context::get('method'); |
| 50 | - if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 50 | + if (!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 51 | 51 | |
| 52 | 52 | $oEditorModel = getModel('editor'); |
| 53 | 53 | $oComponent = &$oEditorModel->getComponentObject($component); |
| 54 | - if(!$oComponent->toBool()) return $oComponent; |
|
| 54 | + if (!$oComponent->toBool()) return $oComponent; |
|
| 55 | 55 | |
| 56 | - if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 56 | + if (!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 57 | 57 | |
| 58 | 58 | //$output = call_user_method($method, $oComponent); |
| 59 | 59 | //$output = call_user_func(array($oComponent, $method)); |
| 60 | - if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
| 61 | - else return new Object(-1,sprintf('%s method is not exists', $method)); |
|
| 60 | + if (method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
| 61 | + else return new Object(-1, sprintf('%s method is not exists', $method)); |
|
| 62 | 62 | |
| 63 | - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; |
|
| 63 | + if ((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; |
|
| 64 | 64 | |
| 65 | 65 | $this->setError($oComponent->getError()); |
| 66 | 66 | $this->setMessage($oComponent->getMessage()); |
| 67 | 67 | |
| 68 | 68 | $vars = $oComponent->getVariables(); |
| 69 | - if(count($vars)) |
|
| 69 | + if (count($vars)) |
|
| 70 | 70 | { |
| 71 | - foreach($vars as $key => $val) |
|
| 71 | + foreach ($vars as $key => $val) |
|
| 72 | 72 | { |
| 73 | 73 | $this->add($key, $val); |
| 74 | 74 | } |
@@ -86,18 +86,18 @@ discard block |
||
| 86 | 86 | $module_srl = array(); |
| 87 | 87 | $oModuleModel = getModel('module'); |
| 88 | 88 | |
| 89 | - foreach($target_module_srl as $srl) |
|
| 89 | + foreach ($target_module_srl as $srl) |
|
| 90 | 90 | { |
| 91 | - if(!$srl) continue; |
|
| 91 | + if (!$srl) continue; |
|
| 92 | 92 | |
| 93 | 93 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($srl); |
| 94 | - if(!$module_info->module_srl) |
|
| 94 | + if (!$module_info->module_srl) |
|
| 95 | 95 | { |
| 96 | 96 | return new Object(-1, 'msg_invalid_request'); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $module_grant = $oModuleModel->getGrant($module_info, $logged_info); |
| 100 | - if(!$module_grant->manager) |
|
| 100 | + if (!$module_grant->manager) |
|
| 101 | 101 | { |
| 102 | 102 | return new Object(-1, 'msg_not_permitted'); |
| 103 | 103 | } |
@@ -111,32 +111,32 @@ discard block |
||
| 111 | 111 | $editor_config->content_style = Context::get('content_style'); |
| 112 | 112 | $editor_config->comment_content_style = Context::get('comment_content_style'); |
| 113 | 113 | $editor_config->content_font = Context::get('content_font'); |
| 114 | - if($editor_config->content_font) |
|
| 114 | + if ($editor_config->content_font) |
|
| 115 | 115 | { |
| 116 | 116 | $font_list = array(); |
| 117 | - $fonts = explode(',',$editor_config->content_font); |
|
| 118 | - for($i=0,$c=count($fonts);$i<$c;$i++) |
|
| 117 | + $fonts = explode(',', $editor_config->content_font); |
|
| 118 | + for ($i = 0, $c = count($fonts); $i < $c; $i++) |
|
| 119 | 119 | { |
| 120 | - $font = trim(str_replace(array('"','\''),'',$fonts[$i])); |
|
| 121 | - if(!$font) continue; |
|
| 120 | + $font = trim(str_replace(array('"', '\''), '', $fonts[$i])); |
|
| 121 | + if (!$font) continue; |
|
| 122 | 122 | $font_list[] = $font; |
| 123 | 123 | } |
| 124 | - if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
| 124 | + if (count($font_list)) $editor_config->content_font = '"'.implode('","', $font_list).'"'; |
|
| 125 | 125 | } |
| 126 | 126 | $editor_config->content_font_size = Context::get('content_font_size'); |
| 127 | 127 | $editor_config->sel_editor_colorset = Context::get('sel_editor_colorset'); |
| 128 | 128 | $editor_config->sel_comment_editor_colorset = Context::get('sel_comment_editor_colorset'); |
| 129 | 129 | |
| 130 | - $grants = array('enable_html_grant','enable_comment_html_grant','upload_file_grant','comment_upload_file_grant','enable_default_component_grant','enable_comment_default_component_grant','enable_component_grant','enable_comment_component_grant'); |
|
| 130 | + $grants = array('enable_html_grant', 'enable_comment_html_grant', 'upload_file_grant', 'comment_upload_file_grant', 'enable_default_component_grant', 'enable_comment_default_component_grant', 'enable_component_grant', 'enable_comment_component_grant'); |
|
| 131 | 131 | |
| 132 | - foreach($grants as $key) |
|
| 132 | + foreach ($grants as $key) |
|
| 133 | 133 | { |
| 134 | 134 | $grant = Context::get($key); |
| 135 | - if(!$grant) |
|
| 135 | + if (!$grant) |
|
| 136 | 136 | { |
| 137 | 137 | $editor_config->{$key} = array(); |
| 138 | 138 | } |
| 139 | - else if(is_array($grant)) |
|
| 139 | + else if (is_array($grant)) |
|
| 140 | 140 | { |
| 141 | 141 | $editor_config->{$key} = $grant; |
| 142 | 142 | } |
@@ -146,13 +146,13 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $editor_config->editor_height = (int)Context::get('editor_height'); |
|
| 150 | - $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); |
|
| 149 | + $editor_config->editor_height = (int) Context::get('editor_height'); |
|
| 150 | + $editor_config->comment_editor_height = (int) Context::get('comment_editor_height'); |
|
| 151 | 151 | $editor_config->enable_autosave = Context::get('enable_autosave'); |
| 152 | - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
| 152 | + if ($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
| 153 | 153 | |
| 154 | 154 | $oModuleController = getController('module'); |
| 155 | - foreach($module_srl as $srl) |
|
| 155 | + foreach ($module_srl as $srl) |
|
| 156 | 156 | { |
| 157 | 157 | $oModuleController->insertModulePartConfig('editor', $srl, $editor_config); |
| 158 | 158 | } |
@@ -169,31 +169,31 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | function triggerEditorComponentCompile(&$content) |
| 171 | 171 | { |
| 172 | - if(Context::getResponseMethod()!='HTML') return new Object(); |
|
| 172 | + if (Context::getResponseMethod() != 'HTML') return new Object(); |
|
| 173 | 173 | |
| 174 | 174 | $module_info = Context::get('module_info'); |
| 175 | 175 | $module_srl = $module_info->module_srl; |
| 176 | - if($module_srl) |
|
| 176 | + if ($module_srl) |
|
| 177 | 177 | { |
| 178 | 178 | $oEditorModel = getModel('editor'); |
| 179 | 179 | $editor_config = $oEditorModel->getEditorConfig($module_srl); |
| 180 | 180 | $content_style = $editor_config->content_style; |
| 181 | - if($content_style) |
|
| 181 | + if ($content_style) |
|
| 182 | 182 | { |
| 183 | - $path = _XE_PATH_ . 'modules/editor/styles/'.$content_style.'/'; |
|
| 184 | - if(is_dir($path) && file_exists($path . 'style.ini')) |
|
| 183 | + $path = _XE_PATH_.'modules/editor/styles/'.$content_style.'/'; |
|
| 184 | + if (is_dir($path) && file_exists($path.'style.ini')) |
|
| 185 | 185 | { |
| 186 | 186 | $ini = file($path.'style.ini'); |
| 187 | - for($i = 0, $c = count($ini); $i < $c; $i++) |
|
| 187 | + for ($i = 0, $c = count($ini); $i < $c; $i++) |
|
| 188 | 188 | { |
| 189 | 189 | $file = trim($ini[$i]); |
| 190 | - if(!$file) continue; |
|
| 190 | + if (!$file) continue; |
|
| 191 | 191 | |
| 192 | - if(substr_compare($file, '.css', -4) === 0) |
|
| 192 | + if (substr_compare($file, '.css', -4) === 0) |
|
| 193 | 193 | { |
| 194 | 194 | Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
| 195 | 195 | } |
| 196 | - elseif(substr_compare($file, '.js', -3) === 0) |
|
| 196 | + elseif (substr_compare($file, '.js', -3) === 0) |
|
| 197 | 197 | { |
| 198 | 198 | Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
| 199 | 199 | } |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | $content_font = $editor_config->content_font; |
| 204 | 204 | $content_font_size = $editor_config->content_font_size; |
| 205 | - if($content_font || $content_font_size) |
|
| 205 | + if ($content_font || $content_font_size) |
|
| 206 | 206 | { |
| 207 | 207 | $buff = array(); |
| 208 | 208 | $buff[] = '<style> .xe_content { '; |
| 209 | - if($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
| 210 | - if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
| 209 | + if ($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
| 210 | + if ($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
| 211 | 211 | $buff[] = ' }</style>'; |
| 212 | 212 | Context::addHtmlHeader(implode('', $buff)); |
| 213 | 213 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | function transComponent($content) |
| 224 | 224 | { |
| 225 | - $content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this,'transEditorComponent'), $content); |
|
| 225 | + $content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this, 'transEditorComponent'), $content); |
|
| 226 | 226 | return $content; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -237,19 +237,19 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $xml_obj = new stdClass; |
| 239 | 239 | $xml_obj->attrs = new stdClass; |
| 240 | - for($i=0,$c=count($m[0]);$i<$c;$i++) |
|
| 240 | + for ($i = 0, $c = count($m[0]); $i < $c; $i++) |
|
| 241 | 241 | { |
| 242 | - if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
| 242 | + if (!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
| 243 | 243 | $xml_obj->attrs->{$m[1][$i]} = $m[2][$i]; |
| 244 | 244 | } |
| 245 | 245 | $xml_obj->body = $match[4]; |
| 246 | 246 | |
| 247 | - if(!$xml_obj->attrs->editor_component) return $match[0]; |
|
| 247 | + if (!$xml_obj->attrs->editor_component) return $match[0]; |
|
| 248 | 248 | |
| 249 | 249 | // Get converted codes by using component::transHTML() |
| 250 | 250 | $oEditorModel = getModel('editor'); |
| 251 | 251 | $oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0); |
| 252 | - if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0]; |
|
| 252 | + if (!is_object($oComponent) || !method_exists($oComponent, 'transHTML')) return $match[0]; |
|
| 253 | 253 | |
| 254 | 254 | return $oComponent->transHTML($xml_obj); |
| 255 | 255 | } |
@@ -259,8 +259,8 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | function doSaveDoc($args) |
| 261 | 261 | { |
| 262 | - if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 263 | - if(Context::get('is_logged')) |
|
| 262 | + if (!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 263 | + if (Context::get('is_logged')) |
|
| 264 | 264 | { |
| 265 | 265 | $logged_info = Context::get('logged_info'); |
| 266 | 266 | $args->member_srl = $logged_info->member_srl; |
@@ -271,11 +271,11 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // Get the current module if module_srl doesn't exist |
| 274 | - if(!$args->module_srl) |
|
| 274 | + if (!$args->module_srl) |
|
| 275 | 275 | { |
| 276 | 276 | $args->module_srl = Context::get('module_srl'); |
| 277 | 277 | } |
| 278 | - if(!$args->module_srl) |
|
| 278 | + if (!$args->module_srl) |
|
| 279 | 279 | { |
| 280 | 280 | $current_module_info = Context::get('current_module_info'); |
| 281 | 281 | $args->module_srl = $current_module_info->module_srl; |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | function deleteSavedDoc($mode = false) |
| 322 | 322 | { |
| 323 | 323 | $args = new stdClass(); |
| 324 | - if(Context::get('is_logged')) |
|
| 324 | + if (Context::get('is_logged')) |
|
| 325 | 325 | { |
| 326 | 326 | $logged_info = Context::get('logged_info'); |
| 327 | 327 | $args->member_srl = $logged_info->member_srl; |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | $args->module_srl = Context::get('module_srl'); |
| 334 | 334 | // Get the current module if module_srl doesn't exist |
| 335 | - if(!$args->module_srl) |
|
| 335 | + if (!$args->module_srl) |
|
| 336 | 336 | { |
| 337 | 337 | $current_module_info = Context::get('current_module_info'); |
| 338 | 338 | $args->module_srl = $current_module_info->module_srl; |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | // Check if the auto-saved document already exists |
| 341 | 341 | $output = executeQuery('editor.getSavedDocument', $args); |
| 342 | 342 | $saved_doc = $output->data; |
| 343 | - if(!$saved_doc) return; |
|
| 343 | + if (!$saved_doc) return; |
|
| 344 | 344 | |
| 345 | 345 | $oDocumentModel = getModel('document'); |
| 346 | 346 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
| 347 | - if(!$oSaved->isExists()) |
|
| 347 | + if (!$oSaved->isExists()) |
|
| 348 | 348 | { |
| 349 | - if($mode) |
|
| 349 | + if ($mode) |
|
| 350 | 350 | { |
| 351 | 351 | $output = executeQuery('editor.getSavedDocument', $args); |
| 352 | 352 | $output = ModuleHandler::triggerCall('editor.deleteSavedDoc', 'after', $saved_doc); |
@@ -374,9 +374,9 @@ discard block |
||
| 374 | 374 | $oEditorModel = getModel('editor'); |
| 375 | 375 | $args = new stdClass; |
| 376 | 376 | |
| 377 | - if($filter_enabled) $args->enabled = "Y"; |
|
| 377 | + if ($filter_enabled) $args->enabled = "Y"; |
|
| 378 | 378 | |
| 379 | - if($site_srl) |
|
| 379 | + if ($site_srl) |
|
| 380 | 380 | { |
| 381 | 381 | $args->site_srl = $site_srl; |
| 382 | 382 | $output = executeQuery('editor.getSiteComponentList', $args); |
@@ -389,10 +389,10 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | // Get information about log-in status and its group |
| 391 | 391 | $is_logged = Context::get('is_logged'); |
| 392 | - if($is_logged) |
|
| 392 | + if ($is_logged) |
|
| 393 | 393 | { |
| 394 | 394 | $logged_info = Context::get('logged_info'); |
| 395 | - if($logged_info->group_list && is_array($logged_info->group_list)) |
|
| 395 | + if ($logged_info->group_list && is_array($logged_info->group_list)) |
|
| 396 | 396 | { |
| 397 | 397 | $group_list = array_keys($logged_info->group_list); |
| 398 | 398 | } |
@@ -400,30 +400,30 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | // Get xml information for looping DB list |
| 403 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
| 403 | + if (!is_array($db_list)) $db_list = array($db_list); |
|
| 404 | 404 | $component_list = new stdClass(); |
| 405 | - foreach($db_list as $component) |
|
| 405 | + foreach ($db_list as $component) |
|
| 406 | 406 | { |
| 407 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
| 407 | + if (in_array($component->component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
| 408 | 408 | |
| 409 | 409 | $component_name = $component->component_name; |
| 410 | - if(!$component_name) continue; |
|
| 410 | + if (!$component_name) continue; |
|
| 411 | 411 | |
| 412 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
| 412 | + if (!in_array($component_name, $downloaded_list)) continue; |
|
| 413 | 413 | |
| 414 | 414 | unset($xml_info); |
| 415 | 415 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
| 416 | 416 | $xml_info->enabled = $component->enabled; |
| 417 | 417 | |
| 418 | - if($component->extra_vars) |
|
| 418 | + if ($component->extra_vars) |
|
| 419 | 419 | { |
| 420 | 420 | $extra_vars = unserialize($component->extra_vars); |
| 421 | - if($extra_vars->target_group) |
|
| 421 | + if ($extra_vars->target_group) |
|
| 422 | 422 | { |
| 423 | 423 | $xml_info->target_group = $extra_vars->target_group; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
| 426 | + if ($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
| 427 | 427 | { |
| 428 | 428 | $xml_info->mid_list = $extra_vars->mid_list; |
| 429 | 429 | } |
@@ -450,9 +450,9 @@ discard block |
||
| 450 | 450 | if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue; |
| 451 | 451 | }*/ |
| 452 | 452 | // Check the configuration of the editor component |
| 453 | - if($xml_info->extra_vars) |
|
| 453 | + if ($xml_info->extra_vars) |
|
| 454 | 454 | { |
| 455 | - foreach($xml_info->extra_vars as $key => $val) |
|
| 455 | + foreach ($xml_info->extra_vars as $key => $val) |
|
| 456 | 456 | { |
| 457 | 457 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
| 458 | 458 | } |
@@ -463,25 +463,25 @@ discard block |
||
| 463 | 463 | // Get buttons, icons, images |
| 464 | 464 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
| 465 | 465 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
| 466 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
| 467 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
| 466 | + if (file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
| 467 | + if (file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // Return if it checks enabled only |
| 471 | - if($filter_enabled) |
|
| 471 | + if ($filter_enabled) |
|
| 472 | 472 | { |
| 473 | 473 | $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); |
| 474 | - $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list))); |
|
| 474 | + $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); |
|
| 475 | 475 | FileHandler::writeFile($cache_file, $buff); |
| 476 | 476 | return $component_list; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | // Get xml_info of downloaded list |
| 480 | - foreach($downloaded_list as $component_name) |
|
| 480 | + foreach ($downloaded_list as $component_name) |
|
| 481 | 481 | { |
| 482 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
| 482 | + if (in_array($component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
| 483 | 483 | // Pass if configured |
| 484 | - if($component_list->{$component_name}) continue; |
|
| 484 | + if ($component_list->{$component_name}) continue; |
|
| 485 | 485 | // Insert data into the DB |
| 486 | 486 | $oEditorController = getAdminController('editor'); |
| 487 | 487 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); |
| 497 | - $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list))); |
|
| 497 | + $buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); |
|
| 498 | 498 | FileHandler::writeFile($cache_file, $buff); |
| 499 | 499 | |
| 500 | 500 | return $component_list; |
@@ -516,9 +516,9 @@ discard block |
||
| 516 | 516 | $editorConfig = $oModuleModel->getModulePartConfig('editor', $obj->originModuleSrl); |
| 517 | 517 | |
| 518 | 518 | $oModuleController = getController('module'); |
| 519 | - if(is_array($obj->moduleSrlList)) |
|
| 519 | + if (is_array($obj->moduleSrlList)) |
|
| 520 | 520 | { |
| 521 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 521 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 522 | 522 | { |
| 523 | 523 | $oModuleController->insertModulePartConfig('editor', $moduleSrl, $editorConfig); |
| 524 | 524 | } |
@@ -47,20 +47,31 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $component = Context::get('component'); |
| 49 | 49 | $method = Context::get('method'); |
| 50 | - if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 50 | + if(!$component) { |
|
| 51 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 52 | + } |
|
| 51 | 53 | |
| 52 | 54 | $oEditorModel = getModel('editor'); |
| 53 | 55 | $oComponent = &$oEditorModel->getComponentObject($component); |
| 54 | - if(!$oComponent->toBool()) return $oComponent; |
|
| 56 | + if(!$oComponent->toBool()) { |
|
| 57 | + return $oComponent; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | - if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 60 | + if(!method_exists($oComponent, $method)) { |
|
| 61 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 62 | + } |
|
| 57 | 63 | |
| 58 | 64 | //$output = call_user_method($method, $oComponent); |
| 59 | 65 | //$output = call_user_func(array($oComponent, $method)); |
| 60 | - if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
| 61 | - else return new Object(-1,sprintf('%s method is not exists', $method)); |
|
| 66 | + if(method_exists($oComponent, $method)) { |
|
| 67 | + $output = $oComponent->{$method}(); |
|
| 68 | + } else { |
|
| 69 | + return new Object(-1,sprintf('%s method is not exists', $method)); |
|
| 70 | + } |
|
| 62 | 71 | |
| 63 | - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; |
|
| 72 | + if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) { |
|
| 73 | + return $output; |
|
| 74 | + } |
|
| 64 | 75 | |
| 65 | 76 | $this->setError($oComponent->getError()); |
| 66 | 77 | $this->setMessage($oComponent->getMessage()); |
@@ -88,7 +99,9 @@ discard block |
||
| 88 | 99 | |
| 89 | 100 | foreach($target_module_srl as $srl) |
| 90 | 101 | { |
| 91 | - if(!$srl) continue; |
|
| 102 | + if(!$srl) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 92 | 105 | |
| 93 | 106 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($srl); |
| 94 | 107 | if(!$module_info->module_srl) |
@@ -118,10 +131,14 @@ discard block |
||
| 118 | 131 | for($i=0,$c=count($fonts);$i<$c;$i++) |
| 119 | 132 | { |
| 120 | 133 | $font = trim(str_replace(array('"','\''),'',$fonts[$i])); |
| 121 | - if(!$font) continue; |
|
| 134 | + if(!$font) { |
|
| 135 | + continue; |
|
| 136 | + } |
|
| 122 | 137 | $font_list[] = $font; |
| 123 | 138 | } |
| 124 | - if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
| 139 | + if(count($font_list)) { |
|
| 140 | + $editor_config->content_font = '"'.implode('","',$font_list).'"'; |
|
| 141 | + } |
|
| 125 | 142 | } |
| 126 | 143 | $editor_config->content_font_size = Context::get('content_font_size'); |
| 127 | 144 | $editor_config->sel_editor_colorset = Context::get('sel_editor_colorset'); |
@@ -135,12 +152,10 @@ discard block |
||
| 135 | 152 | if(!$grant) |
| 136 | 153 | { |
| 137 | 154 | $editor_config->{$key} = array(); |
| 138 | - } |
|
| 139 | - else if(is_array($grant)) |
|
| 155 | + } else if(is_array($grant)) |
|
| 140 | 156 | { |
| 141 | 157 | $editor_config->{$key} = $grant; |
| 142 | - } |
|
| 143 | - else |
|
| 158 | + } else |
|
| 144 | 159 | { |
| 145 | 160 | $editor_config->{$key} = explode('|@|', $grant); |
| 146 | 161 | } |
@@ -149,7 +164,9 @@ discard block |
||
| 149 | 164 | $editor_config->editor_height = (int)Context::get('editor_height'); |
| 150 | 165 | $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); |
| 151 | 166 | $editor_config->enable_autosave = Context::get('enable_autosave'); |
| 152 | - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; |
|
| 167 | + if($editor_config->enable_autosave != 'Y') { |
|
| 168 | + $editor_config->enable_autosave = 'N'; |
|
| 169 | + } |
|
| 153 | 170 | |
| 154 | 171 | $oModuleController = getController('module'); |
| 155 | 172 | foreach($module_srl as $srl) |
@@ -169,7 +186,9 @@ discard block |
||
| 169 | 186 | */ |
| 170 | 187 | function triggerEditorComponentCompile(&$content) |
| 171 | 188 | { |
| 172 | - if(Context::getResponseMethod()!='HTML') return new Object(); |
|
| 189 | + if(Context::getResponseMethod()!='HTML') { |
|
| 190 | + return new Object(); |
|
| 191 | + } |
|
| 173 | 192 | |
| 174 | 193 | $module_info = Context::get('module_info'); |
| 175 | 194 | $module_srl = $module_info->module_srl; |
@@ -187,13 +206,14 @@ discard block |
||
| 187 | 206 | for($i = 0, $c = count($ini); $i < $c; $i++) |
| 188 | 207 | { |
| 189 | 208 | $file = trim($ini[$i]); |
| 190 | - if(!$file) continue; |
|
| 209 | + if(!$file) { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 191 | 212 | |
| 192 | 213 | if(substr_compare($file, '.css', -4) === 0) |
| 193 | 214 | { |
| 194 | 215 | Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
| 195 | - } |
|
| 196 | - elseif(substr_compare($file, '.js', -3) === 0) |
|
| 216 | + } elseif(substr_compare($file, '.js', -3) === 0) |
|
| 197 | 217 | { |
| 198 | 218 | Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false); |
| 199 | 219 | } |
@@ -206,8 +226,12 @@ discard block |
||
| 206 | 226 | { |
| 207 | 227 | $buff = array(); |
| 208 | 228 | $buff[] = '<style> .xe_content { '; |
| 209 | - if($content_font) $buff[] = 'font-family:'.$content_font.';'; |
|
| 210 | - if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';'; |
|
| 229 | + if($content_font) { |
|
| 230 | + $buff[] = 'font-family:'.$content_font.';'; |
|
| 231 | + } |
|
| 232 | + if($content_font_size) { |
|
| 233 | + $buff[] = 'font-size:'.$content_font_size.';'; |
|
| 234 | + } |
|
| 211 | 235 | $buff[] = ' }</style>'; |
| 212 | 236 | Context::addHtmlHeader(implode('', $buff)); |
| 213 | 237 | } |
@@ -239,17 +263,23 @@ discard block |
||
| 239 | 263 | $xml_obj->attrs = new stdClass; |
| 240 | 264 | for($i=0,$c=count($m[0]);$i<$c;$i++) |
| 241 | 265 | { |
| 242 | - if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass; |
|
| 266 | + if(!isset($xml_obj->attrs)) { |
|
| 267 | + $xml_obj->attrs = new stdClass; |
|
| 268 | + } |
|
| 243 | 269 | $xml_obj->attrs->{$m[1][$i]} = $m[2][$i]; |
| 244 | 270 | } |
| 245 | 271 | $xml_obj->body = $match[4]; |
| 246 | 272 | |
| 247 | - if(!$xml_obj->attrs->editor_component) return $match[0]; |
|
| 273 | + if(!$xml_obj->attrs->editor_component) { |
|
| 274 | + return $match[0]; |
|
| 275 | + } |
|
| 248 | 276 | |
| 249 | 277 | // Get converted codes by using component::transHTML() |
| 250 | 278 | $oEditorModel = getModel('editor'); |
| 251 | 279 | $oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0); |
| 252 | - if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0]; |
|
| 280 | + if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) { |
|
| 281 | + return $match[0]; |
|
| 282 | + } |
|
| 253 | 283 | |
| 254 | 284 | return $oComponent->transHTML($xml_obj); |
| 255 | 285 | } |
@@ -259,13 +289,14 @@ discard block |
||
| 259 | 289 | */ |
| 260 | 290 | function doSaveDoc($args) |
| 261 | 291 | { |
| 262 | - if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 292 | + if(!$args->document_srl) { |
|
| 293 | + $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 294 | + } |
|
| 263 | 295 | if(Context::get('is_logged')) |
| 264 | 296 | { |
| 265 | 297 | $logged_info = Context::get('logged_info'); |
| 266 | 298 | $args->member_srl = $logged_info->member_srl; |
| 267 | - } |
|
| 268 | - else |
|
| 299 | + } else |
|
| 269 | 300 | { |
| 270 | 301 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 271 | 302 | } |
@@ -325,8 +356,7 @@ discard block |
||
| 325 | 356 | { |
| 326 | 357 | $logged_info = Context::get('logged_info'); |
| 327 | 358 | $args->member_srl = $logged_info->member_srl; |
| 328 | - } |
|
| 329 | - else |
|
| 359 | + } else |
|
| 330 | 360 | { |
| 331 | 361 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 332 | 362 | } |
@@ -340,7 +370,9 @@ discard block |
||
| 340 | 370 | // Check if the auto-saved document already exists |
| 341 | 371 | $output = executeQuery('editor.getSavedDocument', $args); |
| 342 | 372 | $saved_doc = $output->data; |
| 343 | - if(!$saved_doc) return; |
|
| 373 | + if(!$saved_doc) { |
|
| 374 | + return; |
|
| 375 | + } |
|
| 344 | 376 | |
| 345 | 377 | $oDocumentModel = getModel('document'); |
| 346 | 378 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
@@ -374,14 +406,17 @@ discard block |
||
| 374 | 406 | $oEditorModel = getModel('editor'); |
| 375 | 407 | $args = new stdClass; |
| 376 | 408 | |
| 377 | - if($filter_enabled) $args->enabled = "Y"; |
|
| 409 | + if($filter_enabled) { |
|
| 410 | + $args->enabled = "Y"; |
|
| 411 | + } |
|
| 378 | 412 | |
| 379 | 413 | if($site_srl) |
| 380 | 414 | { |
| 381 | 415 | $args->site_srl = $site_srl; |
| 382 | 416 | $output = executeQuery('editor.getSiteComponentList', $args); |
| 417 | + } else { |
|
| 418 | + $output = executeQuery('editor.getComponentList', $args); |
|
| 383 | 419 | } |
| 384 | - else $output = executeQuery('editor.getComponentList', $args); |
|
| 385 | 420 | $db_list = $output->data; |
| 386 | 421 | |
| 387 | 422 | // Get a list of files |
@@ -395,21 +430,30 @@ discard block |
||
| 395 | 430 | if($logged_info->group_list && is_array($logged_info->group_list)) |
| 396 | 431 | { |
| 397 | 432 | $group_list = array_keys($logged_info->group_list); |
| 433 | + } else { |
|
| 434 | + $group_list = array(); |
|
| 398 | 435 | } |
| 399 | - else $group_list = array(); |
|
| 400 | 436 | } |
| 401 | 437 | |
| 402 | 438 | // Get xml information for looping DB list |
| 403 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
| 439 | + if(!is_array($db_list)) { |
|
| 440 | + $db_list = array($db_list); |
|
| 441 | + } |
|
| 404 | 442 | $component_list = new stdClass(); |
| 405 | 443 | foreach($db_list as $component) |
| 406 | 444 | { |
| 407 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
| 445 | + if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
| 446 | + continue; |
|
| 447 | + } |
|
| 408 | 448 | |
| 409 | 449 | $component_name = $component->component_name; |
| 410 | - if(!$component_name) continue; |
|
| 450 | + if(!$component_name) { |
|
| 451 | + continue; |
|
| 452 | + } |
|
| 411 | 453 | |
| 412 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
| 454 | + if(!in_array($component_name, $downloaded_list)) { |
|
| 455 | + continue; |
|
| 456 | + } |
|
| 413 | 457 | |
| 414 | 458 | unset($xml_info); |
| 415 | 459 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
@@ -463,8 +507,12 @@ discard block |
||
| 463 | 507 | // Get buttons, icons, images |
| 464 | 508 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
| 465 | 509 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
| 466 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
| 467 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
| 510 | + if(file_exists($icon_file)) { |
|
| 511 | + $component_list->{$component_name}->icon = true; |
|
| 512 | + } |
|
| 513 | + if(file_exists($component_icon_file)) { |
|
| 514 | + $component_list->{$component_name}->component_icon = true; |
|
| 515 | + } |
|
| 468 | 516 | } |
| 469 | 517 | |
| 470 | 518 | // Return if it checks enabled only |
@@ -479,9 +527,13 @@ discard block |
||
| 479 | 527 | // Get xml_info of downloaded list |
| 480 | 528 | foreach($downloaded_list as $component_name) |
| 481 | 529 | { |
| 482 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
| 530 | + if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
| 531 | + continue; |
|
| 532 | + } |
|
| 483 | 533 | // Pass if configured |
| 484 | - if($component_list->{$component_name}) continue; |
|
| 534 | + if($component_list->{$component_name}) { |
|
| 535 | + continue; |
|
| 536 | + } |
|
| 485 | 537 | // Insert data into the DB |
| 486 | 538 | $oEditorController = getAdminController('editor'); |
| 487 | 539 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -113,6 +113,11 @@ discard block |
||
| 113 | 113 | Context::set('drComponentList',$drComponentInfo); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | + /** |
|
| 117 | + * @param string $drComponentName |
|
| 118 | + * |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 116 | 121 | function getDrComponentXmlInfo($drComponentName) |
| 117 | 122 | { |
| 118 | 123 | $lang_type = Context::getLangType(); |
@@ -191,6 +196,7 @@ discard block |
||
| 191 | 196 | * @brief Return the editor template |
| 192 | 197 | * You can call upload_target_srl when modifying content |
| 193 | 198 | * The upload_target_srl is used for a routine to check if an attachment exists |
| 199 | + * @param stdClass $option |
|
| 194 | 200 | */ |
| 195 | 201 | function getEditor($upload_target_srl = 0, $option = null) |
| 196 | 202 | { |
@@ -486,6 +492,8 @@ discard block |
||
| 486 | 492 | |
| 487 | 493 | /** |
| 488 | 494 | * @brief Get information which has been auto-saved |
| 495 | + * @param integer $upload_target_srl |
|
| 496 | + * @return string |
|
| 489 | 497 | */ |
| 490 | 498 | function getSavedDoc($upload_target_srl) |
| 491 | 499 | { |
@@ -586,6 +594,7 @@ discard block |
||
| 586 | 594 | |
| 587 | 595 | /** |
| 588 | 596 | * @brief Return a component list (DB Information included) |
| 597 | + * @return string |
|
| 589 | 598 | */ |
| 590 | 599 | function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) |
| 591 | 600 | { |
@@ -34,17 +34,37 @@ discard block |
||
| 34 | 34 | $oModuleModel = getModel('module'); |
| 35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
| 36 | 36 | |
| 37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
| 38 | - |
|
| 39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
| 40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
| 41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
| 42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
| 43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
| 44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
| 45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
| 46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
| 47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
| 37 | + if(!is_object($editor_config)) { |
|
| 38 | + $editor_config = new stdClass(); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if($editor_config->enable_autosave != 'N') { |
|
| 42 | + $editor_config->enable_autosave = 'Y'; |
|
| 43 | + } |
|
| 44 | + if(!is_array($editor_config->enable_html_grant)) { |
|
| 45 | + $editor_config->enable_html_grant = array(); |
|
| 46 | + } |
|
| 47 | + if(!is_array($editor_config->enable_comment_html_grant)) { |
|
| 48 | + $editor_config->enable_comment_html_grant = array(); |
|
| 49 | + } |
|
| 50 | + if(!is_array($editor_config->upload_file_grant)) { |
|
| 51 | + $editor_config->upload_file_grant = array(); |
|
| 52 | + } |
|
| 53 | + if(!is_array($editor_config->comment_upload_file_grant)) { |
|
| 54 | + $editor_config->comment_upload_file_grant = array(); |
|
| 55 | + } |
|
| 56 | + if(!is_array($editor_config->enable_default_component_grant)) { |
|
| 57 | + $editor_config->enable_default_component_grant = array(); |
|
| 58 | + } |
|
| 59 | + if(!is_array($editor_config->enable_comment_default_component_grant)) { |
|
| 60 | + $editor_config->enable_comment_default_component_grant = array(); |
|
| 61 | + } |
|
| 62 | + if(!is_array($editor_config->enable_component_grant)) { |
|
| 63 | + $editor_config->enable_component_grant = array(); |
|
| 64 | + } |
|
| 65 | + if(!is_array($editor_config->enable_comment_component_grant)) { |
|
| 66 | + $editor_config->enable_comment_component_grant= array(); |
|
| 67 | + } |
|
| 48 | 68 | |
| 49 | 69 | if(!$editor_config->editor_height) |
| 50 | 70 | { |
@@ -151,8 +171,11 @@ discard block |
||
| 151 | 171 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
| 152 | 172 | |
| 153 | 173 | // Author information |
| 154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
| 155 | - else $author_list = $xml_doc->component->author; |
|
| 174 | + if(!is_array($xml_doc->component->author)) { |
|
| 175 | + $author_list[] = $xml_doc->component->author; |
|
| 176 | + } else { |
|
| 177 | + $author_list = $xml_doc->component->author; |
|
| 178 | + } |
|
| 156 | 179 | |
| 157 | 180 | for($i=0; $i < count($author_list); $i++) |
| 158 | 181 | { |
@@ -165,7 +188,9 @@ discard block |
||
| 165 | 188 | $extra_vars = $xml_doc->component->extra_vars->var; |
| 166 | 189 | if($extra_vars) |
| 167 | 190 | { |
| 168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
| 191 | + if(!is_array($extra_vars)) { |
|
| 192 | + $extra_vars = array($extra_vars); |
|
| 193 | + } |
|
| 169 | 194 | foreach($extra_vars as $key => $val) |
| 170 | 195 | { |
| 171 | 196 | unset($obj); |
@@ -202,10 +227,15 @@ discard block |
||
| 202 | 227 | { |
| 203 | 228 | $option->editor_sequence = $upload_target_srl; |
| 204 | 229 | } |
| 205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
| 206 | - else $allow_fileupload = true; |
|
| 230 | + if(!$option->allow_fileupload) { |
|
| 231 | + $allow_fileupload = false; |
|
| 232 | + } else { |
|
| 233 | + $allow_fileupload = true; |
|
| 234 | + } |
|
| 207 | 235 | // content_style setting |
| 208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
| 236 | + if(!$option->content_style) { |
|
| 237 | + $option->content_style = 'ckeditor_light'; |
|
| 238 | + } |
|
| 209 | 239 | Context::set('content_style', $option->content_style); |
| 210 | 240 | Context::set('content_style_path', $this->module_path . 'styles/' . $option->content_style); |
| 211 | 241 | // Default font setting |
@@ -213,27 +243,47 @@ discard block |
||
| 213 | 243 | Context::set('content_font_size', $option->content_font_size); |
| 214 | 244 | |
| 215 | 245 | // Option setting to allow auto-save |
| 216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
| 217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
| 218 | - else $enable_autosave = true; |
|
| 246 | + if(!$option->enable_autosave) { |
|
| 247 | + $enable_autosave = false; |
|
| 248 | + } elseif(Context::get($option->primary_key_name)) { |
|
| 249 | + $enable_autosave = false; |
|
| 250 | + } else { |
|
| 251 | + $enable_autosave = true; |
|
| 252 | + } |
|
| 219 | 253 | // Option setting to allow the default editor component |
| 220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
| 221 | - else $enable_default_component = true; |
|
| 254 | + if(!$option->enable_default_component) { |
|
| 255 | + $enable_default_component = false; |
|
| 256 | + } else { |
|
| 257 | + $enable_default_component = true; |
|
| 258 | + } |
|
| 222 | 259 | // Option setting to allow other extended components |
| 223 | - if(!$option->enable_component) $enable_component = false; |
|
| 224 | - else $enable_component = true; |
|
| 260 | + if(!$option->enable_component) { |
|
| 261 | + $enable_component = false; |
|
| 262 | + } else { |
|
| 263 | + $enable_component = true; |
|
| 264 | + } |
|
| 225 | 265 | // Setting for html-mode |
| 226 | - if($option->disable_html) $html_mode = false; |
|
| 227 | - else $html_mode = true; |
|
| 266 | + if($option->disable_html) { |
|
| 267 | + $html_mode = false; |
|
| 268 | + } else { |
|
| 269 | + $html_mode = true; |
|
| 270 | + } |
|
| 228 | 271 | // Set Height |
| 229 | - if(!$option->height) $editor_height = 300; |
|
| 230 | - else $editor_height = $option->height; |
|
| 272 | + if(!$option->height) { |
|
| 273 | + $editor_height = 300; |
|
| 274 | + } else { |
|
| 275 | + $editor_height = $option->height; |
|
| 276 | + } |
|
| 231 | 277 | // Skin Setting |
| 232 | 278 | $skin = $option->skin; |
| 233 | - if(!$skin) $skin = 'ckeditor'; |
|
| 279 | + if(!$skin) { |
|
| 280 | + $skin = 'ckeditor'; |
|
| 281 | + } |
|
| 234 | 282 | |
| 235 | 283 | $colorset = $option->colorset; |
| 236 | - if(!$colorset) $colorset = 'moono'; |
|
| 284 | + if(!$colorset) { |
|
| 285 | + $colorset = 'moono'; |
|
| 286 | + } |
|
| 237 | 287 | Context::set('colorset', $colorset); |
| 238 | 288 | Context::set('skin', $skin); |
| 239 | 289 | Context::set('module_type', $option->module_type); |
@@ -258,10 +308,13 @@ discard block |
||
| 258 | 308 | /** |
| 259 | 309 | * Extract editor's unique number (in order to display multiple editors on a single page) |
| 260 | 310 | */ |
| 261 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
| 262 | - else |
|
| 311 | + if($option->editor_sequence) { |
|
| 312 | + $editor_sequence = $option->editor_sequence; |
|
| 313 | + } else |
|
| 263 | 314 | { |
| 264 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
| 315 | + if(!$_SESSION['_editor_sequence_']) { |
|
| 316 | + $_SESSION['_editor_sequence_'] = 1; |
|
| 317 | + } |
|
| 265 | 318 | $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
| 266 | 319 | } |
| 267 | 320 | |
@@ -285,7 +338,9 @@ discard block |
||
| 285 | 338 | $oFileController = getController('file'); |
| 286 | 339 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
| 287 | 340 | // Check if the file already exists |
| 288 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
| 341 | + if($upload_target_srl) { |
|
| 342 | + $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
| 343 | + } |
|
| 289 | 344 | } |
| 290 | 345 | Context::set('files_count', (int)$files_count); |
| 291 | 346 | |
@@ -377,8 +432,7 @@ discard block |
||
| 377 | 432 | $config->enable_html_grant = $editor_config->enable_html_grant; |
| 378 | 433 | $config->editor_height = $editor_config->editor_height; |
| 379 | 434 | $config->enable_autosave = $editor_config->enable_autosave; |
| 380 | - } |
|
| 381 | - else |
|
| 435 | + } else |
|
| 382 | 436 | { |
| 383 | 437 | $config->editor_skin = $editor_config->comment_editor_skin; |
| 384 | 438 | $config->content_style = $editor_config->comment_content_style; |
@@ -397,8 +451,7 @@ discard block |
||
| 397 | 451 | { |
| 398 | 452 | $logged_info = Context::get('logged_info'); |
| 399 | 453 | $group_list = $logged_info->group_list; |
| 400 | - } |
|
| 401 | - else |
|
| 454 | + } else |
|
| 402 | 455 | { |
| 403 | 456 | $group_list = array(); |
| 404 | 457 | } |
@@ -412,8 +465,9 @@ discard block |
||
| 412 | 465 | $option->colorset = $config->sel_editor_colorset; |
| 413 | 466 | // Permission check for file upload |
| 414 | 467 | $option->allow_fileupload = false; |
| 415 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
| 416 | - elseif(count($config->upload_file_grant)) |
|
| 468 | + if($logged_info->is_admin=='Y') { |
|
| 469 | + $option->allow_fileupload = true; |
|
| 470 | + } elseif(count($config->upload_file_grant)) |
|
| 417 | 471 | { |
| 418 | 472 | foreach($group_list as $group_srl => $group_info) |
| 419 | 473 | { |
@@ -423,12 +477,14 @@ discard block |
||
| 423 | 477 | break; |
| 424 | 478 | } |
| 425 | 479 | } |
| 480 | + } else { |
|
| 481 | + $option->allow_fileupload = true; |
|
| 426 | 482 | } |
| 427 | - else $option->allow_fileupload = true; |
|
| 428 | 483 | // Permission check for using default components |
| 429 | 484 | $option->enable_default_component = false; |
| 430 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
| 431 | - elseif(count($config->enable_default_component_grant)) |
|
| 485 | + if($logged_info->is_admin=='Y') { |
|
| 486 | + $option->enable_default_component = true; |
|
| 487 | + } elseif(count($config->enable_default_component_grant)) |
|
| 432 | 488 | { |
| 433 | 489 | foreach($group_list as $group_srl => $group_info) |
| 434 | 490 | { |
@@ -438,12 +494,14 @@ discard block |
||
| 438 | 494 | break; |
| 439 | 495 | } |
| 440 | 496 | } |
| 497 | + } else { |
|
| 498 | + $option->enable_default_component = true; |
|
| 441 | 499 | } |
| 442 | - else $option->enable_default_component = true; |
|
| 443 | 500 | // Permisshion check for using extended components |
| 444 | 501 | $option->enable_component = false; |
| 445 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
| 446 | - elseif(count($config->enable_component_grant)) |
|
| 502 | + if($logged_info->is_admin=='Y') { |
|
| 503 | + $option->enable_component = true; |
|
| 504 | + } elseif(count($config->enable_component_grant)) |
|
| 447 | 505 | { |
| 448 | 506 | foreach($group_list as $group_srl => $group_info) |
| 449 | 507 | { |
@@ -453,12 +511,14 @@ discard block |
||
| 453 | 511 | break; |
| 454 | 512 | } |
| 455 | 513 | } |
| 514 | + } else { |
|
| 515 | + $option->enable_component = true; |
|
| 456 | 516 | } |
| 457 | - else $option->enable_component = true; |
|
| 458 | 517 | // HTML editing privileges |
| 459 | 518 | $enable_html = false; |
| 460 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
| 461 | - elseif(count($config->enable_html_grant)) |
|
| 519 | + if($logged_info->is_admin=='Y') { |
|
| 520 | + $enable_html = true; |
|
| 521 | + } elseif(count($config->enable_html_grant)) |
|
| 462 | 522 | { |
| 463 | 523 | foreach($group_list as $group_srl => $group_info) |
| 464 | 524 | { |
@@ -468,11 +528,15 @@ discard block |
||
| 468 | 528 | break; |
| 469 | 529 | } |
| 470 | 530 | } |
| 531 | + } else { |
|
| 532 | + $enable_html = true; |
|
| 471 | 533 | } |
| 472 | - else $enable_html = true; |
|
| 473 | 534 | |
| 474 | - if($enable_html) $option->disable_html = false; |
|
| 475 | - else $option->disable_html = true; |
|
| 535 | + if($enable_html) { |
|
| 536 | + $option->disable_html = false; |
|
| 537 | + } else { |
|
| 538 | + $option->disable_html = true; |
|
| 539 | + } |
|
| 476 | 540 | // Set Height |
| 477 | 541 | $option->height = $config->editor_height; |
| 478 | 542 | // Set an option for Auto-save |
@@ -495,8 +559,7 @@ discard block |
||
| 495 | 559 | { |
| 496 | 560 | $logged_info = Context::get('logged_info'); |
| 497 | 561 | $auto_save_args->member_srl = $logged_info->member_srl; |
| 498 | - } |
|
| 499 | - else |
|
| 562 | + } else |
|
| 500 | 563 | { |
| 501 | 564 | $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
| 502 | 565 | } |
@@ -511,11 +574,15 @@ discard block |
||
| 511 | 574 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
| 512 | 575 | $saved_doc = $output->data; |
| 513 | 576 | // Return null if no result is auto-saved |
| 514 | - if(!$saved_doc) return; |
|
| 577 | + if(!$saved_doc) { |
|
| 578 | + return; |
|
| 579 | + } |
|
| 515 | 580 | // Check if the auto-saved document already exists |
| 516 | 581 | $oDocumentModel = getModel('document'); |
| 517 | 582 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
| 518 | - if($oSaved->isExists()) return; |
|
| 583 | + if($oSaved->isExists()) { |
|
| 584 | + return; |
|
| 585 | + } |
|
| 519 | 586 | // Move all the files if the auto-saved data contains document_srl and file |
| 520 | 587 | // Then set document_srl to editor_sequence |
| 521 | 588 | if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
@@ -523,8 +590,9 @@ discard block |
||
| 523 | 590 | $saved_doc->module_srl = $auto_save_args->module_srl; |
| 524 | 591 | $oFileController = getController('file'); |
| 525 | 592 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
| 593 | + } else if($upload_target_srl) { |
|
| 594 | + $saved_doc->document_srl = $upload_target_srl; |
|
| 526 | 595 | } |
| 527 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
| 528 | 596 | // Change auto-saved data |
| 529 | 597 | $oEditorController = getController('editor'); |
| 530 | 598 | $oEditorController->deleteSavedDoc(false); |
@@ -540,18 +608,24 @@ discard block |
||
| 540 | 608 | */ |
| 541 | 609 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
| 542 | 610 | { |
| 543 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
| 611 | + if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) { |
|
| 612 | + return; |
|
| 613 | + } |
|
| 544 | 614 | |
| 545 | 615 | if(!$this->loaded_component_list[$component][$editor_sequence]) |
| 546 | 616 | { |
| 547 | 617 | // Create an object of the component and execute |
| 548 | 618 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
| 549 | 619 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
| 550 | - if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 620 | + if(!file_exists($class_file)) { |
|
| 621 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 622 | + } |
|
| 551 | 623 | // Create an object after loading the class file |
| 552 | 624 | require_once($class_file); |
| 553 | 625 | $oComponent = new $component($editor_sequence, $class_path); |
| 554 | - if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 626 | + if(!$oComponent) { |
|
| 627 | + return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 628 | + } |
|
| 555 | 629 | // Add configuration information |
| 556 | 630 | $component_info = $this->getComponent($component, $site_srl); |
| 557 | 631 | $oComponent->setInfo($component_info); |
@@ -578,8 +652,12 @@ discard block |
||
| 578 | 652 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
| 579 | 653 | FileHandler::makeDir($cache_path); |
| 580 | 654 | $cache_file = $cache_path.'component_list.' . $lang .'.'; |
| 581 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
| 582 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
| 655 | + if($filter_enabled) { |
|
| 656 | + $cache_file .= 'filter.'; |
|
| 657 | + } |
|
| 658 | + if($site_srl) { |
|
| 659 | + $cache_file .= $site_srl.'.'; |
|
| 660 | + } |
|
| 583 | 661 | $cache_file .= 'php'; |
| 584 | 662 | return $cache_file; |
| 585 | 663 | } |
@@ -596,14 +674,15 @@ discard block |
||
| 596 | 674 | $oEditorController->makeCache(false, $site_srl); |
| 597 | 675 | } |
| 598 | 676 | |
| 599 | - if(!file_exists($cache_file)) return; |
|
| 677 | + if(!file_exists($cache_file)) { |
|
| 678 | + return; |
|
| 679 | + } |
|
| 600 | 680 | include($cache_file); |
| 601 | 681 | $logged_info = Context::get('logged_info'); |
| 602 | 682 | if($logged_info && is_array($logged_info->group_list)) |
| 603 | 683 | { |
| 604 | 684 | $group_list = array_keys($logged_info->group_list); |
| 605 | - } |
|
| 606 | - else |
|
| 685 | + } else |
|
| 607 | 686 | { |
| 608 | 687 | $group_list = array(); |
| 609 | 688 | } |
@@ -612,39 +691,50 @@ discard block |
||
| 612 | 691 | { |
| 613 | 692 | foreach($component_list as $key => $val) |
| 614 | 693 | { |
| 615 | - if(!trim($key)) continue; |
|
| 694 | + if(!trim($key)) { |
|
| 695 | + continue; |
|
| 696 | + } |
|
| 616 | 697 | if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
| 617 | 698 | { |
| 618 | 699 | FileHandler::removeFile($cache_file); |
| 619 | 700 | return $this->getComponentList($filter_enabled, $site_srl); |
| 620 | 701 | } |
| 621 | - if(!$filter_enabled) continue; |
|
| 702 | + if(!$filter_enabled) { |
|
| 703 | + continue; |
|
| 704 | + } |
|
| 622 | 705 | if($val->enabled == "N") |
| 623 | 706 | { |
| 624 | 707 | unset($component_list->{$key}); |
| 625 | 708 | continue; |
| 626 | 709 | } |
| 627 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
| 710 | + if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") { |
|
| 711 | + continue; |
|
| 712 | + } |
|
| 628 | 713 | if($val->target_group) |
| 629 | 714 | { |
| 630 | 715 | if(!$logged_info) |
| 631 | 716 | { |
| 632 | 717 | $val->enabled = "N"; |
| 633 | - } |
|
| 634 | - else |
|
| 718 | + } else |
|
| 635 | 719 | { |
| 636 | 720 | $is_granted = false; |
| 637 | 721 | foreach($group_list as $group_srl) |
| 638 | 722 | { |
| 639 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
| 723 | + if(in_array($group_srl, $val->target_group)) { |
|
| 724 | + $is_granted = true; |
|
| 725 | + } |
|
| 726 | + } |
|
| 727 | + if(!$is_granted) { |
|
| 728 | + $val->enabled = "N"; |
|
| 640 | 729 | } |
| 641 | - if(!$is_granted) $val->enabled = "N"; |
|
| 642 | 730 | } |
| 643 | 731 | } |
| 644 | 732 | if($val->enabled != "N" && $val->mid_list) |
| 645 | 733 | { |
| 646 | 734 | $mid = Context::get('mid'); |
| 647 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
| 735 | + if(!in_array($mid, $val->mid_list)) { |
|
| 736 | + $val->enabled = "N"; |
|
| 737 | + } |
|
| 648 | 738 | } |
| 649 | 739 | if($val->enabled == "N") |
| 650 | 740 | { |
@@ -668,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,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | function getEditorConfig($module_srl = null) |
| 25 | 25 | { |
| 26 | - if(!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
| 26 | + if (!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
| 27 | 27 | { |
| 28 | 28 | // Get trackback settings of the selected module |
| 29 | 29 | $oModuleModel = getModel('module'); |
@@ -34,55 +34,55 @@ discard block |
||
| 34 | 34 | $oModuleModel = getModel('module'); |
| 35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
| 36 | 36 | |
| 37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
| 37 | + if (!is_object($editor_config)) $editor_config = new stdClass(); |
|
| 38 | 38 | |
| 39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
| 40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
| 41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
| 42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
| 43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
| 44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
| 45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
| 46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
| 47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
| 39 | + if ($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
| 40 | + if (!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
| 41 | + if (!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
| 42 | + if (!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
| 43 | + if (!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
| 44 | + if (!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
| 45 | + if (!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
| 46 | + if (!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
| 47 | + if (!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant = array(); |
|
| 48 | 48 | |
| 49 | - if(!$editor_config->editor_height) |
|
| 49 | + if (!$editor_config->editor_height) |
|
| 50 | 50 | { |
| 51 | 51 | $editor_config->editor_height = ($editor_default_config->editor_height) ? $editor_default_config->editor_height : 500; |
| 52 | 52 | } |
| 53 | - if(!$editor_config->comment_editor_height) |
|
| 53 | + if (!$editor_config->comment_editor_height) |
|
| 54 | 54 | { |
| 55 | 55 | $editor_config->comment_editor_height = ($editor_default_config->comment_editor_height) ? $editor_default_config->comment_editor_height : 120; |
| 56 | 56 | } |
| 57 | - if(!$editor_config->editor_skin) |
|
| 57 | + if (!$editor_config->editor_skin) |
|
| 58 | 58 | { |
| 59 | 59 | $editor_config->editor_skin = ($editor_default_config->editor_skin) ? $editor_default_config->editor_skin : 'ckeditor'; |
| 60 | 60 | } |
| 61 | - if(!$editor_config->comment_editor_skin) |
|
| 61 | + if (!$editor_config->comment_editor_skin) |
|
| 62 | 62 | { |
| 63 | 63 | $editor_config->comment_editor_skin = ($editor_default_config->comment_editor_skin) ? $editor_default_config->comment_editor_skin : 'ckeditor'; |
| 64 | 64 | } |
| 65 | - if(!$editor_config->content_style) |
|
| 65 | + if (!$editor_config->content_style) |
|
| 66 | 66 | { |
| 67 | 67 | $editor_config->content_style = ($editor_default_config->content_style) ? $editor_default_config->content_style : 'ckeditor_light'; |
| 68 | 68 | } |
| 69 | - if(!$editor_config->content_font && $editor_default_config->content_font) |
|
| 69 | + if (!$editor_config->content_font && $editor_default_config->content_font) |
|
| 70 | 70 | { |
| 71 | 71 | $editor_config->content_font = $editor_default_config->content_font; |
| 72 | 72 | } |
| 73 | - if(!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
| 73 | + if (!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
| 74 | 74 | { |
| 75 | 75 | $editor_config->content_font_size = $editor_default_config->content_font_size; |
| 76 | 76 | } |
| 77 | - if(!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
| 77 | + if (!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
| 78 | 78 | { |
| 79 | 79 | $editor_config->sel_editor_colorset = $editor_default_config->sel_editor_colorset; |
| 80 | 80 | } |
| 81 | - if(!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
| 81 | + if (!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
| 82 | 82 | { |
| 83 | 83 | $editor_config->sel_comment_editor_colorset = $editor_default_config->sel_comment_editor_colorset; |
| 84 | 84 | } |
| 85 | - if(!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
| 85 | + if (!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
| 86 | 86 | { |
| 87 | 87 | $editor_config->comment_content_style = $editor_default_config->comment_content_style; |
| 88 | 88 | } |
@@ -92,25 +92,25 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | function loadDrComponents() |
| 94 | 94 | { |
| 95 | - $drComponentPath = _XE_PATH_ . 'modules/editor/skins/dreditor/drcomponents/'; |
|
| 95 | + $drComponentPath = _XE_PATH_.'modules/editor/skins/dreditor/drcomponents/'; |
|
| 96 | 96 | $drComponentList = FileHandler::readDir($drComponentPath); |
| 97 | 97 | |
| 98 | 98 | $oTemplate = &TemplateHandler::getInstance(); |
| 99 | 99 | |
| 100 | 100 | $drComponentInfo = array(); |
| 101 | - if($drComponentList) |
|
| 101 | + if ($drComponentList) |
|
| 102 | 102 | { |
| 103 | - foreach($drComponentList as $i => $drComponent) |
|
| 103 | + foreach ($drComponentList as $i => $drComponent) |
|
| 104 | 104 | { |
| 105 | 105 | unset($obj); |
| 106 | 106 | $obj = $this->getDrComponentXmlInfo($drComponent); |
| 107 | - Context::loadLang(sprintf('%s%s/lang/',$drComponentPath,$drComponent)); |
|
| 108 | - $path = sprintf('%s%s/tpl/',$drComponentPath,$drComponent); |
|
| 109 | - $obj->html = $oTemplate->compile($path,$drComponent); |
|
| 107 | + Context::loadLang(sprintf('%s%s/lang/', $drComponentPath, $drComponent)); |
|
| 108 | + $path = sprintf('%s%s/tpl/', $drComponentPath, $drComponent); |
|
| 109 | + $obj->html = $oTemplate->compile($path, $drComponent); |
|
| 110 | 110 | $drComponentInfo[$drComponent] = $obj; |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | - Context::set('drComponentList',$drComponentInfo); |
|
| 113 | + Context::set('drComponentList', $drComponentInfo); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | function getDrComponentXmlInfo($drComponentName) |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $xml_file = sprintf('%sinfo.xml', $component_path); |
| 123 | 123 | $cache_file = sprintf('./files/cache/editor/dr_%s.%s.php', $drComponentName, $lang_type); |
| 124 | 124 | // Return information after including it after cached xml file exists |
| 125 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
| 125 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
| 126 | 126 | { |
| 127 | 127 | include($cache_file); |
| 128 | 128 | return $xml_info; |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
| 152 | 152 | |
| 153 | 153 | // Author information |
| 154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
| 154 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
| 155 | 155 | else $author_list = $xml_doc->component->author; |
| 156 | 156 | |
| 157 | - for($i=0; $i < count($author_list); $i++) |
|
| 157 | + for ($i = 0; $i < count($author_list); $i++) |
|
| 158 | 158 | { |
| 159 | 159 | $buff .= sprintf('$xml_info->author['.$i.']->name = "%s";', $author_list[$i]->name->body); |
| 160 | 160 | $buff .= sprintf('$xml_info->author['.$i.']->email_address = "%s";', $author_list[$i]->attrs->email_address); |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | // List extra variables (text type only in the editor component) |
| 165 | 165 | $extra_vars = $xml_doc->component->extra_vars->var; |
| 166 | - if($extra_vars) |
|
| 166 | + if ($extra_vars) |
|
| 167 | 167 | { |
| 168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
| 169 | - foreach($extra_vars as $key => $val) |
|
| 168 | + if (!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
| 169 | + foreach ($extra_vars as $key => $val) |
|
| 170 | 170 | { |
| 171 | 171 | unset($obj); |
| 172 | 172 | $key = $val->attrs->name; |
@@ -198,47 +198,47 @@ discard block |
||
| 198 | 198 | * Editor's default options |
| 199 | 199 | */ |
| 200 | 200 | // Option setting to allow file upload |
| 201 | - if($upload_target_srl) |
|
| 201 | + if ($upload_target_srl) |
|
| 202 | 202 | { |
| 203 | 203 | $option->editor_sequence = $upload_target_srl; |
| 204 | 204 | } |
| 205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
| 205 | + if (!$option->allow_fileupload) $allow_fileupload = false; |
|
| 206 | 206 | else $allow_fileupload = true; |
| 207 | 207 | // content_style setting |
| 208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
| 208 | + if (!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
| 209 | 209 | Context::set('content_style', $option->content_style); |
| 210 | - Context::set('content_style_path', $this->module_path . 'styles/' . $option->content_style); |
|
| 210 | + Context::set('content_style_path', $this->module_path.'styles/'.$option->content_style); |
|
| 211 | 211 | // Default font setting |
| 212 | 212 | Context::set('content_font', addslashes($option->content_font)); |
| 213 | 213 | Context::set('content_font_size', $option->content_font_size); |
| 214 | 214 | |
| 215 | 215 | // Option setting to allow auto-save |
| 216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
| 217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
| 216 | + if (!$option->enable_autosave) $enable_autosave = false; |
|
| 217 | + elseif (Context::get($option->primary_key_name)) $enable_autosave = false; |
|
| 218 | 218 | else $enable_autosave = true; |
| 219 | 219 | // Option setting to allow the default editor component |
| 220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
| 220 | + if (!$option->enable_default_component) $enable_default_component = false; |
|
| 221 | 221 | else $enable_default_component = true; |
| 222 | 222 | // Option setting to allow other extended components |
| 223 | - if(!$option->enable_component) $enable_component = false; |
|
| 223 | + if (!$option->enable_component) $enable_component = false; |
|
| 224 | 224 | else $enable_component = true; |
| 225 | 225 | // Setting for html-mode |
| 226 | - if($option->disable_html) $html_mode = false; |
|
| 226 | + if ($option->disable_html) $html_mode = false; |
|
| 227 | 227 | else $html_mode = true; |
| 228 | 228 | // Set Height |
| 229 | - if(!$option->height) $editor_height = 300; |
|
| 229 | + if (!$option->height) $editor_height = 300; |
|
| 230 | 230 | else $editor_height = $option->height; |
| 231 | 231 | // Skin Setting |
| 232 | 232 | $skin = $option->skin; |
| 233 | - if(!$skin) $skin = 'ckeditor'; |
|
| 233 | + if (!$skin) $skin = 'ckeditor'; |
|
| 234 | 234 | |
| 235 | 235 | $colorset = $option->colorset; |
| 236 | - if(!$colorset) $colorset = 'moono'; |
|
| 236 | + if (!$colorset) $colorset = 'moono'; |
|
| 237 | 237 | Context::set('colorset', $colorset); |
| 238 | 238 | Context::set('skin', $skin); |
| 239 | 239 | Context::set('module_type', $option->module_type); |
| 240 | 240 | |
| 241 | - if($skin=='dreditor') |
|
| 241 | + if ($skin == 'dreditor') |
|
| 242 | 242 | { |
| 243 | 243 | $this->loadDrComponents(); |
| 244 | 244 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | /** |
| 247 | 247 | * Check the automatic backup feature (do not use if the post is edited) |
| 248 | 248 | */ |
| 249 | - if($enable_autosave) |
|
| 249 | + if ($enable_autosave) |
|
| 250 | 250 | { |
| 251 | 251 | // Extract auto-saved data |
| 252 | 252 | $saved_doc = $this->getSavedDoc($upload_target_srl); |
@@ -258,26 +258,26 @@ discard block |
||
| 258 | 258 | /** |
| 259 | 259 | * Extract editor's unique number (in order to display multiple editors on a single page) |
| 260 | 260 | */ |
| 261 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
| 261 | + if ($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
| 262 | 262 | else |
| 263 | 263 | { |
| 264 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
| 265 | - $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
|
| 264 | + if (!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
| 265 | + $editor_sequence = $_SESSION['_editor_sequence_']++; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
| 269 | 269 | * Upload setting by using configuration of the file module internally |
| 270 | 270 | */ |
| 271 | 271 | $files_count = 0; |
| 272 | - if($allow_fileupload) |
|
| 272 | + if ($allow_fileupload) |
|
| 273 | 273 | { |
| 274 | 274 | $oFileModel = getModel('file'); |
| 275 | 275 | // Get upload configuration to set on SWFUploader |
| 276 | 276 | $file_config = $oFileModel->getUploadConfig(); |
| 277 | - $file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024; |
|
| 278 | - $file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024; |
|
| 277 | + $file_config->allowed_attach_size = $file_config->allowed_attach_size * 1024 * 1024; |
|
| 278 | + $file_config->allowed_filesize = $file_config->allowed_filesize * 1024 * 1024; |
|
| 279 | 279 | |
| 280 | - Context::set('file_config',$file_config); |
|
| 280 | + Context::set('file_config', $file_config); |
|
| 281 | 281 | // Configure upload status such as file size |
| 282 | 282 | $upload_status = $oFileModel->getUploadStatus(); |
| 283 | 283 | Context::set('upload_status', $upload_status); |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | $oFileController = getController('file'); |
| 286 | 286 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
| 287 | 287 | // Check if the file already exists |
| 288 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
| 288 | + if ($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
| 289 | 289 | } |
| 290 | - Context::set('files_count', (int)$files_count); |
|
| 290 | + Context::set('files_count', (int) $files_count); |
|
| 291 | 291 | |
| 292 | 292 | Context::set('allow_fileupload', $allow_fileupload); |
| 293 | 293 | // Set editor_sequence value |
@@ -304,10 +304,10 @@ discard block |
||
| 304 | 304 | * Check editor component |
| 305 | 305 | */ |
| 306 | 306 | $site_module_info = Context::get('site_module_info'); |
| 307 | - $site_srl = (int)$site_module_info->site_srl; |
|
| 308 | - if($enable_component) |
|
| 307 | + $site_srl = (int) $site_module_info->site_srl; |
|
| 308 | + if ($enable_component) |
|
| 309 | 309 | { |
| 310 | - if(!Context::get('component_list')) |
|
| 310 | + if (!Context::get('component_list')) |
|
| 311 | 311 | { |
| 312 | 312 | $component_list = $this->getComponentList(true, $site_srl); |
| 313 | 313 | Context::set('component_list', $component_list); |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
| 335 | 335 | $tpl_file = 'editor.html'; |
| 336 | 336 | |
| 337 | - if(!file_exists($tpl_path.$tpl_file)) |
|
| 337 | + if (!file_exists($tpl_path.$tpl_file)) |
|
| 338 | 338 | { |
| 339 | 339 | $skin = 'ckeditor'; |
| 340 | 340 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $config->module_type = $type; |
| 365 | 365 | |
| 366 | 366 | // Configurations listed according to a type |
| 367 | - if($type == 'document') |
|
| 367 | + if ($type == 'document') |
|
| 368 | 368 | { |
| 369 | 369 | $config->editor_skin = $editor_config->editor_skin; |
| 370 | 370 | $config->content_style = $editor_config->content_style; |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | $config->enable_autosave = 'N'; |
| 394 | 394 | } |
| 395 | 395 | // Check a group_list of the currently logged-in user for permission check |
| 396 | - if(Context::get('is_logged')) |
|
| 396 | + if (Context::get('is_logged')) |
|
| 397 | 397 | { |
| 398 | 398 | $logged_info = Context::get('logged_info'); |
| 399 | 399 | $group_list = $logged_info->group_list; |
@@ -412,12 +412,12 @@ discard block |
||
| 412 | 412 | $option->colorset = $config->sel_editor_colorset; |
| 413 | 413 | // Permission check for file upload |
| 414 | 414 | $option->allow_fileupload = false; |
| 415 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
| 416 | - elseif(count($config->upload_file_grant)) |
|
| 415 | + if ($logged_info->is_admin == 'Y') $option->allow_fileupload = true; |
|
| 416 | + elseif (count($config->upload_file_grant)) |
|
| 417 | 417 | { |
| 418 | - foreach($group_list as $group_srl => $group_info) |
|
| 418 | + foreach ($group_list as $group_srl => $group_info) |
|
| 419 | 419 | { |
| 420 | - if(in_array($group_srl, $config->upload_file_grant)) |
|
| 420 | + if (in_array($group_srl, $config->upload_file_grant)) |
|
| 421 | 421 | { |
| 422 | 422 | $option->allow_fileupload = true; |
| 423 | 423 | break; |
@@ -427,12 +427,12 @@ discard block |
||
| 427 | 427 | else $option->allow_fileupload = true; |
| 428 | 428 | // Permission check for using default components |
| 429 | 429 | $option->enable_default_component = false; |
| 430 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
| 431 | - elseif(count($config->enable_default_component_grant)) |
|
| 430 | + if ($logged_info->is_admin == 'Y') $option->enable_default_component = true; |
|
| 431 | + elseif (count($config->enable_default_component_grant)) |
|
| 432 | 432 | { |
| 433 | - foreach($group_list as $group_srl => $group_info) |
|
| 433 | + foreach ($group_list as $group_srl => $group_info) |
|
| 434 | 434 | { |
| 435 | - if(in_array($group_srl, $config->enable_default_component_grant)) |
|
| 435 | + if (in_array($group_srl, $config->enable_default_component_grant)) |
|
| 436 | 436 | { |
| 437 | 437 | $option->enable_default_component = true; |
| 438 | 438 | break; |
@@ -442,12 +442,12 @@ discard block |
||
| 442 | 442 | else $option->enable_default_component = true; |
| 443 | 443 | // Permisshion check for using extended components |
| 444 | 444 | $option->enable_component = false; |
| 445 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
| 446 | - elseif(count($config->enable_component_grant)) |
|
| 445 | + if ($logged_info->is_admin == 'Y') $option->enable_component = true; |
|
| 446 | + elseif (count($config->enable_component_grant)) |
|
| 447 | 447 | { |
| 448 | - foreach($group_list as $group_srl => $group_info) |
|
| 448 | + foreach ($group_list as $group_srl => $group_info) |
|
| 449 | 449 | { |
| 450 | - if(in_array($group_srl, $config->enable_component_grant)) |
|
| 450 | + if (in_array($group_srl, $config->enable_component_grant)) |
|
| 451 | 451 | { |
| 452 | 452 | $option->enable_component = true; |
| 453 | 453 | break; |
@@ -457,12 +457,12 @@ discard block |
||
| 457 | 457 | else $option->enable_component = true; |
| 458 | 458 | // HTML editing privileges |
| 459 | 459 | $enable_html = false; |
| 460 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
| 461 | - elseif(count($config->enable_html_grant)) |
|
| 460 | + if ($logged_info->is_admin == 'Y') $enable_html = true; |
|
| 461 | + elseif (count($config->enable_html_grant)) |
|
| 462 | 462 | { |
| 463 | - foreach($group_list as $group_srl => $group_info) |
|
| 463 | + foreach ($group_list as $group_srl => $group_info) |
|
| 464 | 464 | { |
| 465 | - if(in_array($group_srl, $config->enable_html_grant)) |
|
| 465 | + if (in_array($group_srl, $config->enable_html_grant)) |
|
| 466 | 466 | { |
| 467 | 467 | $enable_html = true; |
| 468 | 468 | break; |
@@ -471,12 +471,12 @@ discard block |
||
| 471 | 471 | } |
| 472 | 472 | else $enable_html = true; |
| 473 | 473 | |
| 474 | - if($enable_html) $option->disable_html = false; |
|
| 474 | + if ($enable_html) $option->disable_html = false; |
|
| 475 | 475 | else $option->disable_html = true; |
| 476 | 476 | // Set Height |
| 477 | 477 | $option->height = $config->editor_height; |
| 478 | 478 | // Set an option for Auto-save |
| 479 | - $option->enable_autosave = $config->enable_autosave=='Y'?true:false; |
|
| 479 | + $option->enable_autosave = $config->enable_autosave == 'Y' ?true:false; |
|
| 480 | 480 | // Other settings |
| 481 | 481 | $option->primary_key_name = $primary_key_name; |
| 482 | 482 | $option->content_key_name = $content_key_name; |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | { |
| 492 | 492 | $auto_save_args = new stdClass(); |
| 493 | 493 | // Find a document by using member_srl for logged-in user and ipaddress for non-logged user |
| 494 | - if(Context::get('is_logged')) |
|
| 494 | + if (Context::get('is_logged')) |
|
| 495 | 495 | { |
| 496 | 496 | $logged_info = Context::get('logged_info'); |
| 497 | 497 | $auto_save_args->member_srl = $logged_info->member_srl; |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | $auto_save_args->module_srl = Context::get('module_srl'); |
| 504 | 504 | // Get the current module if module_srl doesn't exist |
| 505 | - if(!$auto_save_args->module_srl) |
|
| 505 | + if (!$auto_save_args->module_srl) |
|
| 506 | 506 | { |
| 507 | 507 | $current_module_info = Context::get('current_module_info'); |
| 508 | 508 | $auto_save_args->module_srl = $current_module_info->module_srl; |
@@ -511,20 +511,20 @@ discard block |
||
| 511 | 511 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
| 512 | 512 | $saved_doc = $output->data; |
| 513 | 513 | // Return null if no result is auto-saved |
| 514 | - if(!$saved_doc) return; |
|
| 514 | + if (!$saved_doc) return; |
|
| 515 | 515 | // Check if the auto-saved document already exists |
| 516 | 516 | $oDocumentModel = getModel('document'); |
| 517 | 517 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
| 518 | - if($oSaved->isExists()) return; |
|
| 518 | + if ($oSaved->isExists()) return; |
|
| 519 | 519 | // Move all the files if the auto-saved data contains document_srl and file |
| 520 | 520 | // Then set document_srl to editor_sequence |
| 521 | - if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
| 521 | + if ($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
| 522 | 522 | { |
| 523 | 523 | $saved_doc->module_srl = $auto_save_args->module_srl; |
| 524 | 524 | $oFileController = getController('file'); |
| 525 | 525 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
| 526 | 526 | } |
| 527 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
| 527 | + else if ($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
| 528 | 528 | // Change auto-saved data |
| 529 | 529 | $oEditorController = getController('editor'); |
| 530 | 530 | $oEditorController->deleteSavedDoc(false); |
@@ -540,18 +540,18 @@ discard block |
||
| 540 | 540 | */ |
| 541 | 541 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
| 542 | 542 | { |
| 543 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
| 543 | + if (!preg_match('/^[a-zA-Z0-9_-]+$/', $component) || !preg_match('/^[0-9]+$/', $editor_sequence.$site_srl)) return; |
|
| 544 | 544 | |
| 545 | - if(!$this->loaded_component_list[$component][$editor_sequence]) |
|
| 545 | + if (!$this->loaded_component_list[$component][$editor_sequence]) |
|
| 546 | 546 | { |
| 547 | 547 | // Create an object of the component and execute |
| 548 | 548 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
| 549 | 549 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
| 550 | - if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 550 | + if (!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 551 | 551 | // Create an object after loading the class file |
| 552 | 552 | require_once($class_file); |
| 553 | 553 | $oComponent = new $component($editor_sequence, $class_path); |
| 554 | - if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 554 | + if (!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 555 | 555 | // Add configuration information |
| 556 | 556 | $component_info = $this->getComponent($component, $site_srl); |
| 557 | 557 | $oComponent->setInfo($component_info); |
@@ -572,14 +572,14 @@ discard block |
||
| 572 | 572 | /** |
| 573 | 573 | * @brief Return the cache file name of editor component list |
| 574 | 574 | */ |
| 575 | - function getCacheFile($filter_enabled= true, $site_srl = 0) |
|
| 575 | + function getCacheFile($filter_enabled = true, $site_srl = 0) |
|
| 576 | 576 | { |
| 577 | 577 | $lang = Context::getLangType(); |
| 578 | 578 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
| 579 | 579 | FileHandler::makeDir($cache_path); |
| 580 | - $cache_file = $cache_path.'component_list.' . $lang .'.'; |
|
| 581 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
| 582 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
| 580 | + $cache_file = $cache_path.'component_list.'.$lang.'.'; |
|
| 581 | + if ($filter_enabled) $cache_file .= 'filter.'; |
|
| 582 | + if ($site_srl) $cache_file .= $site_srl.'.'; |
|
| 583 | 583 | $cache_file .= 'php'; |
| 584 | 584 | return $cache_file; |
| 585 | 585 | } |
@@ -587,19 +587,19 @@ discard block |
||
| 587 | 587 | /** |
| 588 | 588 | * @brief Return a component list (DB Information included) |
| 589 | 589 | */ |
| 590 | - function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) |
|
| 590 | + function getComponentList($filter_enabled = true, $site_srl = 0, $from_db = false) |
|
| 591 | 591 | { |
| 592 | 592 | $cache_file = $this->getCacheFile(false, $site_srl); |
| 593 | - if($from_db || !file_exists($cache_file)) |
|
| 593 | + if ($from_db || !file_exists($cache_file)) |
|
| 594 | 594 | { |
| 595 | 595 | $oEditorController = getController('editor'); |
| 596 | 596 | $oEditorController->makeCache(false, $site_srl); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - if(!file_exists($cache_file)) return; |
|
| 599 | + if (!file_exists($cache_file)) return; |
|
| 600 | 600 | include($cache_file); |
| 601 | 601 | $logged_info = Context::get('logged_info'); |
| 602 | - if($logged_info && is_array($logged_info->group_list)) |
|
| 602 | + if ($logged_info && is_array($logged_info->group_list)) |
|
| 603 | 603 | { |
| 604 | 604 | $group_list = array_keys($logged_info->group_list); |
| 605 | 605 | } |
@@ -608,45 +608,45 @@ discard block |
||
| 608 | 608 | $group_list = array(); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if(count($component_list)) |
|
| 611 | + if (count($component_list)) |
|
| 612 | 612 | { |
| 613 | - foreach($component_list as $key => $val) |
|
| 613 | + foreach ($component_list as $key => $val) |
|
| 614 | 614 | { |
| 615 | - if(!trim($key)) continue; |
|
| 616 | - if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
| 615 | + if (!trim($key)) continue; |
|
| 616 | + if (!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
| 617 | 617 | { |
| 618 | 618 | FileHandler::removeFile($cache_file); |
| 619 | 619 | return $this->getComponentList($filter_enabled, $site_srl); |
| 620 | 620 | } |
| 621 | - if(!$filter_enabled) continue; |
|
| 622 | - if($val->enabled == "N") |
|
| 621 | + if (!$filter_enabled) continue; |
|
| 622 | + if ($val->enabled == "N") |
|
| 623 | 623 | { |
| 624 | 624 | unset($component_list->{$key}); |
| 625 | 625 | continue; |
| 626 | 626 | } |
| 627 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
| 628 | - if($val->target_group) |
|
| 627 | + if ($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
| 628 | + if ($val->target_group) |
|
| 629 | 629 | { |
| 630 | - if(!$logged_info) |
|
| 630 | + if (!$logged_info) |
|
| 631 | 631 | { |
| 632 | 632 | $val->enabled = "N"; |
| 633 | 633 | } |
| 634 | 634 | else |
| 635 | 635 | { |
| 636 | 636 | $is_granted = false; |
| 637 | - foreach($group_list as $group_srl) |
|
| 637 | + foreach ($group_list as $group_srl) |
|
| 638 | 638 | { |
| 639 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
| 639 | + if (in_array($group_srl, $val->target_group)) $is_granted = true; |
|
| 640 | 640 | } |
| 641 | - if(!$is_granted) $val->enabled = "N"; |
|
| 641 | + if (!$is_granted) $val->enabled = "N"; |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | - if($val->enabled != "N" && $val->mid_list) |
|
| 644 | + if ($val->enabled != "N" && $val->mid_list) |
|
| 645 | 645 | { |
| 646 | 646 | $mid = Context::get('mid'); |
| 647 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
| 647 | + if (!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
| 648 | 648 | } |
| 649 | - if($val->enabled == "N") |
|
| 649 | + if ($val->enabled == "N") |
|
| 650 | 650 | { |
| 651 | 651 | unset($component_list->{$key}); |
| 652 | 652 | continue; |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | $args = new stdClass(); |
| 665 | 665 | $args->component_name = $component_name; |
| 666 | 666 | |
| 667 | - if($site_srl) |
|
| 667 | + if ($site_srl) |
|
| 668 | 668 | { |
| 669 | 669 | $args->site_srl = $site_srl; |
| 670 | 670 | $output = executeQuery('editor.getSiteComponent', $args); |
@@ -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'); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * Delete selected files from the administrator page |
| 58 | 58 | * |
| 59 | - * @return Object |
|
| 59 | + * @return ModuleObject|null |
|
| 60 | 60 | */ |
| 61 | 61 | function procFileAdminDeleteChecked() |
| 62 | 62 | { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | /** |
| 111 | 111 | * Add file information for each module |
| 112 | 112 | * |
| 113 | - * @return void |
|
| 113 | + * @return Object|null |
|
| 114 | 114 | */ |
| 115 | 115 | function procFileAdminInsertModuleConfig() |
| 116 | 116 | { |
@@ -27,12 +27,16 @@ discard block |
||
| 27 | 27 | $args->module_srl = $module_srl; |
| 28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
| 29 | 29 | $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
| 30 | - if(!$output) return $output; |
|
| 30 | + if(!$output) { |
|
| 31 | + return $output; |
|
| 32 | + } |
|
| 31 | 33 | $files = $output->data; |
| 32 | 34 | // Remove from the DB |
| 33 | 35 | $args->module_srl = $module_srl; |
| 34 | 36 | $output = executeQuery('file.deleteModuleFiles', $args); |
| 35 | - if(!$output->toBool()) return $output; |
|
| 37 | + if(!$output->toBool()) { |
|
| 38 | + return $output; |
|
| 39 | + } |
|
| 36 | 40 | // Remove the file |
| 37 | 41 | FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
| 38 | 42 | FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
@@ -45,10 +49,14 @@ discard block |
||
| 45 | 49 | FileHandler::removeFile($uploaded_filename); |
| 46 | 50 | |
| 47 | 51 | $path_info = pathinfo($uploaded_filename); |
| 48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 52 | + if(!in_array($path_info['dirname'], $path)) { |
|
| 53 | + $path[] = $path_info['dirname']; |
|
| 54 | + } |
|
| 49 | 55 | } |
| 50 | 56 | // Remove a file directory of the document |
| 51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
| 57 | + for($i=0;$i<count($path);$i++) { |
|
| 58 | + FileHandler::removeBlankDir($path[$i]); |
|
| 59 | + } |
|
| 52 | 60 | |
| 53 | 61 | return $output; |
| 54 | 62 | } |
@@ -62,18 +70,27 @@ discard block |
||
| 62 | 70 | { |
| 63 | 71 | // An error appears if no document is selected |
| 64 | 72 | $cart = Context::get('cart'); |
| 65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
| 66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
| 67 | - else $file_srl_list = $cart; |
|
| 73 | + if(!$cart) { |
|
| 74 | + return $this->stop('msg_file_cart_is_null'); |
|
| 75 | + } |
|
| 76 | + if(!is_array($cart)) { |
|
| 77 | + $file_srl_list= explode('|@|', $cart); |
|
| 78 | + } else { |
|
| 79 | + $file_srl_list = $cart; |
|
| 80 | + } |
|
| 68 | 81 | $file_count = count($file_srl_list); |
| 69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
| 82 | + if(!$file_count) { |
|
| 83 | + return $this->stop('msg_file_cart_is_null'); |
|
| 84 | + } |
|
| 70 | 85 | |
| 71 | 86 | $oFileController = getController('file'); |
| 72 | 87 | // Delete the post |
| 73 | 88 | for($i=0;$i<$file_count;$i++) |
| 74 | 89 | { |
| 75 | 90 | $file_srl = trim($file_srl_list[$i]); |
| 76 | - if(!$file_srl) continue; |
|
| 91 | + if(!$file_srl) { |
|
| 92 | + continue; |
|
| 93 | + } |
|
| 77 | 94 | |
| 78 | 95 | $oFileController->deleteFile($file_srl); |
| 79 | 96 | } |
@@ -117,8 +134,11 @@ discard block |
||
| 117 | 134 | // Get variables |
| 118 | 135 | $module_srl = Context::get('target_module_srl'); |
| 119 | 136 | // In order to configure multiple modules at once |
| 120 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 121 | - else $module_srl = array($module_srl); |
|
| 137 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
| 138 | + $module_srl = explode(',',$module_srl); |
|
| 139 | + } else { |
|
| 140 | + $module_srl = array($module_srl); |
|
| 141 | + } |
|
| 122 | 142 | |
| 123 | 143 | $download_grant = Context::get('download_grant'); |
| 124 | 144 | |
@@ -130,8 +150,11 @@ discard block |
||
| 130 | 150 | $file_config->allowed_attach_size = Context::get('allowed_attach_size'); |
| 131 | 151 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
| 132 | 152 | |
| 133 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
| 134 | - else $file_config->download_grant = $download_grant; |
|
| 153 | + if(!is_array($download_grant)) { |
|
| 154 | + $file_config->download_grant = explode('|@|',$download_grant); |
|
| 155 | + } else { |
|
| 156 | + $file_config->download_grant = $download_grant; |
|
| 157 | + } |
|
| 135 | 158 | |
| 136 | 159 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
| 137 | 160 | $userFileAllowSize = FileHandler::returnbytes($file_config->allowed_filesize.'M'); |
@@ -140,14 +163,17 @@ discard block |
||
| 140 | 163 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
| 141 | 164 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
| 142 | 165 | |
| 143 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
| 144 | - return new Object(-1, 'input size over than config in php.ini'); |
|
| 166 | + if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) { |
|
| 167 | + return new Object(-1, 'input size over than config in php.ini'); |
|
| 168 | + } |
|
| 145 | 169 | |
| 146 | 170 | $oModuleController = getController('module'); |
| 147 | 171 | for($i=0;$i<count($module_srl);$i++) |
| 148 | 172 | { |
| 149 | 173 | $srl = trim($module_srl[$i]); |
| 150 | - if(!$srl) continue; |
|
| 174 | + if(!$srl) { |
|
| 175 | + continue; |
|
| 176 | + } |
|
| 151 | 177 | $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
| 152 | 178 | } |
| 153 | 179 | |
@@ -174,8 +200,11 @@ discard block |
||
| 174 | 200 | |
| 175 | 201 | if($output->file_srl) |
| 176 | 202 | { |
| 177 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
| 178 | - else $_SESSION['file_management'][$output->file_srl] = true; |
|
| 203 | + if($_SESSION['file_management'][$output->file_srl]) { |
|
| 204 | + unset($_SESSION['file_management'][$output->file_srl]); |
|
| 205 | + } else { |
|
| 206 | + $_SESSION['file_management'][$output->file_srl] = true; |
|
| 207 | + } |
|
| 179 | 208 | } |
| 180 | 209 | } |
| 181 | 210 | } |
@@ -26,29 +26,29 @@ discard block |
||
| 26 | 26 | $args = new stdClass(); |
| 27 | 27 | $args->module_srl = $module_srl; |
| 28 | 28 | $columnList = array('file_srl', 'uploaded_filename'); |
| 29 | - $output = executeQueryArray('file.getModuleFiles',$args, $columnList); |
|
| 30 | - if(!$output) return $output; |
|
| 29 | + $output = executeQueryArray('file.getModuleFiles', $args, $columnList); |
|
| 30 | + if (!$output) return $output; |
|
| 31 | 31 | $files = $output->data; |
| 32 | 32 | // Remove from the DB |
| 33 | 33 | $args->module_srl = $module_srl; |
| 34 | 34 | $output = executeQuery('file.deleteModuleFiles', $args); |
| 35 | - if(!$output->toBool()) return $output; |
|
| 35 | + if (!$output->toBool()) return $output; |
|
| 36 | 36 | // Remove the file |
| 37 | - FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ; |
|
| 38 | - FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) ); |
|
| 37 | + FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl)); |
|
| 38 | + FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl)); |
|
| 39 | 39 | // Remove the file list obtained from the DB |
| 40 | 40 | $path = array(); |
| 41 | 41 | $cnt = count($files); |
| 42 | - for($i=0;$i<$cnt;$i++) |
|
| 42 | + for ($i = 0; $i < $cnt; $i++) |
|
| 43 | 43 | { |
| 44 | 44 | $uploaded_filename = $files[$i]->uploaded_filename; |
| 45 | 45 | FileHandler::removeFile($uploaded_filename); |
| 46 | 46 | |
| 47 | 47 | $path_info = pathinfo($uploaded_filename); |
| 48 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 48 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 49 | 49 | } |
| 50 | 50 | // Remove a file directory of the document |
| 51 | - for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); |
|
| 51 | + for ($i = 0; $i < count($path); $i++) FileHandler::removeBlankDir($path[$i]); |
|
| 52 | 52 | |
| 53 | 53 | return $output; |
| 54 | 54 | } |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | // An error appears if no document is selected |
| 64 | 64 | $cart = Context::get('cart'); |
| 65 | - if(!$cart) return $this->stop('msg_file_cart_is_null'); |
|
| 66 | - if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); |
|
| 65 | + if (!$cart) return $this->stop('msg_file_cart_is_null'); |
|
| 66 | + if (!is_array($cart)) $file_srl_list = explode('|@|', $cart); |
|
| 67 | 67 | else $file_srl_list = $cart; |
| 68 | 68 | $file_count = count($file_srl_list); |
| 69 | - if(!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
| 69 | + if (!$file_count) return $this->stop('msg_file_cart_is_null'); |
|
| 70 | 70 | |
| 71 | 71 | $oFileController = getController('file'); |
| 72 | 72 | // Delete the post |
| 73 | - for($i=0;$i<$file_count;$i++) |
|
| 73 | + for ($i = 0; $i < $file_count; $i++) |
|
| 74 | 74 | { |
| 75 | 75 | $file_srl = trim($file_srl_list[$i]); |
| 76 | - if(!$file_srl) continue; |
|
| 76 | + if (!$file_srl) continue; |
|
| 77 | 77 | |
| 78 | 78 | $oFileController->deleteFile($file_srl); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $this->setMessage( sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count) ); |
|
| 81 | + $this->setMessage(sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count)); |
|
| 82 | 82 | |
| 83 | 83 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminList'); |
| 84 | 84 | $this->setRedirectUrl($returnUrl); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $config->allow_outlink_site = Context::get('allow_outlink_site'); |
| 102 | 102 | // Create module Controller object |
| 103 | 103 | $oModuleController = getController('module'); |
| 104 | - $output = $oModuleController->insertModuleConfig('file',$config); |
|
| 104 | + $output = $oModuleController->insertModuleConfig('file', $config); |
|
| 105 | 105 | |
| 106 | 106 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminConfig'); |
| 107 | 107 | return $this->setRedirectUrl($returnUrl, $output); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | // Get variables |
| 118 | 118 | $module_srl = Context::get('target_module_srl'); |
| 119 | 119 | // In order to configure multiple modules at once |
| 120 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 120 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
| 121 | 121 | else $module_srl = array($module_srl); |
| 122 | 122 | |
| 123 | 123 | $download_grant = Context::get('download_grant'); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $file_config->allowed_attach_size = Context::get('allowed_attach_size'); |
| 131 | 131 | $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes')); |
| 132 | 132 | |
| 133 | - if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant); |
|
| 133 | + if (!is_array($download_grant)) $file_config->download_grant = explode('|@|', $download_grant); |
|
| 134 | 134 | else $file_config->download_grant = $download_grant; |
| 135 | 135 | |
| 136 | 136 | //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas |
@@ -140,15 +140,15 @@ discard block |
||
| 140 | 140 | $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize')); |
| 141 | 141 | $iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize); |
| 142 | 142 | |
| 143 | - if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
| 143 | + if ($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) |
|
| 144 | 144 | return new Object(-1, 'input size over than config in php.ini'); |
| 145 | 145 | |
| 146 | 146 | $oModuleController = getController('module'); |
| 147 | - for($i=0;$i<count($module_srl);$i++) |
|
| 147 | + for ($i = 0; $i < count($module_srl); $i++) |
|
| 148 | 148 | { |
| 149 | 149 | $srl = trim($module_srl[$i]); |
| 150 | - if(!$srl) continue; |
|
| 151 | - $oModuleController->insertModulePartConfig('file',$srl,$file_config); |
|
| 150 | + if (!$srl) continue; |
|
| 151 | + $oModuleController->insertModulePartConfig('file', $srl, $file_config); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $this->setError(-1); |
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | function procFileAdminAddCart() |
| 167 | 167 | { |
| 168 | - $file_srl = (int)Context::get('file_srl'); |
|
| 168 | + $file_srl = (int) Context::get('file_srl'); |
|
| 169 | 169 | //$fileSrlList = array(500, 502); |
| 170 | 170 | |
| 171 | 171 | $oFileModel = getModel('file'); |
| 172 | 172 | $output = $oFileModel->getFile($file_srl); |
| 173 | 173 | //$output = $oFileModel->getFile($fileSrlList); |
| 174 | 174 | |
| 175 | - if($output->file_srl) |
|
| 175 | + if ($output->file_srl) |
|
| 176 | 176 | { |
| 177 | - if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
| 177 | + if ($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]); |
|
| 178 | 178 | else $_SESSION['file_management'][$output->file_srl] = true; |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -144,7 +144,7 @@ |
||
| 144 | 144 | * Make search parameters from object(private) |
| 145 | 145 | * |
| 146 | 146 | * @param object $obj Original searach options |
| 147 | - * @param object $args Result searach options |
|
| 147 | + * @param stdClass $args Result searach options |
|
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | 150 | function _makeSearchParam(&$obj, &$args) |
@@ -68,28 +68,28 @@ discard block |
||
| 68 | 68 | $this->_makeSearchParam($obj, $args); |
| 69 | 69 | |
| 70 | 70 | // Set valid/invalid state |
| 71 | - if($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
| 72 | - elseif($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
| 71 | + if ($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
| 72 | + elseif ($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
| 73 | 73 | // Set multimedia/common file |
| 74 | - if($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
| 75 | - elseif($obj->direct_download == 'N') $args->direct_download= 'N'; |
|
| 74 | + if ($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
| 75 | + elseif ($obj->direct_download == 'N') $args->direct_download = 'N'; |
|
| 76 | 76 | // Set variables |
| 77 | 77 | $args->sort_index = $obj->sort_index; |
| 78 | - $args->page = $obj->page?$obj->page:1; |
|
| 79 | - $args->list_count = $obj->list_count?$obj->list_count:20; |
|
| 80 | - $args->page_count = $obj->page_count?$obj->page_count:10; |
|
| 78 | + $args->page = $obj->page ? $obj->page : 1; |
|
| 79 | + $args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
| 80 | + $args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
| 81 | 81 | $args->s_module_srl = $obj->module_srl; |
| 82 | 82 | $args->exclude_module_srl = $obj->exclude_module_srl; |
| 83 | 83 | // Execute the file.getFileList query |
| 84 | 84 | $output = executeQuery('file.getFileList', $args, $columnList); |
| 85 | 85 | // Return if no result or an error occurs |
| 86 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 86 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
| 87 | 87 | |
| 88 | 88 | $oFileModel = getModel('file'); |
| 89 | 89 | |
| 90 | - foreach($output->data as $key => $file) |
|
| 90 | + foreach ($output->data as $key => $file) |
|
| 91 | 91 | { |
| 92 | - if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
| 92 | + if ($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
| 93 | 93 | else $file->isCarted = false; |
| 94 | 94 | |
| 95 | 95 | $file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | function getFilesCountByDate($date = '') |
| 134 | 134 | { |
| 135 | - if($date) $args->regDate = date('Ymd', strtotime($date)); |
|
| 135 | + if ($date) $args->regDate = date('Ymd', strtotime($date)); |
|
| 136 | 136 | |
| 137 | 137 | $output = executeQuery('file.getFilesCount', $args); |
| 138 | - if(!$output->toBool()) return 0; |
|
| 138 | + if (!$output->toBool()) return 0; |
|
| 139 | 139 | |
| 140 | 140 | return $output->data->count; |
| 141 | 141 | } |
@@ -150,31 +150,31 @@ discard block |
||
| 150 | 150 | function _makeSearchParam(&$obj, &$args) |
| 151 | 151 | { |
| 152 | 152 | // Search options |
| 153 | - $search_target = $obj->search_target?$obj->search_target:trim(Context::get('search_target')); |
|
| 154 | - $search_keyword = $obj->search_keyword?$obj->search_keyword:trim(Context::get('search_keyword')); |
|
| 153 | + $search_target = $obj->search_target ? $obj->search_target : trim(Context::get('search_target')); |
|
| 154 | + $search_keyword = $obj->search_keyword ? $obj->search_keyword : trim(Context::get('search_keyword')); |
|
| 155 | 155 | |
| 156 | - if($search_target && $search_keyword) |
|
| 156 | + if ($search_target && $search_keyword) |
|
| 157 | 157 | { |
| 158 | - switch($search_target) |
|
| 158 | + switch ($search_target) |
|
| 159 | 159 | { |
| 160 | 160 | case 'filename' : |
| 161 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 161 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
| 162 | 162 | $args->s_filename = $search_keyword; |
| 163 | 163 | break; |
| 164 | 164 | case 'filesize_more' : |
| 165 | - $args->s_filesize_more = (int)$search_keyword; |
|
| 165 | + $args->s_filesize_more = (int) $search_keyword; |
|
| 166 | 166 | break; |
| 167 | 167 | case 'filesize_mega_more' : |
| 168 | - $args->s_filesize_more = (int)$search_keyword * 1024 * 1024; |
|
| 168 | + $args->s_filesize_more = (int) $search_keyword * 1024 * 1024; |
|
| 169 | 169 | break; |
| 170 | 170 | case 'filesize_less' : |
| 171 | - $args->s_filesize_less = (int)$search_keyword; |
|
| 171 | + $args->s_filesize_less = (int) $search_keyword; |
|
| 172 | 172 | break; |
| 173 | 173 | case 'filesize_mega_less' : |
| 174 | - $args->s_filesize_less = (int)$search_keyword * 1024 * 1024; |
|
| 174 | + $args->s_filesize_less = (int) $search_keyword * 1024 * 1024; |
|
| 175 | 175 | break; |
| 176 | 176 | case 'download_count' : |
| 177 | - $args->s_download_count = (int)$search_keyword; |
|
| 177 | + $args->s_download_count = (int) $search_keyword; |
|
| 178 | 178 | break; |
| 179 | 179 | case 'regdate' : |
| 180 | 180 | $args->s_regdate = $search_keyword; |
@@ -68,11 +68,17 @@ discard block |
||
| 68 | 68 | $this->_makeSearchParam($obj, $args); |
| 69 | 69 | |
| 70 | 70 | // Set valid/invalid state |
| 71 | - if($obj->isvalid == 'Y') $args->isvalid = 'Y'; |
|
| 72 | - elseif($obj->isvalid == 'N') $args->isvalid = 'N'; |
|
| 71 | + if($obj->isvalid == 'Y') { |
|
| 72 | + $args->isvalid = 'Y'; |
|
| 73 | + } elseif($obj->isvalid == 'N') { |
|
| 74 | + $args->isvalid = 'N'; |
|
| 75 | + } |
|
| 73 | 76 | // Set multimedia/common file |
| 74 | - if($obj->direct_download == 'Y') $args->direct_download = 'Y'; |
|
| 75 | - elseif($obj->direct_download == 'N') $args->direct_download= 'N'; |
|
| 77 | + if($obj->direct_download == 'Y') { |
|
| 78 | + $args->direct_download = 'Y'; |
|
| 79 | + } elseif($obj->direct_download == 'N') { |
|
| 80 | + $args->direct_download= 'N'; |
|
| 81 | + } |
|
| 76 | 82 | // Set variables |
| 77 | 83 | $args->sort_index = $obj->sort_index; |
| 78 | 84 | $args->page = $obj->page?$obj->page:1; |
@@ -83,14 +89,19 @@ discard block |
||
| 83 | 89 | // Execute the file.getFileList query |
| 84 | 90 | $output = executeQuery('file.getFileList', $args, $columnList); |
| 85 | 91 | // Return if no result or an error occurs |
| 86 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
| 92 | + if(!$output->toBool()||!count($output->data)) { |
|
| 93 | + return $output; |
|
| 94 | + } |
|
| 87 | 95 | |
| 88 | 96 | $oFileModel = getModel('file'); |
| 89 | 97 | |
| 90 | 98 | foreach($output->data as $key => $file) |
| 91 | 99 | { |
| 92 | - if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true; |
|
| 93 | - else $file->isCarted = false; |
|
| 100 | + if($_SESSION['file_management'][$file->file_srl]) { |
|
| 101 | + $file->isCarted = true; |
|
| 102 | + } else { |
|
| 103 | + $file->isCarted = false; |
|
| 104 | + } |
|
| 94 | 105 | |
| 95 | 106 | $file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl); |
| 96 | 107 | $output->data[$key] = $file; |
@@ -132,10 +143,14 @@ discard block |
||
| 132 | 143 | */ |
| 133 | 144 | function getFilesCountByDate($date = '') |
| 134 | 145 | { |
| 135 | - if($date) $args->regDate = date('Ymd', strtotime($date)); |
|
| 146 | + if($date) { |
|
| 147 | + $args->regDate = date('Ymd', strtotime($date)); |
|
| 148 | + } |
|
| 136 | 149 | |
| 137 | 150 | $output = executeQuery('file.getFilesCount', $args); |
| 138 | - if(!$output->toBool()) return 0; |
|
| 151 | + if(!$output->toBool()) { |
|
| 152 | + return 0; |
|
| 153 | + } |
|
| 139 | 154 | |
| 140 | 155 | return $output->data->count; |
| 141 | 156 | } |
@@ -158,7 +173,9 @@ discard block |
||
| 158 | 173 | switch($search_target) |
| 159 | 174 | { |
| 160 | 175 | case 'filename' : |
| 161 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 176 | + if($search_keyword) { |
|
| 177 | + $search_keyword = str_replace(' ','%',$search_keyword); |
|
| 178 | + } |
|
| 162 | 179 | $args->s_filename = $search_keyword; |
| 163 | 180 | break; |
| 164 | 181 | case 'filesize_more' : |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * Image resize |
| 91 | 91 | * |
| 92 | - * @return Object |
|
| 92 | + * @return Object|null |
|
| 93 | 93 | */ |
| 94 | 94 | function procFileImageResize() |
| 95 | 95 | { |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | /** |
| 397 | 397 | * get file list |
| 398 | 398 | * |
| 399 | - * @return Object |
|
| 399 | + * @return Object|null |
|
| 400 | 400 | */ |
| 401 | 401 | function procFileGetList() |
| 402 | 402 | { |
@@ -29,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 Object(-1,'msg_invalid_request'); |
|
| 119 | + return new Object(-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 Object(-1,'msg_invalid_request'); |
|
| 126 | + return new Object(-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 Object(-1,'msg_invalid_request'); |
|
| 142 | + return new Object(-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 Object(-1, 'msg_not_permitted'); |
|
| 183 | + if (isset($this->grant->access) && $this->grant->access !== true) return new Object(-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(filesize($uploaded_filename) > 1024 * 1024) |
|
| 376 | + if (filesize($uploaded_filename) > 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 Object(-1,'msg_not_permitted'); |
|
| 440 | + if (!Context::get('is_logged')) return new Object(-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 Object(-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 Object(); |
|
| 487 | + if (!$document_srl) return new Object(); |
|
| 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 Object(); |
|
| 504 | + if (!$document_srl) return new Object(); |
|
| 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 Object(); |
| 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 Object(); |
|
| 521 | + if (!$document_srl) return new Object(); |
|
| 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 Object(); |
|
| 536 | + if (!$comment_srl) return new Object(); |
|
| 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 Object(); |
|
| 554 | + if (!$comment_srl || !$uploaded_count) return new Object(); |
|
| 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 Object(); |
| 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 Object(); |
|
| 571 | + if (!$comment_srl) return new Object(); |
|
| 572 | 572 | |
| 573 | - if($obj->isMoveToTrash) return new Object(); |
|
| 573 | + if ($obj->isMoveToTrash) return new Object(); |
|
| 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 Object(); |
|
| 588 | + if (!$module_srl) return new Object(); |
|
| 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 Object(-1, 'msg_exceeds_limit_size'); |
|
| 701 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-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 Object(-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 Object(-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|swf|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|swf|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 Object(-1,'msg_not_permitted_create'); |
|
| 745 | + if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create'); |
|
| 746 | 746 | |
| 747 | 747 | // Check uploaded file |
| 748 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
| 748 | + if (!checkUploadedFile($file_info['tmp_name'])) return new Object(-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 Object(-1,'msg_file_upload_error'); |
|
| 768 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-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 Object(); |
|
| 905 | + if (!is_array($file_list) || !count($file_list)) return new Object(); |
|
| 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|swf|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|swf|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 Object(-1, 'msg_invalid_request'); |
|
| 990 | + if (!$vars->editor_sequence) return new Object(-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 Object(-1, 'msg_not_founded'); |
|
| 997 | + if (!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 998 | 998 | |
| 999 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 999 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-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 Object(-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 Object(-1, 'msg_not_permitted'); |
|
| 204 | + if(isset($this->grant->access) && $this->grant->access !== true) { |
|
| 205 | + return new Object(-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(filesize($uploaded_filename) > 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 Object(-1,'msg_not_permitted'); |
|
| 505 | + if(!Context::get('is_logged')) { |
|
| 506 | + return new Object(-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 Object(); |
|
| 560 | + if(!$document_srl) { |
|
| 561 | + return new Object(); |
|
| 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 Object(); |
|
| 579 | + if(!$document_srl) { |
|
| 580 | + return new Object(); |
|
| 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 Object(); |
| 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 Object(); |
|
| 600 | + if(!$document_srl) { |
|
| 601 | + return new Object(); |
|
| 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 Object(); |
|
| 617 | + if(!$comment_srl) { |
|
| 618 | + return new Object(); |
|
| 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 Object(); |
|
| 637 | + if(!$comment_srl || !$uploaded_count) { |
|
| 638 | + return new Object(); |
|
| 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 Object(); |
| 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 Object(); |
|
| 658 | + if(!$comment_srl) { |
|
| 659 | + return new Object(); |
|
| 660 | + } |
|
| 572 | 661 | |
| 573 | - if($obj->isMoveToTrash) return new Object(); |
|
| 662 | + if($obj->isMoveToTrash) { |
|
| 663 | + return new Object(); |
|
| 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 Object(); |
|
| 679 | + if(!$module_srl) { |
|
| 680 | + return new Object(); |
|
| 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 Object(-1, 'msg_exceeds_limit_size'); |
|
| 796 | + if($allowed_filesize < filesize($file_info['tmp_name'])) { |
|
| 797 | + return new Object(-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 Object(-1, 'msg_exceeds_limit_size'); |
|
| 804 | + if($attached_size > $allowed_attach_size) { |
|
| 805 | + return new Object(-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 Object(-1,'msg_not_permitted_create'); |
|
| 843 | + if(!FileHandler::makeDir($path)) { |
|
| 844 | + return new Object(-1,'msg_not_permitted_create'); |
|
| 845 | + } |
|
| 746 | 846 | |
| 747 | 847 | // Check uploaded file |
| 748 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
| 848 | + if(!checkUploadedFile($file_info['tmp_name'])) { |
|
| 849 | + return new Object(-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 Object(-1,'msg_file_upload_error'); |
|
| 869 | + if(!@move_uploaded_file($file_info['tmp_name'], $filename)) { |
|
| 870 | + return new Object(-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 Object(); |
|
| 1022 | + if(!is_array($file_list)||!count($file_list)) { |
|
| 1023 | + return new Object(); |
|
| 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 Object(-1, 'msg_invalid_request'); |
|
| 1118 | + if(!$vars->editor_sequence) { |
|
| 1119 | + return new Object(-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 Object(-1, 'msg_not_founded'); |
|
| 1127 | + if(!$file_info) { |
|
| 1128 | + return new Object(-1, 'msg_not_founded'); |
|
| 1129 | + } |
|
| 998 | 1130 | |
| 999 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 1131 | + if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) { |
|
| 1132 | + return new Object(-1, 'msg_not_permitted'); |
|
| 1133 | + } |
|
| 1000 | 1134 | |
| 1001 | 1135 | $args = new stdClass(); |
| 1002 | 1136 | $args->file_srl = $vars->file_srl; |