Ananay has uploaded a new change for review.
https://gerrit.wikimedia.org/r/257835
Change subject: Code perfected again.
......................................................................
Code perfected again.
Change-Id: Icb6d4a5f599cb28a12c75be8423a7d6d9c4615a9
---
A Quiz.hooks.php
M Quiz.php
A extension.json
3 files changed, 112 insertions(+), 63 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Quiz
refs/changes/35/257835/1
diff --git a/Quiz.hooks.php b/Quiz.hooks.php
new file mode 100644
index 0000000..0fe4f12
--- /dev/null
+++ b/Quiz.hooks.php
@@ -0,0 +1,27 @@
+<?php
+class QuizHooks {
+ /**
+ * Register the extension with the WikiText parser.
+ * The tag used is <quiz>
+ * @param $parser Parser the wikitext parser
+ * @return Boolean true to continue hook processing
+ */
+ public static function onParserFirstCallInit( &$parser ) {
+ $parser->setHook( 'quiz', 'QuizHooks::renderQuiz' );
+ return true;
+ }
+ /**
+ * Call the quiz parser on an input text.
+ *
+ * @param $input String text between <quiz> and </quiz> tags, in quiz
syntax.
+ * @param $argv Array an array containing any arguments passed to the
extension
+ * @param $parser Parser the wikitext parser.
+ *
+ * @return string An HTML quiz.
+ */
+ public static function renderQuiz( $input, $argv, $parser ) {
+ $parser->disableCache();
+ $quiz = new Quiz( $argv, $parser );
+ return $quiz->parseQuiz( $input );
+ }
+}
diff --git a/Quiz.php b/Quiz.php
index b92e37f..6a70de9 100644
--- a/Quiz.php
+++ b/Quiz.php
@@ -35,67 +35,50 @@
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This is not a valid entry point to MediaWiki.' );
}
-
-/**
- * Extension credits that will show up on Special:Version
- */
-$wgExtensionCredits['parserhook'][] = array(
- 'path' => __FILE__,
- 'name' => 'Quiz',
- 'version' => '1.2.0',
- 'author' => 'Louis-Rémi Babe',
- 'url' => 'https://www.mediawiki.org/wiki/Extension:Quiz',
- 'descriptionmsg' => 'quiz_desc',
- 'license-name' => 'GPL-2.0+'
-);
-
-/**
- * Add this extension to MediaWiki's extensions list.
- */
-$dir = __DIR__ . '/';
-$wgAutoloadClasses['Quiz'] = $dir . 'Quiz.class.php';
-$wgAutoloadClasses['Question'] = $dir . 'Quiz.class.php';
-$wgMessagesDirs['QuizExtension'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['QuizExtension'] = $dir . 'Quiz.i18n.php';
-
-$wgHooks['ParserFirstCallInit'][] = 'wfQuizExtension';
-$wgHooks['ParserClearState'][] = 'Quiz::resetQuizID';
-
-$commonModuleInfo = array(
- 'localBasePath' => dirname( __FILE__ ) . '/modules',
- 'remoteExtPath' => 'Quiz/modules',
-);
-
-// Styles and any code common to all Special:Code subviews:
-$wgResourceModules['ext.quiz'] = array(
- 'scripts' => 'ext.quiz.js',
- 'styles' => 'ext.quiz.css',
- 'position' => 'top',
-) + $commonModuleInfo;
-
-/**
- * Register the extension with the WikiText parser.
- * The tag used is <quiz>
- *
- * @param $parser Parser the wikitext parser
- * @return Boolean true to continue hook processing
- */
-function wfQuizExtension( &$parser ) {
- $parser->setHook( 'quiz', 'renderQuiz' );
- return true;
-}
-
-/**
- * Call the quiz parser on an input text.
- *
- * @param $input String text between <quiz> and </quiz> tags, in quiz syntax.
- * @param $argv Array an array containing any arguments passed to the extension
- * @param $parser Parser the wikitext parser.
- *
- * @return string An HTML quiz.
- */
-function renderQuiz( $input, $argv, $parser ) {
- $parser->disableCache();
- $quiz = new Quiz( $argv, $parser );
- return $quiz->parseQuiz( $input );
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'Quiz' );
+ /**
+ * Extension credits that will show up on Special:Version
+ */
+ $wgExtensionCredits['parserhook'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'Quiz',
+ 'version' => '1.2.0',
+ 'author' => 'Louis-Rémi Babe',
+ 'url' =>
'https://www.mediawiki.org/wiki/Extension:Quiz',
+ 'descriptionmsg' => 'quiz_desc',
+ 'license-name' => 'GPL-2.0+'
+ );
+
+ /**
+ * Add this extension to MediaWiki's extensions list.
+ */
+ $dir = __DIR__ . '/';
+ $wgAutoloadClasses['Quiz'] = $dir . 'Quiz.class.php';
+ $wgAutoloadClasses['Question'] = $dir . 'Quiz.class.php';
+ $wgAutoloadClasses['QuizHooks'] = $dir . 'Quiz.hooks.php';
+ $wgMessagesDirs['QuizExtension'] = __DIR__ . '/i18n';
+ $wgExtensionMessagesFiles['QuizExtension'] = $dir . 'Quiz.i18n.php';
+
+ $wgHooks['ParserFirstCallInit'][] = 'QuizHooks::onParserFirstCallInit';
+ $wgHooks['ParserClearState'][] = 'Quiz::resetQuizID';
+
+ $commonModuleInfo = array(
+ 'localBasePath' => dirname( __FILE__ ) . '/modules',
+ 'remoteExtPath' => 'Quiz/modules',
+ );
+
+ // Styles and any code common to all Special:Code subviews:
+ $wgResourceModules['ext.quiz'] = array(
+ 'scripts' => 'ext.quiz.js',
+ 'styles' => 'ext.quiz.css',
+ 'position' => 'top',
+ ) + $commonModuleInfo;
+ wfWarn(
+ 'Deprecated PHP entry point used for Quiz extension. Please use
wfLoadExtension instead, ' .
+ 'see https://www.mediawiki.org/wiki/Extension_registration for
more details.'
+ );
+ return;
+} else {
+ die( 'This version of the FooBar extension requires MediaWiki 1.25+' );
}
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..e530ae2
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,39 @@
+{
+ "name": "Quiz",
+ "version": "1.2.0",
+ "author": "Louis-Rémi Babe",
+ "url": "https://www.mediawiki.org/wiki/Extension:Quiz",
+ "descriptionmsg": "quiz_desc",
+ "license-name": "GPL-2.0+",
+ "type": "parserhook",
+ "MessagesDirs": {
+ "QuizExtension": [
+ "i18n"
+ ]
+ },
+ "AutoloadClasses": {
+ "Quiz": "Quiz.class.php",
+ "Question": "Quiz.class.php",
+ "QuizHooks": "Quiz.hooks.php"
+ },
+ "ResourceModules": {
+ "ext.quiz": {
+ "scripts": "ext.quiz.js",
+ "styles": "ext.quiz.css",
+ "position": "top"
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "modules",
+ "remoteExtPath": "Quiz/modules"
+ },
+ "Hooks": {
+ "ParserFirstCallInit": [
+ "QuizHooks::onParserFirstCallInit"
+ ],
+ "ParserClearState": [
+ "Quiz::resetQuizID"
+ ]
+ },
+ "manifest_version": 1
+}
--
To view, visit https://gerrit.wikimedia.org/r/257835
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb6d4a5f599cb28a12c75be8423a7d6d9c4615a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Ananay <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits