Index: trunk/extensions/WikiBhasha/wikiBhashaExtClass.php |
— | — | @@ -1,57 +0,0 @@ |
2 | | -<?php |
3 | | -/******************************************************** |
4 | | -* * |
5 | | -* Copyright (C) Microsoft. All rights reserved. * |
6 | | -* * |
7 | | -********************************************************/ |
8 | | - |
9 | | -/* |
10 | | -Copyright (c) 2010, Microsoft |
11 | | -All rights reserved. |
12 | | -*/ |
13 | | - |
14 | | -// WikiBhasha launch Extention script. |
15 | | -// Description: this script eases the procedure to launch WikiBhasha by instrumenting |
16 | | -// wikipedia pages with links and options to launch the application. It executes the |
17 | | -// same routine as the bookmarklet and is portable across Wikipedia installations. |
18 | | -// |
19 | | -// The current functions to launch WikiBhasha: |
20 | | -// 1. Looks for "action=edit" in the URL and check if toolbar exists. if present adds a |
21 | | -// icon to the toolbar for launching WikiBhasha. |
22 | | -// 2. inserts a "WikiBhasha" option in the left side toolbox menu. |
23 | | -// 3. Looks for "wbAutoLaunch=true" in the URL and launch WikiBhasha. |
24 | | -class wikiBhashaExt { |
25 | | - private $url, $wikiBhashaUrl; |
26 | | - function __construct() { |
27 | | - global $jsPath; |
28 | | - $this->url = $jsPath; |
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);}'; |
30 | | - } |
31 | | - |
32 | | - // add wikibhasha link to the wikipedia left bar toolbar box |
33 | | - public function wikiBhashaToolbox( &$monobook ) { |
34 | | - echo "<li><a href='javascript:void(0);' style='color: rgb(0, 36, 255);' onclick='(function(){" . $this->wikiBhashaUrl . "})()' id='wbInstallLinkff'>" . wfMsg( 'wikiBhashaLink' ) . "</a></li>"; |
35 | | - return true; |
36 | | - } |
37 | | - |
38 | | - // create wikipedia edite page toolbar icon on the edit pages for wikibhasha |
39 | | - public function wbToolbarIcon( &$out, &$sk ) { |
40 | | - global $wgRequest; |
41 | | - $jsAutoLoad = ''; |
42 | | - $jsIconScript = ''; |
43 | | - if ( $wgRequest->getText( 'action' ) == 'edit' ) { |
44 | | - $imgUrl = $this->url . 'images/Square.png'; |
45 | | - $jsWBIconScript = " var wbIcon = document.createElement('a'); wbIcon.title = '" . wfMsg( 'wikiBhashaLink' ) . "';wbIcon.href='javascript:(function(){" . addslashes( $this->wikiBhashaUrl ) . "})()'; wbIcon.innerHTML = '<img src=\'" . $imgUrl . "\'>';"; |
46 | | - $jsIconScript = $jsWBIconScript . "if(document.getElementById('toolbar')){ var toolbar = document.getElementById('toolbar'); if(toolbar.firstChild) toolbar.appendChild(wbIcon);}"; |
47 | | - $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);}"; |
48 | | - |
49 | | - } |
50 | | - // if the url contain wbAutoLaunch as true launch wikibhasha |
51 | | - if ( $wgRequest->getText( 'wbAutoLaunch' ) == "true" ) { |
52 | | - $jsAutoLoad = $this->wikiBhashaUrl; |
53 | | - } |
54 | | - $out->addScript( "<script language='javascript'> window.onload = function(){" . $jsIconScript . $jsAutoLoad . "}</script>" ); |
55 | | - return true; |
56 | | - } |
57 | | -} |
58 | | - |
Index: trunk/extensions/WikiBhasha/WikiBhashaExtClass.php |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +<?php |
| 3 | +/******************************************************** |
| 4 | +* * |
| 5 | +* Copyright (C) Microsoft. All rights reserved. * |
| 6 | +* * |
| 7 | +********************************************************/ |
| 8 | + |
| 9 | +/* |
| 10 | +Copyright (c) 2010, Microsoft |
| 11 | +All rights reserved. |
| 12 | +*/ |
| 13 | + |
| 14 | +// WikiBhasha launch Extention script. |
| 15 | +// Description: this script eases the procedure to launch WikiBhasha by instrumenting |
| 16 | +// wikipedia pages with links and options to launch the application. It executes the |
| 17 | +// same routine as the bookmarklet and is portable across Wikipedia installations. |
| 18 | +// |
| 19 | +// The current functions to launch WikiBhasha: |
| 20 | +// 1. Looks for "action=edit" in the URL and check if toolbar exists. if present adds a |
| 21 | +// icon to the toolbar for launching WikiBhasha. |
| 22 | +// 2. inserts a "WikiBhasha" option in the left side toolbox menu. |
| 23 | +// 3. Looks for "wbAutoLaunch=true" in the URL and launch WikiBhasha. |
| 24 | +class wikiBhashaExt { |
| 25 | + private $url, $wikiBhashaUrl; |
| 26 | + function __construct() { |
| 27 | + global $jsPath; |
| 28 | + $this->url = $jsPath; |
| 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);}'; |
| 30 | + } |
| 31 | + |
| 32 | + // add wikibhasha link to the wikipedia left bar toolbar box |
| 33 | + public function wikiBhashaToolbox( &$monobook ) { |
| 34 | + echo "<li><a href='javascript:void(0);' style='color: rgb(0, 36, 255);' onclick='(function(){" . $this->wikiBhashaUrl . "})()' id='wbInstallLinkff'>" . wfMsg( 'wikiBhashaLink' ) . "</a></li>"; |
| 35 | + return true; |
| 36 | + } |
| 37 | + |
| 38 | + // create wikipedia edite page toolbar icon on the edit pages for wikibhasha |
| 39 | + public function wbToolbarIcon( &$out, &$sk ) { |
| 40 | + global $wgRequest; |
| 41 | + $jsAutoLoad = ''; |
| 42 | + $jsIconScript = ''; |
| 43 | + if ( $wgRequest->getText( 'action' ) == 'edit' ) { |
| 44 | + $imgUrl = $this->url . 'images/Square.png'; |
| 45 | + $jsWBIconScript = " var wbIcon = document.createElement('a'); wbIcon.title = '" . wfMsg( 'wikiBhashaLink' ) . "';wbIcon.href='javascript:(function(){" . addslashes( $this->wikiBhashaUrl ) . "})()'; wbIcon.innerHTML = '<img src=\'" . $imgUrl . "\'>';"; |
| 46 | + $jsIconScript = $jsWBIconScript . "if(document.getElementById('toolbar')){ var toolbar = document.getElementById('toolbar'); if(toolbar.firstChild) toolbar.appendChild(wbIcon);}"; |
| 47 | + $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);}"; |
| 48 | + |
| 49 | + } |
| 50 | + // if the url contain wbAutoLaunch as true launch wikibhasha |
| 51 | + if ( $wgRequest->getText( 'wbAutoLaunch' ) == "true" ) { |
| 52 | + $jsAutoLoad = $this->wikiBhashaUrl; |
| 53 | + } |
| 54 | + $out->addScript( "<script language='javascript'> window.onload = function(){" . $jsIconScript . $jsAutoLoad . "}</script>" ); |
| 55 | + return true; |
| 56 | + } |
| 57 | +} |
| 58 | + |
Property changes on: trunk/extensions/WikiBhasha/WikiBhashaExtClass.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 59 | + native |