| [ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 * The contents of this file are subject to the SugarCRM Public License Version 1.1.2 4 * ("License"); You may not use this file except in compliance with the 5 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL 6 * Software distributed under the License is distributed on an "AS IS" basis, 7 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 8 * the specific language governing rights and limitations under the License. 9 * The Original Code is: SugarCRM Open Source 10 * The Initial Developer of the Original Code is SugarCRM, Inc. 11 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; 12 * All Rights Reserved. 13 * Contributor(s): ______________________________________. 14 ********************************************************************************/ 15 /********************************************************************************* 16 * $Header$ 17 * Description: generic list view class. 18 ********************************************************************************/ 19 require_once ('include/logging.php'); 20 require_once ('include/ListView/ListViewSession.php'); 21 22 class ListView { 23 24 var $local_theme = null; 25 var $local_app_strings= null; 26 var $local_image_path = null; 27 var $local_current_module = null; 28 var $local_mod_strings = null; 29 var $records_per_page = 20; 30 var $xTemplate = null; 31 var $xTemplatePath = null; 32 var $seed_data = null; 33 var $query_where = null; 34 var $query_limit = -1; 35 var $query_orderby = null; 36 var $header_title = ""; 37 var $header_text = ""; 38 var $log = null; 39 var $initialized = false; 40 var $querey_where_has_changed = false; 41 var $display_header_and_footer = true; 42 43 44 /**initializes ListView 45 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 46 * All Rights Reserved. 47 * Contributor(s): ______________________________________. 48 */ 49 function ListView(){ 50 global $log; 51 $log->debug("Entering ListView() method ..."); 52 53 54 if(!$this->initialized){ 55 global $list_max_entries_per_page; 56 $this->records_per_page = $list_max_entries_per_page + 0; 57 $this->initialized = true; 58 global $theme, $app_strings, $image_path, $currentModule; 59 $this->local_theme = $theme; 60 $this->local_app_strings = &$app_strings; 61 $this->local_image_path = $image_path; 62 $this->local_current_module = $currentModule; 63 64 if(empty($this->local_image_path)){ 65 $this->local_image_path = 'themes/'.$theme.'/images'; 66 } 67 $this->log = LoggerManager::getLogger('listView_'.$this->local_current_module); 68 $log->debug("Exiting ListView method ..."); 69 } 70 } 71 /**sets the header title */ 72 function setHeaderTitle($value){ 73 global $log; 74 $log->debug("Entering setHeaderTitle(".$value.") method ..."); 75 $this->header_title = $value; 76 $log->debug("Exiting setHeaderTitle method ..."); 77 } 78 /**sets the header text this is text thats appended to the header vtiger_table and is usually used for the creation of buttons 79 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 80 * All Rights Reserved. 81 * Contributor(s): ______________________________________. 82 */ 83 function setHeaderText($value){ 84 global $log; 85 $log->debug("Entering setHeaderText(".$value.") method ..."); 86 $this->header_text = $value; 87 $log->debug("Exiting setHeaderText method ..."); 88 } 89 /**sets the parameters dealing with the db 90 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 91 * All Rights Reserved. 92 * Contributor(s): ______________________________________. 93 */ 94 function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride= true){ 95 global $log; 96 $log->debug("Entering setQuery(".$where.",". $limit.",". $orderBy.",". $varName.",". $allowOrderByOveride.") method ..."); 97 $this->query_where = $where; 98 if($this->getSessionVariable("query", "where") != $where){ 99 $this->querey_where_has_changed = true; 100 $this->setSessionVariable("query", "where", $where); 101 } 102 103 $this->query_limit = $limit; 104 if(!$allowOrderByOveride){ 105 $this->query_orderby = $orderBy; 106 $log->debug("Exiting setQuery method ..."); 107 return; 108 } 109 $sortBy = $this->getSessionVariable($varName, "ORDER_BY") ; 110 111 if(empty($sortBy)){ 112 $this->setUserVariable($varName, "ORDER_BY", $orderBy); 113 $sortBy = $orderBy; 114 }else{ 115 $this->setUserVariable($varName, "ORDER_BY", $sortBy); 116 } 117 if($sortBy == 'amount'){ 118 $sortBy = 'amount*1'; 119 } 120 121 $desc = false; 122 $desc = $this->getSessionVariable($varName, $sortBy."_desc"); 123 124 if(empty($desc)) 125 $desc = false; 126 if(isset($_REQUEST[$this->getSessionVariableName($varName, "ORDER_BY")])) 127 $last = $this->getSessionVariable($varName, "ORDER_BY_LAST"); 128 if(!empty($last) && $last == $sortBy){ 129 $desc = !$desc; 130 }else { 131 $this->setSessionVariable($varName, "ORDER_BY_LAST", $sortBy); 132 } 133 $this->setSessionVariable($varName, $sortBy."_desc", $desc); 134 if(!empty($sortBy)){ 135 if(substr_count(strtolower($sortBy), ' desc') == 0 && substr_count(strtolower($sortBy), ' asc') == 0){ 136 if($desc){ 137 $this->query_orderby = $sortBy.' desc'; 138 }else{ 139 $this->query_orderby = $sortBy.' asc'; 140 } 141 } 142 else{ 143 $this->query_orderby = $sortBy; 144 } 145 }else { 146 $this->query_orderby = ""; 147 } 148 $log->debug("Exiting setQuery method ..."); 149 150 151 152 153 } 154 155 /**sets the theme used only use if it is different from the global 156 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 157 * All Rights Reserved. 158 * Contributor(s): ______________________________________. 159 */ 160 function setTheme($theme){ 161 global $log; 162 $log->debug("Entering setTheme(".$theme.") method ..."); 163 $this->local_theme = $theme; 164 if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme ); 165 $log->debug("Exiting setTheme method ..."); 166 } 167 168 /**sets the AppStrings used only use if it is different from the global 169 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 170 * All Rights Reserved. 171 * Contributor(s): ______________________________________. 172 */ 173 function setAppStrings(&$app_strings){ 174 global $log; 175 $log->debug("Entering setAppStrings(".$app_strings.") method ..."); 176 unset($this->local_app_strings); 177 $this->local_app_strings = $app_strings; 178 if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings ); 179 $log->debug("Exiting setAppStrings method ..."); 180 } 181 182 /**sets the ModStrings used 183 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 184 * All Rights Reserved. 185 * Contributor(s): ______________________________________. 186 */ 187 function setModStrings(&$mod_strings){ 188 global $log; 189 $log->debug("Entering setModStrings(".$mod_strings.") method ..."); 190 unset($this->local_module_strings); 191 $this->local_mod_strings = $mod_strings; 192 if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings ); 193 $log->debug("Exiting setModStrings method ..."); 194 } 195 196 /**sets the ImagePath used 197 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 198 * All Rights Reserved. 199 * Contributor(s): ______________________________________. 200 */ 201 function setImagePath($image_path){ 202 global $log; 203 $log->debug("Entering setImagePath(".$image_path.") method ..."); 204 $this->local_image_path = $image_path; 205 if(empty($this->local_image_path)){ 206 $this->local_image_path = 'themes/'.$this->local_theme.'/images'; 207 } 208 if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path ); 209 $log->debug("Exiting setImagePath method ..."); 210 } 211 212 /**sets the currentModule only use if this is different from the global 213 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 214 * All Rights Reserved. 215 * Contributor(s): ______________________________________. 216 */ 217 function setCurrentModule($currentModule){ 218 global $log; 219 $log->debug("Entering setCurrentModule(".$currentModule.") method ..."); 220 unset($this->local_current_module); 221 $this->local_current_module = $currentModule; 222 $this->log = LoggerManager::getLogger('listView_'.$this->local_current_module); 223 if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module ); 224 $log->debug("Exiting setCurrentModule method ..."); 225 226 } 227 228 229 /**INTERNAL FUNCTION sets a session variable 230 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 231 * All Rights Reserved. 232 * Contributor(s): ______________________________________. 233 */ 234 function setSessionVariable($localVarName,$varName, $value){ 235 global $log; 236 $log->debug("Entering setSessionVariable(".$localVarName.",".$varName.",". $value.") method ..."); 237 $_SESSION[$this->local_current_module."_".$localVarName."_".$varName] = $value; 238 $log->debug("Exiting setSessionVariable method ..."); 239 } 240 241 function setUserVariable($localVarName,$varName, $value){ 242 global $log; 243 $log->debug("Entering setUserVariable(".$localVarName.",".$varName.",". $value.") method ..."); 244 global $current_user; 245 $current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value); 246 $log->debug("Exiting setUserVariable method ..."); 247 } 248 249 /**INTERNAL FUNCTION returns a session variable first checking the querey for it then checking the session 250 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 251 * All Rights Reserved. 252 * Contributor(s): ______________________________________. 253 */ 254 function getSessionVariable($localVarName,$varName){ 255 global $log; 256 $log->debug("Entering getSessionVariable(".$localVarName.",".$varName.") method ..."); 257 if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])){ 258 $this->setSessionVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]); 259 } 260 if(isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])){ 261 $log->debug("Exiting getSessionVariable method ..."); 262 return $_SESSION[$this->getSessionVariableName($localVarName, $varName)]; 263 } 264 $log->debug("Exiting getSessionVariable method ..."); 265 return ""; 266 } 267 268 269 270 271 272 /** 273 274 * @return void 275 * @param unknown $localVarName 276 * @param unknown $varName 277 * @desc INTERNAL FUNCTION returns the session/query variable name 278 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 279 * All Rights Reserved. 280 * Contributor(s): ______________________________________.. 281 */ 282 function getSessionVariableName($localVarName,$varName){ 283 global $log; 284 $log->debug("Entering getSessionVariableName(".$localVarName.",".$varName.") method ..."); 285 $log->debug("Exiting getSessionVariableName method ..."); 286 return $this->local_current_module."_".$localVarName."_".$varName; 287 } 288 289 290 } 291 292 293 294 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |