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 * Contains a variety of utility functions used to display UI components such as form headers and footers.
42 * @todo refactor out these functions into the base UI objects as indicated
46 * Create HTML to display formatted form title.
48 * @param $form_title string to display as the title in the header
49 * @param $other_text string to next to the title. Typically used for form buttons.
50 * @param $show_help boolean which determines if the print and help links are shown.
53 function get_form_header(
59 global $sugar_version, $sugar_flavor, $server_unique_key, $current_language, $current_module, $current_action;
62 $blankImageURL = SugarThemeRegistry::current()->getImageURL('blank.gif');
63 $printImageURL = SugarThemeRegistry::current()->getImageURL("print.gif");
64 $helpImageURL = SugarThemeRegistry::current()->getImageURL("help.gif");
66 $is_min_max = strpos($other_text,"_search.gif");
67 if($is_min_max !== false)
68 $form_title = "{$other_text} {$form_title}";
71 <table width="100%" cellpadding="0" cellspacing="0" border="0" class="formHeader h3Row">
73 <td nowrap><h3><span>{$form_title}</span></h3></td>
76 $keywords = array("/class=\"button\"/","/class='button'/","/class=button/","/<\/form>/");
78 foreach ($keywords as $left)
79 if (preg_match($left,$other_text))
82 if ($other_text && $match) {
83 $the_form .= <<<EOHTML
84 <td colspan='10' width='100%'><IMG height='1' width='1' src='$blankImageURL' alt=''></td>
87 <td width='100%' align='left' valign='middle' nowrap style='padding-bottom: 2px;'>$other_text</td>
90 $the_form .= "<td align='right' nowrap>";
91 if ($_REQUEST['action'] != "EditView") {
92 $the_form .= <<<EOHTML
93 <a href='index.php?{$GLOBALS['request_string']}' class='utilsLink'>
94 <img src='{$printImageURL}' alt='{$app_strings["LBL_PRINT"]}' border='0' align='absmiddle'>
96 <a href='index.php?{$GLOBALS['request_string']}' class='utilsLink'>
97 {$app_strings['LNK_PRINT']}
101 $the_form .= <<<EOHTML
103 <a href='index.php?module=Administration&action=SupportPortal&view=documentation&version={$sugar_version}&edition={$sugar_flavor}&lang={$current_language}&help_module={$current_module}&help_action={$current_action}&key={$server_unique_key}'
104 class='utilsLink' target='_blank'>
105 <img src='{$helpImageURL}' alt='Help' border='0' align='absmiddle'>
107 <a href='index.php?module=Administration&action=SupportPortal&view=documentation&version={$sugar_version}&edition={$sugar_flavor}&lang={$current_language}&help_module={$current_module}&help_action={$current_action}&key={$server_unique_key}'
108 class='utilsLink' target='_blank'>
109 {$app_strings['LNK_HELP']}
116 if ($other_text && $is_min_max === false) {
117 $the_form .= <<<EOHTML
118 <td width='20'><img height='1' width='20' src='$blankImageURL' alt=''></td>
119 <td valign='middle' nowrap width='100%'>$other_text</td>
123 $the_form .= <<<EOHTML
124 <td width='100%'><IMG height='1' width='1' src='$blankImageURL' alt=''></td>
129 $the_form .= "<td align='right' nowrap>";
130 if ($_REQUEST['action'] != "EditView") {
131 $the_form .= <<<EOHTML
132 <a href='index.php?{$GLOBALS['request_string']}' class='utilsLink'>
133 <img src='{$printImageURL}' alt='{$app_strings['LBL_PRINT']}' border='0' align='absmiddle'>
135 <a href='index.php?{$GLOBALS['request_string']}' class='utilsLink'>
136 {$app_strings['LNK_PRINT']}</a>
139 $the_form .= <<<EOHTML
141 <a href='index.php?module=Administration&action=SupportPortal&view=documentation&version={$sugar_version}&edition={$sugar_flavor}&lang={$current_language}&help_module={$current_module}&help_action={$current_action}&key={$server_unique_key}'
142 class='utilsLink' target='_blank'>
143 <img src='{$helpImageURL}' alt='{$app_strings['LBL_HELP']}' border='0' align='absmiddle'>
145 <a href='index.php?module=Administration&action=SupportPortal&view=documentation&version={$sugar_version}&edition={$sugar_flavor}&lang={$current_language}&help_module={$current_module}&help_action={$current_action}&key={$server_unique_key}'
146 class='utilsLink' target='_blank'>{$app_strings['LNK_HELP']}</a>
152 $the_form .= <<<EOHTML
161 * Wrapper function for the get_module_title function, which is mostly used for pre-MVC modules.
163 * @deprecated use SugarView::getModuleTitle() for MVC modules, or getClassicModuleTitle() for non-MVC modules
165 * @param $module string to next to the title. Typically used for form buttons.
166 * @param $module_title string to display as the module title
167 * @param $show_help boolean which determines if the print and help links are shown.
168 * @return string HTML
170 function get_module_title(
177 global $sugar_version, $sugar_flavor, $server_unique_key, $current_language, $action;
180 $the_title = "<div class='moduleTitle'>\n";
181 $module = preg_replace("/ /","",$module);
183 if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false)))
185 $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
186 } else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false)))
188 $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
190 if (!empty($iconPath)) {
191 $the_title .= '<h2>';
192 if (SugarThemeRegistry::current()->directionality == "ltr") {
193 $the_title .= "<a href='index.php?module={$module}&action=index'><img src='{$iconPath}' " . "alt='".$module."' title='".$module."' align='absmiddle'></a>";
194 $the_title .= ($count >= 1) ? SugarView::getBreadCrumbSymbol() : "";
195 $the_title .= $module_title.'';
197 $the_title .= $module_title;
198 $the_title .= ($count > 1) ? SugarView::getBreadCrumbSymbol() : "";
199 $the_title .= "<a href='index.php?module={$module}&action=index'><img src='{$iconPath}' " . "alt='".$module."' title='".$module."' align='absmiddle'></a>";
201 $the_title .= '</h2>';
203 $the_title .="<h2> $module_title </h2>";
208 $the_title .= "<span class='utils'>";
209 $createRecordURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
210 $the_title .= <<<EOHTML
212 <a href="index.php?module={$module}&action=EditView&return_module={$module}&return_action=DetailView" class="utilsLink">
213 <img src='{$createRecordURL}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'></a>
214 <a href="index.php?module={$module}&action=EditView&return_module={$module}&return_action=DetailView" class="utilsLink">
215 {$GLOBALS['app_strings']['LNK_CREATE']}
219 $the_title .= '</span>';
222 $the_title .= "</div>\n";
227 * Handles displaying the header for classic view modules
229 * @param $module String value of the module to create the title section for
230 * @param $params Array of arguments used to create the title label. Typically this is just the current language string label for the section
231 * These should be in the form of array('label' => '<THE LABEL>', 'link' => '<HREF TO LINK TO>');
232 * the first breadcrumb should be index at 0, and built from there e.g.
235 * '<a href="index.php?module=Contacts&action=index">Contacts</a>',
236 * '<a href="index.php?module=Contacts&action=DetailView&record=123">John Smith</a>',
241 * <a href='index.php?module=Contacts&action=index'>Contacts</a> >> <a href='index.php?module=Contacts&action=DetailView&record=123'>John Smith</a> >> Edit
242 * @param $show_create boolean flag indicating whether or not to display the create link (defaults to false)
243 * @param $index_url_override String value of url to override for module index link (defaults to module's index action if none supplied)
244 * @param $create_url_override String value of url to override for module create link (defaults to EditView action if none supplied)
246 * @return String HTML content for a classic module title section
248 function getClassicModuleTitle($module, $params, $show_create=false, $index_url_override='', $create_url_override='')
250 global $sugar_version, $sugar_flavor, $server_unique_key, $current_language, $action;
256 $module = preg_replace("/ /","",$module);
258 $the_title = "<div class='moduleTitle'>\n";
260 if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false)))
262 $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
263 } else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false)))
265 $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
267 if (!empty($iconPath)) {
268 $url = (!empty($index_url_override)) ? $index_url_override : "index.php?module={$module}&action=index";
269 array_unshift ($params,"<a href='{$url}'><img src='{$iconPath}' ". "alt='".$module."' title='".$module."' align='absmiddle'></a>");
272 $new_params = array_pop($params);
273 if(!is_null($new_params) && ($new_params !== "")) $module_title = $new_params;
274 if(!empty($module_title)){
275 $the_title .= "<h2>".$module_title."</h2>\n";//removing empty H2 tag for 508 compliance
280 $the_title .= "<span class='utils'>";
281 $createRecordImage = SugarThemeRegistry::current()->getImageURL('create-record.gif');
282 if(empty($create_url_override))
284 $create_url_override = "index.php?module={$module}&action=EditView&return_module={$module}&return_action=DetailView";
287 $the_title .= <<<EOHTML
289 <a href="{$create_url_override}" class="utilsLink">
290 <img src='{$createRecordImage}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'></a>
291 <a href="{$create_url_override}" class="utilsLink">
292 {$GLOBALS['app_strings']['LNK_CREATE']}
296 $the_title .= '</span>';
299 $the_title .= "<div class='clear'></div></div>\n";
305 * Create a header for a popup.
307 * @todo refactor this into the base Popup_Picker class
309 * @param $theme string the name of the current theme, ignorred to use SugarThemeRegistry::current() instead.
310 * @return string HTML
312 function insert_popup_header(
317 global $app_strings, $sugar_config;
319 $themeCSS = SugarThemeRegistry::current()->getCSS();
321 $langHeader = get_language_header();
323 //The SugarView will insert the header now, this function should no longer do the actual head element.
327 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
333 if (isset($sugar_config['meta_tags']) && isset($sugar_config['meta_tags']['IE_COMPAT_MODE']))
335 echo $sugar_config['meta_tags']['IE_COMPAT_MODE'];
338 echo "<title>{$app_strings['LBL_BROWSER_TITLE']}</title>" . $themeCSS;
341 $charset = isset($app_strings['LBL_CHARSET']) ? $app_strings['LBL_CHARSET'] : $sugar_config['default_charset'];
342 echo '<meta http-equiv="Content-Type" content="text/html; charset="{$charset}">';
343 echo '<script type="text/javascript" src="' . getJSPath('cache/include/javascript/sugar_grp1_yui.js') . '"></script>';
344 echo '<script type="text/javascript" src="' . getJSPath('cache/include/javascript/sugar_grp1.js') . '"></script>';
347 echo '<body class="popupBody">';
351 * Create a footer for a popup.
353 * @todo refactor this into the base Popup_Picker class
355 * @return string HTML
357 function insert_popup_footer()