Jump to content

Extension:AjaxRatingScript: Difference between revisions

From mediawiki.org
Content deleted Content added
+ archive
 
(14 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{ArchivedExtension|911636|VoteNY}}
{{extension
|name=Ajax RatingScript Unobtrusive
|author=[[User:Dynasource]]
|image=Ratingscript.gif
|type1=page action
|type2=ajax
|version=2.0
|status=beta
|hook1= BeforePageDisplay
|update=2007-09-13
|mediawiki=1.10.1, 1.11, 1.14
|download=[http://www.leerwiki.nl/Ajax_Rating_script_with_Toplist Version 2] <br> [http://www.promotionwiki.com/script.rar Version 1.x]
|readme=
|changelog=
|description=Ajax script with 2 to 10 stars Review/Rating possibilities
|parameters=
|license=GPL Licence
|rights=
|example= [http://www.piemontewireless.net/Biblioteca_Fisica Live Example]
}}

Extension:AjaxRatingScript is a social rating extension.

==AjaxRatingScript V2 tested on different versions of MediaWiki==
* MediaWiki 1.15 - Working
* MediaWiki 1.14 - Working
* MediaWiki 1.6.12 - error: unexpected T_OBJECT_OPERATOR in RateArticle.php on line 21: <code> if $wgArticle->getTitle()->mNamespace != 0) return $out; </code>

==Installation==
For installation of version 1.x follow instructions on http://www.leerwiki.nl/How_to_get_rating_script_work
<br>For '''older versions of MediaWiki''' try [http://www.leerwiki.nl/How_to_port_Unobtrusive_AJAX_Star_Rating_Bar_to_MediaWiki this link] or check the instructions at the end of the [[#RateArticle.php V2|RateArticle.php V2 file.]]
<br><br>'''For installation of version 2:'''
* Create the [[#RateArticle.php V2|RateArticle.php]] ([http://www.leerwiki.nl/Ajax_Rating_script_with_Toplist www.leerwiki.nl - author's site]) file and include it in your mediawiki extensions directory
* Set the ''$pathToRating'' variable in ''RateArticle.php'' according to your mediawiki path
* Download the [http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar Unobtrusive AJAX Star Rating Bar files] to your mediawiki ''extensions/Ratings'' folder
* Edit ''_config-rating.php'' in the ''extensions/Ratings'' folder according to your database user settings
* Add the usual line to the end of your LocalSettings.php:
<source lang="php">require_once("$IP/extensions/Ratings/RateArticle.php"); </source>
* Create the table ''ratings'' in your mediawiki db
<source lang="sql">CREATE TABLE `ratings` (
`id` varchar(11) NOT NULL,
`total_votes` int(11) NOT NULL default '0',
`total_value` int(11) NOT NULL default '0',
`used_ips` longtext,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;</source>

The script's code is not prepared to be invoked from any other directory than where it is placed, so you'll need to adjust some values to make it work on your MediaWiki implementation transparently:

*_config-rating.php: Update your MySQL connection info.
*_drawrating.php: Prefix your MW full path to db.php. In my case, it would be /mediawiki/extensions/Ratings/db.php
*js/rating.js: Prefix your MW full path to rpc.php. In my case, /mediawiki/extensions/Ratings/rpc.php

In order to translate the script to other language you'll have to work with: _drawrating.php, js/rating.js, db.php and rpc.php.




=== RateArticle.php V2 ===
<source lang="php">
<?php
require('Ratings/_drawrating.php');
if ( ! defined( 'MEDIAWIKI' ) )
die();

$wgExtensionCredits['parserhook'][] = array(
'name' => 'AJAX RATING BAR V2 14-07-2007 Based on Masugadesign',
'author' => 'Boudewijn Vahrmeijer',
'url' => 'http://www.leerwiki.nl',
'version' => '1.11,1.10.1/1.9.3/1.9.2/1.8.2',
'description' => 'Ajax Rating Bar for MediaWiki',
);

$pathToRating='/mediawiki/extensions/Ratings/';

$wgHooks['BeforePageDisplay'][] = array("wfRateArticleForm");
function wfRateArticleForm(&$out) {
global $wgArticle,$pathToRating;
if ($wgArticle == null) return $out;
if ($wgArticle->getTitle()->mNamespace != 0) return $out;

$out->mBodytext.='<script type="text/javascript" language="javascript" src="'.$pathToRating.'js/behavior.js"></script>';
$out->mBodytext.='<script type="text/javascript" language="javascript" src="'.$pathToRating.'js/rating.js"></script>';
$out->mBodytext.='<link rel="stylesheet" type="text/css" href="'.$pathToRating.'css/rating.css" />';
$out->mBodytext.=rating_bar($wgArticle->getID(),5);

return $out;
}

$wgExtensionFunctions[] = 'setupSpecialToprating';
function setupSpecialToprating() {
global $IP, $wgMessageCache;
require_once($IP.'/includes/SpecialPage.php');
SpecialPage::addPage(new SpecialPage('RatingOverview', '', true, 'spTopList', false));

# Messages used in this extension
$wgMessageCache->addMessage('ratingoverview', 'A Top Rating Overview');
}

function spTopList() {
global $wgOut, $wgParser, $wgUser;
require('Ratings/_config-rating.php');
$result=mysql_query("SELECT * FROM $rating_dbname.$rating_tableName ORDER BY total_value DESC")or die(" Error: ".mysql_error());

$i='<table border="1" style="border:1px;border-color:black;">
<tr><td>Position</td><td>Title</td><td>Value</td><td>Total Votes</td></tr>';

while ($row = mysql_fetch_assoc($result)) {

#####FOR VERSIONS 1.11 #################:
$title=Title::newFromID($row["id"]);

#####FOR LOWER VERSIONS AS 1.93
// $atitle=Title::newFromID($row["id"]);
// if(is_object($atitle)){
// $title=$atitle->getIndexTitle();
// }

#######################################
if(!$title==''){
$a=$a+1;
$i.= '<tr><td>'.$a.'</td>';
$i.= '<td>[['.$title.']]</td>';
$i.= '<td>'.$row["total_value"].'</td>';
$i.= '<td>'.$row["total_votes"].'</td></tr>';
}
}
$i.='</table>';

$wgOut->addWikiText($i);

}
?>
</source>

== Who's using it? ==
Please add your '''working'''-wiki here!

Creator:
* [http://www.leerwiki.nl/Hoofdpagina LeerWiki.nl] : Learn handy stuff

Users:
* [http://www.holopedia.de Holopedia.de] Community Database
* [http://www.wikicocina.com.ar Wikicocina.com.ar] Recetas de Cocina
* [http://www.piemontewireless.net Piemontewireless.net] ComputerScience, Electronics, Mathematics and more Wiki
* [http://www.darlingwiki.com DarlingWiki.com] A guide for events and resources for parents and kids
* [http://www.NasiLL.com/ NasiLL.com] : howto sources for Turkish users "howto"
* [http://www.stoopidwiki.com/ Stoopid Wiki] : A fun source for all things "stoopid"
* [http://r.evie.ws/ Reviews Wiki] : A great way to review almost anything
* [http://www.htpcnz.net/ HTPCnz] : Home Theatre PC Wiki - Chat - Forums - Blogs
* [http://www.alaskamountainforum.com/wiki AlaskaMountainForum.com] : Alaska Mountain Forum Wiki
* [http://www.ipbwiki.com/ IpbWiki.com] : IpbWiki
* [http://www.captainwiki.com/ CaptainWiki.com] : Sailing Wiki
* [http://www.lezsohbet.gen.tr/ Lez Sohbet] : lez sohbet
* [http://www.wereldpagina.nl/ Wereldpagina.nl] : Worldwide travel guide
* [http://FreeThoughtPedia.com Atheist Encyclopedia] Freethought wiki
* [http://www.hobby-planet.de hobby-planet.de] : Xbox 360 Wiki (Solutions, etc.)
* [http://www.wikinouvelles.fr/wiki/ Wikinouvelles.fr] Ideas
* [http://www.wikiph.org WikiPH] Public health Wiki
* [http://www.emunity.org Emunity] Elders Community Older Peoples Local Community Wiki based in Brent UK
* [[:VLOS:Special:RatingOverview|Vietnamese Library of Science]] Ajax Rating for pages + a summary special page
* [http://www.socialopedia.org Socialopedia, l'encyclopédie collaborative des socialistes] Politic wiki on french (MW1.12, Rating limited to Namespaces : 'Motion:' and 'Proposition:')
* [http://john.bryntze.net/jbkb/ John Bryntze Knowledge Base] IT articles
* [http://asianmediawiki.com AsianMediaWiki] Asian Movie Database
* [http://www.nlpedia.de/ NLPedia] German NLP Wiki
* [http://www.viptravestim.com/ travesti] Travesti rehber NLP Wiki
* [http://www.freecoffee.de Freecoffee] German Freeware-Wiki
* [http://www.guitarpedia.co.il Guitarpedia] Free Guitar index and lessons
* [http://www.spielwiki.de Spielwiki] ein Wiki für Spiele - Partyspiele, Brettspiele, Kartenspiele...
* [http://pcwelt-tipps.de pcwelt-tipps.de] Tips and Howtos from pcwelt.de (German language)
* [http://www.venicewiki.org Venicewiki.org] The People's Guide to Venice
* [http://turkgayclub.org GayWiki] LGBT Wiki of Turk Gay Club[http://www.turkgayclub.com Offical Site]
* [http://www.citroen-sm.org/wiki/index.php/Main_Page citroen-sm.org] Citroen SM Wiki
* [http://wiki.grempis.com.ua/ Wiki GREMPIS] : Gas metering technologies and devices (Russian language)
* [http://hadigayri.com TurkishLGBTTNews] LGBTT Gay News and Forums [http://www.hadigayri.com Offical Site]
* [http://www.elittravestiler.com ElitTravestiler] Travesti Guide Wiki
* [http://www.wihow.com Wihow] How to Instruction and Tips
* [http://www.wikisubj.org WikiSubj] Events, the reasons and their consequences on WikiSubj

== See Also ==
* [[Extension:JSKitRating]]

[[Category:Discussion and forum extensions]]
[[Category:Edit extensions]]
[[Category:Rating extensions]]
http://www.travestibestmodel.com
http://gratistvkijkenoppc.org
http://nhaopleidingen.nl

Latest revision as of 10:02, 21 February 2014