2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 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 ********************************************************************************/
39 require_once('include/ListView/ListViewDisplay.php');
42 require_once('include/contextMenus/contextMenu.php');
44 class ListViewSmarty extends ListViewDisplay{
47 var $ss; // the smarty object
49 var $searchColumns; // set by view.list.php
55 var $mailMerge = true;
56 var $multiSelect = true;
58 var $quickViewLinks = true;
60 var $mergeduplicates = true;
61 var $contextMenus = true;
62 var $showMassupdateFields = true;
64 * Constructor, Smarty object immediately available after
67 function ListViewSmarty() {
68 parent::ListViewDisplay();
69 $this->ss = new Sugar_Smarty();
73 * Processes the request. Calls ListViewData process. Also assigns all lang strings, export links,
74 * This is called from ListViewDisplay
76 * @param file file Template file to use
77 * @param data array from ListViewData
78 * @param html_var string the corresponding html var in xtpl per row
81 function process($file, $data, $htmlVar) {
82 if(!$this->should_process)return;
83 global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings;
84 parent::process($file, $data, $htmlVar);
90 foreach($this->displayColumns as $name => $params) {
91 $totalWidth += $params['width'];
93 $adjustment = $totalWidth / 100;
95 $contextMenuObjectsTypes = array();
96 foreach($this->displayColumns as $name => $params) {
97 $this->displayColumns[$name]['width'] = floor($this->displayColumns[$name]['width'] / $adjustment);
98 // figure out which contextMenu objectsTypes are required
99 if(!empty($params['contextMenu']['objectType']))
100 $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true;
102 $this->ss->assign('displayColumns', $this->displayColumns);
103 $this->ss->assign('APP',$app_strings);
105 $this->ss->assign('bgHilite', $hilite_bg);
106 $this->ss->assign('colCount', count($this->displayColumns) + 10);
107 $this->ss->assign('htmlVar', strtoupper($htmlVar));
108 $this->ss->assign('moduleString', $this->moduleString);
109 $this->ss->assign('editLinkString', $app_strings['LBL_EDIT_BUTTON']);
110 $this->ss->assign('viewLinkString', $app_strings['LBL_VIEW_BUTTON']);
111 $this->ss->assign('allLinkString',$app_strings['LBL_LINK_ALL']);
112 $this->ss->assign('noneLinkString',$app_strings['LBL_LINK_NONE']);
113 $this->ss->assign('recordsLinkString',$app_strings['LBL_LINK_RECORDS']);
114 $this->ss->assign('selectLinkString',$app_strings['LBL_LINK_SELECT']);
115 if($this->overlib) $this->ss->assign('overlib', true);
117 $pageTotal = $this->data['pageData']['offsets']['next'] - $this->data['pageData']['offsets']['current'];
118 if($this->data['pageData']['offsets']['next'] < 0){ // If we are on the last page, 'next' is -1, which means we have to have a custom calculation
119 $pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current'];
121 if($this->select)$this->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal));
123 if($this->show_action_dropdown)
125 $this->ss->assign('actionsLink', $this->buildActionsLink());
128 $this->ss->assign('quickViewLinks', $this->quickViewLinks);
130 // handle save checks and stuff
131 if($this->multiSelect) {
133 //if($this->data['pageData']['bean']['moduleDir']== 'KBDocuments')
135 // $this->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan(true, $this->data['pageData']['offsets']['current']));
137 $this->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan(true, $this->data['pageData']['offsets']['total']));
140 $this->ss->assign('multiSelectData', $this->getMultiSelectData());
142 // include button for Adding to Target List if in one of four applicable modules
143 if ( isset ( $_REQUEST['module']) && in_array ( $_REQUEST['module'] , array ( 'Contacts','Prospects','Leads','Accounts' )))
144 $this->ss->assign( 'targetLink', $this->buildTargetList() ) ;
145 $this->processArrows($data['pageData']['ordering']);
146 $this->ss->assign('prerow', $this->multiSelect);
147 $this->ss->assign('clearAll', $app_strings['LBL_CLEARALL']);
148 $this->ss->assign('rowColor', array('oddListRow', 'evenListRow'));
149 $this->ss->assign('bgColor', array($odd_bg, $even_bg));
150 $this->ss->assign('contextMenus', $this->contextMenus);
151 $this->ss->assign('is_admin_for_user', is_admin_for_module($GLOBALS['current_user'],'Users'));
152 $this->ss->assign('is_admin', is_admin($GLOBALS['current_user']));
155 if($this->contextMenus && !empty($contextMenuObjectsTypes)) {
157 $cm = new contextMenu();
158 foreach($contextMenuObjectsTypes as $type => $value) {
159 $cm->loadFromFile($type);
160 $script .= $cm->getScript();
161 $cm->menuItems = array(); // clear menuItems out
163 $this->ss->assign('contextMenuScript', $script);
168 * Assigns the sort arrows in the tpl
170 * @param ordering array data that contains the ordering info
173 function processArrows($ordering)
175 $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false));
177 list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']);
179 $this->ss->assign('arrowExt', $pathParts['extension']);
180 $this->ss->assign('arrowWidth', $width);
181 $this->ss->assign('arrowHeight', $height);
182 $this->ss->assign('arrowAlt', translate('LBL_SORT'));
188 * Displays the xtpl, either echo or returning the contents
190 * @param end bool display the ending of the listview data (ie MassUpdate)
193 function display($end = true) {
195 if(!$this->should_process) return $GLOBALS['app_strings']['LBL_SEARCH_POPULATE_ONLY'];
197 $this->ss->assign('data', $this->data['data']);
198 $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
199 $this->ss->assign('pageData', $this->data['pageData']);
201 $navStrings = array('next' => $app_strings['LNK_LIST_NEXT'],
202 'previous' => $app_strings['LNK_LIST_PREVIOUS'],
203 'end' => $app_strings['LNK_LIST_END'],
204 'start' => $app_strings['LNK_LIST_START'],
205 'of' => $app_strings['LBL_LIST_OF']);
206 $this->ss->assign('navStrings', $navStrings);
208 $str = parent::display();
209 $strend = $this->displayEnd();
211 return $str . $this->ss->fetch($this->tpl) . (($end) ? $strend : '');
213 function displayEnd() {
215 if($this->show_mass_update_form) {
216 if($this->showMassupdateFields){
217 $str .= $this->mass->getMassUpdateForm(true);
219 $str .= $this->mass->endMassUpdateForm();