diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 67dbe86c..232b93fa 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,8 @@ -------------------------------------------------------------------------- v.3.3.3-Alpha1 + - Added ajax support to ratings, no longer requires a refresh, + hello instant gratification. - Tweaked Kajax, now accepts an array of elements to replace from a passed xml document. allows for multiple targets on a single ajax request diff --git a/index.php b/index.php index 8688fffa..4a3cb667 100644 --- a/index.php +++ b/index.php @@ -44,12 +44,7 @@ if (conf('refresh_limit') > 5) { require_once(conf('prefix') . '/templates/javascript_refresh.inc.php'); } ?> - +
diff --git a/lib/init.php b/lib/init.php index f76f3eb6..e88da245 100644 --- a/lib/init.php +++ b/lib/init.php @@ -255,6 +255,13 @@ else { $user = new user(); } + +/* Add in some variables for ajax done here because we need the user */ +$ajax_info['ajax_url'] = $results['web_path'] . '/server/ajax.server.php'; +$ajax_info['ajax_info'] = '&user_id=' . $user->id . '&sessid=' . session_id(); +conf($ajax_info); +unset($ajax_info); + // Load gettext mojo load_gettext(); diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 47b6cff9..1834dc35 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1353,6 +1353,23 @@ function xml_from_array($array) { } // xml_from_array +/** + * show_ajax_js + * This displays the javascript array definition needed + * For ajax to know what it should be replacing + */ +function show_ajax_js($name,$array) { + $elements = count($array); + + echo "\n"; + +} // show_ajax_js ?> diff --git a/server/ajax.server.php b/server/ajax.server.php index 76e78102..65fbc6dd 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -97,6 +97,17 @@ switch ($action) { $xml_doc = xml_from_array($results); echo $xml_doc; break; + case 'set_rating': + ob_start(); + $rating = new Rating($_REQUEST['object_id'],$_REQUEST['rating_type']); + $rating->set_rating($_REQUEST['rating']); + show_rating($_REQUEST['object_id'],$_REQUEST['rating_type']); + $key = "rating_" . $_REQUEST['object_id'] . "_" . $_REQUEST['rating_type']; + $results[$key] = ob_get_contents(); + ob_end_clean(); + $xml_doc = xml_from_array($results); + echo $xml_doc; + break; default: echo "Default Action"; break; diff --git a/templates/default.css b/templates/default.css index 12506f70..9594a02d 100644 --- a/templates/default.css +++ b/templates/default.css @@ -445,7 +445,7 @@ margin-right:5em; margin:0px; float: right; } -.star-rating li a{ +.star-rating li span{ display:block; width:16px; height: 15px; @@ -455,51 +455,51 @@ margin-right:5em; position: absolute; padding: 0px; } -.star-rating li a:hover{ +.star-rating li span:hover{ background: url(../images/ratings/star_rating.gif) left center; z-index: 2; left: 0px; } -li.zero-stars a:hover { +li.zero-stars span:hover { background: url(../images/ratings/x.gif); height: 15px; left: 80px; display: block; } -a.zero-stars { +span.zero-stars { background: url(../images/ratings/x_off.gif); height: 15px; left: 80px; display: block; } -a.one-stars{ +span.one-stars{ left: 0px; } -a.one-stars:hover{ +span.one-stars:hover{ width:16px; } -a.two-stars{ +span.two-stars{ left:16px; } -a.two-stars:hover{ +span.two-stars:hover{ width: 32px; } -a.three-stars{ +span.three-stars{ left: 32px; } -a.three-stars:hover{ +span.three-stars:hover{ width: 48px; } -a.four-stars{ +span.four-stars{ left: 48px; } -a.four-stars:hover{ +span.four-stars:hover{ width: 64px; } -a.five-stars{ +span.five-stars{ left: 64px; } -a.five-stars:hover{ +span.five-stars:hover{ width: 80px; } li.current-rating{ diff --git a/templates/show_album.inc b/templates/show_album.inc index e2ef6838..5fc28300 100644 --- a/templates/show_album.inc +++ b/templates/show_album.inc @@ -27,7 +27,6 @@ $web_path = conf('web_path'); // Build array of the table classes we are using $row_classes = array('even','odd'); -// Generate variables for the flash ratings //FIXME: $album_id = $album->id; $artist_id = $album->artist_id; @@ -47,7 +46,11 @@ $title = scrub_out($album->name) . ' -- ' . $album->f_artist;
id, 'album');} // end if ratings + if (conf('ratings')) { + show_ajax_js("r_" . $album->id . "_album",array("rating_" . $album->id . "_album")); + echo "id . "_album\">"; + show_rating($album->id, 'album');} // end if ratings + echo ""; echo "
\n"; ?> :
diff --git a/templates/show_object_rating.inc.php b/templates/show_object_rating.inc.php index 1a0cfb8e..afd6d056 100644 --- a/templates/show_object_rating.inc.php +++ b/templates/show_object_rating.inc.php @@ -21,17 +21,18 @@ /* Create some variables we are going to need */ $web_path = conf('web_path'); -$base_url = $web_path . '/ratings.php?action=set_rating&mode=' . conf('flash') . '&rating_type=' . $rating->type . '&object_id=' . $rating->id . '&username=' . $GLOBALS['user']->username; +$base_url = conf('ajax_url') . '?action=set_rating&rating_type=' . $rating->type . '&object_id=' . $rating->id . conf('ajax_info'); + //set the background to no stars echo ""; ?> +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • + diff --git a/templates/show_songs.inc b/templates/show_songs.inc index c8dbcc7c..be8f179c 100644 --- a/templates/show_songs.inc +++ b/templates/show_songs.inc @@ -145,7 +145,8 @@ foreach ($song_ids as $song_id) { - + + id . "_song",array("rating_" . $song->id . "_song")); ?> id,'song'); ?>