diff --git a/includes/parserfunctions/PF_TemplateParams.php b/includes/parserfunctions/PF_TemplateParams.php index d0317482..cf402bff 100644 --- a/includes/parserfunctions/PF_TemplateParams.php +++ b/includes/parserfunctions/PF_TemplateParams.php @@ -1,80 +1,82 @@ getTitle(); if ( $title->getNamespace() !== NS_TEMPLATE ) { return '
\n{{" . $title->getText() . "\n"; foreach ( $fieldData as $fieldName => $fieldParams ) { $text .= "|$fieldName=\n"; } $text .= "}}\n"; $text .= '
' . wfMessage( "pf_template_docufooter" )->escaped() . '
'; return [ $text, 'noparse' => true, 'isHTML' => true ]; } public static function parseWikitextString( $fieldString ) { $fieldParams = []; $matches = []; $foundMatch = preg_match( '/([^(]*)\s*\((.*)\)/s', $fieldString, $matches ); $allowedValuesParam = ""; if ( $foundMatch ) { $fieldName = trim( $matches[1] ); $extraParamsString = $matches[2]; $extraParams = explode( ';', $extraParamsString ); foreach ( $extraParams as $extraParam ) { $extraParamParts = explode( '=', $extraParam, 2 ); if ( count( $extraParamParts ) == 1 ) { $paramKey = strtolower( trim( $extraParamParts[0] ) ); $fieldParams[$paramKey] = true; } else { $paramKey = strtolower( trim( $extraParamParts[0] ) ); $paramValue = trim( $extraParamParts[1] ); $fieldParams[$paramKey] = $paramValue; } } } else { $fieldName = trim( $fieldString ); } return [ $fieldName, $fieldParams ]; } }