/modules/Vtiger/uitypes/Base.php

https://bitbucket.org/thomashii/vtigercrm-6-for-postgresql · PHP · 104 lines · 46 code · 12 blank · 46 comment · 4 complexity · 77b2c4baa0fb32ec6b27ad33978940fd MD5 · raw file

  1. <?php
  2. /*+***********************************************************************************
  3. * The contents of this file are subject to the vtiger CRM Public License Version 1.0
  4. * ("License"); You may not use this file except in compliance with the License
  5. * The Original Code is: vtiger CRM Open Source
  6. * The Initial Developer of the Original Code is vtiger.
  7. * Portions created by vtiger are Copyright (C) vtiger.
  8. * All Rights Reserved.
  9. *************************************************************************************/
  10. class Vtiger_Base_UIType extends Vtiger_Base_Model {
  11. /**
  12. * Function to get the Template name for the current UI Type Object
  13. * @return <String> - Template Name
  14. */
  15. public function getTemplateName() {
  16. return 'uitypes/String.tpl';
  17. }
  18. /**
  19. * Function to get the DB Insert Value, for the current field type with given User Value
  20. * @param <Object> $value
  21. * @return <Object>
  22. */
  23. public function getDBInsertValue($value) {
  24. return $value;
  25. }
  26. /**
  27. * Function to get the Value of the field in the format, the user provides it on Save
  28. * @param <Object> $value
  29. * @return <Object>
  30. */
  31. public function getUserRequestValue($value) {
  32. return $value;
  33. }
  34. /**
  35. * Function to get the Display Value, for the current field type with given DB Insert Value
  36. * @param <Object> $value
  37. * @return <Object>
  38. */
  39. public function getDisplayValue($value, $record=false, $recordInstance=false) {
  40. return $value;
  41. }
  42. /**
  43. * Static function to get the UIType object from Vtiger Field Model
  44. * @param Vtiger_Field_Model $fieldModel
  45. * @return Vtiger_Base_UIType or UIType specific object instance
  46. */
  47. public static function getInstanceFromField($fieldModel) {
  48. $fieldDataType = $fieldModel->getFieldDataType();
  49. $uiTypeClassSuffix = ucfirst($fieldDataType);
  50. $moduleName = $fieldModel->getModuleName();
  51. $moduleSpecificUiTypeClassName = $moduleName.'_'.$uiTypeClassSuffix.'_UIType';
  52. $uiTypeClassName = 'Vtiger_'.$uiTypeClassSuffix.'_UIType';
  53. $fallBackClassName = 'Vtiger_Base_UIType';
  54. $moduleSpecificFileName = 'modules.'. $moduleName .'.uitypes.'.$uiTypeClassSuffix;
  55. $uiTypeClassFileName = 'modules.Vtiger.uitypes.'.$uiTypeClassSuffix;
  56. $moduleSpecificFilePath = Vtiger_Loader::resolveNameToPath($moduleSpecificFileName);
  57. $completeFilePath = Vtiger_Loader::resolveNameToPath($uiTypeClassFileName);
  58. if(file_exists($moduleSpecificFilePath)) {
  59. $instance = new $moduleSpecificUiTypeClassName();
  60. }
  61. else if(file_exists($completeFilePath)) {
  62. $instance = new $uiTypeClassName();
  63. } else {
  64. $instance = new $fallBackClassName();
  65. }
  66. $instance->set('field', $fieldModel);
  67. return $instance;
  68. }
  69. /**
  70. * Function to get the display value in edit view
  71. * @param reference record id
  72. * @return link
  73. */
  74. public function getEditViewDisplayValue($value) {
  75. return $value;
  76. }
  77. /**
  78. * Function to get the Detailview template name for the current UI Type Object
  79. * @return <String> - Template Name
  80. */
  81. public function getDetailViewTemplateName() {
  82. return 'uitypes/StringDetailView.tpl';
  83. }
  84. /**
  85. * Function to get Display value for RelatedList
  86. * @param <String> $value
  87. * @return <String>
  88. */
  89. public function getRelatedListDisplayValue($value) {
  90. return $this->getDisplayValue($value);
  91. }
  92. }