mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-25 22:29:55 +09:00
merge sandbox to trunk for 1.4.4
git-svn-id: http://xe-core.googlecode.com/svn/trunk@7723 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
200d63636c
commit
b8299c8a65
683 changed files with 70982 additions and 69716 deletions
|
|
@ -1,12 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="0.2">
|
||||
<title xml:lang="ko">Syndication</title>
|
||||
<description xml:lang="ko">검색서비스업체와 직접 통신을 통해 컨텐츠를 잘 검색되도록 하는 Syndication 규약을 따라 정보를 주고받는 모듈</description>
|
||||
<version>1.0</version>
|
||||
<date>2010-06-23</date>
|
||||
<category>interlock</category>
|
||||
|
||||
<author email_address="developers@xpressengine.com" link="http://www.xpressengine.com">
|
||||
<name xml:lang="ko">NHN</name>
|
||||
</author>
|
||||
</module>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="0.2">
|
||||
<title xml:lang="ko">Syndication</title>
|
||||
<title xml:lang="zh-TW">聯合供搞</title>
|
||||
<description xml:lang="ko">검색서비스업체와 직접 통신을 통해 컨텐츠를 잘 검색되도록 하는 Syndication 규약을 따라 정보를 주고받는 모듈</description>
|
||||
<description xml:lang="zh-TW">검색서비스업체와 직접 통신을 통해 컨텐츠를 잘 검색되도록 하는 Syndication 규약을 따라 정보를 주고받는 모듈</description>
|
||||
<version>1.0</version>
|
||||
<date>2010-06-23</date>
|
||||
<category>interlock</category>
|
||||
|
||||
<author email_address="developers@xpressengine.com" link="http://xpressengine.com/">
|
||||
<name xml:lang="ko">NHN</name>
|
||||
<name xml:lang="zh-TW">NHN</name>
|
||||
</author>
|
||||
</module>
|
||||
|
|
|
|||
16
modules/syndication/lang/zh-TW.lang.php
Normal file
16
modules/syndication/lang/zh-TW.lang.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
$lang->syndication = '聯合供搞';
|
||||
$lang->about_syndication = '신디케이션이란 검색 서비스 업체와 syndication 이라는 표준 규약을 통해서 보다 더 잘 검색되게 하는 기능입니다.<br/>최소한의 요청만으로 효과적으로 컨텐츠를 검색 서비스 업체와 동기화합니다';
|
||||
|
||||
$lang->syndication_service = '供稿服務';
|
||||
$lang->about_syndication_service = '提供根據標準協議的聯合供搞服務。<br/>[應用] 透過 Ping 的方式';
|
||||
|
||||
$lang->my_syndication_url = '供稿網址';
|
||||
$lang->about_my_syndication_url = '신디케이션 정보를 제공할때 사용되는 사이트의 주소를 입력해주세요. 이 주소는 대표 주소를 이용해주시고 가능한 바꾸시지 않는 것이 좋습니다';
|
||||
|
||||
$lang->except_module = '제외시킬 모듈';
|
||||
$lang->about_except_module = '신디케이션 대상에서 제외시켜 검색서비스 업체와 동기화를 시키지 않을 모듈을 선택해주세요';
|
||||
|
||||
$lang->msg_site_url_is_null = '請輸入網站網址';
|
||||
$lang->success_applied = '적용되었습니다';
|
||||
?>
|
||||
|
|
@ -1,133 +1,133 @@
|
|||
<?php
|
||||
/**
|
||||
* @class syndicationAdminController
|
||||
* @author zero (skklove@gmail.com)
|
||||
* @brief syndication 모듈의 admin Controller class
|
||||
**/
|
||||
|
||||
class syndicationAdminController extends syndication {
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
function procSyndicationAdminInsertService() {
|
||||
$oModuleController = &getController('module');
|
||||
$oSyndicationController = &getController('syndication');
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
|
||||
$config->target_services = explode('|@|',Context::get('target_services'));
|
||||
$config->site_url = preg_replace('/\/+$/is','',Context::get('site_url'));
|
||||
$config->year = Context::get('year');
|
||||
if(!$config->site_url) return new Object(-1,'msg_site_url_is_null');
|
||||
|
||||
$oModuleController->insertModuleConfig('syndication',$config);
|
||||
$oSyndicationController->ping($oSyndicationModel->getID('site'), 'site');
|
||||
|
||||
$except_module = Context::get('except_module');
|
||||
$output = executeQuery('syndication.deleteExceptModules');
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$modules = explode(',',$except_module);
|
||||
for($i=0,$c=count($modules);$i<$c;$i++) {
|
||||
$args->module_srl = $modules[$i];
|
||||
$output = executeQuery('syndication.insertExceptModule',$args);
|
||||
if(!$output->toBool()) return $output;
|
||||
}
|
||||
|
||||
$this->setMessage('success_applied');
|
||||
}
|
||||
|
||||
function procSyndicationAdminCheckSitePingResult(){
|
||||
$site_url = trim(Context::get('site_url'));
|
||||
if(!$site_url) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
|
||||
$id = $oSyndicationModel->getID('site');
|
||||
if(substr($site_url,-1)!='/') $site_url .= '/';
|
||||
$site_ping = sprintf('http://%s?module=syndication&act=getSyndicationList&id=%s&type=site', $site_url, $id);
|
||||
|
||||
$headers = array();
|
||||
$headers['Connection'] = 'TE, close';
|
||||
$headers['User-Agent'] = 'Mozilla/4.0 (compatible; NaverBot/1.0; http://help.naver.com/customer_webtxt_02.jsp)';
|
||||
|
||||
$xml = FileHandler::getRemoteResource($site_ping, null, 3, 'GET', '', $headers);
|
||||
if(!$xml) return new Object(-1, 'msg_ping_test_error');
|
||||
|
||||
$oXmlParser = new XmlParser();
|
||||
$oXml = $oXmlParser->parse($xml);
|
||||
|
||||
if(!$oXml || !is_object($oXml) || !$oXml->entry || !$oXml->entry->id || !$oXml->entry->title) {
|
||||
$this->setMessage('msg_ping_test_error');
|
||||
$this->add('ping_result',$xml);
|
||||
}else{
|
||||
$this->setMessage('msg_success_ping_test');
|
||||
}
|
||||
}
|
||||
|
||||
function procSyndicationAdminCheckApiStatus(){
|
||||
$target_service = Context::get('target_service');
|
||||
if(!$target_service) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$status_url = trim($this->statuses[$target_service]);
|
||||
if(!$status_url) return new Object(-1,'msg_syndication_status_not_support');
|
||||
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
$site_url = preg_replace('/^(http|https):\/\//i','',$config->site_url);
|
||||
|
||||
$method = 'getSyndicationStatus' . ucfirst(strtolower($target_service));
|
||||
if(!method_exists(&$this, $method)) return new Object(-1,'msg_syndication_status_not_support');
|
||||
|
||||
$output = call_user_func(array(&$this,$method),$site_url);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$this->add('result_status',$output->get('result_status'));
|
||||
}
|
||||
|
||||
function getSyndicationStatusNaver($site_url){
|
||||
$status_url = trim($this->statuses['Naver']);
|
||||
|
||||
$xml = FileHandler::getRemoteResource(sprintf($status_url,$site_url), null, 3, 'GET', 'application/xml');
|
||||
$oXmlParser = new XmlParser();
|
||||
$oXml = $oXmlParser->parse($xml);
|
||||
$oStatus = $oXml->syndication_status;
|
||||
|
||||
if($oStatus->error->body != 0) return new Object(-1,$oStatus->message->body);
|
||||
|
||||
$result->site_name = $oStatus->site_name->body;
|
||||
$result->first_update = $oStatus->first_update->body;
|
||||
$result->last_update = $oStatus->last_update->body;
|
||||
$result->visit_ok_count = $oStatus->visit_ok_count->body;
|
||||
$result->visit_fail_count = $oStatus->visit_fail_count->body;
|
||||
$result->status = $oStatus->status->body;
|
||||
|
||||
if(!$oStatus->sync || !$oStatus->sync->article){
|
||||
$oArticleList = array();
|
||||
}else{
|
||||
$oArticleList = $oStatus->sync->article;
|
||||
if(!is_array($oArticleList)) $oArticleList = array($oArticleList);
|
||||
}
|
||||
|
||||
if(count($oArticleList)>0){
|
||||
$article_count = array();
|
||||
foreach($oArticleList as $article){
|
||||
$article_count[$article->attrs->date] = $article->body;
|
||||
}
|
||||
|
||||
$result->article_count = $article_count;
|
||||
$result->max_article_count = max($result->article_count);
|
||||
|
||||
}
|
||||
|
||||
Context::set('result', $result);
|
||||
$oTemplateHandler = &TemplateHandler::getInstance();
|
||||
$html = $oTemplateHandler->compile($this->module_path.'tpl', 'naver_result');
|
||||
|
||||
$output = new Object();
|
||||
$output->add('result_status', $html);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @class syndicationAdminController
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief syndication 모듈의 admin Controller class
|
||||
**/
|
||||
|
||||
class syndicationAdminController extends syndication {
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
function procSyndicationAdminInsertService() {
|
||||
$oModuleController = &getController('module');
|
||||
$oSyndicationController = &getController('syndication');
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
|
||||
$config->target_services = explode('|@|',Context::get('target_services'));
|
||||
$config->site_url = preg_replace('/\/+$/is','',Context::get('site_url'));
|
||||
$config->year = Context::get('year');
|
||||
if(!$config->site_url) return new Object(-1,'msg_site_url_is_null');
|
||||
|
||||
$oModuleController->insertModuleConfig('syndication',$config);
|
||||
$oSyndicationController->ping($oSyndicationModel->getID('site'), 'site');
|
||||
|
||||
$except_module = Context::get('except_module');
|
||||
$output = executeQuery('syndication.deleteExceptModules');
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$modules = explode(',',$except_module);
|
||||
for($i=0,$c=count($modules);$i<$c;$i++) {
|
||||
$args->module_srl = $modules[$i];
|
||||
$output = executeQuery('syndication.insertExceptModule',$args);
|
||||
if(!$output->toBool()) return $output;
|
||||
}
|
||||
|
||||
$this->setMessage('success_applied');
|
||||
}
|
||||
|
||||
function procSyndicationAdminCheckSitePingResult(){
|
||||
$site_url = trim(Context::get('site_url'));
|
||||
if(!$site_url) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
|
||||
$id = $oSyndicationModel->getID('site');
|
||||
if(substr($site_url,-1)!='/') $site_url .= '/';
|
||||
$site_ping = sprintf('http://%s?module=syndication&act=getSyndicationList&id=%s&type=site', $site_url, $id);
|
||||
|
||||
$headers = array();
|
||||
$headers['Connection'] = 'TE, close';
|
||||
$headers['User-Agent'] = 'Mozilla/4.0 (compatible; NaverBot/1.0; http://help.naver.com/customer_webtxt_02.jsp)';
|
||||
|
||||
$xml = FileHandler::getRemoteResource($site_ping, null, 3, 'GET', '', $headers);
|
||||
if(!$xml) return new Object(-1, 'msg_ping_test_error');
|
||||
|
||||
$oXmlParser = new XmlParser();
|
||||
$oXml = $oXmlParser->parse($xml);
|
||||
|
||||
if(!$oXml || !is_object($oXml) || !$oXml->entry || !$oXml->entry->id || !$oXml->entry->title) {
|
||||
$this->setMessage('msg_ping_test_error');
|
||||
$this->add('ping_result',$xml);
|
||||
}else{
|
||||
$this->setMessage('msg_success_ping_test');
|
||||
}
|
||||
}
|
||||
|
||||
function procSyndicationAdminCheckApiStatus(){
|
||||
$target_service = Context::get('target_service');
|
||||
if(!$target_service) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$status_url = trim($this->statuses[$target_service]);
|
||||
if(!$status_url) return new Object(-1,'msg_syndication_status_not_support');
|
||||
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
$site_url = preg_replace('/^(http|https):\/\//i','',$config->site_url);
|
||||
|
||||
$method = 'getSyndicationStatus' . ucfirst(strtolower($target_service));
|
||||
if(!method_exists(&$this, $method)) return new Object(-1,'msg_syndication_status_not_support');
|
||||
|
||||
$output = call_user_func(array(&$this,$method),$site_url);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$this->add('result_status',$output->get('result_status'));
|
||||
}
|
||||
|
||||
function getSyndicationStatusNaver($site_url){
|
||||
$status_url = trim($this->statuses['Naver']);
|
||||
|
||||
$xml = FileHandler::getRemoteResource(sprintf($status_url,$site_url), null, 3, 'GET', 'application/xml');
|
||||
$oXmlParser = new XmlParser();
|
||||
$oXml = $oXmlParser->parse($xml);
|
||||
$oStatus = $oXml->syndication_status;
|
||||
|
||||
if($oStatus->error->body != 0) return new Object(-1,$oStatus->message->body);
|
||||
|
||||
$result->site_name = $oStatus->site_name->body;
|
||||
$result->first_update = $oStatus->first_update->body;
|
||||
$result->last_update = $oStatus->last_update->body;
|
||||
$result->visit_ok_count = $oStatus->visit_ok_count->body;
|
||||
$result->visit_fail_count = $oStatus->visit_fail_count->body;
|
||||
$result->status = $oStatus->status->body;
|
||||
|
||||
if(!$oStatus->sync || !$oStatus->sync->article){
|
||||
$oArticleList = array();
|
||||
}else{
|
||||
$oArticleList = $oStatus->sync->article;
|
||||
if(!is_array($oArticleList)) $oArticleList = array($oArticleList);
|
||||
}
|
||||
|
||||
if(count($oArticleList)>0){
|
||||
$article_count = array();
|
||||
foreach($oArticleList as $article){
|
||||
$article_count[$article->attrs->date] = $article->body;
|
||||
}
|
||||
|
||||
$result->article_count = $article_count;
|
||||
$result->max_article_count = max($result->article_count);
|
||||
|
||||
}
|
||||
|
||||
Context::set('result', $result);
|
||||
$oTemplateHandler = &TemplateHandler::getInstance();
|
||||
$html = $oTemplateHandler->compile($this->module_path.'tpl', 'naver_result');
|
||||
|
||||
$output = new Object();
|
||||
$output->add('result_status', $html);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* @class syndicationAdminView
|
||||
* @author zero (skklove@gmail.com)
|
||||
* @brief syndication admin view class
|
||||
**/
|
||||
|
||||
class syndicationAdminView extends syndication {
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
function dispSyndicationAdminConfig() {
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
$module_config = $oModuleModel->getModuleConfig('syndication');
|
||||
if(!$module_config->target_services) $module_config->target_services = array();
|
||||
|
||||
foreach($this->services as $key => $val) {
|
||||
unset($obj);
|
||||
$obj->service = $key;
|
||||
$obj->ping = $val;
|
||||
$obj->selected = in_array($key, $module_config->target_services)?true:false;
|
||||
$services[] = $obj;
|
||||
}
|
||||
Context::set('services', $services);
|
||||
|
||||
if(!$module_config->site_url) {
|
||||
$module_config->site_url = Context::getDefaultUrl()?Context::getDefaultUrl():getFullUrl();
|
||||
}
|
||||
Context::set('site_url', preg_replace('/^(http|https):\/\//i','',$module_config->site_url));
|
||||
|
||||
if(!$module_config->year) {
|
||||
$module_config->year = date("Y");
|
||||
}
|
||||
Context::set('year', $module_config->year);
|
||||
|
||||
$output = executeQueryArray('syndication.getExceptModules');
|
||||
$except_module_list = array();
|
||||
for($i=0,$c=count($output->data);$i<$c;$i++) {
|
||||
$except_module_list[] = $output->data[$i];
|
||||
}
|
||||
Context::set('except_module', $except_module_list);
|
||||
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
$this->setTemplateFile('config');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @class syndicationAdminView
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief syndication admin view class
|
||||
**/
|
||||
|
||||
class syndicationAdminView extends syndication {
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
function dispSyndicationAdminConfig() {
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
$module_config = $oModuleModel->getModuleConfig('syndication');
|
||||
if(!$module_config->target_services) $module_config->target_services = array();
|
||||
|
||||
foreach($this->services as $key => $val) {
|
||||
unset($obj);
|
||||
$obj->service = $key;
|
||||
$obj->ping = $val;
|
||||
$obj->selected = in_array($key, $module_config->target_services)?true:false;
|
||||
$services[] = $obj;
|
||||
}
|
||||
Context::set('services', $services);
|
||||
|
||||
if(!$module_config->site_url) {
|
||||
$module_config->site_url = Context::getDefaultUrl()?Context::getDefaultUrl():getFullUrl();
|
||||
}
|
||||
Context::set('site_url', preg_replace('/^(http|https):\/\//i','',$module_config->site_url));
|
||||
|
||||
if(!$module_config->year) {
|
||||
$module_config->year = date("Y");
|
||||
}
|
||||
Context::set('year', $module_config->year);
|
||||
|
||||
$output = executeQueryArray('syndication.getExceptModules');
|
||||
$except_module_list = array();
|
||||
for($i=0,$c=count($output->data);$i<$c;$i++) {
|
||||
$except_module_list[] = $output->data[$i];
|
||||
}
|
||||
Context::set('except_module', $except_module_list);
|
||||
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
$this->setTemplateFile('config');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,74 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* @class syndication
|
||||
* @author zero (skklove@gmail.com)
|
||||
* @brief syndication 모듈의 high class
|
||||
**/
|
||||
|
||||
define('SyndicationModule', 'M');
|
||||
define('SyndicationDocument', 'D');
|
||||
|
||||
define('SyndicationInserted', 'I');
|
||||
define('SyndicationUpdated', 'U');
|
||||
define('SyndicationDeleted', 'D');
|
||||
|
||||
class syndication extends ModuleObject {
|
||||
|
||||
var $services = array(
|
||||
'Naver' => 'http://syndication.openapi.naver.com/ping/',
|
||||
);
|
||||
|
||||
var $statuses = array(
|
||||
'Naver' => 'http://syndication.openapi.naver.com/status/?site=%s',
|
||||
);
|
||||
|
||||
function moduleInstall() {
|
||||
$oModuleController = &getController('module');
|
||||
$oModuleController->insertTrigger('document.insertDocument', 'syndication', 'controller', 'triggerInsertDocument', 'after');
|
||||
$oModuleController->insertTrigger('document.updateDocument', 'syndication', 'controller', 'triggerUpdateDocument', 'after');
|
||||
$oModuleController->insertTrigger('document.deleteDocument', 'syndication', 'controller', 'triggerDeleteDocument', 'after');
|
||||
$oModuleController->insertTrigger('module.deleteModule', 'syndication', 'controller', 'triggerDeleteModule', 'after');
|
||||
|
||||
$oModuleController->insertTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after');
|
||||
$oModuleController->insertTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after');
|
||||
|
||||
$oAddonAdminModel = &getAdminModel('addon');
|
||||
if($oAddonAdminModel->getAddonInfoXml('catpcha')){
|
||||
$oAddonAdminController = &addonAdminController::getInstance();
|
||||
$oAddonAdminController->doActivate('catpcha');
|
||||
$oAddonAdminController->makeCacheFile();
|
||||
}
|
||||
}
|
||||
|
||||
function checkUpdate() {
|
||||
$oModuleModel = &getModel('module');
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after')) return true;
|
||||
if(!$oModuleModel->getTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function moduleUpdate() {
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleController = &getController('module');
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after')){
|
||||
$oModuleController->insertTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after');
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after')){
|
||||
$oModuleController->insertTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after');
|
||||
}
|
||||
|
||||
$oAddonAdminModel = &getAdminModel('addon');
|
||||
if($oAddonAdminModel->getAddonInfoXml('catpcha')){
|
||||
$oAddonAdminController = &addonAdminController::getInstance();
|
||||
$oAddonAdminController->doActivate('catpcha');
|
||||
$oAddonAdminController->makeCacheFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function recompileCache() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @class syndication
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief syndication 모듈의 high class
|
||||
**/
|
||||
|
||||
define('SyndicationModule', 'M');
|
||||
define('SyndicationDocument', 'D');
|
||||
|
||||
define('SyndicationInserted', 'I');
|
||||
define('SyndicationUpdated', 'U');
|
||||
define('SyndicationDeleted', 'D');
|
||||
|
||||
class syndication extends ModuleObject {
|
||||
|
||||
var $services = array(
|
||||
'Naver' => 'http://syndication.openapi.naver.com/ping/',
|
||||
);
|
||||
|
||||
var $statuses = array(
|
||||
'Naver' => 'http://syndication.openapi.naver.com/status/?site=%s',
|
||||
);
|
||||
|
||||
function moduleInstall() {
|
||||
$oModuleController = &getController('module');
|
||||
$oModuleController->insertTrigger('document.insertDocument', 'syndication', 'controller', 'triggerInsertDocument', 'after');
|
||||
$oModuleController->insertTrigger('document.updateDocument', 'syndication', 'controller', 'triggerUpdateDocument', 'after');
|
||||
$oModuleController->insertTrigger('document.deleteDocument', 'syndication', 'controller', 'triggerDeleteDocument', 'after');
|
||||
$oModuleController->insertTrigger('module.deleteModule', 'syndication', 'controller', 'triggerDeleteModule', 'after');
|
||||
|
||||
$oModuleController->insertTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after');
|
||||
$oModuleController->insertTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after');
|
||||
|
||||
$oAddonAdminModel = &getAdminModel('addon');
|
||||
if($oAddonAdminModel->getAddonInfoXml('catpcha')){
|
||||
$oAddonAdminController = &addonAdminController::getInstance();
|
||||
$oAddonAdminController->doActivate('catpcha');
|
||||
$oAddonAdminController->makeCacheFile();
|
||||
}
|
||||
}
|
||||
|
||||
function checkUpdate() {
|
||||
$oModuleModel = &getModel('module');
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after')) return true;
|
||||
if(!$oModuleModel->getTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function moduleUpdate() {
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleController = &getController('module');
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after')){
|
||||
$oModuleController->insertTrigger('document.moveDocumentToTrash', 'syndication', 'controller', 'triggerMoveDocumentToTrash', 'after');
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after')){
|
||||
$oModuleController->insertTrigger('document.restoreTrash', 'syndication', 'controller', 'triggerRestoreTrash', 'after');
|
||||
}
|
||||
|
||||
$oAddonAdminModel = &getAdminModel('addon');
|
||||
if($oAddonAdminModel->getAddonInfoXml('catpcha')){
|
||||
$oAddonAdminController = &addonAdminController::getInstance();
|
||||
$oAddonAdminController->doActivate('catpcha');
|
||||
$oAddonAdminController->makeCacheFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function recompileCache() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,127 +1,127 @@
|
|||
<?php
|
||||
/**
|
||||
* @class syndicationController
|
||||
* @author zero (skklove@gmail.com)
|
||||
* @brief syndication 모듈의 Controller class
|
||||
**/
|
||||
|
||||
class syndicationController extends syndication {
|
||||
|
||||
function triggerInsertDocument(&$obj) {
|
||||
if($obj->module_srl < 1) return new Object();
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $obj->module_srl);
|
||||
$this->ping($id, 'article');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerUpdateDocument(&$obj) {
|
||||
if($obj->module_srl < 1) return new Object();
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $obj->module_srl);
|
||||
$this->ping($id, 'article');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerDeleteDocument(&$obj) {
|
||||
if($obj->module_srl < 1) return new Object();
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$this->insertLog($obj->module_srl, $obj->document_srl, $obj->title, $obj->content);
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $obj->module_srl);
|
||||
$this->ping($id, 'deleted');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerDeleteModule(&$obj) {
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$this->insertLog($obj->module_srl, $obj->document_srl, $obj->title, $obj->content);
|
||||
|
||||
$output = executeQuery('syndication.getExceptModule', $obj);
|
||||
if($output->data->count) return new Object();
|
||||
|
||||
$id = $oSyndicationModel->getID('site', $obj->module_srl);
|
||||
$this->ping($id, 'deleted');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerMoveDocumentToTrash(&$obj) {
|
||||
$document_srl = $obj->document_srl;
|
||||
$module_srl = $obj->module_srl;
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($module_srl)) return new Object();
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $module_srl);
|
||||
$this->ping($id, 'deleted');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerRestoreTrash(&$obj) {
|
||||
$document_srl = $obj->document_srl;
|
||||
$module_srl = $obj->module_srl;
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($module_srl)) return new Object();
|
||||
|
||||
$id = $oSyndicationModel->getID('article', $module_srl.'-'.$document_srl);
|
||||
$this->ping($id, 'article');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function insertLog($module_srl, $document_srl, $title = null, $summary = null) {
|
||||
$args->module_srl = $module_srl;
|
||||
$args->document_srl = $document_srl;
|
||||
$args->title = $title;
|
||||
$args->summary = $summary;
|
||||
$output = executeQuery('syndication.insertLog', $args);
|
||||
}
|
||||
|
||||
function ping($id, $type) {
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
|
||||
if(!count($config->target_services)) return;
|
||||
if(substr($config->site_url,-1)!='/') $config->site_url .= '/';
|
||||
foreach($config->target_services as $key => $val) {
|
||||
$ping_url = trim($this->services[$val]);
|
||||
if(!$ping_url) continue;
|
||||
$ping_body = sprintf('http://%s?module=syndication&act=getSyndicationList&id=%s&type=%s', $config->site_url, $id, $type);
|
||||
FileHandler::getRemoteResource($ping_url, null, 3, 'POST', 'application/x-www-form-urlencoded', array(), array(), array('link'=>$ping_body));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @class syndicationController
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief syndication 모듈의 Controller class
|
||||
**/
|
||||
|
||||
class syndicationController extends syndication {
|
||||
|
||||
function triggerInsertDocument(&$obj) {
|
||||
if($obj->module_srl < 1) return new Object();
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $obj->module_srl);
|
||||
$this->ping($id, 'article');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerUpdateDocument(&$obj) {
|
||||
if($obj->module_srl < 1) return new Object();
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $obj->module_srl);
|
||||
$this->ping($id, 'article');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerDeleteDocument(&$obj) {
|
||||
if($obj->module_srl < 1) return new Object();
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$this->insertLog($obj->module_srl, $obj->document_srl, $obj->title, $obj->content);
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $obj->module_srl);
|
||||
$this->ping($id, 'deleted');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerDeleteModule(&$obj) {
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($obj->module_srl)) return new Object();
|
||||
|
||||
$this->insertLog($obj->module_srl, $obj->document_srl, $obj->title, $obj->content);
|
||||
|
||||
$output = executeQuery('syndication.getExceptModule', $obj);
|
||||
if($output->data->count) return new Object();
|
||||
|
||||
$id = $oSyndicationModel->getID('site', $obj->module_srl);
|
||||
$this->ping($id, 'deleted');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerMoveDocumentToTrash(&$obj) {
|
||||
$document_srl = $obj->document_srl;
|
||||
$module_srl = $obj->module_srl;
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($module_srl)) return new Object();
|
||||
|
||||
$id = $oSyndicationModel->getID('channel', $module_srl);
|
||||
$this->ping($id, 'deleted');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function triggerRestoreTrash(&$obj) {
|
||||
$document_srl = $obj->document_srl;
|
||||
$module_srl = $obj->module_srl;
|
||||
|
||||
$oSyndicationModel = &getModel('syndication');
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if($oSyndicationModel->isExceptedModules($module_srl)) return new Object();
|
||||
|
||||
$id = $oSyndicationModel->getID('article', $module_srl.'-'.$document_srl);
|
||||
$this->ping($id, 'article');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function insertLog($module_srl, $document_srl, $title = null, $summary = null) {
|
||||
$args->module_srl = $module_srl;
|
||||
$args->document_srl = $document_srl;
|
||||
$args->title = $title;
|
||||
$args->summary = $summary;
|
||||
$output = executeQuery('syndication.insertLog', $args);
|
||||
}
|
||||
|
||||
function ping($id, $type) {
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
|
||||
if(!count($config->target_services)) return;
|
||||
if(substr($config->site_url,-1)!='/') $config->site_url .= '/';
|
||||
foreach($config->target_services as $key => $val) {
|
||||
$ping_url = trim($this->services[$val]);
|
||||
if(!$ping_url) continue;
|
||||
$ping_body = sprintf('http://%s?module=syndication&act=getSyndicationList&id=%s&type=%s', $config->site_url, $id, $type);
|
||||
FileHandler::getRemoteResource($ping_url, null, 3, 'POST', 'application/x-www-form-urlencoded', array(), array(), array('link'=>$ping_body));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,363 +1,363 @@
|
|||
<?php
|
||||
/**
|
||||
* @class getSyndicationList
|
||||
* @author zero (skklove@gmail.com)
|
||||
* @brief syndication 모듈의 model class
|
||||
**/
|
||||
|
||||
class syndicationModel extends syndication {
|
||||
|
||||
var $site_url = null;
|
||||
var $target_services = array();
|
||||
var $year = null;
|
||||
var $langs = array();
|
||||
var $granted_modules = array();
|
||||
|
||||
function init() {
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
$this->site_url = preg_replace('/\/+$/is','',$config->site_url);
|
||||
$this->target_services = $config->target_services;
|
||||
$this->year = $config->year;
|
||||
|
||||
$output = executeQueryArray('syndication.getGrantedModules');
|
||||
if($output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
$this->granted_modules[] = $val->module_srl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isExceptedModules($module_srl) {
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('syndication.getExceptModule', $args);
|
||||
if($output->data->count) return true;
|
||||
$output = executeQuery('syndication.getGrantedModule', $args);
|
||||
if($output->data->count) return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function getLang($key, $site_srl)
|
||||
{
|
||||
if(!$this->langs[$site_srl])
|
||||
{
|
||||
$this->langs[$site_srl] = array();
|
||||
$args->site_srl = $site_srl;
|
||||
$args->lang_code = Context::getLangType();
|
||||
$output = executeQueryArray("syndication.getLang", $args);
|
||||
if(!$output->toBool() || !$output->data) return $key;
|
||||
foreach($output->data as $value)
|
||||
{
|
||||
$this->langs[$site_srl][$value->name] = $value->value;
|
||||
}
|
||||
}
|
||||
if($this->langs[$site_srl][$key])
|
||||
{
|
||||
return $this->langs[$site_srl][$key];
|
||||
}
|
||||
else return $key;
|
||||
}
|
||||
|
||||
function handleLang($title, $site_srl)
|
||||
{
|
||||
$matches = null;
|
||||
if(!preg_match("/\\\$user_lang->(.+)/",$title, $matches)) return $title;
|
||||
else
|
||||
{
|
||||
return $this->getLang($matches[1], $site_srl);
|
||||
}
|
||||
}
|
||||
|
||||
function getSyndicationList() {
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
if(!$config->year || !$config->site_url) return new Object(-1,'msg_check_syndication_config');
|
||||
|
||||
$id = Context::get('id');
|
||||
$type = Context::get('type');
|
||||
$page = Context::get('page');
|
||||
if(!$id || !$type) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
if(!preg_match('/^tag:([^,]+),([0-9]+):(site|channel|article)(.*)$/i',$id,$matches)) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$url = $matches[1];
|
||||
$year = $matches[2];
|
||||
$target = $matches[3];
|
||||
$id = $matches[4];
|
||||
if($id && $id{0}==':') $id = substr($id, 1);
|
||||
|
||||
if($id && strpos($id,'-')!==false) list($module_srl, $document_srl) = explode('-',$id);
|
||||
elseif($id) $module_srl = $id;
|
||||
if(!$url || !$year || !$target) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$startTime = Context::get('start-time');
|
||||
$endTime = Context::get('end-time');
|
||||
|
||||
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3);
|
||||
Context::set('time_zone', $time_zone);
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
if($target == 'channel' && !$module_srl) $target = 'site';
|
||||
if($target == 'channel' && $module_srl) {
|
||||
$args->module_srls = $module_srl;
|
||||
$output = executeQuery('syndication.getModules', $args);
|
||||
$module_info = $output->data;
|
||||
if($module_info) {
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('syndication.getExceptModules', $args);
|
||||
if($output->data->count) $error = 'target is not founded';
|
||||
} else $error = 'target is not founded';
|
||||
|
||||
unset($args);
|
||||
}
|
||||
|
||||
if(!$error) {
|
||||
Context::set('target', $target);
|
||||
Context::set('type', $type);
|
||||
switch($target) {
|
||||
case 'site' :
|
||||
$site_info->id = $this->getID('site');
|
||||
$site_info->title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl);
|
||||
|
||||
$output = executeQuery('syndication.getSiteUpdatedTime');
|
||||
if($output->data) $site_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)).$time_zone;
|
||||
$site_info->self_href = $this->getSelfHref($site_info->id,$type);
|
||||
$site_info->alternative_href =$this->getAlternativeHref();
|
||||
Context::set('site_info', $site_info);
|
||||
|
||||
$this->setTemplateFile('site');
|
||||
switch($type) {
|
||||
case 'channel' :
|
||||
Context::set('channels', $this->getChannels());
|
||||
break;
|
||||
case 'article' :
|
||||
Context::set('articles', $this->getArticles(null, $page, $startTime, $endTime, 'article',$site_info->id));
|
||||
break;
|
||||
case 'deleted' :
|
||||
Context::set('deleted', $this->getDeleted(null, $page, $startTime, $endTime, 'deleted',$site_info->id));
|
||||
break;
|
||||
default :
|
||||
$this->setTemplateFile('site.info');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'channel' :
|
||||
$channel_info->id = $this->getID('channel', $module_info->module_srl);
|
||||
$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->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";
|
||||
}
|
||||
$output = executeQuery('syndication.getSiteUpdatedTime');
|
||||
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);
|
||||
|
||||
$this->setTemplateFile('channel');
|
||||
switch($type) {
|
||||
case 'article' :
|
||||
Context::set('articles', $this->getArticles($module_srl, $page, $startTime, $endTime, 'article', $channel_info->id));
|
||||
break;
|
||||
case 'deleted' :
|
||||
Context::set('deleted', $this->getDeleted($module_srl, $page, $startTime, $endTime, 'deleted', $channel_info->id));
|
||||
break;
|
||||
default :
|
||||
$this->setTemplateFile('channel.info');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'article':
|
||||
Context::set('article', $this->getArticle($document_srl));
|
||||
$this->setTemplateFile('include.articles');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Context::set('message', $error);
|
||||
$this->setTemplateFile('error');
|
||||
}
|
||||
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
Context::setResponseMethod('XMLRPC');
|
||||
}
|
||||
|
||||
function getChannels() {
|
||||
if($module_srls) $args->module_srls = $module_srls;
|
||||
if(count($this->granted_modules)) $args->except_module_srls = implode(',',$this->granted_modules);
|
||||
$output = executeQueryArray('syndication.getModules', $args);
|
||||
if($output->data) {
|
||||
foreach($output->data as $module_info) {
|
||||
unset($obj);
|
||||
$obj->id = $this->getID('channel', $module_info->module_srl);
|
||||
$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->summary = $module_info->description;
|
||||
if($module_info->module == "textyle")
|
||||
{
|
||||
$obj->type = "blog";
|
||||
$obj->rss_href = getFullSiteUrl($module_info->domain, '', 'mid', $module_info->mid, 'act', 'rss');
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj->type = "web";
|
||||
}
|
||||
|
||||
$list[] = $obj;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
function getArticle($document_srl) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
$oDocumentModel = &getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl,false,false);
|
||||
if(!$oDocument->isExists()) return;
|
||||
|
||||
$val = $oDocument->getObjectVars();
|
||||
|
||||
$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl);
|
||||
$val->updated = date("Y-m-d\\TH:i:s", ztime($val->last_update)).$GLOBALS['_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;
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
function getArticles($module_srl = null, $page=1, $startTime = null, $endTime = null, $type = null, $id = null) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
if($module_srl) $args->module_srl = $module_srl;
|
||||
if($startTime) $args->start_date = $this->getDate($startTime);
|
||||
if($endTime) $args->end_date = $this->getDate($endTime);
|
||||
if(count($this->granted_modules)) $args->except_module_srls = implode(',',$this->granted_modules);
|
||||
$args->page = $page;
|
||||
$output = executeQueryArray('syndication.getDocumentList', $args);
|
||||
$cur_page = $output->page_navigation->cur_page;
|
||||
$total_page = $output->page_navigation->last_page;
|
||||
|
||||
$result->next_url = null;
|
||||
$result->list = array();
|
||||
|
||||
if($cur_page<$total_page) {
|
||||
$next_url = $this->getSelfHref($id, $type);
|
||||
if($startTime) $next_url .= '&startTime='.$startTime;
|
||||
if($endTime) $next_url .= '&endTime='.$endTime;
|
||||
$result->next_url = $next_url.'&page='.($cur_page+1);
|
||||
}
|
||||
|
||||
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)).$GLOBALS['_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;
|
||||
}
|
||||
$result->list = $output->data;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getDeleted($module_srl = null, $page = 1, $startTime = null, $endTime = null, $type = null, $id = null) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
if($module_srl) $args->module_srl= $module_srl;
|
||||
if($startTime) $args->start_date = $this->getDate($startTime);
|
||||
if($endTime) $args->end_date = $this->getDate($endTime);
|
||||
$args->page = $page;
|
||||
|
||||
$output = executeQueryArray('syndication.getDeletedList', $args);
|
||||
|
||||
$cur_page = $output->page_navigation->cur_page;
|
||||
$total_page = $output->page_navigation->last_page;
|
||||
|
||||
$result->next_url = null;
|
||||
$result->list = array();
|
||||
|
||||
if($cur_page<$total_page) {
|
||||
$next_url = $this->getSelfHref($id, $type);
|
||||
if($startTime) $next_url .= '&startTime='.$startTime;
|
||||
if($endTime) $next_url .= '&endTime='.$endTime;
|
||||
$result->next_url = $next_url . '&page='.($cur_page+1);
|
||||
}
|
||||
|
||||
if($output->data) {
|
||||
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)).$GLOBALS['_time_zone'];
|
||||
$val->alternative_href = getFullSiteUrl($this->site_url, '', 'document_srl', $val->document_srl);
|
||||
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl);
|
||||
$output->data[$key] = $val;
|
||||
}
|
||||
$result->list = $output->data;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getID($type, $target_id = null) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
return sprintf('tag:%s,%d:%s', $this->site_url, $this->year, $type) . ($target_id?':'.$target_id:'');
|
||||
}
|
||||
|
||||
function getChannelAlternativeHref($module_srl) {
|
||||
static $module_info = array();
|
||||
if(!isset($module_info[$module_srl])) {
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('syndication.getModuleSiteInfo', $args);
|
||||
if($output->data) $module_info[$module_srl] = $output->data;
|
||||
else $module_info[$module_srl] = null;
|
||||
}
|
||||
|
||||
if(is_null($module_info[$module_srl])) return $this->site_url;
|
||||
|
||||
$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;
|
||||
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', $this->site_url, $id, $type);
|
||||
}
|
||||
|
||||
function getAlternativeHref($module_info = null) {
|
||||
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);
|
||||
|
||||
$domain = $module_info->domain;
|
||||
$url = getFullSiteUrl($domain, '', 'mid', $module_info->mid);
|
||||
|
||||
if(substr($url,0,1)=='/') $domain = 'http://'.$this->site_url.$url;
|
||||
return $url;
|
||||
}
|
||||
|
||||
function getDate($date) {
|
||||
$time = strtotime($date);
|
||||
if($time == -1) $time = ztime(str_replace(array('-','T',':'),'',$date));
|
||||
return date('YmdHis', $time);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @class getSyndicationList
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief syndication 모듈의 model class
|
||||
**/
|
||||
|
||||
class syndicationModel extends syndication {
|
||||
|
||||
var $site_url = null;
|
||||
var $target_services = array();
|
||||
var $year = null;
|
||||
var $langs = array();
|
||||
var $granted_modules = array();
|
||||
|
||||
function init() {
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
$this->site_url = preg_replace('/\/+$/is','',$config->site_url);
|
||||
$this->target_services = $config->target_services;
|
||||
$this->year = $config->year;
|
||||
|
||||
$output = executeQueryArray('syndication.getGrantedModules');
|
||||
if($output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
$this->granted_modules[] = $val->module_srl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isExceptedModules($module_srl) {
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('syndication.getExceptModule', $args);
|
||||
if($output->data->count) return true;
|
||||
$output = executeQuery('syndication.getGrantedModule', $args);
|
||||
if($output->data->count) return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function getLang($key, $site_srl)
|
||||
{
|
||||
if(!$this->langs[$site_srl])
|
||||
{
|
||||
$this->langs[$site_srl] = array();
|
||||
$args->site_srl = $site_srl;
|
||||
$args->lang_code = Context::getLangType();
|
||||
$output = executeQueryArray("syndication.getLang", $args);
|
||||
if(!$output->toBool() || !$output->data) return $key;
|
||||
foreach($output->data as $value)
|
||||
{
|
||||
$this->langs[$site_srl][$value->name] = $value->value;
|
||||
}
|
||||
}
|
||||
if($this->langs[$site_srl][$key])
|
||||
{
|
||||
return $this->langs[$site_srl][$key];
|
||||
}
|
||||
else return $key;
|
||||
}
|
||||
|
||||
function handleLang($title, $site_srl)
|
||||
{
|
||||
$matches = null;
|
||||
if(!preg_match("/\\\$user_lang->(.+)/",$title, $matches)) return $title;
|
||||
else
|
||||
{
|
||||
return $this->getLang($matches[1], $site_srl);
|
||||
}
|
||||
}
|
||||
|
||||
function getSyndicationList() {
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('syndication');
|
||||
if(!$config->year || !$config->site_url) return new Object(-1,'msg_check_syndication_config');
|
||||
|
||||
$id = Context::get('id');
|
||||
$type = Context::get('type');
|
||||
$page = Context::get('page');
|
||||
if(!$id || !$type) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
if(!preg_match('/^tag:([^,]+),([0-9]+):(site|channel|article)(.*)$/i',$id,$matches)) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$url = $matches[1];
|
||||
$year = $matches[2];
|
||||
$target = $matches[3];
|
||||
$id = $matches[4];
|
||||
if($id && $id{0}==':') $id = substr($id, 1);
|
||||
|
||||
if($id && strpos($id,'-')!==false) list($module_srl, $document_srl) = explode('-',$id);
|
||||
elseif($id) $module_srl = $id;
|
||||
if(!$url || !$year || !$target) return new Object(-1,'msg_invalid_request');
|
||||
|
||||
$startTime = Context::get('start-time');
|
||||
$endTime = Context::get('end-time');
|
||||
|
||||
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3);
|
||||
Context::set('time_zone', $time_zone);
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
if($target == 'channel' && !$module_srl) $target = 'site';
|
||||
if($target == 'channel' && $module_srl) {
|
||||
$args->module_srls = $module_srl;
|
||||
$output = executeQuery('syndication.getModules', $args);
|
||||
$module_info = $output->data;
|
||||
if($module_info) {
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('syndication.getExceptModules', $args);
|
||||
if($output->data->count) $error = 'target is not founded';
|
||||
} else $error = 'target is not founded';
|
||||
|
||||
unset($args);
|
||||
}
|
||||
|
||||
if(!$error) {
|
||||
Context::set('target', $target);
|
||||
Context::set('type', $type);
|
||||
switch($target) {
|
||||
case 'site' :
|
||||
$site_info->id = $this->getID('site');
|
||||
$site_info->title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl);
|
||||
|
||||
$output = executeQuery('syndication.getSiteUpdatedTime');
|
||||
if($output->data) $site_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)).$time_zone;
|
||||
$site_info->self_href = $this->getSelfHref($site_info->id,$type);
|
||||
$site_info->alternative_href =$this->getAlternativeHref();
|
||||
Context::set('site_info', $site_info);
|
||||
|
||||
$this->setTemplateFile('site');
|
||||
switch($type) {
|
||||
case 'channel' :
|
||||
Context::set('channels', $this->getChannels());
|
||||
break;
|
||||
case 'article' :
|
||||
Context::set('articles', $this->getArticles(null, $page, $startTime, $endTime, 'article',$site_info->id));
|
||||
break;
|
||||
case 'deleted' :
|
||||
Context::set('deleted', $this->getDeleted(null, $page, $startTime, $endTime, 'deleted',$site_info->id));
|
||||
break;
|
||||
default :
|
||||
$this->setTemplateFile('site.info');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'channel' :
|
||||
$channel_info->id = $this->getID('channel', $module_info->module_srl);
|
||||
$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->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";
|
||||
}
|
||||
$output = executeQuery('syndication.getSiteUpdatedTime');
|
||||
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);
|
||||
|
||||
$this->setTemplateFile('channel');
|
||||
switch($type) {
|
||||
case 'article' :
|
||||
Context::set('articles', $this->getArticles($module_srl, $page, $startTime, $endTime, 'article', $channel_info->id));
|
||||
break;
|
||||
case 'deleted' :
|
||||
Context::set('deleted', $this->getDeleted($module_srl, $page, $startTime, $endTime, 'deleted', $channel_info->id));
|
||||
break;
|
||||
default :
|
||||
$this->setTemplateFile('channel.info');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'article':
|
||||
Context::set('article', $this->getArticle($document_srl));
|
||||
$this->setTemplateFile('include.articles');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Context::set('message', $error);
|
||||
$this->setTemplateFile('error');
|
||||
}
|
||||
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
Context::setResponseMethod('XMLRPC');
|
||||
}
|
||||
|
||||
function getChannels() {
|
||||
if($module_srls) $args->module_srls = $module_srls;
|
||||
if(count($this->granted_modules)) $args->except_module_srls = implode(',',$this->granted_modules);
|
||||
$output = executeQueryArray('syndication.getModules', $args);
|
||||
if($output->data) {
|
||||
foreach($output->data as $module_info) {
|
||||
unset($obj);
|
||||
$obj->id = $this->getID('channel', $module_info->module_srl);
|
||||
$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->summary = $module_info->description;
|
||||
if($module_info->module == "textyle")
|
||||
{
|
||||
$obj->type = "blog";
|
||||
$obj->rss_href = getFullSiteUrl($module_info->domain, '', 'mid', $module_info->mid, 'act', 'rss');
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj->type = "web";
|
||||
}
|
||||
|
||||
$list[] = $obj;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
function getArticle($document_srl) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
$oDocumentModel = &getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl,false,false);
|
||||
if(!$oDocument->isExists()) return;
|
||||
|
||||
$val = $oDocument->getObjectVars();
|
||||
|
||||
$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl);
|
||||
$val->updated = date("Y-m-d\\TH:i:s", ztime($val->last_update)).$GLOBALS['_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;
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
function getArticles($module_srl = null, $page=1, $startTime = null, $endTime = null, $type = null, $id = null) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
if($module_srl) $args->module_srl = $module_srl;
|
||||
if($startTime) $args->start_date = $this->getDate($startTime);
|
||||
if($endTime) $args->end_date = $this->getDate($endTime);
|
||||
if(count($this->granted_modules)) $args->except_module_srls = implode(',',$this->granted_modules);
|
||||
$args->page = $page;
|
||||
$output = executeQueryArray('syndication.getDocumentList', $args);
|
||||
$cur_page = $output->page_navigation->cur_page;
|
||||
$total_page = $output->page_navigation->last_page;
|
||||
|
||||
$result->next_url = null;
|
||||
$result->list = array();
|
||||
|
||||
if($cur_page<$total_page) {
|
||||
$next_url = $this->getSelfHref($id, $type);
|
||||
if($startTime) $next_url .= '&startTime='.$startTime;
|
||||
if($endTime) $next_url .= '&endTime='.$endTime;
|
||||
$result->next_url = $next_url.'&page='.($cur_page+1);
|
||||
}
|
||||
|
||||
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)).$GLOBALS['_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;
|
||||
}
|
||||
$result->list = $output->data;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getDeleted($module_srl = null, $page = 1, $startTime = null, $endTime = null, $type = null, $id = null) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
if($module_srl) $args->module_srl= $module_srl;
|
||||
if($startTime) $args->start_date = $this->getDate($startTime);
|
||||
if($endTime) $args->end_date = $this->getDate($endTime);
|
||||
$args->page = $page;
|
||||
|
||||
$output = executeQueryArray('syndication.getDeletedList', $args);
|
||||
|
||||
$cur_page = $output->page_navigation->cur_page;
|
||||
$total_page = $output->page_navigation->last_page;
|
||||
|
||||
$result->next_url = null;
|
||||
$result->list = array();
|
||||
|
||||
if($cur_page<$total_page) {
|
||||
$next_url = $this->getSelfHref($id, $type);
|
||||
if($startTime) $next_url .= '&startTime='.$startTime;
|
||||
if($endTime) $next_url .= '&endTime='.$endTime;
|
||||
$result->next_url = $next_url . '&page='.($cur_page+1);
|
||||
}
|
||||
|
||||
if($output->data) {
|
||||
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)).$GLOBALS['_time_zone'];
|
||||
$val->alternative_href = getFullSiteUrl($this->site_url, '', 'document_srl', $val->document_srl);
|
||||
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl);
|
||||
$output->data[$key] = $val;
|
||||
}
|
||||
$result->list = $output->data;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getID($type, $target_id = null) {
|
||||
if($this->site_url==null) $this->init();
|
||||
|
||||
return sprintf('tag:%s,%d:%s', $this->site_url, $this->year, $type) . ($target_id?':'.$target_id:'');
|
||||
}
|
||||
|
||||
function getChannelAlternativeHref($module_srl) {
|
||||
static $module_info = array();
|
||||
if(!isset($module_info[$module_srl])) {
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('syndication.getModuleSiteInfo', $args);
|
||||
if($output->data) $module_info[$module_srl] = $output->data;
|
||||
else $module_info[$module_srl] = null;
|
||||
}
|
||||
|
||||
if(is_null($module_info[$module_srl])) return $this->site_url;
|
||||
|
||||
$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;
|
||||
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', $this->site_url, $id, $type);
|
||||
}
|
||||
|
||||
function getAlternativeHref($module_info = null) {
|
||||
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);
|
||||
|
||||
$domain = $module_info->domain;
|
||||
$url = getFullSiteUrl($domain, '', 'mid', $module_info->mid);
|
||||
|
||||
if(substr($url,0,1)=='/') $domain = 'http://'.$this->site_url.$url;
|
||||
return $url;
|
||||
}
|
||||
|
||||
function getDate($date) {
|
||||
$time = strtotime($date);
|
||||
if($time == -1) $time = ztime(str_replace(array('-','T',':'),'',$date));
|
||||
return date('YmdHis', $time);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue