Esempio n. 1
0
 public function index($token_share = '')
 {
     $query = $this->db->query('SELECT mbr.* FROM ' . $this->db->dbprefix('members') . ' AS mbr WHERE mbr.token_share = ? GROUP BY mbr.mbr_id', array($token_share));
     if ($query->num_rows() > 0) {
         //header('content-type: application/atom+xml; charset=UTF-8');
         $member = $query->row();
         $feed = new RSS2();
         if ($member->mbr_nickname) {
             $feed->setTitle($member->mbr_nickname . ' - ' . $this->config->item('title'));
         } else {
             $feed->setTitle($this->lang->line('shared_items'));
         }
         $feed->setLink(base_url() . 'share/' . $token_share);
         if ($member->mbr_description) {
             $feed->setDescription($member->mbr_description);
         }
         $feed->setDate(new DateTime());
         $where = array();
         $bindings = array();
         $where[] = 'itm.fed_id IN ( SELECT sub.fed_id FROM ' . $this->db->dbprefix('subscriptions') . ' AS sub WHERE sub.fed_id = itm.fed_id AND sub.mbr_id = ? )';
         $bindings[] = $member->mbr_id;
         $where[] = 'shr.mbr_id = ?';
         $bindings[] = $member->mbr_id;
         $sql = 'SELECT itm.*, shr.* FROM ' . $this->db->dbprefix('share') . ' AS shr LEFT JOIN ' . $this->db->dbprefix('items') . ' AS itm ON shr.itm_id = itm.itm_id WHERE ' . implode(' AND ', $where) . ' GROUP BY itm.itm_id ORDER BY shr.shr_datecreated DESC LIMIT 0,50';
         $query = $this->db->query($sql, $bindings);
         if ($query->num_rows() > 0) {
             foreach ($query->result() as $itm) {
                 $feed_item = $feed->createNewItem();
                 $feed_item->setTitle($itm->itm_title);
                 $feed_item->setLink($itm->itm_link);
                 $feed_item->setDate($itm->shr_datecreated);
                 if ($itm->itm_author) {
                     $feed_item->setAuthor($itm->itm_author);
                 }
                 $sql = 'SELECT enr.* FROM ' . $this->db->dbprefix('enclosures') . ' AS enr WHERE enr.itm_id = ? GROUP BY enr.enr_id';
                 $enclosures = $this->db->query($sql, array($itm->itm_id))->result();
                 if ($enclosures) {
                     foreach ($enclosures as $enr) {
                         if ($enr->enr_length && $enr->enr_length > 0) {
                             $feed_item->setEnclosure($enr->enr_link, $enr->enr_length, $enr->enr_type);
                         }
                     }
                 }
                 $feed_item->setDescription($itm->itm_content);
                 $feed->addItem($feed_item);
             }
         }
         $feed->printFeed();
         exit(0);
     } else {
         $this->output->set_status_header(404);
         $data = array();
         $content = $this->load->view('error404_index', $data, TRUE);
         $this->readerself_library->set_content($content);
     }
 }
Esempio n. 2
0
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
//Creating an instance of RSS2 class.
$TestFeed = new RSS2();
//Setting the channel elements
//Use wrapper functions for common channel elements
$TestFeed->setTitle('Testing & Checking the RSS writer class');
$TestFeed->setLink('http://www.ajaxray.com/projects/rss');
$TestFeed->setDescription('This is a test of creating a RSS 2.0 feed Universal Feed Writer');
//Image title and link must match with the 'title' and 'link' channel elements for valid RSS 2.0
$TestFeed->setImage('Testing & Checking the RSS writer class', 'http://www.ajaxray.com/projects/rss', 'http://www.rightbrainsolution.com/_resources/img/logo.png');
//Let's add some feed items: Create two empty Item instances
$itemOne = $TestFeed->createNewItem();
$itemTwo = $TestFeed->createNewItem();
//Add item details
$itemOne->setTitle('The title of the first entry.');
$itemOne->setLink('http://www.google.de');
$itemOne->setDate(time());
$itemOne->setDescription('And here\'s the description of the entry.');
$itemTwo->setTitle('Lorem ipsum');
$itemTwo->setLink('http://www.example.com');
$itemTwo->setDate(1234567890);
$itemTwo->setDescription('Lorem ipsum dolor sit amet, consectetur, adipisci velit');
//Now add the feed item
$TestFeed->addItem($itemOne);
$TestFeed->addItem($itemTwo);
//OK. Everything is done. Now generate the feed.
$TestFeed->printFeed();