PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/include/connectors/formatters/default/formatter.php

https://gitlab.com/tjaafar/SuiteCRM
PHP | 155 lines | 95 code | 19 blank | 41 comment | 18 complexity | c14b9fa9351719a62db5bcc4df5a14db MD5 | raw file
  1. <?php
  2. if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
  3. /*********************************************************************************
  4. * SugarCRM Community Edition is a customer relationship management program developed by
  5. * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
  6. * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
  7. * Copyright (C) 2011 - 2014 Salesagility Ltd.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it under
  10. * the terms of the GNU Affero General Public License version 3 as published by the
  11. * Free Software Foundation with the addition of the following permission added
  12. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  13. * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
  14. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  15. *
  16. * This program is distributed in the hope that it will be useful, but WITHOUT
  17. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  18. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  19. * details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License along with
  22. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  23. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  24. * 02110-1301 USA.
  25. *
  26. * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
  27. * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
  28. *
  29. * The interactive user interfaces in modified source and object code versions
  30. * of this program must display Appropriate Legal Notices, as required under
  31. * Section 5 of the GNU Affero General Public License version 3.
  32. *
  33. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  34. * these Appropriate Legal Notices must retain the display of the "Powered by
  35. * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
  36. * reasonably feasible for technical reasons, the Appropriate Legal Notices must
  37. * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
  38. ********************************************************************************/
  39. /**
  40. * Generic formatter
  41. * @api
  42. */
  43. class default_formatter {
  44. protected $_ss;
  45. protected $_component;
  46. protected $_tplFileName;
  47. protected $_module;
  48. protected $_hoverField;
  49. public function __construct() {}
  50. public function getDetailViewFormat() {
  51. $source = $this->_component->getSource();
  52. $class = get_class($source);
  53. $dir = str_replace('_', '/', $class);
  54. $config = $source->getConfig();
  55. $this->_ss->assign('config', $config);
  56. $this->_ss->assign('source', $class);
  57. $this->_ss->assign('module', $this->_module);
  58. $mapping = $source->getMapping();
  59. $mapping = !empty($mapping['beans'][$this->_module]) ? implode(',', array_values($mapping['beans'][$this->_module])) : '';
  60. $this->_ss->assign('mapping', $mapping);
  61. if(file_exists("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl")) {
  62. return $this->_ss->fetch("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl");
  63. } else if(file_exists("modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl")) {
  64. return $this->_ss->fetch("modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl");
  65. } else if(file_exists("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/default.tpl")) {
  66. return $this->_ss->fetch("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/default.tpl");
  67. } else if(file_exists("modules/Connectors/connectors/formatters/{$dir}/tpls/default.tpl")) {
  68. return $this->_ss->fetch("modules/Connectors/connectors/formatters/{$dir}/tpls/default.tpl");
  69. } else if(preg_match('/_soap_/', $class)) {
  70. return $this->_ss->fetch("include/connectors/formatters/ext/soap/tpls/default.tpl");
  71. } else {
  72. return $this->_ss->fetch("include/connectors/formatters/ext/rest/tpls/default.tpl");
  73. }
  74. }
  75. public function getEditViewFormat() {
  76. return '';
  77. }
  78. public function getListViewFormat() {
  79. return '';
  80. }
  81. public function getSearchFormFormat() {
  82. return '';
  83. }
  84. protected function fetchSmarty(){
  85. $source = $this->_component->getSource();
  86. $class = get_class($source);
  87. $dir = str_replace('_', '/', $class);
  88. $config = $source->getConfig();
  89. $this->_ss->assign('config', $config);
  90. $this->_ss->assign('source', $class);
  91. $this->_ss->assign('module', $this->_module);
  92. if(file_exists("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl")) {
  93. return $this->_ss->fetch("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl");
  94. } else if(file_exists("modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl")) {
  95. return $this->_ss->fetch("modules/Connectors/connectors/formatters/{$dir}/tpls/{$this->_module}.tpl");
  96. } else if(file_exists("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/default.tpl")) {
  97. return $this->_ss->fetch("custom/modules/Connectors/connectors/formatters/{$dir}/tpls/default.tpl");
  98. } else {
  99. return $this->_ss->fetch("modules/Connectors/connectors/formatters/{$dir}/tpls/default.tpl");
  100. }
  101. }
  102. public function getSourceMapping(){
  103. $source = $this->_component->getSource();
  104. $mapping = $source->getMapping();
  105. return $mapping;
  106. }
  107. public function setSmarty($smarty) {
  108. $this->_ss = $smarty;
  109. }
  110. public function getSmarty() {
  111. return $this->_ss;
  112. }
  113. public function setComponent($component) {
  114. $this->_component = $component;
  115. }
  116. public function getComponent() {
  117. return $this->_component;
  118. }
  119. public function getTplFileName(){
  120. return $this->tplFileName;
  121. }
  122. public function setTplFileName($tplFileName){
  123. $this->tplFileName = $tplFileName;
  124. }
  125. public function setModule($module) {
  126. $this->_module = $module;
  127. }
  128. public function getModule() {
  129. return $this->_module;
  130. }
  131. public function getIconFilePath() {
  132. return '';
  133. }
  134. }
  135. ?>