r111623 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111622‎ | r111623 | r111624 >
Date:06:27, 16 February 2012
Author:wikinaut
Status:deferred
Tags:
Comment:
removing unnecessary db->addQuotes() wrappers as the extension uses standard select,update wrappers (usernames were added with quotes in the database). Breaking compatibility with older database entries of older polls. (this could be supplied in a one-time run of an updater (ToDo)). removing spaces in javascript inline. Declaring myself as maintainer of the extension.
Modified paths:
  • /trunk/extensions/AJAXPoll/AJAXPoll.css (modified) (history)
  • /trunk/extensions/AJAXPoll/AJAXPoll.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AJAXPoll/AJAXPoll.php
@@ -17,7 +17,8 @@
1818 * @ingroup Extensions
1919 * @author Dariusz Siedlecki <datrio@gmail.com>
2020 * @author Jack Phoenix <jack@countervandalism.net>
21 - * @version 1.4.1
 21+ * @author Thomas Gries
 22+ * @version 1.500
2223 * @link http://www.mediawiki.org/wiki/Extension:AJAX_Poll Documentation
2324 */
2425
@@ -29,8 +30,8 @@
3031 $wgExtensionCredits['parserhook'][] = array(
3132 'path' => __FILE__,
3233 'name' => 'AJAX Poll',
33 - 'version' => '1.4.2',
34 - 'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix' ),
 34+ 'version' => '1.500',
 35+ 'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix', 'Thomas Gries', ),
3536 'description' => 'Allows AJAX-based polls with <tt>&lt;poll&gt;</tt> tag',
3637 'url' => 'https://www.mediawiki.org/wiki/Extension:AJAX_Poll',
3738 );
@@ -188,7 +189,7 @@
189190 'COUNT(*) AS c',
190191 array(
191192 'poll_id' => $ID,
192 - 'poll_user' => $dbw->addQuotes( $user )
 193+ 'poll_user' => $user
193194 ),
194195 __METHOD__
195196 );
@@ -198,12 +199,12 @@
199200 $updateQuery = $dbw->update(
200201 'poll_vote',
201202 array(
202 - "poll_answer='{$answer}'",
 203+ 'poll_answer' => $answer,
203204 'poll_date' => wfTimestampNow()
204205 ),
205206 array(
206207 'poll_id' => $ID,
207 - 'poll_user' => $dbw->addQuotes( $user )
 208+ 'poll_user' => $user
208209 ),
209210 __METHOD__
210211 );
@@ -218,7 +219,7 @@
219220 'poll_vote',
220221 array(
221222 'poll_id' => $ID,
222 - 'poll_user' => $dbw->addQuotes( $user ),
 223+ 'poll_user' => $user,
223224 'poll_ip' => wfGetIP(),
224225 'poll_answer' => $answer,
225226 'poll_date' => wfTimestampNow()
@@ -275,7 +276,7 @@
276277 array( 'poll_answer', 'poll_date' ),
277278 array(
278279 'poll_id' => $ID,
279 - 'poll_user' => $dbw->addQuotes( $user )
 280+ 'poll_user' => $user
280281 ),
281282 __METHOD__
282283 );
@@ -321,17 +322,13 @@
322323 $percent = $wgLang->formatNum( round( ( isset( $poll_result[$i + 1] ) ? $poll_result[$i + 1] : 0 ) * 100 / $amountOfVotes, 2 ) );
323324 }
324325
325 - if ( isset( $r[0] ) && ( $r[0] - 1 == $i ) ) {
326 - $our = true;
327 - } else {
328 - $our = false;
329 - }
 326+ $our = ( isset( $r[0] ) && ( $r[0] - 1 == $i ) );
330327
331328 // If AJAX is enabled, as it is by default in modern MWs, we can
332329 // just use sajax library function here for that AJAX-y feel.
333330 // If not, we'll have to submit the form old-school way...
334331 if ( $wgUseAjax ) {
335 - $submitJS = "sajax_do_call(\"submitVote\", [\"" . $ID . "\", \"" . $i . "\"], document.getElementById(\"pollContainer" . $ID . "\"));";
 332+ $submitJS = "sajax_do_call(\"submitVote\",[\"" . $ID . "\",\"" . $i . "\"], document.getElementById(\"pollContainer" . $ID . "\"));";
336333 } else {
337334 $submitJS = "document.getElementById(\"pollIdAnswer" . $ID . "\").submit();";
338335 }
@@ -343,9 +340,9 @@
344341 $ans_no . "' onclick='document.getElementById(\"pollAjax" .
345342 $ID . "\").innerHTML=\"" . wfMsg( 'poll-submitting' ) .
346343 "\"; document.getElementById(\"pollAjax" . $ID .
347 - "\").style.display=\"block\"; this.getElementsByTagName(\"input\")[0].checked = true; " .
 344+ "\").style.display=\"block\";this.getElementsByTagName(\"input\")[0].checked=true; " .
348345 $submitJS . "'><input type='radio' id='p_answer" . $ans_no .
349 - "' name='p_answer' value='" . $i . "' />" .
 346+ "' name='p_answer' value='" . $i . "'" . ( $our ? 'checked=true ' : '' ) . "/>" .
350347 strip_tags( $lines[$i] ) .
351348 "</label></div> <div class='pollAnswerVotes" . ( $our ? ' ourVote' : '' ) .
352349 "' onmouseover='span=this.getElementsByTagName(\"span\")[0];tmpPollVar=span.innerHTML;span.innerHTML=span.title;span.title=\"\";' onmouseout='span=this.getElementsByTagName(\"span\")[0];span.title=span.innerHTML;span.innerHTML=tmpPollVar;'><span title='" .
Index: trunk/extensions/AJAXPoll/AJAXPoll.css
@@ -26,14 +26,15 @@
2727 }
2828
2929 .poll .pollAnswerName {
30 - padding-left: 10px;
 30+ margin-top: 5px;
 31+ padding-left: 0px;
3132 font-size: 0.9em;
3233 }
3334
3435 .poll .pollAnswerVotes {
3536 border: 1px solid #CCC;
3637 width: 100%;
37 - margin-left: 10px;
 38+ margin-left: 0px;
3839 height: 12px;
3940 font-size: 10px;
4041 position: relative;
@@ -66,4 +67,21 @@
6768
6869 .poll label {
6970 cursor: pointer;
 71+}
 72+.poll input {
 73+ cursor: pointer;
 74+ vertical-align: middle;
 75+ margin-top: 0px;
 76+ margin-bottom: 0px;
 77+ margin-left: 0px;
 78+}
 79+
 80+.poll #pollInfo {
 81+ margin-top: 20px;
 82+ color: grey;
 83+}
 84+
 85+.poll .pollMisc {
 86+ margin-bottom: 20px;
 87+ color: grey;
7088 }
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r111624follow-up r111623 . adding a newlinewikinaut06:29, 16 February 2012

Status & tagging log