Skip to content

Commit

Permalink
https 지원 개선 및 Syndication 문서 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
dorami committed Apr 3, 2016
1 parent bfd4223 commit 6e1c81f
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 92 deletions.
4 changes: 2 additions & 2 deletions conf/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<description xml:lang="tr">Module for better search result, sending and receiving information to search service provider by using Syndication Terms.</description>
<description xml:lang="vi">Module for better search result, sending and receiving information to search service provider by using Syndication Terms.</description>
<description xml:lang="mm">Module for better search result, sending and receiving information to search service provider by using Syndication Terms.</description>
<version>4.0.0</version>
<date>2014-09-17</date>
<version>5.0.0</version>
<date>2016-03-08</date>
<category>interlock</category>

<author email_address="developer@daolcms.org" link="http://www.daolcms.org/">
Expand Down
1 change: 1 addition & 0 deletions syndication.admin.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function dispSyndicationAdminConfig()
Context::set('year', $module_config->year);
Context::set('syndication_token', $module_config->syndication_token);
Context::set('syndication_password', $module_config->syndication_password);
Context::set('uri_scheme', (Context::getSslStatus() == 'always') ? 'https://' : 'http://');

$output = executeQueryArray('syndication.getExceptModules');
$except_module_list = array();
Expand Down
129 changes: 81 additions & 48 deletions syndication.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@

class syndicationModel extends syndication
{
var $site_url = null;
var $syndication_password= null;
var $year = null;
var $langs = array();
var $granted_modules = array();
private $site_url = null;
private $uri_scheme = 'http://';
private $syndication_password= null;
private $year = null;
private $langs = array();
private $granted_modules = array();
static private $modules = array();

function init() {
$oModuleModel = getModel('module');
$config = $oModuleModel->getModuleConfig('syndication');
$this->site_url = preg_replace('/\/+$/is','',$config->site_url);
if(Context::getSslStatus() == 'always') $this->uri_scheme = 'https://';

$this->site_url = preg_replace('/\/+$/is', '', $config->site_url);
$this->syndication_password = $config->syndication_password;
$this->year = $config->year;

Expand Down Expand Up @@ -114,7 +118,7 @@ function getSyndicationList() {
{
$page = 1;
}

$vars = Context::getRequestVars();
if(!$id || !$type)
{
return new Object(-1,'msg_invalid_request');
Expand Down Expand Up @@ -155,7 +159,6 @@ function getSyndicationList() {
return new Object(-1,'msg_invalid_request');
}


$time_zone = substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3);
Context::set('time_zone', $time_zone);

Expand All @@ -172,6 +175,7 @@ function getSyndicationList() {
$args->module_srls = $module_srl;
$output = executeQuery('syndication.getModules', $args);
$module_info = $output->data;
self::$modules[$module_srl] = $output->data;
}

if($target == 'channel' && $module_srl)
Expand All @@ -197,11 +201,19 @@ function getSyndicationList() {
{
Context::set('target', $target);
Context::set('type', $type);

$oMemberModel = getModel('member');
$member_config = $oMemberModel->getMemberConfig();

$oModuleModel = getModel('module');
$site_config = $oModuleModel->getModuleConfig('module');

switch($target)
{
case 'site' :
$site_info = new stdClass;
$site_info->id = $this->getID('site');
$site_info->site_url = getFullSiteUrl($this->uri_scheme . $this->site_url, '');
$site_info->site_title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl);
$site_info->title = $site_info->site_title;

Expand Down Expand Up @@ -270,7 +282,8 @@ function getSyndicationList() {
$channel_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl);
$channel_info->updated = date("Y-m-d\\TH:i:s").$time_zone;
$channel_info->self_href = $this->getSelfHref($channel_info->id, $type);
$channel_info->alternative_href = $this->getAlternativeHref($module_info);
$channel_info->site_url = getFullSiteUrl($this->uri_scheme . $this->site_url, '');
$channel_info->alternative_href = $this->getChannelAlternativeHref($module_info->module_srl);
$channel_info->summary = $module_info->description;
if($module_info->module == "textyle")
{
Expand Down Expand Up @@ -308,21 +321,18 @@ function getSyndicationList() {
case 'article':
$channel_info = new stdClass;
$channel_info->id = $this->getID('channel', $module_info->module_srl);
$channel_info->site_title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl);
$channel_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl);
$channel_info->site_title = $site_config->siteTitle;
if(!$channel_info->site_title) {
$channel_info->site_title = $channel_info->title;
}
$channel_info->updated = date("Y-m-d\\TH:i:s").$time_zone;
$channel_info->self_href = $this->getSelfHref($channel_info->id, $type);
$channel_info->alternative_href = $this->getAlternativeHref($module_info);
$channel_info->summary = $module_info->description;
if($module_info->module == "textyle")
{
$channel_info->type = "blog";
$channel_info->rss_href = getFullSiteUrl($module_info->domain, '', 'mid', $module_info->mid, 'act', 'rss');
}
else
{
$channel_info->type = "web";
}
$channel_info->site_url = getFullSiteUrl($this->uri_scheme . $this->site_url, '');
$channel_info->alternative_href = $this->getChannelAlternativeHref($module_info->module_srl);
$channel_info->webmaster_name = $member_config->webmaster_name;
$channel_info->webmaster_email = $member_config->webmaster_email;

$except_module_srls = $this->getExceptModuleSrls();
if($except_module_srls)
{
Expand All @@ -332,7 +342,7 @@ function getSyndicationList() {
$output = executeQuery('syndication.getSiteUpdatedTime', $args);
if($output->data) $channel_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)).$time_zone;
Context::set('channel_info', $channel_info);

Context::set('member_config', $member_config);

$this->setTemplateFile('channel');
switch($type) {
Expand All @@ -359,6 +369,7 @@ function getSyndicationList() {
Context::setResponseMethod('XMLRPC');
}

// @DEPRECATED
function getChannels() {
if($module_srls) $args->module_srls = $module_srls;
if(count($this->granted_modules)) $args->except_module_srls = implode(',',$this->granted_modules);
Expand All @@ -375,7 +386,7 @@ function getChannels() {
$obj->title = $this->handleLang($module_info->browser_title, $module_info->site_srl);
$obj->updated = date("Y-m-d\\TH:i:s").$time_zone;
$obj->self_href = $this->getSelfHref($obj->id, 'channel');
$obj->alternative_href = $this->getAlternativeHref($module_info);
$obj->alternative_href = $this->getChannelAlternativeHref($module_info);
$obj->summary = $module_info->description;
if($module_info->module == "textyle")
{
Expand Down Expand Up @@ -405,14 +416,26 @@ function getArticle($document_srl) {
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3);
Context::set('time_zone', $time_zone);

$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl);
$val->updated = date("Y-m-d\\TH:i:s", ztime($val->last_update)).$time_zone;
$val->alternative_href = getFullSiteUrl($this->site_url, '', 'document_srl', $val->document_srl);
$val->channel_alternative_href = $this->getChannelAlternativeHref($val->module_srl);
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl);
if(!$val->nick_name) $val->nick_name = $val->user_name;
$mdoule_info = self::$modules[$oDocument->get('module_srl')];

$article = new stdClass();
$article->id = $this->getID('article', $oDocument->get('module_srl').'-'.$oDocument->get('document_srl'));
$article->updated = date("Y-m-d\\TH:i:s", ztime($oDocument->get('last_update'))).$time_zone;
$article->published = date("Y-m-d\\TH:i:s", ztime($oDocument->get('regdate'))).$time_zone;
$article->alternative_href = $this->getAlternativeHref($oDocument->get('document_srl'), $oDocument->get('module_srl'));
$article->channel_alternative_href = $this->getChannelAlternativeHref($oDocument->get('module_srl'));
$article->nick_name = (!$oDocument->get('nick_name')) ? $oDocument->get('user_name') : $oDocument->get('nick_name');
$article->title = $oDocument->getTitle();
$article->content = $oDocument->get('content');
if($val->category_srl) {
$category = $oDocumentModel->getCategory($val->category_srl);
$category_title = $category->title;
$article->category = new stdClass();
$article->category->term = $val->category_srl;
$article->category->label = $category_title;
}

return $val;
return $article;
}

function getArticles($module_srl = null, $page=1, $startTime = null, $endTime = null, $type = null, $id = null) {
Expand Down Expand Up @@ -444,15 +467,16 @@ function getArticles($module_srl = null, $page=1, $startTime = null, $endTime =

if($output->data) {
foreach($output->data as $key => $val) {
$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl);
$val->updated = date("Y-m-d\\TH:i:s", ztime($val->last_update)).$time_zone;
$val->alternative_href = getFullSiteUrl($this->site_url, '', 'document_srl', $val->document_srl);
$val->channel_alternative_href = $this->getChannelAlternativeHref($val->module_srl);
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl);
if(!$val->nick_name) $val->nick_name = $val->user_name;
$output->data[$key] = $val;
$article = new stdClass();
$article->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl);
$article->updated = date("Y-m-d\\TH:i:s", ztime($val->last_update)).$time_zone;
$article->published = date("Y-m-d\\TH:i:s", ztime($val->regdate)).$time_zone;
$article->alternative_href = getFullSiteUrl($this->uri_scheme . $this->site_url, '', 'document_srl', $val->document_srl);
$article->channel_alternative_href = $this->getChannelAlternativeHref($val->module_srl);
$article->nick_name = (!$val->nick_name) ? $val->user_name : $val->nick_name;
$article->content = $val->content;
$result->list[] = $article;
}
$result->list = $output->data;
}
return $result;
}
Expand Down Expand Up @@ -489,7 +513,7 @@ function getDeleted($module_srl = null, $page = 1, $startTime = null, $endTime =
foreach($output->data as $key => $val) {
$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl);
$val->deleted = date("Y-m-d\\TH:i:s", ztime($val->regdate)).$time_zone;
$val->alternative_href = getFullSiteUrl($this->site_url, '', 'document_srl', $val->document_srl);
$val->alternative_href = getFullSiteUrl($this->uri_scheme . $this->site_url, '', 'document_srl', $val->document_srl);
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl);
$output->data[$key] = $val;
}
Expand All @@ -506,7 +530,7 @@ function getDeletedByDocumentSrl($document_srl)
foreach($output->data as $key => $val) {
$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl);
$val->deleted = date("Y-m-d\\TH:i:s", ztime($val->regdate)).$time_zone;
$val->alternative_href = getFullSiteUrl($this->site_url, '', 'document_srl', $val->document_srl);
$val->alternative_href = getFullSiteUrl($this->uri_scheme . $this->site_url, '', 'document_srl', $val->document_srl);
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl);
$output->data[$key] = $val;
}
Expand Down Expand Up @@ -534,26 +558,35 @@ function getChannelAlternativeHref($module_srl) {

$domain = $module_info[$module_srl]->domain;
$url = getFullSiteUrl($domain, '', 'mid', $module_info[$module_srl]->mid);
if(substr($url,0,1)=='/') $domain = 'http://'.$this->site_url.$url;
if(substr($url,0,1)=='/') $domain = $this->uri_scheme . $this->site_url . $url;
return $url;
}

function getSelfHref($id, $type = null) {
if($this->site_url==null) $this->init();

return sprintf('http://%s/?module=syndication&act=getSyndicationList&id=%s&type=%s&syndication_password=%s', $this->site_url, $id, $type, $this->syndication_password);
return sprintf('%s/?module=syndication&act=getSyndicationList&id=%s&type=%s&syndication_password=%s', $this->uri_scheme . $this->site_url, $id, $type, $this->syndication_password);
}

function getAlternativeHref($module_info = null) {
/**
* 문서의 고유 URL 반환
*/
function getAlternativeHref($document_srl, $module_srl) {
if($this->site_url==null) $this->init();

if(!$module_info) return sprintf('http://%s', $this->site_url);
if(!$module_info->site_srl) return getFullUrl('', 'mid', $module_info->mid);
if(!self::$modules[$module_srl]) {
$args = new stdClass;
$args->module_srls = $module_srl;
$output = executeQuery('syndication.getModules', $args);
$module_info = $output->data;
self::$modules[$module_srl] = $module_info;
} else {
$module_info = self::$modules[$module_srl];
}

$domain = $module_info->domain;
$url = getFullSiteUrl($domain, '', 'mid', $module_info->mid);

if(substr($url,0,1)=='/') $domain = 'http://'.$this->site_url.$url;
$url = getFullSiteUrl($domain, '', 'mid', $module_info->mid, 'document_srl', $document_srl);
if(substr($url,0,1)=='/') $domain = $this->uri_scheme . $this->site_url.$url;
return $url;
}

Expand Down
25 changes: 13 additions & 12 deletions tpl/channel.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{'<?xml version="1.0" encoding="utf-8"?>'}
<feed xmlns="http://webmastertool.naver.com">
<!--#include("./include.channel.html")-->
<!--@if($articles->list)-->
<!--@if($articles->next_url)--><link rel="next-in-thread" href="{htmlspecialchars($articles->next_url)}" /><!--@end-->
<!--@foreach($articles->list as $key => $article)-->
<!--#include("./include.articles.html")-->
<!--@end-->
<!--@elseif($deleted->list)-->
<!--@if($deleted->next_url)--><link rel="next-in-thread" href="{htmlspecialchars($deleted->next_url)}" /><!--@end-->
<!--@foreach($deleted->list as $key => $delete)-->
<!--#include("./include.deleted.html")-->
<!--@end-->
<!--@end-->
<include target="./include.channel.html" />

<block cond="$articles->list">
<block loop="$articles->list => $key, $article">
<include target="./include.articles.html" />
</block>
</block>

<block cond="$deleted->list">
<block loop="$deleted->list => $key, $delete">
<include target="./include.deleted.html" />
</block>
</block>
</feed>
4 changes: 2 additions & 2 deletions tpl/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h3 class="xeAdmin">{$lang->syndication} <span class="gray">{$lang->cmd_manageme
<th scope="row"><div>{$lang->help}</div></th>
<td>
<p>{$lang->about_syndication}</p>
<p><a href="http://webmastertool.naver.com/syndi/status.naver" target="_blank">http://webmastertool.naver.com/syndi/status.naver</a></p>
<p><a href="http://webmastertool.naver.com/guide/syndi_guide.naver" target="_blank">http://webmastertool.naver.com/guide/syndi_guide.naver</a></p>
</td>
</tr>

Expand All @@ -35,7 +35,7 @@ <h3 class="xeAdmin">{$lang->syndication} <span class="gray">{$lang->cmd_manageme
<tr>
<th scope="row"><div>{$lang->my_syndication_url}</div></th>
<td>
http://<input type="text" id="site_url" name="site_url" value="{$site_url}" />
{$uri_scheme}<input type="text" id="site_url" name="site_url" value="{$site_url}" />
<span class="btn"><input type="button" value="{$lang->cmd_check_syndication_echo}" onclick="pingCheck(jQuery('#site_url').val())" /></span>
<p>{$lang->about_my_syndication_url}</p>
<p class="ping_test_result"></p>
Expand Down
25 changes: 12 additions & 13 deletions tpl/include.articles.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<entry>
<id>{$article->alternative_href}</id>
<title>{htmlspecialchars($article->title)}</title>
<author>
<name>{htmlspecialchars($article->nick_name)}</name>
</author>
<updated>{$article->updated}</updated>
<published>{date('Y-m-d\TH:i:s',ztime($article->regdate)).$time_zone}</published>
<link rel="via" href="{$article->channel_alternative_href}"/>
<content type="html">{htmlspecialchars($article->content)}</content>
<summary/>
<category/>
</entry>
<entry>
<id>{$article->alternative_href}</id>
<title><![CDATA[{$article->title}]]></title>
<author>
<name><![CDATA[{$article->nick_name}]]></name>
</author>
<updated>{$article->updated}</updated>
<published>{$article->published}</published>
<link rel="via" href="{$article->channel_alternative_href}" title="{htmlspecialchars($channel_info->title)}" />
<content type="html"><![CDATA[{$article->content}]]></content>
<category cond="$article->category" term="{$article->category->term}" label="{htmlspecialchars($article->category->label)}" />
</entry>
15 changes: 8 additions & 7 deletions tpl/include.channel.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<id>{htmlspecialchars($site_info->self_href)}</id>
<title>{htmlspecialchars($channel_info->title)}</title>
<author>
<name>{$channel_info->site_title}</name>
</author>
<updated>{$channel_info->updated}</updated>
<link rel="site" href="{htmlspecialchars($channel_info->self_href)}" title="{htmlspecialchars($channel_info->title)}" />
<id><![CDATA[{$channel_info->self_href}]]></id>
<title><![CDATA[{$channel_info->site_title}]]></title>
<author>
<name><![CDATA[{$channel_info->webmaster_name}]]></name>
<url><![CDATA[{$channel_info->site_url}]]></url>
</author>
<updated>{$channel_info->updated}</updated>
<link rel="site" href="{htmlspecialchars($channel_info->site_url)}" title="{htmlspecialchars($channel_info->site_title)}" />
2 changes: 1 addition & 1 deletion tpl/include.deleted.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<deleted-entry ref="{$delete->alternative_href}" when="{$delete->deleted}" />
<deleted-entry ref="{$delete->alternative_href}" when="{$delete->deleted}" />
14 changes: 7 additions & 7 deletions tpl/include.site.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<id>{htmlspecialchars($site_info->self_href)}</id>
<title>{htmlspecialchars($site_info->title)}</title>
<author>
<name>{$site_info->site_title}</name>
</author>
<updated>{$site_info->updated}</updated>
<link rel="site" href="{htmlspecialchars($site_info->self_href)}" title="{htmlspecialchars($site_info->title)}"/>
<id>{htmlspecialchars($site_info->id)}</id>
<title>{htmlspecialchars($site_info->title)}</title>
<author>
<name>{$site_info->site_title}</name>
</author>
<updated>{$site_info->updated}</updated>
<link rel="site" href="{htmlspecialchars($site_info->site_url)}" title="{htmlspecialchars($site_info->title)}"/>

0 comments on commit 6e1c81f

Please sign in to comment.