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 return $this->getButton($shown_sources, $module, $smarty);
61 * Get button for source
63 * @param string $shown_source
64 * @param mixed $module
65 * @param mixed $smarty
68 private function getButton(array $shown_sources, $module, $smarty)
72 foreach($shown_sources as $id) {
73 $formatter = FormatterFactory::getInstance($id);
74 $formatter->setModule($module);
75 $formatter->setSmarty($smarty);
76 $formatter_code = $formatter->getDetailViewFormat();
77 if (!empty($formatter_code))
79 $iconFilePath = $formatter->getIconFilePath();
80 $iconFilePath = empty($iconFilePath) ? 'themes/default/images/MoreDetail.png' : $iconFilePath;
83 $code .= '<!--not_in_theme!--><img id="dswidget_img" border="0" src="' . $iconFilePath .'" alt="'
84 . $id .'" onclick="show_' . $id . '(event);">';
86 $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>";
87 //$code .= $formatter->getDetailViewFormat();
88 $code .= $formatter_code;
96 * Get popup for sources
98 * @param array $shown_sources
99 * @param mixed $module
100 * @param mixed $smarty
103 private function getPopup(array $shown_sources, $module, $smarty)
108 $menuParams = 'var menuParams = "';
110 $sourcesDisplayed = 0;
112 foreach($shown_sources as $id)
114 $formatter = FormatterFactory::getInstance($id);
115 $formatter->setModule($module);
116 $formatter->setSmarty($smarty);
117 $buttonCode = $formatter->getDetailViewFormat();
118 if (!empty($buttonCode))
121 $singleIcon = $formatter->getIconFilePath();
122 $source = SourceFactory::getSource($id);
123 $config = $source->getConfig();
124 $name = !empty($config['name']) ? $config['name'] : $id;
125 //Create the menu item to call show_[source id] method in javascript
126 $menuParams .= '<a href=\'#\' style=\'width:150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\''
127 . ' onmouseout=\'unhiliteItem(this);\' onclick=\'show_' . $id . '(event);\'>' . $name . '</a>';
128 $formatterCode .= $buttonCode;
132 if (!empty($formatterCode))
134 if ($sourcesDisplayed > 1)
136 $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
137 $code = '<!--not_in_theme!--><img id="dswidget_img" src="' . $dswidget_img . '" width="11" height="7" border="0" alt="'
138 . $app_strings['LBL_CONNECTORS_POPUPS'] . '" onclick="return showConnectorMenu2(this);">';
142 $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
143 $singleIcon = empty($singleIcon) ? $dswidget_img : $singleIcon;
144 $code = '<!--not_in_theme!--><img id="dswidget_img" border="0" src="' . $singleIcon . '" alt="'.$app_strings['LBL_CONNECTORS_POPUPS']
145 . '" onclick="return showConnectorMenu2(this);">';
148 $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>\n";
149 $code .= "<script type='text/javascript'>\n";
150 $code .= "function showConnectorMenu2(el) {literal} { {/literal}\n";
153 $code .= $menuParams . "\n";
154 $code .= "return SUGAR.util.showHelpTips(el,menuParams);\n";
155 $code .= "{literal} } {/literal}\n";
156 $code .= "</script>\n";
157 $code .= $formatterCode;