Permalink
Browse files

instead of using a custom JSS file that we need to add manually, auto…

…matically include the necessary links directly from PHP. Cleanup the main file
  • Loading branch information...
1 parent d959c0c commit 25c6677ee6e0d7fe0b319dc9ab61d7a1595243f4 @Whiteknight committed May 1, 2010
Showing with 50 additions and 54 deletions.
  1. +0 −46 PageReviews.js
  2. +50 −8 PeerReview.php
View
@@ -1,47 +1 @@
-function UserInGroup(group) {
- var username = wgUserName;
- var groups = wgUserGroups;
- for(var i = 0; i < groups.length; i++) {
- if(groups[i] == group)
- return true;
- }
- return false;
-}
-
-addOnloadHook(function () {
- if(
- (UserInGroup('Teachers') || UserInGroup('sysop')) &&
- ((wgCanonicalNamespace != "MediaWiki") && (wgCanonicalNamespace != "Special"))
- ) {
- addPortletLink('p-cactions', wgServer + wgScript + "?title=Special:PageOwner/" + wgPageName, 'ownership', 'ca-ownership', null, null);
- }
-});
-
-function AddPersonalLink(link, text, tag, ibefore) {
- var li = document.createElement( 'li' );
- li.id = tag;
- var a = document.createElement( 'a' );
- a.appendChild( document.createTextNode( text ) );
- a.href = link;
- li.appendChild( a );
- if (!ibefore) {
- // append to end (right) of list
- document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
- } else {
- var before = document.getElementById( ibefore );
- before.appendChild( li, before );
- }
-}
-
-addOnloadHook(function() {
- AddPersonalLink(wgServer + wgScript + "?title=Special:MyReviews",
- 'my reviews',
- 'pt-myreviews',
- 'pt-mytalk'
- );
-});
-
-
-
-
View
@@ -1,41 +1,83 @@
<?php
+$dir = dirname(__FILE__) . '/';
+
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
if (!defined('MEDIAWIKI')) {
echo <<<EOT
To install my extension, put the following line in LocalSettings.php:
-require_once( "\$IP/extensions/WITTIE/PageOwner.php" );
+require_once( "{$dir}PeerReview.php" );
EOT;
exit( 1 );
}
-include_once( "$IP/extensions/PeerReview/PageReviews.php" );
+include_once( "{$dir}PageReviews.php" );
-$dir = dirname(__FILE__) . '/';
+
+# Setup the PageOwner special page
$wgAutoloadClasses['PageOwner'] = $dir . 'PageOwner_body.php';
$wgExtensionMessagesFiles['PageOwner'] = $dir . 'PageOwner.i18n.php';
$wgExtensionAliasesFiles['PageOwner'] = $dir . 'PageOwner.alias.php';
$wgSpecialPages['PageOwner'] = 'PageOwner';
+# Setup the MyReviews special page
$wgAutoloadClasses['MyReviews'] = $dir . 'MyReviews_body.php';
$wgExtensionMessagesFiles['MyReviews'] = $dir . 'MyReviews.i18n.php';
$wgExtensionAliasesFiles['MyReviews'] = $dir . 'MyReviews.alias.php';
$wgSpecialPages['MyReviews'] = 'MyReviews';
-// by default, sysops can assign page ownership
+# Add hooks on setup
+$wgExtensionFunctions[] = 'PeerReview_Setup';
+function PeerReview_Setup() {
+ global $wgUser, $wgHooks;
+ if ($wgUser->getID()) {
+ $wgHooks['PersonalUrls'][] = 'PeerReview_addPersonalUrl';
+ if ($wgUser->isAllowed("assignpage")) {
+ $wgHooks['SkinTemplateContentActions'][] = 'PeerReview_AddActionContentHook';
+ }
+ }
+}
+
+# Add the "my reviews" link to the personal URLs list
+function PeerReview_addPersonalUrl( &$personal_urls, $title ) {
+ $personal_urls['myreviews'] = array(
+ 'text' => "my reviews",
+ 'href' => Skin::makeSpecialUrl('MyReviews')
+ );
+ return true;
+}
+
+# Add the "Ownership" link to the page tabs
+function PeerReview_AddActionContentHook( &$content_actions ) {
+ global $wgRequest, $wgRequest, $wgTitle;
+
+ $action = $wgRequest->getText( 'action' );
+
+ if ($wgTitle->getNamespace() != NS_SPECIAL) {
+ $content_actions['ownership'] = array(
+ 'class' => false,
+ 'text' => "Ownership",
+ 'href' => Skin::makeSpecialUrl('PageOwner')
+ );
+ }
+
+ return true;
+}
+
+# "assignpage" allows a person to use Special:PageOwner
+# "viewreviews" allows a person to see the reviews of another user
+# by default, sysops can assign page ownership
$wgGroupPermissions['sysop']['assignpage'] = true;
$wgGroupPermissions['sysop']['viewreviews'] = true;
$wgGroupPermissions['assigner']['assignpage'] = true;
$wgGroupPermissions['grader']['viewreviews'] = true;
+# Credits
$wgExtensionCredits['specialpage'][] = array(
'name' => 'PeerReview',
- 'author' => 'The WITTIE Team',
+ 'author' => 'Andrew Whitworth and Jason Grafinger',
'url' => 'http://www.wittieproject.org/',
'description' => 'Displays user related reviews',
'descriptionmsg' => 'myreviews-desc',
'version' => '1.0'
);
-
-
-
?>

0 comments on commit 25c6677

Please sign in to comment.