Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions FlexForm.hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FlexForm",
"version": "2.8.0",
"version": "2.8.1",
"author": [
"[https://www.wikibase-solutions.com/author/charlot Sen-Sai]"
],
Expand Down
30 changes: 29 additions & 1 deletion src/Processors/Content/ContentCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,36 @@ class ContentCore {
*/
public static string $jobUser;

/**
* @var int
*/
private static int $fileNumber = 0;

/**
* @return array
*/
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.
*
Expand Down Expand Up @@ -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 )] ) ) {
Expand Down
13 changes: 10 additions & 3 deletions src/Processors/Files/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand Down Expand Up @@ -490,6 +496,7 @@ public function fileUpload(): bool {
$titleName
);
}
ContentCore::setFileCount( $i );
$titleName = ContentCore::parseTitle( $titleName );
if ( Config::isDebug() ) {
Debug::addToDebug(
Expand Down
12 changes: 10 additions & 2 deletions src/Processors/Utilities/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace FlexForm\Processors\Utilities;

use FlexForm\Processors\Content\ContentCore;
use FlexForm\Processors\Security\wsSecurity;
use HTMLPurifier;
use HTMLPurifier_Config;
Expand Down Expand Up @@ -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;

}

/**
Expand Down