function build($action = 'TopStories', $mode = 'rss')
 {
     require_once PATH_CORE . '/classes/content.class.php';
     $cObj = new content($this->db);
     // if $mode is rss, then echo the output
     // if $mode is api, then return the query
     switch ($action) {
         default:
             // do nothing
             break;
         case 'TopStories':
             $this->feedTitle = SITE_TITLE . ' Top Stories';
             $this->feedDescription = ' Top rated stories from ' . SITE_TITLE;
             $this->feedUrl = $this->baseUrl;
             $this->feedRssUrl = $this->baseUrl . '?p=rss&action=TopStories';
             $query = $cObj->fetchUpcomingStories('', RSS_NUMBER_STORIES);
             break;
     }
     // output the xml feed
     if ($mode == 'rss') {
         $code = $this->createXML($this->feedTitle, $this->feedUrl, $this->feedRssUrl, $this->feedDescription, $query);
         return $code;
     } else {
         return $query;
     }
 }
 function postNextTopStory()
 {
     // only post one story every three hours
     $tstamp = $this->statusObj->getState('lastTwitterPost');
     if (!isset($_GET['test']) and time() - $tstamp < 60 * TWITTER_INTERVAL_MINUTES) {
         return;
     }
     //echo 'continuing';
     require_once PATH_CORE . '/classes/content.class.php';
     $cObj = new content($this->db);
     require_once PATH_CORE . '/classes/log.class.php';
     $logObj = new log($this->db);
     $topStories = $cObj->fetchUpcomingStories();
     $uid = 1;
     while ($data = $this->db->readQ($topStories)) {
         if (!$this->checkLog($uid, $data->siteContentId) and $data->score >= TWITTER_SCORE_THRESHOLD) {
             // post to twitter
             $result = $this->update($data->siteContentId, $data->title);
             if ($result) {
                 $logItem = $logObj->serialize(0, $uid, 'postTwitter', $data->siteContentId);
                 $logObj->add($logItem);
                 $this->statusObj->setState('lastTwitterPost', time());
             }
             // only do one at a time
             return;
         }
     }
 }