[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /***************************************************************************\ 3 * EGroupWare - FeLaMiMail * 4 * http://www.linux-at-work.de * 5 * http://www.phpgw.de * 6 * http://www.egroupware.org * 7 * Written by : Lars Kneschke [lkneschke@linux-at-work.de] * 8 * ------------------------------------------------- * 9 * Copyright (c) 2004, Lars Kneschke * 10 * All rights reserved. * 11 * * 12 * Redistribution and use in source and binary forms, with or without * 13 * modification, are permitted provided that the following conditions are * 14 * met: * 15 * * 16 * * Redistributions of source code must retain the above copyright * 17 * notice, this list of conditions and the following disclaimer. * 18 * * Redistributions in binary form must reproduce the above copyright * 19 * notice, this list of conditions and the following disclaimer in the * 20 * documentation and/or other materials provided with the distribution.* 21 * * Neither the name of the FeLaMiMail organization nor the names of * 22 * its contributors may be used to endorse or promote products derived * 23 * from this software without specific prior written permission. * 24 * * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * 27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* 28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * 29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * 30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * 31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 36 \***************************************************************************/ 37 38 /* $Id: class.uiwidgets.inc.php 22170 2006-07-24 09:15:40Z lkneschke $ */ 39 40 /** 41 * a class containing javascript enhanced html widgets 42 * 43 * @package FeLaMiMail 44 * @author Lars Kneschke 45 * @version 1.35 46 * @copyright Lars Kneschke 2004 47 * @license http://www.opensource.org/licenses/bsd-license.php BSD 48 */ 49 class uiwidgets 50 { 51 /** 52 * the contructor 53 * 54 */ 55 function uiwidgets() 56 { 57 $template =& CreateObject('phpgwapi.Template',EGW_APP_TPL); 58 $this->template = $template; 59 $this->template->set_file(array("body" => 'uiwidgets.tpl')); 60 } 61 62 /** 63 * create a folder tree 64 * 65 * this function will create a foldertree based on javascript 66 * on click the sorounding form gets submitted 67 * 68 * @param _folders array containing the list of folders 69 * @param _selected string containing the selected folder 70 * @param _topFolderName string containing the top folder name 71 * @param _topFolderDescription string containing the description for the top folder 72 * @param _formName string name of the sorounding form 73 * @param _hiddenVar string hidden form value, transports the selected folder 74 * 75 * @return string the html code, to be added into the template 76 */ 77 function createHTMLFolder($_folders, $_selected, $_topFolderName, $_topFolderDescription, $_divName, $_displayCheckBox) 78 { 79 $allFolders = array(); 80 81 // create a list of all folders, also the ones which are not subscribed 82 foreach($_folders as $key => $obj) 83 { 84 $folderParts = explode($obj->delimiter,$key); 85 if(is_array($folderParts)) 86 { 87 $partCount = count($folderParts); 88 $string = ''; 89 for($i = 0; $i < $partCount-1; $i++) 90 { 91 if(!empty($string)) $string .= $obj->delimiter; 92 $string .= $folderParts[$i]; 93 if(!$allFolders[$string]) 94 { 95 $allFolders[$string] = $obj; 96 unset($allFolders[$string]->name); 97 unset($allFolders[$string]->attributes); 98 unset($allFolders[$string]->counter); 99 } 100 } 101 } 102 $allFolders[$key] = $obj; 103 } 104 $folderImageDir = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/templates/default/images/'; 105 106 // careful! "d = new..." MUST be on a new line!!! 107 $folder_tree_new = '<link rel="STYLESHEET" type="text/css" href="'.$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/dhtmlxtree/css/dhtmlXTree.css">'; 108 $folder_tree_new .= "<script type='text/javascript'>"; 109 $folder_tree_new .= "tree=new dhtmlXTreeObject('$_divName','100%','100%',0);"; 110 $folder_tree_new .= "tree.setImagePath('$folderImageDir/dhtmlxtree/');"; 111 if($_displayCheckBox) 112 { 113 $folder_tree_new .= "tree.enableCheckBoxes(1);"; 114 $folder_tree_new .= "tree.setOnCheckHandler('onCheckHandler');"; 115 } 116 117 $folder_tree_new .= "tree.insertNewItem(0,'--topfolder--','$_topFolderName',onNodeSelect,'thunderbird.png','thunderbird.png','thunderbird.png','CHILD,TOP');\n"; 118 119 #foreach($_folders as $key => $obj) 120 foreach($allFolders as $longName => $obj) 121 { 122 $image1 = "'folderClosed.gif'"; 123 $image2 = "0"; 124 $image3 = "0"; 125 126 $folderParts = explode($obj->delimiter, $longName); 127 128 //get rightmost folderpart 129 $shortName = array_pop($folderParts); 130 131 // the rest of the array is the name of the parent 132 $parentName = implode((array)$folderParts,$obj->delimiter); 133 if(empty($parentName)) $parentName = '--topfolder--'; 134 135 if( @$obj->counter->unseen > 0 ) 136 { 137 $messageCount = " (".$obj->counter->unseen.")"; 138 } 139 else 140 { 141 $messageCount = ""; 142 } 143 144 $entryOptions = 'CHILD,CHECKED'; 145 146 // highlight currently selected mailbox 147 if ($_selected == $longName) 148 { 149 $entryOptions .= ',SELECT'; 150 } 151 152 $folder_name = $shortName.$messageCount; 153 154 // give INBOX a special foldericon 155 if ($longName == 'INBOX') 156 { 157 $image1 = "'kfm_home.png'"; 158 $image2 = "'kfm_home.png'"; 159 $image3 = "'kfm_home.png'"; 160 } 161 162 $parentName = @htmlspecialchars($parentName, ENT_QUOTES, $this->charset); 163 $longName = @htmlspecialchars($longName, ENT_QUOTES, $this->charset); 164 $folder_name = @htmlspecialchars($folder_name, ENT_QUOTES, $this->charset); 165 166 $folder_tree_new .= "tree.insertNewItem('$parentName','$longName','$folder_name',onNodeSelect,$image1,$image2,$image3,'$entryOptions');\n"; 167 if($_displayCheckBox) 168 $folder_tree_new .= "tree.setCheck('$longName','".(int)$obj->subscribed."');"; 169 } 170 171 $selected = @htmlspecialchars($_selected, ENT_QUOTES, $this->charset); 172 $folder_tree_new.= "tree.closeAllItems(0);tree.openItem('$selected');</script>"; 173 174 return $folder_tree_new; 175 } 176 177 function messageTable($_headers, $_isSentFolder, $_readInNewWindow) 178 { 179 $this->t =& CreateObject('phpgwapi.Template',EGW_APP_TPL); 180 $this->t->set_file(array("body" => 'mainscreen.tpl')); 181 $this->t->set_block('body','header_row'); 182 $this->t->set_block('body','message_table'); 183 184 foreach((array)$_headers['header'] as $header) 185 { 186 // create the listing of subjects 187 $maxSubjectLength = 60; 188 $maxAddressLength = 20; 189 $maxSubjectLengthBold = 50; 190 $maxAddressLengthBold = 14; 191 192 $flags = ""; 193 if(!empty($header['recent'])) $flags .= "R"; 194 if(!empty($header['flagged'])) $flags .= "F"; 195 if(!empty($header['answered'])) $flags .= "A"; 196 if(!empty($header['deleted'])) $flags .= "D"; 197 if(!empty($header['seen'])) $flags .= "S"; 198 199 switch($flags) 200 { 201 case "": 202 $this->t->set_var('imageName','unread_small.png'); 203 $this->t->set_var('row_text',lang('new')); 204 $maxAddressLength = $maxAddressLengthBold; 205 $maxSubjectLength = $maxSubjectLengthBold; 206 break; 207 case "D": 208 case "DS": 209 case "ADS": 210 $this->t->set_var('imageName','unread_small.png'); 211 $this->t->set_var('row_text',lang('deleted')); 212 break; 213 case "F": 214 $this->t->set_var('imageName','unread_flagged_small.png'); 215 $this->t->set_var('row_text',lang('new')); 216 $maxAddressLength = $maxAddressLengthBold; 217 break; 218 case "FS": 219 $this->t->set_var('imageName','read_flagged_small.png'); 220 $this->t->set_var('row_text',lang('replied')); 221 break; 222 case "FAS": 223 $this->t->set_var('imageName','read_answered_flagged_small.png'); 224 $this->t->set_var('row_text',lang('replied')); 225 break; 226 case "S": 227 case "RS": 228 $this->t->set_var('imageName','read_small.png'); 229 $this->t->set_var('row_text',lang('read')); 230 break; 231 case "R": 232 $this->t->set_var('imageName','recent_small.gif'); 233 $this->t->set_var('row_text','*'.lang('recent').'*'); 234 $maxAddressLength = $maxAddressLengthBold; 235 break; 236 case "RAS": 237 case "AS": 238 $this->t->set_var('imageName','read_answered_small.png'); 239 $this->t->set_var('row_text',lang('replied')); 240 #$maxAddressLength = $maxAddressLengthBold; 241 break; 242 default: 243 $this->t->set_var('row_text',$flags); 244 break; 245 } 246 #_debug_array($GLOBALS[phpgw_info]); 247 if (!empty($header['subject'])) 248 { 249 // filter out undisplayable characters 250 $search = array('[\016]','[\017]', 251 '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', 252 '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); 253 $replace = ''; 254 255 $header['subject'] = preg_replace($search,$replace,$header['subject']); 256 257 // make the subject shorter if it is to long 258 $fullSubject = $header['subject']; 259 #if(strlen($header['subject']) > $maxSubjectLength) 260 #{ 261 # $header['subject'] = substr($header['subject'],0,$maxSubjectLength)."..."; 262 #} 263 $header['subject'] = @htmlspecialchars($header['subject'],ENT_QUOTES,$this->displayCharset); 264 if($header['attachments'] == "true") 265 { 266 $image = '<img src="'.$GLOBALS['egw']->common->image('felamimail','attach').'" border="0" style="width:12px;">'; 267 268 $header['attachment'] = $image; 269 } 270 $this->t->set_var('header_subject', $header['subject']); 271 $this->t->set_var('attachments', $header['attachment']); 272 $this->t->set_var('full_subject',@htmlspecialchars($fullSubject,ENT_QUOTES,$this->displayCharset)); 273 } 274 else 275 { 276 $this->t->set_var('header_subject',@htmlentities("(".lang('no subject').")",ENT_QUOTES,$this->displayCharset)); 277 } 278 279 if ($_isSentFolder) 280 { 281 if (!empty($header['to_name'])) 282 { 283 $sender_name = $header['to_name']; 284 $full_address = $header['to_name'].' <'.$header['to_address'].'>'; 285 } 286 else 287 { 288 $sender_name = $header['to_address']; 289 $full_address = $header['to_address']; 290 } 291 #$this->t->set_var('lang_from',lang("to")); 292 } 293 else 294 { 295 if (!empty($header['sender_name'])) 296 { 297 $sender_name = $header['sender_name']; 298 $full_address = $header['sender_name'].' <'.$header['sender_address'].'>'; 299 } 300 else 301 { 302 $sender_name = $header['sender_address']; 303 $full_address = $header['sender_address']; 304 } 305 #$this->t->set_var('lang_from',lang("from")); 306 } 307 #if(strlen($sender_name) > $maxAddressLength) 308 #{ 309 # $sender_name = substr($sender_name,0,$maxAddressLength)."..."; 310 #} 311 $this->t->set_var('sender_name',$sender_name); 312 $this->t->set_var('full_address',$full_address); 313 314 $this->t->set_var('message_counter',$i); 315 $this->t->set_var('message_uid',$header['uid']); 316 317 $this->t->set_var('date',$header['date']); 318 $this->t->set_var('size',$this->show_readable_size($header['size'])); 319 320 $linkData = array 321 ( 322 'menuaction' => 'felamimail.uidisplay.display', 323 'showHeader' => 'false', 324 'uid' => $header['uid'] 325 ); 326 $windowName = ($_readInNewWindow == 1 ? 'displayMessage' : 'displayMessage_'.$header['uid']); 327 $this->t->set_var('url_read_message',"egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"); 328 329 if($_isSentFolder) 330 { 331 if(!empty($header['to_name'])) 332 { 333 list($mailbox, $host) = explode('@',$header['to_address']); 334 $senderAddress = imap_rfc822_write_address($mailbox, 335 $host, 336 $header['to_name']); 337 } 338 else 339 { 340 $senderAddress = $header['to_address']; 341 } 342 } 343 else 344 { 345 if(!empty($header['sender_name'])) 346 { 347 list($mailbox, $host) = explode('@',$header['sender_address']); 348 $senderAddress = imap_rfc822_write_address($mailbox, 349 $host, 350 $header['sender_name']); 351 } 352 else 353 { 354 $senderAddress = $header['sender_address']; 355 } 356 } 357 358 $linkData = array 359 ( 360 'menuaction' => 'felamimail.uicompose.compose', 361 'send_to' => base64_encode($senderAddress) 362 ); 363 $windowName = 'compose'.$header['uid']; 364 $this->t->set_var('url_compose',"egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"); 365 366 $linkData = array 367 ( 368 'menuaction' => 'addressbook.uiaddressbook.add_email', 369 'add_email' => urlencode($header['sender_address']), 370 'name' => urlencode($header['sender_name']), 371 'referer' => urlencode($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']) 372 ); 373 //TODO: url_add_to_addressbook isn't in any of the templates. 374 //If you want to use it, you need to adopt syntax to the new addressbook (popup) 375 $this->t->set_var('url_add_to_addressbook',$GLOBALS['egw']->link('/index.php',$linkData)); 376 $this->t->set_var('msg_icon_sm',$msg_icon_sm); 377 378 $this->t->set_var('phpgw_images',EGW_IMAGES); 379 $this->t->set_var('row_css_class','header_row_'.$flags); 380 381 $this->t->parse('message_rows','header_row',True); 382 } 383 $this->t->parse("out","message_table"); 384 385 return $this->t->get('out','message_table'); 386 } 387 388 /** 389 * create multiselectbox 390 * 391 * this function will create a multiselect box. Hard to describe! :) 392 * 393 * @param _selectedValues Array of values for already selected values(the left selectbox) 394 * @param _predefinedValues Array of values for predefined values(the right selectbox) 395 * @param _valueName name for the variable containing the selected values 396 * @param _boxWidth the width of the multiselectbox( example: 100px, 100%) 397 * 398 * @returns the html code, to be added into the template 399 */ 400 function multiSelectBox($_selectedValues, $_predefinedValues, $_valueName, $_boxWidth="100%") 401 { 402 $this->template->set_block('body','multiSelectBox'); 403 404 if(is_array($_selectedValues)) 405 { 406 foreach($_selectedValues as $key => $value) 407 { 408 $options .= "<option value=\"$key\" selected=\"selected\">".@htmlspecialchars($value,ENT_QUOTES)."</option>"; 409 } 410 $this->template->set_var('multiSelectBox_selected_options',$options); 411 } 412 413 $options = ''; 414 if(is_array($_predefinedValues)) 415 { 416 foreach($_predefinedValues as $key => $value) 417 { 418 if($key != $_selectedValues["$key"]) 419 $options .= "<option value=\"$key\">".@htmlspecialchars($value,ENT_QUOTES)."</option>"; 420 } 421 $this->template->set_var('multiSelectBox_predefinded_options',$options); 422 } 423 424 $this->template->set_var('multiSelectBox_valueName', $_valueName); 425 $this->template->set_var('multiSelectBox_boxWidth', $_boxWidth); 426 427 428 return $this->template->fp('out','multiSelectBox'); 429 } 430 431 function navbarButton($_imageName, $_imageAction, $_toolTip='', $_float='left') 432 { 433 $image = $GLOBALS['egw']->common->image('felamimail',$_imageName); 434 $float = $_float == 'right' ? 'right' : 'left'; 435 436 return "<div class='navButton' style='float:$float;' onmousedown='this.className=\"navButtonActive\";' onmouseup='this.className=\"navButtonHover\";' onmouseout='this.className=\"navButton\";' onclick=\"$_imageAction\"><img style='width:16px; height:16px;' title='$_toolTip' src='$image' ></div>\n"; 437 } 438 439 function navbarSeparator() 440 { 441 return '<div class="navSeparator"></div>'; 442 } 443 444 /* Returns a string showing the size of the message/attachment */ 445 function show_readable_size($bytes, $_mode='short') 446 { 447 $bytes /= 1024; 448 $type = 'k'; 449 450 if ($bytes / 1024 > 1) 451 { 452 $bytes /= 1024; 453 $type = 'M'; 454 } 455 456 if ($bytes < 10) 457 { 458 $bytes *= 10; 459 settype($bytes, 'integer'); 460 $bytes /= 10; 461 } 462 else 463 settype($bytes, 'integer'); 464 465 return $bytes . ' ' . $type ; 466 } 467 468 function tableView($_headValues, $_tableWidth="100%") 469 { 470 $this->template->set_block('body','tableView'); 471 $this->template->set_block('body','tableViewHead'); 472 473 if(is_array($_headValues)) 474 { 475 foreach($_headValues as $head) 476 { 477 $this->template->set_var('tableHeadContent',$head); 478 $this->template->parse('tableView_Head','tableViewHead',True); 479 } 480 } 481 482 if(is_array($this->tableViewRows)) 483 { 484 foreach($this->tableViewRows as $tableRow) 485 { 486 $rowData .= "<tr>"; 487 foreach($tableRow as $tableData) 488 { 489 switch($tableData['type']) 490 { 491 default: 492 $rowData .= '<td>'.$tableData['text'].'</td>'; 493 break; 494 } 495 } 496 $rowData .= "</tr>"; 497 } 498 } 499 500 $this->template->set_var('tableView_width', $_tableWidth); 501 $this->template->set_var('tableView_Rows', $rowData); 502 503 return $this->template->fp('out','tableView'); 504 } 505 506 function tableViewAddRow() 507 { 508 $this->tableViewRows[] = array(); 509 end($this->tableViewRows); 510 return key($this->tableViewRows); 511 } 512 513 function tableViewAddTextCell($_rowID,$_text) 514 { 515 $this->tableViewRows[$_rowID][]= array 516 ( 517 'type' => 'text', 518 'text' => $_text 519 ); 520 } 521 } 522 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |