Lucie Kaffee has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/256439

Change subject: Set the image Property id in configurations
......................................................................

Set the image Property id in configurations

Bug: T113957
Change-Id: I9ffb0ea1851a9a3c9a798ae83ce3ff7c3a616ad5
---
M ArticlePlaceholder.php
M Specials/SpecialAboutTopic.php
M includes/Hooks.php
A includes/Lua/Scribunto_LuaArticlePlaceholderLibrary.php
4 files changed, 80 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticlePlaceholder 
refs/changes/39/256439/1

diff --git a/ArticlePlaceholder.php b/ArticlePlaceholder.php
index 3d156ad..e2ea0e1 100644
--- a/ArticlePlaceholder.php
+++ b/ArticlePlaceholder.php
@@ -22,11 +22,15 @@
 
 $wgAutoloadClasses['ArticlePlaceholder\Specials\SpecialAboutTopic']
        = __DIR__ . '/Specials/SpecialAboutTopic.php';
+$wgAutoloadClasses['ArticlePlaceholder\Lua\Scribunto_LuaArticlePlaceholderLibrary']
+       = __DIR__ . '/includes/Lua/Scribunto_LuaArticlePlaceholderLibrary.php';
 $wgAutoloadClasses['ArticlePlaceholder\Hooks'] = __DIR__ . 
'/includes/Hooks.php';
 $wgAutoloadClasses['ArticlePlaceholder\SearchHookHandler']
        = __DIR__ . '/includes/SearchHookHandler.php';
 
-$wgHooks['ScribuntoExternalLibraryPaths'][]
+$wgHooks['ScribuntoExternalLibraries'][]
+       = '\ArticlePlaceholder\Hooks::onScribuntoExternalLibraries';
+$wgHooks['ScribuntoExternalLibraryPath'][]
        = '\ArticlePlaceholder\Hooks::registerScribuntoExternalLibraryPaths';
 $wgHooks['SpecialSearchResultsAppend'][]
        = '\ArticlePlaceholder\SearchHookHandler::onSpecialSearchResultsAppend';
diff --git a/Specials/SpecialAboutTopic.php b/Specials/SpecialAboutTopic.php
index b0c5169..dc342b6 100644
--- a/Specials/SpecialAboutTopic.php
+++ b/Specials/SpecialAboutTopic.php
@@ -325,9 +325,6 @@
 
                if ( isset( $sitelinksTitles[0][1] ) ) {
                        $sitelinkTitle = $sitelinkTitles[0][1];
-               }
-
-               if ( $sitelinkTitle !== null ) {
                        return $this->titleFactory->newFromText( $sitelinkTitle 
)->getLinkURL();
                }
 
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 3874699..55ffc3d 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -18,17 +18,31 @@
         *
         * @return bool
         */
+       public static function onScribuntoExternalLibraries(
+               $engine,
+               array &$extraLibraries
+       ) {
+               if ( $engine == 'lua' ) {
+                       $extraLibraries['EntityRenderer'] = 
'ArticlePlaceholder\Lua\Scribunto_LuaArticlePlaceholderLibrary';
+               }
+               return true;
+       }
+
+       /**
+        * External Lua library paths for Scribunto
+        *
+        * @param string $engine
+        * @param array &$extraLibraryPaths
+        *
+        * @return bool
+        */
        public static function registerScribuntoExternalLibraryPaths(
                $engine,
-               array &$extraLibraryPaths
+               array &$extraLibraryPath
        ) {
-               if ( $engine !== 'lua' ) {
-                       return true;
+               if ( $engine == 'lua' ) {
+                       $extraLibraryPath[] = __DIR__ . '/Lua';
                }
-
-               // Path containing pure Lua libraries that don't need to 
interact with PHP
-               $extraLibraryPaths[] = __DIR__ . '/Lua';
-
                return true;
        }
 
diff --git a/includes/Lua/Scribunto_LuaArticlePlaceholderLibrary.php 
b/includes/Lua/Scribunto_LuaArticlePlaceholderLibrary.php
new file mode 100644
index 0000000..d24b505
--- /dev/null
+++ b/includes/Lua/Scribunto_LuaArticlePlaceholderLibrary.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace ArticlePlaceholder\Lua;
+
+use Deserializers\Exceptions\DeserializationException;
+use Language;
+use Scribunto_LuaLibraryBase;
+use ScribuntoException;
+use ValueFormatters\FormatterOptions;
+use Wikibase\Client\DataAccess\PropertyIdResolver;
+use Wikibase\Client\PropertyLabelNotResolvedException;
+use Wikibase\Client\Usage\ParserOutputUsageAccumulator;
+use Wikibase\Client\Usage\UsageTrackingSnakFormatter;
+use Wikibase\Client\Usage\UsageTrackingTermLookup;
+use Wikibase\Client\WikibaseClient;
+use Wikibase\DataModel\Entity\EntityIdParsingException;
+use Wikibase\DataModel\Services\Lookup\EntityAccessLimitException;
+use Wikibase\DataModel\Services\Lookup\EntityRetrievingTermLookup;
+use Wikibase\LanguageFallbackChain;
+use Wikibase\LanguageFallbackChainFactory;
+use Wikibase\Lib\SnakFormatter;
+use Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookup;
+
+/**
+ * Registers and defines functions needed by the Lua modules
+ *
+ * @licence GNU GPL v2+
+ * @author Lucie-Aimée Kaffee
+ */
+class Scribunto_LuaArticlePlaceholderLibrary extends Scribunto_LuaLibraryBase {
+
+       /**
+        *
+        */
+       private function getImageProperty() {
+               return 'Hello World';
+       }
+
+       /**
+        * @return array
+        */
+       public function register() {
+               // These functions will be exposed to the Lua module.
+               // They are member functions on a Lua table which is private to 
the module, thus
+               // these can't be called from user code, unless explicitly 
exposed in Lua.
+               $lib = array(
+                       'getImageProperty' => array( $this, 'getImageProperty' 
),
+               );
+
+               return $this->getEngine()->registerInterface(
+                       __DIR__ . '/EntityRenderer.lua', $lib, array()
+               );
+       }
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/256439
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ffb0ea1851a9a3c9a798ae83ce3ff7c3a616ad5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticlePlaceholder
Gerrit-Branch: master
Gerrit-Owner: Lucie Kaffee <lucie.kaf...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to