diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-23 02:10:27 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-23 02:10:27 +0000 |
commit | 84eca6a3d59fc591a7e28b3d7e0c11746dc837fc (patch) | |
tree | 837dd1a9051e787ff9bca6a7f928ac710ea639cd /lib | |
parent | b62f10549d421dfee1d9f4268522946f665ae11f (diff) | |
download | ampache-84eca6a3d59fc591a7e28b3d7e0c11746dc837fc.tar.gz ampache-84eca6a3d59fc591a7e28b3d7e0c11746dc837fc.tar.bz2 ampache-84eca6a3d59fc591a7e28b3d7e0c11746dc837fc.zip |
sync french translation, fixed ratings
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/ajax.class.php | 12 | ||||
-rw-r--r-- | lib/class/rating.class.php | 35 |
2 files changed, 39 insertions, 8 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index 8f68da98..cb734edf 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -80,19 +80,25 @@ class Ajax { * This prints out the specified text as a link and setups the required * ajax for the link so it works correctly */ - public static function text($action,$text,$source,$post='') { + public static function text($action,$text,$source,$post='',$span_class='') { $url = Config::get('ajax_url') . $action; + // Use ajaxPost() if we are doing a post if ($post) { $ajax_string = "ajaxPost('$url','$post','$source')"; } else { - $ajax_string = "ajaxPut('$url','$post','$source')"; + $ajax_string = "ajaxPut('$url','$source')"; + } + + // If they passed a span class + if ($span_class) { + $class_txt = ' class="' . $span_class . '"'; } // If we pass a source put it in the ID - $string = "<span id=\"$source\">$text</span>\n"; + $string = "<span id=\"$source\" $class_txt>$text</span>\n"; $string .= self::observe($source,'click',$ajax_string); diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index 99fa7612..349f01d0 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -64,12 +64,12 @@ class Rating { $user_id = Dba::escape($user_id); - $sql = "SELECT `user_rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'"; + $sql = "SELECT `rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'"; $db_results = Dba::query($sql); $results = Dba::fetch_assoc($db_results); - return $results['user_rating']; + return $results['rating']; } // get_user @@ -82,7 +82,7 @@ class Rating { */ public function get_average() { - $sql = "SELECT `user_rating` AS `rating` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type'"; + $sql = "SELECT `rating` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type'"; $db_results = Dba::query($sql); $i = 0; @@ -123,11 +123,11 @@ class Rating { $db_results = Dba::query($sql); if ($existing = Dba::fetch_assoc($db_results)) { - $sql = "UPDATE `rating` SET `user_rating`='$score' WHERE `id`='" . $existing['id'] . "'"; + $sql = "UPDATE `rating` SET `rating`='$score' WHERE `id`='" . $existing['id'] . "'"; $db_results = Dba::query($sql); } else { - $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`user_rating`,`user`) VALUES " . + $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`rating`,`user`) VALUES " . " ('$this->id','$this->type','$score','" . $GLOBALS['user']->id . "')"; $db_results = Dba::query($sql); } @@ -136,5 +136,30 @@ class Rating { } // set_rating + /** + * show + * This takes an id and a type and displays the rating if ratings are enabled. + */ + public static function show ($object_id,$type) { + + // If there aren't ratings don't return anything + if (!Config::get('ratings')) { return false; } + + $rating = new Rating($object_id,$type); + + require Config::get('prefix') . '/templates/show_object_rating.inc.php'; + + } // show + + /** + * show_static + * This is a static version of the ratings created by Andy90 + */ + public static function show_static ($object_id,$type) { + + + + } // show_static + } //end rating class ?> |