Fz-29 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373600 )

Change subject: Make hierarchy additional parameter order insensitive
......................................................................

Make hierarchy additional parameter order insensitive

Change-Id: I0e54dc07804523f3ffc8c58f8a7674a7dfe884a8
---
M CargoFieldDescription.php
1 file changed, 40 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/00/373600/1

diff --git a/CargoFieldDescription.php b/CargoFieldDescription.php
index acf356c..ee58916 100644
--- a/CargoFieldDescription.php
+++ b/CargoFieldDescription.php
@@ -42,6 +42,7 @@
                // There may be additional parameters, in/ parentheses.
                $matches = array();
                $foundMatch2 = preg_match( '/([^(]*)\s*\((.*)\)/s', 
$fieldDescriptionStr, $matches );
+               $allowedValuesParam = "";
                if ( $foundMatch2 ) {
                        $fieldDescriptionStr = trim( $matches[1] );
                        $extraParamsString = $matches[2];
@@ -58,41 +59,7 @@
                                        $paramKey = trim( $extraParamParts[0] );
                                        $paramValue = trim( $extraParamParts[1] 
);
                                        if ( $paramKey == 'allowed values' ) {
-                                               // Replace the comma/delimiter
-                                               // substitution with a character
-                                               // that has no chance of being
-                                               // included in the values list -
-                                               // namely, the ASCII beep.
-
-                                               // The delimiter can't be a
-                                               // semicolon, because that's
-                                               // already used to separate
-                                               // "extra parameters", so just
-                                               // hardcode it to a semicolon.
-                                               $allowedValuesArray = array();
-                                               if( 
$fieldDescription->mIsHierarchy == true ) {
-                                                       // $paramValue contains 
"*" hierarchy structure
-                                                       
CargoUtils::validateHierarchyStructure( trim( $paramValue ) );
-                                                       
$fieldDescription->mHierarchyStructure = trim( $paramValue );
-                                                       // now make the allowed 
values param similar to the syntax
-                                                       // used by other fields
-                                                       $hierarchyNodesArray = 
explode( "\n", $paramValue );
-                                                       foreach ( 
$hierarchyNodesArray as $node ) {
-                                                               // Remove 
prefix of multiple "*"
-                                                               
$allowedValuesArray[] = preg_replace( '/^[*]* ?/', '', $node );
-                                                       }
-                                               } else {
-                                                       $delimiter = ',';
-                                                       $allowedValuesStr = 
str_replace( "\\$delimiter", "\a", $paramValue );
-                                                       $allowedValuesTempArray 
= explode( $delimiter, $allowedValuesStr );
-                                                       foreach ( 
$allowedValuesTempArray as $i => $value ) {
-                                                               if ( $value == 
'' ) continue;
-                                                               // Replace beep 
back with delimiter, trim.
-                                                               $value = 
str_replace( "\a", $delimiter, trim( $value ) );
-                                                               
$allowedValuesArray[] = $value;
-                                                       }
-                                               }
-                                               
$fieldDescription->mAllowedValues = $allowedValuesArray;
+                        $allowedValuesParam = $paramValue;
                                        } elseif ( $paramKey == 'size' ) {
                                                $fieldDescription->mSize = 
$paramValue;
                                        } else {
@@ -100,6 +67,44 @@
                                        }
                                }
                        }
+                       if ( $allowedValuesParam !== "" ) {
+                $allowedValuesArray = array();
+                if( $fieldDescription->mIsHierarchy == true ) {
+                    // $paramValue contains "*" hierarchy structure
+                    CargoUtils::validateHierarchyStructure( trim( 
$allowedValuesParam ) );
+                    $fieldDescription->mHierarchyStructure = trim( 
$allowedValuesParam );
+                    // now make the allowed values param similar to the syntax
+                    // used by other fields
+                    $hierarchyNodesArray = explode( "\n", $allowedValuesParam 
);
+                    foreach ( $hierarchyNodesArray as $node ) {
+                        // Remove prefix of multiple "*"
+                        $allowedValuesArray[] = preg_replace( '/^[*]* ?/', '', 
$node );
+                    }
+                } else {
+                    // Replace the comma/delimiter
+                    // substitution with a character
+                    // that has no chance of being
+                    // included in the values list -
+                    // namely, the ASCII beep.
+
+                    // The delimiter can't be a
+                    // semicolon, because that's
+                    // already used to separate
+                    // "extra parameters", so just
+                    // hardcode it to a semicolon.
+                    $delimiter = ',';
+                    $allowedValuesStr = str_replace( "\\$delimiter", "\a", 
$allowedValuesParam );
+                    $allowedValuesTempArray = explode( $delimiter, 
$allowedValuesStr );
+                    foreach ( $allowedValuesTempArray as $i => $value ) {
+                        if ( $value == '' ) continue;
+                        // Replace beep back with delimiter, trim.
+                        $value = str_replace( "\a", $delimiter, trim( $value ) 
);
+                        $allowedValuesArray[] = $value;
+                    }
+                }
+                $fieldDescription->mAllowedValues = $allowedValuesArray;
+            }
+
                }
 
                // What's left will be the type, hopefully.

-- 
To view, visit https://gerrit.wikimedia.org/r/373600
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e54dc07804523f3ffc8c58f8a7674a7dfe884a8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Fz-29 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to