mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-12 13:32:16 +09:00
issue 2662 widgets
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12261 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5219a360c6
commit
4d8733156b
5 changed files with 1810 additions and 1600 deletions
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
/**
|
||||
* @class content
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief widget to display content
|
||||
* @version 0.1
|
||||
**/
|
||||
|
||||
class content extends WidgetHandler {
|
||||
|
||||
*/
|
||||
class content extends WidgetHandler
|
||||
{
|
||||
/**
|
||||
* @brief Widget handler
|
||||
*
|
||||
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
|
||||
* After generating the result, do not print but return it.
|
||||
**/
|
||||
*/
|
||||
|
||||
function proc($args) {
|
||||
function proc($args)
|
||||
{
|
||||
// Targets to sort
|
||||
if(!in_array($args->order_target, array('list_order','update_order'))) $args->order_target = 'list_order';
|
||||
// Sort order
|
||||
|
|
@ -50,21 +50,28 @@
|
|||
$module_srls = $args->modules_info = $args->module_srls_info = $args->mid_lists = array();
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// List URLs if a type is RSS
|
||||
if($args->content_type == 'rss'){
|
||||
if($args->content_type == 'rss')
|
||||
{
|
||||
$args->rss_urls = array();
|
||||
$rss_urls = array_unique(array($args->rss_url0,$args->rss_url1,$args->rss_url2,$args->rss_url3,$args->rss_url4));
|
||||
for($i=0,$c=count($rss_urls);$i<$c;$i++) {
|
||||
for($i=0,$c=count($rss_urls);$i<$c;$i++)
|
||||
{
|
||||
if($rss_urls[$i]) $args->rss_urls[] = $rss_urls[$i];
|
||||
}
|
||||
// Get module information after listing module_srls if the module is not RSS
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply to all modules in the site if a target module is not specified
|
||||
if(!$args->module_srls){
|
||||
if(!$args->module_srls)
|
||||
{
|
||||
unset($obj);
|
||||
$obj->site_srl = (int)$site_module_info->site_srl;
|
||||
$output = executeQueryArray('widgets.content.getMids', $obj);
|
||||
if($output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$args->modules_info[$val->mid] = $val;
|
||||
$args->module_srls_info[$val->module_srl] = $val;
|
||||
$args->mid_lists[$val->module_srl] = $val->mid;
|
||||
|
|
@ -74,17 +81,22 @@
|
|||
|
||||
$args->modules_info = $oModuleModel->getMidList($obj);
|
||||
// Apply to the module only if a target module is specified
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj->module_srls = $args->module_srls;
|
||||
$output = executeQueryArray('widgets.content.getMids', $obj);
|
||||
if($output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$args->modules_info[$val->mid] = $val;
|
||||
$args->module_srls_info[$val->module_srl] = $val;
|
||||
$module_srls[] = $val->module_srl;
|
||||
}
|
||||
$idx = explode(',',$args->module_srls);
|
||||
for($i=0,$c=count($idx);$i<$c;$i++) {
|
||||
for($i=0,$c=count($idx);$i<$c;$i++)
|
||||
{
|
||||
$srl = $idx[$i];
|
||||
if(!$args->module_srls_info[$srl]) continue;
|
||||
$args->mid_lists[$srl] = $args->module_srls_info[$srl]->mid;
|
||||
|
|
@ -98,10 +110,12 @@
|
|||
|
||||
/**
|
||||
* Method is separately made because content extraction, articles, comments, trackbacks, RSS and other elements exist
|
||||
**/
|
||||
*/
|
||||
// tab type
|
||||
if($args->tab_type == 'none' || $args->tab_type == '') {
|
||||
switch($args->content_type){
|
||||
if($args->tab_type == 'none' || $args->tab_type == '')
|
||||
{
|
||||
switch($args->content_type)
|
||||
{
|
||||
case 'comment':
|
||||
$content_items = $this->_getCommentItems($args);
|
||||
break;
|
||||
|
|
@ -119,18 +133,23 @@
|
|||
break;
|
||||
}
|
||||
// If not a tab type
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$content_items = array();
|
||||
|
||||
switch($args->content_type){
|
||||
switch($args->content_type)
|
||||
{
|
||||
case 'comment':
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$content_items[$module_srl] = $this->_getCommentItems($args);
|
||||
}
|
||||
break;
|
||||
case 'image':
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$content_items[$module_srl] = $this->_getImageItems($args);
|
||||
}
|
||||
|
|
@ -139,13 +158,15 @@
|
|||
$content_items = $this->getRssItems($args);
|
||||
break;
|
||||
case 'trackback':
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$content_items[$module_srl] = $this->_getTrackbackItems($args);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$content_items[$module_srl] = $this->_getDocumentItems($args);
|
||||
}
|
||||
|
|
@ -159,8 +180,9 @@
|
|||
|
||||
/**
|
||||
* @brief Get a list of comments and return contentItem
|
||||
**/
|
||||
function _getCommentItems($args) {
|
||||
*/
|
||||
function _getCommentItems($args)
|
||||
{
|
||||
// List variables to use CommentModel::getCommentList()
|
||||
$obj->module_srl = $args->module_srl;
|
||||
$obj->sort_index = $args->order_target;
|
||||
|
|
@ -173,7 +195,8 @@
|
|||
|
||||
if(!count($output)) return;
|
||||
|
||||
foreach($output as $key => $oComment) {
|
||||
foreach($output as $key => $oComment)
|
||||
{
|
||||
$attribute = $oComment->getObjectVars();
|
||||
$title = $oComment->getSummary($args->content_cut_size);
|
||||
$thumbnail = $oComment->getThumbnail($args->thumbnail_width,$args->thumbnail_height,$args->thumbnail_type);
|
||||
|
|
@ -195,14 +218,17 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function _getDocumentItems($args){
|
||||
function _getDocumentItems($args)
|
||||
{
|
||||
// Get model object from the document module
|
||||
$oDocumentModel = &getModel('document');
|
||||
// Get categories
|
||||
$obj->module_srl = $args->module_srl;
|
||||
$output = executeQueryArray('widgets.content.getCategories',$obj);
|
||||
if($output->toBool() && $output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->toBool() && $output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$category_lists[$val->module_srl][$val->category_srl] = $val;
|
||||
}
|
||||
}
|
||||
|
|
@ -218,8 +244,10 @@
|
|||
// If the result exists, make each document as an object
|
||||
$content_items = array();
|
||||
$first_thumbnail_idx = -1;
|
||||
if(count($output->data)) {
|
||||
foreach($output->data as $key => $attribute) {
|
||||
if(count($output->data))
|
||||
{
|
||||
foreach($output->data as $key => $attribute)
|
||||
{
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($attribute, false);
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$oDocument->document_srl] = $oDocument;
|
||||
|
|
@ -227,7 +255,8 @@
|
|||
}
|
||||
$oDocumentModel->setToAllDocumentExtraVars();
|
||||
|
||||
for($i=0,$c=count($document_srls);$i<$c;$i++) {
|
||||
for($i=0,$c=count($document_srls);$i<$c;$i++)
|
||||
{
|
||||
$oDocument = $GLOBALS['XE_DOCUMENT_LIST'][$document_srls[$i]];
|
||||
$document_srl = $oDocument->document_srl;
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
|
|
@ -258,7 +287,8 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function _getImageItems($args) {
|
||||
function _getImageItems($args)
|
||||
{
|
||||
$oDocumentModel = &getModel('document');
|
||||
|
||||
$obj->module_srls = $obj->module_srl = $args->module_srl;
|
||||
|
|
@ -266,8 +296,10 @@
|
|||
$obj->isvalid = 'Y';
|
||||
// Get categories
|
||||
$output = executeQueryArray('widgets.content.getCategories',$obj);
|
||||
if($output->toBool() && $output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->toBool() && $output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$category_lists[$val->module_srl][$val->category_srl] = $val;
|
||||
}
|
||||
}
|
||||
|
|
@ -285,7 +317,8 @@
|
|||
|
||||
if(!count($tmp_document_list)) return;
|
||||
|
||||
foreach($tmp_document_list as $oDocument){
|
||||
foreach($tmp_document_list as $oDocument)
|
||||
{
|
||||
$attribute = $oDocument->getObjectVars();
|
||||
$browser_title = $args->module_srls_info[$attribute->module_srl]->browser_title;
|
||||
$domain = $args->module_srls_info[$attribute->module_srl]->domain;
|
||||
|
|
@ -310,25 +343,30 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function getRssItems($args){
|
||||
|
||||
function getRssItems($args)
|
||||
{
|
||||
$content_items = array();
|
||||
$args->mid_lists = array();
|
||||
|
||||
foreach($args->rss_urls as $key => $rss){
|
||||
foreach($args->rss_urls as $key => $rss)
|
||||
{
|
||||
$args->rss_url = $rss;
|
||||
$content_item = $this->_getRssItems($args);
|
||||
if(count($content_item) > 0){
|
||||
if(count($content_item) > 0)
|
||||
{
|
||||
$browser_title = $content_item[0]->getBrowserTitle();
|
||||
$args->mid_lists[] = $browser_title;
|
||||
$content_items[] = $content_item;
|
||||
}
|
||||
}
|
||||
// If it is not a tab type
|
||||
if($args->tab_type == 'none' || $args->tab_type == ''){
|
||||
if($args->tab_type == 'none' || $args->tab_type == '')
|
||||
{
|
||||
$items = array();
|
||||
foreach($content_items as $key => $val){
|
||||
foreach($val as $k => $v){
|
||||
foreach($content_items as $key => $val)
|
||||
{
|
||||
foreach($val as $k => $v)
|
||||
{
|
||||
$date = $v->get('regdate');
|
||||
$i=0;
|
||||
while(array_key_exists(sprintf('%s%02d',$date,$i), $items)) $i++;
|
||||
|
|
@ -339,10 +377,14 @@
|
|||
else krsort($items);
|
||||
$content_items = array_slice(array_values($items),0,$args->list_count*$args->page_count);
|
||||
// Tab Type
|
||||
} else {
|
||||
foreach($content_items as $key=> $content_item_list){
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($content_items as $key=> $content_item_list)
|
||||
{
|
||||
$items = array();
|
||||
foreach($content_item_list as $k => $content_item){
|
||||
foreach($content_item_list as $k => $content_item)
|
||||
{
|
||||
$date = $content_item->get('regdate');
|
||||
$i=0;
|
||||
while(array_key_exists(sprintf('%s%02d',$date,$i), $items)) $i++;
|
||||
|
|
@ -357,13 +399,16 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function _getRssBody($value) {
|
||||
function _getRssBody($value)
|
||||
{
|
||||
if(!$value || is_string($value)) return $value;
|
||||
if(is_object($value)) $value = get_object_vars($value);
|
||||
$body = null;
|
||||
if(!count($value)) return;
|
||||
foreach($value as $key => $val) {
|
||||
if($key == 'body') {
|
||||
foreach($value as $key => $val)
|
||||
{
|
||||
if($key == 'body')
|
||||
{
|
||||
$body = $val;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -393,17 +438,18 @@
|
|||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief function to receive contents from rss url
|
||||
* For Tistory blog in Korea, the original RSS url has location header without contents. Fixed to work as same as rss_reader widget.
|
||||
**/
|
||||
function requestFeedContents($rss_url) {
|
||||
*/
|
||||
function requestFeedContents($rss_url)
|
||||
{
|
||||
$rss_url = str_replace('&','&',Context::convertEncodingStr($rss_url));
|
||||
return FileHandler::getRemoteResource($rss_url, null, 3, 'GET', 'application/xml');
|
||||
}
|
||||
|
||||
function _getRssItems($args){
|
||||
function _getRssItems($args)
|
||||
{
|
||||
// Date Format
|
||||
$DATE_FORMAT = $args->date_format ? $args->date_format : "Y-m-d H:i:s";
|
||||
|
||||
|
|
@ -416,7 +462,8 @@
|
|||
|
||||
$oXmlParser = new XmlParser();
|
||||
$xml_doc = $oXmlParser->parse($buff);
|
||||
if($xml_doc->rss) {
|
||||
if($xml_doc->rss)
|
||||
{
|
||||
$rss->title = $xml_doc->rss->channel->title->body;
|
||||
$rss->link = $xml_doc->rss->channel->link->body;
|
||||
|
||||
|
|
@ -427,11 +474,13 @@
|
|||
|
||||
$content_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
foreach ($items as $key => $value)
|
||||
{
|
||||
if($key >= $args->list_count * $args->page_count) break;
|
||||
unset($item);
|
||||
|
||||
foreach($value as $key2 => $value2) {
|
||||
foreach($value as $key2 => $value2)
|
||||
{
|
||||
if(is_array($value2)) $value2 = array_shift($value2);
|
||||
$item->{$key2} = $this->_getRssBody($value2);
|
||||
}
|
||||
|
|
@ -450,7 +499,9 @@
|
|||
|
||||
$content_items[] = $content_item;
|
||||
}
|
||||
} elseif($xml_doc->{'rdf:rdf'}) {
|
||||
}
|
||||
else if($xml_doc->{'rdf:rdf'})
|
||||
{
|
||||
// rss1.0 supported (XE's XML is case-insensitive because XML parser converts all to small letters. Fixed by misol
|
||||
$rss->title = $xml_doc->{'rdf:rdf'}->channel->title->body;
|
||||
$rss->link = $xml_doc->{'rdf:rdf'}->channel->link->body;
|
||||
|
|
@ -462,11 +513,13 @@
|
|||
|
||||
$content_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
foreach ($items as $key => $value)
|
||||
{
|
||||
if($key >= $args->list_count * $args->page_count) break;
|
||||
unset($item);
|
||||
|
||||
foreach($value as $key2 => $value2) {
|
||||
foreach($value as $key2 => $value2)
|
||||
{
|
||||
if(is_array($value2)) $value2 = array_shift($value2);
|
||||
$item->{$key2} = $this->_getRssBody($value2);
|
||||
}
|
||||
|
|
@ -485,19 +538,24 @@
|
|||
|
||||
$content_items[] = $content_item;
|
||||
}
|
||||
} elseif($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') {
|
||||
}
|
||||
else if($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom')
|
||||
{
|
||||
// Atom 1.0 spec supported by misol
|
||||
$rss->title = $xml_doc->feed->title->body;
|
||||
$links = $xml_doc->feed->link;
|
||||
if(is_array($links)) {
|
||||
foreach ($links as $value) {
|
||||
if($value->attrs->rel == 'alternate') {
|
||||
if(is_array($links))
|
||||
{
|
||||
foreach ($links as $value)
|
||||
{
|
||||
if($value->attrs->rel == 'alternate')
|
||||
{
|
||||
$rss->link = $value->attrs->href;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href;
|
||||
else if($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href;
|
||||
|
||||
$items = $xml_doc->feed->entry;
|
||||
|
||||
|
|
@ -506,29 +564,35 @@
|
|||
|
||||
$content_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
foreach ($items as $key => $value)
|
||||
{
|
||||
if($key >= $args->list_count * $args->page_count) break;
|
||||
unset($item);
|
||||
|
||||
foreach($value as $key2 => $value2) {
|
||||
foreach($value as $key2 => $value2)
|
||||
{
|
||||
if(is_array($value2)) $value2 = array_shift($value2);
|
||||
$item->{$key2} = $this->_getRssBody($value2);
|
||||
}
|
||||
|
||||
$content_item = new contentItem($rss->title);
|
||||
$links = $value->link;
|
||||
if(is_array($links)) {
|
||||
foreach ($links as $val) {
|
||||
if($val->attrs->rel == 'alternate') {
|
||||
if(is_array($links))
|
||||
{
|
||||
foreach ($links as $val)
|
||||
{
|
||||
if($val->attrs->rel == 'alternate')
|
||||
{
|
||||
$item->link = $val->attrs->href;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($links->attrs->rel == 'alternate') $item->link = $links->attrs->href;
|
||||
else if($links->attrs->rel == 'alternate') $item->link = $links->attrs->href;
|
||||
|
||||
$content_item->setContentsLink($rss->link);
|
||||
if($item->title) {
|
||||
if($item->title)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->title->attrs->type)) $item->title = $value->title->body;
|
||||
}
|
||||
$content_item->setTitle($item->title);
|
||||
|
|
@ -536,12 +600,15 @@
|
|||
$content_item->setAuthorSite($value->author->uri->body);
|
||||
//$content_item->setCategory($item->category);
|
||||
$item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->content);
|
||||
if($item->description) {
|
||||
if($item->description)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->content->attrs->type)) $item->description = htmlspecialchars($item->description);
|
||||
}
|
||||
if(!$item->description) {
|
||||
if(!$item->description)
|
||||
{
|
||||
$item->description = $item->summary;
|
||||
if($item->description) {
|
||||
if($item->description)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->summary->attrs->type)) $item->description = htmlspecialchars($item->description);
|
||||
}
|
||||
}
|
||||
|
|
@ -579,11 +646,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
function _getTrackbackItems($args){
|
||||
function _getTrackbackItems($args)
|
||||
{
|
||||
// Get categories
|
||||
$output = executeQueryArray('widgets.content.getCategories',$obj);
|
||||
if($output->toBool() && $output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->toBool() && $output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$category_lists[$val->module_srl][$val->category_srl] = $val;
|
||||
}
|
||||
}
|
||||
|
|
@ -598,7 +668,8 @@
|
|||
if(!$output->toBool() || !$output->data) return;
|
||||
// If the result exists, make each document as an object
|
||||
$content_items = array();
|
||||
foreach($output->data as $key => $item) {
|
||||
foreach($output->data as $key => $item)
|
||||
{
|
||||
$domain = $args->module_srls_info[$item->module_srl]->domain;
|
||||
$category = $category_lists[$item->module_srl]->text;
|
||||
$url = getSiteUrl($domain,'','document_srl',$item->document_srl);
|
||||
|
|
@ -619,7 +690,8 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function _compile($args,$content_items){
|
||||
function _compile($args,$content_items)
|
||||
{
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
// Set variables for widget
|
||||
$widget_info->modules_info = $args->modules_info;
|
||||
|
|
@ -648,9 +720,11 @@
|
|||
|
||||
$widget_info->markup_type = $args->markup_type;
|
||||
// If it is a tab type, list up tab items and change key value(module_srl) to index
|
||||
if($args->tab_type != 'none' && $args->tab_type) {
|
||||
if($args->tab_type != 'none' && $args->tab_type)
|
||||
{
|
||||
$tab = array();
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
if(!is_array($content_items[$module_srl]) || !count($content_items[$module_srl])) continue;
|
||||
|
||||
unset($tab_item);
|
||||
|
|
@ -662,7 +736,9 @@
|
|||
$tab[] = $tab_item;
|
||||
}
|
||||
$widget_info->tab = $tab;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$widget_info->content_items = $content_items;
|
||||
}
|
||||
unset($args->option_view_arr);
|
||||
|
|
@ -674,86 +750,108 @@
|
|||
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
|
||||
return $oTemplate->compile($tpl_path, "content");
|
||||
}
|
||||
}
|
||||
|
||||
class contentItem extends Object {
|
||||
}
|
||||
|
||||
class contentItem extends Object
|
||||
{
|
||||
var $browser_title = null;
|
||||
var $has_first_thumbnail_idx = false;
|
||||
var $first_thumbnail_idx = null;
|
||||
var $contents_link = null;
|
||||
var $domain = null;
|
||||
|
||||
function contentItem($browser_title=''){
|
||||
function contentItem($browser_title='')
|
||||
{
|
||||
$this->browser_title = $browser_title;
|
||||
}
|
||||
function setContentsLink($link){
|
||||
function setContentsLink($link)
|
||||
{
|
||||
$this->contents_link = $link;
|
||||
}
|
||||
function setFirstThumbnailIdx($first_thumbnail_idx){
|
||||
if(is_null($this->first_thumbnail) && $first_thumbnail_idx>-1) {
|
||||
function setFirstThumbnailIdx($first_thumbnail_idx)
|
||||
{
|
||||
if(is_null($this->first_thumbnail) && $first_thumbnail_idx>-1)
|
||||
{
|
||||
$this->has_first_thumbnail_idx = true;
|
||||
$this->first_thumbnail_idx= $first_thumbnail_idx;
|
||||
}
|
||||
}
|
||||
function setExtraImages($extra_images){
|
||||
function setExtraImages($extra_images)
|
||||
{
|
||||
$this->add('extra_images',$extra_images);
|
||||
}
|
||||
function setDomain($domain) {
|
||||
function setDomain($domain)
|
||||
{
|
||||
static $default_domain = null;
|
||||
if(!$domain) {
|
||||
if(!$domain)
|
||||
{
|
||||
if(is_null($default_domain)) $default_domain = Context::getDefaultUrl();
|
||||
$domain = $default_domain;
|
||||
}
|
||||
$this->domain = $domain;
|
||||
}
|
||||
function setLink($url){
|
||||
function setLink($url)
|
||||
{
|
||||
$this->add('url',$url);
|
||||
}
|
||||
function setTitle($title){
|
||||
function setTitle($title)
|
||||
{
|
||||
$this->add('title',$title);
|
||||
}
|
||||
|
||||
function setThumbnail($thumbnail){
|
||||
function setThumbnail($thumbnail)
|
||||
{
|
||||
$this->add('thumbnail',$thumbnail);
|
||||
}
|
||||
function setContent($content){
|
||||
function setContent($content)
|
||||
{
|
||||
$this->add('content',$content);
|
||||
}
|
||||
function setRegdate($regdate){
|
||||
function setRegdate($regdate)
|
||||
{
|
||||
$this->add('regdate',$regdate);
|
||||
}
|
||||
function setNickName($nick_name){
|
||||
function setNickName($nick_name)
|
||||
{
|
||||
$this->add('nick_name',$nick_name);
|
||||
}
|
||||
// Save author's homepage url. By misol
|
||||
function setAuthorSite($site_url){
|
||||
function setAuthorSite($site_url)
|
||||
{
|
||||
$this->add('author_site',$site_url);
|
||||
}
|
||||
function setCategory($category){
|
||||
function setCategory($category)
|
||||
{
|
||||
$this->add('category',$category);
|
||||
}
|
||||
function getBrowserTitle(){
|
||||
function getBrowserTitle()
|
||||
{
|
||||
return $this->browser_title;
|
||||
}
|
||||
function getDomain() {
|
||||
function getDomain()
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
function getContentsLink(){
|
||||
function getContentsLink()
|
||||
{
|
||||
return $this->contents_link;
|
||||
}
|
||||
|
||||
function getFirstThumbnailIdx(){
|
||||
function getFirstThumbnailIdx()
|
||||
{
|
||||
return $this->first_thumbnail_idx;
|
||||
}
|
||||
|
||||
function getLink(){
|
||||
function getLink()
|
||||
{
|
||||
return $this->get('url');
|
||||
}
|
||||
function getModuleSrl(){
|
||||
function getModuleSrl()
|
||||
{
|
||||
return $this->get('module_srl');
|
||||
}
|
||||
function getTitle($cut_size = 0, $tail='...'){
|
||||
function getTitle($cut_size = 0, $tail='...')
|
||||
{
|
||||
$title = strip_tags($this->get('title'));
|
||||
|
||||
if($cut_size) $title = cut_str($title, $cut_size, $tail);
|
||||
|
|
@ -766,40 +864,52 @@
|
|||
|
||||
return $title;
|
||||
}
|
||||
function getContent(){
|
||||
function getContent()
|
||||
{
|
||||
return $this->get('content');
|
||||
}
|
||||
function getCategory(){
|
||||
function getCategory()
|
||||
{
|
||||
return $this->get('category');
|
||||
}
|
||||
function getNickName(){
|
||||
function getNickName()
|
||||
{
|
||||
return $this->get('nick_name');
|
||||
}
|
||||
function getAuthorSite(){
|
||||
function getAuthorSite()
|
||||
{
|
||||
return $this->get('author_site');
|
||||
}
|
||||
function getCommentCount(){
|
||||
function getCommentCount()
|
||||
{
|
||||
$comment_count = $this->get('comment_count');
|
||||
return $comment_count>0 ? $comment_count : '';
|
||||
}
|
||||
function getTrackbackCount(){
|
||||
function getTrackbackCount()
|
||||
{
|
||||
$trackback_count = $this->get('trackback_count');
|
||||
return $trackback_count>0 ? $trackback_count : '';
|
||||
}
|
||||
function getRegdate($format = 'Y.m.d H:i:s') {
|
||||
function getRegdate($format = 'Y.m.d H:i:s')
|
||||
{
|
||||
return zdate($this->get('regdate'), $format);
|
||||
}
|
||||
function printExtraImages() {
|
||||
function printExtraImages()
|
||||
{
|
||||
return $this->get('extra_images');
|
||||
}
|
||||
function haveFirstThumbnail() {
|
||||
function haveFirstThumbnail()
|
||||
{
|
||||
return $this->has_first_thumbnail_idx;
|
||||
}
|
||||
function getThumbnail(){
|
||||
function getThumbnail()
|
||||
{
|
||||
return $this->get('thumbnail');
|
||||
}
|
||||
function getMemberSrl() {
|
||||
function getMemberSrl()
|
||||
{
|
||||
return $this->get('member_srl');
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file content.class.php */
|
||||
/* Location: ./widgets/content/content.class.php */
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
/**
|
||||
* @class counter_status
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @version 0.1
|
||||
* @brief Display counter status by using data in the counter module
|
||||
**/
|
||||
|
||||
class counter_status extends WidgetHandler {
|
||||
|
||||
*/
|
||||
class counter_status extends WidgetHandler
|
||||
{
|
||||
/**
|
||||
* @brief Widget execution
|
||||
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
|
||||
* After generating the result, do not print but return it.
|
||||
**/
|
||||
function proc($args) {
|
||||
*/
|
||||
function proc($args)
|
||||
{
|
||||
// Get status of the accumulated, yesterday's, today's counts
|
||||
$oCounterModel = &getModel('counter');
|
||||
|
||||
|
|
@ -37,5 +37,6 @@
|
|||
$oTemplate = &TemplateHandler::getInstance();
|
||||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file counter_status.class.php */
|
||||
/* Location: ./widgets/counter_status/counter_status.class.php */
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
/**
|
||||
* @class language_select
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief Language selector
|
||||
* @version 0.1
|
||||
**/
|
||||
|
||||
class language_select extends WidgetHandler {
|
||||
|
||||
*/
|
||||
class language_select extends WidgetHandler
|
||||
{
|
||||
/**
|
||||
* @brief Widget execution
|
||||
*
|
||||
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
|
||||
* After generating the result, do not print but return it.
|
||||
**/
|
||||
function proc($args) {
|
||||
*/
|
||||
function proc($args)
|
||||
{
|
||||
// Set a path of the template skin (values of skin, colorset settings)
|
||||
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
|
||||
$tpl_file = 'language_select';
|
||||
|
|
@ -25,5 +25,6 @@
|
|||
$oTemplate = &TemplateHandler::getInstance();
|
||||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file language_select.class.php */
|
||||
/* Location: ./widgets/language_select/language_select.class.php */
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
/**
|
||||
* @class login_info
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @version 0.1
|
||||
* @brief Widget to display log-in form
|
||||
*
|
||||
* $Pre-configured by using $logged_info
|
||||
**/
|
||||
|
||||
class login_info extends WidgetHandler {
|
||||
|
||||
*/
|
||||
class login_info extends WidgetHandler
|
||||
{
|
||||
/**
|
||||
* @brief Widget execution
|
||||
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
|
||||
* After generating the result, do not print but return it.
|
||||
**/
|
||||
function proc($args) {
|
||||
*/
|
||||
function proc($args)
|
||||
{
|
||||
// Set a path of the template skin (values of skin, colorset settings)
|
||||
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
|
||||
Context::set('colorset', $args->colorset);
|
||||
|
|
@ -40,7 +40,6 @@
|
|||
$oTemplate = &TemplateHandler::getInstance();
|
||||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file login_info.class.php */
|
||||
/* Location: ./widgets/login_info/login_info.class.php */
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
/**
|
||||
* @class mcontent
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief widget to display mcontent
|
||||
* @version 0.1
|
||||
**/
|
||||
|
||||
class mcontent extends WidgetHandler {
|
||||
|
||||
*/
|
||||
class mcontent extends WidgetHandler
|
||||
{
|
||||
/**
|
||||
* @brief Widget execution
|
||||
*
|
||||
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
|
||||
* After generating the result, do not print but return it.
|
||||
**/
|
||||
*/
|
||||
|
||||
function proc($args) {
|
||||
function proc($args)
|
||||
{
|
||||
// Targets to sort
|
||||
if(!in_array($args->order_target, array('list_order','update_order'))) $args->order_target = 'list_order';
|
||||
// Sort order
|
||||
|
|
@ -36,21 +36,28 @@
|
|||
$module_srls = $args->modules_info = $args->module_srls_info = $args->mid_lists = array();
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// List URLs if a type is RSS
|
||||
if($args->content_type == 'rss'){
|
||||
if($args->content_type == 'rss')
|
||||
{
|
||||
$args->rss_urls = array();
|
||||
$rss_urls = array_unique(array($args->rss_url0,$args->rss_url1,$args->rss_url2,$args->rss_url3,$args->rss_url4));
|
||||
for($i=0,$c=count($rss_urls);$i<$c;$i++) {
|
||||
for($i=0,$c=count($rss_urls);$i<$c;$i++)
|
||||
{
|
||||
if($rss_urls[$i]) $args->rss_urls[] = $rss_urls[$i];
|
||||
}
|
||||
// Get module information after listing module_srls if the module is not RSS
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply to all modules in the site if a target module is not specified
|
||||
if(!$args->module_srls){
|
||||
if(!$args->module_srls)
|
||||
{
|
||||
unset($obj);
|
||||
$obj->site_srl = (int)$site_module_info->site_srl;
|
||||
$output = executeQueryArray('widgets.content.getMids', $obj);
|
||||
if($output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$args->modules_info[$val->mid] = $val;
|
||||
$args->module_srls_info[$val->module_srl] = $val;
|
||||
$args->mid_lists[$val->module_srl] = $val->mid;
|
||||
|
|
@ -60,17 +67,22 @@
|
|||
|
||||
$args->modules_info = $oModuleModel->getMidList($obj);
|
||||
// Apply to the module only if a target module is specified
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj->module_srls = $args->module_srls;
|
||||
$output = executeQueryArray('widgets.content.getMids', $obj);
|
||||
if($output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$args->modules_info[$val->mid] = $val;
|
||||
$args->module_srls_info[$val->module_srl] = $val;
|
||||
$module_srls[] = $val->module_srl;
|
||||
}
|
||||
$idx = explode(',',$args->module_srls);
|
||||
for($i=0,$c=count($idx);$i<$c;$i++) {
|
||||
for($i=0,$c=count($idx);$i<$c;$i++)
|
||||
{
|
||||
$srl = $idx[$i];
|
||||
if(!$args->module_srls_info[$srl]) continue;
|
||||
$args->mid_lists[$srl] = $args->module_srls_info[$srl]->mid;
|
||||
|
|
@ -84,10 +96,12 @@
|
|||
|
||||
/**
|
||||
* Method is separately made because content extraction, articles, comments, trackbacks, RSS and other elements exist
|
||||
**/
|
||||
*/
|
||||
// tab mode
|
||||
if($args->tab_type == 'none' || $args->tab_type == '') {
|
||||
switch($args->content_type){
|
||||
if($args->tab_type == 'none' || $args->tab_type == '')
|
||||
{
|
||||
switch($args->content_type)
|
||||
{
|
||||
case 'comment':
|
||||
$content_items = $this->_getCommentItems($args);
|
||||
break;
|
||||
|
|
@ -105,18 +119,23 @@
|
|||
break;
|
||||
}
|
||||
// If not a tab type
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$content_items = array();
|
||||
|
||||
switch($args->content_type){
|
||||
switch($args->content_type)
|
||||
{
|
||||
case 'comment':
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$content_items[$module_srl] = $this->_getCommentItems($args);
|
||||
}
|
||||
break;
|
||||
case 'image':
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$content_items[$module_srl] = $this->_getImageItems($args);
|
||||
}
|
||||
|
|
@ -131,7 +150,8 @@
|
|||
}
|
||||
break;
|
||||
default:
|
||||
foreach($args->mid_lists as $module_srl => $mid){
|
||||
foreach($args->mid_lists as $module_srl => $mid)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$content_items[$module_srl] = $this->_getDocumentItems($args);
|
||||
}
|
||||
|
|
@ -145,8 +165,9 @@
|
|||
|
||||
/**
|
||||
* @brief Return to the list of comments extracted mcontentItem
|
||||
**/
|
||||
function _getCommentItems($args) {
|
||||
*/
|
||||
function _getCommentItems($args)
|
||||
{
|
||||
// CommentModel:: getCommentList() to take advantage of the variable order
|
||||
$obj->module_srl = $args->module_srl;
|
||||
$obj->sort_index = $args->order_target;
|
||||
|
|
@ -159,7 +180,8 @@
|
|||
|
||||
if(!count($output)) return;
|
||||
|
||||
foreach($output as $key => $oComment) {
|
||||
foreach($output as $key => $oComment)
|
||||
{
|
||||
$attribute = $oComment->getObjectVars();
|
||||
$title = $oComment->getSummary($args->content_cut_size);
|
||||
$thumbnail = $oComment->getThumbnail();
|
||||
|
|
@ -181,14 +203,17 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function _getDocumentItems($args){
|
||||
function _getDocumentItems($args)
|
||||
{
|
||||
// Get model object of the document module and make the result as an object
|
||||
$oDocumentModel = &getModel('document');
|
||||
// Get categories
|
||||
$obj->module_srl = $args->module_srl;
|
||||
$output = executeQueryArray('widgets.content.getCategories',$obj);
|
||||
if($output->toBool() && $output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->toBool() && $output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$category_lists[$val->module_srl][$val->category_srl] = $val;
|
||||
}
|
||||
}
|
||||
|
|
@ -203,8 +228,10 @@
|
|||
// If the result exists, make each document as an object
|
||||
$content_items = array();
|
||||
$first_thumbnail_idx = -1;
|
||||
if(count($output->data)) {
|
||||
foreach($output->data as $key => $attribute) {
|
||||
if(count($output->data))
|
||||
{
|
||||
foreach($output->data as $key => $attribute)
|
||||
{
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($attribute, false);
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$oDocument->document_srl] = $oDocument;
|
||||
|
|
@ -212,7 +239,8 @@
|
|||
}
|
||||
$oDocumentModel->setToAllDocumentExtraVars();
|
||||
|
||||
for($i=0,$c=count($document_srls);$i<$c;$i++) {
|
||||
for($i=0,$c=count($document_srls);$i<$c;$i++)
|
||||
{
|
||||
$oDocument = $GLOBALS['XE_DOCUMENT_LIST'][$document_srls[$i]];
|
||||
$document_srl = $oDocument->document_srl;
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
|
|
@ -236,7 +264,8 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function _getImageItems($args) {
|
||||
function _getImageItems($args)
|
||||
{
|
||||
$oDocumentModel = &getModel('document');
|
||||
|
||||
$obj->module_srls = $obj->module_srl = $args->module_srl;
|
||||
|
|
@ -244,8 +273,10 @@
|
|||
$obj->isvalid = 'Y';
|
||||
// Get categories
|
||||
$output = executeQueryArray('widgets.content.getCategories',$obj);
|
||||
if($output->toBool() && $output->data) {
|
||||
foreach($output->data as $key => $val) {
|
||||
if($output->toBool() && $output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$category_lists[$val->module_srl][$val->category_srl] = $val;
|
||||
}
|
||||
}
|
||||
|
|
@ -263,7 +294,8 @@
|
|||
|
||||
if(!count($tmp_document_list)) return;
|
||||
|
||||
foreach($tmp_document_list as $oDocument){
|
||||
foreach($tmp_document_list as $oDocument)
|
||||
{
|
||||
$attribute = $oDocument->getObjectVars();
|
||||
$browser_title = $args->module_srls_info[$attribute->module_srl]->browser_title;
|
||||
$domain = $args->module_srls_info[$attribute->module_srl]->domain;
|
||||
|
|
@ -286,25 +318,30 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function getRssItems($args){
|
||||
|
||||
function getRssItems($args)
|
||||
{
|
||||
$content_items = array();
|
||||
$args->mid_lists = array();
|
||||
|
||||
foreach($args->rss_urls as $key => $rss){
|
||||
foreach($args->rss_urls as $key => $rss)
|
||||
{
|
||||
$args->rss_url = $rss;
|
||||
$content_item = $this->_getRssItems($args);
|
||||
if(count($content_item) > 0){
|
||||
if(count($content_item) > 0)
|
||||
{
|
||||
$browser_title = $content_item[0]->getBrowserTitle();
|
||||
$args->mid_lists[] = $browser_title;
|
||||
$content_items[] = $content_item;
|
||||
}
|
||||
}
|
||||
|
||||
if($args->tab_type == 'none' || $args->tab_type == ''){
|
||||
if($args->tab_type == 'none' || $args->tab_type == '')
|
||||
{
|
||||
$items = array();
|
||||
foreach($content_items as $key => $val){
|
||||
foreach($val as $k => $v){
|
||||
foreach($content_items as $key => $val)
|
||||
{
|
||||
foreach($val as $k => $v)
|
||||
{
|
||||
$date = $v->get('regdate');
|
||||
$i=0;
|
||||
while(array_key_exists(sprintf('%s%02d',$date,$i), $items)) $i++;
|
||||
|
|
@ -317,13 +354,16 @@
|
|||
} return $content_items;
|
||||
}
|
||||
|
||||
function _getRssBody($value) {
|
||||
function _getRssBody($value)
|
||||
{
|
||||
if(!$value || is_string($value)) return $value;
|
||||
if(is_object($value)) $value = get_object_vars($value);
|
||||
$body = null;
|
||||
if(!count($value)) return;
|
||||
foreach($value as $key => $val) {
|
||||
if($key == 'body') {
|
||||
foreach($value as $key => $val)
|
||||
{
|
||||
if($key == 'body')
|
||||
{
|
||||
$body = $val;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -357,13 +397,15 @@
|
|||
/**
|
||||
* @brief function to receive contents from rss url
|
||||
* For Tistory blog in Korea, the original RSS url has location header without contents. Fixed to work as same as rss_reader widget.
|
||||
**/
|
||||
function requestFeedContents($rss_url) {
|
||||
*/
|
||||
function requestFeedContents($rss_url)
|
||||
{
|
||||
$rss_url = str_replace('&','&',Context::convertEncodingStr($rss_url));
|
||||
return FileHandler::getRemoteResource($rss_url, null, 3, 'GET', 'application/xml');
|
||||
}
|
||||
|
||||
function _getRssItems($args){
|
||||
function _getRssItems($args)
|
||||
{
|
||||
// Date Format
|
||||
$DATE_FORMAT = $args->date_format ? $args->date_format : "Y-m-d H:i:s";
|
||||
|
||||
|
|
@ -376,7 +418,8 @@
|
|||
|
||||
$oXmlParser = new XmlParser();
|
||||
$xml_doc = $oXmlParser->parse($buff);
|
||||
if($xml_doc->rss) {
|
||||
if($xml_doc->rss)
|
||||
{
|
||||
$rss->title = $xml_doc->rss->channel->title->body;
|
||||
$rss->link = $xml_doc->rss->channel->link->body;
|
||||
|
||||
|
|
@ -387,11 +430,13 @@
|
|||
|
||||
$content_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
foreach ($items as $key => $value)
|
||||
{
|
||||
if($key >= $args->list_count) break;
|
||||
unset($item);
|
||||
|
||||
foreach($value as $key2 => $value2) {
|
||||
foreach($value as $key2 => $value2)
|
||||
{
|
||||
if(is_array($value2)) $value2 = array_shift($value2);
|
||||
$item->{$key2} = $this->_getRssBody($value2);
|
||||
}
|
||||
|
|
@ -409,7 +454,9 @@
|
|||
|
||||
$content_items[] = $content_item;
|
||||
}
|
||||
} elseif($xml_doc->{'rdf:rdf'}) {
|
||||
}
|
||||
else if($xml_doc->{'rdf:rdf'})
|
||||
{
|
||||
// rss1.0 supported (XE's XML is case-insensitive because XML parser converts all to small letters) Fixed by misol
|
||||
$rss->title = $xml_doc->{'rdf:rdf'}->channel->title->body;
|
||||
$rss->link = $xml_doc->{'rdf:rdf'}->channel->link->body;
|
||||
|
|
@ -421,11 +468,13 @@
|
|||
|
||||
$content_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
foreach ($items as $key => $value)
|
||||
{
|
||||
if($key >= $args->list_count) break;
|
||||
unset($item);
|
||||
|
||||
foreach($value as $key2 => $value2) {
|
||||
foreach($value as $key2 => $value2)
|
||||
{
|
||||
if(is_array($value2)) $value2 = array_shift($value2);
|
||||
$item->{$key2} = $this->_getRssBody($value2);
|
||||
}
|
||||
|
|
@ -443,19 +492,23 @@
|
|||
|
||||
$content_items[] = $content_item;
|
||||
}
|
||||
} elseif($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') {
|
||||
}
|
||||
else if($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') {
|
||||
// Atom 1.0 spec supported by misol
|
||||
$rss->title = $xml_doc->feed->title->body;
|
||||
$links = $xml_doc->feed->link;
|
||||
if(is_array($links)) {
|
||||
foreach ($links as $value) {
|
||||
if($value->attrs->rel == 'alternate') {
|
||||
if(is_array($links))
|
||||
{
|
||||
foreach ($links as $value)
|
||||
{
|
||||
if($value->attrs->rel == 'alternate')
|
||||
{
|
||||
$rss->link = $value->attrs->href;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href;
|
||||
else if($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href;
|
||||
|
||||
$items = $xml_doc->feed->entry;
|
||||
|
||||
|
|
@ -464,29 +517,35 @@
|
|||
|
||||
$content_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
foreach ($items as $key => $value)
|
||||
{
|
||||
if($key >= $args->list_count) break;
|
||||
unset($item);
|
||||
|
||||
foreach($value as $key2 => $value2) {
|
||||
foreach($value as $key2 => $value2)
|
||||
{
|
||||
if(is_array($value2)) $value2 = array_shift($value2);
|
||||
$item->{$key2} = $this->_getRssBody($value2);
|
||||
}
|
||||
|
||||
$content_item = new mcontentItem($rss->title);
|
||||
$links = $value->link;
|
||||
if(is_array($links)) {
|
||||
foreach ($links as $val) {
|
||||
if($val->attrs->rel == 'alternate') {
|
||||
if(is_array($links))
|
||||
{
|
||||
foreach ($links as $val)
|
||||
{
|
||||
if($val->attrs->rel == 'alternate')
|
||||
{
|
||||
$item->link = $val->attrs->href;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($links->attrs->rel == 'alternate') $item->link = $links->attrs->href;
|
||||
else if($links->attrs->rel == 'alternate') $item->link = $links->attrs->href;
|
||||
|
||||
$content_item->setContentsLink($rss->link);
|
||||
if($item->title) {
|
||||
if($item->title)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->title->attrs->type)) $item->title = $value->title->body;
|
||||
}
|
||||
$content_item->setTitle($item->title);
|
||||
|
|
@ -494,12 +553,15 @@
|
|||
$content_item->setAuthorSite($value->author->uri->body);
|
||||
//$content_item->setCategory($item->category);
|
||||
$item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->content);
|
||||
if($item->description) {
|
||||
if($item->description)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->content->attrs->type)) $item->description = htmlspecialchars($item->description);
|
||||
}
|
||||
if(!$item->description) {
|
||||
if(!$item->description)
|
||||
{
|
||||
$item->description = $item->summary;
|
||||
if($item->description) {
|
||||
if($item->description)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->summary->attrs->type)) $item->description = htmlspecialchars($item->description);
|
||||
}
|
||||
}
|
||||
|
|
@ -517,7 +579,8 @@
|
|||
function _getTrackbackItems($args){
|
||||
// Get categories
|
||||
$output = executeQueryArray('widgets.content.getCategories',$obj);
|
||||
if($output->toBool() && $output->data) {
|
||||
if($output->toBool() && $output->data)
|
||||
{
|
||||
foreach($output->data as $key => $val) {
|
||||
$category_lists[$val->module_srl][$val->category_srl] = $val;
|
||||
}
|
||||
|
|
@ -533,7 +596,8 @@
|
|||
if(!$output->toBool() || !$output->data) return;
|
||||
// If the result exists, make each document as an object
|
||||
$content_items = array();
|
||||
foreach($output->data as $key => $item) {
|
||||
foreach($output->data as $key => $item)
|
||||
{
|
||||
$domain = $args->module_srls_info[$item->module_srl]->domain;
|
||||
$category = $category_lists[$item->module_srl]->text;
|
||||
$url = getSiteUrl($domain,'','document_srl',$item->document_srl);
|
||||
|
|
@ -554,7 +618,8 @@
|
|||
return $content_items;
|
||||
}
|
||||
|
||||
function _compile($args,$content_items){
|
||||
function _compile($args,$content_items)
|
||||
{
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
// Set variables for widget
|
||||
$widget_info->modules_info = $args->modules_info;
|
||||
|
|
@ -589,9 +654,10 @@
|
|||
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
|
||||
return $oTemplate->compile($tpl_path, "content");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class mcontentItem extends Object {
|
||||
class mcontentItem extends Object
|
||||
{
|
||||
|
||||
var $browser_title = null;
|
||||
var $has_first_thumbnail_idx = false;
|
||||
|
|
@ -599,76 +665,97 @@
|
|||
var $contents_link = null;
|
||||
var $domain = null;
|
||||
|
||||
function mcontentItem($browser_title=''){
|
||||
function mcontentItem($browser_title='')
|
||||
{
|
||||
$this->browser_title = $browser_title;
|
||||
}
|
||||
function setContentsLink($link){
|
||||
function setContentsLink($link)
|
||||
{
|
||||
$this->contents_link = $link;
|
||||
}
|
||||
function setFirstThumbnailIdx($first_thumbnail_idx){
|
||||
function setFirstThumbnailIdx($first_thumbnail_idx)
|
||||
{
|
||||
if(is_null($this->first_thumbnail) && $first_thumbnail_idx>-1) {
|
||||
$this->has_first_thumbnail_idx = true;
|
||||
$this->first_thumbnail_idx= $first_thumbnail_idx;
|
||||
}
|
||||
}
|
||||
function setExtraImages($extra_images){
|
||||
function setExtraImages($extra_images)
|
||||
{
|
||||
$this->add('extra_images',$extra_images);
|
||||
}
|
||||
function setDomain($domain) {
|
||||
function setDomain($domain)
|
||||
{
|
||||
static $default_domain = null;
|
||||
if(!$domain) {
|
||||
if(!$domain)
|
||||
{
|
||||
if(is_null($default_domain)) $default_domain = Context::getDefaultUrl();
|
||||
$domain = $default_domain;
|
||||
}
|
||||
$this->domain = $domain;
|
||||
}
|
||||
function setLink($url){
|
||||
function setLink($url)
|
||||
{
|
||||
$this->add('url',$url);
|
||||
}
|
||||
function setTitle($title){
|
||||
function setTitle($title)
|
||||
{
|
||||
$this->add('title',$title);
|
||||
}
|
||||
|
||||
function setThumbnail($thumbnail){
|
||||
function setThumbnail($thumbnail)
|
||||
{
|
||||
$this->add('thumbnail',$thumbnail);
|
||||
}
|
||||
function setContent($content){
|
||||
function setContent($content)
|
||||
{
|
||||
$this->add('content',$content);
|
||||
}
|
||||
function setRegdate($regdate){
|
||||
function setRegdate($regdate)
|
||||
{
|
||||
$this->add('regdate',$regdate);
|
||||
}
|
||||
function setNickName($nick_name){
|
||||
function setNickName($nick_name)
|
||||
{
|
||||
$this->add('nick_name',$nick_name);
|
||||
}
|
||||
// Save author's homepage url by misol
|
||||
function setAuthorSite($site_url){
|
||||
function setAuthorSite($site_url)
|
||||
{
|
||||
$this->add('author_site',$site_url);
|
||||
}
|
||||
function setCategory($category){
|
||||
function setCategory($category)
|
||||
{
|
||||
$this->add('category',$category);
|
||||
}
|
||||
function getBrowserTitle(){
|
||||
function getBrowserTitle()
|
||||
{
|
||||
return $this->browser_title;
|
||||
}
|
||||
function getDomain() {
|
||||
function getDomain()
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
function getContentsLink(){
|
||||
function getContentsLink()
|
||||
{
|
||||
return $this->contents_link;
|
||||
}
|
||||
|
||||
function getFirstThumbnailIdx(){
|
||||
function getFirstThumbnailIdx()
|
||||
{
|
||||
return $this->first_thumbnail_idx;
|
||||
}
|
||||
|
||||
function getLink(){
|
||||
function getLink()
|
||||
{
|
||||
return $this->get('url');
|
||||
}
|
||||
function getModuleSrl(){
|
||||
function getModuleSrl()
|
||||
{
|
||||
return $this->get('module_srl');
|
||||
}
|
||||
function getTitle($cut_size = 0, $tail='...'){
|
||||
function getTitle($cut_size = 0, $tail='...')
|
||||
{
|
||||
$title = strip_tags($this->get('title'));
|
||||
|
||||
if($cut_size) $title = cut_str($title, $cut_size, $tail);
|
||||
|
|
@ -681,40 +768,52 @@
|
|||
|
||||
return $title;
|
||||
}
|
||||
function getContent(){
|
||||
function getContent()
|
||||
{
|
||||
return $this->get('content');
|
||||
}
|
||||
function getCategory(){
|
||||
function getCategory()
|
||||
{
|
||||
return $this->get('category');
|
||||
}
|
||||
function getNickName(){
|
||||
function getNickName()
|
||||
{
|
||||
return $this->get('nick_name');
|
||||
}
|
||||
function getAuthorSite(){
|
||||
function getAuthorSite()
|
||||
{
|
||||
return $this->get('author_site');
|
||||
}
|
||||
function getCommentCount(){
|
||||
function getCommentCount()
|
||||
{
|
||||
$comment_count = $this->get('comment_count');
|
||||
return $comment_count>0 ? $comment_count : '';
|
||||
}
|
||||
function getTrackbackCount(){
|
||||
function getTrackbackCount()
|
||||
{
|
||||
$trackback_count = $this->get('trackback_count');
|
||||
return $trackback_count>0 ? $trackback_count : '';
|
||||
}
|
||||
function getRegdate($format = 'Y.m.d H:i:s') {
|
||||
function getRegdate($format = 'Y.m.d H:i:s')
|
||||
{
|
||||
return zdate($this->get('regdate'), $format);
|
||||
}
|
||||
function printExtraImages() {
|
||||
function printExtraImages()
|
||||
{
|
||||
return $this->get('extra_images');
|
||||
}
|
||||
function haveFirstThumbnail() {
|
||||
function haveFirstThumbnail()
|
||||
{
|
||||
return $this->has_first_thumbnail_idx;
|
||||
}
|
||||
function getThumbnail(){
|
||||
function getThumbnail()
|
||||
{
|
||||
return $this->get('thumbnail');
|
||||
}
|
||||
function getMemberSrl() {
|
||||
function getMemberSrl()
|
||||
{
|
||||
return $this->get('member_srl');
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file mcontent.class.php */
|
||||
/* Location: ./widgets/mcontent/mcontent.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue