diff options
-rwxr-xr-x | docs/CHANGELOG | 4 | ||||
-rw-r--r-- | lib/class/ajax.class.php | 36 | ||||
-rw-r--r-- | lib/class/metadata.class.php | 39 | ||||
-rw-r--r-- | lib/class/stats.class.php | 3 | ||||
-rw-r--r-- | lib/general.lib.php | 12 | ||||
-rw-r--r-- | lib/ui.lib.php | 19 | ||||
-rw-r--r-- | server/ajax.server.php | 17 | ||||
-rw-r--r-- | server/stats.ajax.php | 79 | ||||
-rw-r--r-- | stats.php | 41 | ||||
-rw-r--r-- | templates/show_artist_box.inc.php | 14 | ||||
-rw-r--r-- | templates/show_artists.inc.php | 6 | ||||
-rw-r--r-- | templates/show_box_top.inc.php | 3 | ||||
-rw-r--r-- | templates/show_index.inc.php | 7 | ||||
-rw-r--r-- | templates/show_object_rating_static.inc.php | 2 | ||||
-rw-r--r-- | templates/show_object_row.inc.php (renamed from templates/show_box.inc.php) | 20 | ||||
-rw-r--r-- | templates/show_objects.inc.php (renamed from templates/show_all_recent.inc.php) | 37 | ||||
-rw-r--r-- | templates/show_plugins.inc.php | 2 | ||||
-rw-r--r-- | templates/show_user.inc.php | 1 | ||||
-rw-r--r-- | themes/classic/templates/default.css | 79 |
19 files changed, 261 insertions, 160 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index e5a9f741..17958f94 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,7 +4,9 @@ -------------------------------------------------------------------------- v.3.4-Alpha2 - - Added MyStrands Plugin + - Added Similar Artists Link, requires MyStrands + - Fixed hovering on the static Ratings displays + - Added MyStrands Plugin, must be enabled under Plugins - Re-enabled / updated Plugin functionality - Fixed CSS (Thx Spocky) - Added Playlists as a browse type and fixed playback diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index 441d9a47..5185538a 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -42,8 +42,17 @@ class Ajax { */ public static function observe($source,$method,$action) { + $non_quoted = array('document','window'); + + if (in_array($source,$non_quoted)) { + $source_txt = $source; + } + else { + $source_txt = "'$source'"; + } + $observe = "<script type=\"text/javascript\"><!--\n"; - $observe .= "\tEvent.observe('$source','$method',function(){" . $action . ";});\n"; + $observe .= "\tEvent.observe($source_txt,'$method',function(){" . $action . ";});\n"; $observe .= "--></script>\n"; return $observe; @@ -59,11 +68,20 @@ class Ajax { $url = Config::get('ajax_url') . $action; + $non_quoted = array('document','window'); + + if (in_array($source,$non_quoted)) { + $source_txt = $source; + } + else { + $source_txt = "'$source'"; + } + if ($post) { - $ajax_string = "ajaxPost('$url','$post','$source')"; + $ajax_string = "ajaxPost('$url','$post',$source_txt)"; } else { - $ajax_string = "ajaxPut('$url','$source')"; + $ajax_string = "ajaxPut('$url',$source_txt)"; } return $ajax_string; @@ -112,5 +130,17 @@ class Ajax { } // text + /** + * run + * This runs the specified action no questions asked + */ + public static function run($action) { + + echo "<script type=\"text/javascript\"><!--\n"; + echo "$action"; + echo "\n--></script>"; + + } // run + } // end Ajax class ?> diff --git a/lib/class/metadata.class.php b/lib/class/metadata.class.php index 01db6072..f5e80626 100644 --- a/lib/class/metadata.class.php +++ b/lib/class/metadata.class.php @@ -33,12 +33,49 @@ class metadata { * constructor * We don't use this, as its really a static class */ - private __construct() { + private function __construct() { // Rien a faire } // constructor + /** + * recommend_similar + * This takes the input and returns an array of objects construct_from_array()'d + */ + public static function recommend_similar($type,$id,$limit='') { + + // For now it's only mystrands + OpenStrands::set_auth_token(Config::get('mystrands_developer_key')); + $openstrands = new OpenStrands($GLOBALS['user']->prefs['mystrands_user'],$GLOBALS['user']->prefs['mystrands_pass']); + + // Make sure auth worked + if (!$openstrands) { return false; } + + switch ($type) { + case 'artist': + $artist = new Artist($id); + $seed = array('name'=>array($artist->name)); + $results = $openstrands->recommend_artists($seed,$limit); + break; + } + + foreach ($results as $item) { + switch ($type) { + case 'artist': + $data['name'] = $item['ArtistName']; + $data['uid'] = $item['__attributes']['ArtistID']; + $data['mystrands_url'] = $item['URI']; + $data['links'] = "<a target=\"_blank\" href=\"" . $item['URI'] . "\">" . get_user_icon('mystrands','','MyStrands Link') . "</a>"; + $objects[] = Artist::construct_from_array($data); + break; + } // end switch on type + } // end foreach + + return $objects; + + } // recommend_similar + } // metadata ?> diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php index 6add04c5..9847da39 100644 --- a/lib/class/stats.class.php +++ b/lib/class/stats.class.php @@ -179,7 +179,6 @@ class Stats { while ($r = Dba::fetch_row($db_results)) { $object = new $object_name($r['0']); - $object->format(); $items[] = $object; } // end while results @@ -187,5 +186,5 @@ class Stats { } // get_newest -} //Stats class +} // Stats class ?> diff --git a/lib/general.lib.php b/lib/general.lib.php index 5ce40831..408a4a99 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -489,18 +489,6 @@ function get_global_popular($type) { } // get_global_popular -/** - * show_info_box - * This shows the basic box that popular and newest stuff goes into - */ -function show_info_box ($title, $type, $items) { - - $web_path = Config::get('web_path'); - $popular_threshold = Config::get('popular_threshold'); - require Config::get('prefix') . '/templates/show_box.inc.php'; - -} // show_info_box - /*! @function get_file_extension @discussion returns all characters after the last "." in $filename diff --git a/lib/ui.lib.php b/lib/ui.lib.php index a6b03629..82cd0334 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -404,23 +404,6 @@ function show_all_popular() { } // show_all_popular /** - * Show All Recent - * This function shows all of the possible "Newest" tables. The number of newest is pulled from the users - * popular threshold - * @package Web Interface - * @catagory Display - * @author Karl Vollmer - */ -function show_all_recent($limit='') { - - $artists = Stats::get_newest('artist',$limit); - $albums = Stats::get_newest('album',$limit); - - require_once Config::get('prefix') . '/templates/show_all_recent.inc.php'; - -} // show_all_recent - -/** * show_local_catalog_info * Shows the catalog stats * @package Web INterface @@ -968,7 +951,7 @@ function show_user_select($name,$selected='',$style='') { * This function requires the top part of the box * it takes title as an optional argument */ -function show_box_top($title='') { +function show_box_top($title='',$class='') { require Config::get('prefix') . '/templates/show_box_top.inc.php'; diff --git a/server/ajax.server.php b/server/ajax.server.php index 7133fb26..f47c8856 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -25,8 +25,6 @@ require_once '../lib/init.php'; -$action = scrub_in($_REQUEST['action']); - /* Set the correct headers */ header("Content-type: text/xml; charset=" . Config::get('site_charset')); header("Content-Disposition: attachment; filename=ajax.xml"); @@ -35,7 +33,20 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Pragma: no-cache"); -switch ($action) { +// Set that this is an ajax include +define('AJAX_INCLUDE','1'); + +switch ($_REQUEST['page']) { + case 'stats': + require_once Config::get('prefix') . '/server/stats.ajax.php'; + exit; + break; + default: + // A taste of compatibility + break; +} // end switch on page + +switch ($_REQUEST['action']) { /* Controls the editing of objects */ case 'show_edit_object': diff --git a/server/stats.ajax.php b/server/stats.ajax.php new file mode 100644 index 00000000..cdb5a7cd --- /dev/null +++ b/server/stats.ajax.php @@ -0,0 +1,79 @@ +<?php +/* + + Copyright (c) 2001 - 2007 Ampache.org + All rights reserved. + + 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. + +*/ + +/** + * Sub-Ajax page, requires AJAX_INCLUDE as one + */ +if (AJAX_INCLUDE != '1') { exit; } + +switch ($_REQUEST['action']) { + case 'show_recommend': + switch ($_REQUEST['type']) { + case 'artist': + case 'album': + case 'track': + // We're good + break; + default: + $results['rfc3514'] = '0x1'; + break 2; + } // verifying the type + + ob_start(); + show_box_top(_('Recommendations')); + echo "Loading..."; + $ajax_action = Ajax::action('?page=stats&action=recommend&type=' . $_REQUEST['type'] . '&id=' . $_REQUEST['id'],'show_recommend_refresh'); + Ajax::run($ajax_action); + show_box_bottom(); + $results['additional_information'] = ob_get_contents(); + ob_end_clean(); + break; + case 'recommend': + switch ($_REQUEST['type']) { + case 'artist': + $headers = array('name'=>_('Name'),'links'=>' '); + break; + case 'album': + case 'track': + // We're good + default: + $results['rtc3514'] = '0x1'; + break 2; + } + + // Get the recommendations + $objects = metadata::recommend_similar($_REQUEST['type'],$_REQUEST['id'],'7'); + + ob_start(); + show_box_top(_('Recommendations')); + require_once Config::get('prefix') . '/templates/show_objects.inc.php'; + show_box_bottom(); + $results['additional_information'] = ob_get_contents(); + ob_end_clean(); + break; + default: + $results['rfc3514'] = '0x1'; + break; +} // switch on action; + +// We always do this +echo xml_from_array($results); +?> @@ -45,47 +45,6 @@ switch ($_REQUEST['action']) { require_once Config::get('prefix') . '/templates/show_user_stats.inc.php'; break; - //FIXME:: The logic in here should be moved to our metadata class - case 'recommend_similar': - // For now this is just MyStrands so verify they've filled out stuff - if (!$GLOBALS['user']->has_access('25') || !$GLOBALS['user']->prefs['mystrands_pass'] || !$GLOBALS['user']->prefs['mystrands_user']) { - access_denied(); - exit; - } - - // We're good attempt to dial up MyStrands - OpenStrands::set_auth_token(Config::get('mystrands_developer_key')); - $openstrands = new OpenStrands($GLOBALS['user']->prefs['mystrands_user'],$GLOBALS['user']->prefs['mystrands_pass']); - - if (!$openstrands) { - debug_event('openstrands','Unable to authenticate MyStrands user, or authtoken invalid','3'); - Error::add('general','Unable to authenticate MyStrands user, or authtoken invalid'); - } - - // Do our recommendation - switch ($_REQUEST['type']) { - case 'artist': - $artist = new Artist($_REQUEST['id']); - $seed = array('name'=>array($artist->name)); - $results = $openstrands->recommend_artists($seed); - break; - } // end switch - - // Run through what we've found and build out the data - foreach ($results as $result) { - - switch ($_REQUEST['type']) { - case 'artist': - $data['name'] = $result['ArtistName']; - $data['f_name_link'] = "<a href=\"" . $result['URI'] . "\">" . $data['name'] . "</a>"; - $object_ids[] = Artist::construct_from_array($data); - break; - } - } // end foreach - - require_once Config::get('prefix') . '/templates/show_artists.inc.php'; - - break; /* Show their stats */ default: /* Here's looking at you kid! */ diff --git a/templates/show_artist_box.inc.php b/templates/show_artist_box.inc.php index c2be0a83..9919b731 100644 --- a/templates/show_artist_box.inc.php +++ b/templates/show_artist_box.inc.php @@ -21,15 +21,16 @@ */ $web_path = Config::get('web_path'); $title = _('Albums by') . " " . $artist->full_name; - -show_box_top(_('Albums by') . ' ' . $artist->f_name); +?> +<?php +show_box_top(_('Albums by') . ' ' . $artist->f_name,'info-box'); if (Config::get('ratings')) { echo "<div id=\"rating_" . $artist->id . "_artist\" style=\"display:inline;\">"; show_rating($artist->id, 'artist'); echo "</div>"; } // end if ratings ?> <strong><?php echo _('Actions'); ?>:</strong> -<div style="padding-left:5px;"> +<div id="information_actions"> <a href="<?php echo $web_path; ?>/artists.php?action=show_all_songs&artist=<?php echo $artist->id; ?>"><?php echo _("Show All Songs By") . " " . $artist->f_name; ?></a><br /> <span class="text-action"><?php echo Ajax::text('?action=basket&type=artist&id=' . $artist->id,_('Play All Songs By') . ' ' . $artist->f_name,'play_full_artist'); ?></span> <span class="text-action"><?php echo Ajax::text('?action=basket&type=artist_random&id=' . $artist->id,_('Play Random Songs By') . ' ' . $artist->f_name,'play_random_artist'); ?></span> @@ -39,7 +40,12 @@ if (Config::get('ratings')) { <a href="<?php echo $web_path; ?>/artists.php?action=show_similar&artist=<?php echo $artist->id; ?>"><?php echo _("Find duplicate artists"); ?></a><br /> <?php } ?> <?php if (Plugin::is_installed('OpenStrands')) { ?> -<a href="<?php echo $web_path; ?>/stats.php?action=recommend_similar&type=artist&id=<?php echo $artist->id; ?>"><?php echo _('Recommend Similar'); ?></a><br /> +<span class="text-action"><?php echo Ajax::text('?page=stats&action=show_recommend&type=artist&id=' . $artist->id,_('Recommend Similar'),'artist_recommend_similar'); ?></span> <?php } ?> </div> <?php show_box_bottom(); ?> +<div id="additional_information"> + +</div> + + diff --git a/templates/show_artists.inc.php b/templates/show_artists.inc.php index 9848a7f0..3f4ef881 100644 --- a/templates/show_artists.inc.php +++ b/templates/show_artists.inc.php @@ -37,14 +37,8 @@ $web_path = Config::get('web_path'); <?php /* Foreach through every artist that has been passed to us */ foreach ($object_ids as $artist_id) { - if (get_class($artist_id) == 'Artist') { - $artist = $artist_id; - $artist->format(); - } - else { $artist = new Artist($artist_id); $artist->format(); - } ?> <tr id="artist_<?php echo $artist->id; ?>" class="<?php echo flip_class(); ?>"> <?php require Config::get('prefix') . '/templates/show_artist_row.inc.php'; ?> diff --git a/templates/show_box_top.inc.php b/templates/show_box_top.inc.php index dd88ec0e..e3e9221a 100644 --- a/templates/show_box_top.inc.php +++ b/templates/show_box_top.inc.php @@ -18,8 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +$class = $class ? $class : 'box'; ?> -<table class="box" cellspacing="0" cellpadding="0"> +<table class="<?php echo $class; ?>" cellspacing="0" cellpadding="0"> <tr> <td class="box-left-top"></td> <td class="box-top"></td> diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php index b3cd164f..765d89df 100644 --- a/templates/show_index.inc.php +++ b/templates/show_index.inc.php @@ -47,7 +47,8 @@ if (isset($_REQUEST['xspf']) && isset ($_REQUEST['play_info'])){ <?php show_local_catalog_info(); ?> </div> <div id="recent_added"> - <?php show_box_top(); ?> - <?php show_all_recent('5'); ?> - <?php show_box_bottom(); ?> + <?php + show_box_top(); + show_box_bottom(); + ?> </div> diff --git a/templates/show_object_rating_static.inc.php b/templates/show_object_rating_static.inc.php index 38252f32..a0b60206 100644 --- a/templates/show_object_rating_static.inc.php +++ b/templates/show_object_rating_static.inc.php @@ -24,7 +24,7 @@ $base_url = Config::get('ajax_url') . '?action=set_rating&rating_type=' . $r //set the background to no stars -echo "<ul class=\"star-rating\">\n"; +echo "<ul class=\"static-star-rating\">\n"; /* Handle the "Not rated" possibility */ if ($rating->rating == '-1') { diff --git a/templates/show_box.inc.php b/templates/show_object_row.inc.php index f0b8ea3c..989eb5d0 100644 --- a/templates/show_box.inc.php +++ b/templates/show_object_row.inc.php @@ -6,7 +6,7 @@ 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. + 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 @@ -18,14 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/** + * Completely variable row does have UID for Ajax ($object->uid) + * build TD's from $headers $key=>$header + */ + ?> - <span class="box-title"><?php echo $title; ?></span> - <ol class="box-list"> - <?php if (count($items)) { ?> - <?php - foreach ($items as $item) { - echo "<li>".$item->f_name_link."</li>\n"; - } - ?> - <?php } else { echo '<li><span class="error">' . _('Not Enough Data') . '</span></li>'; } ?> - </ol> +<?php foreach ($headers as $key=>$header) { ?> + <td><?php echo $object->$key; ?></td> +<?php } ?> diff --git a/templates/show_all_recent.inc.php b/templates/show_objects.inc.php index 5b30f8ed..cd1445a7 100644 --- a/templates/show_all_recent.inc.php +++ b/templates/show_objects.inc.php @@ -1,13 +1,13 @@ <?php /* - - Copyright (c) 2001 - 2006 Ampache.org - All rights reserved. + + Copyright (c) 2001 - 2007 Ampache.org + All rights reserved. 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 @@ -16,20 +16,25 @@ 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. - + */ +/* + * Variable/Non-DB object display takes headers & objects + */ +?> +<table class="table-data" cellspacing="0"> +<tr class="<?php echo flip_class(); ?>"> +<?php foreach ($headers as $header) { ?> + <th><?php echo scrub_out($header); ?></th> +<?php } ?> +</tr> +<?php + foreach ($objects as $object) { + $object->format(); ?> -<table> -<tr> - <td valign="top"> - <?php show_info_box(_('Newest Artist Additions'), '', $artists); ?> - </td> - <td valign="top"> - <?php show_info_box(_('Newest Album Additions'), '', $albums); ?> - </td> - <td valign="top"> - <?php show_info_box(_('Newest Live Stream Additions'),'',$tags); ?> - </td> +<tr id="object_row_<?php echo $object->uid; ?>" class="<?php echo flip_class(); ?>"> + <?php require Config::get('prefix') . '/templates/show_object_row.inc.php'; ?> </tr> +<?php } ?> </table> diff --git a/templates/show_plugins.inc.php b/templates/show_plugins.inc.php index 196475d4..96957942 100644 --- a/templates/show_plugins.inc.php +++ b/templates/show_plugins.inc.php @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +$web_path = Config::get('web_path'); ?> <!-- Plugin we've found --> <table class="tabledata" border="0" cellspacing="0"> diff --git a/templates/show_user.inc.php b/templates/show_user.inc.php index 76f4d68d..9ba5dbfc 100644 --- a/templates/show_user.inc.php +++ b/templates/show_user.inc.php @@ -36,6 +36,7 @@ $client->format(); <?php } else { ?> <i style="color:red;"><?php echo _('User is Offline Now'); ?></i> <?php } ?> + </td> <td valign="top"> <h2><?php echo _('Active Playlist'); ?></h2> diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css index 6fd6c4c6..f7f0ffb0 100644 --- a/themes/classic/templates/default.css +++ b/themes/classic/templates/default.css @@ -353,6 +353,7 @@ h3#content_title span { .star-rating li{ float: right; } + li.current-rating{ display: block; position: absolute; @@ -398,13 +399,43 @@ span.four-stars:hover { width: 64px; } span.five-stars { left: 64px; } span.five-stars:hover { width: 80px; } +/************************************************/ +/* Styles for the static star ratings */ +/************************************************/ +.static-star-rating li span:hover { + /* Kill the mouseovers */ +} +.static-star-rating li span{ + position: absolute; + display:block; + width:16px; + height: 15px; + text-decoration: none; + text-indent: -9000px; + z-index: 20; +} +.static-star-rating li { + float: right; +} +.static-star-rating { + position: relative; + list-style:none; + width: 80px; + height: 15px; + background: url(../../../images/ratings/star_rating.gif) top left repeat-x; +} /************************************************/ /* Box Related Styles */ /************************************************/ .box { background: #f7f7f7; + clear:both; } +.info-box { + background: #f7f7f7; + float:left; +} .box-title { border-bottom: solid 1px #000; font-size: 1.05em; @@ -420,7 +451,7 @@ span.five-stars:hover { width: 80px; } height:16px; } .box-left-bottom { - background: url(../images/bottomleft.gif) no-repeat; + background: url(../images/bottomleft.gif) no-repeat; height:18px; } .box-left { @@ -477,41 +508,6 @@ span.five-stars:hover { width: 80px; } /************************************************/ -/* Tabs (for preferences) */ -/************************************************/ -#tablist { - padding: 3px 0; - margin: 12px 0 0 0; - font: bold 12px Verdana, sans-serif; -} -#tablist li { - list-style: none; - display: inline; -} -#tablist li a { - padding: 3px 0.5em; - margin-left: 3px; - border: 1px solid #ccc; - border-bottom: none; - background: #ddd; - text-decoration: none; -} -#tablist li a:link { color: #222; } -#tablist li a:visited { color: #000; } -#tablist li a:hover { - color: #000; - background: #bbb; - border-color: #000; -} -#tablist li a#current { - color: #000; - background: #bbb; - border-color: #000; - border-bottom: 1px solid #000; -} - - -/************************************************/ /* Styles for Header */ /*(for ampache admin : installation, update...) */ /************************************************/ @@ -623,6 +619,17 @@ td.user_disabled { /************************************************/ +/* Additional Information Boxes */ +/************************************************/ +#information_actions { + margin-left:5px; +} +#additional_information { + float:left; +} + + +/************************************************/ /* Misc */ /************************************************/ .text-box, .confirmation-box { |