Florianschmidtwelzow has uploaded a new change for review. https://gerrit.wikimedia.org/r/212853
Change subject: Add extension.json and clear PHP entry point ...................................................................... Add extension.json and clear PHP entry point Bug: T88047 Change-Id: I6930b478ea094ab9ce829f167674995de6c16bdf --- M FancyCaptcha/FancyCaptcha.php A FancyCaptcha/extension.json M includes/ConfirmEditHooks.php 3 files changed, 72 insertions(+), 85 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmEdit refs/changes/53/212853/1 diff --git a/FancyCaptcha/FancyCaptcha.php b/FancyCaptcha/FancyCaptcha.php index 3d22329..61293cc 100644 --- a/FancyCaptcha/FancyCaptcha.php +++ b/FancyCaptcha/FancyCaptcha.php @@ -1,87 +1,13 @@ <?php -/** - * Experimental image-based captcha plugin, using images generated by an - * external tool. - * - * Copyright (C) 2005, 2006 Brion Vibber <br...@pobox.com> - * http://www.mediawiki.org/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @ingroup Extensions - */ - -if ( !defined( 'MEDIAWIKI' ) ) { - exit; +if ( function_exists( 'wfLoadExtension' ) ) { + wfLoadExtension( 'FancyCaptcha' ); + // Keep i18n globals so mergeMessageFileList.php doesn't break + $wgMessagesDirs['FancyCaptcha'] = __DIR__ . '/i18n'; + /* wfWarn( + 'Deprecated PHP entry point used for Gather extension. Please use wfLoadExtension instead, ' . + 'see https://www.mediawiki.org/wiki/Extension_registration for more details.' + ); */ + return; +} else { + die( 'This version of the FancyCaptcha extension requires MediaWiki 1.25+' ); } - -require_once dirname( __DIR__ ) . '/ConfirmEdit.php'; -$wgCaptchaClass = 'FancyCaptcha'; - -/** - * The name of a file backend ($wgFileBackends) to be used for storing files. - * Defaults to FSFileBackend using $wgCaptchaDirectory as a base path. - */ -$wgCaptchaFileBackend = ''; - -global $wgCaptchaDirectory; -$wgCaptchaDirectory = "$wgUploadDirectory/captcha"; // bad default :D - -global $wgCaptchaDirectoryLevels; -$wgCaptchaDirectoryLevels = 0; // To break into subdirectories - -global $wgCaptchaSecret; -$wgCaptchaSecret = "CHANGE_THIS_SECRET!"; - -/** - * By default the FancyCaptcha rotates among all available captchas. - * Setting $wgCaptchaDeleteOnSolve to true will delete the captcha - * files when they are correctly solved. Thus the user will need - * something like a cron creating new thumbnails to avoid drying up. - */ -$wgCaptchaDeleteOnSolve = false; - -$wgMessagesDirs['FancyCaptcha'] = __DIR__ . '/i18n'; -$wgAutoloadClasses['FancyCaptcha'] = __DIR__ . '/FancyCaptcha.class.php'; - -$wgResourceModules['ext.confirmEdit.fancyCaptcha.styles'] = array( - 'position' => 'top', - 'localBasePath' => __DIR__ . '/resources', - 'remoteExtPath' => 'ConfirmEdit/FancyCaptcha/resources', - 'targets' => array( 'mobile', 'desktop' ), - 'styles' => 'ext.confirmEdit.fancyCaptcha.css', -); - -$wgResourceModules['ext.confirmEdit.fancyCaptcha'] = array( - 'localBasePath' => __DIR__ . '/resources', - 'remoteExtPath' => 'ConfirmEdit/FancyCaptcha/resources', - 'scripts' => 'ext.confirmEdit.fancyCaptcha.js', - 'dependencies' => 'mediawiki.api', -); - -// FIXME: remove, add mobile target to ext.confirmEdit.fancyCaptcha and update -// MobileFrontend accordingly when bug 57629 is resolved -$wgResourceModules['ext.confirmEdit.fancyCaptchaMobile'] = array( - 'localBasePath' => __DIR__ . '/resources', - 'remoteExtPath' => 'ConfirmEdit/FancyCaptcha/resources', - 'scripts' => 'ext.confirmEdit.fancyCaptcha.js', - 'targets' => array( 'mobile', 'desktop' ), - 'dependencies' => 'mobile.startup', -); - -$wgAutoloadClasses['ApiFancyCaptchaReload'] = __DIR__ . '/ApiFancyCaptchaReload.php'; -$wgAPIModules['fancycaptchareload'] = 'ApiFancyCaptchaReload'; diff --git a/FancyCaptcha/extension.json b/FancyCaptcha/extension.json new file mode 100644 index 0000000..6eb2170 --- /dev/null +++ b/FancyCaptcha/extension.json @@ -0,0 +1,51 @@ +{ + "APIModules": { + "fancycaptchareload": "ApiFancyCaptchaReload" + }, + "MessagesDirs": { + "FancyCaptcha": [ + "i18n" + ] + }, + "AutoloadClasses": { + "FancyCaptcha": "FancyCaptcha.class.php", + "ApiFancyCaptchaReload": "ApiFancyCaptchaReload.php" + }, + "ResourceModules": { + "ext.confirmEdit.fancyCaptcha.styles": { + "position": "top", + "targets": [ + "mobile", + "desktop" + ], + "styles": "ext.confirmEdit.fancyCaptcha.css" + }, + "ext.confirmEdit.fancyCaptcha": { + "scripts": "ext.confirmEdit.fancyCaptcha.js", + "dependencies": "mediawiki.api" + }, + "ext.confirmEdit.fancyCaptchaMobile": { + "scripts": "ext.confirmEdit.fancyCaptcha.js", + "targets": [ + "mobile", + "desktop" + ], + "dependencies": "mobile.startup" + } + }, + "ResourceFileModulePaths": { + "localBasePath": "resources", + "remoteExtPath": "ConfirmEdit/FancyCaptcha/resources" + }, + "callback": [ + "ConfirmEditHooks::onFancyCaptchaSetup" + ], + "config": { + "CaptchaClass": "FancyCaptcha", + "CaptchaFileBackend": "", + "CaptchaDirectory": false, + "CaptchaDirectoryLevels": 0, + "CaptchaSecret": "CHANGE_THIS_SECRET!", + "CaptchaDeleteOnSolve": false + } +} diff --git a/includes/ConfirmEditHooks.php b/includes/ConfirmEditHooks.php index 65aa699..2c0cd7e 100644 --- a/includes/ConfirmEditHooks.php +++ b/includes/ConfirmEditHooks.php @@ -129,4 +129,14 @@ $wgWhitelistRead[] = $help->getPrefixedText(); } } + /** + * Callback for extension.json of FancyCaptcha to set a default captcha directory, + * which depends on wgUploadDirectory + */ + public static function onFancyCaptchaSetup() { + global $wgCaptchaDirectory, $wgUploadDirectory; + if ( !$wgCaptchaDirectory ) { + $wgCaptchaDirectory = "$wgUploadDirectory/captcha"; + } + } } -- To view, visit https://gerrit.wikimedia.org/r/212853 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6930b478ea094ab9ce829f167674995de6c16bdf Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ConfirmEdit Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits