Beispiel #1
0
 function feed($id, $showFeed)
 {
     global $database, $mainframe;
     global $mosConfig_live_site, $mosConfig_offset, $mosConfig_absolute_path;
     $params = rdRss::getParameters($id);
     //print_r($params);
     // set filename for live bookmarks feed
     if (!$showFeed & $params->live_bookmark) {
         // standard bookmark filename
         $params->file = $mosConfig_absolute_path . '/cache/' . $params->live_bookmark . "_" . $id;
     } else {
         // set filename for rss feeds
         $params->file = strtolower(str_replace('.', '', $params->feed));
         $params->file = $mosConfig_absolute_path . '/cache/' . $params->file . "_" . $id . '.xml';
     }
     // load feed creator class
     $rss = new UniversalFeedCreator();
     // load image creator class
     $image = new FeedImage();
     // loads cache file
     if ($showFeed && $params->cache) {
         $rss->useCached($params->feed, $params->file, $params->cache_time);
     }
     $rss->title = $params->title;
     $rss->description = $params->description;
     $rss->link = $params->link;
     $rss->syndicationURL = $params->link;
     $rss->cssStyleSheet = NULL;
     $rss->encoding = $params->encoding;
     if ($params->image) {
         $image->url = $params->image;
         $image->link = $params->link;
         $image->title = $params->image_alt;
         $image->description = $params->description;
         // loads image info into rss array
         $rss->image = $image;
     }
     if ($id == '1') {
         $fp = 1;
     } else {
         $fp = 0;
     }
     $rows = rdRss::getData($params, $fp);
     if (count($rows) && $params->published) {
         foreach ($rows as $row) {
             // title for particular item
             $item_title = htmlspecialchars($row->title);
             $item_title = html_entity_decode($item_title);
             // url link to article
             // & used instead of & as this is converted by feed creator
             $item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $mainframe->getItemid($row->id);
             $item_link = sefRelToAbs($item_link);
             // removes all formating from the intro text for the description text
             $item_description = $row->introtext;
             $item_description = mosHTML::cleanText($item_description);
             $item_description = html_entity_decode($item_description);
             if ($params->limit_text) {
                 if ($params->text_length) {
                     // limits description text to x words
                     $item_description_array = split(' ', $item_description);
                     $count = count($item_description_array);
                     if ($count > $params->text_length) {
                         $item_description = '';
                         for ($a = 0; $a < $params->text_length; $a++) {
                             $item_description .= $item_description_array[$a] . ' ';
                         }
                         $item_description = trim($item_description);
                         $item_description .= '...';
                     }
                 } else {
                     // do not include description when text_length = 0
                     $item_description = NULL;
                 }
             }
             // load individual item creator class
             $item = new FeedItem();
             // item info
             $item->title = $item_title;
             $item->link = $item_link;
             $item->description = $item_description;
             $item->source = $params->link;
             $item->date = date('r', $row->created_ts);
             // loads item info into rss array
             $rss->addItem($item);
         }
     }
     //save feed file
     $rss->saveFeed($params->feed, $params->file, $showFeed);
 }
Beispiel #2
0
    case "edit":
    case "editA":
        rdRss::edit($option, $task, $id);
        break;
    case "del":
        rdRss::del($option, $section, $task, $cid);
        break;
    case "publish":
        rdRss::changePublished($cid, 1, $option, $task);
        break;
    case "unpublish":
        rdRss::changePublished($cid, 0, $option, $task);
        break;
    case "list":
    default:
        rdRss::show($option, 'list');
        break;
}
class rdRss
{
    // ---------------------------------------------------------------
    /**
     *
     * @param $option
     */
    function changePublished($cid = null, $state = 0, $option, $task)
    {
        global $database, $my;
        if (count($cid) < 1) {
            $action = $state == 1 ? _RDRSS_PUBLISHED : _RDRSS_UNPUBLISHED;
            echo "<script> alert('" . _RDRSS_SELITEM . " {$action}'); window.history.go(-1);</script>\n";