diff --git a/FlexForm.hooks.php b/FlexForm.hooks.php index d21f7a1f..75cc4afc 100644 --- a/FlexForm.hooks.php +++ b/FlexForm.hooks.php @@ -57,14 +57,14 @@ public static function availableHooks() { */ public static function addToAdminLinks( ALTree &$adminLinksTree ) { global $wgScript; - $wsSection = $adminLinksTree->getSection( 'WikiBase Solutions' ); + $wsSection = $adminLinksTree->getSection( 'Open CSP' ); if ( is_null( $wsSection ) ) { - $section = new ALSection( 'WikiBase Solutions' ); + $section = new ALSection( 'Open CSP' ); $adminLinksTree->addSection( $section, wfMessage( 'adminlinks_general' )->text() ); - $wsSection = $adminLinksTree->getSection( 'WikiBase Solutions' ); + $wsSection = $adminLinksTree->getSection( 'Open CSP' ); $extensionsRow = new ALRow( 'extensions' ); $wsSection->addRow( $extensionsRow ); } diff --git a/README.md b/README.md index da5c1a91..f4b5037f 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ $wgFlexFormConfig['secure'] = true; //( d $wgFlexFormConfig['sec_key'] = ""; // A salt key for encryption. Used together with "secure" option. Must be set when using multiple instances of a wiki $wgFlexFormConfig['auto_save_interval'] = 30000; // defaults to 3 minutes. $wgFlexFormConfig['auto_save_after_change'] = 3000; // defaults to 3 seconds after last change +$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on'; // Text on the autosave button to toggle on. +$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off';// Text on the autosave button to toggle off. $wgFlexFormConfig['FlexFormDefaultTheme'] = "Plain"; // Currently the only form $wgFlexFormConfig['rc_site_key'] = ""; // reCaptcha site key $wgFlexFormConfig['rc_secret_key'] = ""; // reCaptcha secret key @@ -46,9 +48,14 @@ $wgFlexFormConfig['renderi18nErrorInsteadofImageForApprovedForms'] = false; // W $wgFlexFormConfig['userscaneditallpages'] = false; // Defaults to false. This differs from FlexForm before 2.0. FlexForm will now honor the UserCan functions in MediaWiki. If a form edits or creates a page a user has no rights to, the form will fail. $wgFlexFormConfig['hideEdit'] = true; // Defaults to true. If a user is not in the allowedGroups then hide edit and editsource menu items for any page containing a FlexForm form. $wgFlexFormConfig['create-seo-titles'] = true; // Defaults to false. Will filter any user input on creating a new page to be SEO friendly. -$wgFlexFormConfig['auto_save_btn_on'] = "Autosave On"; -$wgFlexFormConfig['auto_save_btn_off'] = "Autosave Off"; +$wgFlexFormConfig['pandoc-install-path'] = ''; // If you want to use a different Pandoc version than the one installed on the server by default +$wgFlexFormConfig['pandoc-convert-to'][] = 'mediawiki'; // defaults to MediaWiki, but you can add more +$wgFlexFormConfig['pandoc-convert-from'][] = 'docx'; // defaults to docx, but you can add more +$wgFlexFormConfig['pandoc-allow-additional-arguments'] = ""; // add additional Pandoc arguments to a convert +$wgFlexFormConfig['forceNullEdit'] = true; // Default to true for backwards compatibility +$wgFlexFormConfig['allowFlexFormOpenAPI'] = false; // As of version 2.7.1: This will enable FlexFormOpenAPI, making it possible to use API 'CanUserBeCreated' which does not require read-rights. $wgFlexFormConfig['loadScriptPath'] = ""; // Defaults to what is described by the loadscript form argument. When you change it do a different folder, then loadScript argument will be looking in this folder for its JavaScript file to load with the Form. +$wgFlexFormConfig['use_mediawiki_mail_settings'] = false; // As of version 2.7.1: When sending email, should we use MediaWiki mail settings (defaults to false)? If set to true: when MediaWiki wgSMTP is set, FlexForm will use those settings, if they are not set, FlexForm will not use SMTP. $wgFlexFormConfig['use_smtp'] = false; // when sending email, should we use separate smtp ? $wgFlexFormConfig['smtp_host'] = ""; $wgFlexFormConfig['smtp_authentication'] = true; @@ -86,6 +93,7 @@ Visit this documentation page https://www.open-csp.org/DevOps:Doc/FlexForm/2.0/V Visit : https://www.open-csp.org/DevOps:Doc/FlexForm ### Changelog +* 2.8.1 : Make sure mwrandom is even more random * 2.8.0 : Pandoc conversions expanded. See online documentation * 2.7.2 : Changed submitting of Forms to a better viewable submit status. Introducing --ff-overlay-bg, --ff-spinner-base, --ff-spinner-color-1 and --ff-spinner-color-2 css variables to control colors. * 2.7.1 : Added: action=FlexFormOpen&ffAction=canUserBeCreated&additionalData=Harry (example) to check if a user can exist. Added use_mediawiki_mail_settings config setting. diff --git a/extension.json b/extension.json index ca2d02a8..5d978305 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "FlexForm", - "version": "2.8.0", + "version": "2.8.1", "author": [ "[https://www.wikibase-solutions.com/author/charlot Sen-Sai]" ], diff --git a/src/Processors/Content/ContentCore.php b/src/Processors/Content/ContentCore.php index 14c20c32..625b41d0 100644 --- a/src/Processors/Content/ContentCore.php +++ b/src/Processors/Content/ContentCore.php @@ -56,6 +56,11 @@ class ContentCore { */ public static string $jobUser; + /** + * @var int + */ + private static int $fileNumber = 0; + /** * @return array */ @@ -63,6 +68,24 @@ public static function getFields(): array { return self::$fields; } + /** + * @param int $fCount + * + * @return void + */ + public static function setFileCount( int $fCount ): void { + self::$fileNumber = $fCount; + } + + /** + * @return int + */ + private static function getFileCount(): int { + $fCount = self::$fileNumber; + self::$fileNumber = 0; + return $fCount; + } + /** * Set userpage in Summary if not summary is available. * @@ -749,9 +772,14 @@ public static function parseTitle( string $title, bool $noSEO = false ) { } foreach ( $tmp as $fieldname ) { if ( $fieldname == 'mwrandom' ) { + $fCount = self::getFileCount(); + $randomNumber = General::MakeTitle(); + if ( $fCount > 0 ) { + $randomNumber .= '-' . $fCount; + } $title = str_replace( '[' . $fieldname . ']', - General::MakeTitle(), + $randomNumber, $title ); } elseif ( isset( $_POST[General::makeUnderscoreFromSpace( $fieldname )] ) ) { diff --git a/src/Processors/Files/Upload.php b/src/Processors/Files/Upload.php index ff3458d1..d56f8bc0 100644 --- a/src/Processors/Files/Upload.php +++ b/src/Processors/Files/Upload.php @@ -198,11 +198,17 @@ private function checkAllowedConversions( string $from, string $to, array $addit if ( !in_array( $to, Config::getConfigVariable( 'pandoc-convert-to' ) ) ) { return "Convert to '$to' is not allowed."; } + if ( !empty( $additional ) ) { - foreach ( $additional as $singleAdditional ) { - if ( !in_array( $singleAdditional, Config::getConfigVariable( 'pandoc-allow-additional-arguments' ) ) ) { - return "Additional argument '$singleAdditional' is not allowed."; + $pandocAllowedArguments = Config::getConfigVariable( 'pandoc-allow-additional-arguments' ); + if ( !empty( $pandocAllowedArguments ) && is_array( $pandocAllowedArguments ) ) { + foreach ( $additional as $key => $singleAdditional ) { + if ( !in_array( $key, $pandocAllowedArguments ) ) { + return "Additional argument '$singleAdditional' is not allowed."; + } } + } else { + return "Additional arguments not correctly set in Config"; } } @@ -490,6 +496,7 @@ public function fileUpload(): bool { $titleName ); } + ContentCore::setFileCount( $i ); $titleName = ContentCore::parseTitle( $titleName ); if ( Config::isDebug() ) { Debug::addToDebug( diff --git a/src/Processors/Utilities/General.php b/src/Processors/Utilities/General.php index fc07fcbd..f3cc829d 100644 --- a/src/Processors/Utilities/General.php +++ b/src/Processors/Utilities/General.php @@ -10,6 +10,7 @@ namespace FlexForm\Processors\Utilities; +use FlexForm\Processors\Content\ContentCore; use FlexForm\Processors\Security\wsSecurity; use HTMLPurifier; use HTMLPurifier_Config; @@ -162,8 +163,15 @@ public static function is_cli(): bool { /** * @return int */ - public static function MakeTitle() : int { - return time(); + public static function MakeTitle(): int { + $randomExtraNumber = str_pad( + mt_rand( 1,999 ), + 3, + '0', + STR_PAD_LEFT + ); + return time() . $randomExtraNumber; + } /**