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-2012 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 ********************************************************************************/
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) {
90 function displayHeaderCellPlain($layout_def)
92 if (!empty ($layout_def['label'])) {
93 return $layout_def['label'];
95 if (!empty ($layout_def['vname'])) {
96 return translate($layout_def['vname'], $this->layout_manager->getAttribute('module_name'));
101 function displayHeaderCell($layout_def) {
102 $module_name = $this->layout_manager->getAttribute('module_name');
104 $this->local_current_module = $_REQUEST['module'];
105 $this->is_dynamic = true;
106 // don't show sort links if name isn't defined
107 if ((empty ($layout_def['name']) || (isset ($layout_def['sortable']) && !$layout_def['sortable']))
108 && !empty ($layout_def['label'])) {
109 return $layout_def['label'];
111 if (isset ($layout_def['sortable']) && !$layout_def['sortable']) {
112 return $this->displayHeaderCellPlain($layout_def);
115 $header_cell_text = $this->displayHeaderCellPlain($layout_def);
117 $subpanel_module = $layout_def['subpanel_module'];
118 $html_var = $subpanel_module . "_CELL";
119 if (empty ($this->base_URL)) {
120 $this->base_URL = ListView :: getBaseURL($html_var);
121 $split_url = explode('&to_pdf=true&action=SubPanelViewer&subpanel=', $this->base_URL);
122 $this->base_URL = $split_url[0];
123 $this->base_URL .= '&inline=true&to_pdf=true&action=SubPanelViewer&subpanel=';
125 $sort_by_name = $layout_def['name'];
126 if (isset ($layout_def['sort_by'])) {
127 $sort_by_name = $layout_def['sort_by'];
130 $sort_by = ListView :: getSessionVariableName($html_var, "ORDER_BY").'='.$sort_by_name;
132 $start = (empty ($layout_def['start_link_wrapper'])) ? '' : $layout_def['start_link_wrapper'];
133 $end = (empty ($layout_def['end_link_wrapper'])) ? '' : $layout_def['end_link_wrapper'];
135 $header_cell = "<a class=\"listViewThLinkS1\" href=\"".$start.$this->base_URL.$subpanel_module.'&'.$sort_by.$end."\">";
136 $header_cell .= $header_cell_text;
140 if (isset ($layout_def['sort'])) {
141 $imgArrow = $layout_def['sort'];
144 $arrow_start = ListView::getArrowUpDownStart($imgArrow);
145 $arrow_end = ListView::getArrowUpDownEnd($imgArrow);
146 $header_cell .= " ".$arrow_start.$arrow_end."</a>";
152 function displayList($layout_def) {
153 return $this->displayListPlain($layout_def);
156 function displayListPlain($layout_def) {
157 $value= $this->_get_list_value($layout_def);
158 if (isset($layout_def['widget_type']) && $layout_def['widget_type'] =='checkbox') {
159 if ($value != '' && ($value == 'on' || intval($value) == 1 || $value == 'yes'))
161 return "<input name='checkbox_display' class='checkbox' type='checkbox' disabled='true' checked>";
163 return "<input name='checkbox_display' class='checkbox' type='checkbox' disabled='true'>";
168 function _get_list_value(& $layout_def)
171 if ( isset($layout_def['varname']) ) {
172 $key = strtoupper($layout_def['varname']);
175 $key = strtoupper($this->_get_column_alias($layout_def));
178 if ( isset($layout_def['fields'][$key]) ) {
179 return $layout_def['fields'][$key];
185 function & displayEditLabel($layout_def) {
189 function & displayEdit($layout_def) {
193 function & displaySearchLabel($layout_def) {
197 function & displaySearch($layout_def) {
201 function displayInput($layout_def) {
202 return ' -- Not Implemented --';
205 function getVardef($layout_def) {
206 $myName = $layout_def['column_key'];
207 $vardef = $this->layout_manager->defs['reporter']->all_fields[$myName];
209 if ( !isset($vardef) ) {
210 // No vardef, return an empty array