From 54f5e87fb63da8777f3d705a8e0870bc272bc408 Mon Sep 17 00:00:00 2001 From: Tim Mallezie Date: Thu, 7 May 2015 21:10:19 +0200 Subject: [PATCH] remove constants for size in Schema --- CRM/Core/CodeGen/Specification.php | 25 ++--------------------- xml/schema/Contact/Contact.xml | 28 +++++++++++++------------- xml/schema/Contribute/Contribution.xml | 2 +- xml/schema/Core/Email.xml | 2 +- xml/schema/Core/Phone.xml | 2 +- xml/schema/Core/Website.xml | 2 +- xml/schema/Financial/FinancialTrxn.xml | 2 +- xml/schema/Price/PriceFieldValue.xml | 2 +- 8 files changed, 22 insertions(+), 43 deletions(-) diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index 86c69c0b28..516a11e326 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -660,35 +660,14 @@ class CRM_Core_CodeGen_Specification { /** * Sets the size property of a textfield. - * See constants defined in CRM_Utils_Type for possible values */ protected function getSize($fieldXML) { // Extract from tag if supplied if (!empty($fieldXML->html) && $this->value('size', $fieldXML->html)) { - $const = 'CRM_Utils_Type::' . strtoupper($fieldXML->html->size); - if (defined($const)) { - return $const; - } + return $this->value('size', $fieldXML->html); } // Infer from tag if was not explicitly set or was invalid - - // This map is slightly different from CRM_Core_Form_Renderer::$_sizeMapper - // Because we usually want fields to render as smaller than their maxlength - $sizes = array( - 2 => 'TWO', - 4 => 'FOUR', - 6 => 'SIX', - 8 => 'EIGHT', - 16 => 'TWELVE', - 32 => 'MEDIUM', - 64 => 'BIG', - ); - foreach ($sizes as $length => $name) { - if ($fieldXML->length <= $length) { - return "CRM_Utils_Type::$name"; - } - } - return 'CRM_Utils_Type::HUGE'; + return $fieldXML->length; } } diff --git a/xml/schema/Contact/Contact.xml b/xml/schema/Contact/Contact.xml index d8c78e8d36..06f6b50d67 100644 --- a/xml/schema/Contact/Contact.xml +++ b/xml/schema/Contact/Contact.xml @@ -166,7 +166,7 @@ 64 Text - EIGHT + 8 true @@ -188,7 +188,7 @@ 128 Text - BIG + 30 true @@ -207,7 +207,7 @@ 128 Text - BIG + 30 true @@ -221,7 +221,7 @@ 128 Text - BIG + 30 true @@ -237,7 +237,7 @@ 128 Text - BIG + 30 true @@ -254,7 +254,7 @@ 128 Text - BIG + 30 true @@ -273,7 +273,7 @@ 1.1 File - BIG + 30 @@ -366,7 +366,7 @@ 255 Text - BIG + 30 true @@ -380,7 +380,7 @@ 64 Text - BIG + 30 true /^first|(f(irst\s)?name)$/i @@ -400,7 +400,7 @@ 64 Text - MEDIUM + 30 true /^middle|(m(iddle\s)?name)$/i @@ -415,7 +415,7 @@ 64 Text - BIG + 30 true /^last|(l(ast\s)?name)$/i @@ -624,7 +624,7 @@ 255 Text - MEDIUM + 30 true /^job|(j(ob\s)?title)$/i @@ -715,7 +715,7 @@ 128 Text - BIG + 30 true /^household|(h(ousehold\s)?name)$/i @@ -752,7 +752,7 @@ 128 Text - BIG + 30 true /^organization|(o(rganization\s)?name)$/i diff --git a/xml/schema/Contribute/Contribution.xml b/xml/schema/Contribute/Contribution.xml index df7f9c0af1..e7b166204e 100644 --- a/xml/schema/Contribute/Contribution.xml +++ b/xml/schema/Contribute/Contribution.xml @@ -423,7 +423,7 @@ 255 Text - SIX + 6 true 2.2 diff --git a/xml/schema/Core/Email.xml b/xml/schema/Core/Email.xml index a731fae3cc..9e60f7f804 100644 --- a/xml/schema/Core/Email.xml +++ b/xml/schema/Core/Email.xml @@ -60,7 +60,7 @@ 254 Text - MEDIUM + 30 true /e.?mail/i diff --git a/xml/schema/Core/Phone.xml b/xml/schema/Core/Phone.xml index dd854ec11d..7dee80ee06 100644 --- a/xml/schema/Core/Phone.xml +++ b/xml/schema/Core/Phone.xml @@ -108,7 +108,7 @@ 16 Text - FOUR + 4 true true diff --git a/xml/schema/Core/Website.xml b/xml/schema/Core/Website.xml index 32a68a4c76..7eda447a10 100644 --- a/xml/schema/Core/Website.xml +++ b/xml/schema/Core/Website.xml @@ -39,7 +39,7 @@ 128 Text - BIG + 30 true /Website/i diff --git a/xml/schema/Financial/FinancialTrxn.xml b/xml/schema/Financial/FinancialTrxn.xml index 8aee581831..9ec34cd018 100755 --- a/xml/schema/Financial/FinancialTrxn.xml +++ b/xml/schema/Financial/FinancialTrxn.xml @@ -212,7 +212,7 @@ 255 Text - SIX + 6 4.3 diff --git a/xml/schema/Price/PriceFieldValue.xml b/xml/schema/Price/PriceFieldValue.xml index 060c9e4524..256a5284d7 100644 --- a/xml/schema/Price/PriceFieldValue.xml +++ b/xml/schema/Price/PriceFieldValue.xml @@ -74,7 +74,7 @@ 512 Text - EIGHT + 8 true Price field option amount -- 2.25.1