From 5e545f3840874d38033f0f13fbee623840088e0c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 11 Dec 2013 13:25:44 -0800 Subject: [PATCH] CRM-13497 - Update CodeGen to handle xml mods --- CRM/Core/CodeGen/Specification.php | 30 ++++++++++++++++++++++++++---- xml/templates/dao.tpl | 9 +++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index 4e667336ef..da2a6e6399 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -284,8 +284,10 @@ class CRM_Core_CodeGen_Specification { case 'text': $field['sqlType'] = $field['phpType'] = $type; $field['crmType'] = 'CRM_Utils_Type::T_' . strtoupper($type); - $field['rows'] = $this->value('rows', $fieldXML); - $field['cols'] = $this->value('cols', $fieldXML); + // CRM-13497 see fixme below + $field['rows'] = isset($fieldXML->html) ? $this->value('rows', $fieldXML->html) : NULL; + $field['cols'] = isset($fieldXML->html) ? $this->value('cols', $fieldXML->html) : NULL; + break; break; case 'datetime': @@ -344,6 +346,26 @@ class CRM_Core_CodeGen_Specification { $field['headerPattern'] = $this->value('headerPattern', $fieldXML); $field['dataPattern'] = $this->value('dataPattern', $fieldXML); $field['uniqueName'] = $this->value('uniqueName', $fieldXML); + $field['html'] = $this->value('html', $fieldXML); + if (!empty($field['html'])) { + $validOptions = array( + 'type', + /* Fixme: prior to CRM-13497 these were in a flat structure + // CRM-13497 moved them to be nested within 'html' but there's no point + // making that change in the DAOs right now since we are in the process of + // moving to docrtine anyway. + // So translating from nested xml back to flat structure for now. + 'rows', + 'cols', + 'size', */ + ); + $field['html'] = array(); + foreach ($validOptions as $htmlOption) { + if(!empty($fieldXML->html->$htmlOption)){ + $field['html'][$htmlOption] = $this->value($htmlOption, $fieldXML->html); + } + } + } $field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML); if(!empty($field['pseudoconstant'])){ //ok this is a bit long-winded but it gets there & is consistent with above approach @@ -561,8 +583,8 @@ class CRM_Core_CodeGen_Specification { */ protected function getSize($fieldXML) { // Extract from tag if supplied - if ($this->value('size', $fieldXML)) { - $const = 'CRM_Utils_Type::' . strtoupper($fieldXML->size); + if (!empty($fieldXML->html) && $this->value('size', $fieldXML->html)) { + $const = 'CRM_Utils_Type::' . strtoupper($fieldXML->html->size); if (defined($const)) { return $const; } diff --git a/xml/templates/dao.tpl b/xml/templates/dao.tpl index f6e7ad545a..270e7ca494 100644 --- a/xml/templates/dao.tpl +++ b/xml/templates/dao.tpl @@ -220,6 +220,15 @@ class {$table.className} extends CRM_Core_DAO {ldelim} {if $field.FKClassName} 'FKClassName' => '{$field.FKClassName}', {/if} {* field.FKClassName *} +{if $field.html} + {assign var=htmlOptions value=$field.html} + 'html' => array( +{*{$htmlOptions|@print_array}*} + {foreach from=$htmlOptions key=optionKey item=optionValue} + '{$optionKey}' => '{$optionValue}', + {/foreach} + ), +{/if} {* field.html *} {if $field.pseudoconstant} {assign var=pseudoOptions value=$field.pseudoconstant} 'pseudoconstant' => array( -- 2.25.1