r85289 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85288‎ | r85289 | r85290 >
Date:22:20, 3 April 2011
Author:krinkle
Status:deferred
Tags:
Comment:
adding support for MonumentsAPI (for real this time) - on ignore for now for TranslateWiki. + more blacklink/dashboard/ implementation (FU r85270)
Modified paths:
  • /trunk/tools/ToolserverI18N/TsIntuition.php (modified) (history)
  • /trunk/tools/ToolserverI18N/TsIntuitionUtil.php (modified) (history)
  • /trunk/tools/ToolserverI18N/language/Fallbacks.php (modified) (history)
  • /trunk/tools/ToolserverI18N/language/messages/Monumentsapi.i18n.php (added) (history)
  • /trunk/tools/ToolserverI18N/language/messages/Tsintuition.i18n.php (modified) (history)
  • /trunk/tools/ToolserverI18N/public_html/index.php (modified) (history)

Diff [purge]

Index: trunk/tools/ToolserverI18N/TsIntuition.php
@@ -30,9 +30,10 @@
3131 private $localBaseDir = __DIR__; // to be moved to p_i18n
3232
3333 private static $registeredTextdomains = array(
34 - 'general' => array( 'file' => 'General.i18n.php' ),
 34+ 'General' => array( 'file' => 'General.i18n.php' ),
3535 'Getwikiapi' => array( 'file' => 'Getwikiapi.i18n.php' ),
3636 'Jarry' => array( 'file' => 'Jarry.i18n.php' ),
 37+ 'Monumentsapi' => array( 'file' => 'Monumentsapi.i18n.php' ),
3738 'Orphantalk2' => array( 'file' => 'Orphantalk2.i18n.php' ),
3839 'Svgtranslate' => array( 'file' => 'Svgtranslate.i18n.php' ),
3940 'Tsintuition' => array( 'file' => 'Tsintuition.i18n.php' ),
@@ -558,12 +559,12 @@
559560 $domain = ucfirst( strtolower( $domain ) );
560561
561562 // Already loaded ?
562 - if ( in_array( $domain, $this->loadedTextdomains ) ) {
 563+ if ( in_array( $domain, $this->loadedTextdomains ) || !isset( self::$registeredTextdomains[$domain] ) ) {
563564 return false;
564565 }
565566
566567 // File exists ?
567 - $path = $this->localBaseDir . "/language/messages/" . $this->registeredTextdomains[$domain]['file'];
 568+ $path = $this->localBaseDir . "/language/messages/" . self::$registeredTextdomains[$domain]['file'];
568569 if ( !file_exists( $path ) ) {
569570 $this->errTrigger( "Textdomain file not found for \"$domain\" at $path. Ignoring", __METHOD__, E_NOTICE, __FILE__, __LINE__ );
570571 return false;
@@ -788,9 +789,9 @@
789790 }
790791
791792
792 -
793793 /* Output promo and dashboard backlinks
794794 * ------------------------------------------------- */
 795+
795796 /**
796797 * Show a link that explains that this tool has been
797798 * localized via Toolserver Intuition and that they
@@ -805,30 +806,60 @@
806807 } else {
807808 $text = $this->msg( 'bl-mysettings-new', 'tsintuition' );
808809 }
809 - $p = array(
810 - 'returnto' => $_SERVER['SCRIPT_NAME'],
811 - 'returntoquery' => http_build_query( $_GET ),
812 - );
813 - $p = http_build_query( $p );
814 - return kfTag(
 810+ return '<span class="tsint-dashboardbacklink">' . TsIntuitionUtil::tag(
815811 $text,
816812 'a',
817813 array(
818 - 'href' => "{$this->dashboardHome}?$p",
 814+ 'href' => $this->getDashboardReturnToUrl(),
819815 'title' => $this->msg( 'bl-changelanguage', 'tsintuition' ),
820816 )
821 - );
 817+ ) . '</span>';
822818 }
823819
824 - public function showPromo(){
825 - // http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Wikimedia_Community_Logo-Toolserver.svg/21px-Wikimedia_Community_Logo-Toolserver.svg.png
 820+ /**
 821+ * Show a promobox on the bottom of your tool.
 822+ *
 823+ * @param $imgSize integer (optional) Defaults to 28px.
 824+ * If 0 or a non-integer the image will be hidden.
 825+ * @return The HTML for the promo box.
 826+ */
 827+ public function getPromoBox( $imgSize = 28 ) {
 828+ if ( is_int( $imgSize ) && $imgSize > 0 ) {
 829+ $src = 'http://upload.wikimedia.org/wikipedia/commons/thumb/b/be'
 830+ . '/Wikimedia_Community_Logo-Toolserver.svg'
 831+ . "/{$imgSize}px-Wikimedia_Community_Logo-Toolserver.svg.png";
 832+ $img = TsIntuitionUtil::tag( '', 'img', array(
 833+ 'src' => $src,
 834+ 'width' => $imgSize,
 835+ 'height' => $imgSize,
 836+ 'alt' => '',
 837+ 'title' => '',
 838+ 'class' => 'tsint-logo',
 839+ ) );
 840+ } else {
 841+ $img = '';
 842+ }
 843+ $promoMsgOpts = array(
 844+ 'domain' => 'tsintuition',
 845+ 'escape' => 'html',
 846+ 'raw-variables' => true,
 847+ 'variables' => array(
 848+ '<a href="http://translatewiki.net/">TranslateWiki</a>',
 849+ '<a href="http://toolserver.org/~krinkle/TsIntuition/">Toolserver Intuition</a>'
 850+ ),
 851+ );
 852+ $powered = $this->msg( 'bl-promo', $promoMsgOpts );
 853+ $change = $this->msg( 'bl-changelanguage', 'tsintuition' );
 854+ return "<div id=\"tsint-promobox\"><a href=\"{$this->getDashboardReturnToUrl()}\">$img</a><p>$powered <a href=\"{$this->dashboardHome}\">$change</a></p></div>";
826855
827 - // bl-promo
828 - // bl-changelanguage
829 - return '';
 856+ // bl-promo, bl-changelanguage
830857 }
831858
 859+ public function getFooterLine(){
 860+ return $this->getPromoBox( 'no-image' );
 861+ }
832862
 863+
833864 /* Other functions
834865 * ------------------------------------------------- */
835866
@@ -866,6 +897,26 @@
867898 }
868899
869900 /**
 901+ * Build a permalink to the dashboard with a returnto query
 902+ * to return to the current page. To be used in other tools.
 903+ *
 904+ * @example:
 905+ * Location: http://toolserver.org/~foo/JohnDoe.php?wiki=loremwiki_p
 906+ * HTML:
 907+ * '<p>Change the settings <a href="' . $I18N->getDashboardReturnToUrl() . '">here</a>';
 908+ *
 909+ *
 910+ */
 911+ public function getDashboardReturnToUrl() {
 912+ $p = array(
 913+ 'returnto' => $_SERVER['SCRIPT_NAME'],
 914+ 'returntoquery' => http_build_query( $_GET ),
 915+ );
 916+ $p = http_build_query( $p );
 917+ return "{$this->dashboardHome}?$p";
 918+ }
 919+
 920+ /**
870921 * Get a localized date. Pass a format, time or both.
871922 * Defaults to the current timestamp in the language's default date format.
872923 *
Index: trunk/tools/ToolserverI18N/public_html/index.php
@@ -109,7 +109,7 @@
110110 $returnTo = $kgReq->getVal( 'returnto' );
111111 $returnToQuery = $kgReq->getVal( 'returntoquery' );
112112 if ( TsIntuitionUtil::nonEmptyStr( $returnTo ) ) {
113 - if ( !TsIntuitionUtil::nonEmptyStr( $returnToQuery ) ) {
 113+ if ( TsIntuitionUtil::nonEmptyStr( $returnToQuery ) ) {
114114 $returnToQuery = '?' . urldecode( $returnToQuery );
115115 } else {
116116 $returnToQuery = '';
Index: trunk/tools/ToolserverI18N/language/messages/Monumentsapi.i18n.php
@@ -0,0 +1,36 @@
 2+<?php
 3+/**
 4+ * Interface messages for tool "MonumentsAPI".
 5+ *
 6+ * @toolowner p_erfgoed
 7+ */
 8+
 9+$url = '~erfgoed/api/';
 10+
 11+/**
 12+ * English
 13+ *
 14+ * @author Multichill
 15+ */
 16+$messages['en'] = array(
 17+ 'title' => 'Monuments API', // Do not translate
 18+ 'search-table-th-field' => 'Field',
 19+);
 20+
 21+/**
 22+ * Documentation
 23+ *
 24+ * @author Krinkle
 25+ */
 26+$messages['qqq'] = array(
 27+ 'title' => "{{Notranslate}}\n\nThe title of the tool.",
 28+);
 29+
 30+/**
 31+ * Nederlands
 32+ *
 33+ * @author Krinkle
 34+ */
 35+$messages['nl'] = array(
 36+ 'search-table-th-field' => 'Veld',
 37+);
Property changes on: trunk/tools/ToolserverI18N/language/messages/Monumentsapi.i18n.php
___________________________________________________________________
Added: svn:eol-style
138 + native
Index: trunk/tools/ToolserverI18N/language/messages/Tsintuition.i18n.php
@@ -64,6 +64,7 @@
6565 'renewcookies-success' => 'Cookies vernieuwd! Je bent weer helemaal gereed voor de komende $1.',
6666 'tab-overview' => 'Overzicht',
6767 'tab-settings' => 'Verander instellingen',
 68+ 'bl-mysettings' => 'Mijn taalinstellingen',
6869 );
6970
7071 /**
Index: trunk/tools/ToolserverI18N/language/Fallbacks.php
@@ -20,4 +20,6 @@
2121 'fy' => 'nl',
2222
2323 'nds' => 'de',
 24+
 25+ 'os' => 'ru',
2426 );
Index: trunk/tools/ToolserverI18N/TsIntuitionUtil.php
@@ -90,4 +90,36 @@
9191 return $dump;
9292 }
9393
 94+
 95+ /* Primitive html building */
 96+ /* Based on kfTag from the BaseTool class */
 97+ function tag( $str, $wrapTag = 0, $attributes = array() ) {
 98+ $selfclose = array( 'link', 'input', 'br', 'img' );
 99+
 100+ if ( is_string( $str ) ) {
 101+ if ( is_string( $wrapTag ) ) {
 102+ $wrapTag = trim( strtolower( $wrapTag ) );
 103+ $attrString = '';
 104+ if ( is_array ( $attributes ) ) {
 105+ foreach ( $attributes as $attrKey => $attrVal ) {
 106+ $attrKey = htmlspecialchars( trim( strtolower( $attrKey ) ), ENT_QUOTES);
 107+ $attrVal = htmlspecialchars( trim( $attrVal ), ENT_QUOTES);
 108+ $attrString .= " $attrKey=\"$attrVal\"";
 109+ }
 110+ }
 111+ $return = "<$wrapTag$attrString";
 112+ if ( in_array( $wrapTag, $selfclose ) ) {
 113+ $return .= '/>';
 114+ } else {
 115+ $return .= ">" . htmlspecialchars( $str ) ."</$wrapTag>";
 116+ }
 117+ } else {
 118+ $return = $str;
 119+ }
 120+ return $return;
 121+ } else {
 122+ return '';
 123+ }
 124+ }
 125+
94126 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85270begin of backlink and returnto implementationkrinkle19:39, 3 April 2011

Status & tagging log