@@ -101,7 +101,6 @@ |
||
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @brief check member's grant |
| 104 | - * @param object $member_info |
|
| 105 | 104 | * @param array $arrGrant |
| 106 | 105 | * @return boolean |
| 107 | 106 | */ |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * @brief get grant array for insert to database. table module_config's config field |
|
| 65 | - * @param string $default |
|
| 66 | - * @param array $group |
|
| 67 | - * @return array |
|
| 68 | - */ |
|
| 64 | + * @brief get grant array for insert to database. table module_config's config field |
|
| 65 | + * @param string $default |
|
| 66 | + * @param array $group |
|
| 67 | + * @return array |
|
| 68 | + */ |
|
| 69 | 69 | function getGrantArray($default, $group) |
| 70 | 70 | { |
| 71 | 71 | $grant = array(); |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | - * @brief check member's grant |
|
| 104 | - * @param object $member_info |
|
| 105 | - * @param array $arrGrant |
|
| 106 | - * @return boolean |
|
| 107 | - */ |
|
| 103 | + * @brief check member's grant |
|
| 104 | + * @param object $member_info |
|
| 105 | + * @param array $arrGrant |
|
| 106 | + * @return boolean |
|
| 107 | + */ |
|
| 108 | 108 | function checkGrant($arrGrant) |
| 109 | 109 | { |
| 110 | 110 | if(!$arrGrant) |
@@ -27,32 +27,32 @@ discard block |
||
| 27 | 27 | $oModuleModel = getModel('module'); |
| 28 | 28 | $communication_config = $oModuleModel->getModuleConfig('communication'); |
| 29 | 29 | |
| 30 | - if(!is_object($communication_config)) |
|
| 30 | + if (!is_object($communication_config)) |
|
| 31 | 31 | { |
| 32 | 32 | $communication_config = new stdClass(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(!$communication_config->skin) |
|
| 35 | + if (!$communication_config->skin) |
|
| 36 | 36 | { |
| 37 | 37 | $communication_config->skin = 'default'; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if(!$communication_config->colorset) |
|
| 40 | + if (!$communication_config->colorset) |
|
| 41 | 41 | { |
| 42 | 42 | $communication_config->colorset = 'white'; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(!$communication_config->editor_skin) |
|
| 45 | + if (!$communication_config->editor_skin) |
|
| 46 | 46 | { |
| 47 | 47 | $communication_config->editor_skin = 'ckeditor'; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if(!$communication_config->mskin) |
|
| 50 | + if (!$communication_config->mskin) |
|
| 51 | 51 | { |
| 52 | 52 | $communication_config->mskin = 'default'; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if(!$communication_config->grant_write) |
|
| 55 | + if (!$communication_config->grant_write) |
|
| 56 | 56 | { |
| 57 | 57 | $communication_config->grant_write = array('default_grant'=>'member'); |
| 58 | 58 | } |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | function getGrantArray($default, $group) |
| 70 | 70 | { |
| 71 | 71 | $grant = array(); |
| 72 | - if($default!="") |
|
| 72 | + if ($default != "") |
|
| 73 | 73 | { |
| 74 | - switch($default) |
|
| 74 | + switch ($default) |
|
| 75 | 75 | { |
| 76 | 76 | case "-2": |
| 77 | 77 | $grant = array("default_grant"=>"site"); |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | break; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - else if(is_array($group)) |
|
| 87 | + else if (is_array($group)) |
|
| 88 | 88 | { |
| 89 | 89 | $oMemberModel = getModel('member'); |
| 90 | 90 | $group_list = $oMemberModel->getGroups($this->site_srl); |
| 91 | 91 | |
| 92 | 92 | $group_grant = array(); |
| 93 | - foreach($group as $group_srl) |
|
| 93 | + foreach ($group as $group_srl) |
|
| 94 | 94 | { |
| 95 | 95 | $group_grant[$group_srl] = $group_list[$group_srl]->title; |
| 96 | 96 | } |
@@ -107,37 +107,37 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | function checkGrant($arrGrant) |
| 109 | 109 | { |
| 110 | - if(!$arrGrant) |
|
| 110 | + if (!$arrGrant) |
|
| 111 | 111 | return false; |
| 112 | 112 | |
| 113 | 113 | $logged_info = Context::get('logged_info'); |
| 114 | - if(!$logged_info) |
|
| 114 | + if (!$logged_info) |
|
| 115 | 115 | return false; |
| 116 | 116 | |
| 117 | - if($logged_info->is_admin == "Y") |
|
| 117 | + if ($logged_info->is_admin == "Y") |
|
| 118 | 118 | return true; |
| 119 | 119 | |
| 120 | - if($arrGrant['default_grant']) |
|
| 120 | + if ($arrGrant['default_grant']) |
|
| 121 | 121 | { |
| 122 | - if($arrGrant['default_grant'] == "member" && $logged_info) |
|
| 122 | + if ($arrGrant['default_grant'] == "member" && $logged_info) |
|
| 123 | 123 | return true; |
| 124 | 124 | |
| 125 | - if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) |
|
| 125 | + if ($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) |
|
| 126 | 126 | return true; |
| 127 | 127 | |
| 128 | - if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") |
|
| 128 | + if ($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") |
|
| 129 | 129 | return true; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if($arrGrant['group_grant']) |
|
| 132 | + if ($arrGrant['group_grant']) |
|
| 133 | 133 | { |
| 134 | 134 | $group_grant = $arrGrant['group_grant']; |
| 135 | - if(!is_array($group_grant)) |
|
| 135 | + if (!is_array($group_grant)) |
|
| 136 | 136 | return false; |
| 137 | 137 | |
| 138 | - foreach($logged_info->group_list as $group_srl=>$title) |
|
| 138 | + foreach ($logged_info->group_list as $group_srl=>$title) |
|
| 139 | 139 | { |
| 140 | - if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title) |
|
| 140 | + if (isset($group_grant[$group_srl]) && $group_grant[$group_srl] == $title) |
|
| 141 | 141 | return true; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $output = executeQuery('communication.getMessage', $args, $columnList); |
| 163 | 163 | |
| 164 | 164 | $message = $output->data; |
| 165 | - if(!$message) |
|
| 165 | + if (!$message) |
|
| 166 | 166 | { |
| 167 | 167 | return; |
| 168 | 168 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | // get recipient's information if it is a sent message |
| 171 | 171 | $oMemberModel = getModel('member'); |
| 172 | 172 | |
| 173 | - if($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S') |
|
| 173 | + if ($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S') |
|
| 174 | 174 | { |
| 175 | 175 | $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->receiver_srl); |
| 176 | 176 | } |
@@ -180,22 +180,22 @@ discard block |
||
| 180 | 180 | $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->sender_srl); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if($member_info) |
|
| 183 | + if ($member_info) |
|
| 184 | 184 | { |
| 185 | - foreach($member_info as $key => $val) |
|
| 185 | + foreach ($member_info as $key => $val) |
|
| 186 | 186 | { |
| 187 | - if($key === 'title') continue; |
|
| 188 | - if($key === 'content') continue; |
|
| 189 | - if($key === 'sender_srl') continue; |
|
| 190 | - if($key === 'password') continue; |
|
| 191 | - if($key === 'regdate') continue; |
|
| 187 | + if ($key === 'title') continue; |
|
| 188 | + if ($key === 'content') continue; |
|
| 189 | + if ($key === 'sender_srl') continue; |
|
| 190 | + if ($key === 'password') continue; |
|
| 191 | + if ($key === 'regdate') continue; |
|
| 192 | 192 | |
| 193 | 193 | $message->{$key} = $val; |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // change the status if is a received and not yet read message |
| 198 | - if($message->message_type == 'R' && $message->readed != 'Y') |
|
| 198 | + if ($message->message_type == 'R' && $message->readed != 'Y') |
|
| 199 | 199 | { |
| 200 | 200 | $oCommunicationController = getController('communication'); |
| 201 | 201 | $oCommunicationController->setMessageReaded($message_srl); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $args->readed = 'N'; |
| 219 | 219 | |
| 220 | 220 | $output = executeQuery('communication.getNewMessage', $args, $columnList); |
| 221 | - if(!count($output->data)) |
|
| 221 | + if (!count($output->data)) |
|
| 222 | 222 | { |
| 223 | 223 | return; |
| 224 | 224 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $logged_info = Context::get('logged_info'); |
| 243 | 243 | $args = new stdClass(); |
| 244 | 244 | |
| 245 | - switch($message_type) |
|
| 245 | + switch ($message_type) |
|
| 246 | 246 | { |
| 247 | 247 | case 'R' : |
| 248 | 248 | $args->member_srl = $logged_info->member_srl; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $output = executeQueryArray('communication.getFriendGroups', $args); |
| 348 | 348 | |
| 349 | 349 | $group_list = $output->data; |
| 350 | - if(!$group_list) |
|
| 350 | + if (!$group_list) |
|
| 351 | 351 | { |
| 352 | 352 | return; |
| 353 | 353 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | $output = executeQuery('communication.isAddedFriend', $args); |
| 372 | 372 | |
| 373 | - if($output->data->count) |
|
| 373 | + if ($output->data->count) |
|
| 374 | 374 | { |
| 375 | 375 | return TRUE; |
| 376 | 376 | } |
@@ -83,8 +83,7 @@ discard block |
||
| 83 | 83 | $grant = array("default_grant"=>"member"); |
| 84 | 84 | break; |
| 85 | 85 | } |
| 86 | - } |
|
| 87 | - else if(is_array($group)) |
|
| 86 | + } else if(is_array($group)) |
|
| 88 | 87 | { |
| 89 | 88 | $oMemberModel = getModel('member'); |
| 90 | 89 | $group_list = $oMemberModel->getGroups($this->site_srl); |
@@ -107,38 +106,46 @@ discard block |
||
| 107 | 106 | */ |
| 108 | 107 | function checkGrant($arrGrant) |
| 109 | 108 | { |
| 110 | - if(!$arrGrant) |
|
| 111 | - return false; |
|
| 109 | + if(!$arrGrant) { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | $logged_info = Context::get('logged_info'); |
| 114 | - if(!$logged_info) |
|
| 115 | - return false; |
|
| 114 | + if(!$logged_info) { |
|
| 115 | + return false; |
|
| 116 | + } |
|
| 116 | 117 | |
| 117 | - if($logged_info->is_admin == "Y") |
|
| 118 | - return true; |
|
| 118 | + if($logged_info->is_admin == "Y") { |
|
| 119 | + return true; |
|
| 120 | + } |
|
| 119 | 121 | |
| 120 | 122 | if($arrGrant['default_grant']) |
| 121 | 123 | { |
| 122 | - if($arrGrant['default_grant'] == "member" && $logged_info) |
|
| 123 | - return true; |
|
| 124 | + if($arrGrant['default_grant'] == "member" && $logged_info) { |
|
| 125 | + return true; |
|
| 126 | + } |
|
| 124 | 127 | |
| 125 | - if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) |
|
| 126 | - return true; |
|
| 128 | + if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) { |
|
| 129 | + return true; |
|
| 130 | + } |
|
| 127 | 131 | |
| 128 | - if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") |
|
| 129 | - return true; |
|
| 132 | + if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") { |
|
| 133 | + return true; |
|
| 134 | + } |
|
| 130 | 135 | } |
| 131 | 136 | |
| 132 | 137 | if($arrGrant['group_grant']) |
| 133 | 138 | { |
| 134 | 139 | $group_grant = $arrGrant['group_grant']; |
| 135 | - if(!is_array($group_grant)) |
|
| 136 | - return false; |
|
| 140 | + if(!is_array($group_grant)) { |
|
| 141 | + return false; |
|
| 142 | + } |
|
| 137 | 143 | |
| 138 | 144 | foreach($logged_info->group_list as $group_srl=>$title) |
| 139 | 145 | { |
| 140 | - if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title) |
|
| 141 | - return true; |
|
| 146 | + if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title) { |
|
| 147 | + return true; |
|
| 148 | + } |
|
| 142 | 149 | } |
| 143 | 150 | |
| 144 | 151 | } |
@@ -184,11 +191,21 @@ discard block |
||
| 184 | 191 | { |
| 185 | 192 | foreach($member_info as $key => $val) |
| 186 | 193 | { |
| 187 | - if($key === 'title') continue; |
|
| 188 | - if($key === 'content') continue; |
|
| 189 | - if($key === 'sender_srl') continue; |
|
| 190 | - if($key === 'password') continue; |
|
| 191 | - if($key === 'regdate') continue; |
|
| 194 | + if($key === 'title') { |
|
| 195 | + continue; |
|
| 196 | + } |
|
| 197 | + if($key === 'content') { |
|
| 198 | + continue; |
|
| 199 | + } |
|
| 200 | + if($key === 'sender_srl') { |
|
| 201 | + continue; |
|
| 202 | + } |
|
| 203 | + if($key === 'password') { |
|
| 204 | + continue; |
|
| 205 | + } |
|
| 206 | + if($key === 'regdate') { |
|
| 207 | + continue; |
|
| 208 | + } |
|
| 192 | 209 | |
| 193 | 210 | $message->{$key} = $val; |
| 194 | 211 | } |
@@ -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) |
@@ -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 */ |
@@ -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 BaseObject(0,'success_updated'); |
|
| 340 | + return new BaseObject(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 | } |
@@ -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,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') && abs($this->get('member_srl')) == $logged_info->member_srl) |
|
| 178 | + if ($this->get('member_srl') && abs($this->get('member_srl')) == $logged_info->member_srl) |
|
| 179 | 179 | { |
| 180 | 180 | return $this->grant_cache = true; |
| 181 | 181 | } |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | function isAccessible() |
| 193 | 193 | { |
| 194 | - return $_SESSION['accessible'][$this->document_srl]==true?true:false; |
|
| 194 | + return $_SESSION['accessible'][$this->document_srl] == true ?true:false; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | function allowComment() |
| 198 | 198 | { |
| 199 | 199 | // init write, document is not exists. so allow comment status is true |
| 200 | - if(!$this->isExists()) return true; |
|
| 200 | + if (!$this->isExists()) return true; |
|
| 201 | 201 | |
| 202 | 202 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
| 203 | 203 | } |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | function allowTrackback() |
| 206 | 206 | { |
| 207 | 207 | static $allow_trackback_status = null; |
| 208 | - if(is_null($allow_trackback_status)) |
|
| 208 | + if (is_null($allow_trackback_status)) |
|
| 209 | 209 | { |
| 210 | 210 | |
| 211 | 211 | // Check the tarckback module exist |
| 212 | - if(!getClass('trackback')) |
|
| 212 | + if (!getClass('trackback')) |
|
| 213 | 213 | { |
| 214 | 214 | $allow_trackback_status = false; |
| 215 | 215 | } |
@@ -219,20 +219,20 @@ discard block |
||
| 219 | 219 | $oModuleModel = getModel('module'); |
| 220 | 220 | $trackback_config = $oModuleModel->getModuleConfig('trackback'); |
| 221 | 221 | |
| 222 | - if(!$trackback_config) |
|
| 222 | + if (!$trackback_config) |
|
| 223 | 223 | { |
| 224 | 224 | $trackback_config = new stdClass(); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 228 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 227 | + if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 228 | + if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 229 | 229 | else |
| 230 | 230 | { |
| 231 | 231 | $module_srl = $this->get('module_srl'); |
| 232 | 232 | // Check settings of each module |
| 233 | 233 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
| 234 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 235 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 234 | + if ($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 235 | + else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | function isLocked() |
| 243 | 243 | { |
| 244 | - if(!$this->isExists()) return false; |
|
| 244 | + if (!$this->isExists()) return false; |
|
| 245 | 245 | |
| 246 | 246 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | function isEditable() |
| 250 | 250 | { |
| 251 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 251 | + if ($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 252 | 252 | return false; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | function useNotify() |
| 267 | 267 | { |
| 268 | - return $this->get('notify_message')=='Y' ? true : false; |
|
| 268 | + return $this->get('notify_message') == 'Y' ? true : false; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | function doCart() |
| 272 | 272 | { |
| 273 | - if(!$this->document_srl) return false; |
|
| 274 | - if($this->isCarted()) $this->removeCart(); |
|
| 273 | + if (!$this->document_srl) return false; |
|
| 274 | + if ($this->isCarted()) $this->removeCart(); |
|
| 275 | 275 | else $this->addCart(); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -298,18 +298,18 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | function notify($type, $content) |
| 300 | 300 | { |
| 301 | - if(!$this->document_srl) return; |
|
| 301 | + if (!$this->document_srl) return; |
|
| 302 | 302 | // return if it is not useNotify |
| 303 | - if(!$this->useNotify()) return; |
|
| 303 | + if (!$this->useNotify()) return; |
|
| 304 | 304 | // Pass if an author is not a logged-in user |
| 305 | - if(!$this->get('member_srl')) return; |
|
| 305 | + if (!$this->get('member_srl')) return; |
|
| 306 | 306 | // Return if the currently logged-in user is an author |
| 307 | 307 | $logged_info = Context::get('logged_info'); |
| 308 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 308 | + if ($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 309 | 309 | // List variables |
| 310 | - if($type) $title = "[".$type."] "; |
|
| 310 | + if ($type) $title = "[".$type."] "; |
|
| 311 | 311 | $title .= cut_str(strip_tags($content), 10, '...'); |
| 312 | - $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)); |
|
| 312 | + $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)); |
|
| 313 | 313 | $receiver_srl = $this->get('member_srl'); |
| 314 | 314 | $sender_member_srl = $logged_info->member_srl; |
| 315 | 315 | // Send a message |
@@ -324,26 +324,26 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | function getIpAddress() |
| 326 | 326 | { |
| 327 | - if($this->isGranted()) |
|
| 327 | + if ($this->isGranted()) |
|
| 328 | 328 | { |
| 329 | 329 | return $this->get('ipaddress'); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - return '*' . strstr($this->get('ipaddress'), '.'); |
|
| 332 | + return '*'.strstr($this->get('ipaddress'), '.'); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | function isExistsHomepage() |
| 336 | 336 | { |
| 337 | - if(trim($this->get('homepage'))) return true; |
|
| 337 | + if (trim($this->get('homepage'))) return true; |
|
| 338 | 338 | return false; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | function getHomepageUrl() |
| 342 | 342 | { |
| 343 | 343 | $url = trim($this->get('homepage')); |
| 344 | - if(!$url) return; |
|
| 344 | + if (!$url) return; |
|
| 345 | 345 | |
| 346 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
| 346 | + if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://'.$url; |
|
| 347 | 347 | |
| 348 | 348 | return $url; |
| 349 | 349 | } |
@@ -373,52 +373,52 @@ discard block |
||
| 373 | 373 | return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - function getTitleText($cut_size = 0, $tail='...') |
|
| 376 | + function getTitleText($cut_size = 0, $tail = '...') |
|
| 377 | 377 | { |
| 378 | - if(!$this->document_srl) return; |
|
| 378 | + if (!$this->document_srl) return; |
|
| 379 | 379 | |
| 380 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 380 | + if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 381 | 381 | else $title = $this->get('title'); |
| 382 | 382 | |
| 383 | 383 | return $title; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - function getTitle($cut_size = 0, $tail='...') |
|
| 386 | + function getTitle($cut_size = 0, $tail = '...') |
|
| 387 | 387 | { |
| 388 | - if(!$this->document_srl) return; |
|
| 388 | + if (!$this->document_srl) return; |
|
| 389 | 389 | |
| 390 | 390 | $title = $this->getTitleText($cut_size, $tail); |
| 391 | 391 | |
| 392 | 392 | $attrs = array(); |
| 393 | 393 | $this->add('title_color', trim($this->get('title_color'))); |
| 394 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
| 395 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 394 | + if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;"; |
|
| 395 | + if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 396 | 396 | |
| 397 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 397 | + if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 398 | 398 | else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | function getContentText($strlen = 0) |
| 402 | 402 | { |
| 403 | - if(!$this->document_srl) return; |
|
| 403 | + if (!$this->document_srl) return; |
|
| 404 | 404 | |
| 405 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 405 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 406 | 406 | |
| 407 | 407 | $result = $this->_checkAccessibleFromStatus(); |
| 408 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 408 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 409 | 409 | |
| 410 | 410 | $content = $this->get('content'); |
| 411 | 411 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
| 412 | 412 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
| 413 | 413 | |
| 414 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
| 414 | + if ($strlen) return cut_str(strip_tags($content), $strlen, '...'); |
|
| 415 | 415 | |
| 416 | 416 | return htmlspecialchars($content); |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | function _addAllowScriptAccess($m) |
| 420 | 420 | { |
| 421 | - if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
| 421 | + if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
| 422 | 422 | { |
| 423 | 423 | $m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>'; |
| 424 | 424 | } |
@@ -428,26 +428,26 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | function _checkAllowScriptAccess($m) |
| 430 | 430 | { |
| 431 | - if($m[1] == 'object') |
|
| 431 | + if ($m[1] == 'object') |
|
| 432 | 432 | { |
| 433 | 433 | $this->allowscriptaccessList[] = 1; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if($m[1] == 'param') |
|
| 436 | + if ($m[1] == 'param') |
|
| 437 | 437 | { |
| 438 | - if(stripos($m[0], 'allowscriptaccess')) |
|
| 438 | + if (stripos($m[0], 'allowscriptaccess')) |
|
| 439 | 439 | { |
| 440 | 440 | $m[0] = '<param name="allowscriptaccess" value="never"'; |
| 441 | - if(substr($m[0], -1) == '/') |
|
| 441 | + if (substr($m[0], -1) == '/') |
|
| 442 | 442 | { |
| 443 | 443 | $m[0] .= '/'; |
| 444 | 444 | } |
| 445 | - $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
|
| 445 | + $this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--; |
|
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | - else if($m[1] == 'embed') |
|
| 448 | + else if ($m[1] == 'embed') |
|
| 449 | 449 | { |
| 450 | - if(stripos($m[0], 'allowscriptaccess')) |
|
| 450 | + if (stripos($m[0], 'allowscriptaccess')) |
|
| 451 | 451 | { |
| 452 | 452 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
| 453 | 453 | } |
@@ -461,24 +461,24 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
| 463 | 463 | { |
| 464 | - if(!$this->document_srl) return; |
|
| 464 | + if (!$this->document_srl) return; |
|
| 465 | 465 | |
| 466 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 466 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 467 | 467 | |
| 468 | 468 | $result = $this->_checkAccessibleFromStatus(); |
| 469 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 469 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 470 | 470 | |
| 471 | 471 | $content = $this->get('content'); |
| 472 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 472 | + if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 473 | 473 | |
| 474 | 474 | // Define a link if using a rewrite module |
| 475 | 475 | $oContext = &Context::getInstance(); |
| 476 | - if($oContext->allow_rewrite) |
|
| 476 | + if ($oContext->allow_rewrite) |
|
| 477 | 477 | { |
| 478 | - $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content); |
|
| 478 | + $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2".Context::getRequestUri()."?", $content); |
|
| 479 | 479 | } |
| 480 | 480 | // To display a pop-up menu |
| 481 | - if($add_popup_menu) |
|
| 481 | + if ($add_popup_menu) |
|
| 482 | 482 | { |
| 483 | 483 | $content = sprintf( |
| 484 | 484 | '%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>', |
@@ -487,10 +487,10 @@ discard block |
||
| 487 | 487 | ); |
| 488 | 488 | } |
| 489 | 489 | // If additional content information is set |
| 490 | - if($add_content_info) |
|
| 490 | + if ($add_content_info) |
|
| 491 | 491 | { |
| 492 | 492 | $memberSrl = $this->get('member_srl'); |
| 493 | - if($memberSrl < 0) |
|
| 493 | + if ($memberSrl < 0) |
|
| 494 | 494 | { |
| 495 | 495 | $memberSrl = 0; |
| 496 | 496 | } |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | } |
| 507 | 507 | else |
| 508 | 508 | { |
| 509 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 509 | + if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 510 | 510 | } |
| 511 | 511 | // Change the image path to a valid absolute path if resource_realpath is true |
| 512 | - if($resource_realpath) |
|
| 512 | + if ($resource_realpath) |
|
| 513 | 513 | { |
| 514 | - $content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content); |
|
| 514 | + $content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | return $content; |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | $content = trim(cut_str($content, $str_size, $tail)); |
| 561 | 561 | |
| 562 | 562 | // Replace back < , <, " |
| 563 | - $content = str_replace(array('<', '>', '"'),array('<', '>', '"'), $content); |
|
| 563 | + $content = str_replace(array('<', '>', '"'), array('<', '>', '"'), $content); |
|
| 564 | 564 | |
| 565 | 565 | return $content; |
| 566 | 566 | } |
@@ -573,13 +573,13 @@ discard block |
||
| 573 | 573 | function getRegdateTime() |
| 574 | 574 | { |
| 575 | 575 | $regdate = $this->get('regdate'); |
| 576 | - $year = substr($regdate,0,4); |
|
| 577 | - $month = substr($regdate,4,2); |
|
| 578 | - $day = substr($regdate,6,2); |
|
| 579 | - $hour = substr($regdate,8,2); |
|
| 580 | - $min = substr($regdate,10,2); |
|
| 581 | - $sec = substr($regdate,12,2); |
|
| 582 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
| 576 | + $year = substr($regdate, 0, 4); |
|
| 577 | + $month = substr($regdate, 4, 2); |
|
| 578 | + $day = substr($regdate, 6, 2); |
|
| 579 | + $hour = substr($regdate, 8, 2); |
|
| 580 | + $min = substr($regdate, 10, 2); |
|
| 581 | + $sec = substr($regdate, 12, 2); |
|
| 582 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | function getRegdateGM() |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | function getRegdateDT() |
| 591 | 591 | { |
| 592 | - return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
| 592 | + return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | function getUpdate($format = 'Y.m.d H:i:s') |
@@ -599,13 +599,13 @@ discard block |
||
| 599 | 599 | |
| 600 | 600 | function getUpdateTime() |
| 601 | 601 | { |
| 602 | - $year = substr($this->get('last_update'),0,4); |
|
| 603 | - $month = substr($this->get('last_update'),4,2); |
|
| 604 | - $day = substr($this->get('last_update'),6,2); |
|
| 605 | - $hour = substr($this->get('last_update'),8,2); |
|
| 606 | - $min = substr($this->get('last_update'),10,2); |
|
| 607 | - $sec = substr($this->get('last_update'),12,2); |
|
| 608 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
| 602 | + $year = substr($this->get('last_update'), 0, 4); |
|
| 603 | + $month = substr($this->get('last_update'), 4, 2); |
|
| 604 | + $day = substr($this->get('last_update'), 6, 2); |
|
| 605 | + $hour = substr($this->get('last_update'), 8, 2); |
|
| 606 | + $min = substr($this->get('last_update'), 10, 2); |
|
| 607 | + $sec = substr($this->get('last_update'), 12, 2); |
|
| 608 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | function getUpdateGM() |
@@ -615,21 +615,21 @@ discard block |
||
| 615 | 615 | |
| 616 | 616 | function getUpdateDT() |
| 617 | 617 | { |
| 618 | - return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
| 618 | + return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | function getPermanentUrl() |
| 622 | 622 | { |
| 623 | - return getFullUrl('','mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl')); |
|
| 623 | + return getFullUrl('', 'mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl')); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | function getTrackbackUrl() |
| 627 | 627 | { |
| 628 | - if(!$this->document_srl) return; |
|
| 628 | + if (!$this->document_srl) return; |
|
| 629 | 629 | |
| 630 | 630 | // Generate a key to prevent spams |
| 631 | 631 | $oTrackbackModel = getModel('trackback'); |
| 632 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 632 | + if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -639,24 +639,24 @@ discard block |
||
| 639 | 639 | function updateReadedCount() |
| 640 | 640 | { |
| 641 | 641 | $oDocumentController = getController('document'); |
| 642 | - if($oDocumentController->updateReadedCount($this)) |
|
| 642 | + if ($oDocumentController->updateReadedCount($this)) |
|
| 643 | 643 | { |
| 644 | 644 | $readed_count = $this->get('readed_count'); |
| 645 | - $this->add('readed_count', $readed_count+1); |
|
| 645 | + $this->add('readed_count', $readed_count + 1); |
|
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | function isExtraVarsExists() |
| 650 | 650 | { |
| 651 | - if(!$this->get('module_srl')) return false; |
|
| 651 | + if (!$this->get('module_srl')) return false; |
|
| 652 | 652 | $oDocumentModel = getModel('document'); |
| 653 | 653 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
| 654 | - return count($extra_keys)?true:false; |
|
| 654 | + return count($extra_keys) ?true:false; |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | function getExtraVars() |
| 658 | 658 | { |
| 659 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 659 | + if (!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 660 | 660 | |
| 661 | 661 | $oDocumentModel = getModel('document'); |
| 662 | 662 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | function getExtraValue($idx) |
| 666 | 666 | { |
| 667 | 667 | $extra_vars = $this->getExtraVars(); |
| 668 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
| 668 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
| 669 | 669 | { |
| 670 | 670 | return $extra_vars[$idx]->getValue(); |
| 671 | 671 | } |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | function getExtraValueHTML($idx) |
| 679 | 679 | { |
| 680 | 680 | $extra_vars = $this->getExtraVars(); |
| 681 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
| 681 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
| 682 | 682 | { |
| 683 | 683 | return $extra_vars[$idx]->getValueHTML(); |
| 684 | 684 | } |
@@ -692,16 +692,16 @@ discard block |
||
| 692 | 692 | { |
| 693 | 693 | $extra_vars = $this->getExtraVars(); |
| 694 | 694 | |
| 695 | - if($extra_vars) |
|
| 695 | + if ($extra_vars) |
|
| 696 | 696 | { |
| 697 | 697 | // Handle extra variable(eid) |
| 698 | - foreach($extra_vars as $idx => $key) |
|
| 698 | + foreach ($extra_vars as $idx => $key) |
|
| 699 | 699 | { |
| 700 | 700 | $extra_eid[$key->eid] = $key; |
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
| 704 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
| 705 | 705 | { |
| 706 | 706 | return $extra_eid[$eid]->getValue(); |
| 707 | 707 | } |
@@ -715,12 +715,12 @@ discard block |
||
| 715 | 715 | { |
| 716 | 716 | $extra_vars = $this->getExtraVars(); |
| 717 | 717 | // Handle extra variable(eid) |
| 718 | - foreach($extra_vars as $idx => $key) |
|
| 718 | + foreach ($extra_vars as $idx => $key) |
|
| 719 | 719 | { |
| 720 | 720 | $extra_eid[$key->eid] = $key; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
| 723 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
| 724 | 724 | { |
| 725 | 725 | return $extra_eid[$eid]->getValueHTML(); |
| 726 | 726 | } |
@@ -744,13 +744,13 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | function getComments() |
| 746 | 746 | { |
| 747 | - if(!$this->getCommentCount()) return; |
|
| 748 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
| 747 | + if (!$this->getCommentCount()) return; |
|
| 748 | + if (!$this->isGranted() && $this->isSecret()) return; |
|
| 749 | 749 | // cpage is a number of comment pages |
| 750 | 750 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
| 751 | 751 | $cpage = Context::get($cpageStr); |
| 752 | 752 | |
| 753 | - if(!$cpage) |
|
| 753 | + if (!$cpage) |
|
| 754 | 754 | { |
| 755 | 755 | $cpage = Context::get('cpage'); |
| 756 | 756 | } |
@@ -758,19 +758,19 @@ discard block |
||
| 758 | 758 | // Get a list of comments |
| 759 | 759 | $oCommentModel = getModel('comment'); |
| 760 | 760 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
| 761 | - if(!$output->toBool() || !count($output->data)) return; |
|
| 761 | + if (!$output->toBool() || !count($output->data)) return; |
|
| 762 | 762 | // Create commentItem object from a comment list |
| 763 | 763 | // If admin priviledge is granted on parent posts, you can read its child posts. |
| 764 | 764 | $accessible = array(); |
| 765 | 765 | $comment_list = array(); |
| 766 | - foreach($output->data as $key => $val) |
|
| 766 | + foreach ($output->data as $key => $val) |
|
| 767 | 767 | { |
| 768 | 768 | $oCommentItem = new commentItem(); |
| 769 | 769 | $oCommentItem->setAttribute($val); |
| 770 | 770 | // If permission is granted to the post, you can access it temporarily |
| 771 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 771 | + if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 772 | 772 | // 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 |
| 773 | - if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
|
| 773 | + if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) |
|
| 774 | 774 | { |
| 775 | 775 | $oCommentItem->setAccessible(); |
| 776 | 776 | } |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | // Variable setting to be displayed on the skin |
| 780 | 780 | Context::set($cpageStr, $output->page_navigation->cur_page); |
| 781 | 781 | Context::set('cpage', $output->page_navigation->cur_page); |
| 782 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
| 782 | + if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation; |
|
| 783 | 783 | |
| 784 | 784 | return $comment_list; |
| 785 | 785 | } |
@@ -791,9 +791,9 @@ discard block |
||
| 791 | 791 | |
| 792 | 792 | function getTrackbacks() |
| 793 | 793 | { |
| 794 | - if(!$this->document_srl) return; |
|
| 794 | + if (!$this->document_srl) return; |
|
| 795 | 795 | |
| 796 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 796 | + if (!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 797 | 797 | |
| 798 | 798 | $oTrackbackModel = getModel('trackback'); |
| 799 | 799 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -801,47 +801,47 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | function thumbnailExists($width = 80, $height = 0, $type = '') |
| 803 | 803 | { |
| 804 | - if(!$this->document_srl) return false; |
|
| 805 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
| 804 | + if (!$this->document_srl) return false; |
|
| 805 | + if (!$this->getThumbnail($width, $height, $type)) return false; |
|
| 806 | 806 | return true; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
| 810 | 810 | { |
| 811 | 811 | // Return false if the document doesn't exist |
| 812 | - if(!$this->document_srl) return; |
|
| 812 | + if (!$this->document_srl) return; |
|
| 813 | 813 | |
| 814 | - if($this->isSecret() && !$this->isGranted()) |
|
| 814 | + if ($this->isSecret() && !$this->isGranted()) |
|
| 815 | 815 | { |
| 816 | 816 | return; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | // If not specify its height, create a square |
| 820 | - if(!$height) $height = $width; |
|
| 820 | + if (!$height) $height = $width; |
|
| 821 | 821 | |
| 822 | 822 | // Return false if neither attachement nor image files in the document |
| 823 | 823 | $content = $this->get('content'); |
| 824 | - if(!$this->get('uploaded_count')) |
|
| 824 | + if (!$this->get('uploaded_count')) |
|
| 825 | 825 | { |
| 826 | - if(!$content) |
|
| 826 | + if (!$content) |
|
| 827 | 827 | { |
| 828 | 828 | $args = new stdClass(); |
| 829 | 829 | $args->document_srl = $this->document_srl; |
| 830 | 830 | $output = executeQuery('document.getDocument', $args, array('content')); |
| 831 | - if($output->toBool() && $output->data) |
|
| 831 | + if ($output->toBool() && $output->data) |
|
| 832 | 832 | { |
| 833 | 833 | $content = $output->data->content; |
| 834 | 834 | $this->add('content', $content); |
| 835 | 835 | } |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - if(!preg_match("!<img!is", $content)) return; |
|
| 838 | + if (!preg_match("!<img!is", $content)) return; |
|
| 839 | 839 | } |
| 840 | 840 | // Get thumbnai_type information from document module's configuration |
| 841 | - if(!in_array($thumbnail_type, array('crop','ratio'))) |
|
| 841 | + if (!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
| 842 | 842 | { |
| 843 | 843 | $config = $GLOBALS['__document_config__']; |
| 844 | - if(!$config) |
|
| 844 | + if (!$config) |
|
| 845 | 845 | { |
| 846 | 846 | $oDocumentModel = getModel('document'); |
| 847 | 847 | $config = $oDocumentModel->getDocumentConfig(); |
@@ -851,15 +851,15 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | // Define thumbnail information |
| 854 | - $thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3)); |
|
| 854 | + $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3)); |
|
| 855 | 855 | $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); |
| 856 | 856 | $thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type); |
| 857 | 857 | $thumbnail_url = Context::getRequestUri().$thumbnail_file; |
| 858 | 858 | |
| 859 | 859 | // Return false if thumbnail file exists and its size is 0. Otherwise, return its path |
| 860 | - if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 860 | + if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 861 | 861 | { |
| 862 | - if(filesize($thumbnail_file) < 1) |
|
| 862 | + if (filesize($thumbnail_file) < 1) |
|
| 863 | 863 | { |
| 864 | 864 | return FALSE; |
| 865 | 865 | } |
@@ -877,64 +877,64 @@ discard block |
||
| 877 | 877 | $is_tmp_file = false; |
| 878 | 878 | |
| 879 | 879 | // Find an iamge file among attached files if exists |
| 880 | - if($this->hasUploadedFiles()) |
|
| 880 | + if ($this->hasUploadedFiles()) |
|
| 881 | 881 | { |
| 882 | 882 | $file_list = $this->getUploadedFiles(); |
| 883 | 883 | |
| 884 | 884 | $first_image = null; |
| 885 | - foreach($file_list as $file) |
|
| 885 | + foreach ($file_list as $file) |
|
| 886 | 886 | { |
| 887 | - if($file->direct_download !== 'Y') continue; |
|
| 887 | + if ($file->direct_download !== 'Y') continue; |
|
| 888 | 888 | |
| 889 | - if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 889 | + if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 890 | 890 | { |
| 891 | 891 | $source_file = $file->uploaded_filename; |
| 892 | 892 | break; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if($first_image) continue; |
|
| 895 | + if ($first_image) continue; |
|
| 896 | 896 | |
| 897 | - if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 897 | + if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 898 | 898 | { |
| 899 | - if(file_exists($file->uploaded_filename)) |
|
| 899 | + if (file_exists($file->uploaded_filename)) |
|
| 900 | 900 | { |
| 901 | 901 | $first_image = $file->uploaded_filename; |
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | - if(!$source_file && $first_image) |
|
| 906 | + if (!$source_file && $first_image) |
|
| 907 | 907 | { |
| 908 | 908 | $source_file = $first_image; |
| 909 | 909 | } |
| 910 | 910 | } |
| 911 | 911 | // If not exists, file an image file from the content |
| 912 | 912 | $is_tmp_file = false; |
| 913 | - if(!$source_file) |
|
| 913 | + if (!$source_file) |
|
| 914 | 914 | { |
| 915 | 915 | $random = new Password(); |
| 916 | 916 | |
| 917 | 917 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
| 918 | 918 | |
| 919 | - foreach($matches as $target_image) |
|
| 919 | + foreach ($matches as $target_image) |
|
| 920 | 920 | { |
| 921 | 921 | $target_src = trim($target_image[1]); |
| 922 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 922 | + if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 923 | 923 | |
| 924 | - if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
| 924 | + if (!preg_match('/^(http|https):\/\//i', $target_src)) |
|
| 925 | 925 | { |
| 926 | 926 | $target_src = Context::getRequestUri().$target_src; |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | $target_src = htmlspecialchars_decode($target_src); |
| 930 | 930 | |
| 931 | - $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
| 931 | + $tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex'); |
|
| 932 | 932 | FileHandler::getRemoteFile($target_src, $tmp_file); |
| 933 | - if(!file_exists($tmp_file)) continue; |
|
| 933 | + if (!file_exists($tmp_file)) continue; |
|
| 934 | 934 | |
| 935 | 935 | $imageinfo = getimagesize($tmp_file); |
| 936 | 936 | list($_w, $_h) = $imageinfo; |
| 937 | - if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 937 | + if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 938 | 938 | FileHandler::removeFile($tmp_file); |
| 939 | 939 | continue; |
| 940 | 940 | } |
@@ -945,13 +945,13 @@ discard block |
||
| 945 | 945 | } |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | - if($source_file) |
|
| 948 | + if ($source_file) |
|
| 949 | 949 | { |
| 950 | 950 | $output_file = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | // Remove source file if it was temporary |
| 954 | - if($is_tmp_file) |
|
| 954 | + if ($is_tmp_file) |
|
| 955 | 955 | { |
| 956 | 956 | FileHandler::removeFile($source_file); |
| 957 | 957 | } |
@@ -960,14 +960,14 @@ discard block |
||
| 960 | 960 | FileHandler::removeFile($thumbnail_lockfile); |
| 961 | 961 | |
| 962 | 962 | // Return the thumbnail path if it was successfully generated |
| 963 | - if($output_file) |
|
| 963 | + if ($output_file) |
|
| 964 | 964 | { |
| 965 | 965 | return $thumbnail_url; |
| 966 | 966 | } |
| 967 | 967 | // Create an empty file if thumbnail generation failed |
| 968 | 968 | else |
| 969 | 969 | { |
| 970 | - FileHandler::writeFile($thumbnail_file, '','w'); |
|
| 970 | + FileHandler::writeFile($thumbnail_file, '', 'w'); |
|
| 971 | 971 | } |
| 972 | 972 | |
| 973 | 973 | return; |
@@ -981,21 +981,21 @@ discard block |
||
| 981 | 981 | */ |
| 982 | 982 | function getExtraImages($time_interval = 43200) |
| 983 | 983 | { |
| 984 | - if(!$this->document_srl) return; |
|
| 984 | + if (!$this->document_srl) return; |
|
| 985 | 985 | // variables for icon list |
| 986 | 986 | $buffs = array(); |
| 987 | 987 | |
| 988 | 988 | $check_files = false; |
| 989 | 989 | |
| 990 | 990 | // Check if secret post is |
| 991 | - if($this->isSecret()) $buffs[] = "secret"; |
|
| 991 | + if ($this->isSecret()) $buffs[] = "secret"; |
|
| 992 | 992 | |
| 993 | 993 | // Set the latest time |
| 994 | - $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
|
| 994 | + $time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval); |
|
| 995 | 995 | |
| 996 | 996 | // Check new post |
| 997 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
| 998 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
| 997 | + if ($this->get('regdate') > $time_check) $buffs[] = "new"; |
|
| 998 | + else if ($this->get('last_update') > $time_check) $buffs[] = "update"; |
|
| 999 | 999 | |
| 1000 | 1000 | /* |
| 1001 | 1001 | $content = $this->get('content'); |
@@ -1018,14 +1018,14 @@ discard block |
||
| 1018 | 1018 | */ |
| 1019 | 1019 | |
| 1020 | 1020 | // Check the attachment |
| 1021 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1021 | + if ($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1022 | 1022 | |
| 1023 | 1023 | return $buffs; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | function getStatus() |
| 1027 | 1027 | { |
| 1028 | - if(!$this->get('status')) { |
|
| 1028 | + if (!$this->get('status')) { |
|
| 1029 | 1029 | $oDocumentClass = getClass('document'); |
| 1030 | 1030 | return $oDocumentClass->getDefaultStatus(); |
| 1031 | 1031 | } |
@@ -1039,11 +1039,11 @@ discard block |
||
| 1039 | 1039 | */ |
| 1040 | 1040 | function printExtraImages($time_check = 43200) |
| 1041 | 1041 | { |
| 1042 | - if(!$this->document_srl) return; |
|
| 1042 | + if (!$this->document_srl) return; |
|
| 1043 | 1043 | |
| 1044 | 1044 | $oDocumentModel = getModel('document'); |
| 1045 | 1045 | $documentConfig = $oDocumentModel->getDocumentConfig(); |
| 1046 | - if(Mobile::isFromMobilePhone()) |
|
| 1046 | + if (Mobile::isFromMobilePhone()) |
|
| 1047 | 1047 | { |
| 1048 | 1048 | $iconSkin = $documentConfig->micons; |
| 1049 | 1049 | } |
@@ -1051,13 +1051,13 @@ discard block |
||
| 1051 | 1051 | { |
| 1052 | 1052 | $iconSkin = $documentConfig->icons; |
| 1053 | 1053 | } |
| 1054 | - $path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
| 1054 | + $path = sprintf('%s%s', getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
| 1055 | 1055 | |
| 1056 | 1056 | $buffs = $this->getExtraImages($time_check); |
| 1057 | - if(!count($buffs)) return; |
|
| 1057 | + if (!count($buffs)) return; |
|
| 1058 | 1058 | |
| 1059 | 1059 | $buff = array(); |
| 1060 | - foreach($buffs as $key => $val) |
|
| 1060 | + foreach ($buffs as $key => $val) |
|
| 1061 | 1061 | { |
| 1062 | 1062 | $buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val); |
| 1063 | 1063 | } |
@@ -1066,20 +1066,20 @@ discard block |
||
| 1066 | 1066 | |
| 1067 | 1067 | function hasUploadedFiles() |
| 1068 | 1068 | { |
| 1069 | - if(!$this->document_srl) return; |
|
| 1069 | + if (!$this->document_srl) return; |
|
| 1070 | 1070 | |
| 1071 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
| 1072 | - return $this->get('uploaded_count')? true : false; |
|
| 1071 | + if ($this->isSecret() && !$this->isGranted()) return false; |
|
| 1072 | + return $this->get('uploaded_count') ? true : false; |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | function getUploadedFiles($sortIndex = 'file_srl') |
| 1076 | 1076 | { |
| 1077 | - if(!$this->document_srl) return; |
|
| 1077 | + if (!$this->document_srl) return; |
|
| 1078 | 1078 | |
| 1079 | - if($this->isSecret() && !$this->isGranted()) return; |
|
| 1080 | - if(!$this->get('uploaded_count')) return; |
|
| 1079 | + if ($this->isSecret() && !$this->isGranted()) return; |
|
| 1080 | + if (!$this->get('uploaded_count')) return; |
|
| 1081 | 1081 | |
| 1082 | - if(!$this->uploadedFiles[$sortIndex]) |
|
| 1082 | + if (!$this->uploadedFiles[$sortIndex]) |
|
| 1083 | 1083 | { |
| 1084 | 1084 | $oFileModel = getModel('file'); |
| 1085 | 1085 | $this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true); |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | function getEditor() |
| 1096 | 1096 | { |
| 1097 | 1097 | $module_srl = $this->get('module_srl'); |
| 1098 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1098 | + if (!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1099 | 1099 | |
| 1100 | 1100 | $oEditorModel = getModel('editor'); |
| 1101 | 1101 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | { |
| 1111 | 1111 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
| 1112 | 1112 | if (!$this->allowComment()) return false; |
| 1113 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
| 1113 | + if (!$this->isGranted() && $this->isSecret()) return false; |
|
| 1114 | 1114 | |
| 1115 | 1115 | return true; |
| 1116 | 1116 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | */ |
| 1122 | 1122 | function getCommentEditor() |
| 1123 | 1123 | { |
| 1124 | - if(!$this->isEnableComment()) return; |
|
| 1124 | + if (!$this->isEnableComment()) return; |
|
| 1125 | 1125 | |
| 1126 | 1126 | $oEditorModel = getModel('editor'); |
| 1127 | 1127 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1133,10 +1133,10 @@ discard block |
||
| 1133 | 1133 | */ |
| 1134 | 1134 | function getProfileImage() |
| 1135 | 1135 | { |
| 1136 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1136 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1137 | 1137 | $oMemberModel = getModel('member'); |
| 1138 | 1138 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
| 1139 | - if(!$profile_info) return; |
|
| 1139 | + if (!$profile_info) return; |
|
| 1140 | 1140 | |
| 1141 | 1141 | return $profile_info->src; |
| 1142 | 1142 | } |
@@ -1148,21 +1148,21 @@ discard block |
||
| 1148 | 1148 | function getSignature() |
| 1149 | 1149 | { |
| 1150 | 1150 | // Pass if a document doesn't exist |
| 1151 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1151 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1152 | 1152 | // Get signature information |
| 1153 | 1153 | $oMemberModel = getModel('member'); |
| 1154 | 1154 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
| 1155 | 1155 | // Check if a maximum height of signiture is set in the member module |
| 1156 | - if(!isset($GLOBALS['__member_signature_max_height'])) |
|
| 1156 | + if (!isset($GLOBALS['__member_signature_max_height'])) |
|
| 1157 | 1157 | { |
| 1158 | 1158 | $oModuleModel = getModel('module'); |
| 1159 | 1159 | $member_config = $oModuleModel->getModuleConfig('member'); |
| 1160 | 1160 | $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; |
| 1161 | 1161 | } |
| 1162 | - if($signature) |
|
| 1162 | + if ($signature) |
|
| 1163 | 1163 | { |
| 1164 | 1164 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
| 1165 | - 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); |
|
| 1165 | + 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); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | return $signature; |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | */ |
| 1176 | 1176 | function replaceResourceRealPath($matches) |
| 1177 | 1177 | { |
| 1178 | - return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
| 1178 | + return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | /** |
@@ -1186,19 +1186,19 @@ discard block |
||
| 1186 | 1186 | function _checkAccessibleFromStatus() |
| 1187 | 1187 | { |
| 1188 | 1188 | $logged_info = Context::get('logged_info'); |
| 1189 | - if($logged_info->is_admin == 'Y') return true; |
|
| 1189 | + if ($logged_info->is_admin == 'Y') return true; |
|
| 1190 | 1190 | |
| 1191 | 1191 | $status = $this->get('status'); |
| 1192 | - if(empty($status)) return false; |
|
| 1192 | + if (empty($status)) return false; |
|
| 1193 | 1193 | |
| 1194 | 1194 | $oDocumentModel = getModel('document'); |
| 1195 | 1195 | $configStatusList = $oDocumentModel->getStatusList(); |
| 1196 | 1196 | |
| 1197 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1197 | + if ($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1198 | 1198 | return true; |
| 1199 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1199 | + else if ($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1200 | 1200 | { |
| 1201 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
| 1201 | + if ($this->get('member_srl') == $logged_info->member_srl) |
|
| 1202 | 1202 | return true; |
| 1203 | 1203 | } |
| 1204 | 1204 | return false; |
@@ -79,7 +79,9 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | function _loadFromDB($load_extra_vars = true) |
| 81 | 81 | { |
| 82 | - if(!$this->document_srl) return; |
|
| 82 | + if(!$this->document_srl) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 83 | 85 | |
| 84 | 86 | $document_item = false; |
| 85 | 87 | $cache_put = false; |
@@ -111,8 +113,7 @@ discard block |
||
| 111 | 113 | { |
| 112 | 114 | $oCacheHandler->put($cache_key, $document_item); |
| 113 | 115 | } |
| 114 | - } |
|
| 115 | - else |
|
| 116 | + } else |
|
| 116 | 117 | { |
| 117 | 118 | $document_item->readed_count = $output->data->readed_count; |
| 118 | 119 | $document_item->voted_count = $output->data->voted_count; |
@@ -159,21 +160,29 @@ 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 | 187 | if($this->get('member_srl') && abs($this->get('member_srl')) == $logged_info->member_srl) |
| 179 | 188 | { |
@@ -197,7 +206,9 @@ discard block |
||
| 197 | 206 | function allowComment() |
| 198 | 207 | { |
| 199 | 208 | // init write, document is not exists. so allow comment status is true |
| 200 | - if(!$this->isExists()) return true; |
|
| 209 | + if(!$this->isExists()) { |
|
| 210 | + return true; |
|
| 211 | + } |
|
| 201 | 212 | |
| 202 | 213 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
| 203 | 214 | } |
@@ -212,8 +223,7 @@ discard block |
||
| 212 | 223 | if(!getClass('trackback')) |
| 213 | 224 | { |
| 214 | 225 | $allow_trackback_status = false; |
| 215 | - } |
|
| 216 | - else |
|
| 226 | + } else |
|
| 217 | 227 | { |
| 218 | 228 | // If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module. |
| 219 | 229 | $oModuleModel = getModel('module'); |
@@ -224,15 +234,21 @@ discard block |
||
| 224 | 234 | $trackback_config = new stdClass(); |
| 225 | 235 | } |
| 226 | 236 | |
| 227 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 228 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 229 | - else |
|
| 237 | + if(!isset($trackback_config->enable_trackback)) { |
|
| 238 | + $trackback_config->enable_trackback = 'Y'; |
|
| 239 | + } |
|
| 240 | + if($trackback_config->enable_trackback != 'Y') { |
|
| 241 | + $allow_trackback_status = false; |
|
| 242 | + } else |
|
| 230 | 243 | { |
| 231 | 244 | $module_srl = $this->get('module_srl'); |
| 232 | 245 | // Check settings of each module |
| 233 | 246 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
| 234 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 235 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 247 | + if($module_config->enable_trackback == 'N') { |
|
| 248 | + $allow_trackback_status = false; |
|
| 249 | + } else if($this->get('allow_trackback')=='Y' || !$this->isExists()) { |
|
| 250 | + $allow_trackback_status = true; |
|
| 251 | + } |
|
| 236 | 252 | } |
| 237 | 253 | } |
| 238 | 254 | } |
@@ -241,14 +257,18 @@ discard block |
||
| 241 | 257 | |
| 242 | 258 | function isLocked() |
| 243 | 259 | { |
| 244 | - if(!$this->isExists()) return false; |
|
| 260 | + if(!$this->isExists()) { |
|
| 261 | + return false; |
|
| 262 | + } |
|
| 245 | 263 | |
| 246 | 264 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
| 247 | 265 | } |
| 248 | 266 | |
| 249 | 267 | function isEditable() |
| 250 | 268 | { |
| 251 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 269 | + if($this->isGranted() || !$this->get('member_srl')) { |
|
| 270 | + return true; |
|
| 271 | + } |
|
| 252 | 272 | return false; |
| 253 | 273 | } |
| 254 | 274 | |
@@ -270,9 +290,14 @@ discard block |
||
| 270 | 290 | |
| 271 | 291 | function doCart() |
| 272 | 292 | { |
| 273 | - if(!$this->document_srl) return false; |
|
| 274 | - if($this->isCarted()) $this->removeCart(); |
|
| 275 | - else $this->addCart(); |
|
| 293 | + if(!$this->document_srl) { |
|
| 294 | + return false; |
|
| 295 | + } |
|
| 296 | + if($this->isCarted()) { |
|
| 297 | + $this->removeCart(); |
|
| 298 | + } else { |
|
| 299 | + $this->addCart(); |
|
| 300 | + } |
|
| 276 | 301 | } |
| 277 | 302 | |
| 278 | 303 | function addCart() |
@@ -298,16 +323,26 @@ discard block |
||
| 298 | 323 | */ |
| 299 | 324 | function notify($type, $content) |
| 300 | 325 | { |
| 301 | - if(!$this->document_srl) return; |
|
| 326 | + if(!$this->document_srl) { |
|
| 327 | + return; |
|
| 328 | + } |
|
| 302 | 329 | // return if it is not useNotify |
| 303 | - if(!$this->useNotify()) return; |
|
| 330 | + if(!$this->useNotify()) { |
|
| 331 | + return; |
|
| 332 | + } |
|
| 304 | 333 | // Pass if an author is not a logged-in user |
| 305 | - if(!$this->get('member_srl')) return; |
|
| 334 | + if(!$this->get('member_srl')) { |
|
| 335 | + return; |
|
| 336 | + } |
|
| 306 | 337 | // Return if the currently logged-in user is an author |
| 307 | 338 | $logged_info = Context::get('logged_info'); |
| 308 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 339 | + if($logged_info->member_srl == $this->get('member_srl')) { |
|
| 340 | + return; |
|
| 341 | + } |
|
| 309 | 342 | // List variables |
| 310 | - if($type) $title = "[".$type."] "; |
|
| 343 | + if($type) { |
|
| 344 | + $title = "[".$type."] "; |
|
| 345 | + } |
|
| 311 | 346 | $title .= cut_str(strip_tags($content), 10, '...'); |
| 312 | 347 | $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)); |
| 313 | 348 | $receiver_srl = $this->get('member_srl'); |
@@ -334,16 +369,22 @@ discard block |
||
| 334 | 369 | |
| 335 | 370 | function isExistsHomepage() |
| 336 | 371 | { |
| 337 | - if(trim($this->get('homepage'))) return true; |
|
| 372 | + if(trim($this->get('homepage'))) { |
|
| 373 | + return true; |
|
| 374 | + } |
|
| 338 | 375 | return false; |
| 339 | 376 | } |
| 340 | 377 | |
| 341 | 378 | function getHomepageUrl() |
| 342 | 379 | { |
| 343 | 380 | $url = trim($this->get('homepage')); |
| 344 | - if(!$url) return; |
|
| 381 | + if(!$url) { |
|
| 382 | + return; |
|
| 383 | + } |
|
| 345 | 384 | |
| 346 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
| 385 | + if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) { |
|
| 386 | + $url = 'http://' . $url; |
|
| 387 | + } |
|
| 347 | 388 | |
| 348 | 389 | return $url; |
| 349 | 390 | } |
@@ -375,43 +416,65 @@ discard block |
||
| 375 | 416 | |
| 376 | 417 | function getTitleText($cut_size = 0, $tail='...') |
| 377 | 418 | { |
| 378 | - if(!$this->document_srl) return; |
|
| 419 | + if(!$this->document_srl) { |
|
| 420 | + return; |
|
| 421 | + } |
|
| 379 | 422 | |
| 380 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 381 | - else $title = $this->get('title'); |
|
| 423 | + if($cut_size) { |
|
| 424 | + $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 425 | + } else { |
|
| 426 | + $title = $this->get('title'); |
|
| 427 | + } |
|
| 382 | 428 | |
| 383 | 429 | return $title; |
| 384 | 430 | } |
| 385 | 431 | |
| 386 | 432 | function getTitle($cut_size = 0, $tail='...') |
| 387 | 433 | { |
| 388 | - if(!$this->document_srl) return; |
|
| 434 | + if(!$this->document_srl) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 389 | 437 | |
| 390 | 438 | $title = $this->getTitleText($cut_size, $tail); |
| 391 | 439 | |
| 392 | 440 | $attrs = array(); |
| 393 | 441 | $this->add('title_color', trim($this->get('title_color'))); |
| 394 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
| 395 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 442 | + if($this->get('title_bold')=='Y') { |
|
| 443 | + $attrs[] = "font-weight:bold;"; |
|
| 444 | + } |
|
| 445 | + if($this->get('title_color') && $this->get('title_color') != 'N') { |
|
| 446 | + $attrs[] = "color:#".$this->get('title_color'); |
|
| 447 | + } |
|
| 396 | 448 | |
| 397 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 398 | - else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
| 449 | + if(count($attrs)) { |
|
| 450 | + return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 451 | + } else { |
|
| 452 | + return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
| 453 | + } |
|
| 399 | 454 | } |
| 400 | 455 | |
| 401 | 456 | function getContentText($strlen = 0) |
| 402 | 457 | { |
| 403 | - if(!$this->document_srl) return; |
|
| 458 | + if(!$this->document_srl) { |
|
| 459 | + return; |
|
| 460 | + } |
|
| 404 | 461 | |
| 405 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 462 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
| 463 | + return Context::getLang('msg_is_secret'); |
|
| 464 | + } |
|
| 406 | 465 | |
| 407 | 466 | $result = $this->_checkAccessibleFromStatus(); |
| 408 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 467 | + if($result) { |
|
| 468 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
| 469 | + } |
|
| 409 | 470 | |
| 410 | 471 | $content = $this->get('content'); |
| 411 | 472 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
| 412 | 473 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
| 413 | 474 | |
| 414 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
| 475 | + if($strlen) { |
|
| 476 | + return cut_str(strip_tags($content),$strlen,'...'); |
|
| 477 | + } |
|
| 415 | 478 | |
| 416 | 479 | return htmlspecialchars($content); |
| 417 | 480 | } |
@@ -444,14 +507,12 @@ discard block |
||
| 444 | 507 | } |
| 445 | 508 | $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
| 446 | 509 | } |
| 447 | - } |
|
| 448 | - else if($m[1] == 'embed') |
|
| 510 | + } else if($m[1] == 'embed') |
|
| 449 | 511 | { |
| 450 | 512 | if(stripos($m[0], 'allowscriptaccess')) |
| 451 | 513 | { |
| 452 | 514 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
| 453 | - } |
|
| 454 | - else |
|
| 515 | + } else |
|
| 455 | 516 | { |
| 456 | 517 | $m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]); |
| 457 | 518 | } |
@@ -461,15 +522,23 @@ discard block |
||
| 461 | 522 | |
| 462 | 523 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
| 463 | 524 | { |
| 464 | - if(!$this->document_srl) return; |
|
| 525 | + if(!$this->document_srl) { |
|
| 526 | + return; |
|
| 527 | + } |
|
| 465 | 528 | |
| 466 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 529 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
| 530 | + return Context::getLang('msg_is_secret'); |
|
| 531 | + } |
|
| 467 | 532 | |
| 468 | 533 | $result = $this->_checkAccessibleFromStatus(); |
| 469 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 534 | + if($result) { |
|
| 535 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
| 536 | + } |
|
| 470 | 537 | |
| 471 | 538 | $content = $this->get('content'); |
| 472 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 539 | + if(!$stripEmbedTagException) { |
|
| 540 | + stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 541 | + } |
|
| 473 | 542 | |
| 474 | 543 | // Define a link if using a rewrite module |
| 475 | 544 | $oContext = &Context::getInstance(); |
@@ -503,10 +572,11 @@ discard block |
||
| 503 | 572 | $this->document_srl, $memberSrl |
| 504 | 573 | ); |
| 505 | 574 | // Add xe_content class although accessing content is not required |
| 506 | - } |
|
| 507 | - else |
|
| 575 | + } else |
|
| 508 | 576 | { |
| 509 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 577 | + if($add_xe_content_class) { |
|
| 578 | + $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 579 | + } |
|
| 510 | 580 | } |
| 511 | 581 | // Change the image path to a valid absolute path if resource_realpath is true |
| 512 | 582 | if($resource_realpath) |
@@ -625,11 +695,15 @@ discard block |
||
| 625 | 695 | |
| 626 | 696 | function getTrackbackUrl() |
| 627 | 697 | { |
| 628 | - if(!$this->document_srl) return; |
|
| 698 | + if(!$this->document_srl) { |
|
| 699 | + return; |
|
| 700 | + } |
|
| 629 | 701 | |
| 630 | 702 | // Generate a key to prevent spams |
| 631 | 703 | $oTrackbackModel = getModel('trackback'); |
| 632 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 704 | + if($oTrackbackModel) { |
|
| 705 | + return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 706 | + } |
|
| 633 | 707 | } |
| 634 | 708 | |
| 635 | 709 | /** |
@@ -648,7 +722,9 @@ discard block |
||
| 648 | 722 | |
| 649 | 723 | function isExtraVarsExists() |
| 650 | 724 | { |
| 651 | - if(!$this->get('module_srl')) return false; |
|
| 725 | + if(!$this->get('module_srl')) { |
|
| 726 | + return false; |
|
| 727 | + } |
|
| 652 | 728 | $oDocumentModel = getModel('document'); |
| 653 | 729 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
| 654 | 730 | return count($extra_keys)?true:false; |
@@ -656,7 +732,9 @@ discard block |
||
| 656 | 732 | |
| 657 | 733 | function getExtraVars() |
| 658 | 734 | { |
| 659 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 735 | + if(!$this->get('module_srl') || !$this->document_srl) { |
|
| 736 | + return null; |
|
| 737 | + } |
|
| 660 | 738 | |
| 661 | 739 | $oDocumentModel = getModel('document'); |
| 662 | 740 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -668,8 +746,7 @@ discard block |
||
| 668 | 746 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
| 669 | 747 | { |
| 670 | 748 | return $extra_vars[$idx]->getValue(); |
| 671 | - } |
|
| 672 | - else |
|
| 749 | + } else |
|
| 673 | 750 | { |
| 674 | 751 | return ''; |
| 675 | 752 | } |
@@ -681,8 +758,7 @@ discard block |
||
| 681 | 758 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
| 682 | 759 | { |
| 683 | 760 | return $extra_vars[$idx]->getValueHTML(); |
| 684 | - } |
|
| 685 | - else |
|
| 761 | + } else |
|
| 686 | 762 | { |
| 687 | 763 | return ''; |
| 688 | 764 | } |
@@ -704,8 +780,7 @@ discard block |
||
| 704 | 780 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
| 705 | 781 | { |
| 706 | 782 | return $extra_eid[$eid]->getValue(); |
| 707 | - } |
|
| 708 | - else |
|
| 783 | + } else |
|
| 709 | 784 | { |
| 710 | 785 | return ''; |
| 711 | 786 | } |
@@ -723,8 +798,7 @@ discard block |
||
| 723 | 798 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
| 724 | 799 | { |
| 725 | 800 | return $extra_eid[$eid]->getValueHTML(); |
| 726 | - } |
|
| 727 | - else |
|
| 801 | + } else |
|
| 728 | 802 | { |
| 729 | 803 | return ''; |
| 730 | 804 | } |
@@ -744,8 +818,12 @@ discard block |
||
| 744 | 818 | |
| 745 | 819 | function getComments() |
| 746 | 820 | { |
| 747 | - if(!$this->getCommentCount()) return; |
|
| 748 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
| 821 | + if(!$this->getCommentCount()) { |
|
| 822 | + return; |
|
| 823 | + } |
|
| 824 | + if(!$this->isGranted() && $this->isSecret()) { |
|
| 825 | + return; |
|
| 826 | + } |
|
| 749 | 827 | // cpage is a number of comment pages |
| 750 | 828 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
| 751 | 829 | $cpage = Context::get($cpageStr); |
@@ -758,7 +836,9 @@ discard block |
||
| 758 | 836 | // Get a list of comments |
| 759 | 837 | $oCommentModel = getModel('comment'); |
| 760 | 838 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
| 761 | - if(!$output->toBool() || !count($output->data)) return; |
|
| 839 | + if(!$output->toBool() || !count($output->data)) { |
|
| 840 | + return; |
|
| 841 | + } |
|
| 762 | 842 | // Create commentItem object from a comment list |
| 763 | 843 | // If admin priviledge is granted on parent posts, you can read its child posts. |
| 764 | 844 | $accessible = array(); |
@@ -768,7 +848,9 @@ discard block |
||
| 768 | 848 | $oCommentItem = new commentItem(); |
| 769 | 849 | $oCommentItem->setAttribute($val); |
| 770 | 850 | // If permission is granted to the post, you can access it temporarily |
| 771 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 851 | + if($oCommentItem->isGranted()) { |
|
| 852 | + $accessible[$val->comment_srl] = true; |
|
| 853 | + } |
|
| 772 | 854 | // 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 |
| 773 | 855 | if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
| 774 | 856 | { |
@@ -779,7 +861,9 @@ discard block |
||
| 779 | 861 | // Variable setting to be displayed on the skin |
| 780 | 862 | Context::set($cpageStr, $output->page_navigation->cur_page); |
| 781 | 863 | Context::set('cpage', $output->page_navigation->cur_page); |
| 782 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
| 864 | + if($output->total_page>1) { |
|
| 865 | + $this->comment_page_navigation = $output->page_navigation; |
|
| 866 | + } |
|
| 783 | 867 | |
| 784 | 868 | return $comment_list; |
| 785 | 869 | } |
@@ -791,9 +875,13 @@ discard block |
||
| 791 | 875 | |
| 792 | 876 | function getTrackbacks() |
| 793 | 877 | { |
| 794 | - if(!$this->document_srl) return; |
|
| 878 | + if(!$this->document_srl) { |
|
| 879 | + return; |
|
| 880 | + } |
|
| 795 | 881 | |
| 796 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 882 | + if(!$this->allowTrackback() || !$this->get('trackback_count')) { |
|
| 883 | + return; |
|
| 884 | + } |
|
| 797 | 885 | |
| 798 | 886 | $oTrackbackModel = getModel('trackback'); |
| 799 | 887 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -801,15 +889,21 @@ discard block |
||
| 801 | 889 | |
| 802 | 890 | function thumbnailExists($width = 80, $height = 0, $type = '') |
| 803 | 891 | { |
| 804 | - if(!$this->document_srl) return false; |
|
| 805 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
| 892 | + if(!$this->document_srl) { |
|
| 893 | + return false; |
|
| 894 | + } |
|
| 895 | + if(!$this->getThumbnail($width, $height, $type)) { |
|
| 896 | + return false; |
|
| 897 | + } |
|
| 806 | 898 | return true; |
| 807 | 899 | } |
| 808 | 900 | |
| 809 | 901 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
| 810 | 902 | { |
| 811 | 903 | // Return false if the document doesn't exist |
| 812 | - if(!$this->document_srl) return; |
|
| 904 | + if(!$this->document_srl) { |
|
| 905 | + return; |
|
| 906 | + } |
|
| 813 | 907 | |
| 814 | 908 | if($this->isSecret() && !$this->isGranted()) |
| 815 | 909 | { |
@@ -817,7 +911,9 @@ discard block |
||
| 817 | 911 | } |
| 818 | 912 | |
| 819 | 913 | // If not specify its height, create a square |
| 820 | - if(!$height) $height = $width; |
|
| 914 | + if(!$height) { |
|
| 915 | + $height = $width; |
|
| 916 | + } |
|
| 821 | 917 | |
| 822 | 918 | // Return false if neither attachement nor image files in the document |
| 823 | 919 | $content = $this->get('content'); |
@@ -835,7 +931,9 @@ discard block |
||
| 835 | 931 | } |
| 836 | 932 | } |
| 837 | 933 | |
| 838 | - if(!preg_match("!<img!is", $content)) return; |
|
| 934 | + if(!preg_match("!<img!is", $content)) { |
|
| 935 | + return; |
|
| 936 | + } |
|
| 839 | 937 | } |
| 840 | 938 | // Get thumbnai_type information from document module's configuration |
| 841 | 939 | if(!in_array($thumbnail_type, array('crop','ratio'))) |
@@ -862,8 +960,7 @@ discard block |
||
| 862 | 960 | if(filesize($thumbnail_file) < 1) |
| 863 | 961 | { |
| 864 | 962 | return FALSE; |
| 865 | - } |
|
| 866 | - else |
|
| 963 | + } else |
|
| 867 | 964 | { |
| 868 | 965 | return $thumbnail_url; |
| 869 | 966 | } |
@@ -884,7 +981,9 @@ discard block |
||
| 884 | 981 | $first_image = null; |
| 885 | 982 | foreach($file_list as $file) |
| 886 | 983 | { |
| 887 | - if($file->direct_download !== 'Y') continue; |
|
| 984 | + if($file->direct_download !== 'Y') { |
|
| 985 | + continue; |
|
| 986 | + } |
|
| 888 | 987 | |
| 889 | 988 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
| 890 | 989 | { |
@@ -892,7 +991,9 @@ discard block |
||
| 892 | 991 | break; |
| 893 | 992 | } |
| 894 | 993 | |
| 895 | - if($first_image) continue; |
|
| 994 | + if($first_image) { |
|
| 995 | + continue; |
|
| 996 | + } |
|
| 896 | 997 | |
| 897 | 998 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
| 898 | 999 | { |
@@ -919,7 +1020,9 @@ discard block |
||
| 919 | 1020 | foreach($matches as $target_image) |
| 920 | 1021 | { |
| 921 | 1022 | $target_src = trim($target_image[1]); |
| 922 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 1023 | + if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) { |
|
| 1024 | + continue; |
|
| 1025 | + } |
|
| 923 | 1026 | |
| 924 | 1027 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
| 925 | 1028 | { |
@@ -930,7 +1033,9 @@ discard block |
||
| 930 | 1033 | |
| 931 | 1034 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
| 932 | 1035 | FileHandler::getRemoteFile($target_src, $tmp_file); |
| 933 | - if(!file_exists($tmp_file)) continue; |
|
| 1036 | + if(!file_exists($tmp_file)) { |
|
| 1037 | + continue; |
|
| 1038 | + } |
|
| 934 | 1039 | |
| 935 | 1040 | $imageinfo = getimagesize($tmp_file); |
| 936 | 1041 | list($_w, $_h) = $imageinfo; |
@@ -981,21 +1086,28 @@ discard block |
||
| 981 | 1086 | */ |
| 982 | 1087 | function getExtraImages($time_interval = 43200) |
| 983 | 1088 | { |
| 984 | - if(!$this->document_srl) return; |
|
| 1089 | + if(!$this->document_srl) { |
|
| 1090 | + return; |
|
| 1091 | + } |
|
| 985 | 1092 | // variables for icon list |
| 986 | 1093 | $buffs = array(); |
| 987 | 1094 | |
| 988 | 1095 | $check_files = false; |
| 989 | 1096 | |
| 990 | 1097 | // Check if secret post is |
| 991 | - if($this->isSecret()) $buffs[] = "secret"; |
|
| 1098 | + if($this->isSecret()) { |
|
| 1099 | + $buffs[] = "secret"; |
|
| 1100 | + } |
|
| 992 | 1101 | |
| 993 | 1102 | // Set the latest time |
| 994 | 1103 | $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
| 995 | 1104 | |
| 996 | 1105 | // Check new post |
| 997 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
| 998 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
| 1106 | + if($this->get('regdate')>$time_check) { |
|
| 1107 | + $buffs[] = "new"; |
|
| 1108 | + } else if($this->get('last_update')>$time_check) { |
|
| 1109 | + $buffs[] = "update"; |
|
| 1110 | + } |
|
| 999 | 1111 | |
| 1000 | 1112 | /* |
| 1001 | 1113 | $content = $this->get('content'); |
@@ -1018,7 +1130,9 @@ discard block |
||
| 1018 | 1130 | */ |
| 1019 | 1131 | |
| 1020 | 1132 | // Check the attachment |
| 1021 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1133 | + if($this->hasUploadedFiles()) { |
|
| 1134 | + $buffs[] = "file"; |
|
| 1135 | + } |
|
| 1022 | 1136 | |
| 1023 | 1137 | return $buffs; |
| 1024 | 1138 | } |
@@ -1039,22 +1153,25 @@ discard block |
||
| 1039 | 1153 | */ |
| 1040 | 1154 | function printExtraImages($time_check = 43200) |
| 1041 | 1155 | { |
| 1042 | - if(!$this->document_srl) return; |
|
| 1156 | + if(!$this->document_srl) { |
|
| 1157 | + return; |
|
| 1158 | + } |
|
| 1043 | 1159 | |
| 1044 | 1160 | $oDocumentModel = getModel('document'); |
| 1045 | 1161 | $documentConfig = $oDocumentModel->getDocumentConfig(); |
| 1046 | 1162 | if(Mobile::isFromMobilePhone()) |
| 1047 | 1163 | { |
| 1048 | 1164 | $iconSkin = $documentConfig->micons; |
| 1049 | - } |
|
| 1050 | - else |
|
| 1165 | + } else |
|
| 1051 | 1166 | { |
| 1052 | 1167 | $iconSkin = $documentConfig->icons; |
| 1053 | 1168 | } |
| 1054 | 1169 | $path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
| 1055 | 1170 | |
| 1056 | 1171 | $buffs = $this->getExtraImages($time_check); |
| 1057 | - if(!count($buffs)) return; |
|
| 1172 | + if(!count($buffs)) { |
|
| 1173 | + return; |
|
| 1174 | + } |
|
| 1058 | 1175 | |
| 1059 | 1176 | $buff = array(); |
| 1060 | 1177 | foreach($buffs as $key => $val) |
@@ -1066,18 +1183,28 @@ discard block |
||
| 1066 | 1183 | |
| 1067 | 1184 | function hasUploadedFiles() |
| 1068 | 1185 | { |
| 1069 | - if(!$this->document_srl) return; |
|
| 1186 | + if(!$this->document_srl) { |
|
| 1187 | + return; |
|
| 1188 | + } |
|
| 1070 | 1189 | |
| 1071 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
| 1190 | + if($this->isSecret() && !$this->isGranted()) { |
|
| 1191 | + return false; |
|
| 1192 | + } |
|
| 1072 | 1193 | return $this->get('uploaded_count')? true : false; |
| 1073 | 1194 | } |
| 1074 | 1195 | |
| 1075 | 1196 | function getUploadedFiles($sortIndex = 'file_srl') |
| 1076 | 1197 | { |
| 1077 | - if(!$this->document_srl) return; |
|
| 1198 | + if(!$this->document_srl) { |
|
| 1199 | + return; |
|
| 1200 | + } |
|
| 1078 | 1201 | |
| 1079 | - if($this->isSecret() && !$this->isGranted()) return; |
|
| 1080 | - if(!$this->get('uploaded_count')) return; |
|
| 1202 | + if($this->isSecret() && !$this->isGranted()) { |
|
| 1203 | + return; |
|
| 1204 | + } |
|
| 1205 | + if(!$this->get('uploaded_count')) { |
|
| 1206 | + return; |
|
| 1207 | + } |
|
| 1081 | 1208 | |
| 1082 | 1209 | if(!$this->uploadedFiles[$sortIndex]) |
| 1083 | 1210 | { |
@@ -1095,7 +1222,9 @@ discard block |
||
| 1095 | 1222 | function getEditor() |
| 1096 | 1223 | { |
| 1097 | 1224 | $module_srl = $this->get('module_srl'); |
| 1098 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1225 | + if(!$module_srl) { |
|
| 1226 | + $module_srl = Context::get('module_srl'); |
|
| 1227 | + } |
|
| 1099 | 1228 | |
| 1100 | 1229 | $oEditorModel = getModel('editor'); |
| 1101 | 1230 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1109,8 +1238,12 @@ discard block |
||
| 1109 | 1238 | function isEnableComment() |
| 1110 | 1239 | { |
| 1111 | 1240 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
| 1112 | - if (!$this->allowComment()) return false; |
|
| 1113 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
| 1241 | + if (!$this->allowComment()) { |
|
| 1242 | + return false; |
|
| 1243 | + } |
|
| 1244 | + if(!$this->isGranted() && $this->isSecret()) { |
|
| 1245 | + return false; |
|
| 1246 | + } |
|
| 1114 | 1247 | |
| 1115 | 1248 | return true; |
| 1116 | 1249 | } |
@@ -1121,7 +1254,9 @@ discard block |
||
| 1121 | 1254 | */ |
| 1122 | 1255 | function getCommentEditor() |
| 1123 | 1256 | { |
| 1124 | - if(!$this->isEnableComment()) return; |
|
| 1257 | + if(!$this->isEnableComment()) { |
|
| 1258 | + return; |
|
| 1259 | + } |
|
| 1125 | 1260 | |
| 1126 | 1261 | $oEditorModel = getModel('editor'); |
| 1127 | 1262 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1133,10 +1268,14 @@ discard block |
||
| 1133 | 1268 | */ |
| 1134 | 1269 | function getProfileImage() |
| 1135 | 1270 | { |
| 1136 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1271 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
| 1272 | + return; |
|
| 1273 | + } |
|
| 1137 | 1274 | $oMemberModel = getModel('member'); |
| 1138 | 1275 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
| 1139 | - if(!$profile_info) return; |
|
| 1276 | + if(!$profile_info) { |
|
| 1277 | + return; |
|
| 1278 | + } |
|
| 1140 | 1279 | |
| 1141 | 1280 | return $profile_info->src; |
| 1142 | 1281 | } |
@@ -1148,7 +1287,9 @@ discard block |
||
| 1148 | 1287 | function getSignature() |
| 1149 | 1288 | { |
| 1150 | 1289 | // Pass if a document doesn't exist |
| 1151 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1290 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
| 1291 | + return; |
|
| 1292 | + } |
|
| 1152 | 1293 | // Get signature information |
| 1153 | 1294 | $oMemberModel = getModel('member'); |
| 1154 | 1295 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
@@ -1162,7 +1303,9 @@ discard block |
||
| 1162 | 1303 | if($signature) |
| 1163 | 1304 | { |
| 1164 | 1305 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
| 1165 | - 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); |
|
| 1306 | + if($max_signature_height) { |
|
| 1307 | + $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); |
|
| 1308 | + } |
|
| 1166 | 1309 | } |
| 1167 | 1310 | |
| 1168 | 1311 | return $signature; |
@@ -1186,20 +1329,25 @@ discard block |
||
| 1186 | 1329 | function _checkAccessibleFromStatus() |
| 1187 | 1330 | { |
| 1188 | 1331 | $logged_info = Context::get('logged_info'); |
| 1189 | - if($logged_info->is_admin == 'Y') return true; |
|
| 1332 | + if($logged_info->is_admin == 'Y') { |
|
| 1333 | + return true; |
|
| 1334 | + } |
|
| 1190 | 1335 | |
| 1191 | 1336 | $status = $this->get('status'); |
| 1192 | - if(empty($status)) return false; |
|
| 1337 | + if(empty($status)) { |
|
| 1338 | + return false; |
|
| 1339 | + } |
|
| 1193 | 1340 | |
| 1194 | 1341 | $oDocumentModel = getModel('document'); |
| 1195 | 1342 | $configStatusList = $oDocumentModel->getStatusList(); |
| 1196 | 1343 | |
| 1197 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1198 | - return true; |
|
| 1199 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1344 | + if($status == $configStatusList['public'] || $status == $configStatusList['publish']) { |
|
| 1345 | + return true; |
|
| 1346 | + } else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1200 | 1347 | { |
| 1201 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
| 1202 | - return true; |
|
| 1348 | + if($this->get('member_srl') == $logged_info->member_srl) { |
|
| 1349 | + return true; |
|
| 1350 | + } |
|
| 1203 | 1351 | } |
| 1204 | 1352 | return false; |
| 1205 | 1353 | } |
@@ -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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 50 | + if (!$component) return new BaseObject(-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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 56 | + if (!method_exists($oComponent, $method)) return new BaseObject(-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 BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
| 60 | + if (method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
| 61 | + else return new BaseObject(-1, sprintf('%s method is not exists', $method)); |
|
| 62 | 62 | |
| 63 | - if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) return $output; |
|
| 63 | + if ((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$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 BaseObject(-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 BaseObject(-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 BaseObject(); |
|
| 172 | + if (Context::getResponseMethod() != 'HTML') return new BaseObject(); |
|
| 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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 50 | + if(!$component) { |
|
| 51 | + return new BaseObject(-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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
| 60 | + if(!method_exists($oComponent, $method)) { |
|
| 61 | + return new BaseObject(-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 BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
| 66 | + if(method_exists($oComponent, $method)) { |
|
| 67 | + $output = $oComponent->{$method}(); |
|
| 68 | + } else { |
|
| 69 | + return new BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
| 70 | + } |
|
| 62 | 71 | |
| 63 | - if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) return $output; |
|
| 72 | + if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$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 BaseObject(); |
|
| 189 | + if(Context::getResponseMethod()!='HTML') { |
|
| 190 | + return new BaseObject(); |
|
| 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); |
@@ -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' : |
@@ -216,6 +216,7 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | 218 | * Merge item |
| 219 | + * @param string $filename |
|
| 219 | 220 | * @return void |
| 220 | 221 | */ |
| 221 | 222 | function mergeItems($filename) |
@@ -310,6 +311,11 @@ discard block |
||
| 310 | 311 | return $this->key; |
| 311 | 312 | } |
| 312 | 313 | |
| 314 | + /** |
|
| 315 | + * @param string $str |
|
| 316 | + * |
|
| 317 | + * @return string |
|
| 318 | + */ |
|
| 313 | 319 | function _addTagCRTail($str) { |
| 314 | 320 | $str = preg_replace('/<\/([^>]*)></i', "</$1>\r\n<", $str); |
| 315 | 321 | return $str; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $this->filename = $filename; |
| 100 | 100 | |
| 101 | 101 | $this->startTag = $startTag; |
| 102 | - if($endTag) $this->endTag = $endTag; |
|
| 102 | + if ($endTag) $this->endTag = $endTag; |
|
| 103 | 103 | $this->itemStartTag = $itemTag; |
| 104 | 104 | $this->itemEndTag = $itemEndTag; |
| 105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $this->cache_path = './files/cache/importer/'.$this->key; |
| 109 | 109 | $this->cache_index_file = $this->cache_path.'/index'; |
| 110 | 110 | |
| 111 | - if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
| 111 | + if (!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
| 112 | 112 | |
| 113 | 113 | return $this->openFile(); |
| 114 | 114 | } |
@@ -120,55 +120,55 @@ discard block |
||
| 120 | 120 | function openFile() |
| 121 | 121 | { |
| 122 | 122 | FileHandler::removeFile($this->cache_index_file); |
| 123 | - $this->index_fd = fopen($this->cache_index_file,"a"); |
|
| 123 | + $this->index_fd = fopen($this->cache_index_file, "a"); |
|
| 124 | 124 | // If local file |
| 125 | - if(strncasecmp('http://', $this->filename, 7) !== 0) |
|
| 125 | + if (strncasecmp('http://', $this->filename, 7) !== 0) |
|
| 126 | 126 | { |
| 127 | - if(!file_exists($this->filename)) return new BaseObject(-1,'msg_no_xml_file'); |
|
| 128 | - $this->fd = fopen($this->filename,"r"); |
|
| 127 | + if (!file_exists($this->filename)) return new BaseObject(-1, 'msg_no_xml_file'); |
|
| 128 | + $this->fd = fopen($this->filename, "r"); |
|
| 129 | 129 | // If remote file |
| 130 | 130 | } |
| 131 | 131 | else |
| 132 | 132 | { |
| 133 | 133 | $url_info = parse_url($this->filename); |
| 134 | - if(!$url_info['port']) $url_info['port'] = 80; |
|
| 135 | - if(!$url_info['path']) $url_info['path'] = '/'; |
|
| 134 | + if (!$url_info['port']) $url_info['port'] = 80; |
|
| 135 | + if (!$url_info['path']) $url_info['path'] = '/'; |
|
| 136 | 136 | |
| 137 | 137 | $this->fd = @fsockopen($url_info['host'], $url_info['port']); |
| 138 | - if(!$this->fd) return new BaseObject(-1,'msg_no_xml_file'); |
|
| 138 | + if (!$this->fd) return new BaseObject(-1, 'msg_no_xml_file'); |
|
| 139 | 139 | // If the file name contains Korean, do urlencode(iconv required) |
| 140 | 140 | $path = $url_info['path']; |
| 141 | - if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) |
|
| 141 | + if (preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path) && function_exists('iconv')) |
|
| 142 | 142 | { |
| 143 | - $path_list = explode('/',$path); |
|
| 143 | + $path_list = explode('/', $path); |
|
| 144 | 144 | $cnt = count($path_list); |
| 145 | - $filename = $path_list[$cnt-1]; |
|
| 146 | - $filename = urlencode(iconv("UTF-8","EUC-KR",$filename)); |
|
| 147 | - $path_list[$cnt-1] = $filename; |
|
| 148 | - $path = implode('/',$path_list); |
|
| 145 | + $filename = $path_list[$cnt - 1]; |
|
| 146 | + $filename = urlencode(iconv("UTF-8", "EUC-KR", $filename)); |
|
| 147 | + $path_list[$cnt - 1] = $filename; |
|
| 148 | + $path = implode('/', $path_list); |
|
| 149 | 149 | $url_info['path'] = $path; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $header = sprintf("GET %s?%s HTTP/1.0\r\nHost: %s\r\nReferer: %s://%s\r\nConnection: Close\r\n\r\n", $url_info['path'], $url_info['query'], $url_info['host'], $url_info['scheme'], $url_info['host']); |
| 153 | 153 | @fwrite($this->fd, $header); |
| 154 | 154 | $buff = ''; |
| 155 | - while(!feof($this->fd)) |
|
| 155 | + while (!feof($this->fd)) |
|
| 156 | 156 | { |
| 157 | 157 | $buff .= $str = fgets($this->fd, 1024); |
| 158 | - if(!trim($str)) break; |
|
| 158 | + if (!trim($str)) break; |
|
| 159 | 159 | } |
| 160 | - if(preg_match('/404 Not Found/i',$buff)) return new BaseObject(-1,'msg_no_xml_file'); |
|
| 160 | + if (preg_match('/404 Not Found/i', $buff)) return new BaseObject(-1, 'msg_no_xml_file'); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if($this->startTag) |
|
| 163 | + if ($this->startTag) |
|
| 164 | 164 | { |
| 165 | - while(!feof($this->fd)) |
|
| 165 | + while (!feof($this->fd)) |
|
| 166 | 166 | { |
| 167 | 167 | $str = fgets($this->fd, 1024); |
| 168 | 168 | $pos = strpos($str, $this->startTag); |
| 169 | - if($pos !== false) |
|
| 169 | + if ($pos !== false) |
|
| 170 | 170 | { |
| 171 | - $this->buff = substr($this->buff, $pos+strlen($this->startTag)); |
|
| 171 | + $this->buff = substr($this->buff, $pos + strlen($this->startTag)); |
|
| 172 | 172 | $this->isStarted = true; |
| 173 | 173 | $this->isFinished = false; |
| 174 | 174 | break; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | FileHandler::removeDir($this->cache_path.$this->key); |
| 210 | 210 | $this->index = 0; |
| 211 | - while(!$this->isFinished()) |
|
| 211 | + while (!$this->isFinished()) |
|
| 212 | 212 | { |
| 213 | 213 | $this->getItem(); |
| 214 | 214 | } |
@@ -224,14 +224,14 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | $filename = sprintf('%s/%s', $this->cache_path, $filename); |
| 226 | 226 | |
| 227 | - $index_fd = fopen($this->cache_index_file,"r"); |
|
| 228 | - $fd = fopen($filename,'w'); |
|
| 227 | + $index_fd = fopen($this->cache_index_file, "r"); |
|
| 228 | + $fd = fopen($filename, 'w'); |
|
| 229 | 229 | |
| 230 | 230 | fwrite($fd, '<items>'); |
| 231 | - while(!feof($index_fd)) |
|
| 231 | + while (!feof($index_fd)) |
|
| 232 | 232 | { |
| 233 | - $target_file = trim(fgets($index_fd,1024)); |
|
| 234 | - if(!file_exists($target_file)) continue; |
|
| 233 | + $target_file = trim(fgets($index_fd, 1024)); |
|
| 234 | + if (!file_exists($target_file)) continue; |
|
| 235 | 235 | $buff = FileHandler::readFile($target_file); |
| 236 | 236 | fwrite($fd, FileHandler::readFile($target_file)); |
| 237 | 237 | |
@@ -247,21 +247,21 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | function getItem() |
| 249 | 249 | { |
| 250 | - if($this->isFinished()) return; |
|
| 250 | + if ($this->isFinished()) return; |
|
| 251 | 251 | |
| 252 | - while(!feof($this->fd)) |
|
| 252 | + while (!feof($this->fd)) |
|
| 253 | 253 | { |
| 254 | 254 | $startPos = strpos($this->buff, $this->itemStartTag); |
| 255 | - if($startPos !== false) |
|
| 255 | + if ($startPos !== false) |
|
| 256 | 256 | { |
| 257 | 257 | $this->buff = substr($this->buff, $startPos); |
| 258 | - $this->buff = preg_replace("/\>/",">\r\n",$this->buff,1); |
|
| 258 | + $this->buff = preg_replace("/\>/", ">\r\n", $this->buff, 1); |
|
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | - elseif($this->endTag) |
|
| 261 | + elseif ($this->endTag) |
|
| 262 | 262 | { |
| 263 | 263 | $endPos = strpos($this->buff, $this->endTag); |
| 264 | - if($endPos !== false) |
|
| 264 | + if ($endPos !== false) |
|
| 265 | 265 | { |
| 266 | 266 | $this->closeFile(); |
| 267 | 267 | return; |
@@ -271,21 +271,21 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $startPos = strpos($this->buff, $this->itemStartTag); |
| 274 | - if($startPos === false) |
|
| 274 | + if ($startPos === false) |
|
| 275 | 275 | { |
| 276 | 276 | $this->closeFile(); |
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $filename = sprintf('%s/%s.xml',$this->cache_path, $this->index++); |
|
| 280 | + $filename = sprintf('%s/%s.xml', $this->cache_path, $this->index++); |
|
| 281 | 281 | fwrite($this->index_fd, $filename."\r\n"); |
| 282 | 282 | |
| 283 | - $fd = fopen($filename,'w'); |
|
| 283 | + $fd = fopen($filename, 'w'); |
|
| 284 | 284 | |
| 285 | - while(!feof($this->fd)) |
|
| 285 | + while (!feof($this->fd)) |
|
| 286 | 286 | { |
| 287 | 287 | $endPos = strpos($this->buff, $this->itemEndTag); |
| 288 | - if($endPos !== false) |
|
| 288 | + if ($endPos !== false) |
|
| 289 | 289 | { |
| 290 | 290 | $endPos += strlen($this->itemEndTag); |
| 291 | 291 | $buff = substr($this->buff, 0, $endPos); |
@@ -99,7 +99,9 @@ discard block |
||
| 99 | 99 | $this->filename = $filename; |
| 100 | 100 | |
| 101 | 101 | $this->startTag = $startTag; |
| 102 | - if($endTag) $this->endTag = $endTag; |
|
| 102 | + if($endTag) { |
|
| 103 | + $this->endTag = $endTag; |
|
| 104 | + } |
|
| 103 | 105 | $this->itemStartTag = $itemTag; |
| 104 | 106 | $this->itemEndTag = $itemEndTag; |
| 105 | 107 | |
@@ -108,7 +110,9 @@ discard block |
||
| 108 | 110 | $this->cache_path = './files/cache/importer/'.$this->key; |
| 109 | 111 | $this->cache_index_file = $this->cache_path.'/index'; |
| 110 | 112 | |
| 111 | - if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); |
|
| 113 | + if(!is_dir($this->cache_path)) { |
|
| 114 | + FileHandler::makeDir($this->cache_path); |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | return $this->openFile(); |
| 114 | 118 | } |
@@ -124,18 +128,25 @@ discard block |
||
| 124 | 128 | // If local file |
| 125 | 129 | if(strncasecmp('http://', $this->filename, 7) !== 0) |
| 126 | 130 | { |
| 127 | - if(!file_exists($this->filename)) return new BaseObject(-1,'msg_no_xml_file'); |
|
| 131 | + if(!file_exists($this->filename)) { |
|
| 132 | + return new BaseObject(-1,'msg_no_xml_file'); |
|
| 133 | + } |
|
| 128 | 134 | $this->fd = fopen($this->filename,"r"); |
| 129 | 135 | // If remote file |
| 130 | - } |
|
| 131 | - else |
|
| 136 | + } else |
|
| 132 | 137 | { |
| 133 | 138 | $url_info = parse_url($this->filename); |
| 134 | - if(!$url_info['port']) $url_info['port'] = 80; |
|
| 135 | - if(!$url_info['path']) $url_info['path'] = '/'; |
|
| 139 | + if(!$url_info['port']) { |
|
| 140 | + $url_info['port'] = 80; |
|
| 141 | + } |
|
| 142 | + if(!$url_info['path']) { |
|
| 143 | + $url_info['path'] = '/'; |
|
| 144 | + } |
|
| 136 | 145 | |
| 137 | 146 | $this->fd = @fsockopen($url_info['host'], $url_info['port']); |
| 138 | - if(!$this->fd) return new BaseObject(-1,'msg_no_xml_file'); |
|
| 147 | + if(!$this->fd) { |
|
| 148 | + return new BaseObject(-1,'msg_no_xml_file'); |
|
| 149 | + } |
|
| 139 | 150 | // If the file name contains Korean, do urlencode(iconv required) |
| 140 | 151 | $path = $url_info['path']; |
| 141 | 152 | if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) |
@@ -155,9 +166,13 @@ discard block |
||
| 155 | 166 | while(!feof($this->fd)) |
| 156 | 167 | { |
| 157 | 168 | $buff .= $str = fgets($this->fd, 1024); |
| 158 | - if(!trim($str)) break; |
|
| 169 | + if(!trim($str)) { |
|
| 170 | + break; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + if(preg_match('/404 Not Found/i',$buff)) { |
|
| 174 | + return new BaseObject(-1,'msg_no_xml_file'); |
|
| 159 | 175 | } |
| 160 | - if(preg_match('/404 Not Found/i',$buff)) return new BaseObject(-1,'msg_no_xml_file'); |
|
| 161 | 176 | } |
| 162 | 177 | |
| 163 | 178 | if($this->startTag) |
@@ -174,8 +189,7 @@ discard block |
||
| 174 | 189 | break; |
| 175 | 190 | } |
| 176 | 191 | } |
| 177 | - } |
|
| 178 | - else |
|
| 192 | + } else |
|
| 179 | 193 | { |
| 180 | 194 | $this->isStarted = true; |
| 181 | 195 | $this->isFinished = false; |
@@ -231,7 +245,9 @@ discard block |
||
| 231 | 245 | while(!feof($index_fd)) |
| 232 | 246 | { |
| 233 | 247 | $target_file = trim(fgets($index_fd,1024)); |
| 234 | - if(!file_exists($target_file)) continue; |
|
| 248 | + if(!file_exists($target_file)) { |
|
| 249 | + continue; |
|
| 250 | + } |
|
| 235 | 251 | $buff = FileHandler::readFile($target_file); |
| 236 | 252 | fwrite($fd, FileHandler::readFile($target_file)); |
| 237 | 253 | |
@@ -247,7 +263,9 @@ discard block |
||
| 247 | 263 | */ |
| 248 | 264 | function getItem() |
| 249 | 265 | { |
| 250 | - if($this->isFinished()) return; |
|
| 266 | + if($this->isFinished()) { |
|
| 267 | + return; |
|
| 268 | + } |
|
| 251 | 269 | |
| 252 | 270 | while(!feof($this->fd)) |
| 253 | 271 | { |
@@ -257,8 +275,7 @@ discard block |
||
| 257 | 275 | $this->buff = substr($this->buff, $startPos); |
| 258 | 276 | $this->buff = preg_replace("/\>/",">\r\n",$this->buff,1); |
| 259 | 277 | break; |
| 260 | - } |
|
| 261 | - elseif($this->endTag) |
|
| 278 | + } elseif($this->endTag) |
|
| 262 | 279 | { |
| 263 | 280 | $endPos = strpos($this->buff, $this->endTag); |
| 264 | 281 | if($endPos !== false) |
@@ -450,7 +450,7 @@ |
||
| 450 | 450 | * @param int $upload_target_srl |
| 451 | 451 | * @param array $files |
| 452 | 452 | * @param string $buff |
| 453 | - * @return bool |
|
| 453 | + * @return null|boolean |
|
| 454 | 454 | */ |
| 455 | 455 | function importAttaches($fp, $module_srl, $upload_target_srl, &$files, $buff) |
| 456 | 456 | { |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | $oDocumentModel = getModel('document'); |
| 41 | 41 | $category_list = $category_titles = array(); |
| 42 | 42 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 43 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 43 | + if(count($category_list)) { |
|
| 44 | + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 45 | + } |
|
| 44 | 46 | // First handle categorty information |
| 45 | 47 | $category_file = preg_replace('/index$/i', 'category.xml', $index_file); |
| 46 | 48 | if(file_exists($category_file)) |
@@ -58,15 +60,21 @@ discard block |
||
| 58 | 60 | foreach($categories as $k => $v) |
| 59 | 61 | { |
| 60 | 62 | $category = $v->name; |
| 61 | - if(!$category || $category_titles[$category]) continue; |
|
| 63 | + if(!$category || $category_titles[$category]) { |
|
| 64 | + continue; |
|
| 65 | + } |
|
| 62 | 66 | |
| 63 | 67 | $obj = null; |
| 64 | 68 | $obj->title = $category; |
| 65 | 69 | $obj->module_srl = $module_srl; |
| 66 | - if($v->parent) $obj->parent_srl = $match_sequence[$v->parent]; |
|
| 70 | + if($v->parent) { |
|
| 71 | + $obj->parent_srl = $match_sequence[$v->parent]; |
|
| 72 | + } |
|
| 67 | 73 | $output = $oDocumentController->insertCategory($obj); |
| 68 | 74 | |
| 69 | - if($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
| 75 | + if($output->toBool()) { |
|
| 76 | + $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
| 77 | + } |
|
| 70 | 78 | } |
| 71 | 79 | $oDocumentController->makeCategoryFile($module_srl); |
| 72 | 80 | } |
@@ -74,28 +82,40 @@ discard block |
||
| 74 | 82 | } |
| 75 | 83 | $category_list = $category_titles = array(); |
| 76 | 84 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 77 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 85 | + if(count($category_list)) { |
|
| 86 | + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 87 | + } |
|
| 78 | 88 | // Get administrator information |
| 79 | 89 | $oMemberModel = getModel('member'); |
| 80 | 90 | $member_info = $oMemberModel->getMemberInfoByUserID($user_id); |
| 81 | 91 | $author_xml_id = 0; |
| 82 | 92 | |
| 83 | - if(!$cur) $cur = 0; |
|
| 93 | + if(!$cur) { |
|
| 94 | + $cur = 0; |
|
| 95 | + } |
|
| 84 | 96 | // Open an index file |
| 85 | 97 | $f = fopen($index_file,"r"); |
| 86 | 98 | // Pass if already read |
| 87 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 99 | + for($i=0;$i<$cur;$i++) { |
|
| 100 | + fgets($f, 1024); |
|
| 101 | + } |
|
| 88 | 102 | // Read each line until the codition meets |
| 89 | 103 | for($idx=$cur;$idx<$cur+$unit_count;$idx++) |
| 90 | 104 | { |
| 91 | - if(feof($f)) break; |
|
| 105 | + if(feof($f)) { |
|
| 106 | + break; |
|
| 107 | + } |
|
| 92 | 108 | // Find a location |
| 93 | 109 | $target_file = trim(fgets($f, 1024)); |
| 94 | 110 | |
| 95 | - if(!file_exists($target_file)) continue; |
|
| 111 | + if(!file_exists($target_file)) { |
|
| 112 | + continue; |
|
| 113 | + } |
|
| 96 | 114 | // Start importing data |
| 97 | 115 | $fp = fopen($target_file,"r"); |
| 98 | - if(!$fp) continue; |
|
| 116 | + if(!$fp) { |
|
| 117 | + continue; |
|
| 118 | + } |
|
| 99 | 119 | |
| 100 | 120 | $obj = null; |
| 101 | 121 | $obj->module_srl = $module_srl; |
@@ -116,14 +136,17 @@ discard block |
||
| 116 | 136 | $started = true; |
| 117 | 137 | continue; |
| 118 | 138 | // Import the attachment |
| 119 | - } |
|
| 120 | - else if(substr($str,0,12) == '<attachment ') |
|
| 139 | + } else if(substr($str,0,12) == '<attachment ') |
|
| 121 | 140 | { |
| 122 | - if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++; |
|
| 141 | + if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) { |
|
| 142 | + $obj->uploaded_count++; |
|
| 143 | + } |
|
| 123 | 144 | continue; |
| 124 | 145 | } |
| 125 | 146 | |
| 126 | - if($started) $buff .= $str; |
|
| 147 | + if($started) { |
|
| 148 | + $buff .= $str; |
|
| 149 | + } |
|
| 127 | 150 | } |
| 128 | 151 | |
| 129 | 152 | $xmlDoc = $this->oXmlParser->parse('<post>'.$buff); |
@@ -134,7 +157,9 @@ discard block |
||
| 134 | 157 | { |
| 135 | 158 | $tmp_arr = explode('/',$xmlDoc->post->category->body); |
| 136 | 159 | $category = trim($tmp_arr[count($tmp_arr)-1]); |
| 137 | - if($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
| 160 | + if($category_titles[$category]) { |
|
| 161 | + $obj->category_srl = $category_titles[$category]; |
|
| 162 | + } |
|
| 138 | 163 | } |
| 139 | 164 | |
| 140 | 165 | $obj->is_notice = 'N'; |
@@ -148,15 +173,21 @@ discard block |
||
| 148 | 173 | //$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N'; |
| 149 | 174 | $obj->regdate = date("YmdHis",$xmlDoc->post->published->body); |
| 150 | 175 | $obj->last_update = date("YmdHis", $xmlDoc->post->modified->body); |
| 151 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 176 | + if(!$obj->last_update) { |
|
| 177 | + $obj->last_update = $obj->regdate; |
|
| 178 | + } |
|
| 152 | 179 | |
| 153 | 180 | $tag = null; |
| 154 | 181 | $tmp_tags = null; |
| 155 | 182 | $tag = $xmlDoc->post->tag; |
| 156 | 183 | if($tag) |
| 157 | 184 | { |
| 158 | - if(!is_array($tag)) $tag = array($tag); |
|
| 159 | - foreach($tag as $key => $val) $tmp_tags[] = $val->body; |
|
| 185 | + if(!is_array($tag)) { |
|
| 186 | + $tag = array($tag); |
|
| 187 | + } |
|
| 188 | + foreach($tag as $key => $val) { |
|
| 189 | + $tmp_tags[] = $val->body; |
|
| 190 | + } |
|
| 160 | 191 | $obj->tags = implode(',',$tmp_tags); |
| 161 | 192 | } |
| 162 | 193 | |
@@ -192,7 +223,9 @@ discard block |
||
| 192 | 223 | if($xmlDoc->post->trackback) |
| 193 | 224 | { |
| 194 | 225 | $trackbacks = $xmlDoc->post->trackback; |
| 195 | - if(!is_array($trackbacks)) $trackbacks = array($trackbacks); |
|
| 226 | + if(!is_array($trackbacks)) { |
|
| 227 | + $trackbacks = array($trackbacks); |
|
| 228 | + } |
|
| 196 | 229 | if(count($trackbacks)) |
| 197 | 230 | { |
| 198 | 231 | foreach($trackbacks as $key => $val) |
@@ -209,7 +242,9 @@ discard block |
||
| 209 | 242 | $tobj->ipaddress = $val->ip->body; |
| 210 | 243 | $tobj->list_order = -1*$tobj->trackback_srl; |
| 211 | 244 | $output = executeQuery('trackback.insertTrackback', $tobj); |
| 212 | - if($output->toBool()) $obj->trackback_count++; |
|
| 245 | + if($output->toBool()) { |
|
| 246 | + $obj->trackback_count++; |
|
| 247 | + } |
|
| 213 | 248 | } |
| 214 | 249 | } |
| 215 | 250 | } |
@@ -218,21 +253,29 @@ discard block |
||
| 218 | 253 | if($xmlDoc->post->comment) |
| 219 | 254 | { |
| 220 | 255 | $comment = $xmlDoc->post->comment; |
| 221 | - if(!is_array($comment)) $comment = array($comment); |
|
| 256 | + if(!is_array($comment)) { |
|
| 257 | + $comment = array($comment); |
|
| 258 | + } |
|
| 222 | 259 | foreach($comment as $key => $val) |
| 223 | 260 | { |
| 224 | 261 | $parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); |
| 225 | - if($parent_srl === false) continue; |
|
| 262 | + if($parent_srl === false) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 226 | 265 | |
| 227 | 266 | $obj->comment_count++; |
| 228 | 267 | if($val->comment) |
| 229 | 268 | { |
| 230 | 269 | $child_comment = $val->comment; |
| 231 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 270 | + if(!is_array($child_comment)) { |
|
| 271 | + $child_comment = array($child_comment); |
|
| 272 | + } |
|
| 232 | 273 | foreach($child_comment as $k => $v) |
| 233 | 274 | { |
| 234 | 275 | $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id); |
| 235 | - if($result !== false) $obj->comment_count++; |
|
| 276 | + if($result !== false) { |
|
| 277 | + $obj->comment_count++; |
|
| 278 | + } |
|
| 236 | 279 | } |
| 237 | 280 | } |
| 238 | 281 | } |
@@ -270,7 +313,9 @@ discard block |
||
| 270 | 313 | $args->document_srl = $obj->document_srl; |
| 271 | 314 | $args->tag = trim($tag_list[$i]); |
| 272 | 315 | $args->regdate = $obj->regdate; |
| 273 | - if(!$args->tag) continue; |
|
| 316 | + if(!$args->tag) { |
|
| 317 | + continue; |
|
| 318 | + } |
|
| 274 | 319 | $output = executeQuery('tag.insertTag', $args); |
| 275 | 320 | } |
| 276 | 321 | } |
@@ -282,7 +327,9 @@ discard block |
||
| 282 | 327 | |
| 283 | 328 | fclose($f); |
| 284 | 329 | |
| 285 | - if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 330 | + if(count($category_list)) { |
|
| 331 | + foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 332 | + } |
|
| 286 | 333 | // Guestbook information |
| 287 | 334 | $guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file); |
| 288 | 335 | if(file_exists($guestbook_file)) |
@@ -293,7 +340,9 @@ discard block |
||
| 293 | 340 | if($guestbook_module_srl && $xmlDoc->guestbook->comment) |
| 294 | 341 | { |
| 295 | 342 | $comment = $xmlDoc->guestbook->comment; |
| 296 | - if(!is_array($comment)) $comment = array($comment); |
|
| 343 | + if(!is_array($comment)) { |
|
| 344 | + $comment = array($comment); |
|
| 345 | + } |
|
| 297 | 346 | |
| 298 | 347 | if($module_name =='textyle') |
| 299 | 348 | { |
@@ -304,7 +353,9 @@ discard block |
||
| 304 | 353 | if($val->comment) |
| 305 | 354 | { |
| 306 | 355 | $child_comment = $val->comment; |
| 307 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 356 | + if(!is_array($child_comment)) { |
|
| 357 | + $child_comment = array($child_comment); |
|
| 358 | + } |
|
| 308 | 359 | foreach($child_comment as $k => $v) |
| 309 | 360 | { |
| 310 | 361 | $result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info,0,$textyle_guestbook_srl,$author_xml_id); |
@@ -313,8 +364,7 @@ discard block |
||
| 313 | 364 | |
| 314 | 365 | $result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info,$textyle_guestbook_srl,0,$author_xml_id); |
| 315 | 366 | } |
| 316 | - } |
|
| 317 | - else |
|
| 367 | + } else |
|
| 318 | 368 | { |
| 319 | 369 | foreach($comment as $key => $val) |
| 320 | 370 | { |
@@ -328,13 +378,17 @@ discard block |
||
| 328 | 378 | |
| 329 | 379 | // Extract a title form the bocy |
| 330 | 380 | $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
| 331 | - if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 381 | + if ($obj->title == '') { |
|
| 382 | + $obj->title = 'Untitled'; |
|
| 383 | + } |
|
| 332 | 384 | |
| 333 | 385 | $obj->commentStatus = 'ALLOW'; |
| 334 | 386 | $obj->allow_trackback = 'N'; |
| 335 | 387 | $obj->regdate = date("YmdHis",$val->written->body); |
| 336 | 388 | $obj->last_update = date("YmdHis", $val->written->body); |
| 337 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 389 | + if(!$obj->last_update) { |
|
| 390 | + $obj->last_update = $obj->regdate; |
|
| 391 | + } |
|
| 338 | 392 | $obj->tags = ''; |
| 339 | 393 | $obj->readed_count = 0; |
| 340 | 394 | $obj->voted_count = 0; |
@@ -347,8 +401,7 @@ discard block |
||
| 347 | 401 | $obj->member_srl = $member_info->member_srl; |
| 348 | 402 | $obj->email_address = $member_info->email_address; |
| 349 | 403 | $obj->homepage = $member_info->homepage; |
| 350 | - } |
|
| 351 | - else |
|
| 404 | + } else |
|
| 352 | 405 | { |
| 353 | 406 | $obj->password = $val->password->body; |
| 354 | 407 | $obj->nick_name = $val->commenter->name->body; |
@@ -364,11 +417,15 @@ discard block |
||
| 364 | 417 | if($val->comment) |
| 365 | 418 | { |
| 366 | 419 | $child_comment = $val->comment; |
| 367 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 420 | + if(!is_array($child_comment)) { |
|
| 421 | + $child_comment = array($child_comment); |
|
| 422 | + } |
|
| 368 | 423 | foreach($child_comment as $k => $v) |
| 369 | 424 | { |
| 370 | 425 | $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0,$author_xml_id); |
| 371 | - if($result !== false) $obj->comment_count++; |
|
| 426 | + if($result !== false) { |
|
| 427 | + $obj->comment_count++; |
|
| 428 | + } |
|
| 372 | 429 | } |
| 373 | 430 | } |
| 374 | 431 | |
@@ -399,8 +456,7 @@ discard block |
||
| 399 | 456 | if($textyle_guestbook_srl>0) |
| 400 | 457 | { |
| 401 | 458 | $tobj->textyle_guestbook_srl = $textyle_guestbook_srl; |
| 402 | - } |
|
| 403 | - else |
|
| 459 | + } else |
|
| 404 | 460 | { |
| 405 | 461 | $tobj->textyle_guestbook_srl = getNextSequence(); |
| 406 | 462 | } |
@@ -416,8 +472,7 @@ discard block |
||
| 416 | 472 | $tobj->member_srl = $member_info->member_srl; |
| 417 | 473 | $tobj->homepage = $member_info->homepage; |
| 418 | 474 | $tobj->email_address = $member_info->email_address; |
| 419 | - } |
|
| 420 | - else |
|
| 475 | + } else |
|
| 421 | 476 | { |
| 422 | 477 | $tobj->password = $val->password->body; |
| 423 | 478 | $tobj->nick_name = $val->commenter->name->body; |
@@ -431,15 +486,16 @@ discard block |
||
| 431 | 486 | { |
| 432 | 487 | $tobj->parent_srl = $parent_srl; |
| 433 | 488 | $tobj->list_order = $tobj->parent_srl * -1; |
| 434 | - } |
|
| 435 | - else |
|
| 489 | + } else |
|
| 436 | 490 | { |
| 437 | 491 | $tobj->list_order = $tobj->textyle_guestbook_srl*-1; |
| 438 | 492 | } |
| 439 | 493 | |
| 440 | 494 | $output = executeQuery('textyle.insertTextyleGuestbook', $tobj); |
| 441 | 495 | |
| 442 | - if($output->toBool()) return $tobj->textyle_guestbook_srl; |
|
| 496 | + if($output->toBool()) { |
|
| 497 | + return $tobj->textyle_guestbook_srl; |
|
| 498 | + } |
|
| 443 | 499 | return false; |
| 444 | 500 | } |
| 445 | 501 | |
@@ -465,7 +521,9 @@ discard block |
||
| 465 | 521 | { |
| 466 | 522 | $str = fgets($fp, 1024); |
| 467 | 523 | // If it ends with </attaches>, break |
| 468 | - if(trim($str) == '</attachment>') break; |
|
| 524 | + if(trim($str) == '</attachment>') { |
|
| 525 | + break; |
|
| 526 | + } |
|
| 469 | 527 | // If it starts with <file>, handle the attachement in the xml file |
| 470 | 528 | if(substr($str, 0, 9)=='<content>') |
| 471 | 529 | { |
@@ -475,7 +533,9 @@ discard block |
||
| 475 | 533 | |
| 476 | 534 | $buff .= $str; |
| 477 | 535 | } |
| 478 | - if(!file_exists($file_obj->file)) return false; |
|
| 536 | + if(!file_exists($file_obj->file)) { |
|
| 537 | + return false; |
|
| 538 | + } |
|
| 479 | 539 | |
| 480 | 540 | $buff .= '</attachment>'; |
| 481 | 541 | |
@@ -490,15 +550,16 @@ discard block |
||
| 490 | 550 | $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
| 491 | 551 | $filename = $path.$file_obj->source_filename; |
| 492 | 552 | $file_obj->direct_download = 'Y'; |
| 493 | - } |
|
| 494 | - else |
|
| 553 | + } else |
|
| 495 | 554 | { |
| 496 | 555 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
| 497 | 556 | $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); |
| 498 | 557 | $file_obj->direct_download = 'N'; |
| 499 | 558 | } |
| 500 | 559 | // Create a directory |
| 501 | - if(!FileHandler::makeDir($path)) return; |
|
| 560 | + if(!FileHandler::makeDir($path)) { |
|
| 561 | + return; |
|
| 562 | + } |
|
| 502 | 563 | |
| 503 | 564 | FileHandler::rename($file_obj->file, $filename); |
| 504 | 565 | // Insert to the DB |
@@ -515,8 +576,11 @@ discard block |
||
| 515 | 576 | { |
| 516 | 577 | $uploaded_count++; |
| 517 | 578 | $tmp_obj = null; |
| 518 | - if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; |
|
| 519 | - else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
| 579 | + if($file_obj->direct_download == 'Y') { |
|
| 580 | + $files[$name]->url = $file_obj->uploaded_filename; |
|
| 581 | + } else { |
|
| 582 | + $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
| 583 | + } |
|
| 520 | 584 | $files[$name]->direct_download = $file_obj->direct_download; |
| 521 | 585 | $files[$name]->source_filename = $file_obj->source_filename; |
| 522 | 586 | return true; |
@@ -532,9 +596,13 @@ discard block |
||
| 532 | 596 | function getTmpFilename() |
| 533 | 597 | { |
| 534 | 598 | $path = "./files/cache/importer"; |
| 535 | - if(!is_dir($path)) FileHandler::makeDir($path); |
|
| 599 | + if(!is_dir($path)) { |
|
| 600 | + FileHandler::makeDir($path); |
|
| 601 | + } |
|
| 536 | 602 | $filename = sprintf("%s/%d", $path, rand(11111111,99999999)); |
| 537 | - if(file_exists($filename)) $filename .= rand(111,999); |
|
| 603 | + if(file_exists($filename)) { |
|
| 604 | + $filename .= rand(111,999); |
|
| 605 | + } |
|
| 538 | 606 | return $filename; |
| 539 | 607 | } |
| 540 | 608 | |
@@ -553,7 +621,9 @@ discard block |
||
| 553 | 621 | { |
| 554 | 622 | $str = trim(fgets($fp, 1024)); |
| 555 | 623 | $buff .= $str; |
| 556 | - if(substr($str, -10) == '</content>') break; |
|
| 624 | + if(substr($str, -10) == '</content>') { |
|
| 625 | + break; |
|
| 626 | + } |
|
| 557 | 627 | } |
| 558 | 628 | |
| 559 | 629 | $buff = substr($buff, 0, -10); |
@@ -572,7 +642,9 @@ discard block |
||
| 572 | 642 | function _replaceTTAttach($matches) |
| 573 | 643 | { |
| 574 | 644 | $name = $matches[2]; |
| 575 | - if(!$name) return $matches[0]; |
|
| 645 | + if(!$name) { |
|
| 646 | + return $matches[0]; |
|
| 647 | + } |
|
| 576 | 648 | |
| 577 | 649 | $obj = $this->files[$name]; |
| 578 | 650 | // If multimedia file is, |
@@ -583,14 +655,12 @@ discard block |
||
| 583 | 655 | { |
| 584 | 656 | return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4])); |
| 585 | 657 | // If other multimedia file but image is, |
| 586 | - } |
|
| 587 | - else |
|
| 658 | + } else |
|
| 588 | 659 | { |
| 589 | 660 | return sprintf('<img src="./common/img/blank.gif" editor_component="multimedia_link" multimedia_src="%s" width="400" height="320" style="display:block;width:400px;height:320px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center;" auto_start="false" alt="" />', $obj->url); |
| 590 | 661 | } |
| 591 | 662 | // If binary file is |
| 592 | - } |
|
| 593 | - else |
|
| 663 | + } else |
|
| 594 | 664 | { |
| 595 | 665 | return sprintf('<a href="%s">%s</a>', $obj->url, $obj->source_filename); |
| 596 | 666 | } |
@@ -603,7 +673,9 @@ discard block |
||
| 603 | 673 | function _replaceTTMovie($matches) |
| 604 | 674 | { |
| 605 | 675 | $key = $matches[1]; |
| 606 | - if(!$key) return $matches[0]; |
|
| 676 | + if(!$key) { |
|
| 677 | + return $matches[0]; |
|
| 678 | + } |
|
| 607 | 679 | |
| 608 | 680 | return |
| 609 | 681 | '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'. |
@@ -645,8 +717,7 @@ discard block |
||
| 645 | 717 | $tobj->member_srl = $member_info->member_srl; |
| 646 | 718 | $tobj->homepage = $member_info->homepage; |
| 647 | 719 | $tobj->email_address = $member_info->email_address; |
| 648 | - } |
|
| 649 | - else |
|
| 720 | + } else |
|
| 650 | 721 | { |
| 651 | 722 | $tobj->password = $val->password->body; |
| 652 | 723 | $tobj->nick_name = $val->commenter->name->body; |
@@ -670,24 +741,28 @@ discard block |
||
| 670 | 741 | $list_args->head = $list_args->arrange = $tobj->comment_srl; |
| 671 | 742 | $list_args->depth = 0; |
| 672 | 743 | // Get parent_srl if parent comment exists |
| 673 | - } |
|
| 674 | - else |
|
| 744 | + } else |
|
| 675 | 745 | { |
| 676 | 746 | // Get parent_srl |
| 677 | 747 | $parent_args->comment_srl = $tobj->parent_srl; |
| 678 | 748 | $parent_output = executeQuery('comment.getCommentListItem', $parent_args); |
| 679 | 749 | // Return if parent comment doesn't exist |
| 680 | - if(!$parent_output->toBool() || !$parent_output->data) return false; |
|
| 750 | + if(!$parent_output->toBool() || !$parent_output->data) { |
|
| 751 | + return false; |
|
| 752 | + } |
|
| 681 | 753 | $parent = $parent_output->data; |
| 682 | 754 | |
| 683 | 755 | $list_args->head = $parent->head; |
| 684 | 756 | $list_args->depth = $parent->depth+1; |
| 685 | - if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl; |
|
| 686 | - else |
|
| 757 | + if($list_args->depth<2) { |
|
| 758 | + $list_args->arrange = $tobj->comment_srl; |
|
| 759 | + } else |
|
| 687 | 760 | { |
| 688 | 761 | $list_args->arrange = $parent->arrange; |
| 689 | 762 | $output = executeQuery('comment.updateCommentListArrange', $list_args); |
| 690 | - if(!$output->toBool()) return $output; |
|
| 763 | + if(!$output->toBool()) { |
|
| 764 | + return $output; |
|
| 765 | + } |
|
| 691 | 766 | } |
| 692 | 767 | } |
| 693 | 768 | |
@@ -695,7 +770,9 @@ discard block |
||
| 695 | 770 | if($output->toBool()) |
| 696 | 771 | { |
| 697 | 772 | $output = executeQuery('comment.insertComment', $tobj); |
| 698 | - if($output->toBool()) return $tobj->comment_srl; |
|
| 773 | + if($output->toBool()) { |
|
| 774 | + return $tobj->comment_srl; |
|
| 775 | + } |
|
| 699 | 776 | } |
| 700 | 777 | return false; |
| 701 | 778 | } |
@@ -710,9 +787,14 @@ discard block |
||
| 710 | 787 | */ |
| 711 | 788 | function arrangeCategory($obj, &$category, &$idx, $parent = 0) |
| 712 | 789 | { |
| 713 | - if(!$obj->category) return; |
|
| 714 | - if(!is_array($obj->category)) $c = array($obj->category); |
|
| 715 | - else $c = $obj->category; |
|
| 790 | + if(!$obj->category) { |
|
| 791 | + return; |
|
| 792 | + } |
|
| 793 | + if(!is_array($obj->category)) { |
|
| 794 | + $c = array($obj->category); |
|
| 795 | + } else { |
|
| 796 | + $c = $obj->category; |
|
| 797 | + } |
|
| 716 | 798 | foreach($c as $val) |
| 717 | 799 | { |
| 718 | 800 | $idx++; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param string $module_name |
| 32 | 32 | * @return int |
| 33 | 33 | */ |
| 34 | - function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name=null) |
|
| 34 | + function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name = null) |
|
| 35 | 35 | { |
| 36 | 36 | // Pre-create the objects needed |
| 37 | 37 | $this->oXmlParser = new XmlParser(); |
@@ -40,33 +40,33 @@ discard block |
||
| 40 | 40 | $oDocumentModel = getModel('document'); |
| 41 | 41 | $category_list = $category_titles = array(); |
| 42 | 42 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 43 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 43 | + if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 44 | 44 | // First handle categorty information |
| 45 | 45 | $category_file = preg_replace('/index$/i', 'category.xml', $index_file); |
| 46 | - if(file_exists($category_file)) |
|
| 46 | + if (file_exists($category_file)) |
|
| 47 | 47 | { |
| 48 | 48 | // Create the xmlParser object |
| 49 | 49 | $xmlDoc = $this->oXmlParser->loadXmlFile($category_file); |
| 50 | 50 | // List category information |
| 51 | - if($xmlDoc->categories->category) |
|
| 51 | + if ($xmlDoc->categories->category) |
|
| 52 | 52 | { |
| 53 | 53 | $categories = array(); |
| 54 | 54 | $idx = 0; |
| 55 | 55 | $this->arrangeCategory($xmlDoc->categories, $categories, $idx, 0); |
| 56 | 56 | |
| 57 | 57 | $match_sequence = array(); |
| 58 | - foreach($categories as $k => $v) |
|
| 58 | + foreach ($categories as $k => $v) |
|
| 59 | 59 | { |
| 60 | 60 | $category = $v->name; |
| 61 | - if(!$category || $category_titles[$category]) continue; |
|
| 61 | + if (!$category || $category_titles[$category]) continue; |
|
| 62 | 62 | |
| 63 | 63 | $obj = null; |
| 64 | 64 | $obj->title = $category; |
| 65 | 65 | $obj->module_srl = $module_srl; |
| 66 | - if($v->parent) $obj->parent_srl = $match_sequence[$v->parent]; |
|
| 66 | + if ($v->parent) $obj->parent_srl = $match_sequence[$v->parent]; |
|
| 67 | 67 | $output = $oDocumentController->insertCategory($obj); |
| 68 | 68 | |
| 69 | - if($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
| 69 | + if ($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); |
|
| 70 | 70 | } |
| 71 | 71 | $oDocumentController->makeCategoryFile($module_srl); |
| 72 | 72 | } |
@@ -74,28 +74,28 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | $category_list = $category_titles = array(); |
| 76 | 76 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 77 | - if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 77 | + if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; |
|
| 78 | 78 | // Get administrator information |
| 79 | 79 | $oMemberModel = getModel('member'); |
| 80 | 80 | $member_info = $oMemberModel->getMemberInfoByUserID($user_id); |
| 81 | 81 | $author_xml_id = 0; |
| 82 | 82 | |
| 83 | - if(!$cur) $cur = 0; |
|
| 83 | + if (!$cur) $cur = 0; |
|
| 84 | 84 | // Open an index file |
| 85 | - $f = fopen($index_file,"r"); |
|
| 85 | + $f = fopen($index_file, "r"); |
|
| 86 | 86 | // Pass if already read |
| 87 | - for($i=0;$i<$cur;$i++) fgets($f, 1024); |
|
| 87 | + for ($i = 0; $i < $cur; $i++) fgets($f, 1024); |
|
| 88 | 88 | // Read each line until the codition meets |
| 89 | - for($idx=$cur;$idx<$cur+$unit_count;$idx++) |
|
| 89 | + for ($idx = $cur; $idx < $cur + $unit_count; $idx++) |
|
| 90 | 90 | { |
| 91 | - if(feof($f)) break; |
|
| 91 | + if (feof($f)) break; |
|
| 92 | 92 | // Find a location |
| 93 | 93 | $target_file = trim(fgets($f, 1024)); |
| 94 | 94 | |
| 95 | - if(!file_exists($target_file)) continue; |
|
| 95 | + if (!file_exists($target_file)) continue; |
|
| 96 | 96 | // Start importing data |
| 97 | - $fp = fopen($target_file,"r"); |
|
| 98 | - if(!$fp) continue; |
|
| 97 | + $fp = fopen($target_file, "r"); |
|
| 98 | + if (!$fp) continue; |
|
| 99 | 99 | |
| 100 | 100 | $obj = null; |
| 101 | 101 | $obj->module_srl = $module_srl; |
@@ -107,57 +107,57 @@ discard block |
||
| 107 | 107 | $started = false; |
| 108 | 108 | $buff = null; |
| 109 | 109 | // Start importing from the body data |
| 110 | - while(!feof($fp)) |
|
| 110 | + while (!feof($fp)) |
|
| 111 | 111 | { |
| 112 | 112 | $str = fgets($fp, 1024); |
| 113 | 113 | // Prepare an item |
| 114 | - if(substr($str,0,5) == '<post') |
|
| 114 | + if (substr($str, 0, 5) == '<post') |
|
| 115 | 115 | { |
| 116 | 116 | $started = true; |
| 117 | 117 | continue; |
| 118 | 118 | // Import the attachment |
| 119 | 119 | } |
| 120 | - else if(substr($str,0,12) == '<attachment ') |
|
| 120 | + else if (substr($str, 0, 12) == '<attachment ') |
|
| 121 | 121 | { |
| 122 | - if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++; |
|
| 122 | + if ($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++; |
|
| 123 | 123 | continue; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if($started) $buff .= $str; |
|
| 126 | + if ($started) $buff .= $str; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $xmlDoc = $this->oXmlParser->parse('<post>'.$buff); |
| 130 | 130 | |
| 131 | 131 | $author_xml_id = $xmlDoc->post->author->body; |
| 132 | 132 | |
| 133 | - if($xmlDoc->post->category->body) |
|
| 133 | + if ($xmlDoc->post->category->body) |
|
| 134 | 134 | { |
| 135 | - $tmp_arr = explode('/',$xmlDoc->post->category->body); |
|
| 136 | - $category = trim($tmp_arr[count($tmp_arr)-1]); |
|
| 137 | - if($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
| 135 | + $tmp_arr = explode('/', $xmlDoc->post->category->body); |
|
| 136 | + $category = trim($tmp_arr[count($tmp_arr) - 1]); |
|
| 137 | + if ($category_titles[$category]) $obj->category_srl = $category_titles[$category]; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $obj->is_notice = 'N'; |
| 141 | - $obj->status = in_array($xmlDoc->post->visibility->body, array('public','syndicated'))?$oDocumentModel->getConfigStatus('public'):$oDocumentModel->getConfigStatus('secret'); |
|
| 141 | + $obj->status = in_array($xmlDoc->post->visibility->body, array('public', 'syndicated')) ? $oDocumentModel->getConfigStatus('public') : $oDocumentModel->getConfigStatus('secret'); |
|
| 142 | 142 | $obj->title = $xmlDoc->post->title->body; |
| 143 | 143 | $obj->content = $xmlDoc->post->content->body; |
| 144 | 144 | $obj->password = md5($xmlDoc->post->password->body); |
| 145 | - $obj->commentStatus = $xmlDoc->post->acceptcomment->body=='1'?'ALLOW':'DENY'; |
|
| 146 | - $obj->allow_trackback = $xmlDoc->post->accepttrackback->body=='1'?'Y':'N'; |
|
| 145 | + $obj->commentStatus = $xmlDoc->post->acceptcomment->body == '1' ? 'ALLOW' : 'DENY'; |
|
| 146 | + $obj->allow_trackback = $xmlDoc->post->accepttrackback->body == '1' ? 'Y' : 'N'; |
|
| 147 | 147 | //$obj->allow_comment = $xmlDoc->post->acceptComment->body=='1'?'Y':'N'; |
| 148 | 148 | //$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N'; |
| 149 | - $obj->regdate = date("YmdHis",$xmlDoc->post->published->body); |
|
| 149 | + $obj->regdate = date("YmdHis", $xmlDoc->post->published->body); |
|
| 150 | 150 | $obj->last_update = date("YmdHis", $xmlDoc->post->modified->body); |
| 151 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 151 | + if (!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 152 | 152 | |
| 153 | 153 | $tag = null; |
| 154 | 154 | $tmp_tags = null; |
| 155 | 155 | $tag = $xmlDoc->post->tag; |
| 156 | - if($tag) |
|
| 156 | + if ($tag) |
|
| 157 | 157 | { |
| 158 | - if(!is_array($tag)) $tag = array($tag); |
|
| 159 | - foreach($tag as $key => $val) $tmp_tags[] = $val->body; |
|
| 160 | - $obj->tags = implode(',',$tmp_tags); |
|
| 158 | + if (!is_array($tag)) $tag = array($tag); |
|
| 159 | + foreach ($tag as $key => $val) $tmp_tags[] = $val->body; |
|
| 160 | + $obj->tags = implode(',', $tmp_tags); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $obj->readed_count = 0; |
@@ -169,33 +169,33 @@ discard block |
||
| 169 | 169 | $obj->email_address = $member_info->email_address; |
| 170 | 170 | $obj->homepage = $member_info->homepage; |
| 171 | 171 | $obj->ipaddress = $_REMOTE['SERVER_ADDR']; |
| 172 | - $obj->list_order = $obj->update_order = $obj->document_srl*-1; |
|
| 172 | + $obj->list_order = $obj->update_order = $obj->document_srl * -1; |
|
| 173 | 173 | $obj->notify_message = 'N'; |
| 174 | 174 | // Change content information (attachment) |
| 175 | - $obj->content = str_replace('[##_ATTACH_PATH_##]/','',$obj->content); |
|
| 176 | - if(count($files)) |
|
| 175 | + $obj->content = str_replace('[##_ATTACH_PATH_##]/', '', $obj->content); |
|
| 176 | + if (count($files)) |
|
| 177 | 177 | { |
| 178 | - foreach($files as $key => $val) { |
|
| 179 | - $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val->url.'"',$obj->content); |
|
| 178 | + foreach ($files as $key => $val) { |
|
| 179 | + $obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val->url.'"', $obj->content); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $obj->content = preg_replace_callback('!\[##_Movie\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTMovie'), $obj->content); |
| 184 | 184 | |
| 185 | - if(count($files)) |
|
| 185 | + if (count($files)) |
|
| 186 | 186 | { |
| 187 | 187 | $this->files = $files; |
| 188 | 188 | $obj->content = preg_replace_callback('!\[##_([a-z0-9]+)\|([^\|]*)\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTAttach'), $obj->content); |
| 189 | 189 | } |
| 190 | 190 | // Trackback inserted |
| 191 | 191 | $obj->trackback_count = 0; |
| 192 | - if($xmlDoc->post->trackback) |
|
| 192 | + if ($xmlDoc->post->trackback) |
|
| 193 | 193 | { |
| 194 | 194 | $trackbacks = $xmlDoc->post->trackback; |
| 195 | - if(!is_array($trackbacks)) $trackbacks = array($trackbacks); |
|
| 196 | - if(count($trackbacks)) |
|
| 195 | + if (!is_array($trackbacks)) $trackbacks = array($trackbacks); |
|
| 196 | + if (count($trackbacks)) |
|
| 197 | 197 | { |
| 198 | - foreach($trackbacks as $key => $val) |
|
| 198 | + foreach ($trackbacks as $key => $val) |
|
| 199 | 199 | { |
| 200 | 200 | $tobj = null; |
| 201 | 201 | $tobj->trackback_srl = getNextSequence(); |
@@ -205,40 +205,40 @@ discard block |
||
| 205 | 205 | $tobj->title = $val->title->body; |
| 206 | 206 | $tobj->blog_name = $val->site->body; |
| 207 | 207 | $tobj->excerpt = $val->excerpt->body; |
| 208 | - $tobj->regdate = date("YmdHis",$val->received->body); |
|
| 208 | + $tobj->regdate = date("YmdHis", $val->received->body); |
|
| 209 | 209 | $tobj->ipaddress = $val->ip->body; |
| 210 | - $tobj->list_order = -1*$tobj->trackback_srl; |
|
| 210 | + $tobj->list_order = -1 * $tobj->trackback_srl; |
|
| 211 | 211 | $output = executeQuery('trackback.insertTrackback', $tobj); |
| 212 | - if($output->toBool()) $obj->trackback_count++; |
|
| 212 | + if ($output->toBool()) $obj->trackback_count++; |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | // Comment |
| 217 | 217 | $obj->comment_count = 0; |
| 218 | - if($xmlDoc->post->comment) |
|
| 218 | + if ($xmlDoc->post->comment) |
|
| 219 | 219 | { |
| 220 | 220 | $comment = $xmlDoc->post->comment; |
| 221 | - if(!is_array($comment)) $comment = array($comment); |
|
| 222 | - foreach($comment as $key => $val) |
|
| 221 | + if (!is_array($comment)) $comment = array($comment); |
|
| 222 | + foreach ($comment as $key => $val) |
|
| 223 | 223 | { |
| 224 | 224 | $parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); |
| 225 | - if($parent_srl === false) continue; |
|
| 225 | + if ($parent_srl === false) continue; |
|
| 226 | 226 | |
| 227 | 227 | $obj->comment_count++; |
| 228 | - if($val->comment) |
|
| 228 | + if ($val->comment) |
|
| 229 | 229 | { |
| 230 | 230 | $child_comment = $val->comment; |
| 231 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 232 | - foreach($child_comment as $k => $v) |
|
| 231 | + if (!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 232 | + foreach ($child_comment as $k => $v) |
|
| 233 | 233 | { |
| 234 | 234 | $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id); |
| 235 | - if($result !== false) $obj->comment_count++; |
|
| 235 | + if ($result !== false) $obj->comment_count++; |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if($module_name == 'textyle') |
|
| 241 | + if ($module_name == 'textyle') |
|
| 242 | 242 | { |
| 243 | 243 | $args->document_srl = $obj->document_srl; |
| 244 | 244 | $args->module_srl = $obj->module_srl; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | // Visibility value of published state |
| 248 | 248 | $status_published = array('public', 'syndicated'); |
| 249 | 249 | // Save state if not published |
| 250 | - if(!in_array($xmlDoc->post->visibility->body, $status_published)) |
|
| 250 | + if (!in_array($xmlDoc->post->visibility->body, $status_published)) |
|
| 251 | 251 | { |
| 252 | 252 | $obj->module_srl = $member_info->member_srl; |
| 253 | 253 | } |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | // Document |
| 256 | 256 | $output = executeQuery('document.insertDocument', $obj); |
| 257 | 257 | |
| 258 | - if($output->toBool()) |
|
| 258 | + if ($output->toBool()) |
|
| 259 | 259 | { |
| 260 | 260 | // Tags |
| 261 | - if($obj->tags) |
|
| 261 | + if ($obj->tags) |
|
| 262 | 262 | { |
| 263 | - $tag_list = explode(',',$obj->tags); |
|
| 263 | + $tag_list = explode(',', $obj->tags); |
|
| 264 | 264 | $tag_count = count($tag_list); |
| 265 | - for($i=0;$i<$tag_count;$i++) |
|
| 265 | + for ($i = 0; $i < $tag_count; $i++) |
|
| 266 | 266 | { |
| 267 | 267 | $args = new stdClass; |
| 268 | 268 | $args->tag_srl = getNextSequence(); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $args->document_srl = $obj->document_srl; |
| 271 | 271 | $args->tag = trim($tag_list[$i]); |
| 272 | 272 | $args->regdate = $obj->regdate; |
| 273 | - if(!$args->tag) continue; |
|
| 273 | + if (!$args->tag) continue; |
|
| 274 | 274 | $output = executeQuery('tag.insertTag', $args); |
| 275 | 275 | } |
| 276 | 276 | } |
@@ -282,63 +282,63 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | fclose($f); |
| 284 | 284 | |
| 285 | - if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 285 | + if (count($category_list)) foreach ($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); |
|
| 286 | 286 | // Guestbook information |
| 287 | 287 | $guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file); |
| 288 | - if(file_exists($guestbook_file)) |
|
| 288 | + if (file_exists($guestbook_file)) |
|
| 289 | 289 | { |
| 290 | 290 | // Create the xmlParser object |
| 291 | 291 | $xmlDoc = $this->oXmlParser->loadXmlFile($guestbook_file); |
| 292 | 292 | // Handle guest book information |
| 293 | - if($guestbook_module_srl && $xmlDoc->guestbook->comment) |
|
| 293 | + if ($guestbook_module_srl && $xmlDoc->guestbook->comment) |
|
| 294 | 294 | { |
| 295 | 295 | $comment = $xmlDoc->guestbook->comment; |
| 296 | - if(!is_array($comment)) $comment = array($comment); |
|
| 296 | + if (!is_array($comment)) $comment = array($comment); |
|
| 297 | 297 | |
| 298 | - if($module_name =='textyle') |
|
| 298 | + if ($module_name == 'textyle') |
|
| 299 | 299 | { |
| 300 | - foreach($comment as $key => $val) |
|
| 300 | + foreach ($comment as $key => $val) |
|
| 301 | 301 | { |
| 302 | - $textyle_guestbook_srl = getNextSequence(); |
|
| 302 | + $textyle_guestbook_srl = getNextSequence(); |
|
| 303 | 303 | |
| 304 | - if($val->comment) |
|
| 304 | + if ($val->comment) |
|
| 305 | 305 | { |
| 306 | 306 | $child_comment = $val->comment; |
| 307 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 308 | - foreach($child_comment as $k => $v) |
|
| 307 | + if (!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 308 | + foreach ($child_comment as $k => $v) |
|
| 309 | 309 | { |
| 310 | - $result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info,0,$textyle_guestbook_srl,$author_xml_id); |
|
| 310 | + $result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info, 0, $textyle_guestbook_srl, $author_xml_id); |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info,$textyle_guestbook_srl,0,$author_xml_id); |
|
| 314 | + $result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, 0, $author_xml_id); |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | else |
| 318 | 318 | { |
| 319 | - foreach($comment as $key => $val) |
|
| 319 | + foreach ($comment as $key => $val) |
|
| 320 | 320 | { |
| 321 | 321 | $obj = null; |
| 322 | 322 | $obj->module_srl = $guestbook_module_srl; |
| 323 | 323 | $obj->document_srl = getNextSequence(); |
| 324 | 324 | $obj->uploaded_count = 0; |
| 325 | 325 | $obj->is_notice = 'N'; |
| 326 | - $obj->status = $val->secret->body=='1'?$oDocumentModel->getConfigStatus('secret'):$oDocumentModel->getConfigStatus('public'); |
|
| 326 | + $obj->status = $val->secret->body == '1' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public'); |
|
| 327 | 327 | $obj->content = nl2br($val->content->body); |
| 328 | 328 | |
| 329 | 329 | // Extract a title form the bocy |
| 330 | - $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 330 | + $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
| 331 | 331 | if ($obj->title == '') $obj->title = 'Untitled'; |
| 332 | 332 | |
| 333 | 333 | $obj->commentStatus = 'ALLOW'; |
| 334 | 334 | $obj->allow_trackback = 'N'; |
| 335 | - $obj->regdate = date("YmdHis",$val->written->body); |
|
| 335 | + $obj->regdate = date("YmdHis", $val->written->body); |
|
| 336 | 336 | $obj->last_update = date("YmdHis", $val->written->body); |
| 337 | - if(!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 337 | + if (!$obj->last_update) $obj->last_update = $obj->regdate; |
|
| 338 | 338 | $obj->tags = ''; |
| 339 | 339 | $obj->readed_count = 0; |
| 340 | 340 | $obj->voted_count = 0; |
| 341 | - if($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
| 341 | + if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
| 342 | 342 | { |
| 343 | 343 | $obj->password = ''; |
| 344 | 344 | $obj->nick_name = $member_info->nick_name; |
@@ -356,19 +356,19 @@ discard block |
||
| 356 | 356 | $homepage = $val->commenter->homepage->body; |
| 357 | 357 | } |
| 358 | 358 | $obj->ipaddress = $val->commenter->ip->body; |
| 359 | - $obj->list_order = $obj->update_order = $obj->document_srl*-1; |
|
| 359 | + $obj->list_order = $obj->update_order = $obj->document_srl * -1; |
|
| 360 | 360 | $obj->notify_message = 'N'; |
| 361 | 361 | $obj->trackback_count = 0; |
| 362 | 362 | |
| 363 | 363 | $obj->comment_count = 0; |
| 364 | - if($val->comment) |
|
| 364 | + if ($val->comment) |
|
| 365 | 365 | { |
| 366 | 366 | $child_comment = $val->comment; |
| 367 | - if(!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 368 | - foreach($child_comment as $k => $v) |
|
| 367 | + if (!is_array($child_comment)) $child_comment = array($child_comment); |
|
| 368 | + foreach ($child_comment as $k => $v) |
|
| 369 | 369 | { |
| 370 | - $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0,$author_xml_id); |
|
| 371 | - if($result !== false) $obj->comment_count++; |
|
| 370 | + $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); |
|
| 371 | + if ($result !== false) $obj->comment_count++; |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | FileHandler::removeFile($guestbook_file); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - return $idx-1; |
|
| 383 | + return $idx - 1; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | * @param int $author_xml_id |
| 394 | 394 | * @return int|bool |
| 395 | 395 | */ |
| 396 | - function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl,$parent_srl = 0, $author_xml_id=null) |
|
| 396 | + function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, $parent_srl = 0, $author_xml_id = null) |
|
| 397 | 397 | { |
| 398 | 398 | $tobj = null; |
| 399 | - if($textyle_guestbook_srl>0) |
|
| 399 | + if ($textyle_guestbook_srl > 0) |
|
| 400 | 400 | { |
| 401 | 401 | $tobj->textyle_guestbook_srl = $textyle_guestbook_srl; |
| 402 | 402 | } |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | $tobj->textyle_guestbook_srl = getNextSequence(); |
| 406 | 406 | } |
| 407 | 407 | $tobj->module_srl = $module_srl; |
| 408 | - $tobj->is_secret = $val->secret->body=='1'?1:-1; |
|
| 408 | + $tobj->is_secret = $val->secret->body == '1' ? 1 : -1; |
|
| 409 | 409 | $tobj->content = nl2br($val->content->body); |
| 410 | - if($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
| 410 | + if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
| 411 | 411 | { |
| 412 | 412 | $tobj->password = ''; |
| 413 | 413 | $tobj->nick_name = $member_info->nick_name; |
@@ -424,22 +424,22 @@ discard block |
||
| 424 | 424 | $tobj->homepage = $val->commenter->homepage->body; |
| 425 | 425 | $tobj->member_srl = 0; |
| 426 | 426 | } |
| 427 | - $tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body); |
|
| 427 | + $tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body); |
|
| 428 | 428 | $tobj->ipaddress = $val->commenter->ip->body; |
| 429 | 429 | |
| 430 | - if($parent_srl>0) |
|
| 430 | + if ($parent_srl > 0) |
|
| 431 | 431 | { |
| 432 | 432 | $tobj->parent_srl = $parent_srl; |
| 433 | 433 | $tobj->list_order = $tobj->parent_srl * -1; |
| 434 | 434 | } |
| 435 | 435 | else |
| 436 | 436 | { |
| 437 | - $tobj->list_order = $tobj->textyle_guestbook_srl*-1; |
|
| 437 | + $tobj->list_order = $tobj->textyle_guestbook_srl * -1; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | $output = executeQuery('textyle.insertTextyleGuestbook', $tobj); |
| 441 | 441 | |
| 442 | - if($output->toBool()) return $tobj->textyle_guestbook_srl; |
|
| 442 | + if ($output->toBool()) return $tobj->textyle_guestbook_srl; |
|
| 443 | 443 | return false; |
| 444 | 444 | } |
| 445 | 445 | |
@@ -456,18 +456,18 @@ discard block |
||
| 456 | 456 | { |
| 457 | 457 | $uploaded_count = 0; |
| 458 | 458 | |
| 459 | - $file_obj = null; |
|
| 459 | + $file_obj = null; |
|
| 460 | 460 | $file_obj->file_srl = getNextSequence(); |
| 461 | 461 | $file_obj->upload_target_srl = $upload_target_srl; |
| 462 | 462 | $file_obj->module_srl = $module_srl; |
| 463 | 463 | |
| 464 | - while(!feof($fp)) |
|
| 464 | + while (!feof($fp)) |
|
| 465 | 465 | { |
| 466 | 466 | $str = fgets($fp, 1024); |
| 467 | 467 | // If it ends with </attaches>, break |
| 468 | - if(trim($str) == '</attachment>') break; |
|
| 468 | + if (trim($str) == '</attachment>') break; |
|
| 469 | 469 | // If it starts with <file>, handle the attachement in the xml file |
| 470 | - if(substr($str, 0, 9)=='<content>') |
|
| 470 | + if (substr($str, 0, 9) == '<content>') |
|
| 471 | 471 | { |
| 472 | 472 | $file_obj->file = $this->saveTemporaryFile($fp, $str); |
| 473 | 473 | continue; |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | $buff .= $str; |
| 477 | 477 | } |
| 478 | - if(!file_exists($file_obj->file)) return false; |
|
| 478 | + if (!file_exists($file_obj->file)) return false; |
|
| 479 | 479 | |
| 480 | 480 | $buff .= '</attachment>'; |
| 481 | 481 | |
@@ -485,20 +485,20 @@ discard block |
||
| 485 | 485 | $file_obj->download_count = $xmlDoc->attachment->downloads->body; |
| 486 | 486 | $name = $xmlDoc->attachment->name->body; |
| 487 | 487 | // Set upload path by checking if the attachement is an image or other kind of file |
| 488 | - if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename)) |
|
| 488 | + if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename)) |
|
| 489 | 489 | { |
| 490 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
| 490 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 491 | 491 | $filename = $path.$file_obj->source_filename; |
| 492 | 492 | $file_obj->direct_download = 'Y'; |
| 493 | 493 | } |
| 494 | 494 | else |
| 495 | 495 | { |
| 496 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
| 497 | - $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); |
|
| 496 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 497 | + $filename = $path.md5(crypt(rand(1000000, 900000), rand(0, 100))); |
|
| 498 | 498 | $file_obj->direct_download = 'N'; |
| 499 | 499 | } |
| 500 | 500 | // Create a directory |
| 501 | - if(!FileHandler::makeDir($path)) return; |
|
| 501 | + if (!FileHandler::makeDir($path)) return; |
|
| 502 | 502 | |
| 503 | 503 | FileHandler::rename($file_obj->file, $filename); |
| 504 | 504 | // Insert to the DB |
@@ -507,16 +507,16 @@ discard block |
||
| 507 | 507 | $file_obj->file_size = filesize($filename); |
| 508 | 508 | $file_obj->comment = NULL; |
| 509 | 509 | $file_obj->member_srl = 0; |
| 510 | - $file_obj->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999))); |
|
| 510 | + $file_obj->sid = md5(rand(rand(1111111, 4444444), rand(4444445, 9999999))); |
|
| 511 | 511 | $file_obj->isvalid = 'Y'; |
| 512 | 512 | $output = executeQuery('file.insertFile', $file_obj); |
| 513 | 513 | |
| 514 | - if($output->toBool()) |
|
| 514 | + if ($output->toBool()) |
|
| 515 | 515 | { |
| 516 | 516 | $uploaded_count++; |
| 517 | 517 | $tmp_obj = null; |
| 518 | - if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; |
|
| 519 | - else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid); |
|
| 518 | + if ($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; |
|
| 519 | + else $files[$name]->url = getUrl('', 'module', 'file', 'act', 'procFileDownload', 'file_srl', $file_obj->file_srl, 'sid', $file_obj->sid); |
|
| 520 | 520 | $files[$name]->direct_download = $file_obj->direct_download; |
| 521 | 521 | $files[$name]->source_filename = $file_obj->source_filename; |
| 522 | 522 | return true; |
@@ -532,9 +532,9 @@ discard block |
||
| 532 | 532 | function getTmpFilename() |
| 533 | 533 | { |
| 534 | 534 | $path = "./files/cache/importer"; |
| 535 | - if(!is_dir($path)) FileHandler::makeDir($path); |
|
| 536 | - $filename = sprintf("%s/%d", $path, rand(11111111,99999999)); |
|
| 537 | - if(file_exists($filename)) $filename .= rand(111,999); |
|
| 535 | + if (!is_dir($path)) FileHandler::makeDir($path); |
|
| 536 | + $filename = sprintf("%s/%d", $path, rand(11111111, 99999999)); |
|
| 537 | + if (file_exists($filename)) $filename .= rand(111, 999); |
|
| 538 | 538 | return $filename; |
| 539 | 539 | } |
| 540 | 540 | |
@@ -549,11 +549,11 @@ discard block |
||
| 549 | 549 | $temp_filename = $this->getTmpFilename(); |
| 550 | 550 | $buff = substr($buff, 9); |
| 551 | 551 | |
| 552 | - while(!feof($fp)) |
|
| 552 | + while (!feof($fp)) |
|
| 553 | 553 | { |
| 554 | 554 | $str = trim(fgets($fp, 1024)); |
| 555 | 555 | $buff .= $str; |
| 556 | - if(substr($str, -10) == '</content>') break; |
|
| 556 | + if (substr($str, -10) == '</content>') break; |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | $buff = substr($buff, 0, -10); |
@@ -572,16 +572,16 @@ discard block |
||
| 572 | 572 | function _replaceTTAttach($matches) |
| 573 | 573 | { |
| 574 | 574 | $name = $matches[2]; |
| 575 | - if(!$name) return $matches[0]; |
|
| 575 | + if (!$name) return $matches[0]; |
|
| 576 | 576 | |
| 577 | 577 | $obj = $this->files[$name]; |
| 578 | 578 | // If multimedia file is, |
| 579 | - if($obj->direct_download == 'Y') |
|
| 579 | + if ($obj->direct_download == 'Y') |
|
| 580 | 580 | { |
| 581 | 581 | // If image file is |
| 582 | - if(preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename)) |
|
| 582 | + if (preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename)) |
|
| 583 | 583 | { |
| 584 | - return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4])); |
|
| 584 | + return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"', '\\"', $matches[4])); |
|
| 585 | 585 | // If other multimedia file but image is, |
| 586 | 586 | } |
| 587 | 587 | else |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | function _replaceTTMovie($matches) |
| 604 | 604 | { |
| 605 | 605 | $key = $matches[1]; |
| 606 | - if(!$key) return $matches[0]; |
|
| 606 | + if (!$key) return $matches[0]; |
|
| 607 | 607 | |
| 608 | 608 | return |
| 609 | 609 | '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'. |
@@ -631,12 +631,12 @@ discard block |
||
| 631 | 631 | $tobj->comment_srl = getNextSequence(); |
| 632 | 632 | $tobj->module_srl = $module_srl; |
| 633 | 633 | $tobj->document_srl = $document_srl; |
| 634 | - $tobj->is_secret = $val->secret->body=='1'?'Y':'N'; |
|
| 634 | + $tobj->is_secret = $val->secret->body == '1' ? 'Y' : 'N'; |
|
| 635 | 635 | $tobj->notify_message = 'N'; |
| 636 | 636 | $tobj->content = nl2br($val->content->body); |
| 637 | 637 | $tobj->voted_count = 0; |
| 638 | 638 | $tobj->status = 1; |
| 639 | - if($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
| 639 | + if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id) |
|
| 640 | 640 | { |
| 641 | 641 | $tobj->password = ''; |
| 642 | 642 | $tobj->nick_name = $member_info->nick_name; |
@@ -653,9 +653,9 @@ discard block |
||
| 653 | 653 | $tobj->homepage = $val->commenter->homepage->body; |
| 654 | 654 | $tobj->member_srl = 0; |
| 655 | 655 | } |
| 656 | - $tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body); |
|
| 656 | + $tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body); |
|
| 657 | 657 | $tobj->ipaddress = $val->commenter->ip->body; |
| 658 | - $tobj->list_order = $tobj->comment_srl*-1; |
|
| 658 | + $tobj->list_order = $tobj->comment_srl * -1; |
|
| 659 | 659 | $tobj->sequence = $sequence; |
| 660 | 660 | $tobj->parent_srl = $parent_srl; |
| 661 | 661 | // Comment list first |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | $list_args->module_srl = $tobj->module_srl; |
| 666 | 666 | $list_args->regdate = $tobj->regdate; |
| 667 | 667 | // Set data directly if parent comment doesn't exist |
| 668 | - if(!$tobj->parent_srl) |
|
| 668 | + if (!$tobj->parent_srl) |
|
| 669 | 669 | { |
| 670 | 670 | $list_args->head = $list_args->arrange = $tobj->comment_srl; |
| 671 | 671 | $list_args->depth = 0; |
@@ -677,25 +677,25 @@ discard block |
||
| 677 | 677 | $parent_args->comment_srl = $tobj->parent_srl; |
| 678 | 678 | $parent_output = executeQuery('comment.getCommentListItem', $parent_args); |
| 679 | 679 | // Return if parent comment doesn't exist |
| 680 | - if(!$parent_output->toBool() || !$parent_output->data) return false; |
|
| 680 | + if (!$parent_output->toBool() || !$parent_output->data) return false; |
|
| 681 | 681 | $parent = $parent_output->data; |
| 682 | 682 | |
| 683 | 683 | $list_args->head = $parent->head; |
| 684 | - $list_args->depth = $parent->depth+1; |
|
| 685 | - if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl; |
|
| 684 | + $list_args->depth = $parent->depth + 1; |
|
| 685 | + if ($list_args->depth < 2) $list_args->arrange = $tobj->comment_srl; |
|
| 686 | 686 | else |
| 687 | 687 | { |
| 688 | 688 | $list_args->arrange = $parent->arrange; |
| 689 | 689 | $output = executeQuery('comment.updateCommentListArrange', $list_args); |
| 690 | - if(!$output->toBool()) return $output; |
|
| 690 | + if (!$output->toBool()) return $output; |
|
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | $output = executeQuery('comment.insertCommentList', $list_args); |
| 695 | - if($output->toBool()) |
|
| 695 | + if ($output->toBool()) |
|
| 696 | 696 | { |
| 697 | 697 | $output = executeQuery('comment.insertComment', $tobj); |
| 698 | - if($output->toBool()) return $tobj->comment_srl; |
|
| 698 | + if ($output->toBool()) return $tobj->comment_srl; |
|
| 699 | 699 | } |
| 700 | 700 | return false; |
| 701 | 701 | } |
@@ -710,10 +710,10 @@ discard block |
||
| 710 | 710 | */ |
| 711 | 711 | function arrangeCategory($obj, &$category, &$idx, $parent = 0) |
| 712 | 712 | { |
| 713 | - if(!$obj->category) return; |
|
| 714 | - if(!is_array($obj->category)) $c = array($obj->category); |
|
| 713 | + if (!$obj->category) return; |
|
| 714 | + if (!is_array($obj->category)) $c = array($obj->category); |
|
| 715 | 715 | else $c = $obj->category; |
| 716 | - foreach($c as $val) |
|
| 716 | + foreach ($c as $val) |
|
| 717 | 717 | { |
| 718 | 718 | $idx++; |
| 719 | 719 | $priority = $val->priority->body; |
@@ -545,6 +545,7 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | /** |
| 547 | 547 | * @brief Install an each module |
| 548 | + * @param string $module_path |
|
| 548 | 549 | */ |
| 549 | 550 | function installModule($module, $module_path) |
| 550 | 551 | { |
@@ -614,6 +615,7 @@ discard block |
||
| 614 | 615 | /** |
| 615 | 616 | * @brief Create etc config file |
| 616 | 617 | * Create the config file when all settings are completed |
| 618 | + * @param stdClass $config_info |
|
| 617 | 619 | */ |
| 618 | 620 | function makeEtcConfigFile($config_info) |
| 619 | 621 | { |
@@ -413,7 +413,7 @@ |
||
| 413 | 413 | * make a file to files/config and check url approach by ".htaccess" rules |
| 414 | 414 | * |
| 415 | 415 | * @return bool |
| 416 | - */ |
|
| 416 | + */ |
|
| 417 | 417 | function checkRewriteUsable() { |
| 418 | 418 | $checkString = "isApproached"; |
| 419 | 419 | $checkFilePath = 'files/config/tmpRewriteCheck.txt'; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | function init() |
| 18 | 18 | { |
| 19 | 19 | // Error occurs if already installed |
| 20 | - if($this->act !== 'procInstallLicenseAggrement' && Context::isInstalled()) |
|
| 20 | + if ($this->act !== 'procInstallLicenseAggrement' && Context::isInstalled()) |
|
| 21 | 21 | { |
| 22 | 22 | $this->stop('msg_already_installed'); |
| 23 | 23 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | function _procDBSetting() |
| 87 | 87 | { |
| 88 | 88 | // Get DB-related variables |
| 89 | - $con_string = Context::gets('db_type','db_port','db_hostname','db_userid','db_password','db_database','db_table_prefix'); |
|
| 89 | + $con_string = Context::gets('db_type', 'db_port', 'db_hostname', 'db_userid', 'db_password', 'db_database', 'db_table_prefix'); |
|
| 90 | 90 | |
| 91 | 91 | $db_info = new stdClass(); |
| 92 | 92 | $db_info->master_db = get_object_vars($con_string); |
@@ -101,13 +101,13 @@ discard block |
||
| 101 | 101 | // Check if available to connect to the DB |
| 102 | 102 | $oDB = &DB::getInstance(); |
| 103 | 103 | $output = $oDB->getError(); |
| 104 | - if(!$output->toBool()) return $output; |
|
| 105 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
| 104 | + if (!$output->toBool()) return $output; |
|
| 105 | + if (!$oDB->isConnected()) return $oDB->getError(); |
|
| 106 | 106 | |
| 107 | 107 | // Create a db temp config file |
| 108 | - if(!$this->makeDBConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
| 108 | + if (!$this->makeDBConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
| 109 | 109 | |
| 110 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
| 110 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
| 111 | 111 | { |
| 112 | 112 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallConfigForm'); |
| 113 | 113 | header('location:'.$returnUrl); |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | function procConfigSetting() |
| 122 | 122 | { |
| 123 | 123 | // Get variables |
| 124 | - $config_info = Context::gets('use_rewrite','time_zone'); |
|
| 125 | - if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N'; |
|
| 124 | + $config_info = Context::gets('use_rewrite', 'time_zone'); |
|
| 125 | + if ($config_info->use_rewrite != 'Y') $config_info->use_rewrite = 'N'; |
|
| 126 | 126 | |
| 127 | 127 | // Create a db temp config file |
| 128 | - if(!$this->makeEtcConfigFile($config_info)) return new BaseObject(-1, 'msg_install_failed'); |
|
| 128 | + if (!$this->makeEtcConfigFile($config_info)) return new BaseObject(-1, 'msg_install_failed'); |
|
| 129 | 129 | |
| 130 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
| 130 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
| 131 | 131 | { |
| 132 | 132 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallManagerForm'); |
| 133 | 133 | header('location:'.$returnUrl); |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | function procInstall() |
| 142 | 142 | { |
| 143 | 143 | // Check if it is already installed |
| 144 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
| 144 | + if (Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
| 145 | 145 | |
| 146 | 146 | Context::loadLang('modules/member/lang'); |
| 147 | 147 | $oMemberModel = getModel('member'); |
| 148 | 148 | $vars = Context::getRequestVars(); |
| 149 | 149 | |
| 150 | - if(!$oMemberModel->checkPasswordStrength($vars->password, 'high')) |
|
| 150 | + if (!$oMemberModel->checkPasswordStrength($vars->password, 'high')) |
|
| 151 | 151 | { |
| 152 | 152 | Context::loadLang('modules/member/lang'); |
| 153 | 153 | $message = Context::getLang('about_password_strength'); |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | Context::set('logged_info', $logged_info); |
| 161 | 161 | |
| 162 | 162 | // check install config |
| 163 | - if(Context::get('install_config')) |
|
| 163 | + if (Context::get('install_config')) |
|
| 164 | 164 | { |
| 165 | 165 | $db_info = $this->_makeDbInfoByInstallConfig(); |
| 166 | 166 | } |
| 167 | 167 | // install by default XE UI |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | - if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
| 171 | - if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
| 170 | + if (FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
| 171 | + if (FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Set DB type and information |
@@ -176,30 +176,30 @@ discard block |
||
| 176 | 176 | // Create DB Instance |
| 177 | 177 | $oDB = &DB::getInstance(); |
| 178 | 178 | // Check if available to connect to the DB |
| 179 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
| 179 | + if (!$oDB->isConnected()) return $oDB->getError(); |
|
| 180 | 180 | |
| 181 | 181 | // Install all the modules |
| 182 | 182 | try { |
| 183 | 183 | $oDB->begin(); |
| 184 | 184 | $this->installDownloadedModule(); |
| 185 | 185 | $oDB->commit(); |
| 186 | - } catch(Exception $e) { |
|
| 186 | + } catch (Exception $e) { |
|
| 187 | 187 | $oDB->rollback(); |
| 188 | 188 | return new BaseObject(-1, $e->getMessage()); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // Create a config file |
| 192 | - if(!$this->makeConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
| 192 | + if (!$this->makeConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
| 193 | 193 | |
| 194 | 194 | // load script |
| 195 | - $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
|
| 196 | - if(count($scripts)>0) |
|
| 195 | + $scripts = FileHandler::readDir(_XE_PATH_.'modules/install/script', '/(\.php)$/'); |
|
| 196 | + if (count($scripts) > 0) |
|
| 197 | 197 | { |
| 198 | 198 | sort($scripts); |
| 199 | - foreach($scripts as $script) |
|
| 199 | + foreach ($scripts as $script) |
|
| 200 | 200 | { |
| 201 | 201 | $script_path = FileHandler::getRealPath('./modules/install/script/'); |
| 202 | - $output = include($script_path . $script); |
|
| 202 | + $output = include($script_path.$script); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | unset($_SESSION['use_rewrite']); |
| 214 | 214 | |
| 215 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
| 215 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
| 216 | 216 | { |
| 217 | 217 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl(''); |
| 218 | 218 | header('location:'.$returnUrl); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $db_info->use_rewrite = Context::get('use_rewrite'); |
| 243 | 243 | $db_info->time_zone = Context::get('time_zone'); |
| 244 | 244 | |
| 245 | - if($_SERVER['HTTPS'] == 'on') |
|
| 245 | + if ($_SERVER['HTTPS'] == 'on') |
|
| 246 | 246 | { |
| 247 | 247 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
| 248 | 248 | $https_port = (!$https_port != 443) ? $https_port : null; |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
| 253 | 253 | $http_port = (!$http_port != 80) ? $http_port : null; |
| 254 | 254 | } |
| 255 | - if($http_port) $db_info->http_port = $http_port; |
|
| 256 | - if($https_port) $db_info->https_port = $https_port; |
|
| 255 | + if ($http_port) $db_info->http_port = $http_port; |
|
| 256 | + if ($https_port) $db_info->https_port = $https_port; |
|
| 257 | 257 | |
| 258 | 258 | return $db_info; |
| 259 | 259 | } |
@@ -263,57 +263,57 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | function procInstallFTP() |
| 265 | 265 | { |
| 266 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
| 267 | - $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
|
| 268 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
| 269 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 270 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 271 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 266 | + if (Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
| 267 | + $ftp_info = Context::gets('ftp_host', 'ftp_user', 'ftp_password', 'ftp_port', 'ftp_root_path'); |
|
| 268 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
| 269 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 270 | + if (!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 271 | + if (!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 272 | 272 | |
| 273 | 273 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
| 274 | 274 | $buff[] = "\$ftp_info = new stdClass();"; |
| 275 | - foreach($ftp_info as $key => $val) |
|
| 275 | + foreach ($ftp_info as $key => $val) |
|
| 276 | 276 | { |
| 277 | - $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'","\\'",$val)); |
|
| 277 | + $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'", "\\'", $val)); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // If safe_mode |
| 281 | - if(ini_get('safe_mode')) |
|
| 281 | + if (ini_get('safe_mode')) |
|
| 282 | 282 | { |
| 283 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
| 283 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1, 'msg_safe_mode_ftp_needed'); |
|
| 284 | 284 | |
| 285 | 285 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 286 | 286 | $oFtp = new ftp(); |
| 287 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 287 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 288 | 288 | |
| 289 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 289 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 290 | 290 | { |
| 291 | 291 | $oFtp->ftp_quit(); |
| 292 | - return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
|
| 292 | + return new BaseObject(-1, 'msg_ftp_invalid_auth_info'); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - if(!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
| 295 | + if (!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
| 296 | 296 | { |
| 297 | 297 | $oFtp->ftp_quit(); |
| 298 | - return new BaseObject(-1,'msg_ftp_mkdir_fail'); |
|
| 298 | + return new BaseObject(-1, 'msg_ftp_mkdir_fail'); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
| 301 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
| 302 | 302 | { |
| 303 | 303 | $oFtp->ftp_quit(); |
| 304 | - return new BaseObject(-1,'msg_ftp_chmod_fail'); |
|
| 304 | + return new BaseObject(-1, 'msg_ftp_chmod_fail'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if(!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
| 307 | + if (!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
| 308 | 308 | { |
| 309 | 309 | $oFtp->ftp_quit(); |
| 310 | - return new BaseObject(-1,'msg_ftp_mkdir_fail'); |
|
| 310 | + return new BaseObject(-1, 'msg_ftp_mkdir_fail'); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
| 313 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
| 314 | 314 | { |
| 315 | 315 | $oFtp->ftp_quit(); |
| 316 | - return new BaseObject(-1,'msg_ftp_chmod_fail'); |
|
| 316 | + return new BaseObject(-1, 'msg_ftp_chmod_fail'); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | $oFtp->ftp_quit(); |
@@ -324,31 +324,31 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | function procInstallCheckFtp() |
| 326 | 326 | { |
| 327 | - $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
|
| 328 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
| 329 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 330 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 327 | + $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port', 'sftp'); |
|
| 328 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
| 329 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 330 | + if (!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 331 | 331 | |
| 332 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
| 332 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1, 'msg_safe_mode_ftp_needed'); |
|
| 333 | 333 | |
| 334 | - if($ftp_info->sftp == 'Y') |
|
| 334 | + if ($ftp_info->sftp == 'Y') |
|
| 335 | 335 | { |
| 336 | 336 | $connection = ssh2_connect('localhost', $ftp_info->ftp_port); |
| 337 | - if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 337 | + if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 338 | 338 | { |
| 339 | - return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
|
| 339 | + return new BaseObject(-1, 'msg_ftp_invalid_auth_info'); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | else |
| 343 | 343 | { |
| 344 | 344 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 345 | 345 | $oFtp = new ftp(); |
| 346 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 346 | + if (!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 347 | 347 | |
| 348 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 348 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 349 | 349 | { |
| 350 | 350 | $oFtp->ftp_quit(); |
| 351 | - return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
|
| 351 | + return new BaseObject(-1, 'msg_ftp_invalid_auth_info'); |
|
| 352 | 352 | } |
| 353 | 353 | $oFtp->ftp_quit(); |
| 354 | 354 | } |
@@ -365,36 +365,36 @@ discard block |
||
| 365 | 365 | $checklist = array(); |
| 366 | 366 | // 0. check your version of php (5.2.4 or higher) |
| 367 | 367 | $checklist['php_version'] = true; |
| 368 | - if(version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
| 368 | + if (version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
| 369 | 369 | { |
| 370 | 370 | $checklist['php_version'] = false; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if(version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
| 373 | + if (version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
| 374 | 374 | { |
| 375 | 375 | Context::set('phpversion_warning', true); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // 1. Check permission |
| 379 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
| 379 | + if (is_writable('./') || is_writable('./files')) $checklist['permission'] = true; |
|
| 380 | 380 | else $checklist['permission'] = false; |
| 381 | 381 | // 2. Check if xml_parser_create exists |
| 382 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 382 | + if (function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 383 | 383 | else $checklist['xml'] = false; |
| 384 | 384 | // 3. Check if ini_get (session.auto_start) == 1 |
| 385 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
| 385 | + if (ini_get('session.auto_start') != 1) $checklist['session'] = true; |
|
| 386 | 386 | else $checklist['session'] = false; |
| 387 | 387 | // 4. Check if iconv exists |
| 388 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
| 388 | + if (function_exists('iconv')) $checklist['iconv'] = true; |
|
| 389 | 389 | else $checklist['iconv'] = false; |
| 390 | 390 | // 5. Check gd(imagecreatefromgif function) |
| 391 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 391 | + if (function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 392 | 392 | else $checklist['gd'] = false; |
| 393 | 393 | // 6. Check DB |
| 394 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
| 394 | + if (DB::getEnableList()) $checklist['db'] = true; |
|
| 395 | 395 | else $checklist['db'] = false; |
| 396 | 396 | |
| 397 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 397 | + if (!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 398 | 398 | else $install_enable = true; |
| 399 | 399 | |
| 400 | 400 | // Save the checked result to the Context |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | $license_agreement = ($vars->license_agreement == 'Y') ? true : false; |
| 416 | 416 | |
| 417 | - if($license_agreement) |
|
| 417 | + if ($license_agreement) |
|
| 418 | 418 | { |
| 419 | 419 | $currentTime = $_SERVER['REQUEST_TIME']; |
| 420 | 420 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | return new BaseObject(-1, 'msg_must_accept_license_agreement'); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
| 428 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
| 429 | 429 | { |
| 430 | 430 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallCheckEnv'); |
| 431 | 431 | $this->setRedirectUrl($returnUrl); |
@@ -448,25 +448,25 @@ discard block |
||
| 448 | 448 | $hostname = $_SERVER['SERVER_NAME']; |
| 449 | 449 | $port = $_SERVER['SERVER_PORT']; |
| 450 | 450 | $str_port = ''; |
| 451 | - if($port) |
|
| 451 | + if ($port) |
|
| 452 | 452 | { |
| 453 | - $str_port = ':' . $port; |
|
| 453 | + $str_port = ':'.$port; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | $tmpPath = $_SERVER['DOCUMENT_ROOT']; |
| 457 | 457 | |
| 458 | 458 | //if DIRECTORY_SEPARATOR is not /(IIS) |
| 459 | - if(DIRECTORY_SEPARATOR !== '/') |
|
| 459 | + if (DIRECTORY_SEPARATOR !== '/') |
|
| 460 | 460 | { |
| 461 | 461 | //change to slash for compare |
| 462 | 462 | $tmpPath = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']); |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - $query = "/JUST/CHECK/REWRITE/" . $checkFilePath; |
|
| 465 | + $query = "/JUST/CHECK/REWRITE/".$checkFilePath; |
|
| 466 | 466 | $currentPath = str_replace($tmpPath, "", _XE_PATH_); |
| 467 | - if($currentPath != "") |
|
| 467 | + if ($currentPath != "") |
|
| 468 | 468 | { |
| 469 | - $query = $currentPath . $query; |
|
| 469 | + $query = $currentPath.$query; |
|
| 470 | 470 | } |
| 471 | 471 | $requestUrl = sprintf('%s://%s%s%s', $scheme, $hostname, $str_port, $query); |
| 472 | 472 | $requestConfig = array(); |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | './files/cache/template_compiled', |
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | - foreach($directory_list as $dir) |
|
| 494 | + foreach ($directory_list as $dir) |
|
| 495 | 495 | { |
| 496 | 496 | FileHandler::makeDir($dir); |
| 497 | 497 | } |
@@ -507,57 +507,57 @@ discard block |
||
| 507 | 507 | $oModuleModel = getModel('module'); |
| 508 | 508 | // Create a table ny finding schemas/*.xml file in each module |
| 509 | 509 | $module_list = FileHandler::readDir('./modules/', NULL, false, true); |
| 510 | - foreach($module_list as $module_path) |
|
| 510 | + foreach ($module_list as $module_path) |
|
| 511 | 511 | { |
| 512 | 512 | // Get module name |
| 513 | - $tmp_arr = explode('/',$module_path); |
|
| 514 | - $module = $tmp_arr[count($tmp_arr)-1]; |
|
| 513 | + $tmp_arr = explode('/', $module_path); |
|
| 514 | + $module = $tmp_arr[count($tmp_arr) - 1]; |
|
| 515 | 515 | |
| 516 | 516 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
| 517 | - if(!$xml_info) continue; |
|
| 517 | + if (!$xml_info) continue; |
|
| 518 | 518 | $modules[$xml_info->category][] = $module; |
| 519 | 519 | } |
| 520 | 520 | // Install "module" module in advance |
| 521 | - $this->installModule('module','./modules/module'); |
|
| 521 | + $this->installModule('module', './modules/module'); |
|
| 522 | 522 | $oModule = getClass('module'); |
| 523 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 523 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 524 | 524 | // Determine the order of module installation depending on category |
| 525 | - $install_step = array('system','content','member'); |
|
| 525 | + $install_step = array('system', 'content', 'member'); |
|
| 526 | 526 | // Install all the remaining modules |
| 527 | - foreach($install_step as $category) |
|
| 527 | + foreach ($install_step as $category) |
|
| 528 | 528 | { |
| 529 | - if(count($modules[$category])) |
|
| 529 | + if (count($modules[$category])) |
|
| 530 | 530 | { |
| 531 | - foreach($modules[$category] as $module) |
|
| 531 | + foreach ($modules[$category] as $module) |
|
| 532 | 532 | { |
| 533 | - if($module == 'module') continue; |
|
| 533 | + if ($module == 'module') continue; |
|
| 534 | 534 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 535 | 535 | |
| 536 | 536 | $oModule = getClass($module); |
| 537 | - if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
| 537 | + if (is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
| 538 | 538 | { |
| 539 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 539 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | unset($modules[$category]); |
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | // Install all the remaining modules |
| 546 | - if(count($modules)) |
|
| 546 | + if (count($modules)) |
|
| 547 | 547 | { |
| 548 | - foreach($modules as $category => $module_list) |
|
| 548 | + foreach ($modules as $category => $module_list) |
|
| 549 | 549 | { |
| 550 | - if(count($module_list)) |
|
| 550 | + if (count($module_list)) |
|
| 551 | 551 | { |
| 552 | - foreach($module_list as $module) |
|
| 552 | + foreach ($module_list as $module) |
|
| 553 | 553 | { |
| 554 | - if($module == 'module') continue; |
|
| 554 | + if ($module == 'module') continue; |
|
| 555 | 555 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 556 | 556 | |
| 557 | 557 | $oModule = getClass($module); |
| 558 | - if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
| 558 | + if ($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
| 559 | 559 | { |
| 560 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 560 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | } |
@@ -579,31 +579,31 @@ discard block |
||
| 579 | 579 | $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); |
| 580 | 580 | |
| 581 | 581 | $file_cnt = count($schema_files); |
| 582 | - for($i=0;$i<$file_cnt;$i++) |
|
| 582 | + for ($i = 0; $i < $file_cnt; $i++) |
|
| 583 | 583 | { |
| 584 | 584 | $file = trim($schema_files[$i]); |
| 585 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
| 585 | + if (!$file || substr($file, -4) != '.xml') continue; |
|
| 586 | 586 | $output = $oDB->createTableByXmlFile($file); |
| 587 | - if($output === false) |
|
| 587 | + if ($output === false) |
|
| 588 | 588 | throw new Exception('msg_create_table_failed'); |
| 589 | 589 | } |
| 590 | 590 | // Create a table and module instance and then execute install() method |
| 591 | 591 | unset($oModule); |
| 592 | 592 | $oModule = getClass($module); |
| 593 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 593 | + if (method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 594 | 594 | return new BaseObject(); |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | function _getDBConfigFileContents($db_info) |
| 598 | 598 | { |
| 599 | - if(substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
| 599 | + if (substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
| 600 | 600 | { |
| 601 | 601 | $db_info->master_db['db_table_prefix'] .= '_'; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - foreach($db_info->slave_db as &$slave) |
|
| 604 | + foreach ($db_info->slave_db as &$slave) |
|
| 605 | 605 | { |
| 606 | - if(substr($slave['db_table_prefix'], -1) != '_') |
|
| 606 | + if (substr($slave['db_table_prefix'], -1) != '_') |
|
| 607 | 607 | { |
| 608 | 608 | $slave['db_table_prefix'] .= '_'; |
| 609 | 609 | } |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | |
| 612 | 612 | $buff = array(); |
| 613 | 613 | $buff[] = '<?php if(!defined("__XE__")) exit();'; |
| 614 | - $buff[] = '$db_info = (object)' . var_export(get_object_vars($db_info), TRUE) . ';'; |
|
| 614 | + $buff[] = '$db_info = (object)'.var_export(get_object_vars($db_info), TRUE).';'; |
|
| 615 | 615 | |
| 616 | 616 | return implode(PHP_EOL, $buff); |
| 617 | 617 | } |
@@ -625,13 +625,13 @@ discard block |
||
| 625 | 625 | $db_tmp_config_file = $this->db_tmp_config_file; |
| 626 | 626 | |
| 627 | 627 | $db_info = Context::getDBInfo(); |
| 628 | - if(!$db_info) return; |
|
| 628 | + if (!$db_info) return; |
|
| 629 | 629 | |
| 630 | 630 | $buff = $this->_getDBConfigFileContents($db_info); |
| 631 | 631 | |
| 632 | 632 | FileHandler::writeFile($db_tmp_config_file, $buff); |
| 633 | 633 | |
| 634 | - if(@file_exists($db_tmp_config_file)) return true; |
|
| 634 | + if (@file_exists($db_tmp_config_file)) return true; |
|
| 635 | 635 | return false; |
| 636 | 636 | } |
| 637 | 637 | |
@@ -644,14 +644,14 @@ discard block |
||
| 644 | 644 | $etc_tmp_config_file = $this->etc_tmp_config_file; |
| 645 | 645 | |
| 646 | 646 | $buff = '<?php if(!defined("__XE__")) exit();'."\n"; |
| 647 | - foreach($config_info as $key => $val) |
|
| 647 | + foreach ($config_info as $key => $val) |
|
| 648 | 648 | { |
| 649 | - $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'","\\'",$val)); |
|
| 649 | + $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val)); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
| 653 | 653 | |
| 654 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
| 654 | + if (@file_exists($etc_tmp_config_file)) return true; |
|
| 655 | 655 | return false; |
| 656 | 656 | } |
| 657 | 657 | |
@@ -666,13 +666,13 @@ discard block |
||
| 666 | 666 | //if(file_exists($config_file)) return; |
| 667 | 667 | |
| 668 | 668 | $db_info = Context::getDBInfo(); |
| 669 | - if(!$db_info) return; |
|
| 669 | + if (!$db_info) return; |
|
| 670 | 670 | |
| 671 | 671 | $buff = $this->_getDBConfigFileContents($db_info); |
| 672 | 672 | |
| 673 | 673 | FileHandler::writeFile($config_file, $buff); |
| 674 | 674 | |
| 675 | - if(@file_exists($config_file)) |
|
| 675 | + if (@file_exists($config_file)) |
|
| 676 | 676 | { |
| 677 | 677 | FileHandler::removeFile($this->db_tmp_config_file); |
| 678 | 678 | FileHandler::removeFile($this->etc_tmp_config_file); |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | function installByConfig($install_config_file) |
| 688 | 688 | { |
| 689 | 689 | include $install_config_file; |
| 690 | - if(!is_array($auto_config)) return false; |
|
| 690 | + if (!is_array($auto_config)) return false; |
|
| 691 | 691 | |
| 692 | 692 | $auto_config['module'] = 'install'; |
| 693 | 693 | $auto_config['act'] = 'procInstall'; |
@@ -695,22 +695,22 @@ discard block |
||
| 695 | 695 | $fstr = "<%s><![CDATA[%s]]></%s>\r\n"; |
| 696 | 696 | $fheader = "POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/xml\r\nContent-Length: %s\r\n\r\n%s\r\n"; |
| 697 | 697 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
| 698 | - foreach($auto_config as $k => $v) |
|
| 698 | + foreach ($auto_config as $k => $v) |
|
| 699 | 699 | { |
| 700 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
| 700 | + if (!in_array($k, array('host', 'port', 'path'))) $body .= sprintf($fstr, $k, $v, $k); |
|
| 701 | 701 | } |
| 702 | 702 | $body .= "</params>\r\n</methodCall>"; |
| 703 | 703 | |
| 704 | - $header = sprintf($fheader,$auto_config['path'],$auto_config['host'],strlen($body),$body); |
|
| 704 | + $header = sprintf($fheader, $auto_config['path'], $auto_config['host'], strlen($body), $body); |
|
| 705 | 705 | $fp = @fsockopen($auto_config['host'], $auto_config['port'], $errno, $errstr, 5); |
| 706 | 706 | |
| 707 | - if($fp) |
|
| 707 | + if ($fp) |
|
| 708 | 708 | { |
| 709 | 709 | fputs($fp, $header); |
| 710 | - while(!feof($fp)) |
|
| 710 | + while (!feof($fp)) |
|
| 711 | 711 | { |
| 712 | 712 | $line = trim(fgets($fp, 4096)); |
| 713 | - if(strncmp('<error>', $line, 7) === 0) |
|
| 713 | + if (strncmp('<error>', $line, 7) === 0) |
|
| 714 | 714 | { |
| 715 | 715 | fclose($fp); |
| 716 | 716 | return false; |
@@ -101,11 +101,17 @@ discard block |
||
| 101 | 101 | // Check if available to connect to the DB |
| 102 | 102 | $oDB = &DB::getInstance(); |
| 103 | 103 | $output = $oDB->getError(); |
| 104 | - if(!$output->toBool()) return $output; |
|
| 105 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
| 104 | + if(!$output->toBool()) { |
|
| 105 | + return $output; |
|
| 106 | + } |
|
| 107 | + if(!$oDB->isConnected()) { |
|
| 108 | + return $oDB->getError(); |
|
| 109 | + } |
|
| 106 | 110 | |
| 107 | 111 | // Create a db temp config file |
| 108 | - if(!$this->makeDBConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
| 112 | + if(!$this->makeDBConfigFile()) { |
|
| 113 | + return new BaseObject(-1, 'msg_install_failed'); |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
| 111 | 117 | { |
@@ -122,10 +128,14 @@ discard block |
||
| 122 | 128 | { |
| 123 | 129 | // Get variables |
| 124 | 130 | $config_info = Context::gets('use_rewrite','time_zone'); |
| 125 | - if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N'; |
|
| 131 | + if($config_info->use_rewrite!='Y') { |
|
| 132 | + $config_info->use_rewrite = 'N'; |
|
| 133 | + } |
|
| 126 | 134 | |
| 127 | 135 | // Create a db temp config file |
| 128 | - if(!$this->makeEtcConfigFile($config_info)) return new BaseObject(-1, 'msg_install_failed'); |
|
| 136 | + if(!$this->makeEtcConfigFile($config_info)) { |
|
| 137 | + return new BaseObject(-1, 'msg_install_failed'); |
|
| 138 | + } |
|
| 129 | 139 | |
| 130 | 140 | if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
| 131 | 141 | { |
@@ -141,7 +151,9 @@ discard block |
||
| 141 | 151 | function procInstall() |
| 142 | 152 | { |
| 143 | 153 | // Check if it is already installed |
| 144 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
| 154 | + if(Context::isInstalled()) { |
|
| 155 | + return new BaseObject(-1, 'msg_already_installed'); |
|
| 156 | + } |
|
| 145 | 157 | |
| 146 | 158 | Context::loadLang('modules/member/lang'); |
| 147 | 159 | $oMemberModel = getModel('member'); |
@@ -167,8 +179,12 @@ discard block |
||
| 167 | 179 | // install by default XE UI |
| 168 | 180 | else |
| 169 | 181 | { |
| 170 | - if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
| 171 | - if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
| 182 | + if(FileHandler::exists($this->db_tmp_config_file)) { |
|
| 183 | + include $this->db_tmp_config_file; |
|
| 184 | + } |
|
| 185 | + if(FileHandler::exists($this->etc_tmp_config_file)) { |
|
| 186 | + include $this->etc_tmp_config_file; |
|
| 187 | + } |
|
| 172 | 188 | } |
| 173 | 189 | |
| 174 | 190 | // Set DB type and information |
@@ -176,7 +192,9 @@ discard block |
||
| 176 | 192 | // Create DB Instance |
| 177 | 193 | $oDB = &DB::getInstance(); |
| 178 | 194 | // Check if available to connect to the DB |
| 179 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
| 195 | + if(!$oDB->isConnected()) { |
|
| 196 | + return $oDB->getError(); |
|
| 197 | + } |
|
| 180 | 198 | |
| 181 | 199 | // Install all the modules |
| 182 | 200 | try { |
@@ -189,7 +207,9 @@ discard block |
||
| 189 | 207 | } |
| 190 | 208 | |
| 191 | 209 | // Create a config file |
| 192 | - if(!$this->makeConfigFile()) return new BaseObject(-1, 'msg_install_failed'); |
|
| 210 | + if(!$this->makeConfigFile()) { |
|
| 211 | + return new BaseObject(-1, 'msg_install_failed'); |
|
| 212 | + } |
|
| 193 | 213 | |
| 194 | 214 | // load script |
| 195 | 215 | $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
@@ -246,14 +266,17 @@ discard block |
||
| 246 | 266 | { |
| 247 | 267 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
| 248 | 268 | $https_port = (!$https_port != 443) ? $https_port : null; |
| 249 | - } |
|
| 250 | - else |
|
| 269 | + } else |
|
| 251 | 270 | { |
| 252 | 271 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
| 253 | 272 | $http_port = (!$http_port != 80) ? $http_port : null; |
| 254 | 273 | } |
| 255 | - if($http_port) $db_info->http_port = $http_port; |
|
| 256 | - if($https_port) $db_info->https_port = $https_port; |
|
| 274 | + if($http_port) { |
|
| 275 | + $db_info->http_port = $http_port; |
|
| 276 | + } |
|
| 277 | + if($https_port) { |
|
| 278 | + $db_info->https_port = $https_port; |
|
| 279 | + } |
|
| 257 | 280 | |
| 258 | 281 | return $db_info; |
| 259 | 282 | } |
@@ -263,12 +286,20 @@ discard block |
||
| 263 | 286 | */ |
| 264 | 287 | function procInstallFTP() |
| 265 | 288 | { |
| 266 | - if(Context::isInstalled()) return new BaseObject(-1, 'msg_already_installed'); |
|
| 289 | + if(Context::isInstalled()) { |
|
| 290 | + return new BaseObject(-1, 'msg_already_installed'); |
|
| 291 | + } |
|
| 267 | 292 | $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
| 268 | 293 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
| 269 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 270 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 271 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 294 | + if(!$ftp_info->ftp_port) { |
|
| 295 | + $ftp_info->ftp_port = 21; |
|
| 296 | + } |
|
| 297 | + if(!$ftp_info->ftp_host) { |
|
| 298 | + $ftp_info->ftp_host = '127.0.0.1'; |
|
| 299 | + } |
|
| 300 | + if(!$ftp_info->ftp_root_path) { |
|
| 301 | + $ftp_info->ftp_root_path = '/'; |
|
| 302 | + } |
|
| 272 | 303 | |
| 273 | 304 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
| 274 | 305 | $buff[] = "\$ftp_info = new stdClass();"; |
@@ -280,11 +311,15 @@ discard block |
||
| 280 | 311 | // If safe_mode |
| 281 | 312 | if(ini_get('safe_mode')) |
| 282 | 313 | { |
| 283 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
| 314 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
| 315 | + return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
| 316 | + } |
|
| 284 | 317 | |
| 285 | 318 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 286 | 319 | $oFtp = new ftp(); |
| 287 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 320 | + if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { |
|
| 321 | + return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 322 | + } |
|
| 288 | 323 | |
| 289 | 324 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
| 290 | 325 | { |
@@ -326,10 +361,16 @@ discard block |
||
| 326 | 361 | { |
| 327 | 362 | $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
| 328 | 363 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
| 329 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 330 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 364 | + if(!$ftp_info->ftp_port) { |
|
| 365 | + $ftp_info->ftp_port = 21; |
|
| 366 | + } |
|
| 367 | + if(!$ftp_info->sftp) { |
|
| 368 | + $ftp_info->sftp = 'N'; |
|
| 369 | + } |
|
| 331 | 370 | |
| 332 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
| 371 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
| 372 | + return new BaseObject(-1,'msg_safe_mode_ftp_needed'); |
|
| 373 | + } |
|
| 333 | 374 | |
| 334 | 375 | if($ftp_info->sftp == 'Y') |
| 335 | 376 | { |
@@ -338,12 +379,13 @@ discard block |
||
| 338 | 379 | { |
| 339 | 380 | return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
| 340 | 381 | } |
| 341 | - } |
|
| 342 | - else |
|
| 382 | + } else |
|
| 343 | 383 | { |
| 344 | 384 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 345 | 385 | $oFtp = new ftp(); |
| 346 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 386 | + if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) { |
|
| 387 | + return new BaseObject(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 388 | + } |
|
| 347 | 389 | |
| 348 | 390 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
| 349 | 391 | { |
@@ -376,26 +418,47 @@ discard block |
||
| 376 | 418 | } |
| 377 | 419 | |
| 378 | 420 | // 1. Check permission |
| 379 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
| 380 | - else $checklist['permission'] = false; |
|
| 421 | + if(is_writable('./')||is_writable('./files')) { |
|
| 422 | + $checklist['permission'] = true; |
|
| 423 | + } else { |
|
| 424 | + $checklist['permission'] = false; |
|
| 425 | + } |
|
| 381 | 426 | // 2. Check if xml_parser_create exists |
| 382 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 383 | - else $checklist['xml'] = false; |
|
| 427 | + if(function_exists('xml_parser_create')) { |
|
| 428 | + $checklist['xml'] = true; |
|
| 429 | + } else { |
|
| 430 | + $checklist['xml'] = false; |
|
| 431 | + } |
|
| 384 | 432 | // 3. Check if ini_get (session.auto_start) == 1 |
| 385 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
| 386 | - else $checklist['session'] = false; |
|
| 433 | + if(ini_get('session.auto_start')!=1) { |
|
| 434 | + $checklist['session'] = true; |
|
| 435 | + } else { |
|
| 436 | + $checklist['session'] = false; |
|
| 437 | + } |
|
| 387 | 438 | // 4. Check if iconv exists |
| 388 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
| 389 | - else $checklist['iconv'] = false; |
|
| 439 | + if(function_exists('iconv')) { |
|
| 440 | + $checklist['iconv'] = true; |
|
| 441 | + } else { |
|
| 442 | + $checklist['iconv'] = false; |
|
| 443 | + } |
|
| 390 | 444 | // 5. Check gd(imagecreatefromgif function) |
| 391 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 392 | - else $checklist['gd'] = false; |
|
| 445 | + if(function_exists('imagecreatefromgif')) { |
|
| 446 | + $checklist['gd'] = true; |
|
| 447 | + } else { |
|
| 448 | + $checklist['gd'] = false; |
|
| 449 | + } |
|
| 393 | 450 | // 6. Check DB |
| 394 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
| 395 | - else $checklist['db'] = false; |
|
| 451 | + if(DB::getEnableList()) { |
|
| 452 | + $checklist['db'] = true; |
|
| 453 | + } else { |
|
| 454 | + $checklist['db'] = false; |
|
| 455 | + } |
|
| 396 | 456 | |
| 397 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 398 | - else $install_enable = true; |
|
| 457 | + if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) { |
|
| 458 | + $install_enable = false; |
|
| 459 | + } else { |
|
| 460 | + $install_enable = true; |
|
| 461 | + } |
|
| 399 | 462 | |
| 400 | 463 | // Save the checked result to the Context |
| 401 | 464 | Context::set('checklist', $checklist); |
@@ -418,8 +481,7 @@ discard block |
||
| 418 | 481 | { |
| 419 | 482 | $currentTime = $_SERVER['REQUEST_TIME']; |
| 420 | 483 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
| 421 | - } |
|
| 422 | - else |
|
| 484 | + } else |
|
| 423 | 485 | { |
| 424 | 486 | FileHandler::removeFile($this->flagLicenseAgreement); |
| 425 | 487 | return new BaseObject(-1, 'msg_must_accept_license_agreement'); |
@@ -514,13 +576,17 @@ discard block |
||
| 514 | 576 | $module = $tmp_arr[count($tmp_arr)-1]; |
| 515 | 577 | |
| 516 | 578 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
| 517 | - if(!$xml_info) continue; |
|
| 579 | + if(!$xml_info) { |
|
| 580 | + continue; |
|
| 581 | + } |
|
| 518 | 582 | $modules[$xml_info->category][] = $module; |
| 519 | 583 | } |
| 520 | 584 | // Install "module" module in advance |
| 521 | 585 | $this->installModule('module','./modules/module'); |
| 522 | 586 | $oModule = getClass('module'); |
| 523 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 587 | + if($oModule->checkUpdate()) { |
|
| 588 | + $oModule->moduleUpdate(); |
|
| 589 | + } |
|
| 524 | 590 | // Determine the order of module installation depending on category |
| 525 | 591 | $install_step = array('system','content','member'); |
| 526 | 592 | // Install all the remaining modules |
@@ -530,13 +596,17 @@ discard block |
||
| 530 | 596 | { |
| 531 | 597 | foreach($modules[$category] as $module) |
| 532 | 598 | { |
| 533 | - if($module == 'module') continue; |
|
| 599 | + if($module == 'module') { |
|
| 600 | + continue; |
|
| 601 | + } |
|
| 534 | 602 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 535 | 603 | |
| 536 | 604 | $oModule = getClass($module); |
| 537 | 605 | if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
| 538 | 606 | { |
| 539 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 607 | + if($oModule->checkUpdate()) { |
|
| 608 | + $oModule->moduleUpdate(); |
|
| 609 | + } |
|
| 540 | 610 | } |
| 541 | 611 | } |
| 542 | 612 | unset($modules[$category]); |
@@ -551,13 +621,17 @@ discard block |
||
| 551 | 621 | { |
| 552 | 622 | foreach($module_list as $module) |
| 553 | 623 | { |
| 554 | - if($module == 'module') continue; |
|
| 624 | + if($module == 'module') { |
|
| 625 | + continue; |
|
| 626 | + } |
|
| 555 | 627 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 556 | 628 | |
| 557 | 629 | $oModule = getClass($module); |
| 558 | 630 | if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
| 559 | 631 | { |
| 560 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 632 | + if($oModule->checkUpdate()) { |
|
| 633 | + $oModule->moduleUpdate(); |
|
| 634 | + } |
|
| 561 | 635 | } |
| 562 | 636 | } |
| 563 | 637 | } |
@@ -582,15 +656,20 @@ discard block |
||
| 582 | 656 | for($i=0;$i<$file_cnt;$i++) |
| 583 | 657 | { |
| 584 | 658 | $file = trim($schema_files[$i]); |
| 585 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
| 659 | + if(!$file || substr($file,-4)!='.xml') { |
|
| 660 | + continue; |
|
| 661 | + } |
|
| 586 | 662 | $output = $oDB->createTableByXmlFile($file); |
| 587 | - if($output === false) |
|
| 588 | - throw new Exception('msg_create_table_failed'); |
|
| 663 | + if($output === false) { |
|
| 664 | + throw new Exception('msg_create_table_failed'); |
|
| 665 | + } |
|
| 589 | 666 | } |
| 590 | 667 | // Create a table and module instance and then execute install() method |
| 591 | 668 | unset($oModule); |
| 592 | 669 | $oModule = getClass($module); |
| 593 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 670 | + if(method_exists($oModule, 'moduleInstall')) { |
|
| 671 | + $oModule->moduleInstall(); |
|
| 672 | + } |
|
| 594 | 673 | return new BaseObject(); |
| 595 | 674 | } |
| 596 | 675 | |
@@ -625,13 +704,17 @@ discard block |
||
| 625 | 704 | $db_tmp_config_file = $this->db_tmp_config_file; |
| 626 | 705 | |
| 627 | 706 | $db_info = Context::getDBInfo(); |
| 628 | - if(!$db_info) return; |
|
| 707 | + if(!$db_info) { |
|
| 708 | + return; |
|
| 709 | + } |
|
| 629 | 710 | |
| 630 | 711 | $buff = $this->_getDBConfigFileContents($db_info); |
| 631 | 712 | |
| 632 | 713 | FileHandler::writeFile($db_tmp_config_file, $buff); |
| 633 | 714 | |
| 634 | - if(@file_exists($db_tmp_config_file)) return true; |
|
| 715 | + if(@file_exists($db_tmp_config_file)) { |
|
| 716 | + return true; |
|
| 717 | + } |
|
| 635 | 718 | return false; |
| 636 | 719 | } |
| 637 | 720 | |
@@ -651,7 +734,9 @@ discard block |
||
| 651 | 734 | |
| 652 | 735 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
| 653 | 736 | |
| 654 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
| 737 | + if(@file_exists($etc_tmp_config_file)) { |
|
| 738 | + return true; |
|
| 739 | + } |
|
| 655 | 740 | return false; |
| 656 | 741 | } |
| 657 | 742 | |
@@ -666,7 +751,9 @@ discard block |
||
| 666 | 751 | //if(file_exists($config_file)) return; |
| 667 | 752 | |
| 668 | 753 | $db_info = Context::getDBInfo(); |
| 669 | - if(!$db_info) return; |
|
| 754 | + if(!$db_info) { |
|
| 755 | + return; |
|
| 756 | + } |
|
| 670 | 757 | |
| 671 | 758 | $buff = $this->_getDBConfigFileContents($db_info); |
| 672 | 759 | |
@@ -687,7 +774,9 @@ discard block |
||
| 687 | 774 | function installByConfig($install_config_file) |
| 688 | 775 | { |
| 689 | 776 | include $install_config_file; |
| 690 | - if(!is_array($auto_config)) return false; |
|
| 777 | + if(!is_array($auto_config)) { |
|
| 778 | + return false; |
|
| 779 | + } |
|
| 691 | 780 | |
| 692 | 781 | $auto_config['module'] = 'install'; |
| 693 | 782 | $auto_config['act'] = 'procInstall'; |
@@ -697,7 +786,9 @@ discard block |
||
| 697 | 786 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
| 698 | 787 | foreach($auto_config as $k => $v) |
| 699 | 788 | { |
| 700 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
| 789 | + if(!in_array($k,array('host','port','path'))) { |
|
| 790 | + $body .= sprintf($fstr,$k,$v,$k); |
|
| 791 | + } |
|
| 701 | 792 | } |
| 702 | 793 | $body .= "</params>\r\n</methodCall>"; |
| 703 | 794 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * get layout setting view. |
| 19 | - * @return void |
|
| 19 | + * @return string|null |
|
| 20 | 20 | */ |
| 21 | 21 | public function getLayoutAdminSetInfoView() |
| 22 | 22 | { |
@@ -115,14 +115,17 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $layout_file = $oLayoutModel->getDefaultLayoutHtml($layout_info->layout); |
| 117 | 117 | $layout_css_file = $oLayoutModel->getDefaultLayoutCss($layout_info->layout); |
| 118 | - } |
|
| 119 | - else |
|
| 118 | + } else |
|
| 120 | 119 | { |
| 121 | 120 | $layout_file = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); |
| 122 | 121 | $layout_css_file = $oLayoutModel->getUserLayoutCss($layout_info->layout_srl); |
| 123 | 122 | |
| 124 | - if(!file_exists($layout_file)) $layout_file = $layout_info->path . 'layout.html'; |
|
| 125 | - if(!file_exists($layout_css_file)) $layout_css_file = $layout_info->path . 'layout.css'; |
|
| 123 | + if(!file_exists($layout_file)) { |
|
| 124 | + $layout_file = $layout_info->path . 'layout.html'; |
|
| 125 | + } |
|
| 126 | + if(!file_exists($layout_css_file)) { |
|
| 127 | + $layout_css_file = $layout_info->path . 'layout.css'; |
|
| 128 | + } |
|
| 126 | 129 | } |
| 127 | 130 | |
| 128 | 131 | if(file_exists($layout_css_file)) |
@@ -182,7 +185,9 @@ discard block |
||
| 182 | 185 | { |
| 183 | 186 | $target = ($viewType == 'M') ? 'mlayout_srl' : 'layout_srl'; |
| 184 | 187 | $designInfoFile = sprintf(_XE_PATH_ . 'files/site_design/design_%s.php', $siteSrl); |
| 185 | - if(FileHandler::exists($designInfoFile)) include($designInfoFile); |
|
| 188 | + if(FileHandler::exists($designInfoFile)) { |
|
| 189 | + include($designInfoFile); |
|
| 190 | + } |
|
| 186 | 191 | |
| 187 | 192 | if(!$designInfo || !$designInfo->{$target}) |
| 188 | 193 | { |
@@ -30,27 +30,27 @@ discard block |
||
| 30 | 30 | preg_match_all('/<!--#JSPLUGIN:(.*)-->/', $html, $m); |
| 31 | 31 | $pluginList = $m[1]; |
| 32 | 32 | |
| 33 | - foreach($pluginList as $plugin) |
|
| 33 | + foreach ($pluginList as $plugin) |
|
| 34 | 34 | { |
| 35 | 35 | $info = Context::getJavascriptPluginInfo($plugin); |
| 36 | - if(!$info) |
|
| 36 | + if (!$info) |
|
| 37 | 37 | { |
| 38 | 38 | continue; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - foreach($info->jsList as $js) |
|
| 41 | + foreach ($info->jsList as $js) |
|
| 42 | 42 | { |
| 43 | 43 | $script .= sprintf('<script src="%s"></script>', $js); |
| 44 | 44 | } |
| 45 | - foreach($info->cssList as $css) |
|
| 45 | + foreach ($info->cssList as $css) |
|
| 46 | 46 | { |
| 47 | 47 | $csss .= sprintf('<link rel="stylesheet" href="%s" />', $css); |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $this->add('html', $csss . $script . $html); |
|
| 51 | + $this->add('html', $csss.$script.$html); |
|
| 52 | 52 | |
| 53 | - if($isReturn) |
|
| 53 | + if ($isReturn) |
|
| 54 | 54 | { |
| 55 | 55 | return $this->get('html'); |
| 56 | 56 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $layout_info = $oLayoutModel->getLayout($layout_srl); |
| 66 | 66 | |
| 67 | 67 | // Error appears if there is no layout information is registered |
| 68 | - if(!$layout_info) |
|
| 68 | + if (!$layout_info) |
|
| 69 | 69 | { |
| 70 | 70 | return $this->stop('msg_invalid_request'); |
| 71 | 71 | } |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | $layout_info = $security->encodeHTML('.', 'author..', 'extra_var..'); |
| 83 | 83 | |
| 84 | 84 | $layout_info->description = nl2br(trim($layout_info->description)); |
| 85 | - if(!is_object($layout_info->extra_var)) |
|
| 85 | + if (!is_object($layout_info->extra_var)) |
|
| 86 | 86 | { |
| 87 | 87 | $layout_info->extra_var = new StdClass(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - foreach($layout_info->extra_var as $var_name => $val) |
|
| 90 | + foreach ($layout_info->extra_var as $var_name => $val) |
|
| 91 | 91 | { |
| 92 | - if(isset($layout_info->{$var_name}->description)) |
|
| 92 | + if (isset($layout_info->{$var_name}->description)) |
|
| 93 | 93 | { |
| 94 | 94 | $layout_info->{$var_name}->description = nl2br(trim($val->description)); |
| 95 | 95 | } |
@@ -105,27 +105,27 @@ discard block |
||
| 105 | 105 | $oLayoutModel = getModel('layout'); |
| 106 | 106 | $layout_info = $oLayoutModel->getLayout($layout_srl); |
| 107 | 107 | // Error appears if there is no layout information is registered |
| 108 | - if(!$layout_info) |
|
| 108 | + if (!$layout_info) |
|
| 109 | 109 | { |
| 110 | 110 | return $this->dispLayoutAdminInstalledList(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Get Layout Code |
| 114 | - if($oLayoutModel->useDefaultLayout($layout_info->layout_srl)) |
|
| 114 | + if ($oLayoutModel->useDefaultLayout($layout_info->layout_srl)) |
|
| 115 | 115 | { |
| 116 | - $layout_file = $oLayoutModel->getDefaultLayoutHtml($layout_info->layout); |
|
| 117 | - $layout_css_file = $oLayoutModel->getDefaultLayoutCss($layout_info->layout); |
|
| 116 | + $layout_file = $oLayoutModel->getDefaultLayoutHtml($layout_info->layout); |
|
| 117 | + $layout_css_file = $oLayoutModel->getDefaultLayoutCss($layout_info->layout); |
|
| 118 | 118 | } |
| 119 | 119 | else |
| 120 | 120 | { |
| 121 | 121 | $layout_file = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); |
| 122 | 122 | $layout_css_file = $oLayoutModel->getUserLayoutCss($layout_info->layout_srl); |
| 123 | 123 | |
| 124 | - if(!file_exists($layout_file)) $layout_file = $layout_info->path . 'layout.html'; |
|
| 125 | - if(!file_exists($layout_css_file)) $layout_css_file = $layout_info->path . 'layout.css'; |
|
| 124 | + if (!file_exists($layout_file)) $layout_file = $layout_info->path.'layout.html'; |
|
| 125 | + if (!file_exists($layout_css_file)) $layout_css_file = $layout_info->path.'layout.css'; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if(file_exists($layout_css_file)) |
|
| 128 | + if (file_exists($layout_css_file)) |
|
| 129 | 129 | { |
| 130 | 130 | $layout_code_css = FileHandler::readFile($layout_css_file); |
| 131 | 131 | Context::set('layout_code_css', $layout_code_css); |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | public function getSiteDefaultLayout($viewType = 'P', $siteSrl = 0) |
| 182 | 182 | { |
| 183 | 183 | $target = ($viewType == 'M') ? 'mlayout_srl' : 'layout_srl'; |
| 184 | - $designInfoFile = sprintf(_XE_PATH_ . 'files/site_design/design_%s.php', $siteSrl); |
|
| 185 | - if(FileHandler::exists($designInfoFile)) include($designInfoFile); |
|
| 184 | + $designInfoFile = sprintf(_XE_PATH_.'files/site_design/design_%s.php', $siteSrl); |
|
| 185 | + if (FileHandler::exists($designInfoFile)) include($designInfoFile); |
|
| 186 | 186 | |
| 187 | - if(!$designInfo || !$designInfo->{$target}) |
|
| 187 | + if (!$designInfo || !$designInfo->{$target}) |
|
| 188 | 188 | { |
| 189 | 189 | return 0; |
| 190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $oModel = getModel('layout'); |
| 193 | 193 | $layout_info = $oModel->getLayout($designInfo->{$target}); |
| 194 | 194 | |
| 195 | - if(!$layout_info) |
|
| 195 | + if (!$layout_info) |
|
| 196 | 196 | { |
| 197 | 197 | return 0; |
| 198 | 198 | } |