PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/widgets/mcontent/mcontent.class.php

http://xe-core.googlecode.com/
PHP | 821 lines | 678 code | 77 blank | 66 comment | 107 complexity | 111bfab8145bfa829b01728f3154fa38 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause
  1. <?php
  2. /**
  3. * @class mcontent
  4. * @author NHN (developers@xpressengine.com)
  5. * @brief widget to display mcontent
  6. * @version 0.1
  7. */
  8. class mcontent extends WidgetHandler
  9. {
  10. /**
  11. * @brief Widget execution
  12. *
  13. * Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
  14. * After generating the result, do not print but return it.
  15. */
  16. function proc($args)
  17. {
  18. // Targets to sort
  19. if(!in_array($args->order_target, array('list_order','update_order'))) $args->order_target = 'list_order';
  20. // Sort order
  21. if(!in_array($args->order_type, array('asc','desc'))) $args->order_type = 'asc';
  22. // The number of displayed lists
  23. $args->list_count = (int)$args->list_count;
  24. if(!$args->list_count) $args->list_count = 5;
  25. // Cut the length of the title
  26. if(!$args->subject_cut_size) $args->subject_cut_size = 0;
  27. // Cut the length of contents
  28. if(!$args->content_cut_size) $args->content_cut_size = 100;
  29. // Viewing options
  30. $args->option_view_arr = explode(',',$args->option_view);
  31. // markup options
  32. if(!$args->markup_type) $args->markup_type = 'list';
  33. // Set variables for internal use
  34. $oModuleModel = &getModel('module');
  35. $module_srls = $args->modules_info = $args->module_srls_info = $args->mid_lists = array();
  36. $site_module_info = Context::get('site_module_info');
  37. // List URLs if a type is RSS
  38. if($args->content_type == 'rss')
  39. {
  40. $args->rss_urls = array();
  41. $rss_urls = array_unique(array($args->rss_url0,$args->rss_url1,$args->rss_url2,$args->rss_url3,$args->rss_url4));
  42. for($i=0,$c=count($rss_urls);$i<$c;$i++)
  43. {
  44. if($rss_urls[$i]) $args->rss_urls[] = $rss_urls[$i];
  45. }
  46. // Get module information after listing module_srls if the module is not RSS
  47. }
  48. else
  49. {
  50. // Apply to all modules in the site if a target module is not specified
  51. if(!$args->module_srls)
  52. {
  53. $obj = new stdClass();
  54. $obj->site_srl = (int)$site_module_info->site_srl;
  55. $output = executeQueryArray('widgets.content.getMids', $obj);
  56. if($output->data)
  57. {
  58. foreach($output->data as $key => $val)
  59. {
  60. $args->modules_info[$val->mid] = $val;
  61. $args->module_srls_info[$val->module_srl] = $val;
  62. $args->mid_lists[$val->module_srl] = $val->mid;
  63. $module_srls[] = $val->module_srl;
  64. }
  65. }
  66. $args->modules_info = $oModuleModel->getMidList($obj);
  67. // Apply to the module only if a target module is specified
  68. }
  69. else
  70. {
  71. $obj->module_srls = $args->module_srls;
  72. $output = executeQueryArray('widgets.content.getMids', $obj);
  73. if($output->data)
  74. {
  75. foreach($output->data as $key => $val)
  76. {
  77. $args->modules_info[$val->mid] = $val;
  78. $args->module_srls_info[$val->module_srl] = $val;
  79. $module_srls[] = $val->module_srl;
  80. }
  81. $idx = explode(',',$args->module_srls);
  82. for($i=0,$c=count($idx);$i<$c;$i++)
  83. {
  84. $srl = $idx[$i];
  85. if(!$args->module_srls_info[$srl]) continue;
  86. $args->mid_lists[$srl] = $args->module_srls_info[$srl]->mid;
  87. }
  88. }
  89. }
  90. // Exit if no module is found
  91. if(!count($args->modules_info)) return Context::get('msg_not_founded');
  92. $args->module_srl = implode(',',$module_srls);
  93. }
  94. /**
  95. * Method is separately made because content extraction, articles, comments, trackbacks, RSS and other elements exist
  96. */
  97. // tab mode
  98. if($args->tab_type == 'none' || $args->tab_type == '')
  99. {
  100. switch($args->content_type)
  101. {
  102. case 'comment':
  103. $content_items = $this->_getCommentItems($args);
  104. break;
  105. case 'image':
  106. $content_items = $this->_getImageItems($args);
  107. break;
  108. case 'rss':
  109. $content_items = $this->getRssItems($args);
  110. break;
  111. case 'trackback':
  112. $content_items = $this->_getTrackbackItems($args);
  113. break;
  114. default:
  115. $content_items = $this->_getDocumentItems($args);
  116. break;
  117. }
  118. // If not a tab type
  119. }
  120. else
  121. {
  122. $content_items = array();
  123. switch($args->content_type)
  124. {
  125. case 'comment':
  126. foreach($args->mid_lists as $module_srl => $mid)
  127. {
  128. $args->module_srl = $module_srl;
  129. $content_items[$module_srl] = $this->_getCommentItems($args);
  130. }
  131. break;
  132. case 'image':
  133. foreach($args->mid_lists as $module_srl => $mid)
  134. {
  135. $args->module_srl = $module_srl;
  136. $content_items[$module_srl] = $this->_getImageItems($args);
  137. }
  138. break;
  139. case 'rss':
  140. $content_items = $this->getRssItems($args);
  141. break;
  142. case 'trackback':
  143. foreach($args->mid_lists as $module_srl => $mid){
  144. $args->module_srl = $module_srl;
  145. $content_items[$module_srl] = $this->_getTrackbackItems($args);
  146. }
  147. break;
  148. default:
  149. foreach($args->mid_lists as $module_srl => $mid)
  150. {
  151. $args->module_srl = $module_srl;
  152. $content_items[$module_srl] = $this->_getDocumentItems($args);
  153. }
  154. break;
  155. }
  156. }
  157. $output = $this->_compile($args,$content_items);
  158. return $output;
  159. }
  160. /**
  161. * @brief Return to the list of comments extracted mcontentItem
  162. */
  163. function _getCommentItems($args)
  164. {
  165. // CommentModel:: getCommentList() to take advantage of the variable order
  166. $obj->module_srl = $args->module_srl;
  167. $obj->sort_index = $args->order_target;
  168. $obj->list_count = $args->list_count;
  169. // Get model object of the comment module getCommentList() method runs
  170. $oCommentModel = &getModel('comment');
  171. $output = $oCommentModel->getNewestCommentList($obj);
  172. $content_items = array();
  173. if(!count($output)) return;
  174. foreach($output as $key => $oComment)
  175. {
  176. $attribute = $oComment->getObjectVars();
  177. $title = $oComment->getSummary($args->content_cut_size);
  178. $thumbnail = $oComment->getThumbnail();
  179. $url = sprintf("%s#comment_%s",getUrl('','document_srl',$oComment->get('document_srl')),$oComment->get('comment_srl'));
  180. $attribute->mid = $args->mid_lists[$attribute->module_srl];
  181. $browser_title = $args->module_srls_info[$attribute->module_srl]->browser_title;
  182. $domain = $args->module_srls_info[$attribute->module_srl]->domain;
  183. $content_item = new mcontentItem($browser_title);
  184. $content_item->adds($attribute);
  185. $content_item->setTitle($title);
  186. $content_item->setThumbnail($thumbnail);
  187. $content_item->setLink($url);
  188. $content_item->setDomain($domain);
  189. $content_item->add('mid', $args->mid_lists[$attribute->module_srl]);
  190. $content_items[] = $content_item;
  191. }
  192. return $content_items;
  193. }
  194. function _getDocumentItems($args)
  195. {
  196. // Get model object of the document module and make the result as an object
  197. $oDocumentModel = &getModel('document');
  198. // Get categories
  199. $obj = new stdClass();
  200. $obj->module_srl = $args->module_srl;
  201. $output = executeQueryArray('widgets.content.getCategories',$obj);
  202. if($output->toBool() && $output->data)
  203. {
  204. foreach($output->data as $key => $val)
  205. {
  206. $category_lists[$val->module_srl][$val->category_srl] = $val;
  207. }
  208. }
  209. // Get a list of documents
  210. $obj->module_srl = $args->module_srl;
  211. $obj->sort_index = $args->order_target;
  212. $obj->order_type = $args->order_type=="desc"?"asc":"desc";
  213. $obj->list_count = $args->list_count;
  214. $obj->statusList = array('PUBLIC');
  215. $output = executeQueryArray('widgets.content.getNewestDocuments', $obj);
  216. if(!$output->toBool() || !$output->data) return;
  217. // If the result exists, make each document as an object
  218. $content_items = array();
  219. $first_thumbnail_idx = -1;
  220. if(count($output->data))
  221. {
  222. foreach($output->data as $key => $attribute)
  223. {
  224. $oDocument = new documentItem();
  225. $oDocument->setAttribute($attribute, false);
  226. $GLOBALS['XE_DOCUMENT_LIST'][$oDocument->document_srl] = $oDocument;
  227. $document_srls[] = $oDocument->document_srl;
  228. }
  229. $oDocumentModel->setToAllDocumentExtraVars();
  230. for($i=0,$c=count($document_srls);$i<$c;$i++)
  231. {
  232. $oDocument = $GLOBALS['XE_DOCUMENT_LIST'][$document_srls[$i]];
  233. $document_srl = $oDocument->document_srl;
  234. $module_srl = $oDocument->get('module_srl');
  235. $category_srl = $oDocument->get('category_srl');
  236. $thumbnail = $oDocument->getThumbnail();
  237. $content_item = new mcontentItem( $args->module_srls_info[$module_srl]->browser_title );
  238. $content_item->adds($oDocument->getObjectVars());
  239. $content_item->setTitle($oDocument->getTitleText());
  240. $content_item->setCategory( $category_lists[$module_srl][$category_srl]->title );
  241. $content_item->setDomain( $args->module_srls_info[$module_srl]->domain );
  242. $content_item->setContent($oDocument->getSummary($args->content_cut_size));
  243. $content_item->setLink( getSiteUrl($domain,'','document_srl',$document_srl) );
  244. $content_item->setThumbnail($thumbnail);
  245. $content_item->add('mid', $args->mid_lists[$module_srl]);
  246. if($first_thumbnail_idx==-1 && $thumbnail) $first_thumbnail_idx = $i;
  247. $content_items[] = $content_item;
  248. }
  249. $content_items[0]->setFirstThumbnailIdx($first_thumbnail_idx);
  250. }
  251. return $content_items;
  252. }
  253. function _getImageItems($args)
  254. {
  255. $oDocumentModel = &getModel('document');
  256. $obj->module_srls = $obj->module_srl = $args->module_srl;
  257. $obj->direct_download = 'Y';
  258. $obj->isvalid = 'Y';
  259. // Get categories
  260. $output = executeQueryArray('widgets.content.getCategories',$obj);
  261. if($output->toBool() && $output->data)
  262. {
  263. foreach($output->data as $key => $val)
  264. {
  265. $category_lists[$val->module_srl][$val->category_srl] = $val;
  266. }
  267. }
  268. // Get a file list in each document on the module
  269. $obj->list_count = $args->list_count;
  270. $files_output = executeQueryArray("file.getOneFileInDocument", $obj);
  271. $files_count = count($files_output->data);
  272. if(!$files_count) return;
  273. $content_items = array();
  274. for($i=0;$i<$files_count;$i++) $document_srl_list[] = $files_output->data[$i]->document_srl;
  275. $tmp_document_list = $oDocumentModel->getDocuments($document_srl_list);
  276. if(!count($tmp_document_list)) return;
  277. foreach($tmp_document_list as $oDocument)
  278. {
  279. $attribute = $oDocument->getObjectVars();
  280. $browser_title = $args->module_srls_info[$attribute->module_srl]->browser_title;
  281. $domain = $args->module_srls_info[$attribute->module_srl]->domain;
  282. $category = $category_lists[$attribute->module_srl]->text;
  283. $content = $oDocument->getSummary($args->content_cut_size);
  284. $url = sprintf("%s#%s",$oDocument->getPermanentUrl() ,$oDocument->getCommentCount());
  285. $thumbnail = $oDocument->getThumbnail();
  286. $content_item = new mcontentItem($browser_title);
  287. $content_item->adds($attribute);
  288. $content_item->setCategory($category);
  289. $content_item->setContent($content);
  290. $content_item->setLink($url);
  291. $content_item->setThumbnail($thumbnail);
  292. $content_item->setExtraImages($extra_images);
  293. $content_item->setDomain($domain);
  294. $content_item->add('mid', $args->mid_lists[$attribute->module_srl]);
  295. $content_items[] = $content_item;
  296. }
  297. return $content_items;
  298. }
  299. function getRssItems($args)
  300. {
  301. $content_items = array();
  302. $args->mid_lists = array();
  303. foreach($args->rss_urls as $key => $rss)
  304. {
  305. $args->rss_url = $rss;
  306. $content_item = $this->_getRssItems($args);
  307. if(count($content_item) > 0)
  308. {
  309. $browser_title = $content_item[0]->getBrowserTitle();
  310. $args->mid_lists[] = $browser_title;
  311. $content_items[] = $content_item;
  312. }
  313. }
  314. if($args->tab_type == 'none' || $args->tab_type == '')
  315. {
  316. $items = array();
  317. foreach($content_items as $key => $val)
  318. {
  319. foreach($val as $k => $v)
  320. {
  321. $date = $v->get('regdate');
  322. $i=0;
  323. while(array_key_exists(sprintf('%s%02d',$date,$i), $items)) $i++;
  324. $items[sprintf('%s%02d',$date,$i)] = $v;
  325. }
  326. }
  327. if($args->order_type =='asc') ksort($items);
  328. else krsort($items);
  329. $content_items = array_slice(array_values($items),0,$args->list_count);
  330. } return $content_items;
  331. }
  332. function _getRssBody($value)
  333. {
  334. if(!$value || is_string($value)) return $value;
  335. if(is_object($value)) $value = get_object_vars($value);
  336. $body = null;
  337. if(!count($value)) return;
  338. foreach($value as $key => $val)
  339. {
  340. if($key == 'body')
  341. {
  342. $body = $val;
  343. continue;
  344. }
  345. if(is_object($val)||is_array($val)) $body = $this->_getRssBody($val);
  346. if($body !== null) return $body;
  347. }
  348. return $body;
  349. }
  350. function _getSummary($content, $str_size = 50)
  351. {
  352. $content = preg_replace('!(<br[\s]*/{0,1}>[\s]*)+!is', ' ', $content);
  353. // Replace tags such as </p> , </div> , </li> and others to a whitespace
  354. $content = str_replace(array('</p>', '</div>', '</li>'), ' ', $content);
  355. // Remove Tag
  356. $content = preg_replace('!<([^>]*?)>!is','', $content);
  357. // Replace tags to < , > , "
  358. $content = str_replace(array('&lt;','&gt;','&quot;','&nbsp;'), array('<','>','"',' '), $content);
  359. // Delete a series of whitespaces
  360. $content = preg_replace('/ ( +)/is', ' ', $content);
  361. // Truncate string
  362. $content = trim(cut_str($content, $str_size, $tail));
  363. // Replace back < , > , " to theoriginal tags
  364. $content = str_replace(array('<','>','"'),array('&lt;','&gt;','&quot;'), $content);
  365. // Fixed a newline bug on a set of consecutive English letters
  366. $content = preg_replace('/([a-z0-9\+:\/\.\~,\|\!\@\#\$\%\^\&\*\(\)\_]){20}/is',"$0-",$content);
  367. return $content;
  368. }
  369. /**
  370. * @brief function to receive contents from rss url
  371. * For Tistory blog in Korea, the original RSS url has location header without contents. Fixed to work as same as rss_reader widget.
  372. */
  373. function requestFeedContents($rss_url)
  374. {
  375. $rss_url = str_replace('&amp;','&',Context::convertEncodingStr($rss_url));
  376. return FileHandler::getRemoteResource($rss_url, null, 3, 'GET', 'application/xml');
  377. }
  378. function _getRssItems($args)
  379. {
  380. // Date Format
  381. $DATE_FORMAT = $args->date_format ? $args->date_format : "Y-m-d H:i:s";
  382. $buff = $this->requestFeedContents($args->rss_url);
  383. $encoding = preg_match("/<\?xml.*encoding=\"(.+)\".*\?>/i", $buff, $matches);
  384. if($encoding && !preg_match("/UTF-8/i", $matches[1])) $buff = Context::convertEncodingStr($buff);
  385. $buff = preg_replace("/<\?xml.*\?>/i", "", $buff);
  386. $oXmlParser = new XmlParser();
  387. $xml_doc = $oXmlParser->parse($buff);
  388. if($xml_doc->rss)
  389. {
  390. $rss->title = $xml_doc->rss->channel->title->body;
  391. $rss->link = $xml_doc->rss->channel->link->body;
  392. $items = $xml_doc->rss->channel->item;
  393. if(!$items) return;
  394. if($items && !is_array($items)) $items = array($items);
  395. $content_items = array();
  396. foreach ($items as $key => $value)
  397. {
  398. if($key >= $args->list_count) break;
  399. unset($item);
  400. foreach($value as $key2 => $value2)
  401. {
  402. if(is_array($value2)) $value2 = array_shift($value2);
  403. $item->{$key2} = $this->_getRssBody($value2);
  404. }
  405. $content_item = new mcontentItem($rss->title);
  406. $content_item->setContentsLink($rss->link);
  407. $content_item->setTitle($item->title);
  408. $content_item->setNickName(max($item->author,$item->{'dc:creator'}));
  409. //$content_item->setCategory($item->category);
  410. $item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->description);
  411. $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
  412. $content_item->setLink($item->link);
  413. $date = date('YmdHis', strtotime(max($item->pubdate,$item->pubDate,$item->{'dc:date'})));
  414. $content_item->setRegdate($date);
  415. $content_items[] = $content_item;
  416. }
  417. }
  418. else if($xml_doc->{'rdf:rdf'})
  419. {
  420. // rss1.0 supported (XE's XML is case-insensitive because XML parser converts all to small letters) Fixed by misol
  421. $rss->title = $xml_doc->{'rdf:rdf'}->channel->title->body;
  422. $rss->link = $xml_doc->{'rdf:rdf'}->channel->link->body;
  423. $items = $xml_doc->{'rdf:rdf'}->item;
  424. if(!$items) return;
  425. if($items && !is_array($items)) $items = array($items);
  426. $content_items = array();
  427. foreach ($items as $key => $value)
  428. {
  429. if($key >= $args->list_count) break;
  430. unset($item);
  431. foreach($value as $key2 => $value2)
  432. {
  433. if(is_array($value2)) $value2 = array_shift($value2);
  434. $item->{$key2} = $this->_getRssBody($value2);
  435. }
  436. $content_item = new mcontentItem($rss->title);
  437. $content_item->setContentsLink($rss->link);
  438. $content_item->setTitle($item->title);
  439. $content_item->setNickName(max($item->author,$item->{'dc:creator'}));
  440. //$content_item->setCategory($item->category);
  441. $item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->description);
  442. $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
  443. $content_item->setLink($item->link);
  444. $date = date('YmdHis', strtotime(max($item->pubdate,$item->pubDate,$item->{'dc:date'})));
  445. $content_item->setRegdate($date);
  446. $content_items[] = $content_item;
  447. }
  448. }
  449. else if($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') {
  450. // Atom 1.0 spec supported by misol
  451. $rss->title = $xml_doc->feed->title->body;
  452. $links = $xml_doc->feed->link;
  453. if(is_array($links))
  454. {
  455. foreach ($links as $value)
  456. {
  457. if($value->attrs->rel == 'alternate')
  458. {
  459. $rss->link = $value->attrs->href;
  460. break;
  461. }
  462. }
  463. }
  464. else if($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href;
  465. $items = $xml_doc->feed->entry;
  466. if(!$items) return;
  467. if($items && !is_array($items)) $items = array($items);
  468. $content_items = array();
  469. foreach ($items as $key => $value)
  470. {
  471. if($key >= $args->list_count) break;
  472. unset($item);
  473. foreach($value as $key2 => $value2)
  474. {
  475. if(is_array($value2)) $value2 = array_shift($value2);
  476. $item->{$key2} = $this->_getRssBody($value2);
  477. }
  478. $content_item = new mcontentItem($rss->title);
  479. $links = $value->link;
  480. if(is_array($links))
  481. {
  482. foreach ($links as $val)
  483. {
  484. if($val->attrs->rel == 'alternate')
  485. {
  486. $item->link = $val->attrs->href;
  487. break;
  488. }
  489. }
  490. }
  491. else if($links->attrs->rel == 'alternate') $item->link = $links->attrs->href;
  492. $content_item->setContentsLink($rss->link);
  493. if($item->title)
  494. {
  495. if(!preg_match("/html/i", $value->title->attrs->type)) $item->title = $value->title->body;
  496. }
  497. $content_item->setTitle($item->title);
  498. $content_item->setNickName(max($item->author,$item->{'dc:creator'}));
  499. $content_item->setAuthorSite($value->author->uri->body);
  500. //$content_item->setCategory($item->category);
  501. $item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->content);
  502. if($item->description)
  503. {
  504. if(!preg_match("/html/i", $value->content->attrs->type)) $item->description = htmlspecialchars($item->description);
  505. }
  506. if(!$item->description)
  507. {
  508. $item->description = $item->summary;
  509. if($item->description)
  510. {
  511. if(!preg_match("/html/i", $value->summary->attrs->type)) $item->description = htmlspecialchars($item->description);
  512. }
  513. }
  514. $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
  515. $content_item->setLink($item->link);
  516. $date = date('YmdHis', strtotime(max($item->published,$item->updated,$item->{'dc:date'})));
  517. $content_item->setRegdate($date);
  518. $content_items[] = $content_item;
  519. }
  520. }
  521. return $content_items;
  522. }
  523. function _getTrackbackItems($args){
  524. // Get categories
  525. $output = executeQueryArray('widgets.content.getCategories',$obj);
  526. if($output->toBool() && $output->data)
  527. {
  528. foreach($output->data as $key => $val) {
  529. $category_lists[$val->module_srl][$val->category_srl] = $val;
  530. }
  531. }
  532. $obj->module_srl = $args->module_srl;
  533. $obj->sort_index = $args->order_target;
  534. $obj->list_count = $args->list_count;
  535. // Get model object from the trackback module and execute getTrackbackList() method
  536. $oTrackbackModel = &getModel('trackback');
  537. $output = $oTrackbackModel->getNewestTrackbackList($obj);
  538. // If an error occurs, just ignore it.
  539. if(!$output->toBool() || !$output->data) return;
  540. // If the result exists, make each document as an object
  541. $content_items = array();
  542. foreach($output->data as $key => $item)
  543. {
  544. $domain = $args->module_srls_info[$item->module_srl]->domain;
  545. $category = $category_lists[$item->module_srl]->text;
  546. $url = getSiteUrl($domain,'','document_srl',$item->document_srl);
  547. $browser_title = $args->module_srls_info[$item->module_srl]->browser_title;
  548. $content_item = new mcontentItem($browser_title);
  549. $content_item->adds($item);
  550. $content_item->setTitle($item->title);
  551. $content_item->setCategory($category);
  552. $content_item->setNickName($item->blog_name);
  553. $content_item->setContent($item->excerpt); ///<<
  554. $content_item->setDomain($domain); ///<<
  555. $content_item->setLink($url);
  556. $content_item->add('mid', $args->mid_lists[$item->module_srl]);
  557. $content_item->setRegdate($item->regdate);
  558. $content_items[] = $content_item;
  559. }
  560. return $content_items;
  561. }
  562. function _compile($args,$content_items)
  563. {
  564. $oTemplate = &TemplateHandler::getInstance();
  565. // Set variables for widget
  566. $widget_info = new stdClass();
  567. $widget_info->modules_info = $args->modules_info;
  568. $widget_info->option_view_arr = $args->option_view_arr;
  569. $widget_info->list_count = $args->list_count;
  570. $widget_info->subject_cut_size = $args->subject_cut_size;
  571. $widget_info->content_cut_size = $args->content_cut_size;
  572. $widget_info->thumbnail_type = $args->thumbnail_type;
  573. $widget_info->thumbnail_width = $args->thumbnail_width;
  574. $widget_info->thumbnail_height = $args->thumbnail_height;
  575. $widget_info->mid_lists = $args->mid_lists;
  576. $widget_info->show_browser_title = $args->show_browser_title;
  577. $widget_info->show_category = $args->show_category;
  578. $widget_info->show_comment_count = $args->show_comment_count;
  579. $widget_info->show_trackback_count = $args->show_trackback_count;
  580. $widget_info->show_icon = $args->show_icon;
  581. $widget_info->list_type = $args->list_type;
  582. $widget_info->tab_type = $args->tab_type;
  583. $widget_info->markup_type = $args->markup_type;
  584. $widget_info->content_items = $content_items;
  585. unset($args->option_view_arr);
  586. unset($args->modules_info);
  587. Context::set('colorset', $args->colorset);
  588. Context::set('widget_info', $widget_info);
  589. $tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
  590. return $oTemplate->compile($tpl_path, "content");
  591. }
  592. }
  593. class mcontentItem extends Object
  594. {
  595. var $browser_title = null;
  596. var $has_first_thumbnail_idx = false;
  597. var $first_thumbnail_idx = null;
  598. var $contents_link = null;
  599. var $domain = null;
  600. function mcontentItem($browser_title='')
  601. {
  602. $this->browser_title = $browser_title;
  603. }
  604. function setContentsLink($link)
  605. {
  606. $this->contents_link = $link;
  607. }
  608. function setFirstThumbnailIdx($first_thumbnail_idx)
  609. {
  610. if(is_null($this->first_thumbnail) && $first_thumbnail_idx>-1) {
  611. $this->has_first_thumbnail_idx = true;
  612. $this->first_thumbnail_idx= $first_thumbnail_idx;
  613. }
  614. }
  615. function setExtraImages($extra_images)
  616. {
  617. $this->add('extra_images',$extra_images);
  618. }
  619. function setDomain($domain)
  620. {
  621. static $default_domain = null;
  622. if(!$domain)
  623. {
  624. if(is_null($default_domain)) $default_domain = Context::getDefaultUrl();
  625. $domain = $default_domain;
  626. }
  627. $this->domain = $domain;
  628. }
  629. function setLink($url)
  630. {
  631. $this->add('url',$url);
  632. }
  633. function setTitle($title)
  634. {
  635. $this->add('title',$title);
  636. }
  637. function setThumbnail($thumbnail)
  638. {
  639. $this->add('thumbnail',$thumbnail);
  640. }
  641. function setContent($content)
  642. {
  643. $this->add('content',$content);
  644. }
  645. function setRegdate($regdate)
  646. {
  647. $this->add('regdate',$regdate);
  648. }
  649. function setNickName($nick_name)
  650. {
  651. $this->add('nick_name',$nick_name);
  652. }
  653. // Save author's homepage url by misol
  654. function setAuthorSite($site_url)
  655. {
  656. $this->add('author_site',$site_url);
  657. }
  658. function setCategory($category)
  659. {
  660. $this->add('category',$category);
  661. }
  662. function getBrowserTitle()
  663. {
  664. return $this->browser_title;
  665. }
  666. function getDomain()
  667. {
  668. return $this->domain;
  669. }
  670. function getContentsLink()
  671. {
  672. return $this->contents_link;
  673. }
  674. function getFirstThumbnailIdx()
  675. {
  676. return $this->first_thumbnail_idx;
  677. }
  678. function getLink()
  679. {
  680. return $this->get('url');
  681. }
  682. function getModuleSrl()
  683. {
  684. return $this->get('module_srl');
  685. }
  686. function getTitle($cut_size = 0, $tail='...')
  687. {
  688. $title = strip_tags($this->get('title'));
  689. if($cut_size) $title = cut_str($title, $cut_size, $tail);
  690. $attrs = array();
  691. if($this->get('title_bold') == 'Y') $attrs[] = 'font-weight:bold';
  692. if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = 'color:#'.$this->get('title_color');
  693. if(count($attrs)) $title = sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title));
  694. return $title;
  695. }
  696. function getContent()
  697. {
  698. return $this->get('content');
  699. }
  700. function getCategory()
  701. {
  702. return $this->get('category');
  703. }
  704. function getNickName()
  705. {
  706. return $this->get('nick_name');
  707. }
  708. function getAuthorSite()
  709. {
  710. return $this->get('author_site');
  711. }
  712. function getCommentCount()
  713. {
  714. $comment_count = $this->get('comment_count');
  715. return $comment_count>0 ? $comment_count : '';
  716. }
  717. function getTrackbackCount()
  718. {
  719. $trackback_count = $this->get('trackback_count');
  720. return $trackback_count>0 ? $trackback_count : '';
  721. }
  722. function getRegdate($format = 'Y.m.d H:i:s')
  723. {
  724. return zdate($this->get('regdate'), $format);
  725. }
  726. function printExtraImages()
  727. {
  728. return $this->get('extra_images');
  729. }
  730. function haveFirstThumbnail()
  731. {
  732. return $this->has_first_thumbnail_idx;
  733. }
  734. function getThumbnail()
  735. {
  736. return $this->get('thumbnail');
  737. }
  738. function getMemberSrl()
  739. {
  740. return $this->get('member_srl');
  741. }
  742. }
  743. /* End of file mcontent.class.php */
  744. /* Location: ./widgets/mcontent/mcontent.class.php */