示例#1
0
 public static function getInstance()
 {
     if (self::$instance === NULL) {
         self::$instance = new SubscriptionStorage();
     }
     return self::$instance;
 }
示例#2
0
            if ($sub->isActive) {
                $tempdata = str_replace('{isactive}', 'checked="checked"', $tempdata);
            } else {
                $tempdata = str_replace('{isactive}', '', $tempdata);
            }
            echo $tempdata;
        }
    } else {
        echo "Subscription list empty";
    }
}
// if we come from the zebrabar, zflist is in the _GET array
/*if (isset($_GET['zflist']) && $_GET['zflist']!='') {
	$_POST['zflist'] = $_GET['zflist'];
}*/
$storage = SubscriptionStorage::getInstance();
//----------------------------------------------------------------------------
/* display channels list, with list control form on top */
?>
	<div id="core">

<?php 
$subs = $storage->getSubscriptions();
if (ZF_SORT == 'feed') {
    $sortedChannels = sortChannelsByPosition($subs);
} else {
    $sortedChannels = sortChannelsByName($subs);
}
?>
		<script type="text/javascript">
			var currentid = -1;
示例#3
0
function handleRequest()
{
    $type = param('q', 'tag');
    $outputType = param('f', 'html');
    switch ($type) {
        case 'item':
            //refresh: always from cache
            $zf_aggregator = new Aggregator();
            $item = $zf_aggregator->getItem(param('itemid'));
            $view = zf_createView($outputType);
            $view->renderArticle($item);
            break;
        case 'download-item':
            //refresh: always from cache
            $zf_aggregator = new Aggregator();
            $item = $zf_aggregator->downloadItem(param('itemid'));
            $view = zf_createView($outputType);
            $view->renderArticle($item);
            break;
        case 'save-item':
            //refresh: always from cache
            $zf_aggregator = new Aggregator();
            $item = $zf_aggregator->saveItem(param('itemid'), param('save', 1));
            $view = zf_createView($outputType);
            $view->renderArticle($item);
            break;
        case 'summary':
            //refresh: always from cache
            $zf_aggregator = new Aggregator();
            $item = $zf_aggregator->getItem(param('itemid'));
            $view = zf_createView($outputType);
            $view->renderSummary($item);
            break;
        case 'channel':
            //refresh: user defined
            $zf_aggregator = new Aggregator();
            $feed = $zf_aggregator->getPublisherFeed(param('id'), param('mode', ZF_REFRESHMODE == 'automatic' ? 'auto' : 'none'), param('trim', 'auto'), int_param('onlynew', ZF_ONLYNEW == 'no' ? 0 : 1));
            $view = zf_createView($outputType);
            $view->renderFeed($feed, array('groupbyday' => false, 'decoration' => int_param('decoration'), 'summary' => param('sum', 1) == 1));
            break;
        case 'tag':
            //refresh: always auto refresh for tag view
            // if html output & sorted by feed, trim every single item
            // according to subcription's settings
            $sort = param('sort', ZF_SORT);
            if ($sort == 'feed' && strstr($outputType, 'html')) {
                $groupbyday = false;
                $aggregate = false;
            } else {
                // otherwise just aggregate in a single feed
                $groupbyday = true;
                $aggregate = true;
            }
            $zf_aggregator = new Aggregator();
            $tag = param('tag', ZF_HOMETAG);
            $feeds = $zf_aggregator->getFeedsForTag($tag, $aggregate, $trim = param('trim', 'auto'), int_param('onlynew', ZF_ONLYNEW == 'no' ? 0 : 1));
            zf_debugRuntime("before rendering");
            $view = zf_createView($outputType);
            $view->renderFeedList($feeds, array('groupbyday' => $groupbyday, 'summary' => int_param('sum', 1) == 1, 'tag' => $tag));
            break;
        case 'subs':
            //only JSON
            $subs = SubscriptionStorage::getInstance()->getSortedActiveSubscriptions(param('tag', ''));
            if (!headers_sent()) {
                header('Content-Type: application/json; charset=' . ZF_ENCODING);
            }
            echo json_encode($subs, JSON_FORCE_OBJECT);
            break;
        case 'tags':
            $tags = SubscriptionStorage::getInstance()->getTags();
            if (!headers_sent()) {
                header('Content-Type: application/json; charset=' . ZF_ENCODING);
            }
            echo json_encode($tags, JSON_FORCE_OBJECT);
            break;
        case 'force-refresh':
            // only internal use
            // TODO: check API key
            $sub = SubscriptionStorage::getInstance()->getSubscription(param('id'));
            FeedCache::getInstance()->updateSingle($sub->source);
            echo $sub->source->title . ' DONE. ';
            break;
        case 'refresh-all':
            $subs = SubscriptionStorage::getInstance()->getActiveSubscriptions(param('tag', ''));
            FeedCache::getInstance()->update($subs);
            echo ' DONE. ';
            break;
    }
}
示例#4
0
function displaydata()
{
    //global $items, $itemcount;
    if (count($list->channels) > 0) {
        $htmldata = <<<EOD
\t\t<tr class="sub-line">
\t\t  <td class="sub-subscribed">
\t\t\t<input type="checkbox" name="addbox{i}" value="checkbox"/>
\t\t</td>
\t\t  <td class="sub-subscribed">
\t\t\t<select name="subscribed{i}">
\t\t\t  <option value="yes" {issubscribed}>yes</option>
\t\t\t  <option value="no" {notsubscribed}>no</option>
\t\t\t</select></td>
\t\t  <td class="sub-subscribed">
\t\t\t<div class="feed">
\t\t\t<a href="javascript:open('{htmlurl}')" onclick="window.open('{htmlurl}'); return false;">{chantitle}</a>
\t\t\t[{lang}]<br/>
\t\t\tFeed URL : <i>{xmlurl}</i><br/>
\t\t\tWebsite : <i>{htmlurl}</i>
\t\t\t<a href="javascript:open('{xmlurl}')" onclick="window.open('{xmlurl}'); return false;"><img src="../res/img/feed.png" border="0" alt="RSS/ATOM feed"/></a><br/>
\t\t\t{description}
\t\t\t</div>
\t\t</td>
\t\t  <td class="sub-subscribed">
\t\t\t<input name="refreshtime{i}" type="text" size="4" value="{refreshtime}"></input>
\t\t\t</td>
\t\t  <td class="sub-subscribed">
\t\t\t<input name="showeditems{i}" type="text" size="4" value="{showeditems}"></input>
\t\t\t<input type="hidden" name="description{i}" value="{description}" />
\t\t\t<input type="hidden" name="chantitle{i}" value="{chantitle}" />
\t\t\t<input type="hidden" name="xmlurl{i}" value="{xmlurl}" />
\t\t\t<input type="hidden" name="htmlurl{i}" value="{htmlurl}" />
\t\t\t</td>
\t\t</tr>
EOD;
        $returndata = '';
        $i = 0;
        $subscriptions = SubscriptionStorage::getInstance()->getSubscriptions();
        foreach ($subscriptions as $key => $sub) {
            $tempdata = '';
            $tempdata = str_replace("{i}", $i, $htmldata);
            $tempdata = str_replace("{chantitle}", $sub->title, $tempdata);
            $tempdata = str_replace("{htmlurl}", $sub->htmlurl, $tempdata);
            $tempdata = str_replace("{description}", $sub->description, $tempdata);
            $tempdata = str_replace("{xmlurl}", $sub->xmlurl, $tempdata);
            if ($sub->isActive) {
                $tempdata = str_replace("{issubscribed}", "selected=\"selected\"", $tempdata);
                $tempdata = str_replace("{notsubscribed}", "", $tempdata);
            } else {
                $tempdata = str_replace("{issubscribed}", "", $tempdata);
                $tempdata = str_replace("{notsubscribed}", "selected=\"selected\"", $tempdata);
            }
            $tempdata = str_replace("{bgcolor}", $i % 2 ? '#fff' : '#f2ebe0', $tempdata);
            $returndata .= $tempdata;
            $i++;
        }
    } else {
        $returndata = "no subscriptions in subscriptions list";
    }
    return $returndata;
}
示例#5
0
 public function getItem($itemId)
 {
     $itemarr = DBProxy::getInstance()->getSingleItem($itemId);
     $sub = SubscriptionStorage::getInstance()->getSubscription($itemarr['source_id']);
     $item = NewsItem::createFromFlatArray($sub->source, $itemarr, time() - ZF_SESSION_DURATION);
     DBProxy::getInstance()->markItemsAsImpressed(array($itemId));
     return $item;
 }
示例#6
0
 public function getPublisherFeed($sourceId, $updateMode, $trim, $onlyNew)
 {
     $sub = SubscriptionStorage::getInstance()->getSubscription($sourceId);
     $this->cache->update(array($sub->id => $sub), $updateMode);
     if ($trim == 'auto') {
         $trim = $sub->shownItems . 'news';
     }
     $params1 = array();
     if ($onlyNew == 1) {
         $params1['impressedSince'] = time() - ZF_SESSION_DURATION;
     }
     $params = array_merge($params1, $this->buildLimiterParam($trim));
     $feed = $this->cache->getFeed($sub, $params);
     return $feed;
 }
示例#7
0
<!DOCTYPE html>
<html>
<head>
<title>ZebraFeeds jobs</title>
</head>
<body>
<?php 
require_once __DIR__ . '/../init.php';
if ($_GET['key'] != md5(ZF_ADMINNAME . ZF_ADMINPASS)) {
    echo "No authorization<br/>";
    exit;
}
$subs = SubscriptionStorage::getInstance()->getActiveSubscriptions();
FeedCache::getInstance()->update($subs, 'auto');
echo 'complete';
?>

</body>
</html>