jenkins-bot has submitted this change and it was merged.
Change subject: Re-factor toolbox
......................................................................
Re-factor toolbox
Done in order to reuse common components and use existing i18n
messages.
Also:
* added a few new i18n messages
* repaired the pussle message
* fixed incorrect path in css
Change-Id: I4f8a7292f0d8668c53fcdb06b022cc8c1558223a
---
M i18n/en.json
M i18n/qqq.json
M toolbox/css/default_css.css
M toolbox/index.php
M toolbox/search.php
M toolbox/statistics.php
A toolbox/toolbox.php
7 files changed, 120 insertions(+), 132 deletions(-)
Approvals:
Jean-Frédéric: Looks good to me, approved
jenkins-bot: Verified
diff --git a/i18n/en.json b/i18n/en.json
index 6ea22d4..75887b4 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -49,13 +49,15 @@
"db-field-st_total": "Total number",
"toolbox-label-searchtipps": "use %term or term% or %term% for fuzzy
search",
"toolbox-meta-title": "Wiki Loves Monuments Toolbox",
+ "toolbox-main-logo-alt": "Wiki Loves Monuments logo",
"toolbox-main-title": "WLM Toolbox",
- "toolbox-main-description": "A set of tools related to",
+ "toolbox-main-description": "A set of tools related to $1",
"toolbox-wikilovesmonuments": "Wiki Loves Monuments",
"toolbox-nav-homepage": "Homepage",
"toolbox-nav-statistics": "Statistics",
"toolbox-nav-search": "Search",
"toolbox-title-searchmonuments": "Search monuments",
+ "toolbox-title-statistics": "Monument statistics",
"location": "Location",
"source-monuments-list": "Source monuments list on a Wikimedia project"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index dadef5d..4bf4d11 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -59,13 +59,15 @@
"db-field-st_total": "{{Identical|Total number}}",
"toolbox-label-searchtipps": "Instruction for how to perform a fuzzy
search.",
"toolbox-meta-title": "Title used in the metadata header of the page.",
+ "toolbox-main-logo-alt": "Alt text for Wiki Loves Monuments logo.",
"toolbox-main-title": "Page header used in the top of every page of the
toolbox.",
- "toolbox-main-description": "Description of the toolbox, part 1.",
- "toolbox-wikilovesmonuments": "Description of the toolbox, part 2.",
+ "toolbox-main-description": "Description of the toolbox.\nParameter:
{{Msg-intuition|Monumentsapi-toolbox-wikilovesmonuments}}",
+ "toolbox-wikilovesmonuments": "The name of the competition.",
"toolbox-nav-homepage": "{{Identical|Homepage}}",
"toolbox-nav-statistics": "{{Identical|Statistics}}",
"toolbox-nav-search": "{{Identical|Search}}",
- "toolbox-title-searchmonuments": "Title used in the top of the search
page.",
+ "toolbox-title-searchmonuments": "Title used in the top of the toolbox
search page.",
+ "toolbox-title-statistics": "Title used in the top of the toolbox
statistics page.",
"location": "{{Identical|Location}}",
"source-monuments-list": "Link text for the \"source\" link. The link
goes to the list on a Wikimedia project from which the data was imported."
}
diff --git a/toolbox/css/default_css.css b/toolbox/css/default_css.css
index f449465..3b290a9 100644
--- a/toolbox/css/default_css.css
+++ b/toolbox/css/default_css.css
@@ -115,7 +115,7 @@
*/
body {
background-color: #fff;
- background-image: url(/theme/images/bg_stripes.png);
+ background-image: url(../img/bg_stripes.png);
background-repeat: repeat;
height: 100%;
}
diff --git a/toolbox/index.php b/toolbox/index.php
index 1e9542c..af1786e 100644
--- a/toolbox/index.php
+++ b/toolbox/index.php
@@ -1,40 +1,14 @@
<?php
+require_once ( 'toolbox.php' );
-require_once ( dirname( __DIR__ ) . '/api/common.php' );
+$toolboxPage = new ToolboxPage( $I18N );
+echo $toolboxPage->getPageIntro();
+?>
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<div id="content">
+ <h2>Home</h2>
+ <p>this is only a starting point</p>
+</div><!-- end content -->
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Wiki Loves Monuments Toolbox</title>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="css/default_css.css" />
- <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"/>
-</head>
-<body>
- <div id="wrapper">
- <div id="header">
- <a href="#"><img id="wlm-logo"
src="img/logo-wiki-loves-monuments.png" width="80" alt="Wiki loves monuments
logo" /></a>
- <h2>Wlm Toolbox</h2>
- <h1>A set of tools related to <span>Wiki Loves
Monuments</span></span></h1>
- </div><!-- end header -->
- <div id="maincontainer">
- <div id="leftnav">
- <ul class="first">
- <li><a href="#">Home</a>
- <ul>
- <li><a href="statistics.php">Statistics</a></li>
- <li><a href="search.php">Search Form</a></li>
- </ul>
- </li>
- </ul>
- </div><!-- end leftnav-->
- <div id="content">
- <h2>Home</h2>
- <p>this is only a starting point</p>
- </div><!-- end content -->
- </div><!-- end maincontainer -->
- <br style="clear:left;" />
- </div> <!-- end wrapper -->
-</body>
-</html>
+<?php
+echo $toolboxPage->getPageOutro();
diff --git a/toolbox/search.php b/toolbox/search.php
index ad11330..7965570 100644
--- a/toolbox/search.php
+++ b/toolbox/search.php
@@ -1,51 +1,14 @@
<?php
+require_once ( 'toolbox.php' );
-require_once ( dirname( __DIR__ ) . '/api/common.php' );
-
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Wiki Loves Monuments Toolbox</title>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="css/default_css.css" />
- <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"/>
- <script src="js/jquery.js" type="text/javascript" />
-
- </script>
- </head>
-<body>
- <div id="wrapper">
-
- <div id="header">
-
-
- <a href="#"><img id="wlm-logo"
src="img/logo-wiki-loves-monuments.png" width="80" alt="Wiki loves monuments
logo" /></a>
- <h2>Wlm Toolbox</h2>
- <h1>A set of tools related to <span>Wiki Loves
Monuments</span></span></h1>
-
- </div><!-- end header -->
-
- <div id="maincontainer">
-
-
-
-<div id="leftnav">
- <ul class="first">
- <li><a href="index.php">Home</a>
- <ul>
- <li><a href="statistics.php">Statistics</a></li>
- <li><a href="search.php">Search Form</a></li>
- </ul>
- </li>
- </ul>
-
-</div><!-- end leftnav-->
+$toolboxPage = new ToolboxPage( $I18N );
+echo $toolboxPage->getPageIntro();
+?>
<div id="content">
-<h2>Search Monuments</h2>
+<h2><?php echo _( 'toolbox-title-searchmonuments' ) ?></h2>
<form method="get" action="https://tools.wmflabs.org/heritage/api/api.php">
<input type="hidden" name="action" value="search" />
<input type="hidden" name="limit" value="100" />
@@ -219,12 +182,6 @@
displayVals();
</script>
</div><!-- end content -->
-</div><!-- end maincontainer -->
-
-<br style="clear:left;" />
- </div> <!-- end wrapper -->
-
-</body>
-</html>
-
+<?php
+echo $toolboxPage->getPageOutro();
diff --git a/toolbox/statistics.php b/toolbox/statistics.php
index 5b293e5..1f955a4 100644
--- a/toolbox/statistics.php
+++ b/toolbox/statistics.php
@@ -1,40 +1,14 @@
<?php
+require_once ( 'toolbox.php' );
-require_once ( dirname( __DIR__ ) . '/api/common.php' );
-
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Wiki Loves Monuments Toolbox</title>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="css/default_css.css" />
- <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"/>
-</head>
-<body>
- <div id="wrapper">
- <div id="header">
- <a href="#"><img id="wlm-logo"
src="img/logo-wiki-loves-monuments.png" width="80" alt="Wiki loves monuments
logo" /></a>
- <h2>Wlm Toolbox</h2>
- <h1>A set of tools related to <span>Wiki Loves
Monuments</span></span></h1>
- </div><!-- end header -->
- <div id="maincontainer">
- <div id="leftnav">
- <ul class="first">
- <li><a href="index.php">Home</a>
- <ul>
- <li><a href="statistics.php">Statistics</a></li>
- <li><a href="search.php">Search Form</a></li>
- </ul>
- </li>
- </ul>
-
-</div><!-- end leftnav-->
+$toolboxPage = new ToolboxPage( $I18N );
+echo $toolboxPage->getPageIntro();
+?>
<div id="content">
-<h2>Statistics</h2>
+<h2><?php echo _( 'toolbox-title-statistics' ) ?></h2>
<form method="get" action="https://tools.wmflabs.org/heritage/api/api.php">
<input type="hidden" name="action" value="statistics" />
<input type="hidden" name="format" value="html" />
@@ -122,14 +96,6 @@
</form>
</div><!-- end content -->
-</div><!-- end maincontainer -->
-
-<br style="clear:left;" />
- </div> <!-- end wrapper -->
-
-
-
-</body>
-</html>
-
+<?php
+echo $toolboxPage->getPageOutro();
diff --git a/toolbox/toolbox.php b/toolbox/toolbox.php
new file mode 100644
index 0000000..25c17b8
--- /dev/null
+++ b/toolbox/toolbox.php
@@ -0,0 +1,87 @@
+<?php
+
+require_once ( dirname( __DIR__ ) . '/api/common.php' );
+
+class ToolboxPage {
+ private $I18N = null;
+
+ function __construct( $I18N ) {
+ $this->I18N = $I18N;
+ }
+
+ public function getIndexPage() {
+ return $this->getPage( $this->getIndexBody() );
+ }
+
+ public function getPageIntro() {
+ $result = [];
+ $result[] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" ' .
+
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ $result[] = '<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="' .
+ $this->I18N->getLang() . '" lang="' .
+ $this->I18N->getLang() . '">';
+ $result = array_merge( $result, $this->getHead() );
+ $result[] = '<body>';
+ $result[] = ' <div id="wrapper">';
+ $result[] = ' <div id="header">';
+ $result = array_merge( $result, $this->getBodyHeader() );
+ $result[] = ' <div id="maincontainer">';
+ $result = array_merge( $result, $this->getLeftNav() );
+
+ return implode( "\n", $result );
+ }
+
+ public function getPageOutro() {
+ $result = [];
+ $result[] = ' </div><!-- end maincontainer -->';
+ $result[] = ' <br style="clear:left;" />';
+ $result[] = ' <hr/>';
+ $result[] = $this->I18N->getPromoBox();
+ $result[] = ' </div> <!-- end wrapper -->';
+ $result[] = '</body>';
+ $result[] = '</html>';
+
+ return implode( "\n", $result );
+ }
+ public function getHead() {
+ $result = [];
+ $result[] = '<head>';
+ $result[] = ' <title>'. _( 'toolbox-meta-title' ) .'</title>';
+ $result[] = ' <meta http-equiv="content-type"
content="text/html; charset=utf-8">';
+ $result[] = ' <link rel="stylesheet" type="text/css"
href="css/default_css.css" />';
+ $result[] = ' <link rel="shortcut icon" href="img/favicon.ico"
type="image/x-icon"/>';
+ $result[] = ' <script src="js/jquery.js"
type="text/javascript" /></script>';
+ $result[] = '</head>';
+ return $result;
+ }
+
+ public function getLeftNav() {
+ $result = [];
+ $result[] = ' <div id="leftnav">';
+ $result[] = ' <ul class="first">';
+ $result[] = ' <li><a href="index.php">'. _(
'toolbox-nav-homepage' ) .'</a>';
+ $result[] = ' <ul>';
+ $result[] = ' <li><a href="statistics.php">'. _(
'toolbox-nav-statistics' ) .'</a></li>';
+ $result[] = ' <li><a href="search.php">'. _(
'toolbox-nav-search' ) .'</a></li>';
+ $result[] = ' </ul>';
+ $result[] = ' </li>';
+ $result[] = ' </ul>';
+ $result[] = ' </div><!-- end leftnav-->';
+ return $result;
+ }
+
+ public function getBodyHeader() {
+ $result = [];
+ $result[] = ' <div id="header">';
+ $result[] = ' <a href="#"><img id="wlm-logo"
src="img/logo-wiki-loves-monuments.png" width="80" alt="'. _(
'toolbox-main-logo-alt' ) .'" /></a>';
+ $result[] = ' <h2>'. _( 'toolbox-main-title' ) .'</h2>';
+ $wlm = [
+ 'variables' => [
+ '<span>' . _( 'toolbox-wikilovesmonuments' ) .
'</span>' ]
+ ];
+ $result[] = ' <h1>'. _( 'toolbox-main-description', $wlm )
.'</h1>';
+ $result[] = ' </div><!-- end header -->';
+ return $result;
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/297193
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4f8a7292f0d8668c53fcdb06b022cc8c1558223a
Gerrit-PatchSet: 3
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <[email protected]>
Gerrit-Reviewer: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits