Skip to content

Commit

Permalink
finish converting MyReviews over to i18n compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed May 13, 2010
1 parent e111e78 commit 2b2496b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
66 changes: 24 additions & 42 deletions MyReviews_body.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class MyReviews extends SpecialPage {
function __construct() {
parent::__construct('MyReviews');
parent::__construct('MyReviews', 'autoconfirmed');
wfLoadExtensionMessages('PeerReview');
}

Expand All @@ -13,16 +13,14 @@ function __construct() {
function validateUser()
{
global $wgUser;

$this->userName = "";
$this->userID = $wgUser->getID();
if($this->userID == 0) {
if (!$this->userCanExecute($wgUser)) {
$this->displayRestrictionError();
return false;
} else {
$this->username = $wgUser->getName();
$this->viewer = $wgUser->isAllowed('viewreviews');
return true;
}
$this->username = $wgUser->getName();
$this->userID = $wgUser->getID();
$this->viewer = $wgUser->isAllowed('viewreviews');
return true;
}

# Given a namespace ID value, convert it to a textual representation suitable
Expand Down Expand Up @@ -58,13 +56,7 @@ function deleteRecord($recordid)
$back = $this->linkArgs();
$msgDeleted = wfMsg('peerreview-commentdelete');
$msgBack = wfMsg('peerreview-back');
$html = <<<EOT
<p>
{$msgDeleted}<br>
<a href="$back">{$msgBack}</a>
</p>
EOT;
$wgOut->addHTML($html);
$wgOut->addHTML("<p>{$msgDeleted}</p><a href=\"$back\">{$msgBack}</a>");
}

# Show an edit form to edit an existing comment
Expand Down Expand Up @@ -135,14 +127,9 @@ function handlePostBack()
__METHOD__
);
$href = $this->linkArgs();
$html = <<<EOT
<h2>Comment Updated</h2>
<p>
Your comment has been successfully updated!
</p>
<a href="$href">Back</a>
EOT;
$wgOut->addHTML($html);
$msgBack = wfMsg('peerreview-back');
$msgSaved = wfMsg('peerreview-commentsaved');
$wgOut->addHTML("<p>$msgSaved</p><a href=\"$href\">$msgBack</a>");;
}
else if ($postbackmode == "impersonateuser") {
$this->username = $wgRequest->getText("username");
Expand All @@ -156,17 +143,8 @@ function execute($par) {
global $wgOut, $wgScriptPath, $wgRequest;

$this->setHeaders();
$wgOut->setPageTitle("My Reviews");
if (!$this->validateUser()) {
$html = <<<EOT
<h2>Access Denied!</h2>
<p>
You must be logged in to view this page!
</p>
EOT;
$wgOut->addHTML($html);
if (!$this->validateUser())
return;
}
if ($wgRequest->wasPosted()) {
$this->handlePostBack();
return;
Expand Down Expand Up @@ -220,6 +198,8 @@ function reviewsIGave() {
$dbr = wfGetDB(DB_SLAVE);
$given = $dbr->query($selectquery);
$givenReviews = "";
$msgEdit = wfMsg('peerreview-edit');
$msgDelete = wfMsg('peerreview-delete');
while($row = $dbr->fetchObject($given)) {
$namespaceId = $row->page_namespace;
$namespace = $this->getNamespaceNameFromId($namespaceId);
Expand All @@ -231,9 +211,9 @@ function reviewsIGave() {
<div class="PeerReview-MyReviews-given">
<p>
<span style='float: right; font-size: 80%'>
<a href="javascript: really_delete({$row->id});">delete</a>
[<a href="javascript: really_delete({$row->id});">{$msgDelete}</a>
&mdash;
<a href="{$editlink}">edit</a>
<a href="{$editlink}">{$msgEdit}</a>]
</span>
<b><a href="{$pagehref}">{$pagelink}</a></b>
</p>
Expand Down Expand Up @@ -318,30 +298,32 @@ function showMainPage() {
$takenReviews = $this->reviewsIReceive();
$ownedpages = $this->ownedPages();
$baseurl = $this->linkArgs();

# TODO: Show a list of all pages I own
$msgReally = wfMsg('peerreview-reallydelete');
$msgOwned = wfMsg('peerreview-pagesowned');
$msgGiven = wfMsg('peerreview-reviewsgiven');
$msgTaken = wfMsg('peerreview-reviewstaken');
$html = <<<EOT
<script type="text/javascript">
function really_delete(id) {
var url = "{$baseurl}/delete/" + id;
if(confirm("Really delete this review?"))
if(confirm("R{$msgReally}"))
document.location = url;
}
</script>
<table style="width: 100%;" cellspacing="5" cellpadding="5">
<tr>
<td id="PeerReview-MyReviews-owned-side" valign="top" colspan="2">
<h3>Pages Owned</h3>
<h3>{$msgOwned}</h3>
{$ownedpages}
</td>
</tr>
<tr>
<td id="PeerReview-MyReviews-received-side" valign="top">
<h3>Reviews Received</h3>
<h3>{$msgTaken}</h3>
{$takenReviews}
</td>
<td id="PeerReview-MyReviews-given-side" valign="top">
<h3>Reviews Given</h3>
<h3>{$msgGiven}</h3>
{$givenReviews}
</td>
</tr>
Expand Down
7 changes: 7 additions & 0 deletions PeerReview.i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@
'peerreview-newowners' => 'Add New Owners',
'peerreview-add' => 'Add',
'peerreview-commentdelete' => 'Comment deleted.',
'peerreview-commentsaved' => 'Your comment has been successfully updated.',
'peerreview-errowncomment' => 'You cannot edit review $1 because you did not create it.',
'peerreview-comment' => 'Comment',
'peerreview-score' => 'Score',
'peerreview-cancel' => 'Cancel',
'peerreview-save' => 'Save',
'peerreview-delete' => 'Delete',
'peerreview-edit' => 'Edit',
'peerreview-reallydelete' => 'Really delete this review?',
'peerreview-pagesowned' => 'Pages Owned',
'peerreview-reviewsgiven' => 'Reviews Given',
'peerreview-reviewstaken' => 'Reviews Received',

);

0 comments on commit 2b2496b

Please sign in to comment.