r74925 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74924‎ | r74925 | r74926 >
Date:22:08, 17 October 2010
Author:siebrand
Status:ok
Tags:
Comment:
Fixes round 1:
* stylize.php run
* line breaks for README.txt
* preparing renames for files to same name as extension folder
* change variable for i18n for special page aliases
*
Modified paths:
  • /trunk/extensions/WikiBhasha/README.txt (modified) (history)
  • /trunk/extensions/WikiBhasha/wikiBhashaExtClass.php (modified) (history)
  • /trunk/extensions/WikiBhasha/wikiBhashaSpecial.php (modified) (history)
  • /trunk/extensions/WikiBhasha/wikibhasha.alias.php (modified) (history)
  • /trunk/extensions/WikiBhasha/wikibhasha.i18n.php (modified) (history)
  • /trunk/extensions/WikiBhasha/wikibhasha.php (modified) (history)
  • /trunk/extensions/WikiBhasha/wikibhasha_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiBhasha/wikibhasha.php
@@ -6,7 +6,7 @@
77 ********************************************************/
88
99 /*
10 -Copyright (c) 2010, Microsoft
 10+Copyright (c) 2010, Microsoft
1111 All rights reserved.
1212 */
1313
@@ -23,31 +23,31 @@
2424
2525 $wgExtensionCredits['specialpage'][] = array(
2626 'name' => 'WikiBhasha',
27 - 'author' => 'Microsoft Researh',
 27+ 'author' => 'Microsoft Research',
2828 'url' => 'http://www.mediawiki.org/wiki/Extension:WikiBhasha',
2929 'description' => 'Default description message',
3030 'descriptionmsg' => 'wikibhasha-desc',
3131 'version' => '1.0',
3232 );
3333
34 -//static Paths
35 -$dir = dirname(__FILE__) . '/';
 34+// static Paths
 35+$dir = dirname( __FILE__ ) . '/';
3636 $jsPath = "extensions/WikiBhasha/src/";
3737
38 -//add a special page
 38+// add a special page
3939 $wgSpecialPages['wikiBhasha'] = 'WikiBhasha';
4040 $wgSpecialPageGroups['wikiBhasha'] = 'wiki';
4141
4242 // Autoloadable classes
43 -$wgAutoloadClasses['wikiBhashaExt'] = $dir . 'wikiBhashaExtClass.php';
44 -$wgAutoloadClasses['wikiBhasha'] = $dir . 'wikiBhashaSpecial.php';
 43+$wgAutoloadClasses['wikiBhashaExt'] = $dir . 'WikiBhashaExtClass.php';
 44+$wgAutoloadClasses['wikiBhasha'] = $dir . 'WikiBhashaSpecial.php';
4545
46 -//initilize wikiBhasha launch class
 46+// initilize wikiBhasha launch class
4747 $wbExtClass = new wikiBhashaExt();
4848
49 -$wgAutoloadClasses['wikibhasha'] = $dir . 'wikibhasha_body.php'; # Location of the wikibhasha class (Tell MediaWiki to load this file)
50 -$wgExtensionMessagesFiles['wikibhasha'] = $dir . 'wikibhasha.i18n.php'; # Location of a messages file (Tell MediaWiki to load this file)
51 -$wgHooks['MonoBookTemplateToolboxEnd'][] = array( $wbExtClass, 'wikiBhashaToolbox' );
 49+$wgAutoloadClasses['wikibhasha'] = $dir . 'WikiBhasha_body.php'; # Location of the wikibhasha class (Tell MediaWiki to load this file)
 50+$wgExtensionMessagesFiles['WikiBhasha'] = $dir . 'WikiBhasha.i18n.php'; # Location of a messages file (Tell MediaWiki to load this file)
 51+$wgExtensionAliasesFiles['WikiBhasha'] = $dir . 'WikiBhasha.alias.php'; # Location of a messages file (Tell MediaWiki to load this file)
 52+
 53+$wgHooks['MonoBookTemplateToolboxEnd'][] = array( $wbExtClass, 'wikiBhashaToolbox' );
5254 $wgHooks['BeforePageDisplay'][] = array( $wbExtClass, 'wbToolbarIcon' );
53 -
54 -?>
\ No newline at end of file
Index: trunk/extensions/WikiBhasha/wikiBhashaSpecial.php
@@ -1,19 +1,11 @@
22 <?php
33 /**
4 - * Special:Gadgets, provides a preview of MediaWiki:Gadgets.
 4+ * Special:WikiBhasha
55 *
66 * @file
77 * @ingroup SpecialPage
8 - * @author Daniel Kinzler, brightbyte.de
9 - * @copyright © 2007 Daniel Kinzler
10 - * @license GNU General Public License 2.0 or later
118 */
129
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - echo( "not a valid entry point.\n" );
15 - die( 1 );
16 -}
17 -
1810 /**
1911 *
2012 */
@@ -33,8 +25,6 @@
3426 function execute( $par ) {
3527 global $wgRequest, $wgOut;
3628 $this->setHeaders();
37 - $wgOut->addHTML('<h2>message goes here</h2>');
 29+ $wgOut->addHTML( '<h2>message goes here</h2>' );
3830 }
39 -
4031 }
41 -?>
\ No newline at end of file
Index: trunk/extensions/WikiBhasha/wikiBhashaExtClass.php
@@ -6,7 +6,7 @@
77 ********************************************************/
88
99 /*
10 -Copyright (c) 2010, Microsoft
 10+Copyright (c) 2010, Microsoft
1111 All rights reserved.
1212 */
1313
@@ -20,41 +20,38 @@
2121 // icon to the toolbar for launching WikiBhasha.
2222 // 2. inserts a "WikiBhasha" option in the left side toolbox menu.
2323 // 3. Looks for "wbAutoLaunch=true" in the URL and launch WikiBhasha.
24 -
25 -
26 -class wikiBhashaExt{
 24+class wikiBhashaExt {
2725 private $url, $wikiBhashaUrl;
2826 function __construct() {
2927 global $jsPath;
3028 $this->url = $jsPath;
31 - $this->wikiBhashaUrl = 'if(!(document.getElementById("wbBlockParentUI"))){this.baseUrl ="'.$this->url.'";this.targetLanguageCode="en";this.wikiSourceLanguage=typeof(wgUserLanguage)!=="undefined"?wgUserLanguage:"en";wbBookMarkletLinkDiv=document.createElement("div");wbBookMarkletLinkDiv.id="wbLoadDiv";wbBookMarkletLinkDiv.innerHTML="<div style=\"background-color:Black;color:#FFFFFF;position:absolute;text-align:center;font-size:13px;font-weight:bold;left:0px;top:0px;padding:10px 0;z-index:1000;width:100%;border-bottom:3px solid gray;\">Loading...</div>";document.body.appendChild(wbBookMarkletLinkDiv);wbBookMarkletScripts=document.createElement("script");wbBookMarkletScripts.setAttribute("src", "'.$this->url.'js/main.js");document.body.appendChild(wbBookMarkletScripts);}';
 29+ $this->wikiBhashaUrl = 'if(!(document.getElementById("wbBlockParentUI"))){this.baseUrl ="' . $this->url . '";this.targetLanguageCode="en";this.wikiSourceLanguage=typeof(wgUserLanguage)!=="undefined"?wgUserLanguage:"en";wbBookMarkletLinkDiv=document.createElement("div");wbBookMarkletLinkDiv.id="wbLoadDiv";wbBookMarkletLinkDiv.innerHTML="<div style=\"background-color:Black;color:#FFFFFF;position:absolute;text-align:center;font-size:13px;font-weight:bold;left:0px;top:0px;padding:10px 0;z-index:1000;width:100%;border-bottom:3px solid gray;\">Loading...</div>";document.body.appendChild(wbBookMarkletLinkDiv);wbBookMarkletScripts=document.createElement("script");wbBookMarkletScripts.setAttribute("src", "' . $this->url . 'js/main.js");document.body.appendChild(wbBookMarkletScripts);}';
3230 }
3331
34 - //add wikibhasha link to the wikipedia left bar toolbar box
 32+ // add wikibhasha link to the wikipedia left bar toolbar box
3533 public function wikiBhashaToolbox( &$monobook ) {
3634 echo "<li><a href='javascript:void(0);' style='color: rgb(0, 36, 255);' onclick='(function(){" . $this->wikiBhashaUrl . "})()' id='wbInstallLinkff'>" . wfMsg( 'wikiBhashaLink' ) . "</a></li>";
3735 return true;
3836 }
39 -
40 - //create wikipedia edite page toolbar icon on the edit pages for wikibhasha
 37+
 38+ // create wikipedia edite page toolbar icon on the edit pages for wikibhasha
4139 public function wbToolbarIcon( &$out, &$sk ) {
4240 global $wgRequest;
4341 $jsAutoLoad = '';
4442 $jsIconScript = '';
45 - if( $wgRequest->getText( 'action' ) == 'edit' ){
46 - $imgUrl = $this->url.'images/Square.png';
 43+ if ( $wgRequest->getText( 'action' ) == 'edit' ) {
 44+ $imgUrl = $this->url . 'images/Square.png';
4745 $jsWBIconScript = " var wbIcon = document.createElement('a'); wbIcon.title = '" . wfMsg( 'wikiBhashaLink' ) . "';wbIcon.href='javascript:(function(){" . addslashes( $this->wikiBhashaUrl ) . "})()'; wbIcon.innerHTML = '<img src=\'" . $imgUrl . "\'>';";
4846 $jsIconScript = $jsWBIconScript . "if(document.getElementById('toolbar')){ var toolbar = document.getElementById('toolbar'); if(toolbar.firstChild) toolbar.appendChild(wbIcon);}";
4947 $jsIconScript .= "if(document.getElementById('wikiEditor-ui-toolbar')){wbIconGroupDiv = document.createElement('div');wbIconGroupDiv.setAttribute('class', 'group group-format');wbIconGroupDiv.appendChild(wbIcon);var toolbar = document.getElementById('wikiEditor-ui-toolbar');if(toolbar.firstChild)toolbar.firstChild.appendChild(wbIconGroupDiv);}";
50 -
 48+
5149 }
52 - //if the url contain wbAutoLaunch as true launch wikibhasha
53 - if( $wgRequest->getText( 'wbAutoLaunch' ) == "true" ){
 50+ // if the url contain wbAutoLaunch as true launch wikibhasha
 51+ if ( $wgRequest->getText( 'wbAutoLaunch' ) == "true" ) {
5452 $jsAutoLoad = $this->wikiBhashaUrl;
5553 }
5654 $out->addScript( "<script language='javascript'> window.onload = function(){" . $jsIconScript . $jsAutoLoad . "}</script>" );
5755 return true;
5856 }
5957 }
60 -?>
6158
Index: trunk/extensions/WikiBhasha/wikibhasha.alias.php
@@ -1,13 +1,12 @@
22 <?php
3 -$aliases = array();
4 -
5 -/** English */
6 -$aliases['en'] = array(
7 - 'wikibhasha' => array( 'Wikibhasha' ),
 3+
 4+$specialPageAliases = array();
 5+
 6+$specialPageAliases['en'] = array(
 7+ 'WikiBhasha' => array( 'WikiBhasha' ),
88 );
9 -
10 -/** German (Deutsch) */
11 -$aliases['de'] = array(
12 - 'wikibhasha' => array( 'MeineErweiterung', 'Meine Erweiterung' ),
13 -);
14 -?>
\ No newline at end of file
 9+
 10+/**
 11+ * For backwards compatibility with MediaWiki 1.15 and earlier.
 12+ */
 13+$aliases =& $specialPageAliases;
Index: trunk/extensions/WikiBhasha/README.txt
@@ -1,7 +1,11 @@
2 -This directory contains the Javascript and PHP sources and other resources for the WikiBhasha (Beta) extension that is being open sourced by Microsoft Research. WikiBhasha (Beta) is a being open-sourced as a MediaWiki Extension, with the Javascript portions under Apache License 2.0 and the PHP portions under Gnu GPL License 2.0. We plan to work with the community to go thorugh the review process to make this available as an extension.
 2+This directory contains the Javascript and PHP sources and other resources for
 3+the WikiBhasha (Beta) extension that is being open sourced by Microsoft
 4+Research. WikiBhasha (Beta) is a being open-sourced as a MediaWiki Extension,
 5+with the JavaScript portions under Apache License 2.0 and the PHP portions under
 6+GNU GPL License 2.0. We plan to work with the community to go through the
 7+review process to make this available as an extension.
38
4 -WikiBhasha is aimed at enabling user communities in creating multilingual content in Wikipedia.
 9+WikiBhasha is aimed at enabling user communities in creating multilingual
 10+content in Wikipedia.
511
612 -- WikiBhasha team (17 October 2010)
7 -
8 -
Index: trunk/extensions/WikiBhasha/wikibhasha_body.php
@@ -1,22 +1,21 @@
22 <?php
 3+
34 class wikibhasha extends SpecialPage {
45 function __construct() {
56 parent::__construct( 'Wikibhasha' );
6 - wfLoadExtensionMessages('Wikibhasha');
77 }
8 -
 8+
99 function execute( $par ) {
1010 global $wgRequest, $wgOut;
11 -
 11+
1212 $this->setHeaders();
13 -
 13+
1414 # Get request data from, e.g.
15 - $param = $wgRequest->getText('param');
16 -
 15+ $param = $wgRequest->getText( 'param' );
 16+
1717 # Do stuff
1818 # ...
19 - $output="WikiBhasha";
 19+ $output = "WikiBhasha";
2020 $wgOut->addWikiText( $output );
2121 }
2222 }
23 -?>
\ No newline at end of file
Index: trunk/extensions/WikiBhasha/wikibhasha.i18n.php
@@ -1,17 +1,21 @@
22 <?php
 3+
34 $messages = array();
4 -
5 -/* *** English *** */
 5+
 6+/**
 7+ * English
 8+ */
69 $messages['en'] = array(
710 'wikibhasha' => 'WikiBhasha',
811 'wikibhasha-desc' => "Extension's description",
9 - 'wikiBhashaLink'=>'WikiBhasha(Beta)'
 12+ 'wikiBhashaLink' => 'WikiBhasha(Beta)'
1013 );
11 -
12 -/* *** German (Deutsch) *** */
 14+
 15+/**
 16+ * German (Deutsch)
 17+ */
1318 $messages['de'] = array(
1419 'wikibhasha' => 'WikiBhasha',
1520 'wikibhasha-desc' => 'Beschreibung der Erweiterung',
16 - 'wikiBhashaLink'=>'WikiBhasha(Beta)'
 21+ 'wikiBhashaLink' => 'WikiBhasha(Beta)'
1722 );
18 -?>
\ No newline at end of file

Status & tagging log