r85471 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85470‎ | r85471 | r85472 >
Date:21:10, 5 April 2011
Author:krinkle
Status:deferred
Tags:
Comment:
Refactor sandboxes + clean op __construct()-options
* Clean up __construct() options (using $defaultOptions / array_merge instead)
* Rewrote sandboxes as a new /public_html/demo/ directory
- Using php's native show_source()
- Including a simple navigation on top
- Some basic page styling
* 'suppresserrors' no longer exists (it used to suppress warnings, notices and brackets, but was buggy)
* Introduced new 'suppressfatal' option
* Introduced new 'suppressbrackets' option
* translatewiki.net system is now live and ready to go, integrated direct link in getFooterLine()-method
* Integrated translatewiki.net TranslationStats-graph in the about-tab
* TranslateWiki -> translatewiki.net
Modified paths:
  • /trunk/tools/ToolserverI18N/TsIntuition.php (modified) (history)
  • /trunk/tools/ToolserverI18N/public_html/demo (added) (history)
  • /trunk/tools/ToolserverI18N/public_html/demo/demo1.php (added) (history)
  • /trunk/tools/ToolserverI18N/public_html/demo/demo2.php (added) (history)
  • /trunk/tools/ToolserverI18N/public_html/demo/demo3.php (added) (history)
  • /trunk/tools/ToolserverI18N/public_html/demo/demo4.php (added) (history)
  • /trunk/tools/ToolserverI18N/public_html/demo/demo5.php (added) (history)
  • /trunk/tools/ToolserverI18N/public_html/demo/demoBase.php (added) (history)
  • /trunk/tools/ToolserverI18N/public_html/index.php (modified) (history)
  • /trunk/tools/ToolserverI18N/public_html/sandbox.php (deleted) (history)
  • /trunk/tools/ToolserverI18N/public_html/sandbox1.php (deleted) (history)
  • /trunk/tools/ToolserverI18N/public_html/sandbox2.php (deleted) (history)
  • /trunk/tools/ToolserverI18N/public_html/sandbox3.php (deleted) (history)
  • /trunk/tools/ToolserverI18N/public_html/sandbox4.php (deleted) (history)

Diff [purge]

Index: trunk/tools/ToolserverI18N/TsIntuition.php
@@ -29,17 +29,17 @@
3030
3131 private $localBaseDir = __DIR__; // to be moved to p_i18n
3232
33 - private $registeredTextdomains = null;
 33+ private $registeredTextdomains;
3434
35 - private $suppresserrors = false;
36 - private $suppressnotices = true;
37 - private $stayalive = false;
38 - private $constructLang = false;
39 - private $currentTextdomain = 'general';
40 - private $useRequestParam = true;
 35+ // Construct options
 36+ private $currentTextdomain;
 37+ private $currentLanguage;
 38+ private $suppressfatal;
 39+ private $suppressnotice;
 40+ private $suppressbrackets;
 41+ private $stayalive;
 42+ private $useRequestParam;
4143
42 - private $currentLanguage = 'en';
43 -
4444 // Changing this will invalidate all cookies
4545 private $cookieNames = array(
4646 'userlang' => 'TsIntuition_userlang',
@@ -89,12 +89,13 @@
9090 * Pass a string (domain) or array (options)
9191 *
9292 * Options:
93 - * - suppresserrors
94 - * - suppressnotices
95 - * - stayalive
96 - * - globalfunctions
9793 * - lang
9894 * - domain
 95+ * - globalfunctions
 96+ * - suppressfatal
 97+ * - suppressnotice
 98+ * - suppressbrackets
 99+ * - stayalive
99100 * - param
100101 */
101102 function __construct( $options = array() ) {
@@ -103,51 +104,52 @@
104105 $options = array( 'domain' => $options );
105106 }
106107
107 - $this->loadDomains();
 108+ $defaultOptions = array(
 109+ 'domain' => 'general',
 110+ 'lang' => null,
 111+ 'globalfunctions' => true,
 112+ 'suppressfatal' => false,
 113+ 'suppressnotice' => true,
 114+ 'suppressbrackets' => false,
 115+ 'stayalive' => false,
 116+ 'param' => true,
 117+ );
 118+ $options = array_merge( $defaultOptions, $options );
 119+
 120+ $this->loadDomainRegistry();
108121
109 - // Allow a tool to suppress errors, which will prevent TsIntuition from showing fatal errors
110 - if ( isset( $options['suppresserrors'] ) && $options['suppresserrors'] == true ) {
111 - $this->suppresserrors = true;
112 - $this->suppressnotices = true;
 122+ // The textdomain of your tool can be set here.
 123+ // Otherwise defaults to 'general'. See also documentation of msg()
 124+ // First character is case-insensitive
 125+ if ( isset( $options['domain'] ) ) {
 126+ $this->setDomain( $options['domain'] );
113127 }
114128
115 - // Allow a tool to suppress errors, which will prevent TsIntuition from showing notices
116 - if ( isset( $options['suppressnotices'] ) && $options['suppressnotices'] == false ) {
117 - $this->suppressnotices = false;
 129+ // Allow a tool to disable the loading of global functions,
 130+ // in case they have a _() and/or _e() already.
 131+ if ( $options['globalfunctions'] === true ) {
 132+ //require_once( $this->localBaseDir . '/Functions.php' );
118133 }
119134
120 - // Allow a tool to prevent TsIntuition for exiting/dieing on fatal errors
121 - if ( isset( $options['stayalive'] ) && $options['stayalive'] == true ) {
122 - $this->stayalive = true;
123 - }
 135+ // Allow a tool to suppress fatals, which will prevent TsIntuition from showing fatal errors.
 136+ $this->suppressfatal = $options['suppressfatal'];
124137
125 - // Allow a tool to disable the loading of global functions in case they have a _() and/or _e() already
126 - if ( !isset( $options['globalfunctions'] ) || $options['globalfunctions'] == true ) {
127 - require_once( $this->localBaseDir . '/Functions.php' );
128 - }
 138+ // Allow a tool to suppress notices, which will prevent TsIntuition from showing notices.
 139+ $this->suppressnotice = $options['suppressnotice'];
129140
130 - // If the tool doesn't want to use the cookie and parameter or would like to test something
131 - // The user language can be overridden here. Note you can also override it for individual
132 - // messages by passing the language code as third argument to msg().
133 - if ( isset( $options['lang'] ) ) {
134 - $this->constructLang = $options['lang'];
135 - }
 141+ // Allow a tool to suppress brackets, msg() will return "Messagekey" instead of "[messagekey]"
 142+ // if this is true.
 143+ $this->suppressbrackets = $options['suppressbrackets'];
136144
137 - // The textdomain of your tool can be set here.
138 - // Otherwise defaults to 'general'. See also documentation of msg()
139 - // First character is case-insensitive
140 - if ( isset( $options['domain'] ) ) {
141 - $this->setDomain( $options['domain'] );
142 - }
 145+ // Allow a tool to prevent TsIntuition for exiting/dieing on fatal errors.
 146+ $this->stayalive = $options['stayalive'];
143147
144148 // TsIntuition will choose the language based on a cookie. However it
145149 // can be manually overriden for permalinks through a request parameter.
146150 // By default this is 'userlang'. If you need this parameter for something else
147151 // you can disable this system here. To avoid inconsistencies between tools
148152 // a custom parameter name will not be supported. It's either on or off.
149 - if ( isset( $options['param'] ) ) {
150 - $this->setUseRequestParam( false );
151 - }
 153+ $this->setUseRequestParam( $options['param'] );
152154
153155 // Load the initial text domain
154156 $this->loadTextdomain( $this->getDomain() );
@@ -158,8 +160,14 @@
159161 // Load names
160162 $this->loadNames();
161163
 164+ // A tool may override the automatic initiation with cookies and paramters
 165+ // (ie. during development). Note you can also override it for individual msg calls,
 166+ // by passing the language code as third argument to msg().
 167+ // If options['lang'] is a non-empty string, initLangSelect will use it,
 168+ // instead of it's own routine.
 169+
162170 // Initialize language choise
163 - $this->initLangSelect();
 171+ $this->initLangSelect( $options['lang'] );
164172
165173 }
166174
@@ -173,11 +181,17 @@
174182
175183 /**
176184 * Set the current language which will be used when requesting messages etc.
177 - * @return true
 185+ *
 186+ * @param $lang String of language code (lowercase). If not a valid string
 187+ * setting will stay the same and false is returned.
 188+ * @return boolean
178189 */
179190 public function setLang( $lang ) {
180 - $this->currentLanguage = $lang;
181 - return true;
 191+ if ( TsIntuitionUtil::nonEmptyStr( $lang ) ) {
 192+ $this->currentLanguage = $lang;
 193+ return true;
 194+ }
 195+ return false;
182196 }
183197
184198 /**
@@ -426,7 +440,7 @@
427441 if ( !is_null( $fail ) ) {
428442 return $fail;
429443 }
430 - if ( $this->suppresserrors ) {
 444+ if ( $this->suppressbrackets ) {
431445 return ucfirst( $key ); // Keyname
432446 }
433447 return "[$key]"; // [keyname]
@@ -450,7 +464,7 @@
451465 /**
452466 * Adds or overwrites a message in the blob.
453467 * This function is public so tools can use it while testing their tools
454 - * and don't need a message to exist in TranslateWiki yet, but don't want to see [msgkey] either.
 468+ * and don't need a message to exist in translatewiki.net yet, but don't want to see [msgkey] either.
455469 * See also addMsgs() for registering multiple messages.
456470 *
457471 * First two parameters are required. Others (domain, language) default to current environment.
@@ -795,7 +809,7 @@
796810 *
797811 * @return true
798812 */
799 - private function loadDomains(){
 813+ private function loadDomainRegistry(){
800814
801815 // Don't load twice
802816 if ( is_array( $this->registeredTextdomains ) ) {
@@ -906,9 +920,16 @@
907921 *
908922 * @param $imgSize integer (optional) Defaults to 28px.
909923 * If 0 or a non-integer the image will be hidden.
 924+ * @param $helpTranslateDomain mixed (optional)
 925+ * - null (or nothing, default): Current domain
 926+ * - true: All domains
 927+ * - string: Custom domain
 928+ * - false: Disable this message all together.
910929 * @return The HTML for the promo box.
911930 */
912 - public function getPromoBox( $imgSize = 28 ) {
 931+ public function getPromoBox( $imgSize = 28, $helpTranslateDomain = null ) {
 932+
 933+ // Logo
913934 if ( is_int( $imgSize ) && $imgSize > 0 ) {
914935 $src = 'http://upload.wikimedia.org/wikipedia/commons/thumb/b/be'
915936 . '/Wikimedia_Community_Logo-Toolserver.svg'
@@ -924,27 +945,55 @@
925946 } else {
926947 $img = '';
927948 }
 949+
 950+ // Promo message
928951 $promoMsgOpts = array(
929952 'domain' => 'tsintuition',
930953 'escape' => 'html',
931954 'raw-variables' => true,
932955 'variables' => array(
933 - '<a href="http://translatewiki.net/">TranslateWiki</a>',
 956+ '<a href="http://translatewiki.net/">translatewiki.net</a>',
934957 '<a href="http://toolserver.org/~krinkle/TsIntuition/">Toolserver Intuition</a>'
935958 ),
936959 );
937960 $powered = $this->msg( 'bl-promo', $promoMsgOpts );
938961 $change = $this->msg( 'bl-changelanguage', 'tsintuition' );
939 - return "<div id=\"tsint-promobox\"><a href=\"{$this->getDashboardReturnToUrl()}\">$img</a>"
940 - . "<p>$powered <a href=\"{$this->dashboardHome}\">$change</a></p></div>";
 962+
 963+ // Help translation
 964+ if ( $helpTranslateDomain === true ) {
 965+ $helpTranslateDomain = '0-all';
 966+ $twLinkText = $this->msg( 'help-translate-all', 'tsintuition' );
 967+ } elseif ( is_null( $helpTranslateDomain ) ) {
 968+ $helpTranslateDomain = $this->getDomain();
 969+ $twLinkText = $this->msg( 'help-translate-tool', 'tsintuition' );
 970+ } else {
 971+ $twLinkText = $this->msg( 'help-translate-tool', 'tsintuition' );
 972+ }
 973+ $helpTranslateLink = '';
 974+ if ( is_string( $helpTranslateDomain ) ) {
 975+ $helpTranslateDomain = strtolower( $helpTranslateDomain );
 976+ // https://translatewiki.net/w/i.php?language=nl&title=Special:Translate&group=tsint-0-all
 977+ $twParams = array(
 978+ 'title' => 'Special:Translate',
 979+ 'language' => $this->getLang(),
 980+ 'group' => "tsint-$helpTranslateDomain",
 981+ );
 982+ $twParams = http_build_query( $twParams );
 983+ $helpTranslateLink = TsIntuitionUtil::tag( $twLinkText, 'a', array( 'href' => "https://translatewiki.net/w/i.php?$twParams", 'title' => $this->msg( 'help-translate-tooltip', 'tsintuition' ) ) );
 984+ }
 985+
 986+ // Build output
 987+ return
 988+ "<div id=\"tsint-promobox\"><p><a href=\"{$this->getDashboardReturnToUrl()}\">$img</a> "
 989+ . "$powered {$this->dashboardBacklink()} $helpTranslateLink</p></div>";
941990 }
942991
943992 /**
944993 * Show a typical "powered by .." footer line.
945994 * Same as getPromoBox() but without the image.
946995 */
947 - public function getFooterLine(){
948 - return $this->getPromoBox( 'no-image' );
 996+ public function getFooterLine( $helpTranslateDomain = null ){
 997+ return $this->getPromoBox( 'no-image', $helpTranslateDomain );
949998 }
950999
9511000
@@ -1071,10 +1120,10 @@
10721121 *
10731122 * @return true
10741123 */
1075 - private function initLangSelect() {
 1124+ private function initLangSelect( $option ) {
10761125 $set = false;
1077 - if ( $this->constructLang ) {
1078 - $set = $this->setLang( $this->constructLang );
 1126+ if ( isset( $option ) && !empty( $option ) ) {
 1127+ $set = $this->setLang( $option );
10791128 }
10801129 if ( !$set && $this->getUseRequestParam() === true && isset( $_GET[ $this->paramNames['userlang'] ] ) ) {
10811130 $set = $this->setLang( $_GET[ $this->paramNames['userlang'] ] );
@@ -1082,6 +1131,9 @@
10831132 if ( !$set && isset( $_COOKIE[ $this->cookieNames['userlang'] ] ) ) {
10841133 $set = $this->setLang( $_COOKIE[ $this->cookieNames['userlang'] ] );
10851134 }
 1135+ if ( !$set ) {
 1136+ $set = $this->setLang( 'en' );
 1137+ }
10861138 return $set;
10871139 }
10881140
@@ -1137,10 +1189,10 @@
11381190 $code = 'Unknown error: ';
11391191 }
11401192
1141 - if ( $error && $this->suppresserrors ) {
 1193+ if ( $error && $this->suppressfatal ) {
11421194 return;
11431195 }
1144 - if ( $notice && $this->suppressnotices ) {
 1196+ if ( $notice && $this->suppressnotice ) {
11451197 return;
11461198 }
11471199
Index: trunk/tools/ToolserverI18N/public_html/sandbox.php
@@ -1,19 +0,0 @@
2 -<?php
3 -/* Load Toolserver Intuition */
4 -require_once( '/home/krinkle/TsIntuition/ToolStart.php' );
5 -
6 -
7 -// Output-header
8 -echo '<h3 style="margin: 8px 0px 5px 0px; border-bottom: 1px solid #AAA;">Output</h3>';
9 -
10 -
11 -// Source
12 -function view_source( $file ) {
13 - echo '<h3 style="margin: 8px 0px 5px 0px; border-bottom: 1px solid #AAA;">Source</h3>'
14 - . '<pre style="background: #f2f2f2; padding: 5px 8px; border: 1px solid #CCC;">'
15 - . htmlspecialchars( file_get_contents( $file ) )
16 - . '</pre>';
17 -}
18 -
19 -
20 -if(basename($_SERVER['SCRIPT_NAME'])=='sandbox.php') view_source( __FILE__ );
\ No newline at end of file
Index: trunk/tools/ToolserverI18N/public_html/sandbox1.php
@@ -1,15 +0,0 @@
2 -<?php
3 -/* Config */
4 -require_once( 'sandbox.php' );
5 -
6 -
7 -/* Demonstration */
8 -// 1) Init $I18N
9 -$I18N = new TsIntuition( 'general' /* name of textdomain here */ );
10 -
11 -// 2) Get message
12 -echo $I18N->msg( 'welcome' );
13 -
14 -
15 -/* View source */
16 -view_source( __FILE__ );
\ No newline at end of file
Index: trunk/tools/ToolserverI18N/public_html/sandbox2.php
@@ -1,24 +0,0 @@
2 -<?php
3 -/* Config */
4 -require_once( 'sandbox.php' );
5 -
6 -
7 -/* Demonstration */
8 -
9 -// 1) Init TsIntuition
10 -$options = array(
11 - 'domain' => 'tsintuition',
12 -
13 - // Show notices
14 - 'suppressnotices' => false,
15 -);
16 -$I18N = new TsIntuition( $options );
17 -
18 -// 2) Request an undefined message
19 -// Because 'suppressnotices' is false,
20 -// this will trigger a Notice: 'r4nd0mstr1n9' undefined
21 -echo $I18N->msg( 'r4nd0mstr1n9' );
22 -
23 -
24 -/* View source */
25 -view_source( __FILE__ );
\ No newline at end of file
Index: trunk/tools/ToolserverI18N/public_html/sandbox3.php
@@ -1,24 +0,0 @@
2 -<?php
3 -/* Config */
4 -require_once( 'sandbox.php' );
5 -
6 -
7 -/* Demonstration */
8 -
9 -// 1) Init TsIntuition
10 -$options = array(
11 - 'domain' => 'tsintuition',
12 -
13 - // Hide any kind of warning sign, errors, fatals and never call die
14 - 'suppresserrors' => true,
15 -);
16 -$I18N = new TsIntuition( $options );
17 -
18 -// 2) Request an undefined message
19 -// Because 'suppresserrors' is true,
20 -// this will display "R4nd0mstr1n9" instead of [r4nd0mstr1n9]
21 -echo $I18N->msg( 'r4nd0mstr1n9' );
22 -
23 -
24 -/* View source */
25 -view_source( __FILE__ );
Index: trunk/tools/ToolserverI18N/public_html/sandbox4.php
@@ -1,14 +0,0 @@
2 -<?php
3 -/* Config */
4 -require_once( 'sandbox.php' );
5 -$I18N = new TsIntuition( 'general' );
6 -
7 -
8 -/* Demonstration */
9 -echo $I18N->dashboardBacklink();
10 -echo $I18N->getPromoBox();
11 -echo $I18N->getFooterLine();
12 -
13 -
14 -/* View source */
15 -view_source( __FILE__ );
Index: trunk/tools/ToolserverI18N/public_html/demo/demo5.php
@@ -0,0 +1,16 @@
 2+<?php
 3+/* Config */
 4+require_once( 'demoBase.php' );
 5+$I18N = new TsIntuition( 'general' );
 6+
 7+
 8+/* Demonstration */
 9+echo $I18N->dashboardBacklink();
 10+echo $I18N->getPromoBox();
 11+echo $I18N->getFooterLine();
 12+echo $I18N->getFooterLine( false );
 13+echo $I18N->getFooterLine( true );
 14+
 15+/* View source */
 16+view_source( __FILE__ );
 17+close_demo();
Property changes on: trunk/tools/ToolserverI18N/public_html/demo/demo5.php
___________________________________________________________________
Added: svn:eol-style
118 + native
Index: trunk/tools/ToolserverI18N/public_html/demo/demoBase.php
@@ -0,0 +1,90 @@
 2+<?php
 3+error_reporting(E_ALL); ini_set('display_errors', 1);
 4+
 5+/* Load Toolserver Intuition from the main directory */
 6+require_once( dirname(dirname( __DIR__ )) . '/ToolStart.php' );
 7+
 8+// Known demos
 9+$demoRegistry = array(
 10+ 'demo1' => 'Basic setup to load a message',
 11+ 'demo2' => 'Undefined message (default)',
 12+ 'demo3' => 'Undefined message (notice)',
 13+ 'demo4' => 'Undefined message (no brackets)',
 14+ 'demo5' => 'Dashboard backlink and footer line',
 15+);
 16+
 17+$thisFile = basename( $_SERVER['SCRIPT_NAME'], '.php' );
 18+$thisDescr = htmlspecialchars( @$demoRegistry[$thisFile] );
 19+
 20+// HTML fragments
 21+$startHTML = <<<HTML
 22+<!DOCTYPE html>
 23+<html dir="ltr" lang="en-US">
 24+<head>
 25+ <meta charset="utf-8">
 26+ <title>Toolserver Intuition | Demonstration sandboxes | $thisFile: $thisDescr</title>
 27+ <style>
 28+ /* Demo framework */
 29+ body {
 30+ font-family: sans-serif;
 31+ }
 32+ img {
 33+ vertical-align: middle;
 34+ }
 35+ h3 {
 36+ clear: both;
 37+ margin: 10px 0px;
 38+ border-bottom: 1px solid #AAA;
 39+ }
 40+ pre {
 41+ background: #F9F9F9;
 42+ padding: 5px 8px;
 43+ border: 1px solid #CCC;
 44+ }
 45+ ul {
 46+ color: #777777;
 47+ list-style: none;
 48+ }
 49+ ul li {
 50+ background: #F9F9F9;
 51+ display: inline;
 52+ float: left;
 53+ padding: 3px 2px;
 54+ margin: 0px 2px;
 55+ }
 56+ /* Example */
 57+ #tsint-promobox { background: #F9F9F9; padding: 5px 8px; margin: 10px; }
 58+ </style>
 59+</head>
 60+<body>
 61+HTML;
 62+$outputHead = '<h3>Output</h3>';
 63+
 64+
 65+// Start output
 66+header( 'Content-Type: text/html; charset=utf-8' );
 67+echo $startHTML . '<ul>';
 68+foreach ( $demoRegistry as $demoFilename => $descr ) {
 69+ $descr = htmlspecialchars( $descr );
 70+ echo "<li><a href=\"$demoFilename.php\" title=\"$descr\">$demoFilename</a><br /><small>$descr</small></a></li>";
 71+}
 72+echo "</ul>$outputHead";
 73+
 74+
 75+// Output source-heading and source code
 76+function view_source( $file ) {
 77+ echo '<h3>Source</h3>'
 78+ . '<pre>'
 79+ . show_source( $file, true )
 80+ . '</pre>';
 81+}
 82+
 83+// End of track
 84+function close_demo(){
 85+ echo '</body></html>';
 86+}
 87+
 88+// Make this file viewable as well
 89+if( $thisFile == 'demoBase' ){
 90+ view_source( __FILE__ );
 91+}
\ No newline at end of file
Property changes on: trunk/tools/ToolserverI18N/public_html/demo/demoBase.php
___________________________________________________________________
Added: svn:eol-style
192 + native
Index: trunk/tools/ToolserverI18N/public_html/demo/demo1.php
@@ -0,0 +1,15 @@
 2+<?php
 3+/* Config */
 4+require_once( 'demoBase.php' );
 5+
 6+/* Demonstration */
 7+// 1) Init $I18N
 8+$I18N = new TsIntuition( 'general' /* name of textdomain here */ );
 9+
 10+// 2) Get message
 11+echo $I18N->msg( 'welcome' );
 12+
 13+
 14+/* View source */
 15+view_source( __FILE__ );
 16+close_demo();
\ No newline at end of file
Property changes on: trunk/tools/ToolserverI18N/public_html/demo/demo1.php
___________________________________________________________________
Added: svn:eol-style
117 + native
Index: trunk/tools/ToolserverI18N/public_html/demo/demo2.php
@@ -0,0 +1,22 @@
 2+<?php
 3+/* Config */
 4+require_once( 'demoBase.php' );
 5+
 6+
 7+/* Demonstration */
 8+
 9+// 1) Init TsIntuition
 10+$options = array(
 11+ 'domain' => 'tsintuition',
 12+);
 13+$I18N = new TsIntuition( $options );
 14+
 15+// 2) Request an undefined message
 16+// Because 'suppressnotices' is true (default),
 17+// this won't trigger a Notice, and show a bracket msg: '[r4nd0mstr1n9]'
 18+echo $I18N->msg( 'r4nd0mstr1n9' );
 19+
 20+
 21+/* View source */
 22+view_source( __FILE__ );
 23+close_demo();
\ No newline at end of file
Property changes on: trunk/tools/ToolserverI18N/public_html/demo/demo2.php
___________________________________________________________________
Added: svn:eol-style
124 + native
Index: trunk/tools/ToolserverI18N/public_html/demo/demo3.php
@@ -0,0 +1,25 @@
 2+<?php
 3+/* Config */
 4+require_once( 'demoBase.php' );
 5+
 6+
 7+/* Demonstration */
 8+
 9+// 1) Init TsIntuition
 10+$options = array(
 11+ 'domain' => 'tsintuition',
 12+
 13+ // Show notices
 14+ 'suppressnotice' => false,
 15+);
 16+$I18N = new TsIntuition( $options );
 17+
 18+// 2) Request an undefined message
 19+// Because 'suppressnotices' is false,
 20+// this will trigger a Notice: 'r4nd0mstr1n9' undefined
 21+echo $I18N->msg( 'r4nd0mstr1n9' );
 22+
 23+
 24+/* View source */
 25+view_source( __FILE__ );
 26+close_demo();
\ No newline at end of file
Property changes on: trunk/tools/ToolserverI18N/public_html/demo/demo3.php
___________________________________________________________________
Added: svn:eol-style
127 + native
Index: trunk/tools/ToolserverI18N/public_html/demo/demo4.php
@@ -0,0 +1,25 @@
 2+<?php
 3+/* Config */
 4+require_once( 'demoBase.php' );
 5+
 6+
 7+/* Demonstration */
 8+
 9+// 1) Init TsIntuition
 10+$options = array(
 11+ 'domain' => 'tsintuition',
 12+
 13+ // Hide any sign of an undefined message to the end-user
 14+ 'suppressbrackets' => true,
 15+);
 16+$I18N = new TsIntuition( $options );
 17+
 18+// 2) Request an undefined message
 19+// Because 'suppressbrackets' is true,
 20+// this will display "R4nd0mstr1n9" instead of [r4nd0mstr1n9]
 21+echo $I18N->msg( 'r4nd0mstr1n9' );
 22+
 23+
 24+/* View source */
 25+view_source( __FILE__ );
 26+close_demo();
Property changes on: trunk/tools/ToolserverI18N/public_html/demo/demo4.php
___________________________________________________________________
Added: svn:eol-style
127 + native
Index: trunk/tools/ToolserverI18N/public_html/index.php
@@ -245,8 +245,13 @@
246246 // About tab
247247 $about = '<div id="tab-about">'
248248 . 'Technical documentation: <a href="https://wiki.toolserver.org/view/Toolserver_Intuition">https://wiki.toolserver.org/view/Toolserver_Intuition</a>'
249 - . '<div class="tab-paragraph-head">' . _( 'usage' ) . '</div><ul>';
250 -
 249+ . '<div class="tab-paragraph-head">' . _( 'usage' ) . '</div>';
 250+
 251+$about .= '<div class="aligncenter"><a href="http://translatewiki.net/wiki/Translating:Toolserver">'
 252+ . '<img src="http://translatewiki.net/w/i.php?title=Special:TranslationStats&'
 253+ . 'graphit=1&width=600&height=400&group=tsint-0-all" width="600" height="400" alt="" />'
 254+ . '</a></div>';
 255+$about .= '<ul>';
251256 foreach ( $I18N->getAllRegisteredDomains() as $domainKey => $domainFile ) {
252257 $domainInfo = $I18N->getDomainInfo( $domainKey );
253258 $title = $I18N->msg( 'title', $domainKey, /* fallback = */ $domainKey );

Follow-up revisions

RevisionCommit summaryAuthorDate
r85472FU r85471: fix commentkrinkle21:12, 5 April 2011

Status & tagging log