r50494 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50493‎ | r50494 | r50495 >
Date:18:39, 11 May 2009
Author:jan
Status:deferred
Tags:
Comment:
* Add new messages
* Add $wgSpecialPageGroups
* Add theDB function for create
Modified paths:
  • /trunk/extensions/Poll/Poll.i18n.php (modified) (history)
  • /trunk/extensions/Poll/Poll.php (modified) (history)
  • /trunk/extensions/Poll/Poll_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Poll/Poll_body.php
@@ -43,17 +43,17 @@
4444 }
4545 else {
4646 $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => 'index.php?title=Special:Poll&action=submit' ) ) );
47 - $wgOut->addHtml( Xml::openElement( 'table' );
48 - $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('poll_name').'</td></tr>' );
 47+ $wgOut->addHtml( Xml::openElement( 'table' ) );
 48+ $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('question').'</td></tr>' );
4949 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 1:</td><td>'.Xml::input('poll_alternative_1').'</td></tr>' );
5050 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 2:</td><td>'.Xml::input('poll_alternative_2').'</td></tr>' );
5151 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 3:</td><td>'.Xml::input('poll_alternative_3').'</td></tr>' );
5252 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 4:</td><td>'.Xml::input('poll_alternative_4').'</td></tr>' );
5353 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 5:</td><td>'.Xml::input('poll_alternative_5').'</td></tr>' );
5454 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 6:</td><td>'.Xml::input('poll_alternative_6').'</td></tr>' );
55 - $wgOut->addHtml( '<tr><td>'.Xml::submitButton(wfMsg( 'poll-submit' )).'</td></tr>' );
56 - $wgOut->addHtml( Xml::closeElement( table ) );
57 - $wgOut->addHtml( Xml::closeElement( form ) );
 55+ $wgOut->addHtml( '<tr><td>'.Xml::submitButton(wfMsg( 'poll-submit' )).''.Xml::hidden('action', 'create').'</td></tr>' );
 56+ $wgOut->addHtml( Xml::closeElement( 'table' ) );
 57+ $wgOut->addHtml( Xml::closeElement( 'form' ) );
5858 }
5959 }
6060
@@ -77,5 +77,36 @@
7878
7979 public function submit() {
8080 global $wgRequest, $wgOut, $wgUser;
 81+
 82+ $type = htmlenttitles($_POST['action']);
 83+
 84+ if($type == 'create') {
 85+ $controll_create_right = $wgUser->isAllowed( 'poll-create' );
 86+ $controll_create_blocked = $wgUser->isBlocked();
 87+ if ( $controll_create_right != true ) {
 88+ $wgOut->addWikiMsg( 'poll-create-right-error' );
 89+ }
 90+ elseif ( $controll_create_blocked == true ) {
 91+ $wgOut->addWikiMsg( 'poll-create-block-error' );
 92+ }
 93+ else {
 94+ $dbw = wfGetDB( DB_MASTER );
 95+ $question = $_POST['question'];
 96+ $alternative_1 = $_POST['poll_alternative_1'];
 97+ $alternative_2 = $_POST['poll_alternative_2'];
 98+ $alternative_3 = ($_POST['poll_alternative_3'] != "")? $_POST['poll_alternative_3'] : "";
 99+ $alternative_4 = ($_POST['poll_alternative_4'] != "")? $_POST['poll_alternative_4'] : "";
 100+ $alternative_5 = ($_POST['poll_alternative_5'] != "")? $_POST['poll_alternative_5'] : "";
 101+ $alternative_6 = ($_POST['poll_alternative_6'] != "")? $_POST['poll_alternative_6'] : "";
 102+
 103+ if($question != "" && $alternative_1 != "" && $alternative_2 != "") {
 104+ $dbw->insert( 'poll', array( 'question' => $question, 'alternative_1' => $alternative_1, 'alternative_2' => $alternative_2,
 105+ 'alternative_3' => $alternative_3, 'alternative_4' => $alternative_4, 'alternative_5' => $alternative_5,
 106+ 'alternative_6' => $alternative_6 ) );
 107+ }
 108+ else {
 109+ $wgOut->addWikiMsg( 'poll-create-fields-error' );
 110+ }
 111+ }
81112 }
82113 }
Index: trunk/extensions/Poll/Poll.i18n.php
@@ -22,6 +22,10 @@
2323 'poll-alternative' => 'Alternative',
2424 'poll-question' => 'Question',
2525 'poll-submit' => 'Submit',
 26+ 'right-poll-create' => 'Create Poll',
 27+ 'right-poll-vote' => 'Vote by a Poll',
 28+ 'right-poll-admin' => 'Manage the Polls',
 29+ 'poll-create-fields-error' => 'The fields Question, Alternative 1 and Alternative 2 must be set',
2630 );
2731
2832 $messages['de'] = array(
@@ -37,4 +41,8 @@
3842 'poll-alternative' => 'Antwortmöglichkeit',
3943 'poll-question' => 'Frage',
4044 'poll-submit' => 'Absenden',
 45+ 'right-poll-create' => 'Umfrage erstellen',
 46+ 'right-poll-vote' => 'Bei einer Umfrage abstimmen',
 47+ 'right-poll-admin' => 'Umfragen verwalten',
 48+ 'poll-create-fields-error' => 'Die Felder Frage, Antwortmöglichkeit 1 sowie Antwortmöglichkeit 2 müssen ausgefüllt sein',
4149 );
Index: trunk/extensions/Poll/Poll.php
@@ -54,4 +54,4 @@
5555 $wgExtensionMessagesFiles['Poll'] = $dir . 'Poll.i18n.php';
5656 $wgExtensionAliasesFiles['Poll'] = $dir . 'Poll.alias.php';
5757 $wgSpecialPages['Poll'] = 'Poll'; # Let MediaWiki know about your new special page.
58 -// FIXME: add $wgSpecialPageGroups
 58+$wgSpecialPageGroups['Poll'] = 'other';
\ No newline at end of file

Status & tagging log