summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Validator/Validator.php
diff options
context:
space:
mode:
authorYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
committerYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
commitfc7369835258467bf97eb64f184b93691f9a9fd5 (patch)
treedaabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/Validator/Validator.php
first commit
Diffstat (limited to 'www/wiki/extensions/Validator/Validator.php')
-rw-r--r--www/wiki/extensions/Validator/Validator.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/www/wiki/extensions/Validator/Validator.php b/www/wiki/extensions/Validator/Validator.php
new file mode 100644
index 00000000..d172e129
--- /dev/null
+++ b/www/wiki/extensions/Validator/Validator.php
@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * Initialization file for the Validator MediaWiki extension.
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
+
+if ( defined( 'ParamProcessor_VERSION' ) ) {
+ // Do not initialize more than once.
+ return 1;
+}
+
+define( 'Validator_VERSION', '2.2.1' );
+define( 'ParamProcessor_VERSION', Validator_VERSION ); // @deprecated since 1.0
+
+// Internationalization
+$GLOBALS['wgMessagesDirs']['Validator'] = __DIR__ . '/i18n';
+
+
+$GLOBALS['wgExtensionFunctions'][] = function () {
+ if ( version_compare( $GLOBALS['wgVersion'], '1.23c', '<' ) ) {
+ die( '<b>Error:</b> This version of Validator requires MediaWiki 1.23 or above.' );
+ }
+
+ if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
+ include_once( __DIR__ . '/vendor/autoload.php' );
+ }
+
+ if ( !class_exists( ParamProcessor\Processor::class ) ) {
+ throw new Exception( 'Validator depends on the ParamProcessor library.' );
+ }
+
+ // Display extension information
+ $GLOBALS['wgExtensionCredits']['other'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'Validator',
+ 'version' => Validator_VERSION,
+ 'author' => array(
+ '[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]'
+ ),
+ 'url' => 'https://github.com/JeroenDeDauw/Validator',
+ 'descriptionmsg' => 'validator-desc',
+ 'license-name' => 'GPL-2.0+'
+ );
+
+ /**
+ * Hook to add PHPUnit test cases.
+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
+ *
+ * @since 1.0
+ *
+ * @param array $files
+ *
+ * @return boolean
+ */
+ $GLOBALS['wgHooks']['UnitTestsList'][] = function( array &$files ) {
+ // @codeCoverageIgnoreStart
+ $directoryIterator = new RecursiveDirectoryIterator( __DIR__ . '/tests/phpunit/' );
+
+ /**
+ * @var SplFileInfo $fileInfo
+ */
+ foreach ( new RecursiveIteratorIterator( $directoryIterator ) as $fileInfo ) {
+ if ( substr( $fileInfo->getFilename(), -8 ) === 'Test.php' ) {
+ $files[] = $fileInfo->getPathname();
+ }
+ }
+
+ return true;
+ // @codeCoverageIgnoreEnd
+ };
+
+ $GLOBALS['wgDataValues']['mediawikititle'] = ParamProcessor\MediaWikiTitleValue::class;
+
+ $GLOBALS['wgParamDefinitions']['title'] = array(
+ 'string-parser' => ParamProcessor\TitleParser::class,
+ 'validator' => ValueValidators\TitleValidator::class,
+ );
+};
+