1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Add new display_home plugin category

Add RSS View plugin
This commit is contained in:
Afterster 2014-10-02 23:51:39 +02:00
parent bef75fd05a
commit e92c41c652
25 changed files with 228 additions and 33 deletions

View file

@ -33,5 +33,6 @@ should be implemented as a public method:
shortener(string $url) shortener(string $url)
get_photos(string $search) get_photos(string $search)
gather_arts(string $type, array $options, int $limit) gather_arts(string $type, array $options, int $limit)
get_song_preview($track_mbid, $artist_name, $title) get_song_preview(string $track_mbid, string $artist_name, string $title)
stream_song_preview($file) stream_song_preview(string $file)
display_home()

View file

@ -268,7 +268,8 @@ class Ampache_RSS
'description' => $album->f_artist_name . ' - ' . $album->f_name, 'description' => $album->f_artist_name . ' - ' . $album->f_name,
'image' => Art::url($album->id, 'album'), 'image' => Art::url($album->id, 'album'),
'comments' => '', 'comments' => '',
'pubDate' => $album->get_addtime_first_song()); 'pubDate' => date("c", $album->get_addtime_first_song())
);
$results[] = $xml_array; $results[] = $xml_array;
} // end foreach } // end foreach

View file

@ -74,11 +74,11 @@ class Plugin
public static function get_plugins($type='') public static function get_plugins($type='')
{ {
// make static cache for optimization when multiple call // make static cache for optimization when multiple call
static $plugins_list; static $plugins_list = array();
if (!is_null($plugins_list)) if (isset($plugins_list[$type]))
return $plugins_list; return $plugins_list[$type];
$plugins_list = array(); $plugins_list[$type] = array();
// Open up the plugin dir // Open up the plugin dir
$handle = opendir(AmpConfig::get('prefix') . '/modules/plugins'); $handle = opendir(AmpConfig::get('prefix') . '/modules/plugins');
@ -109,13 +109,13 @@ class Plugin
} }
} }
// It's a plugin record it // It's a plugin record it
$plugins_list[$plugin_name] = $plugin_name; $plugins_list[$type][$plugin_name] = $plugin_name;
} // end while } // end while
// Little stupid but hey // Little stupid but hey
ksort($plugins_list); ksort($plugins_list[$type]);
return $plugins_list; return $plugins_list[$type];
} // get_plugins } // get_plugins

View file

@ -23,6 +23,7 @@
class Ampache7digital { class Ampache7digital {
public $name = '7digital'; public $name = '7digital';
public $categories = 'misc,preview';
public $description = 'Song preview from 7digital'; public $description = 'Song preview from 7digital';
public $url = 'http://www.7digital.com'; public $url = 'http://www.7digital.com';
public $version = '000001'; public $version = '000001';

View file

@ -23,7 +23,9 @@
class AmpacheAmazon { class AmpacheAmazon {
public $name = 'Amazon'; public $name = 'Amazon';
public $categories = 'metadata';
public $description = 'Amazon arts'; public $description = 'Amazon arts';
public $url = 'http://www.amazon.com';
public $version = '000001'; public $version = '000001';
public $min_ampache = '370009'; public $min_ampache = '370009';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -23,8 +23,9 @@
class AmpacheBitly { class AmpacheBitly {
public $name = 'Bit.ly'; public $name = 'Bit.ly';
public $categories = 'shortener';
public $description = 'Url shorteners on shared links with Bit.ly'; public $description = 'Url shorteners on shared links with Bit.ly';
public $url = 'http://bitly.com/'; public $url = 'http://bitly.com';
public $version = '000002'; public $version = '000002';
public $min_ampache = '360037'; public $min_ampache = '360037';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -23,8 +23,9 @@
class Ampachechartlyrics { class Ampachechartlyrics {
public $name = 'ChartLyrics'; public $name = 'ChartLyrics';
public $categories = 'lyrics';
public $description = 'Get lyrics from ChartLyrics'; public $description = 'Get lyrics from ChartLyrics';
public $url = ''; public $url = 'http://www.chartlyrics.com';
public $version ='000001'; public $version ='000001';
public $min_ampache ='360022'; public $min_ampache ='360022';
public $max_ampache ='999999'; public $max_ampache ='999999';

View file

@ -23,6 +23,7 @@
class Ampacheflickr { class Ampacheflickr {
public $name = 'Flickr'; public $name = 'Flickr';
public $categories = 'misc,slideshow';
public $description = 'Artist photos from Flickr'; public $description = 'Artist photos from Flickr';
public $url = 'http://www.flickr.com'; public $url = 'http://www.flickr.com';
public $version = '000001'; public $version = '000001';

View file

@ -23,6 +23,7 @@
class AmpacheGravatar { class AmpacheGravatar {
public $name = 'Gravatar'; public $name = 'Gravatar';
public $categories = 'avatar';
public $description = 'Users avatars with Gravatar'; public $description = 'Users avatars with Gravatar';
public $url = 'http://gravatar.com'; public $url = 'http://gravatar.com';
public $version = '000001'; public $version = '000001';

View file

@ -23,8 +23,9 @@
class Ampachegrowl { class Ampachegrowl {
public $name = 'Growl'; public $name = 'Growl';
public $categories = 'scrobbling';
public $description = 'Send your played songs notification to Growl'; public $description = 'Send your played songs notification to Growl';
public $url = ''; public $url = 'http://growl.info';
public $version ='000001'; public $version ='000001';
public $min_ampache ='360003'; public $min_ampache ='360003';
public $max_ampache ='999999'; public $max_ampache ='999999';

View file

@ -23,6 +23,7 @@
class AmpacheHeadphones { class AmpacheHeadphones {
public $name = 'Headphones'; public $name = 'Headphones';
public $categories = 'misc,wanted';
public $description = 'Automatically download accepted Wanted List albums with Headphones'; public $description = 'Automatically download accepted Wanted List albums with Headphones';
public $url = 'https://github.com/rembo10/headphones/'; public $url = 'https://github.com/rembo10/headphones/';
public $version = '000001'; public $version = '000001';

View file

@ -22,12 +22,13 @@
class AmpacheLastfm { class AmpacheLastfm {
public $name ='Last.FM'; public $name = 'Last.FM';
public $description ='Records your played songs to your Last.FM Account'; public $categories = 'scrobbling';
public $url =''; public $description = 'Records your played songs to your Last.FM Account';
public $version ='000004'; public $url = 'http://www.lastfm.com';
public $min_ampache ='360003'; public $version = '000004';
public $max_ampache ='999999'; public $min_ampache = '360003';
public $max_ampache = '999999';
// These are internal settings used by this class, run this->load to // These are internal settings used by this class, run this->load to
// fill them out // fill them out

View file

@ -23,6 +23,7 @@
class AmpacheLibravatar { class AmpacheLibravatar {
public $name = 'Libravatar'; public $name = 'Libravatar';
public $categories = 'avatar';
public $description = 'Users avatars with Libravatar'; public $description = 'Users avatars with Libravatar';
public $url = 'https://www.libravatar.org'; public $url = 'https://www.libravatar.org';
public $version = '000001'; public $version = '000001';

View file

@ -22,12 +22,13 @@
class Ampachelibrefm { class Ampachelibrefm {
public $name ='Libre.FM'; public $name = 'Libre.FM';
public $description ='Records your played songs to your Libre.FM Account'; public $categories = 'scrobbling';
public $url =''; public $description = 'Records your played songs to your Libre.FM Account';
public $version ='000002'; public $url = 'https://libre.fm';
public $min_ampache ='360003'; public $version = '000002';
public $max_ampache ='999999'; public $min_ampache = '360003';
public $max_ampache = '999999';
// These are internal settings used by this class, run this->load to // These are internal settings used by this class, run this->load to
// fill them out // fill them out

View file

@ -23,8 +23,9 @@
class Ampachelyricwiki { class Ampachelyricwiki {
public $name = 'LyricWiki'; public $name = 'LyricWiki';
public $categories = 'lyrics';
public $description = 'Get lyrics from LyricWiki'; public $description = 'Get lyrics from LyricWiki';
public $url = ''; public $url = 'http://lyrics.wikia.com/Lyrics_Wiki';
public $version ='000001'; public $version ='000001';
public $min_ampache ='360022'; public $min_ampache ='360022';
public $max_ampache ='999999'; public $max_ampache ='999999';

View file

@ -26,7 +26,9 @@ use MusicBrainz\Clients\RequestsMbClient;
class AmpacheMusicBrainz { class AmpacheMusicBrainz {
public $name = 'MusicBrainz'; public $name = 'MusicBrainz';
public $categories = 'metadata';
public $description = 'MusicBrainz metadata integration'; public $description = 'MusicBrainz metadata integration';
public $url = 'http://www.musicbrainz.org';
public $version = '000001'; public $version = '000001';
public $min_ampache = '360003'; public $min_ampache = '360003';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -23,7 +23,9 @@
class AmpacheOmdb { class AmpacheOmdb {
public $name = 'Omdb'; public $name = 'Omdb';
public $categories = 'metadata';
public $description = 'Omdb metadata integration'; public $description = 'Omdb metadata integration';
public $url = 'http://www.omdbapi.com';
public $version = '000001'; public $version = '000001';
public $min_ampache = '370009'; public $min_ampache = '370009';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -0,0 +1,135 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* Copyright 2001 - 2014 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
class AmpacheRSSView {
public $name = 'RSSView';
public $categories = 'home';
public $description = 'RSS View';
public $url = '';
public $version = '000001';
public $min_ampache = '370021';
public $max_ampache = '999999';
// These are internal settings used by this class, run this->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 '<table class="tabledata">';
foreach ($xml->channel->item as $item) {
echo '<tr class="' . ((($i % 2) == 0) ? 'even' : 'odd') . '"><td>';
echo '<div>';
echo '<div style="float: left; font-weight: bold;"><a href="' . $item->link . '" target="_blank">' . $item->title . '</a></div>';
echo '<div style="float: right;">' . date("Y/m/d H:i:s", strtotime($item->pubDate)) . '</div>';
echo '</div><br />';
echo '<div style="margin-left: 30px;">';
if (isset($item->image)) {
echo '<div style="float: left; margin-right: 20px;"><img src="' . $item->image . '" style="width: auto; max-height: 48px;" /></div>';
}
echo '<div>'. $item->description .'</div>';
echo '</div>';
echo '</td></tr>';
$i++;
if ($i >= $this->maxitems) {
break;
}
}
echo '</table>';
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;
}
}

View file

@ -23,7 +23,9 @@
class AmpacheTheaudiodb { class AmpacheTheaudiodb {
public $name = 'TheAudioDb'; public $name = 'TheAudioDb';
public $categories = 'metadata';
public $description = 'TheAudioDb metadata integration'; public $description = 'TheAudioDb metadata integration';
public $url = 'http://www.theaudiodb.com';
public $version = '000001'; public $version = '000001';
public $min_ampache = '370009'; public $min_ampache = '370009';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -23,7 +23,9 @@
class AmpacheTmdb { class AmpacheTmdb {
public $name = 'Tmdb'; public $name = 'Tmdb';
public $categories = 'metadata';
public $description = 'Tmdb metadata integration'; public $description = 'Tmdb metadata integration';
public $url = 'https://www.themoviedb.org';
public $version = '000001'; public $version = '000001';
public $min_ampache = '370009'; public $min_ampache = '370009';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -23,7 +23,9 @@
class AmpacheTvdb { class AmpacheTvdb {
public $name = 'Tvdb'; public $name = 'Tvdb';
public $categories = 'metadata';
public $description = 'Tvdb metadata integration'; public $description = 'Tvdb metadata integration';
public $url = 'http://thetvdb.com';
public $version = '000001'; public $version = '000001';
public $min_ampache = '370009'; public $min_ampache = '370009';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -23,8 +23,9 @@
class AmpacheYourls { class AmpacheYourls {
public $name = 'YOURLS'; public $name = 'YOURLS';
public $categories = 'shortener';
public $description = 'Url shorteners on shared links with YOURLS'; public $description = 'Url shorteners on shared links with YOURLS';
public $url = 'http://yourls.org/'; public $url = 'http://yourls.org';
public $version = '000002'; public $version = '000002';
public $min_ampache = '360037'; public $min_ampache = '360037';
public $max_ampache = '999999'; public $max_ampache = '999999';

View file

@ -0,0 +1,20 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* Copyright 2001 - 2014 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/

View file

@ -1,5 +1,12 @@
auxiliary.org-netbeans-modules-css-prep.less_2e_compiler_2e_options=
auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false
auxiliary.org-netbeans-modules-css-prep.less_2e_mappings=/less:/css
auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options=
auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false
auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss:/css
include.path=${php.global.include.path} include.path=${php.global.include.path}
php.version=PHP_53 php.version=PHP_53
project.licensePath=./nbproject/licenseheader.txt
source.encoding=UTF-8 source.encoding=UTF-8
src.dir=. src.dir=.
tags.asp=false tags.asp=false

View file

@ -19,6 +19,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
*/ */
foreach (Plugin::get_plugins('display_home') as $plugin_name) {
$plugin = new Plugin($plugin_name);
if ($plugin->load($GLOBALS['user'])) {
echo '<div class="home_plugin">' . $plugin->_plugin->display_home() . '</div>';
}
}
?> ?>
<div id="now_playing"> <div id="now_playing">
<?php show_now_playing(); ?> <?php show_now_playing(); ?>