X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=xml%2Ftemplates%2Fdao.tpl;h=be5768e58a310e52faa7f1321b784ba614db14d3;hb=e6662685fd5a0b66e910e6c9d840f78af1727219;hp=270e7ca4949fae4d1eebbf39d5eee60b27c0334a;hpb=b987fa2b9f45bbfb37bfcebe9a846c003251e933;p=civicrm-core.git diff --git a/xml/templates/dao.tpl b/xml/templates/dao.tpl index 270e7ca494..be5768e58a 100644 --- a/xml/templates/dao.tpl +++ b/xml/templates/dao.tpl @@ -2,9 +2,9 @@ /* +--------------------------------------------------------------------+ - | CiviCRM version 4.4 | + | CiviCRM version 4.5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2013 | + | Copyright CiviCRM LLC (c) 2004-2014 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -29,7 +29,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2013 + * @copyright CiviCRM LLC (c) 2004-2014 * * Generated from {$table.sourceFile} * {$generated} @@ -137,19 +137,18 @@ class {$table.className} extends CRM_Core_DAO {ldelim} * * @static * @access public - * @return array of CRM_Core_EntityReference + * @return array of CRM_Core_Reference_Interface */ static function getReferenceColumns() {ldelim} if (!self::$_links) {ldelim} - self::$_links = array( + self::$_links = static::createReferenceColumns(__CLASS__); {foreach from=$table.foreignKey item=foreign} - new CRM_Core_EntityReference(self::getTableName(), '{$foreign.name}', '{$foreign.table}', '{$foreign.key}'), + self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName(), '{$foreign.name}', '{$foreign.table}', '{$foreign.key}'); {/foreach} {foreach from=$table.dynamicForeignKey item=foreign} - new CRM_Core_EntityReference(self::getTableName(), '{$foreign.idColumn}', NULL, '{$foreign.key|default:'id'}', '{$foreign.typeColumn}'), + self::$_links[] = new CRM_Core_Reference_Dynamic(self::getTableName(), '{$foreign.idColumn}', NULL, '{$foreign.key|default:'id'}', '{$foreign.typeColumn}'); {/foreach} - ); {rdelim} return self::$_links; {rdelim} @@ -183,6 +182,9 @@ class {$table.className} extends CRM_Core_DAO {ldelim} {if $field.length} 'maxlength' => {$field.length}, {/if} {* field.length *} +{if $field.precision} + 'precision' => array({$field.precision}), +{/if} {if $field.size} 'size' => {$field.size}, {/if} {* field.size *} @@ -213,9 +215,6 @@ class {$table.className} extends CRM_Core_DAO {ldelim} {if $field.default} 'default' => '{if ($field.default[0]=="'" or $field.default[0]=='"')}{$field.default|substring:1:-1}{else}{$field.default}{/if}', {/if} {* field.default *} -{if $field.enumValues} - 'enumValues' => '{$field.enumValues}', -{/if} {* field.enumValues *} {if $field.FKClassName} 'FKClassName' => '{$field.FKClassName}', @@ -357,65 +356,6 @@ class {$table.className} extends CRM_Core_DAO {ldelim} return self::$_export; {rdelim} -{if $table.hasEnum} - /** - * returns an array containing the enum fields of the {$table.name} table - * - * @return array (reference) the array of enum fields - */ - static function &getEnums() {ldelim} - static $enums = array( - {foreach from=$table.fields item=field} - {if $field.crmType == 'CRM_Utils_Type::T_ENUM'} - '{$field.name}', - {/if} - {/foreach} - ); - return $enums; - {rdelim} - - /** - * returns a ts()-translated enum value for display purposes - * - * @param string $field the enum field in question - * @param string $value the enum value up for translation - * - * @return string the display value of the enum - */ - static function tsEnum($field, $value) {ldelim} - static $translations = null; - if (!$translations) {ldelim} - $translations = array( - {foreach from=$table.fields item=field} - {if $field.crmType == 'CRM_Utils_Type::T_ENUM'} - '{$field.name}' => array( - {foreach from=$field.values item=value} - '{$value}' => ts('{$value}'), - {/foreach} - ), - {/if} - {/foreach} - ); - {rdelim} - return $translations[$field][$value]; - {rdelim} - - /** - * adds $value['foo_display'] for each $value['foo'] enum from {$table.name} - * - * @param array $values (reference) the array up for enhancing - * @return void - */ - static function addDisplayEnums(&$values) {ldelim} - $enumFields =& {$table.className}::getEnums(); - foreach ($enumFields as $enum) {ldelim} - if (isset($values[$enum])) {ldelim} - $values[$enum.'_display'] = {$table.className}::tsEnum($enum, $values[$enum]); - {rdelim} - {rdelim} - {rdelim} -{/if} - {rdelim}