12 $current_module_info =
Context::get(
'current_module_info');
13 $is_index = ($current_module_info->module_srl == $site_module_info->module_srl) ?
true :
false;
16 $piece[
'[:site_name:]'] = $config->site_name;
17 $piece[
'[:site_slogan:]'] = $config->site_slogan;
18 $piece[
'[:module_title:]'] = $current_module_info->browser_title;
19 if ($document_title) $piece[
'[:document_title:]'] = $document_title;
21 if ($config->use_optimize_title ==
'Y') {
23 if ($piece[
'[:document_title:]']) {
24 $title[] = $piece[
'[:document_title:]'];
25 $title[] = $piece[
'[:module_title:]'];
26 $title[] = $piece[
'[:site_name:]'];
29 $title[] = $piece[
'[:site_name:]'];
30 if ($piece[
'[:site_slogan:]']) $title[] = $piece[
'[:site_slogan:]'];
32 $title[] = $piece[
'[:module_title:]'];
33 $title[] = $piece[
'[:site_name:]'];
36 $title = implode(
' - ', $title);
47 require_once(
_XE_PATH_ .
'libs/idna_convert/idna_convert.class.php');
73 $current_module_info =
Context::get(
'current_module_info');
77 $single_image =
false;
78 $is_index = ($current_module_info->module_srl == $site_module_info->module_srl) ?
true :
false;
80 $piece =
new stdClass;
81 $piece->document_title = null;
82 $piece->type =
'website';
85 $piece->description = $config->site_description;
86 $piece->keywords = $config->site_keywords;
87 $piece->tags = array();
88 $piece->image = array();
89 $piece->author = null;
91 if(stristr($_SERVER[
'HTTP_USER_AGENT'],
'facebookexternalhit') != FALSE) {
96 if($current_module_info->module_srl !== $site_module_info->module_srl) {
97 $mdoulePartConfig =
$oModuleModel->getModulePartConfig(
'seo', $current_module_info->module_srl);
98 if($mdoulePartConfig && isset($mdoulePartConfig->meta_description) && trim($mdoulePartConfig->meta_description)) {
99 $piece->description = trim($mdoulePartConfig->meta_description);
105 if (!is_a($oDocument,
'documentItem')) {
110 if (is_a($oDocument,
'documentItem') &&
$document_srl == $oDocument->document_srl) {
117 if (!$oDocument->isSecret()) {
118 $piece->document_title = $oDocument->getTitleText();
120 $piece->type =
'article';
121 $piece->description = trim(str_replace(
' ',
' ', $oDocument->getContentText(400)));
122 $piece->author = $oDocument->getNickName();
123 $tags = $oDocument->get(
'tag_list');
124 if (count($tags)) $piece->tags = $tags;
126 $document_images =
false;
127 if($oCacheHandler->isSupport()) {
128 $cache_key_document_images =
'seo:document_images:' .
$document_srl;
129 $document_images = $oCacheHandler->get($cache_key_document_images);
132 if($document_images ===
false && $oDocument->hasUploadedFiles()) {
133 $image_ext = array(
'bmp',
'gif',
'jpg',
'jpeg',
'png');
134 $document_images = array();
136 foreach ($oDocument->getUploadedFiles() as $file) {
137 if ($file->isvalid !=
'Y')
continue;
139 $ext = array_pop(explode(
'.', $file->uploaded_filename));
141 if (!in_array(strtolower($ext), $image_ext))
continue;
142 list($width, $height) = @getimagesize($file->uploaded_filename);
143 if($width < 100 && $height < 100)
continue;
146 'filepath' => $file->uploaded_filename,
151 if($file->cover_image ===
'Y') {
152 array_unshift($document_images, $image);
154 $document_images[] = $image;
158 if($oCacheHandler->isSupport()) {
159 $oCacheHandler->put($cache_key_document_images, $document_images);
163 if($document_images) $piece->image = $document_images;
165 $piece->url =
getFullUrl(
'',
'mid', $current_module_info->mid);
176 if($oCacheHandler->isSupport()) {
177 $cache_key =
'seo:site_image';
178 $site_image = $oCacheHandler->get($cache_key);
180 $site_image[
'url'] = $config->site_image_url;
182 $piece->image[] = $site_image;
185 $this->
addLink(
'canonical', $piece->url);
186 $this->
addMeta(
'keywords', $piece->keywords,
'name');
187 $this->
addMeta(
'description', $piece->description,
'name');
191 $this->
addMeta(
'og:type', $piece->type);
192 $this->
addMeta(
'og:url', $piece->url);
193 $this->
addMeta(
'og:site_name', $config->site_name);
194 $this->
addMeta(
'og:title', $piece->title);
195 $this->
addMeta(
'og:description', $piece->description);
198 $this->
addMeta(
'og:locale:alternate', $locales[$oDocument->getLangCode()]);
200 $this->
addMeta(
'article:published_time', $oDocument->getRegdate(
'c'));
201 $this->
addMeta(
'article:modified_time', $oDocument->getUpdate(
'c'));
202 foreach ($piece->tags as $tag) {
203 $this->
addMeta(
'article:tag', $tag);
207 foreach ($piece->image as $img) {
209 if(!$img[
'filepath'])
continue;
210 $img[
'url'] = $request_uri . $img[
'filepath'];
213 $this->
addMeta(
'og:image', $img[
'url']);
214 $this->
addMeta(
'og:image:width', $img[
'width']);
215 $this->
addMeta(
'og:image:height', $img[
'height']);
216 if($single_image)
break;
219 $this->canonical_url = $piece->url;
249 if($oCacheHandler->isSupport()) {
250 $cache_key_document_images =
'seo:document_images:' .
$document_srl;
251 $oCacheHandler->delete($cache_key_document_images);
triggerAfterDocumentDeleteDocument($data)
triggerBeforeDisplay(&$output_content)
& getInstance($target= 'object', $info=null, $always_use_file=false)
triggerAfterFileDeleteFile($data)
setBrowserTitle($site_title)
makeObject($code=0, $message= 'success')
getBrowserTitle($document_title=null)
triggerAfterDocumentUpdateDocument($data)
addMeta($property, $content, $attr_name= 'property')