|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* @class getSyndicationList |
|
6
|
|
|
* @author NAVER ([email protected]) |
|
7
|
|
|
* @brief syndication model class of the module |
|
8
|
|
|
**/ |
|
9
|
|
|
|
|
10
|
|
|
class syndicationModel extends syndication |
|
11
|
|
|
{ |
|
12
|
|
|
private $site_url = null; |
|
13
|
|
|
private $uri_scheme = 'http://'; |
|
14
|
|
|
private $syndication_password= null; |
|
15
|
|
|
private $year = null; |
|
16
|
|
|
private $langs = array(); |
|
17
|
|
|
private $granted_modules = array(); |
|
18
|
|
|
static private $modules = array(); |
|
19
|
|
|
|
|
20
|
|
|
function init() { |
|
21
|
|
|
$oModuleModel = getModel('module'); |
|
22
|
|
|
$config = $oModuleModel->getModuleConfig('syndication'); |
|
23
|
|
|
if(Context::getSslStatus() == 'always') $this->uri_scheme = 'https://'; |
|
24
|
|
|
|
|
25
|
|
|
$this->site_url = preg_replace('/\/+$/is', '', $config->site_url); |
|
26
|
|
|
$this->syndication_password = $config->syndication_password; |
|
27
|
|
|
$this->year = $config->year; |
|
28
|
|
|
|
|
29
|
|
|
$output = executeQueryArray('syndication.getGrantedModules'); |
|
30
|
|
|
if($output->data) { |
|
31
|
|
|
foreach($output->data as $key => $val) { |
|
32
|
|
|
$this->granted_modules[] = $val->module_srl; |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
$this->gzhandler_enable = FALSE; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function isExceptedModules($module_srl) { |
|
40
|
|
|
$args = new stdClass; |
|
41
|
|
|
$args->module_srl = $module_srl; |
|
42
|
|
|
|
|
43
|
|
|
$output = executeQuery('syndication.getExceptModule', $args); |
|
44
|
|
|
if($output->data->count) return TRUE; |
|
45
|
|
|
|
|
46
|
|
|
$output = executeQuery('syndication.getGrantedModule', $args); |
|
47
|
|
|
if($output->data->count) return TRUE; |
|
48
|
|
|
|
|
49
|
|
|
return FALSE; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
function getExceptModuleSrls() |
|
53
|
|
|
{ |
|
54
|
|
|
$output = executeQueryArray('syndication.getExceptModuleSrls'); |
|
55
|
|
|
$module_srls = array(); |
|
56
|
|
|
if (is_array($output->data)) |
|
57
|
|
|
{ |
|
58
|
|
|
foreach($output->data as $val) |
|
59
|
|
|
{ |
|
60
|
|
|
$module_srls[] = $val->module_srl; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
return $module_srls; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
function getLang($key, $site_srl) |
|
67
|
|
|
{ |
|
68
|
|
|
if(!$this->langs[$site_srl]) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->langs[$site_srl] = array(); |
|
71
|
|
|
$args = new stdClass; |
|
72
|
|
|
$args->site_srl = $site_srl; |
|
73
|
|
|
$args->lang_code = Context::getLangType(); |
|
74
|
|
|
$output = executeQueryArray("syndication.getLang", $args); |
|
75
|
|
|
if(!$output->toBool() || !$output->data) return $key; |
|
76
|
|
|
|
|
77
|
|
|
foreach($output->data as $value) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->langs[$site_srl][$value->name] = $value->value; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
if($this->langs[$site_srl][$key]) |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->langs[$site_srl][$key]; |
|
85
|
|
|
} |
|
86
|
|
|
else return $key; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
function handleLang($title, $site_srl) |
|
90
|
|
|
{ |
|
91
|
|
|
$matches = NULL; |
|
92
|
|
|
if(!preg_match("/\\\$user_lang->(.+)/", $title, $matches)) |
|
93
|
|
|
{ |
|
94
|
|
|
return $title; |
|
95
|
|
|
} |
|
96
|
|
|
else |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->getLang($matches[1], $site_srl); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
function getSyndicationList() { |
|
103
|
|
|
$oModuleModel = getModel('module'); |
|
104
|
|
|
$config = $oModuleModel->getModuleConfig('syndication'); |
|
105
|
|
|
if(!$config->year || !$config->site_url || !$config->syndication_token) |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->makeObject(-1,'msg_check_syndication_config'); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
$id = Context::get('id'); |
|
111
|
|
|
$type = Context::get('type'); |
|
112
|
|
|
|
|
113
|
|
|
$startTime = Context::get('start-time'); |
|
114
|
|
|
$endTime = Context::get('end-time'); |
|
115
|
|
|
|
|
116
|
|
|
$page = Context::get('page'); |
|
117
|
|
|
if(!$page) |
|
118
|
|
|
{ |
|
119
|
|
|
$page = 1; |
|
120
|
|
|
} |
|
121
|
|
|
$vars = Context::getRequestVars(); |
|
|
|
|
|
|
122
|
|
|
if(!$id || !$type) |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->makeObject(-1,'msg_invalid_request'); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
if(!preg_match('/^tag:([^,]+),([0-9]+):(site|channel|article)(.*)$/i',$id,$matches)) |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->makeObject(-1,'msg_invalid_request'); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
if($config->syndication_password != Context::get('syndication_password')) |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->makeObject(-1,'msg_invalid_request'); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
$url = $matches[1]; |
|
138
|
|
|
$year = $matches[2]; |
|
139
|
|
|
$target = $matches[3]; |
|
140
|
|
|
$id = $matches[4]; |
|
141
|
|
|
if($id && $id{0}==':') |
|
142
|
|
|
{ |
|
143
|
|
|
$id = substr($id, 1); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
$module_srl = null; |
|
147
|
|
|
$document_srl = null; |
|
148
|
|
|
if($id && strpos($id,'-')!==false) |
|
149
|
|
|
{ |
|
150
|
|
|
list($module_srl, $document_srl) = explode('-', $id); |
|
151
|
|
|
} |
|
152
|
|
|
elseif($id) |
|
153
|
|
|
{ |
|
154
|
|
|
$module_srl = $id; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
if(!$url || !$year || !$target) |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->makeObject(-1,'msg_invalid_request'); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
$time_zone = substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3); |
|
163
|
|
|
Context::set('time_zone', $time_zone); |
|
164
|
|
|
|
|
165
|
|
|
$site_module_info = Context::get('site_module_info'); |
|
166
|
|
|
|
|
167
|
|
|
if($target == 'channel' && !$module_srl) |
|
168
|
|
|
{ |
|
169
|
|
|
$target = 'site'; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
if($module_srl) |
|
173
|
|
|
{ |
|
174
|
|
|
$args = new stdClass; |
|
175
|
|
|
$args->module_srls = $module_srl; |
|
176
|
|
|
$output = executeQuery('syndication.getModules', $args); |
|
177
|
|
|
$module_info = $output->data; |
|
178
|
|
|
self::$modules[$module_srl] = $output->data; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
if($target == 'channel' && $module_srl) |
|
182
|
|
|
{ |
|
183
|
|
|
if($module_info) |
|
|
|
|
|
|
184
|
|
|
{ |
|
185
|
|
|
$args->module_srl = $module_srl; |
|
|
|
|
|
|
186
|
|
|
$output = executeQuery('syndication.getExceptModules', $args); |
|
187
|
|
|
if($output->data->count) |
|
188
|
|
|
{ |
|
189
|
|
|
$error = 'target is not founded'; |
|
190
|
|
|
} |
|
191
|
|
|
} |
|
192
|
|
|
else |
|
193
|
|
|
{ |
|
194
|
|
|
$error = 'target is not founded'; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
unset($args); |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
if(!$error) |
|
201
|
|
|
{ |
|
202
|
|
|
Context::set('target', $target); |
|
203
|
|
|
Context::set('type', $type); |
|
204
|
|
|
|
|
205
|
|
|
$oMemberModel = getModel('member'); |
|
206
|
|
|
$member_config = $oMemberModel->getMemberConfig(); |
|
207
|
|
|
|
|
208
|
|
|
$oModuleModel = getModel('module'); |
|
209
|
|
|
$site_config = $oModuleModel->getModuleConfig('module'); |
|
210
|
|
|
|
|
211
|
|
|
switch($target) |
|
212
|
|
|
{ |
|
213
|
|
|
case 'site' : |
|
214
|
|
|
$site_info = new stdClass; |
|
215
|
|
|
$site_info->id = $this->getID('site'); |
|
216
|
|
|
$site_info->site_url = getFullSiteUrl($this->uri_scheme . $this->site_url, ''); |
|
217
|
|
|
$site_info->site_title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl); |
|
218
|
|
|
$site_info->title = $site_info->site_title; |
|
219
|
|
|
|
|
220
|
|
|
if($module_srl) |
|
221
|
|
|
{ |
|
222
|
|
|
$args->module_srl = $module_srl; |
|
223
|
|
|
$site_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl); |
|
224
|
|
|
if(!$site_info->title) |
|
225
|
|
|
{ |
|
226
|
|
|
$site_info->title = $site_info->site_title; |
|
227
|
|
|
} |
|
228
|
|
|
} |
|
229
|
|
|
else |
|
230
|
|
|
{ |
|
231
|
|
|
$except_module_output = executeQueryArray('syndication.getExceptModuleSrls'); |
|
232
|
|
|
if(is_array($except_module_output->data)) |
|
233
|
|
|
{ |
|
234
|
|
|
$except_module_srls = array(); |
|
235
|
|
|
foreach($except_module_output->data as $val) |
|
236
|
|
|
{ |
|
237
|
|
|
$except_module_srls[] = $val->module_srl; |
|
238
|
|
|
} |
|
239
|
|
|
$args->except_modules = implode(',', $except_module_srls); |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
$output = executeQuery('syndication.getSiteUpdatedTime', $args); |
|
244
|
|
|
|
|
245
|
|
View Code Duplication |
if($output->data) |
|
246
|
|
|
{ |
|
247
|
|
|
$site_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)).$time_zone; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
$site_info->self_href = $this->getSelfHref($site_info->id,$type); |
|
251
|
|
|
Context::set('site_info', $site_info); |
|
252
|
|
|
|
|
253
|
|
|
$this->setTemplateFile('site'); |
|
254
|
|
|
switch($type) { |
|
255
|
|
|
case 'article' : |
|
256
|
|
|
// 문서 전체를 신디케이션에 추가 |
|
257
|
|
|
Context::set('articles', $this->getArticles($module_srl, $page, $startTime, $endTime, 'article',$site_info->id)); |
|
258
|
|
|
$next_url = Context::get('articles')->next_url; |
|
259
|
|
|
|
|
260
|
|
|
break; |
|
261
|
|
|
case 'deleted' : |
|
262
|
|
|
// 문서 전체를 신디케이션에서 삭제 |
|
263
|
|
|
Context::set('deleted', $this->getArticles($module_srl, $page, $startTime, $endTime, 'deleted',$site_info->id)); |
|
264
|
|
|
$next_url = Context::get('deleted')->next_url; |
|
265
|
|
|
break; |
|
266
|
|
|
default : |
|
267
|
|
|
$this->setTemplateFile('site.info'); |
|
268
|
|
|
break; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
// 다음 페이지가 있다면 다시 신디케이션 호출 |
|
272
|
|
|
if($next_url) |
|
|
|
|
|
|
273
|
|
|
{ |
|
274
|
|
|
$oSyndicationController = getController('syndication'); |
|
275
|
|
|
$oSyndicationController->ping(Context::get('id'), Context::get('type'), ++$page); |
|
276
|
|
|
} |
|
277
|
|
|
break; |
|
278
|
|
|
case 'channel' : |
|
279
|
|
|
$channel_info = new stdClass; |
|
280
|
|
|
$channel_info->id = $this->getID('channel', $module_info->module_srl); |
|
281
|
|
|
$channel_info->site_title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl); |
|
282
|
|
|
$channel_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl); |
|
283
|
|
|
$channel_info->updated = date("Y-m-d\\TH:i:s").$time_zone; |
|
284
|
|
|
$channel_info->self_href = $this->getSelfHref($channel_info->id, $type); |
|
285
|
|
|
$channel_info->site_url = getFullSiteUrl($this->uri_scheme . $this->site_url, ''); |
|
286
|
|
|
$channel_info->alternative_href = $this->getChannelAlternativeHref($module_info->module_srl); |
|
287
|
|
|
$channel_info->summary = $module_info->description; |
|
288
|
|
View Code Duplication |
if($module_info->module == "textyle") |
|
289
|
|
|
{ |
|
290
|
|
|
$channel_info->type = "blog"; |
|
291
|
|
|
$channel_info->rss_href = getFullSiteUrl($module_info->domain, '', 'mid', $module_info->mid, 'act', 'rss'); |
|
292
|
|
|
} |
|
293
|
|
|
else |
|
294
|
|
|
{ |
|
295
|
|
|
$channel_info->type = "web"; |
|
296
|
|
|
} |
|
297
|
|
|
$except_module_srls = $this->getExceptModuleSrls(); |
|
298
|
|
|
if($except_module_srls) |
|
|
|
|
|
|
299
|
|
|
{ |
|
300
|
|
|
$args->except_modules = implode(',',$except_module_srls); |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
$output = executeQuery('syndication.getSiteUpdatedTime', $args); |
|
304
|
|
View Code Duplication |
if($output->data) $channel_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)).$time_zone; |
|
305
|
|
|
Context::set('channel_info', $channel_info); |
|
306
|
|
|
|
|
307
|
|
|
$this->setTemplateFile('channel'); |
|
308
|
|
|
switch($type) { |
|
309
|
|
|
case 'article' : |
|
310
|
|
|
Context::set('articles', $this->getArticles($module_srl, $page, $startTime, $endTime, 'article', $channel_info->id)); |
|
311
|
|
|
break; |
|
312
|
|
|
case 'deleted' : |
|
313
|
|
|
Context::set('deleted', $this->getDeleted($module_srl, $page, $startTime, $endTime, 'deleted', $channel_info->id)); |
|
314
|
|
|
break; |
|
315
|
|
|
default : |
|
316
|
|
|
$this->setTemplateFile('channel.info'); |
|
317
|
|
|
break; |
|
318
|
|
|
} |
|
319
|
|
|
break; |
|
320
|
|
|
|
|
321
|
|
|
case 'article': |
|
322
|
|
|
$channel_info = new stdClass; |
|
323
|
|
|
$channel_info->id = $this->getID('channel', $module_info->module_srl); |
|
324
|
|
|
$channel_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl); |
|
325
|
|
|
$channel_info->site_title = $site_config->siteTitle; |
|
326
|
|
|
if(!$channel_info->site_title) { |
|
327
|
|
|
$channel_info->site_title = $channel_info->title; |
|
328
|
|
|
} |
|
329
|
|
|
$channel_info->updated = date("Y-m-d\\TH:i:s").$time_zone; |
|
330
|
|
|
$channel_info->self_href = $this->getSelfHref($channel_info->id, $type); |
|
331
|
|
|
$channel_info->site_url = getFullSiteUrl($this->uri_scheme . $this->site_url, ''); |
|
332
|
|
|
$channel_info->alternative_href = $this->getChannelAlternativeHref($module_info->module_srl); |
|
333
|
|
|
$channel_info->webmaster_name = $member_config->webmaster_name; |
|
334
|
|
|
$channel_info->webmaster_email = $member_config->webmaster_email; |
|
335
|
|
|
|
|
336
|
|
|
$except_module_srls = $this->getExceptModuleSrls(); |
|
337
|
|
|
if($except_module_srls) |
|
|
|
|
|
|
338
|
|
|
{ |
|
339
|
|
|
$args->except_modules = implode(',',$except_module_srls); |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
$output = executeQuery('syndication.getSiteUpdatedTime', $args); |
|
343
|
|
View Code Duplication |
if($output->data) $channel_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)).$time_zone; |
|
344
|
|
|
Context::set('channel_info', $channel_info); |
|
345
|
|
|
Context::set('member_config', $member_config); |
|
346
|
|
|
|
|
347
|
|
|
$this->setTemplateFile('channel'); |
|
348
|
|
|
switch($type) { |
|
349
|
|
|
case "article" : |
|
350
|
|
|
$articles = new stdClass; |
|
351
|
|
|
$articles->list = array($this->getArticle($document_srl)); |
|
352
|
|
|
Context::set('articles', $articles); |
|
353
|
|
|
break; |
|
354
|
|
|
|
|
355
|
|
|
case "deleted" : |
|
356
|
|
|
$deleted = new stdClass; |
|
357
|
|
|
$deleted->list = $this->getDeletedByDocumentSrl($document_srl); |
|
358
|
|
|
Context::set('deleted', $deleted); |
|
359
|
|
|
break; |
|
360
|
|
|
} |
|
361
|
|
|
break; |
|
362
|
|
|
} |
|
363
|
|
|
} else { |
|
364
|
|
|
Context::set('message', $error); |
|
|
|
|
|
|
365
|
|
|
$this->setTemplateFile('error'); |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
$this->setTemplatePath($this->module_path.'tpl'); |
|
369
|
|
|
Context::setResponseMethod('XMLRPC'); |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
// @DEPRECATED |
|
373
|
|
|
function getChannels() { |
|
374
|
|
|
if($module_srls) $args->module_srls = $module_srls; |
|
|
|
|
|
|
375
|
|
|
if(count($this->granted_modules)) $args->except_module_srls = implode(',',$this->granted_modules); |
|
376
|
|
|
$output = executeQueryArray('syndication.getModules', $args); |
|
377
|
|
|
|
|
378
|
|
|
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3); |
|
379
|
|
|
Context::set('time_zone', $time_zone); |
|
380
|
|
|
|
|
381
|
|
|
if($output->data) { |
|
382
|
|
|
foreach($output->data as $module_info) { |
|
383
|
|
|
unset($obj); |
|
384
|
|
|
$obj = new stdClass; |
|
385
|
|
|
$obj->id = $this->getID('channel', $module_info->module_srl); |
|
386
|
|
|
$obj->title = $this->handleLang($module_info->browser_title, $module_info->site_srl); |
|
387
|
|
|
$obj->updated = date("Y-m-d\\TH:i:s").$time_zone; |
|
388
|
|
|
$obj->self_href = $this->getSelfHref($obj->id, 'channel'); |
|
389
|
|
|
$obj->alternative_href = $this->getChannelAlternativeHref($module_info); |
|
390
|
|
|
$obj->summary = $module_info->description; |
|
391
|
|
View Code Duplication |
if($module_info->module == "textyle") |
|
392
|
|
|
{ |
|
393
|
|
|
$obj->type = "blog"; |
|
394
|
|
|
$obj->rss_href = getFullSiteUrl($module_info->domain, '', 'mid', $module_info->mid, 'act', 'rss'); |
|
395
|
|
|
} |
|
396
|
|
|
else |
|
397
|
|
|
{ |
|
398
|
|
|
$obj->type = "web"; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
$list[] = $obj; |
|
|
|
|
|
|
402
|
|
|
} |
|
403
|
|
|
} |
|
404
|
|
|
return $list; |
|
|
|
|
|
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
function getArticle($document_srl) { |
|
408
|
|
|
if($this->site_url==null) $this->init(); |
|
409
|
|
|
|
|
410
|
|
|
$oDocumentModel = getModel('document'); |
|
411
|
|
|
$oDocument = $oDocumentModel->getDocument($document_srl,false,false); |
|
412
|
|
|
if(!$oDocument->isExists()) return; |
|
413
|
|
|
|
|
414
|
|
|
$val = $oDocument->getObjectVars(); |
|
415
|
|
|
|
|
416
|
|
|
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3); |
|
417
|
|
|
Context::set('time_zone', $time_zone); |
|
418
|
|
|
|
|
419
|
|
|
$mdoule_info = self::$modules[$oDocument->get('module_srl')]; |
|
|
|
|
|
|
420
|
|
|
|
|
421
|
|
|
$article = new stdClass(); |
|
422
|
|
|
$article->id = $this->getID('article', $oDocument->get('module_srl').'-'.$oDocument->get('document_srl')); |
|
423
|
|
|
$article->updated = date("Y-m-d\\TH:i:s", ztime($oDocument->get('last_update'))).$time_zone; |
|
424
|
|
|
$article->published = date("Y-m-d\\TH:i:s", ztime($oDocument->get('regdate'))).$time_zone; |
|
425
|
|
|
$article->alternative_href = $this->getAlternativeHref($oDocument->get('document_srl'), $oDocument->get('module_srl')); |
|
426
|
|
|
$article->channel_alternative_href = $this->getChannelAlternativeHref($oDocument->get('module_srl')); |
|
427
|
|
|
$article->nick_name = (!$oDocument->get('nick_name')) ? $oDocument->get('user_name') : $oDocument->get('nick_name'); |
|
428
|
|
|
$article->title = $oDocument->getTitle(); |
|
429
|
|
|
$article->content = $oDocument->get('content'); |
|
430
|
|
|
if($val->category_srl) { |
|
431
|
|
|
$category = $oDocumentModel->getCategory($val->category_srl); |
|
432
|
|
|
$category_title = $category->title; |
|
433
|
|
|
$article->category = new stdClass(); |
|
434
|
|
|
$article->category->term = $val->category_srl; |
|
435
|
|
|
$article->category->label = $category_title; |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
return $article; |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
|
|
function getArticles($module_srl = null, $page=1, $startTime = null, $endTime = null, $type = null, $id = null) { |
|
442
|
|
|
if($this->site_url==null) $this->init(); |
|
443
|
|
|
|
|
444
|
|
|
$args = new stdClass; |
|
445
|
|
|
if($module_srl) $args->module_srl = $module_srl; |
|
446
|
|
|
if($startTime) $args->start_date = $this->getDate($startTime); |
|
447
|
|
|
if($endTime) $args->end_date = $this->getDate($endTime); |
|
448
|
|
|
if(count($this->granted_modules)) $args->except_module_srls = implode(',',$this->granted_modules); |
|
449
|
|
|
$args->page = $page; |
|
450
|
|
|
$output = executeQueryArray('syndication.getDocumentList', $args); |
|
451
|
|
|
$cur_page = $output->page_navigation->cur_page; |
|
452
|
|
|
$total_page = $output->page_navigation->last_page; |
|
453
|
|
|
|
|
454
|
|
|
$result = new stdClass; |
|
455
|
|
|
$result->next_url = null; |
|
456
|
|
|
$result->list = array(); |
|
457
|
|
|
|
|
458
|
|
|
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3); |
|
459
|
|
|
Context::set('time_zone', $time_zone); |
|
460
|
|
|
|
|
461
|
|
View Code Duplication |
if($cur_page<$total_page) { |
|
462
|
|
|
$next_url = $this->getSelfHref($id, $type); |
|
463
|
|
|
if($startTime) $next_url .= '&startTime='.$startTime; |
|
464
|
|
|
if($endTime) $next_url .= '&endTime='.$endTime; |
|
465
|
|
|
$result->next_url = $next_url.'&page='.($cur_page+1); |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
if($output->data) { |
|
469
|
|
|
foreach($output->data as $key => $val) { |
|
470
|
|
|
$article = new stdClass(); |
|
471
|
|
|
$article->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl); |
|
472
|
|
|
$article->updated = date("Y-m-d\\TH:i:s", ztime($val->last_update)).$time_zone; |
|
473
|
|
|
$article->published = date("Y-m-d\\TH:i:s", ztime($val->regdate)).$time_zone; |
|
474
|
|
|
$article->alternative_href = getFullSiteUrl($this->uri_scheme . $this->site_url, '', 'document_srl', $val->document_srl); |
|
475
|
|
|
$article->channel_alternative_href = $this->getChannelAlternativeHref($val->module_srl); |
|
476
|
|
|
$article->nick_name = (!$val->nick_name) ? $val->user_name : $val->nick_name; |
|
477
|
|
|
$article->content = $val->content; |
|
478
|
|
|
$result->list[] = $article; |
|
479
|
|
|
} |
|
480
|
|
|
} |
|
481
|
|
|
return $result; |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
function getDeleted($module_srl = null, $page = 1, $startTime = null, $endTime = null, $type = null, $id = null) { |
|
485
|
|
|
if($this->site_url==null) $this->init(); |
|
486
|
|
|
|
|
487
|
|
|
$args = new stdClass; |
|
488
|
|
|
if($module_srl) $args->module_srl= $module_srl; |
|
489
|
|
|
if($startTime) $args->start_date = $this->getDate($startTime); |
|
490
|
|
|
if($endTime) $args->end_date = $this->getDate($endTime); |
|
491
|
|
|
$args->page = $page; |
|
492
|
|
|
|
|
493
|
|
|
$output = executeQueryArray('syndication.getDeletedList', $args); |
|
494
|
|
|
|
|
495
|
|
|
$cur_page = $output->page_navigation->cur_page; |
|
496
|
|
|
$total_page = $output->page_navigation->last_page; |
|
497
|
|
|
|
|
498
|
|
|
$result = new stdClass; |
|
499
|
|
|
$result->next_url = null; |
|
500
|
|
|
$result->list = array(); |
|
501
|
|
|
|
|
502
|
|
|
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3); |
|
503
|
|
|
Context::set('time_zone', $time_zone); |
|
504
|
|
|
|
|
505
|
|
View Code Duplication |
if($cur_page<$total_page) { |
|
506
|
|
|
$next_url = $this->getSelfHref($id, $type); |
|
507
|
|
|
if($startTime) $next_url .= '&startTime='.$startTime; |
|
508
|
|
|
if($endTime) $next_url .= '&endTime='.$endTime; |
|
509
|
|
|
$result->next_url = $next_url . '&page='.($cur_page+1); |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
if($output->data) { |
|
513
|
|
|
foreach($output->data as $key => $val) { |
|
514
|
|
|
$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl); |
|
515
|
|
|
$val->deleted = date("Y-m-d\\TH:i:s", ztime($val->regdate)).$time_zone; |
|
516
|
|
|
$val->alternative_href = getFullSiteUrl($this->uri_scheme . $this->site_url, '', 'document_srl', $val->document_srl); |
|
517
|
|
|
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl); |
|
518
|
|
|
$output->data[$key] = $val; |
|
519
|
|
|
} |
|
520
|
|
|
$result->list = $output->data; |
|
521
|
|
|
} |
|
522
|
|
|
return $result; |
|
523
|
|
|
} |
|
524
|
|
|
|
|
525
|
|
|
function getDeletedByDocumentSrl($document_srl) |
|
526
|
|
|
{ |
|
527
|
|
|
static $module_info = array(); |
|
528
|
|
|
|
|
529
|
|
|
$args = new stdClass; |
|
530
|
|
|
$args->document_srl = $document_srl; |
|
531
|
|
|
$output = executeQueryArray('syndication.getDeletedList', $args); |
|
532
|
|
|
|
|
533
|
|
|
$time_zone = substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3); |
|
534
|
|
|
Context::set('time_zone', $time_zone); |
|
535
|
|
|
|
|
536
|
|
|
foreach($output->data as $key => $val) |
|
537
|
|
|
{ |
|
538
|
|
|
$module_srl = $val->module_srl; |
|
539
|
|
|
|
|
540
|
|
View Code Duplication |
if(!isset($module_info[$module_srl])) |
|
541
|
|
|
{ |
|
542
|
|
|
$args = new stdClass; |
|
543
|
|
|
$args->module_srl = $module_srl; |
|
544
|
|
|
$module_output = executeQuery('syndication.getModuleSiteInfo', $args); |
|
545
|
|
|
if($module_output->data) $module_info[$module_srl] = $module_output->data; |
|
546
|
|
|
else $module_info[$module_srl] = null; |
|
547
|
|
|
} |
|
548
|
|
|
|
|
549
|
|
|
$val->id = $this->getID('article', $val->module_srl.'-'.$val->document_srl); |
|
550
|
|
|
$val->deleted = date("Y-m-d\\TH:i:s", ztime($val->regdate)).$time_zone; |
|
551
|
|
|
$val->alternative_href = getFullSiteUrl($this->uri_scheme . $this->site_url, '', 'mid', $module_info[$module_srl]->mid, 'document_srl', $val->document_srl); |
|
552
|
|
|
$val->channel_id = $this->getID('channel', $val->module_srl.'-'.$val->document_srl); |
|
553
|
|
|
$output->data[$key] = $val; |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
return $output->data; |
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
|
|
function getID($type, $target_id = null) { |
|
560
|
|
|
if($this->site_url==null) $this->init(); |
|
561
|
|
|
|
|
562
|
|
|
return sprintf('tag:%s,%d:%s', $this->site_url, $this->year, $type) . ($target_id?':'.$target_id:''); |
|
563
|
|
|
} |
|
564
|
|
|
|
|
565
|
|
|
function getChannelAlternativeHref($module_srl) { |
|
566
|
|
|
static $module_info = array(); |
|
567
|
|
View Code Duplication |
if(!isset($module_info[$module_srl])) { |
|
568
|
|
|
$args = new stdClass; |
|
569
|
|
|
$args->module_srl = $module_srl; |
|
570
|
|
|
$output = executeQuery('syndication.getModuleSiteInfo', $args); |
|
571
|
|
|
if($output->data) $module_info[$module_srl] = $output->data; |
|
572
|
|
|
else $module_info[$module_srl] = null; |
|
573
|
|
|
} |
|
574
|
|
|
|
|
575
|
|
|
if(is_null($module_info[$module_srl])) return $this->site_url; |
|
576
|
|
|
|
|
577
|
|
|
$domain = $module_info[$module_srl]->domain; |
|
578
|
|
|
$url = getFullSiteUrl($domain, '', 'mid', $module_info[$module_srl]->mid); |
|
579
|
|
View Code Duplication |
if(substr($url,0,1)=='/') $domain = $this->uri_scheme . $this->site_url . $url; |
|
|
|
|
|
|
580
|
|
|
return $url; |
|
581
|
|
|
} |
|
582
|
|
|
|
|
583
|
|
|
function getSelfHref($id, $type = null) { |
|
584
|
|
|
if($this->site_url==null) $this->init(); |
|
585
|
|
|
|
|
586
|
|
|
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); |
|
587
|
|
|
} |
|
588
|
|
|
|
|
589
|
|
|
/** |
|
590
|
|
|
* 문서의 고유 URL 반환 |
|
591
|
|
|
*/ |
|
592
|
|
|
function getAlternativeHref($document_srl, $module_srl) { |
|
593
|
|
|
if($this->site_url==null) $this->init(); |
|
594
|
|
|
|
|
595
|
|
|
if(!self::$modules[$module_srl]) { |
|
596
|
|
|
$args = new stdClass; |
|
597
|
|
|
$args->module_srls = $module_srl; |
|
598
|
|
|
$output = executeQuery('syndication.getModules', $args); |
|
599
|
|
|
$module_info = $output->data; |
|
600
|
|
|
self::$modules[$module_srl] = $module_info; |
|
601
|
|
|
} else { |
|
602
|
|
|
$module_info = self::$modules[$module_srl]; |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
$domain = $module_info->domain; |
|
606
|
|
|
$url = getFullSiteUrl($domain, '', 'mid', $module_info->mid, 'document_srl', $document_srl); |
|
607
|
|
View Code Duplication |
if(substr($url,0,1)=='/') $domain = $this->uri_scheme . $this->site_url.$url; |
|
|
|
|
|
|
608
|
|
|
return $url; |
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
function getDate($date) { |
|
612
|
|
|
$time = strtotime($date); |
|
613
|
|
|
if($time == -1) $time = ztime(str_replace(array('-','T',':'),'',$date)); |
|
614
|
|
|
return date('YmdHis', $time); |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
function getResentPingLogPath() |
|
618
|
|
|
{ |
|
619
|
|
|
$target_filename = _XE_PATH_.'files/cache/tmp/syndication_ping_log'; |
|
620
|
|
|
if(!file_exists($target_filename)) |
|
621
|
|
|
{ |
|
622
|
|
|
FileHandler::writeFile($target_filename, ''); |
|
623
|
|
|
} |
|
624
|
|
|
return $target_filename; |
|
625
|
|
|
} |
|
626
|
|
|
|
|
627
|
|
|
function setResentPingLog($msg) |
|
628
|
|
|
{ |
|
629
|
|
|
$file_path = $this->getResentPingLogPath(); |
|
630
|
|
|
|
|
631
|
|
|
$args = new stdClass; |
|
632
|
|
|
$args->regdate = date('YmdHis'); |
|
633
|
|
|
$args->message = urlencode($msg); |
|
634
|
|
|
|
|
635
|
|
|
$list = $this->getResentPingLog(); |
|
636
|
|
|
if(count($list)>=10) |
|
637
|
|
|
{ |
|
638
|
|
|
array_pop($list); |
|
639
|
|
|
} |
|
640
|
|
|
array_unshift($list, $args); |
|
641
|
|
|
FileHandler::writeFile($file_path, serialize($list)); |
|
642
|
|
|
|
|
643
|
|
|
return true; |
|
644
|
|
|
} |
|
645
|
|
|
|
|
646
|
|
|
function getResentPingLog() |
|
647
|
|
|
{ |
|
648
|
|
|
$file_path = $this->getResentPingLogPath(); |
|
649
|
|
|
$str = FileHandler::readFile($file_path); |
|
650
|
|
|
$list = array(); |
|
651
|
|
|
if($str) |
|
652
|
|
|
{ |
|
653
|
|
|
$list = unserialize($str); |
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
return $list; |
|
657
|
|
|
} |
|
658
|
|
|
} |
|
659
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.