11 private $triggers = array(
12 array(
'display',
'seo',
'controller',
'triggerBeforeDisplay',
'before'),
13 array(
'file.deleteFile',
'seo',
'controller',
'triggerAfterFileDeleteFile',
'after'),
14 array(
'document.updateDocument',
'seo',
'controller',
'triggerAfterDocumentUpdateDocument',
'after'),
15 array(
'document.deleteDocument',
'seo',
'controller',
'triggerAfterDocumentDeleteDocument',
'after'),
16 array(
'module.dispAdditionSetup',
'seo',
'view',
'triggerDispSeoAdditionSetup',
'before')
24 require_once(
_XE_PATH_ .
'libs/idna_convert/idna_convert.class.php');
28 if (!$config) $config =
new stdClass;
29 if (!$config->enable) $config->enable =
'Y';
30 if (!$config->use_optimize_title) $config->use_optimize_title =
'N';
31 if (!$config->ga_except_admin) $config->ga_except_admin =
'N';
32 if (!$config->ga_track_subdomain) $config->ga_track_subdomain =
'N';
33 if ($config->site_image)
35 $config->site_image_url = $request_uri .
'files/attach/site_image/' . $config->site_image;
38 if($oCacheHandler->isSupport()) {
40 $cache_key =
'seo:site_image';
41 $site_image = $oCacheHandler->get($cache_key);
43 $path =
_XE_PATH_ .
'files/attach/site_image/';
44 list($width, $height) = @getimagesize($path . $config->site_image);
45 $site_image_dimension = array(
49 $cache_key =
'seo:site_image';
50 $oCacheHandler->put($cache_key, $site_image_dimension);
58 public function addMeta($property, $content, $attr_name =
'property')
60 if (!$content)
return;
64 if (!in_array($property, array(
'og:url'))) {
65 $content = htmlspecialchars($content);
66 $content = preg_replace(
"/(\s+)/",
' ', $content);
69 $this->SEO[
'meta'][] = array(
'property' => $property,
'content' => $content,
'attr_name' => $attr_name);
76 $this->SEO[
'link'][] = array(
'rel' => $rel,
'href' => $href);
84 foreach ($this->SEO as $type => $list) {
85 if (!$list || !count($list))
continue;
87 foreach ($list as $val) {
88 if ($type ==
'meta') {
89 $attr_name = $val[
'attr_name'];
90 Context::addHtmlHeader(
'<meta ' . $attr_name .
'="' . $val[
'property'] .
'" content="' . $val[
'content'] .
'" />');
91 } elseif ($type ==
'link') {
98 if ($config->ga_id && !($config->ga_except_admin ==
'Y' &&
$logged_info->is_admin ==
'Y')) {
101 $gaq_push[] =
"ga('create', '{$config->ga_id}', 'auto');";
103 $gaq_push[] =
"ga('send', 'pageview', '{$canonical_url}');";
104 $gaq_push = implode(PHP_EOL, $gaq_push);
106 $ga_script = <<< GASCRIPT
107 <!-- Google Analytics -->
109 (
function(i,s,o,g,r,a,m){i[
'GoogleAnalyticsObject']=r;i[r]=i[r]||
function(){
110 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*
new Date();a=s.createElement(o),
111 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
112 })(window,
document,
'script',
'//www.google-analytics.com/analytics.js',
'ga');
122 if ($config->na_id && !($config->na_except_admin ==
'Y' &&
$logged_info->is_admin ==
'Y')) {
123 $na_script = <<< NASCRIPT
124 <!-- NAVER Analytics -->
125 <script src=
"//wcs.naver.net/wcslog.js"></script>
126 <script>
if(!wcs_add){var wcs_add={};};wcs_add[
'wa']=
'{$config->na_id}';
if(typeof wcs_do!=
"undefined"){wcs_do();}</script>
143 if($seo_config->enable ===
'Y') {
144 foreach ($this->triggers as $trigger) {
145 if (!
$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]))
return TRUE;
159 if($seo_config->enable ===
'Y') {
160 foreach ($this->triggers as $trigger) {
161 if (!
$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) {
162 $oModuleController->insertTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]);
167 return $this->
makeObject(0,
'success_updated');
174 foreach ($this->triggers as $trigger) {
175 $oModuleController->deleteTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]);
getController($module_name)
& getInstance($target= 'object', $info=null, $always_use_file=false)
makeObject($code=0, $message= 'success')
document the module's high class {
addMeta($property, $content, $attr_name= 'property')