@@ -25,12 +25,24 @@ discard block |
||
| 25 | 25 | $IDN = new idna_convert(array('idn_version' => 2008)); |
| 26 | 26 | $request_uri = $IDN->encode(Context::get('request_uri')); |
| 27 | 27 | |
| 28 | - if (!$config) $config = new stdClass; |
|
| 29 | - if (!$config->enable) $config->enable = 'Y'; |
|
| 30 | - if (!$config->link_nofollow) $config->link_nofollow = 'N'; |
|
| 31 | - if (!$config->use_optimize_title) $config->use_optimize_title = 'N'; |
|
| 32 | - if (!$config->ga_except_admin) $config->ga_except_admin = 'N'; |
|
| 33 | - if (!$config->ga_track_subdomain) $config->ga_track_subdomain = 'N'; |
|
| 28 | + if (!$config) { |
|
| 29 | + $config = new stdClass; |
|
| 30 | + } |
|
| 31 | + if (!$config->enable) { |
|
| 32 | + $config->enable = 'Y'; |
|
| 33 | + } |
|
| 34 | + if (!$config->link_nofollow) { |
|
| 35 | + $config->link_nofollow = 'N'; |
|
| 36 | + } |
|
| 37 | + if (!$config->use_optimize_title) { |
|
| 38 | + $config->use_optimize_title = 'N'; |
|
| 39 | + } |
|
| 40 | + if (!$config->ga_except_admin) { |
|
| 41 | + $config->ga_except_admin = 'N'; |
|
| 42 | + } |
|
| 43 | + if (!$config->ga_track_subdomain) { |
|
| 44 | + $config->ga_track_subdomain = 'N'; |
|
| 45 | + } |
|
| 34 | 46 | if ($config->site_image) |
| 35 | 47 | { |
| 36 | 48 | $config->site_image_url = $request_uri . 'files/attach/site_image/' . $config->site_image; |
@@ -58,7 +70,9 @@ discard block |
||
| 58 | 70 | |
| 59 | 71 | public function addMeta($property, $content, $attr_name = 'property') |
| 60 | 72 | { |
| 61 | - if (!$content) return; |
|
| 73 | + if (!$content) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 62 | 76 | |
| 63 | 77 | $oModuleController = getController('module'); |
| 64 | 78 | $oModuleController->replaceDefinedLangCode($content); |
@@ -72,7 +86,9 @@ discard block |
||
| 72 | 86 | |
| 73 | 87 | public function addLink($rel, $href) |
| 74 | 88 | { |
| 75 | - if (!$href) return; |
|
| 89 | + if (!$href) { |
|
| 90 | + return; |
|
| 91 | + } |
|
| 76 | 92 | |
| 77 | 93 | $this->SEO['link'][] = array('rel' => $rel, 'href' => $href); |
| 78 | 94 | } |
@@ -83,7 +99,9 @@ discard block |
||
| 83 | 99 | $logged_info = Context::get('logged_info'); |
| 84 | 100 | |
| 85 | 101 | foreach ($this->SEO as $type => $list) { |
| 86 | - if (!$list || !count($list)) continue; |
|
| 102 | + if (!$list || !count($list)) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 87 | 105 | |
| 88 | 106 | foreach ($list as $val) { |
| 89 | 107 | if ($type == 'meta') { |
@@ -143,7 +161,9 @@ discard block |
||
| 143 | 161 | |
| 144 | 162 | if($seo_config->enable === 'Y') { |
| 145 | 163 | foreach ($this->triggers as $trigger) { |
| 146 | - if (!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) return TRUE; |
|
| 164 | + if (!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) { |
|
| 165 | + return TRUE; |
|
| 166 | + } |
|
| 147 | 167 | } |
| 148 | 168 | } |
| 149 | 169 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | if (Context::getResponseMethod() != 'HTML') return; |
| 45 | 45 | if (Context::get('module') == 'admin') return; |
| 46 | 46 | |
| 47 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
| 47 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
| 48 | 48 | |
| 49 | 49 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 50 | 50 | |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | $piece->image = array(); |
| 89 | 89 | $piece->author = null; |
| 90 | 90 | |
| 91 | - if(stristr($_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit') != FALSE) { |
|
| 91 | + if (stristr($_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit') != FALSE) { |
|
| 92 | 92 | $single_image = true; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | - if($current_module_info->module_srl !== $site_module_info->module_srl) { |
|
| 96 | + if ($current_module_info->module_srl !== $site_module_info->module_srl) { |
|
| 97 | 97 | $mdoulePartConfig = $oModuleModel->getModulePartConfig('seo', $current_module_info->module_srl); |
| 98 | - if($mdoulePartConfig && isset($mdoulePartConfig->meta_description) && trim($mdoulePartConfig->meta_description)) { |
|
| 98 | + if ($mdoulePartConfig && isset($mdoulePartConfig->meta_description) && trim($mdoulePartConfig->meta_description)) { |
|
| 99 | 99 | $piece->description = trim($mdoulePartConfig->meta_description); |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if ($is_article) { |
| 117 | 117 | if (!$oDocument->isSecret()) { |
| 118 | 118 | $piece->document_title = $oDocument->getTitleText(); |
| 119 | - $piece->url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl',$document_srl); |
|
| 119 | + $piece->url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl); |
|
| 120 | 120 | $piece->type = 'article'; |
| 121 | 121 | $piece->description = trim(str_replace(' ', ' ', $oDocument->getContentText(400))); |
| 122 | 122 | $piece->author = $oDocument->getNickName(); |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | if (count($tags)) $piece->tags = $tags; |
| 125 | 125 | |
| 126 | 126 | $document_images = false; |
| 127 | - if($oCacheHandler->isSupport()) { |
|
| 128 | - $cache_key_document_images = 'seo:document_images:' . $document_srl; |
|
| 127 | + if ($oCacheHandler->isSupport()) { |
|
| 128 | + $cache_key_document_images = 'seo:document_images:'.$document_srl; |
|
| 129 | 129 | $document_images = $oCacheHandler->get($cache_key_document_images); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if($document_images === false && $oDocument->hasUploadedFiles()) { |
|
| 132 | + if ($document_images === false && $oDocument->hasUploadedFiles()) { |
|
| 133 | 133 | $image_ext = array('bmp', 'gif', 'jpg', 'jpeg', 'png'); |
| 134 | 134 | $document_images = array(); |
| 135 | 135 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | if (!in_array(strtolower($ext), $image_ext)) continue; |
| 142 | 142 | list($width, $height) = @getimagesize($file->uploaded_filename); |
| 143 | - if($width < 100 && $height < 100) continue; |
|
| 143 | + if ($width < 100 && $height < 100) continue; |
|
| 144 | 144 | |
| 145 | 145 | $image = array( |
| 146 | 146 | 'filepath' => $file->uploaded_filename, |
@@ -148,35 +148,35 @@ discard block |
||
| 148 | 148 | 'height' => $height |
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | - if($file->cover_image === 'Y') { |
|
| 151 | + if ($file->cover_image === 'Y') { |
|
| 152 | 152 | array_unshift($document_images, $image); |
| 153 | 153 | } else { |
| 154 | 154 | $document_images[] = $image; |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if($oCacheHandler->isSupport()) { |
|
| 158 | + if ($oCacheHandler->isSupport()) { |
|
| 159 | 159 | $oCacheHandler->put($cache_key_document_images, $document_images); |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if($document_images) $piece->image = $document_images; |
|
| 163 | + if ($document_images) $piece->image = $document_images; |
|
| 164 | 164 | } else { |
| 165 | 165 | $piece->url = getFullUrl('', 'mid', $current_module_info->mid); |
| 166 | 166 | } |
| 167 | 167 | } else { |
| 168 | 168 | if (!$is_index) { |
| 169 | 169 | $page = (Context::get('page') > 1) ? Context::get('page') : null; |
| 170 | - $piece->url = getNotEncodedFullUrl('mid', $current_module_info->mid, 'page',$page); |
|
| 170 | + $piece->url = getNotEncodedFullUrl('mid', $current_module_info->mid, 'page', $page); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $piece->title = $this->getBrowserTitle($piece->document_title); |
| 175 | 175 | |
| 176 | - if($oCacheHandler->isSupport()) { |
|
| 176 | + if ($oCacheHandler->isSupport()) { |
|
| 177 | 177 | $cache_key = 'seo:site_image'; |
| 178 | 178 | $site_image = $oCacheHandler->get($cache_key); |
| 179 | - if($site_image) { |
|
| 179 | + if ($site_image) { |
|
| 180 | 180 | $site_image['url'] = $config->site_image_url; |
| 181 | 181 | } |
| 182 | 182 | $piece->image[] = $site_image; |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | $this->addMeta('og:site_name', $config->site_name); |
| 194 | 194 | $this->addMeta('og:title', $piece->title); |
| 195 | 195 | $this->addMeta('og:description', $piece->description); |
| 196 | - if($is_article) { |
|
| 197 | - if(Context::getLangType() !== $oDocument->getLangCode()) { |
|
| 196 | + if ($is_article) { |
|
| 197 | + if (Context::getLangType() !== $oDocument->getLangCode()) { |
|
| 198 | 198 | $this->addMeta('og:locale:alternate', $locales[$oDocument->getLangCode()]); |
| 199 | 199 | } |
| 200 | 200 | $this->addMeta('article:published_time', $oDocument->getRegdate('c')); |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | foreach ($piece->image as $img) { |
| 208 | - if(!$img['url']) { |
|
| 209 | - if(!$img['filepath']) continue; |
|
| 210 | - $img['url'] = $request_uri . $img['filepath']; |
|
| 208 | + if (!$img['url']) { |
|
| 209 | + if (!$img['filepath']) continue; |
|
| 210 | + $img['url'] = $request_uri.$img['filepath']; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | $this->addMeta('og:image', $img['url']); |
| 214 | 214 | $this->addMeta('og:image:width', $img['width']); |
| 215 | 215 | $this->addMeta('og:image:height', $img['height']); |
| 216 | - if($single_image) break; |
|
| 216 | + if ($single_image) break; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $this->canonical_url = $piece->url; |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | if ($config->use_optimize_title == 'Y') Context::setBrowserTitle($piece->title); |
| 224 | 224 | |
| 225 | - if($config->link_nofollow == 'Y') { |
|
| 226 | - $temp_output = (string)$output_content; |
|
| 225 | + if ($config->link_nofollow == 'Y') { |
|
| 226 | + $temp_output = (string) $output_content; |
|
| 227 | 227 | $temp_output = preg_replace_callback('!<\!--BeforeComment\([0-9]+,[0-9]+\)-->(.+?)<\!--AfterComment\([0-9]+,[0-9]+\)-->!is', array($this, 'replaceCommentHyperlink'), $temp_output); |
| 228 | 228 | $output_content = $temp_output; |
| 229 | 229 | } |
@@ -236,13 +236,13 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | private function _addNofollow($matches) |
| 238 | 238 | { |
| 239 | - return '<a' . preg_replace('!\srel=(?:"|\')?([^"\']+)(?:"|\')?!is', '', $matches[1]) . ' rel="nofollow">' . $matches[2] . '</a>'; |
|
| 239 | + return '<a'.preg_replace('!\srel=(?:"|\')?([^"\']+)(?:"|\')?!is', '', $matches[1]).' rel="nofollow">'.$matches[2].'</a>'; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | function triggerAfterFileDeleteFile($data) |
| 243 | 243 | { |
| 244 | 244 | $document_srl = $data->upload_target_srl; |
| 245 | - if(!$document_srl) return $this->makeObject(); |
|
| 245 | + if (!$document_srl) return $this->makeObject(); |
|
| 246 | 246 | |
| 247 | 247 | $this->deleteCacheDocumentImages($document_srl); |
| 248 | 248 | } |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | private function deleteCacheDocumentImages($document_srl) |
| 263 | 263 | { |
| 264 | 264 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 265 | - if($oCacheHandler->isSupport()) { |
|
| 266 | - $cache_key_document_images = 'seo:document_images:' . $document_srl; |
|
| 265 | + if ($oCacheHandler->isSupport()) { |
|
| 266 | + $cache_key_document_images = 'seo:document_images:'.$document_srl; |
|
| 267 | 267 | $oCacheHandler->delete($cache_key_document_images); |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -4,10 +4,14 @@ discard block |
||
| 4 | 4 | function getBrowserTitle($document_title = null) |
| 5 | 5 | { |
| 6 | 6 | $site_module_info = Context::get('site_module_info'); |
| 7 | - if ($site_module_info->site_srl != 0) return Context::getBrowserTitle(); |
|
| 7 | + if ($site_module_info->site_srl != 0) { |
|
| 8 | + return Context::getBrowserTitle(); |
|
| 9 | + } |
|
| 8 | 10 | |
| 9 | 11 | $config = $this->getConfig(); |
| 10 | - if ($config->use_optimize_title != 'Y') return Context::getBrowserTitle(); |
|
| 12 | + if ($config->use_optimize_title != 'Y') { |
|
| 13 | + return Context::getBrowserTitle(); |
|
| 14 | + } |
|
| 11 | 15 | |
| 12 | 16 | $current_module_info = Context::get('current_module_info'); |
| 13 | 17 | $is_index = ($current_module_info->module_srl == $site_module_info->module_srl) ? true : false; |
@@ -16,7 +20,9 @@ discard block |
||
| 16 | 20 | $piece['[:site_name:]'] = $config->site_name; |
| 17 | 21 | $piece['[:site_slogan:]'] = $config->site_slogan; |
| 18 | 22 | $piece['[:module_title:]'] = $current_module_info->browser_title; |
| 19 | - if ($document_title) $piece['[:document_title:]'] = $document_title; |
|
| 23 | + if ($document_title) { |
|
| 24 | + $piece['[:document_title:]'] = $document_title; |
|
| 25 | + } |
|
| 20 | 26 | |
| 21 | 27 | if ($config->use_optimize_title == 'Y') { |
| 22 | 28 | $title = array(); |
@@ -27,7 +33,9 @@ discard block |
||
| 27 | 33 | } else { |
| 28 | 34 | if ($is_index) { |
| 29 | 35 | $title[] = $piece['[:site_name:]']; |
| 30 | - if ($piece['[:site_slogan:]']) $title[] = $piece['[:site_slogan:]']; |
|
| 36 | + if ($piece['[:site_slogan:]']) { |
|
| 37 | + $title[] = $piece['[:site_slogan:]']; |
|
| 38 | + } |
|
| 31 | 39 | } else { |
| 32 | 40 | $title[] = $piece['[:module_title:]']; |
| 33 | 41 | $title[] = $piece['[:site_name:]']; |
@@ -41,8 +49,12 @@ discard block |
||
| 41 | 49 | |
| 42 | 50 | function triggerBeforeDisplay(&$output_content) |
| 43 | 51 | { |
| 44 | - if (Context::getResponseMethod() != 'HTML') return; |
|
| 45 | - if (Context::get('module') == 'admin') return; |
|
| 52 | + if (Context::getResponseMethod() != 'HTML') { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 55 | + if (Context::get('module') == 'admin') { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 46 | 58 | |
| 47 | 59 | require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
| 48 | 60 | |
@@ -121,7 +133,9 @@ discard block |
||
| 121 | 133 | $piece->description = trim(str_replace(' ', ' ', $oDocument->getContentText(400))); |
| 122 | 134 | $piece->author = $oDocument->getNickName(); |
| 123 | 135 | $tags = $oDocument->get('tag_list'); |
| 124 | - if (count($tags)) $piece->tags = $tags; |
|
| 136 | + if (count($tags)) { |
|
| 137 | + $piece->tags = $tags; |
|
| 138 | + } |
|
| 125 | 139 | |
| 126 | 140 | $document_images = false; |
| 127 | 141 | if($oCacheHandler->isSupport()) { |
@@ -134,13 +148,19 @@ discard block |
||
| 134 | 148 | $document_images = array(); |
| 135 | 149 | |
| 136 | 150 | foreach ($oDocument->getUploadedFiles() as $file) { |
| 137 | - if ($file->isvalid != 'Y') continue; |
|
| 151 | + if ($file->isvalid != 'Y') { |
|
| 152 | + continue; |
|
| 153 | + } |
|
| 138 | 154 | |
| 139 | 155 | $ext = array_pop(explode('.', $file->uploaded_filename)); |
| 140 | 156 | |
| 141 | - if (!in_array(strtolower($ext), $image_ext)) continue; |
|
| 157 | + if (!in_array(strtolower($ext), $image_ext)) { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 142 | 160 | list($width, $height) = @getimagesize($file->uploaded_filename); |
| 143 | - if($width < 100 && $height < 100) continue; |
|
| 161 | + if($width < 100 && $height < 100) { |
|
| 162 | + continue; |
|
| 163 | + } |
|
| 144 | 164 | |
| 145 | 165 | $image = array( |
| 146 | 166 | 'filepath' => $file->uploaded_filename, |
@@ -160,7 +180,9 @@ discard block |
||
| 160 | 180 | } |
| 161 | 181 | } |
| 162 | 182 | |
| 163 | - if($document_images) $piece->image = $document_images; |
|
| 183 | + if($document_images) { |
|
| 184 | + $piece->image = $document_images; |
|
| 185 | + } |
|
| 164 | 186 | } else { |
| 165 | 187 | $piece->url = getFullUrl('', 'mid', $current_module_info->mid); |
| 166 | 188 | } |
@@ -206,21 +228,27 @@ discard block |
||
| 206 | 228 | |
| 207 | 229 | foreach ($piece->image as $img) { |
| 208 | 230 | if(!$img['url']) { |
| 209 | - if(!$img['filepath']) continue; |
|
| 231 | + if(!$img['filepath']) { |
|
| 232 | + continue; |
|
| 233 | + } |
|
| 210 | 234 | $img['url'] = $request_uri . $img['filepath']; |
| 211 | 235 | } |
| 212 | 236 | |
| 213 | 237 | $this->addMeta('og:image', $img['url']); |
| 214 | 238 | $this->addMeta('og:image:width', $img['width']); |
| 215 | 239 | $this->addMeta('og:image:height', $img['height']); |
| 216 | - if($single_image) break; |
|
| 240 | + if($single_image) { |
|
| 241 | + break; |
|
| 242 | + } |
|
| 217 | 243 | } |
| 218 | 244 | |
| 219 | 245 | $this->canonical_url = $piece->url; |
| 220 | 246 | |
| 221 | 247 | $this->applySEO(); |
| 222 | 248 | |
| 223 | - if ($config->use_optimize_title == 'Y') Context::setBrowserTitle($piece->title); |
|
| 249 | + if ($config->use_optimize_title == 'Y') { |
|
| 250 | + Context::setBrowserTitle($piece->title); |
|
| 251 | + } |
|
| 224 | 252 | |
| 225 | 253 | if($config->link_nofollow == 'Y') { |
| 226 | 254 | $temp_output = (string)$output_content; |
@@ -242,7 +270,9 @@ discard block |
||
| 242 | 270 | function triggerAfterFileDeleteFile($data) |
| 243 | 271 | { |
| 244 | 272 | $document_srl = $data->upload_target_srl; |
| 245 | - if(!$document_srl) return $this->makeObject(); |
|
| 273 | + if(!$document_srl) { |
|
| 274 | + return $this->makeObject(); |
|
| 275 | + } |
|
| 246 | 276 | |
| 247 | 277 | $this->deleteCacheDocumentImages($document_srl); |
| 248 | 278 | } |