load to // fill them out private $feed_url; private $maxitems; /** * Constructor * This function does nothing... */ public function __construct() { return true; } /** * install * This is a required plugin function. It inserts our preferences * into Ampache */ public function install() { // Check and see if it's already installed if (Preference::exists('rssview_feed_url')) { return false; } Preference::insert('rssview_feed_url','RSS Feed url','','25','string','plugins'); Preference::insert('rssview_max_items','RSS Feed max items','5','25','integer','plugins'); return true; } /** * uninstall * This is a required plugin function. It removes our preferences from * the database returning it to its original form */ public function uninstall() { Preference::delete('rssview_feed_url'); Preference::delete('rssview_max_items'); return true; } /** * upgrade * This is a recommended plugin function */ public function upgrade() { return true; } /** * display_home * This display the module in home page */ public function display_home() { $xmlstr = file_get_contents($this->feed_url); $xml = simplexml_load_string($xmlstr); if ($xml->channel) { UI::show_box_top($xml->channel->title); $i = 0; echo ''; foreach ($xml->channel->item as $item) { echo ''; $i++; if ($i >= $this->maxitems) { break; } } echo '
'; echo '
'; echo ''; echo '
' . date("Y/m/d H:i:s", strtotime($item->pubDate)) . '
'; echo '

'; echo '
'; if (isset($item->image)) { echo '
'; } echo '
'. $item->description .'
'; echo '
'; echo '
'; UI::show_box_bottom(); } } /** * load * This loads up the data we need into this object, this stuff comes * from the preferences. */ public function load($user) { $user->set_preferences(); $data = $user->prefs; if (strlen(trim($data['rssview_feed_url']))) { $this->feed_url = trim($data['rssview_feed_url']); } else { debug_event($this->name,'No rss feed url, home plugin skipped','3'); return false; } $this->maxitems = intval($data['rssview_max_items']); return true; } }