1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
/** |
4
|
|
|
* The view class of the rss module |
5
|
|
|
* |
6
|
|
|
* @author NAVER ([email protected]) |
7
|
|
|
*/ |
8
|
|
|
class rssView extends rss |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Initialization |
12
|
|
|
* |
13
|
|
|
* @return void |
14
|
|
|
*/ |
15
|
|
|
function init() |
16
|
|
|
{ |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Feed output. |
21
|
|
|
* When trying to directly print out the RSS, the results variable can be directly specified through $oRssView->rss($document_list) |
22
|
|
|
* |
23
|
|
|
* @param Object $document_list Document list |
24
|
|
|
* @param string $rss_title Rss title |
25
|
|
|
* @param string $add_description Add description |
26
|
|
|
*/ |
27
|
|
|
function rss($document_list = null, $rss_title = null, $add_description = null) |
28
|
|
|
{ |
29
|
|
|
$oDocumentModel = getModel('document'); |
30
|
|
|
$oModuleModel = getModel('module'); |
31
|
|
|
$oModuleController = getController('module'); |
32
|
|
|
// Get the content and information for the current requested module if the method is not called from another module |
33
|
|
|
if(!$document_list) |
34
|
|
|
{ |
35
|
|
|
$site_module_info = Context::get('site_module_info'); |
36
|
|
|
$site_srl = $site_module_info->site_srl; |
37
|
|
|
$mid = Context::get('mid'); // The target module id, if absent, then all |
38
|
|
|
$start_date = (int)Context::get('start_date'); |
39
|
|
|
$end_date = (int)Context::get('end_date'); |
40
|
|
|
|
41
|
|
|
$module_srls = array(); |
42
|
|
|
$rss_config = array(); |
|
|
|
|
43
|
|
|
$total_config = ''; |
|
|
|
|
44
|
|
|
$total_config = $oModuleModel->getModuleConfig('rss'); |
45
|
|
|
// If one is specified, extract only for this mid |
46
|
|
|
if($mid) |
47
|
|
|
{ |
48
|
|
|
$module_srl = $this->module_info->module_srl; |
|
|
|
|
49
|
|
|
$config = $oModuleModel->getModulePartConfig('rss', $module_srl); |
50
|
|
View Code Duplication |
if($config->open_rss && $config->open_rss != 'N') |
51
|
|
|
{ |
52
|
|
|
$module_srls[] = $module_srl; |
53
|
|
|
$open_rss_config[$module_srl] = $config->open_rss; |
|
|
|
|
54
|
|
|
} |
55
|
|
|
// If mid is not selected, then get all |
56
|
|
|
} |
57
|
|
|
else |
58
|
|
|
{ |
59
|
|
|
if($total_config->use_total_feed != 'N') |
60
|
|
|
{ |
61
|
|
|
$rss_config = $oModuleModel->getModulePartConfigs('rss', $site_srl); |
62
|
|
|
if($rss_config) |
63
|
|
|
{ |
64
|
|
|
foreach($rss_config as $module_srl => $config) |
65
|
|
|
{ |
66
|
|
View Code Duplication |
if($config && $config->open_rss != 'N' && $config->open_total_feed != 'T_N') |
67
|
|
|
{ |
68
|
|
|
$module_srls[] = $module_srl; |
69
|
|
|
$open_rss_config[$module_srl] = $config->open_rss; |
|
|
|
|
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if(!count($module_srls) && !$add_description) return $this->dispError(); |
|
|
|
|
77
|
|
|
|
78
|
|
|
$info = new stdClass; |
79
|
|
|
$args = new stdClass; |
80
|
|
|
|
81
|
|
|
if($module_srls) |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
$args->module_srl = implode(',',$module_srls); |
84
|
|
|
//$module_list = $oModuleModel->getMidList($args); //perhaps module_list varialbles not use |
85
|
|
|
|
86
|
|
|
$args->search_target = 'is_secret'; |
87
|
|
|
$args->search_keyword = 'N'; |
88
|
|
|
$args->page = (int)Context::get('page'); |
89
|
|
|
$args->list_count = 15; |
90
|
|
|
if($total_config->feed_document_count) $args->list_count = $total_config->feed_document_count; |
91
|
|
|
if(!$args->page || $args->page < 1) $args->page = 1; |
92
|
|
|
if($start_date || $start_date != 0) $args->start_date = $start_date; |
93
|
|
|
if($end_date || $end_date != 0) $args->end_date = $end_date; |
94
|
|
|
if($start_date == 0) unset($start_date); |
95
|
|
|
if($end_date == 0) unset($end_date); |
96
|
|
|
|
97
|
|
|
$args->sort_index = 'list_order'; |
98
|
|
|
$args->order_type = 'asc'; |
99
|
|
|
$output = $oDocumentModel->getDocumentList($args); |
100
|
|
|
$document_list = $output->data; |
101
|
|
|
// Extract the feed title and information with Context::getBrowserTitle |
102
|
|
|
if($mid) |
103
|
|
|
{ |
104
|
|
|
$info->title = Context::getBrowserTitle(); |
105
|
|
|
$oModuleController->replaceDefinedLangCode($info->title); |
106
|
|
|
|
107
|
|
|
$info->title = str_replace('\'', ''',$info->title); |
108
|
|
|
if($config->feed_description) |
109
|
|
|
{ |
110
|
|
|
$info->description = str_replace('\'', ''', htmlspecialchars($config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
else |
113
|
|
|
{ |
114
|
|
|
$info->description = str_replace('\'', ''', htmlspecialchars($this->module_info->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
|
|
|
115
|
|
|
} |
116
|
|
|
$info->link = getUrl('','mid',$mid); |
117
|
|
|
$info->feed_copyright = str_replace('\'', ''', htmlspecialchars($feed_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
|
|
|
118
|
|
View Code Duplication |
if(!$info->feed_copyright) |
119
|
|
|
{ |
120
|
|
|
$info->feed_copyright = str_replace('\'', ''', htmlspecialchars($total_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
if(!$info->title) |
127
|
|
|
{ |
128
|
|
|
if($rss_title) $info->title = $rss_title; |
|
|
|
|
129
|
|
|
else if($total_config->feed_title) $info->title = $total_config->feed_title; |
|
|
|
|
130
|
|
|
else |
131
|
|
|
{ |
132
|
|
|
$site_module_info = Context::get('site_module_info'); |
133
|
|
|
$info->title = $site_module_info->browser_title; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
$oModuleController->replaceDefinedLangCode($info->title); |
137
|
|
|
$info->title = str_replace('\'', ''', htmlspecialchars($info->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
138
|
|
|
$info->description = str_replace('\'', ''', htmlspecialchars($total_config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
139
|
|
|
$info->link = Context::getRequestUri(); |
140
|
|
|
$info->feed_copyright = str_replace('\'', ''', htmlspecialchars($total_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
141
|
|
|
} |
142
|
|
|
if($add_description) $info->description .= "\r\n".$add_description; |
|
|
|
|
143
|
|
|
|
144
|
|
View Code Duplication |
if($total_config->image) $info->image = Context::getRequestUri().str_replace('\'', ''', htmlspecialchars($total_config->image, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
145
|
|
|
switch(Context::get('format')) |
146
|
|
|
{ |
147
|
|
|
case 'atom': |
148
|
|
|
$info->date = date('Y-m-d\TH:i:sP'); |
149
|
|
|
if($mid) { $info->id = getUrl('','mid',$mid,'act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } |
|
|
|
|
150
|
|
View Code Duplication |
else { $info->id = getUrl('','module','rss','act','atom','page',Context::get('page'),'start_date',Context::get('start_date'),'end_date',Context::get('end_date')); } |
151
|
|
|
break; |
152
|
|
|
case 'rss1.0': |
153
|
|
|
$info->date = date('Y-m-d\TH:i:sP'); |
154
|
|
|
break; |
155
|
|
|
default: |
156
|
|
|
$info->date = date("D, d M Y H:i:s").' '.$GLOBALS['_time_zone']; |
157
|
|
|
break; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
if($_SERVER['HTTPS']=='on') $proctcl = 'https://'; |
161
|
|
|
else $proctcl = 'http://'; |
162
|
|
|
|
163
|
|
|
$temp_link = explode('/', $info->link); |
164
|
|
|
if($temp_link[0]=='' && $info->link) |
165
|
|
|
{ |
166
|
|
|
$info->link = $proctcl.$_SERVER['HTTP_HOST'].$info->link; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
$temp_id = explode('/', $info->id); |
170
|
|
|
if($temp_id[0]=='' && $info->id) |
171
|
|
|
{ |
172
|
|
|
$info->id = $proctcl.$_SERVER['HTTP_HOST'].$info->id; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
$info->language = str_replace('jp','ja',Context::getLangType()); |
176
|
|
|
// Set the variables used in the RSS output |
177
|
|
|
Context::set('info', $info); |
|
|
|
|
178
|
|
|
Context::set('feed_config', $config); |
179
|
|
|
Context::set('open_rss_config', $open_rss_config); |
|
|
|
|
180
|
|
|
Context::set('document_list', $document_list); |
181
|
|
|
// Force the result output to be of XMLRPC |
182
|
|
|
Context::setResponseMethod("XMLRPC"); |
183
|
|
|
// Perform the preprocessing function of the editor component as the results are obtained |
184
|
|
|
$path = $this->module_path.'tpl/'; |
|
|
|
|
185
|
|
|
//if($args->start_date || $args->end_date) $file = 'xe_rss'; |
186
|
|
|
//else $file = 'rss20'; |
187
|
|
|
switch (Context::get('format')) |
188
|
|
|
{ |
189
|
|
|
case 'xe': |
190
|
|
|
$file = 'xe_rss'; |
191
|
|
|
break; |
192
|
|
|
case 'atom': |
193
|
|
|
$file = 'atom10'; |
194
|
|
|
break; |
195
|
|
|
case 'rss1.0': |
196
|
|
|
$file = 'rss10'; |
197
|
|
|
break; |
198
|
|
|
default: |
199
|
|
|
$file = 'rss20'; |
200
|
|
|
break; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
$oTemplate = new TemplateHandler(); |
204
|
|
|
|
205
|
|
|
$content = $oTemplate->compile($path, $file); |
206
|
|
|
Context::set('content', $content); |
207
|
|
|
// Set the template file |
208
|
|
|
$this->setTemplatePath($path); |
209
|
|
|
$this->setTemplateFile('display'); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* ATOM output |
214
|
|
|
* |
215
|
|
|
* @return Object |
216
|
|
|
*/ |
217
|
|
|
function atom() |
218
|
|
|
{ |
219
|
|
|
Context::set('format', 'atom'); |
220
|
|
|
$this->rss(); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Error output |
225
|
|
|
* |
226
|
|
|
* @return Object |
227
|
|
|
*/ |
228
|
|
|
function dispError() |
229
|
|
|
{ |
230
|
|
|
// Prepare the output message |
231
|
|
|
$this->rss(null, null, Context::getLang('msg_rss_is_disabled') ); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Additional configurations for a service module |
236
|
|
|
* Receive the form for the form used by rss |
237
|
|
|
* |
238
|
|
|
* @param string $obj Will be inserted content in template |
239
|
|
|
* @return Object |
240
|
|
|
*/ |
241
|
|
|
function triggerDispRssAdditionSetup(&$obj) |
242
|
|
|
{ |
243
|
|
|
$current_module_srl = Context::get('module_srl'); |
244
|
|
|
$current_module_srls = Context::get('module_srls'); |
245
|
|
|
|
246
|
|
|
if(!$current_module_srl && !$current_module_srls) |
247
|
|
|
{ |
248
|
|
|
// Get information of the selected module |
249
|
|
|
$current_module_info = Context::get('current_module_info'); |
250
|
|
|
$current_module_srl = $current_module_info->module_srl; |
251
|
|
|
if(!$current_module_srl) return new Object(); |
252
|
|
|
} |
253
|
|
|
// Get teh RSS configurations for the selected module |
254
|
|
|
$oRssModel = getModel('rss'); |
255
|
|
|
$rss_config = $oRssModel->getRssModuleConfig($current_module_srl); |
256
|
|
|
Context::set('rss_config', $rss_config); |
257
|
|
|
// Set the template file |
258
|
|
|
$oTemplate = &TemplateHandler::getInstance(); |
259
|
|
|
$tpl = $oTemplate->compile($this->module_path.'tpl', 'rss_module_config'); |
|
|
|
|
260
|
|
|
$obj .= $tpl; |
261
|
|
|
|
262
|
|
|
return new Object(); |
263
|
|
|
} |
264
|
|
|
} |
265
|
|
|
/* End of file rss.view.php */ |
266
|
|
|
/* Location: ./modules/rss/rss.view.php */ |
267
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.