diff --git a/lib/class/ampache_rss.class.php b/lib/class/ampache_rss.class.php index c344dbba..7ac80e9f 100644 --- a/lib/class/ampache_rss.class.php +++ b/lib/class/ampache_rss.class.php @@ -73,8 +73,11 @@ class Ampache_RSS public function get_title() { $titles = array('now_playing' => T_('Now Playing'), - 'recently_played' => T_('Recently Played'), - 'latest_album' => T_('Newest Albums')); + 'recently_played' => T_('Recently Played'), + 'latest_album' => T_('Newest Albums'), + 'latest_artist' => T_('Newest Artists'), + 'latest_shout' => T_('Newest Shouts') + ); return scrub_out(AmpConfig::get('site_title')) . ' - ' . $titles[$this->type]; @@ -100,7 +103,7 @@ class Ampache_RSS */ public static function validate_type($type) { - $valid_types = array('now_playing','recently_played','latest_album'); + $valid_types = array('now_playing','recently_played','latest_album','latest_artist','latest_shout'); if (!in_array($type,$valid_types)) { return 'now_playing'; @@ -276,7 +279,71 @@ class Ampache_RSS return $results; - } // load_recently_played + } // load_latest_album + + /** + * load_latest_artist + * This loads in the latest added artists + * @return array + */ + public static function load_latest_artist() + { + $ids = Stats::get_newest('artist', 10); + + $results = array(); + + foreach ($ids as $id) { + $artist = new Artist($id); + $artist->format(); + + $xml_array = array('title' => $artist->f_name, + 'link' => $artist->link, + 'description' => $artist->summary, + 'image' => Art::url($artist->id, 'artist'), + 'comments' => '', + 'pubDate' => '' + ); + $results[] = $xml_array; + + } // end foreach + + return $results; + + } // load_latest_artist + + /** + * load_latest_shout + * This loads in the latest added shouts + * @return array + */ + public static function load_latest_shout() + { + $ids = Shoutbox::get_top(10); + + $results = array(); + + foreach ($ids as $id) { + $shout = new Shoutbox($id); + $shout->format(); + $object = Shoutbox::get_object($shout->object_type, $shout->object_id); + $object->format(); + $user = new User($shout->user); + $user->format(); + + $xml_array = array('title' => T_('Shout by') . ' ' . $user->username . ' ' . T_('on') . ' ' . $object->get_fullname(), + 'link' => $object->link, + 'description' => $shout->text, + 'image' => Art::url($shout->object_id, $shout->object_type), + 'comments' => '', + 'pubDate' => date("c", $shout->date) + ); + $results[] = $xml_array; + + } // end foreach + + return $results; + + } // load_latest_shout /** * pubdate_recently_played diff --git a/lib/class/shoutbox.class.php b/lib/class/shoutbox.class.php index 91230ef3..a50d26b6 100644 --- a/lib/class/shoutbox.class.php +++ b/lib/class/shoutbox.class.php @@ -32,6 +32,8 @@ class Shoutbox public $date; public $f_link; + public $f_date; + public $f_text; /** * Constructor @@ -210,7 +212,8 @@ class Shoutbox public function format() { $this->sticky = ($this->sticky == "0") ? 'No' : 'Yes'; - $this->date = date("m\/d\/Y - H:i", $this->date); + $this->f_date = date("m\/d\/Y - H:i", $this->date); + $this->f_text = preg_replace('/(\r\n|\n|\r)/', '
', $this->text); return true; } //format @@ -246,7 +249,7 @@ class Shoutbox $html .= "
" . $object->f_link . "
"; $html .= "
".date("Y/m/d H:i:s", $this->date) . "
"; } - $html .= "
" . preg_replace('/(\r\n|\n|\r)/', '
', $this->text) . "
"; + $html .= "
" . $this->f_text . "
"; $html .= ""; $html .= ""; $html .= "