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

Change subject: Added support for hierarchy fields in the Page Forms extension. 
Hierarchy fields automatically get the right input type ("tree"), with the 
right values filled in. According to the task T161034.
......................................................................

Added support for hierarchy fields in the Page Forms extension. Hierarchy 
fields automatically get the right input type ("tree"), with the right values 
filled in. According to the task T161034.

Change-Id: I03bc8cf413ce0969eee6397d652aa5d319a38c86
---
M includes/PF_TemplateField.php
M includes/forminputs/PF_TreeInput.php
2 files changed, 29 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageForms 
refs/changes/28/356928/1

diff --git a/includes/PF_TemplateField.php b/includes/PF_TemplateField.php
index b3c11da..f866b32 100644
--- a/includes/PF_TemplateField.php
+++ b/includes/PF_TemplateField.php
@@ -127,7 +127,11 @@
                // We have some "pseudo-types", used for setting the correct
                // form input.
                if ( $fieldDescription->mAllowedValues != null ) {
-                       $this->mFieldType = 'Enumeration';
+                       if( $fieldDescription->mIsHierarchy == true ) {
+                               $this->mFieldType = 'hierarchy';
+                       } else {
+                               $this->mFieldType = 'Enumeration';
+                       }                       
                } elseif ( $fieldDescription->mType == 'Text' && 
$fieldDescription->mSize != '' && $fieldDescription->mSize <= 100 ) {
                        $this->mFieldType = 'String';
                } else {
diff --git a/includes/forminputs/PF_TreeInput.php 
b/includes/forminputs/PF_TreeInput.php
index 8758d51..e3c760b 100644
--- a/includes/forminputs/PF_TreeInput.php
+++ b/includes/forminputs/PF_TreeInput.php
@@ -40,6 +40,18 @@
                }
        }
 
+       public static function getDefaultCargoTypes() {
+               return array(
+                       'hierarchy' => array()
+               );
+       }
+
+       public static function getDefaultCargoTypeLists() {
+               return array(
+                       'hierarchy' => array()
+               );
+       }
+
        public static function getOtherCargoTypesHandled() {
                return array( 'String', 'Page' );
        }
@@ -51,10 +63,10 @@
        public static function getHTML( $cur_value, $input_name, $is_mandatory, 
$is_disabled, $other_args ) {
                // Handle the now-deprecated 'category' and 'categories'
                // input types.
-               if ( $other_args['input type'] == 'category' ) {
+               if ( array_key_exists( 'input type', $other_args ) && 
$other_args['input type'] == 'category' ) {
                        $inputType = "radio";
                        self::$multipleSelect = false;
-               } elseif ( $other_args['input type'] == 'categories' ) {
+               } elseif ( array_key_exists( 'input type', $other_args ) && 
$other_args['input type'] == 'categories' ) {
                        $inputType = "checkbox";
                        self::$multipleSelect = true;
                } else {
@@ -107,6 +119,16 @@
                        $structure = $other_args['structure'];
                        $tree = PFTree::newFromWikiText( $structure );
                        $hideroot = true;
+               } elseif ( array_key_exists( 'possible_values', $other_args ) ) 
{
+                       //The possibility of field being of type - 'hierarchy' 
pseudo-type
+                               if ( count( $other_args['possible_values'] ) >= 
1) {
+                                       $structure = 
$other_args['possible_values'][0];
+                                       $tree = PFTree::newFromWikiText( 
$structure );
+                                       $hideroot = true;
+                               } else {
+                                       return null;
+                               }
+
                } else {
                        // Escape - we can't do anything.
                        return null;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03bc8cf413ce0969eee6397d652aa5d319a38c86
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageForms
Gerrit-Branch: master
Gerrit-Owner: Fz-29 <f29ah...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to