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-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 ********************************************************************************/
40 * Created on Sep 10, 2007
42 * To change the template for this generated file go to
43 * Window - Preferences - PHPeclipse - PHP - Code Templates
45 require_once('include/ListView/ListViewSmarty.php');
49 * A Facade to ListView and ListViewSmarty
63 var $params = array();
66 var $filter_fields = array();
69 var $mod_strings = array();
73 * @param $focus - the bean
74 * @param $module - the module name
75 * @param - 0 = decide for me, 1 = ListView.html, 2 = ListViewSmarty
77 function ListViewFacade($focus, $module, $type = 0){
78 $this->focus = $focus;
79 $this->module = $module;
85 //we will assume that if the ListView.html file exists we will want to use that one
86 if(file_exists('modules/'.$this->module.'/ListView.html')){
88 $this->lv = new ListView();
89 $this->template = 'modules/'.$this->module.'/ListView.html';
92 $foundViewDefs = false;
93 if(file_exists('custom/modules/' . $this->module. '/metadata/listviewdefs.php')){
94 $metadataFile = 'custom/modules/' . $this->module . '/metadata/listviewdefs.php';
95 $foundViewDefs = true;
97 if(file_exists('custom/modules/'. $this->module.'/metadata/metafiles.php')){
98 require_once('custom/modules/'. $this->module.'/metadata/metafiles.php');
99 if(!empty($metafiles[ $this->module]['listviewdefs'])){
100 $metadataFile = $metafiles[ $this->module]['listviewdefs'];
101 $foundViewDefs = true;
103 }elseif(file_exists('modules/'. $this->module.'/metadata/metafiles.php')){
104 require_once('modules/'. $this->module.'/metadata/metafiles.php');
105 if(!empty($metafiles[ $this->module]['listviewdefs'])){
106 $metadataFile = $metafiles[ $this->module]['listviewdefs'];
107 $foundViewDefs = true;
111 if(!$foundViewDefs && file_exists('modules/'. $this->module.'/metadata/listviewdefs.php')){
112 $metadataFile = 'modules/'. $this->module.'/metadata/listviewdefs.php';
114 require_once($metadataFile);
117 $this->lv = new ListViewSmarty();
118 $displayColumns = array();
119 if(!empty($_REQUEST['displayColumns'])) {
120 foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
121 if(!empty($listViewDefs[$this->module][$col]))
122 $displayColumns[$col] = $listViewDefs[$this->module][$col];
126 foreach($listViewDefs[$this->module] as $col => $params) {
127 if(!empty($params['default']) && $params['default'])
128 $displayColumns[$col] = $params;
131 $this->lv->displayColumns = $displayColumns;
133 $this->template = 'include/ListView/ListViewGeneric.tpl';
137 function setup($template = '', $where = '', $params = array(), $mod_strings = array(), $offset = 0, $limit = -1, $orderBy = '', $prefix = '', $filter_fields = array(), $id_field = 'id'){
138 if(!empty($template))
139 $this->template = $template;
141 $this->mod_strings = $mod_strings;
143 if($this->type == 1){
144 $this->lv->initNewXTemplate($this->template,$this->mod_strings);
145 $this->prefix = $prefix;
146 $this->lv->setQuery($where, $limit, $orderBy, $prefix);
147 $this->lv->show_select_menu = false;
148 $this->lv->show_export_button = false;
149 $this->lv->show_delete_button = false;
150 $this->lv->show_mass_update = false;
151 $this->lv->show_mass_update_form = false;
153 $this->lv->export = false;
154 $this->lv->delete = false;
155 $this->lv->select = false;
156 $this->lv->mailMerge = false;
157 $this->lv->multiSelect = false;
158 $this->lv->setup($this->focus, $this->template, $where, $params, $offset, $limit, $filter_fields, $id_field);
163 function display($title = '', $section = 'main'){
164 if($this->type == 1){
165 $this->lv->setHeaderTitle($title);
166 $this->lv->processListView($this->focus, $section, $this->prefix);
168 echo get_form_header($title, '', false);
169 echo $this->lv->display();
173 function setTitle($title = ''){
174 $this->title = $title;