Repository navigation
Expand file tree
/
Copy pathseo.controller.php
More file actions
138 lines (117 loc) · 4.53 KB
/
Copy pathseo.controller.php
File metadata and controls
138 lines (117 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
class seoController extends seo
{
function getBrowserTitle($document_title = null)
{
$site_module_info = Context::get('site_module_info');
if ($site_module_info->site_srl != 0) return Context::getBrowserTitle();
$config = $this->getConfig();
if ($config->use_optimize_title != 'Y') return Context::getBrowserTitle();
$current_module_info = Context::get('current_module_info');
$is_index = ($current_module_info->module_srl == $site_module_info->module_srl) ? true : false;
$piece = array();
$piece['[:site_name:]'] = $config->site_name;
$piece['[:site_slogan:]'] = $config->site_slogan;
$piece['[:module_title:]'] = $current_module_info->browser_title;
if ($document_title) $piece['[:document_title:]'] = $document_title;
if ($config->use_optimize_title == 'Y') {
$title = array();
if ($piece['[:document_title:]']) {
$title[] = $piece['[:document_title:]'];
$title[] = $piece['[:module_title:]'];
$title[] = $piece['[:site_name:]'];
} else {
if ($is_index) {
$title[] = $piece['[:site_name:]'];
if ($piece['[:site_slogan:]']) $title[] = $piece['[:site_slogan:]'];
} else {
$title[] = $piece['[:module_title:]'];
$title[] = $piece['[:site_name:]'];
}
}
$title = implode(' - ', $title);
}
return $title;
}
function triggerBeforeDisplay(&$output_content)
{
if (Context::getResponseMethod() != 'HTML') return;
if (Context::get('module') == 'admin') return;
$oModuleModel = getModel('module');
$config = $this->getConfig();
$logged_info = Context::get('logged_info');
$current_module_info = Context::get('current_module_info');
$site_module_info = Context::get('site_module_info');
$document_srl = Context::get('document_srl');
$is_article = false;
$is_index = ($current_module_info->module_srl == $site_module_info->module_srl) ? true : false;
$piece = new stdClass;
$piece->document_title = null;
$piece->type = 'website';
$piece->url = getFullUrl('');
$piece->title = Context::getBrowserTitle();
$piece->description = $config->site_description;
$piece->keywords = $config->site_keywords;
$piece->image = array();
$piece->author = null;
if ($document_srl) {
$oDocument = Context::get('oDocument');
if (!is_a($oDocument, 'documentItem')) {
$oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
}
if (is_a($oDocument, 'documentItem') && $document_srl == $oDocument->document_srl) {
$is_article = true;
}
}
// 문서 데이터 수집
if ($is_article) {
if (!$oDocument->isSecret()) {
$piece->document_title = $oDocument->getTitleText();
$piece->url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl',$document_srl);
$piece->type = 'article';
$piece->description = trim(str_replace(' ', ' ', $oDocument->getContentText(400)));
$piece->author = $oDocument->getNickName();
if (count($oDocument->get('tag_list'))) {
$tags = implode(',', $oDocument->get('tag_list'));
if ($tags) $piece->keywords = $tags;
}
if ($oDocument->hasUploadedFiles()) {
$image_ext = array('bmp', 'gif', 'jpg', 'jpeg', 'png');
foreach ($oDocument->getUploadedFiles() as $file) {
if ($file->isvalid != 'Y') continue;
$ext = array_pop(explode('.', $file->uploaded_filename));
if (!in_array(strtolower($ext), $image_ext)) continue;
$piece->image[] = Context::get('request_uri') . $file->uploaded_filename;
}
}
} else {
$piece->url = getFullUrl('', 'mid', $current_module_info->mid);
}
} else {
if (!$is_index) {
$page = (Context::get('page') > 1) ? Context::get('page') : null;
$piece->url = getNotEncodedFullUrl('mid', $current_module_info->mid, 'page',$page);
}
}
$piece->title = $this->getBrowserTitle($piece->document_title);
if ($config->site_image_url) $piece->image[] = $config->site_image_url;
$this->addLink('canonical', $piece->url);
$this->addMeta('keywords', $piece->keywords);
$this->addMeta('description', $piece->description);
// Open Graph
$this->addMeta('og:type', $piece->type);
$this->addMeta('og:url', $piece->url);
$this->addMeta('og:site_name', $config->site_name);
$this->addMeta('og:title', $piece->title);
$this->addMeta('og:description', $piece->description);
$this->addMeta('og:article:author', $piece->author);
foreach ($piece->image as $img) {
$this->addMeta('og:image', $img);
}
$this->canonical_url = $piece->url;
$this->applySEO();
if ($config->use_optimize_title == 'Y') Context::setBrowserTitle($piece->title);
}
}
/* !End of file */