Kipcool has submitted this change and it was merged.
Change subject: Added an icon to switch language filtering on/off for Vector
skin only.
......................................................................
Added an icon to switch language filtering on/off
for Vector skin only.
Change-Id: Ia1c056bd1e51355ae3da254ad0e0f3ea2397b1c1
---
M App.php
A Images/all_lang.png
A Images/my_lang.png
M OmegaWiki/ViewInformation.php
M OmegaWiki/resources/tables.css
M Wikidata.hooks.php
6 files changed, 71 insertions(+), 13 deletions(-)
Approvals:
Kipcool: Verified; Looks good to me, approved
diff --git a/App.php b/App.php
index 7584905..49dd060 100644
--- a/App.php
+++ b/App.php
@@ -68,7 +68,7 @@
'scripts' => 'OmegaWiki/resources/suggest.js'
);
-$wgAutoloadClasses['WikidataHooks'] = $dir . 'Wikidata.hooks.php';
+$wgAutoloadClasses['WikiLexicalDataHooks'] = $dir . 'Wikidata.hooks.php';
$wgAutoloadClasses['WikidataArticle' ] = $dir .
'includes/WikidataArticle.php';
$wgAutoloadClasses['WikidataEditPage' ] = $dir .
'includes/WikidataEditPage.php';
@@ -178,15 +178,16 @@
#
## Hooks
#
-$wgHooks['BeforePageDisplay'][] = 'WikidataHooks::onBeforePageDisplay';
-$wgHooks['GetPreferences'][] = 'WikidataHooks::onGetPreferences';
-$wgHooks['ArticleFromTitle'][] = 'WikidataHooks::onArticleFromTitle';
-$wgHooks['CustomEditor'][] = 'WikidataHooks::onCustomEditor';
-$wgHooks['MediaWikiPerformAction'][] =
'WikidataHooks::onMediaWikiPerformAction';
-$wgHooks['AbortMove'][] = 'WikidataHooks::onAbortMove';
-$wgHooks['NamespaceIsMovable'][] = 'WikidataHooks::onNamespaceIsMovable';
-$wgHooks['SpecialSearchNogomatch'][] = 'WikidataHooks::onNoGoMatchHook';
-$wgHooks['SearchGetNearMatchBefore'][] = 'WikidataHooks::onGoClicked';
+$wgHooks['BeforePageDisplay'][] = 'WikiLexicalDataHooks::onBeforePageDisplay';
+$wgHooks['GetPreferences'][] = 'WikiLexicalDataHooks::onGetPreferences';
+$wgHooks['ArticleFromTitle'][] = 'WikiLexicalDataHooks::onArticleFromTitle';
+$wgHooks['CustomEditor'][] = 'WikiLexicalDataHooks::onCustomEditor';
+$wgHooks['MediaWikiPerformAction'][] =
'WikiLexicalDataHooks::onMediaWikiPerformAction';
+$wgHooks['AbortMove'][] = 'WikiLexicalDataHooks::onAbortMove';
+$wgHooks['NamespaceIsMovable'][] =
'WikiLexicalDataHooks::onNamespaceIsMovable';
+$wgHooks['SpecialSearchNogomatch'][] = 'WikiLexicalDataHooks::onNoGoMatchHook';
+$wgHooks['SearchGetNearMatchBefore'][] = 'WikiLexicalDataHooks::onGoClicked';
+$wgHooks['SkinTemplateNavigation'][] =
'WikiLexicalDataHooks::onSkinTemplateNavigation';
// LocalApp.php is optional. Its function is like LocalSettings.php,
// if you want to separate the MediaWiki configuration from the Wikidata
configuration
diff --git a/Images/all_lang.png b/Images/all_lang.png
new file mode 100644
index 0000000..6adcd8e
--- /dev/null
+++ b/Images/all_lang.png
Binary files differ
diff --git a/Images/my_lang.png b/Images/my_lang.png
new file mode 100644
index 0000000..2783be2
--- /dev/null
+++ b/Images/my_lang.png
Binary files differ
diff --git a/OmegaWiki/ViewInformation.php b/OmegaWiki/ViewInformation.php
index 6c2685d..e433ae9 100644
--- a/OmegaWiki/ViewInformation.php
+++ b/OmegaWiki/ViewInformation.php
@@ -45,6 +45,17 @@
$this->propertyToColumnFilters = array();
$this->viewOrEdit = "view";
+ // check if language filtering is changed from the url
+ // and modify the user options accordingly. Cf.
onSkinTemplateNavigation hook
+ $langFilterRequest = $wgRequest->getVal( 'langfilter' );
+ if ( $langFilterRequest == "on" ) {
+ $wgUser->setOption ( 'ow_language_filter', true );
+ $wgUser->saveSettings();
+ } elseif ( $langFilterRequest == "off" ) {
+ $wgUser->setOption ( 'ow_language_filter', false );
+ $wgUser->saveSettings();
+ }
+
// set filterLanguageList according to the user preferences
if ( $wgUser->getOption( 'ow_language_filter' ) ) {
// language filtering is activated (checkbox selected
in preferences)
diff --git a/OmegaWiki/resources/tables.css b/OmegaWiki/resources/tables.css
index a9a4caf..932d9ee 100644
--- a/OmegaWiki/resources/tables.css
+++ b/OmegaWiki/resources/tables.css
@@ -1,4 +1,26 @@
+/* Language filtering Icon Styling */
+.wld_lang_filter_on a, .wld_lang_filter_off a {
+ margin: 0;
+ padding: 0;
+ outline: none;
+ display: block;
+ width: 26px;
+ background-repeat: no-repeat;
+ background-position: center;
+}
+
+.wld_lang_filter_on a {
+ /* @embed */
+ background-image: url("../../Images/my_lang.png");
+}
+
+.wld_lang_filter_off a {
+ /* @embed */
+ background-image: url("../../Images/all_lang.png");
+}
+
+
/* Wikidata tables */
.wiki-data-table td, .wiki-data-table th {
diff --git a/Wikidata.hooks.php b/Wikidata.hooks.php
index f01773a..2dde213 100644
--- a/Wikidata.hooks.php
+++ b/Wikidata.hooks.php
@@ -2,7 +2,7 @@
require_once( "OmegaWiki/WikiDataGlobals.php" );
-class WikidataHooks {
+class WikiLexicalDataHooks {
public static function onBeforePageDisplay( $out, $skin ) {
global $wgLang, $wgScriptPath, $wgRequest, $wgResourceModules;
@@ -137,9 +137,9 @@
return true;
}
- # Replace normal namespace with expression namespace
+ // Replace normal namespace with expression namespace
if ( $title->getNamespace() == NS_MAIN ) {
- $title = Title::newFromText( $term, NS_EXPRESSION ) ;
// $expressionNamespaceId ) ;
+ $title = Title::newFromText( $term, NS_EXPRESSION ) ;
}
if ( $title->exists() ) {
@@ -148,4 +148,28 @@
return true; // no match
}
+ public static function onSkinTemplateNavigation ( &$skin, &$links ) {
+
+ // display an icon for enabling/disabling language filtering
+ // only available in Vector.
+ if ( $skin instanceof SkinVector ) {
+ if ( $skin->getUser()->getOption( 'ow_language_filter'
) ) {
+ // language filtering is on. The button is for
disabling it
+ $links['views']['switch_lang_filter'] = array (
+ 'class' => 'wld_lang_filter_on',
+ 'text' => '', // no text, just an
image, see css
+ 'href' =>
$skin->getTitle()->getLocalUrl( "langfilter=off" ),
+ );
+ } else {
+ // language filtering is off. The button is for
enablingit
+ $links['views']['switch_lang_filter'] = array (
+ 'class' => 'wld_lang_filter_off',
+ 'text' => '', // no text, just an
image, see css
+ 'href' =>
$skin->getTitle()->getLocalUrl( "langfilter=on" ),
+ );
+ }
+ }
+
+ return true;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/49480
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia1c056bd1e51355ae3da254ad0e0f3ea2397b1c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiLexicalData
Gerrit-Branch: master
Gerrit-Owner: Kipcool <[email protected]>
Gerrit-Reviewer: Kipcool <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits