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-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
40 * Connector's HTML helper
43 class ConnectorHtmlHelper
46 * Method return the HTML code for the hover link field
48 * @param array $shown_sources
49 * @param mixed $module
50 * @param mixed $smarty
53 public function getConnectorButtonCode(array $shown_sources, $module, $smarty)
55 require_once('include/connectors/formatters/FormatterFactory.php');
57 //If there is only one source, just show the icon or some standalone view
58 if (count($shown_sources) == 1)
60 $code = $this->getButton($shown_sources[0], $module, $smarty);
64 $code = $this->getPopup($shown_sources, $module, $smarty);
71 * Get button for source
73 * @param string $shown_source
74 * @param mixed $module
75 * @param mixed $smarty
78 private function getButton($shown_source, $module, $smarty)
82 $formatter = FormatterFactory::getInstance($shown_source);
83 $formatter->setModule($module);
84 $formatter->setSmarty($smarty);
85 $formatter_code = $formatter->getDetailViewFormat();
86 if (!empty($formatter_code))
88 $iconFilePath = $formatter->getIconFilePath();
89 $iconFilePath = empty($iconFilePath) ? 'themes/default/images/MoreDetail.png' : $iconFilePath;
91 $code = '<!--not_in_theme!--><img id="dswidget_img" border="0" src="' . $iconFilePath .'" alt="'
92 . $shown_source .'" onmouseover="show_' . $shown_source . '(event);">';
94 $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>";
95 $code .= $formatter->getDetailViewFormat();
96 $code .= $formatter_code;
103 * Get popup for sources
105 * @param array $shown_sources
106 * @param mixed $module
107 * @param mixed $smarty
110 private function getPopup(array $shown_sources, $module, $smarty)
115 $menuParams = 'var menuParams = "';
117 $sourcesDisplayed = 0;
119 foreach($shown_sources as $id)
121 $formatter = FormatterFactory::getInstance($id);
122 $formatter->setModule($module);
123 $formatter->setSmarty($smarty);
124 $buttonCode = $formatter->getDetailViewFormat();
125 if (!empty($buttonCode))
128 $singleIcon = $formatter->getIconFilePath();
129 $source = SourceFactory::getSource($id);
130 $config = $source->getConfig();
131 $name = !empty($config['name']) ? $config['name'] : $id;
132 //Create the menu item to call show_[source id] method in javascript
133 $menuParams .= '<a href=\'#\' style=\'width:150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\''
134 . ' onmouseout=\'unhiliteItem(this);\' onclick=\'show_' . $id . '(event);\'>' . $name . '</a>';
135 $formatterCode .= $buttonCode;
139 if (!empty($formatterCode))
141 if ($sourcesDisplayed > 1)
143 $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
144 $code = '<!--not_in_theme!--><img id="dswidget_img" src="' . $dswidget_img . '" width="11" height="7" border="0" alt="'
145 . $app_strings['LBL_CONNECTORS_POPUPS'] . '" onclick="return showConnectorMenu2(this);">';
149 $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
150 $singleIcon = empty($singleIcon) ? $dswidget_img : $singleIcon;
151 $code = '<!--not_in_theme!--><img id="dswidget_img" border="0" src="' . $singleIcon . '" alt="'.$app_strings['LBL_CONNECTORS_POPUPS']
152 . '" onclick="return showConnectorMenu2(this);">';
155 $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>\n";
156 $code .= "<script type='text/javascript'>\n";
157 $code .= "function showConnectorMenu2(el) {literal} { {/literal}\n";
160 $code .= $menuParams . "\n";
161 $code .= "return SUGAR.util.showHelpTips(el,menuParams);\n";
162 $code .= "{literal} } {/literal}\n";
163 $code .= "</script>\n";
164 $code .= $formatterCode;