Ejemplo n.º 1
0
 function _getRssItems($args)
 {
     // Date Format
     $DATE_FORMAT = $args->date_format ? $args->date_format : "Y-m-d H:i:s";
     $buff = $this->requestFeedContents($args->rss_url);
     $encoding = preg_match("/<\\?xml.*encoding=\"(.+)\".*\\?>/i", $buff, $matches);
     if ($encoding && !preg_match("/UTF-8/i", $matches[1])) {
         $buff = Context::convertEncodingStr($buff);
     }
     $buff = preg_replace("/<\\?xml.*\\?>/i", "", $buff);
     $oXmlParser = new XmlParser();
     $xml_doc = $oXmlParser->parse($buff);
     if ($xml_doc->rss) {
         $rss->title = $xml_doc->rss->channel->title->body;
         $rss->link = $xml_doc->rss->channel->link->body;
         $items = $xml_doc->rss->channel->item;
         if (!$items) {
             return;
         }
         if ($items && !is_array($items)) {
             $items = array($items);
         }
         $content_items = array();
         foreach ($items as $key => $value) {
             if ($key >= $args->list_count * $args->page_count) {
                 break;
             }
             unset($item);
             foreach ($value as $key2 => $value2) {
                 if (is_array($value2)) {
                     $value2 = array_shift($value2);
                 }
                 $item->{$key2} = $this->_getRssBody($value2);
             }
             $content_item = new contentItem($rss->title);
             $content_item->setContentsLink($rss->link);
             $content_item->setTitle($item->title);
             $content_item->setNickName(max($item->author, $item->{'dc:creator'}));
             //$content_item->setCategory($item->category);
             $item->description = preg_replace('!<a href=!is', '<a onclick="window.open(this.href);return false" href=', $item->description);
             $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
             $content_item->setThumbnail($this->_getRssThumbnail($item->description));
             $content_item->setLink($item->link);
             $date = date('YmdHis', strtotime(max($item->pubdate, $item->pubDate, $item->{'dc:date'})));
             $content_item->setRegdate($date);
             $content_items[] = $content_item;
         }
     } elseif ($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;
         $items = $xml_doc->{'rdf:rdf'}->item;
         if (!$items) {
             return;
         }
         if ($items && !is_array($items)) {
             $items = array($items);
         }
         $content_items = array();
         foreach ($items as $key => $value) {
             if ($key >= $args->list_count * $args->page_count) {
                 break;
             }
             unset($item);
             foreach ($value as $key2 => $value2) {
                 if (is_array($value2)) {
                     $value2 = array_shift($value2);
                 }
                 $item->{$key2} = $this->_getRssBody($value2);
             }
             $content_item = new contentItem($rss->title);
             $content_item->setContentsLink($rss->link);
             $content_item->setTitle($item->title);
             $content_item->setNickName(max($item->author, $item->{'dc:creator'}));
             //$content_item->setCategory($item->category);
             $item->description = preg_replace('!<a href=!is', '<a onclick="window.open(this.href);return false" href=', $item->description);
             $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
             $content_item->setThumbnail($this->_getRssThumbnail($item->description));
             $content_item->setLink($item->link);
             $date = date('YmdHis', strtotime(max($item->pubdate, $item->pubDate, $item->{'dc:date'})));
             $content_item->setRegdate($date);
             $content_items[] = $content_item;
         }
     } elseif ($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') {
                     $rss->link = $value->attrs->href;
                     break;
                 }
             }
         } elseif ($links->attrs->rel == 'alternate') {
             $rss->link = $links->attrs->href;
         }
         $items = $xml_doc->feed->entry;
         if (!$items) {
             return;
         }
         if ($items && !is_array($items)) {
             $items = array($items);
         }
         $content_items = array();
         foreach ($items as $key => $value) {
             if ($key >= $args->list_count * $args->page_count) {
                 break;
             }
             unset($item);
             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') {
                         $item->link = $val->attrs->href;
                         break;
                     }
                 }
             } elseif ($links->attrs->rel == 'alternate') {
                 $item->link = $links->attrs->href;
             }
             $content_item->setContentsLink($rss->link);
             if ($item->title) {
                 if (!preg_match("/html/i", $value->title->attrs->type)) {
                     $item->title = $value->title->body;
                 }
             }
             $content_item->setTitle($item->title);
             $content_item->setNickName(max($item->author, $item->{'dc:creator'}));
             $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 (!preg_match("/html/i", $value->content->attrs->type)) {
                     $item->description = htmlspecialchars($item->description);
                 }
             }
             if (!$item->description) {
                 $item->description = $item->summary;
                 if ($item->description) {
                     if (!preg_match("/html/i", $value->summary->attrs->type)) {
                         $item->description = htmlspecialchars($item->description);
                     }
                 }
             }
             $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
             $content_item->setThumbnail($this->_getRssThumbnail($item->description));
             $content_item->setLink($item->link);
             $date = date('YmdHis', strtotime(max($item->published, $item->updated, $item->{'dc:date'})));
             $content_item->setRegdate($date);
             $content_items[] = $content_item;
         }
     }
     return $content_items;
 }
Ejemplo n.º 2
0
 function _getImageItems($args)
 {
     $oDocumentModel =& getModel('document');
     $obj->module_srls = $obj->module_srl = $args->module_srl;
     $obj->direct_download = 'Y';
     $obj->isvalid = 'Y';
     // 분류 구함
     $output = executeQueryArray('widgets.content.getCategories', $obj);
     if ($output->toBool() && $output->data) {
         foreach ($output->data as $key => $val) {
             $category_lists[$val->module_srl][$val->category_srl] = $val;
         }
     }
     // 정해진 모듈에서 문서별 파일 목록을 구함
     $obj->list_count = $args->list_count * $args->page_count;
     $files_output = executeQueryArray("file.getOneFileInDocument", $obj);
     $files_count = count($files_output->data);
     if (!$files_count) {
         return;
     }
     $content_items = array();
     for ($i = 0; $i < $files_count; $i++) {
         $document_srl_list[] = $files_output->data[$i]->document_srl;
     }
     $tmp_document_list = $oDocumentModel->getDocuments($document_srl_list);
     if (!count($tmp_document_list)) {
         return;
     }
     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;
         $category = $category_lists[$attribute->module_srl]->text;
         $content = $oDocument->getSummary($args->content_cut_size);
         $url = sprintf("%s#%s", $oDocument->getPermanentUrl(), $oDocument->getCommentCount());
         $thumbnail = $oDocument->getThumbnail($args->thumbnail_width, $args->thumbnail_height, $args->thumbnail_type);
         $extra_images = $oDocument->printExtraImages($args->duration_new);
         $content_item = new contentItem($browser_title);
         $content_item->adds($attribute);
         $content_item->setCategory($category);
         $content_item->setContent($content);
         $content_item->setLink($url);
         $content_item->setThumbnail($thumbnail);
         $content_item->setExtraImages($extra_images);
         $content_item->setDomain($domain);
         $content_item->add('mid', $args->mid_lists[$attribute->module_srl]);
         $content_items[] = $content_item;
     }
     return $content_items;
 }
Ejemplo n.º 3
0
 function _getDocumentItems($args)
 {
     // Get model object from the document module
     $oDocumentModel =& getModel('document');
     // Get categories
     $obj = new stdClass();
     $obj->module_srl = $args->module_srl;
     $output = executeQueryArray('widgets.flatContent.getCategories', $obj);
     if ($output->toBool() && $output->data) {
         foreach ($output->data as $key => $val) {
             $category_lists[$val->module_srl][$val->category_srl] = $val;
         }
     }
     // Get a list of documents
     $obj->module_srl = $args->module_srl;
     $obj->category_srl = $args->category_srl;
     $obj->sort_index = $args->order_target;
     if ($args->order_target == 'list_order' || $args->order_target == 'update_order') {
         $obj->order_type = $args->order_type == "desc" ? "asc" : "desc";
     } else {
         $obj->order_type = $args->order_type == "desc" ? "desc" : "asc";
     }
     $obj->list_count = $args->list_count * $args->page_count;
     $obj->statusList = array('PUBLIC');
     if ($args->regdate) {
         $obj->regdate = date("Ymd", strtotime("-{$args->regdate} day"));
     }
     $output = executeQueryArray('widgets.flatContent.getNewestDocuments', $obj);
     if (!$output->toBool() || !$output->data) {
         return;
     }
     // 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) {
             $oDocument = new documentItem();
             $oDocument->setAttribute($attribute, false);
             $GLOBALS['XE_DOCUMENT_LIST'][$oDocument->document_srl] = $oDocument;
             $document_srls[] = $oDocument->document_srl;
         }
         $oDocumentModel->setToAllDocumentExtraVars();
         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');
             $category_srl = $oDocument->get('category_srl');
             $thumbnail = $oDocument->getThumbnail($args->thumbnail_width, $args->thumbnail_height, $args->thumbnail_type);
             $content_item = new contentItem($args->module_srls_info[$module_srl]->browser_title);
             $content_item->adds($oDocument->getObjectVars());
             $content_item->add('original_content', $oDocument->get('content'));
             $content_item->setTitle($oDocument->getTitleText());
             $content_item->setCategory($category_lists[$module_srl][$category_srl]->title);
             $content_item->setDomain($args->module_srls_info[$module_srl]->domain);
             $content_item->setContent($oDocument->getSummary($args->content_cut_size));
             $content_item->setLink(getSiteUrl($domain, '', 'document_srl', $document_srl));
             $content_item->setThumbnail($thumbnail);
             $content_item->setExtraImages($oDocument->printExtraImages($args->duration_new * 60 * 60));
             $content_item->add('mid', $args->mid_lists[$module_srl]);
             if ($first_thumbnail_idx == -1 && $thumbnail) {
                 $first_thumbnail_idx = $i;
             }
             $content_items[] = $content_item;
         }
         $content_items[0]->setFirstThumbnailIdx($first_thumbnail_idx);
     }
     $oSecurity = new Security($content_items);
     $oSecurity->encodeHTML('..variables.content', '..variables.user_name', '..variables.nick_name');
     return $content_items;
 }