XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
rss.view.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class rssView extends rss
9 {
15  function init()
16  {
17  }
18 
27  function rss($document_list = null, $rss_title = null, $add_description = null)
28  {
29  $oDocumentModel = getModel('document');
30  $oModuleModel = getModel('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::getRequestVars()->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  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  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('\'', '&apos;',$info->title);
108  if($config->feed_description)
109  {
110  $info->description = str_replace('\'', '&apos;', htmlspecialchars($config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
111  }
112  else
113  {
114  $info->description = str_replace('\'', '&apos;', 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('\'', '&apos;', htmlspecialchars($feed_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
118  if(!$info->feed_copyright)
119  {
120  $info->feed_copyright = str_replace('\'', '&apos;', 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('\'', '&apos;', htmlspecialchars($info->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
138  $info->description = str_replace('\'', '&apos;', htmlspecialchars($total_config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
139  $info->link = Context::getRequestUri();
140  $info->feed_copyright = str_replace('\'', '&apos;', 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  if($total_config->image) $info->image = Context::getRequestUri().str_replace('\'', '&apos;', 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  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 
217  function atom()
218  {
219  Context::set('format', 'atom');
220  $this->rss();
221  }
222 
228  function dispError()
229  {
230  // Prepare the output message
231  $this->rss(null, null, Context::getLang('msg_rss_is_disabled') );
232  }
233 
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 BaseObject();
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 BaseObject();
263  }
264 }
265 /* End of file rss.view.php */
266 /* Location: ./modules/rss/rss.view.php */
setTemplateFile($filename)
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
$obj
Definition: ko.install.php:262
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
Definition: config.inc.php:324
$output
Definition: ko.install.php:193
rss($document_list=null, $rss_title=null, $add_description=null)
Definition: rss.view.php:27
triggerDispRssAdditionSetup(&$obj)
Definition: rss.view.php:241
set($key, $val, $set_to_get_vars=0)
init()
Definition: rss.view.php:15
$module_srl
integer value to represent a run-time instance of Module (XE Module)
$args
Definition: ko.install.php:185
$mid
string to represent run-time instance of Module (XE Module)
$oDocumentModel
Definition: ko.install.php:259
getLang($code)
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)
getModel($module_name)
Definition: func.inc.php:145
setResponseMethod($method= 'HTML')
Definition: rss.class.php:8
$oModuleController
Definition: ko.install.php:287
getUrl()
Definition: func.inc.php:297
dispError()
Definition: rss.view.php:228