2 if(!defined('sugarEntry') || !sugarEntry)
3 die('Not A Valid Entry Point');
4 /*********************************************************************************
5 * SugarCRM Community Edition is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
42 require_once ('include/generic/SugarWidgets/SugarWidget.php');
44 class SugarWidgetField extends SugarWidget {
46 function SugarWidgetField(&$layout_manager) {
47 parent::SugarWidget($layout_manager);
50 function display($layout_def) {
51 //print $layout_def['start_link_wrapper']."===";
52 $context = $this->layout_manager->getAttribute('context'); //_ppd($context);
53 $func_name = 'display'.$context;
55 if (!empty ($context) && method_exists($this, $func_name)) {
56 return $this-> $func_name ($layout_def);
58 return 'display not found:'.$func_name;
62 function _get_column_alias($layout_def) {
63 $alias_arr = array ();
65 if (!empty ($layout_def['name']) && $layout_def['name'] == 'count') {
69 if (!empty ($layout_def['table_alias'])) {
70 array_push($alias_arr, $layout_def['table_alias']);
73 if (!empty ($layout_def['name'])) {
74 array_push($alias_arr, $layout_def['name']);
77 return $this->getTruncatedColumnAlias(implode("_", $alias_arr));
80 function & displayDetailLabel(& $layout_def) {
85 function & displayDetail($layout_def) {
89 function displayHeaderCellPlain($layout_def) {
90 $module_name = $this->layout_manager->getAttribute('module_name');
91 $header_cell_text = '';
94 if (!empty ($layout_def['label'])) {
95 $header_cell_text = $layout_def['label'];
97 elseif (!empty ($layout_def['vname'])) {
98 $key = $layout_def['vname'];
101 $header_cell_text = $layout_def['name'];
103 $header_cell_text = translate($key, $module_name);
106 return $header_cell_text;
109 function displayHeaderCell($layout_def) {
110 $module_name = $this->layout_manager->getAttribute('module_name');
112 $this->local_current_module = $_REQUEST['module'];
113 $this->is_dynamic = true;
114 // don't show sort links if name isn't defined
115 if (empty ($layout_def['name'])) {
116 return $layout_def['label'];
118 if (isset ($layout_def['sortable']) && !$layout_def['sortable']) {
119 return $this->displayHeaderCellPlain($layout_def);
122 $header_cell_text = '';
125 if (!empty ($layout_def['vname'])) {
126 $key = $layout_def['vname'];
130 $header_cell_text = $layout_def['name'];
132 $header_cell_text = translate($key, $module_name);
135 $subpanel_module = $layout_def['subpanel_module'];
136 $html_var = $subpanel_module . "_CELL";
137 if (empty ($this->base_URL)) {
138 $this->base_URL = ListView :: getBaseURL($html_var);
139 $split_url = explode('&to_pdf=true&action=SubPanelViewer&subpanel=', $this->base_URL);
140 $this->base_URL = $split_url[0];
141 $this->base_URL .= '&inline=true&to_pdf=true&action=SubPanelViewer&subpanel=';
143 $sort_by_name = $layout_def['name'];
144 if (isset ($layout_def['sort_by'])) {
145 $sort_by_name = $layout_def['sort_by'];
148 $sort_by = ListView :: getSessionVariableName($html_var, "ORDER_BY").'='.$sort_by_name;
150 $start = (empty ($layout_def['start_link_wrapper'])) ? '' : $layout_def['start_link_wrapper'];
151 $end = (empty ($layout_def['end_link_wrapper'])) ? '' : $layout_def['end_link_wrapper'];
153 $header_cell = "<a class=\"listViewThLinkS1\" href=\"".$start.$this->base_URL.$subpanel_module.'&'.$sort_by.$end."\">";
154 $header_cell .= $header_cell_text;
155 $header_cell .= "</a>";
159 if (isset ($layout_def['sort'])) {
160 $imgArrow = $layout_def['sort'];
162 $arrow_start = ListView :: getArrowUpDownStart($imgArrow);
164 $header_cell .= " ".$arrow_start;
170 function displayList($layout_def) {
171 return $this->displayListPlain($layout_def);
174 function displayListPlain($layout_def) {
175 $value= $this->_get_list_value($layout_def);
176 if (isset($layout_def['widget_type']) && $layout_def['widget_type'] =='checkbox') {
177 if ($value != '' && ($value == 'on' || intval($value) == 1 || $value == 'yes'))
179 return "<input name='checkbox_display' class='checkbox' type='checkbox' disabled='true' checked>";
181 return "<input name='checkbox_display' class='checkbox' type='checkbox' disabled='true'>";
186 function _get_list_value(& $layout_def) {
190 if (isset ($layout_def['varname'])) {
191 $key = strtoupper($layout_def['varname']);
193 $key = $this->_get_column_alias($layout_def);
194 $key = strtoupper($key);
197 if (isset ($layout_def['fields'][$key])) {
198 return $layout_def['fields'][$key];
204 function & displayEditLabel($layout_def) {
208 function & displayEdit($layout_def) {
212 function & displaySearchLabel($layout_def) {
216 function & displaySearch($layout_def) {
220 function displayInput($layout_def) {
221 return ' -- Not Implemented --';
224 function getVardef($layout_def) {
225 $myName = $layout_def['column_key'];
226 $vardef = $this->layout_manager->defs['reporter']->all_fields[$myName];
228 if ( !isset($vardef) ) {
229 // No vardef, return an empty array