1# $Id: tconfig.tcl 1204 2009-02-02 19:54:23Z hubert@u.washington.edu $ 2# ======================================================================== 3# Copyright 2006 University of Washington 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# ======================================================================== 12 13# tconfig.tcl 14# 15# Purpose: CGI script to configure features/variables 16 17# Input: 18set conf_vars { 19 {newconf {} 0} 20 {oncancel "Nothing set for oncancel"} 21 {wv "" general} 22 {vlavar "" ""} 23} 24 25# Output: 26# 27 28# read config 29source genvars.tcl 30 31set confs { 32 {general General g genconf} 33 {msgl "Message List" ml mlconf} 34 {msgv "Message View" mv mvconf} 35 {composer Composer c compconf} 36 {address "Address Books" ab abconf} 37 {folder "Folders" f fldrconf} 38 {rule "Rules" r ruleconf} 39} 40 41 42set var_menu { 43 { 44 {} 45 { 46 { 47 # * * * * Save Config * * * * 48 #cgi_image_button save=[WPimg but_save] border=0 alt="Save Config" 49 cgi_submit_button save=Save 50 } 51 } 52 } 53 { 54 {} 55 { 56 { 57 # * * * * Close * * * * 58 #cgi_image_button cancel=[WPimg but_cancel] border=0 alt="Cancel" 59 cgi_submit_button cancel=Cancel 60 } 61 } 62 } 63} 64 65## read vars 66foreach item $conf_vars { 67 if {[catch {cgi_import [lindex $item 0].x}]} { 68 if {[catch {eval WPImport $item} result]} { 69 if {[llength $item] > 2} { 70 set [lindex $item 0] [lindex $item 2] 71 } else { 72 error [list _action [lindex $item 1] $result] 73 } 74 } 75 } else { 76 set [lindex $item 0] 1 77 } 78} 79 80set type $wv 81WPCmd set conf_page $type 82switch -- $type { 83 msgl { 84 set goodvars $msglist_vars 85 } 86 msgv { 87 set goodvars $msgview_vars 88 } 89 address { 90 set goodvars $address_vars 91 } 92 folder { 93 set goodvars $folder_vars 94 } 95 composer { 96 set goodvars $composer_vars 97 } 98 general { 99 set goodvars $general_vars 100 } 101 rule { 102 set goodvars $rule_vars 103 } 104} 105set typeexp "General" 106 107proc button_text {but butno fg bg text} { 108 if {[string length $fg]} { 109 set fg "color: #${fg};" 110 } 111 112 if {[string length $bg]} { 113 set bg "background-color: #${bg}" 114 } 115 116 cgi_puts "<script><!-- " 117 cgi_puts "document.write('<a href=\\\'#\\\' style=\\\"text-decoration: none;\\\" onClick=\"return setop(\\\'${but}\\\',$butno)\">');// -->" 118 cgi_puts "</script>" 119 120 cgi_put [cgi_span "style=$fg $bg" $text] 121 122 cgi_puts "<script><!-- " 123 cgi_puts "document.write('</a>');// -->" 124 cgi_puts "</script>" 125} 126 127proc button_checked {def but} { 128 if {[string compare $def $but]} { 129 return "" 130 } else { 131 return checked 132 } 133} 134 135foreach conf $confs { 136 if {[string compare $type [lindex $conf 0]] == 0} { 137 append ttitle [cgi_imglink "[lindex $conf 2]tab"] 138 lappend conftitle [list [cgi_imglink "[lindex $conf 2]tab"] {} {}] 139 set typeexp [lindex $conf 1] 140 set _wp(helpname) [lindex $conf 3] 141 } else { 142 append ttitle "<input type=image name=\"[lindex $conf 2]tab\" src=\"[WPimg "tabs/[lindex $conf 2]dtab"]\" border=0 alt=\"[lindex $conf 1]\">"; 143 } 144} 145 146cgi_http_head { 147 WPStdHttpHdrs 148} 149 150if {$newconf == 1} { 151 WPCmd PEConfig newconf 152} 153 154cgi_html { 155 cgi_head { 156 WPStdHtmlHdr "Configuration" 157 WPStyleSheets 158 159 cgi_put "<style type='text/css'>" 160 cgi_put ".vtext { font-size: 10pt; font-family: courier, 'new courier', monospace ; font-weight: medium ; padding-left: 6; border-left: 1px solid black}" 161 cgi_put ".instr { font-size: 10pt; font-weight: bold}" 162 cgi_puts "</style>" 163 164 cgi_javascript { 165 cgi_put "function setop(b,i){" 166 cgi_put " eval('document.varconfig.'+b+'\['+i+'\].checked = true');" 167 cgi_put " return false;" 168 cgi_put "}" 169 } 170 } 171 172 cgi_body BGCOLOR="$_wp(bordercolor)" { 173 set postjs "" 174 175 cgi_form $_wp(appdir)/$_wp(ui1dir)/wp method=post name=varconfig enctype=multipart/form-data target=_top { 176 cgi_text "oncancel=$oncancel" type=hidden notab 177 cgi_text "cid=[WPCmd PEInfo key]" type=hidden notab 178 cgi_text "page=conf_process" type=hidden notab 179 180 cgi_table width="100%" cellpadding=0 cellspacing=0 { 181 cgi_table_row { 182 cgi_table_data width=112 bgcolor=$_wp(menucolor) { 183 cgi_puts [cgi_img [WPimg dot2] width=1 height=1] 184 } 185 cgi_table_data align=right nowrap background="[WPimg [file join tabs tabbg]]" { 186 cgi_put $ttitle 187 } 188 } 189 } 190 if {0} { 191 cgi_division align=right { 192 cgi_put $ttitle 193 } 194 } 195 cgi_table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%" { 196 197 cgi_table_row { 198 # 199 # next comes the menu down the left side 200 # 201 eval { 202 cgi_table_data $_wp(menuargs) rowspan=4 { 203 WPTFCommandMenu var_menu {} 204 } 205 } 206 207 # 208 # In main body of screen goe confg list 209 # 210 cgi_table_data valign=top width="100%" class=dialog "style=\"padding-left: 6\"" { 211 cgi_h2 [cgi_bold "${typeexp} configuration settings:"] 212 switch -- $type { 213 msgl { 214 cgi_text "wv=msgl" type=hidden notab 215 } 216 msgv { 217 cgi_text "wv=msgv" type=hidden notab 218 } 219 address { 220 cgi_text "wv=address" type=hidden notab 221 } 222 folder { 223 cgi_text "wv=folder" type=hidden notab 224 } 225 composer { 226 cgi_text "wv=composer" type=hidden notab 227 } 228 general { 229 cgi_text "wv=general" type=hidden notab 230 } 231 rule { 232 cgi_text "wv=rule" type=hidden notab 233 } 234 } 235 set setfeatures [WPCmd PEConfig featuresettings] 236 set icnt 0 237 cgi_table border=0 cellspacing=0 cellpadding=5 width=98% { 238 foreach tmpvar $goodvars { 239 set vtypeinp [lindex $tmpvar 0] 240 set varname [lindex $tmpvar 1] 241 set vardesc [lindex $tmpvar 2] 242 243 if {[catch {WPCmd PEConfig varget $varname} section] == 0} { 244 set varvals [lindex $section 0] 245 set vartype [lindex $section 1] 246 set vtvals [lindex $section 2] 247 set v_is_default [lindex $section 3] 248 set v_is_fixed [lindex $section 4] 249 } else { 250 # UNKNOWN VAR: configure disabled? 251 continue 252 } 253 254 switch -- $vtypeinp { 255 var { 256 cgi_table_row { 257 258 cgi_table_data align=right valign=top nowrap width=50% { 259 if {[info exists varname]} { 260 # set script "help.tcl?vn=$varname" 261 # set js "cOpen('$script', 'help', 'scrollbars=yes', 600, 400); return false;" 262 # set js "return vh('$varname')" 263 # cgi_puts [WPurl null "" $varname "" onClick=$js] 264 # cgi_puts [WPurl null "" $vardesc "" onClick=$js] 265 # cgi_submit_button varhelp=$vardesc class=lnkbt 266 cgi_puts [cgi_font class=cfvn $vardesc] 267 } 268 } 269 cgi_table_data valign=top { 270 cgi_image_button "hlp.$varname=[WPimg cf_help]" alt="Help for $vardesc" 271 } 272 cgi_table_data align=left colspan=2 width=50% { 273 switch -- $vartype { 274 listbox { 275 cgi_select $varname align=left { 276 foreach tmpvt $vtvals { 277 set tmpvttxt [lindex $tmpvt 0] 278 set tmpvtval $tmpvttxt 279 if {[llength $tmpvt] > 1} { 280 set tmpvtval [lindex $tmpvt 1] 281 } 282 if {[string compare $tmpvtval [lindex $varvals 0]]} { 283 if {[llength $tmpvt] > 1} { 284 cgi_option "${tmpvttxt}" "value=${tmpvtval}" 285 } else { 286 cgi_option "${tmpvttxt}" "value=${tmpvttxt}" 287 } 288 } else { 289 if {[llength $tmpvt] > 1} { 290 cgi_option "$tmpvttxt" "value=${tmpvtval}" selected 291 } else { 292 cgi_option "$tmpvttxt" selected 293 } 294 } 295 } 296 } 297 } 298 textarea { 299 cgi_table border=0 cellpadding=0 cellspacing=0 { 300 set addfield 0 301 set tiwidth 30 302 foreach varval $varvals { 303 if {[string length $varval] > [expr {[info exists maxwidth] ? $maxwidth : 0}]} { 304 set maxwidth [string length $varval] 305 incr maxwidth 5 306 } 307 } 308 if {[info exists maxwidth]} { 309 set tiwidth $maxwidth 310 } 311 if {$tiwidth < 20} { 312 set tiwidth 20 313 } elseif {$tiwidth > 50} { 314 set tiwidth 50 315 } 316 cgi_table_row { 317 cgi_table_data colspan=4 { 318 cgi_image_button vla.$varname=[WPimg cf_add] alt="Add Value" 319 } 320 } 321 if {[string compare $vlavar $varname] == 0} { 322 set addfield 1 323 cgi_table_row { 324 cgi_table_data { 325 cgi_text "varlistadd=$varname" type=hidden notab 326 cgi_text "$varname-add=" type=text size=$tiwidth 327 } 328 cgi_table_data colspan=3 { 329 cgi_puts [cgi_font class=cfntc "(The value entered here will be added.)"] 330 } 331 } 332 } 333 set i 0 334 set vvsz [llength $varvals] 335 foreach varval $varvals { 336 cgi_table_row { 337 cgi_table_data { 338 cgi_text vle.$varname.$i=$varval type=text size=$tiwidth 339 } 340 cgi_table_data { 341 cgi_image_button vld.$varname.$i=[WPimg cf_delete] alt="Delete Value" 342 } 343 cgi_table_data { 344 if {$i < [expr {$vvsz - 1}]} { 345 cgi_image_button vlsd.$varname.$i=[WPimg cf_shdown] alt="Shuffle Down" 346 } else { 347 cgi_puts [cgi_nbspace] 348 } 349 } 350 cgi_table_data width=50% { 351 if {$i || $addfield} { 352 cgi_image_button vlsu.$varname.$i=[WPimg cf_shup] alt="Shuffle Up" 353 } else { 354 cgi_puts [cgi_nbspace] 355 } 356 } 357 } 358 incr i 359 } 360 cgi_text "$varname-sz=$i" type=hidden notab 361 } 362 } 363 default { 364 set size [string length [lindex $varvals 0]] 365 if {$size == 0} { 366 set size 20 367 } else { 368 incr size 5 369 } 370 cgi_text "$varname=[lindex $varvals 0]" type=text size=$size tableindex=1 371 } 372 } 373 } 374 } 375 } 376 feat { 377 cgi_table_row { 378 cgi_table_data align=right width=50% { 379 if {[info exists varname]} { 380 # cgi_submit_button feathelp=$vardesc class=lnkbt 381 cgi_puts [cgi_font class=cfvn $vardesc] 382 } 383 } 384 cgi_table_data { 385 cgi_image_button "hlp.$varname=[WPimg cf_help]" alt="Help for $vardesc" 386 } 387 cgi_table_data align=left colspan=3 width=50% { 388 if {[lsearch $setfeatures $varname] >= 0} { 389 cgi_checkbox $varname checked class=dialog 390 } else { 391 cgi_checkbox $varname class=dialog 392 } 393 } 394 } 395 396 } 397 special { 398 switch -- $varname { 399 wp-columns { 400 cgi_table_row { 401 cgi_table_data align=right valign=top nowrap { 402 cgi_puts [cgi_font class=cfvn $vardesc] 403 } 404 cgi_table_data valign=top { 405 cgi_image_button "hlp.${varname}=[WPimg cf_help]" alt="Help for $vardesc" 406 } 407 cgi_table_data align=left colspan=2 { 408 set cols [WPCmd PEConfig columns] 409 cgi_select columns align=left { 410 for {set i 20} {$i <= 128} {incr i 4} { 411 if {$i == $cols} { 412 cgi_option $i "value=$i" selected 413 } else { 414 cgi_option $i "value=$i" 415 } 416 } 417 } 418 } 419 } 420 } 421 left-column-folders { 422 cgi_table_row { 423 cgi_table_data align=right valign=top nowrap { 424 cgi_puts [cgi_font class=cfvn $vardesc] 425 } 426 cgi_table_data valign=top { 427 cgi_puts [cgi_nbspace] 428 } 429 cgi_table_data align=left colspan=2 { 430 if {[catch {WPSessionState left_column_folders} cols]} { 431 set cols $_wp(fldr_cache_def) 432 } 433 434 cgi_select fcachel align=left { 435 for {set i 0} {$i <= $_wp(fldr_cache_max)} {incr i} { 436 if {$i == $cols} { 437 cgi_option $i "value=$i" selected 438 } else { 439 cgi_option $i "value=$i" 440 } 441 } 442 } 443 } 444 } 445 } 446 signature { 447 cgi_table_row { 448 cgi_table_data colspan=4 align=center { 449 cgi_puts "<fieldset>" 450 cgi_puts "<legend>Signature</legend>" 451 452 set rawsig [join [WPCmd PEConfig rawsig] "\n"] 453 cgi_textarea signature=$rawsig rows=8 cols=80 wrap=off 454 455 cgi_puts "</fieldset>" 456 } 457 } 458 459 } 460 filters - 461 scores - 462 indexcolor - 463 collections { 464 set flt 0 465 set cll 0 466 switch $varname { 467 filters { 468 set flt 1 469 set descsing "Filter" 470 set filts [WPCmd PEConfig filters] 471 set lvals $filts 472 set varhelp 1 473 } 474 scores { 475 set flt 1 476 set descsing "Scores" 477 set filts [WPCmd PEConfig scores] 478 set lvals $filts 479 set varhelp 1 480 } 481 indexcolor { 482 set flt 1 483 set descsing "Index Colors" 484 set filts [WPCmd PEConfig indexcolors] 485 set lvals $filts 486 set varhelp 1 487 } 488 default { 489 set cll 1 490 set descsing "Collection" 491 set colls [WPCmd PEConfig collections] 492 set lvals $colls 493 } 494 } 495 set tasize [llength $lvals] 496 cgi_table_row { 497 cgi_table_data align=center colspan=4 width=50% { 498 cgi_table border=0 cellpadding=3 cellspacing=0 width=100% { 499 cgi_table_row { 500 cgi_table_data width=50% { 501 cgi_puts [cgi_bold $vardesc] 502 } 503 if {[info exists varhelp]} { 504 cgi_table_data valign=top { 505 cgi_image_button "hlp.$varname=[WPimg cf_help]" alt="Help for $vardesc" 506 } 507 } 508 cgi_table_data "style=\"padding-left: 10px\"" { 509 cgi_image_button vla.$varname=[WPimg cf_add] alt="Add $descsing" 510 } 511 } 512 set i 0 513 foreach lval $lvals { 514 cgi_table_row { 515 cgi_table_data "style=\"padding-left: 8px\"" { 516 if {$flt} { 517 cgi_puts [cgi_font class=cfvn "[cgi_nbspace]$lval"] 518 } else { 519 cgi_puts "[cgi_font class=cfvn [lindex $lval 0]]<br>[cgi_span class=cfval "style=margin-left: 8px" [lindex $lval 1]]" 520 } 521 } 522 523 cgi_table_data "style=\"padding-left: 10px\"" valign=top width=30% { 524 cgi_unbreakable { 525 cgi_image_button vle.$varname.$i=[WPimg cf_edit] alt="Edit $descsing" 526 527 cgi_image_button vld.$varname.$i=[WPimg cf_delete] alt="Delete $descsing" 528 529 if {$i < [expr {$tasize - 1}]} { 530 cgi_image_button vlsd.$varname.$i=[WPimg cf_shdown] alt="Shuffle Down" 531 } else { 532 cgi_puts [cgi_img [WPimg dot2] width=18] 533 } 534 535 if {$i} { 536 cgi_image_button vlsu.$varname.$i=[WPimg cf_shup] alt="Shuffle Up" 537 } 538 } 539 } 540 } 541 incr i 542 } 543 cgi_text "$varname-sz=$i" type=hidden notab 544 } 545 } 546 } 547 } 548 index-format { 549 cgi_table_row { 550 cgi_table_data align=left colspan=4 { 551 cgi_puts "<fieldset style=\"margin-left:1%; margin-right:1%\">" 552 #set helpbut [cgi_buffer {cgi_image_button "hlp.$varname=[WPimg cf_help]" alt="Help for $vardesc"}] 553 cgi_puts "<legend>Message Line Format</legend>" 554 555 set varval [WPCmd PEConfig varget $varname] 556 if {[llength [lindex $varval 0]]} { 557 set fmt "" 558 foreach fms [lindex [lindex $varval 0] 0] { 559 if {[regexp {^([a-zA-Z]+[0-9]*)\(([0-9]+[%]?)\)$} $fms dummy f w]} { 560 lappend fmt [list $f $w] 561 } elseif {[regexp {^([a-zA-Z]+[0-9]*)$} $fms dummy f]} { 562 lappend fmt [list $f ""] 563 } 564 } 565 } else { 566 set fmt [WPCmd PEMailbox indexformat] 567 } 568 569 cgi_text "index-format=$fmt" type=hidden notab 570 571 cgi_table cellpadding=0 cellspacing=0 width=100% align=center "bgcolor=#999999" "style=\"border: 1px solid black \"" border=0 { 572 cgi_table_row "bgcolor=#999999" { 573 if {[WPCmd PEInfo feature enable-aggregate-command-set]} { 574 cgi_td [cgi_img [WPimg dot2]] 575 cgi_td width=1 [cgi_img [WPimg dot2] width=1] 576 } 577 578 foreach fme $fmt { 579 set f [lindex $fme 0] 580 set w [lindex $fme 1] 581 cgi_td xcolspan=3 [cgi_span "style=font-size: 10px; color: white;" $f] 582 if {[regexp {[0123456789]+[%]} $w]} { 583 cgi_td xcolspan=2 align=right [cgi_span "style=font-size: 10px; color: white; padding-right: 4" "(${w})"] 584 } else { 585 cgi_td width=1 [cgi_img [WPimg dot2] width=1] 586 } 587 588 cgi_td width=1 [cgi_img [WPimg dot2] width=1] 589 } 590 } 591 592 cgi_table_row { 593 if {[WPCmd PEInfo feature enable-aggregate-command-set]} { 594 cgi_table_data background="[WPimg bg_index]" align=center valign=middle "style=\"padding-left: 4; padding-right: 4\"" { 595 cgi_checkbox bogus 596 } 597 598 cgi_td width=1 [cgi_img [WPimg dot2] width=1] 599 } 600 601 foreach fme $fmt { 602 set f [lindex $fme 0] 603 set w [lindex $fme 1] 604 605 switch -regexp $w { 606 [0123456789]+[%] { 607 set width width=$w 608 } 609 "" { 610 set r [WPTFIndexWidthRatio $fmt $f] 611 switch $r { 612 1 { set width "" } 613 default { 614 set width "width=[expr {round((100/[llength $fmt]) * $r)}]%" 615 } 616 } 617 } 618 } 619 620 set align "" 621 set class "" 622 switch [string toupper [lindex $f 0]] { 623 TO { 624 set varval [WPCmd PEConfig varget personal-name] 625 if {[string length [lindex $varval 0]]} { 626 set ftext "To: [lindex $varval 0]" 627 } else { 628 set ftext "To: <sender@foo.bar.com>" 629 } 630 } 631 FROM - 632 FROMORTO { 633 set varval [WPCmd PEConfig varget personal-name] 634 if {[string length [lindex $varval 0]]} { 635 set ftext [lindex $varval 0] 636 } else { 637 set ftext "<sender@foo.bar.com>" 638 } 639 } 640 FULLSTATUS - 641 IMAPSTATUS - 642 STATUS { 643 set ftext "+N" 644 set align "align=center" 645 } 646 MSGNO { 647 set ftext [WPcomma [WPCmd PEMailbox messagecount]] 648 set align "align=center" 649 } 650 SIZE { 651 set ftext [cgi_span class=isize "(1234)"] 652 set class class=isize 653 set align "align=center" 654 } 655 KSIZE { 656 set ftext [cgi_span class=isize "(1K)"] 657 set class class=isize 658 set align "align=center" 659 } 660 SIZECOMMA { 661 set ftext [cgi_span class=isize "(1,234)"] 662 set class class=isize 663 set align "align=center" 664 } 665 DESCRIPSIZE { 666 set ftext "(short+)" 667 set align "align=center" 668 } 669 SIZENARROW { 670 set ftext (1K) 671 } 672 DATE { 673 set ftext [clock format [clock seconds] -format "%b %d"] 674 set align "align=center" 675 } 676 DATEISO { 677 set ftext [clock format [clock seconds] -format "%Y-%m-%d"] 678 set align "align=center" 679 } 680 SHORTDATE1 { 681 set ftext [clock format [clock seconds] -format "%m/%d/%y"] 682 set align "align=center" 683 } 684 SHORTDATE2 { 685 set ftext [clock format [clock seconds] -format "%d/%m/%y"] 686 set align "align=center" 687 } 688 SHORTDATE3 { 689 set ftext [clock format [clock seconds] -format "%d.%m.%y"] 690 set align "align=center" 691 } 692 SHORTDATE4 { 693 set ftext [clock format [clock seconds] -format "%y.%m.%d"] 694 set align "align=center" 695 } 696 SHORTDATEISO { 697 set ftext [clock format [clock seconds] -format "%y-%m-%d"] 698 set align "align=center" 699 } 700 SMARTTIME - 701 SMARTDATETIME - 702 TIME12 { 703 regsub {^0*(.*)$} [string tolower [clock format [clock seconds] -format "%I:%M%p"]] {\1} ftext 704 set align "align=center" 705 } 706 TIME24 { 707 set ftext [clock format [clock seconds] -format "%H:%M"] 708 set align "align=center" 709 } 710 TIMEZONE { 711 set ftext [clock format [clock seconds] -format "%z"] 712 set align "align=center" 713 } 714 SUBJECT { 715 set ftext "Re: Config changes..." 716 } 717 ATT { 718 set ftext "1" 719 } 720 CC { 721 set ftext "user@domain" 722 } 723 FROMORTONOTNEWS { 724 set ftext "news.group" 725 } 726 LONGDATE { 727 set ftext [clock format [clock seconds] -format "%b %d, %Y"] 728 set align "align=center" 729 } 730 MONTHABBREV { 731 set ftext [clock format [clock seconds] -format "%b"] 732 set align "align=center" 733 } 734 NEWS { 735 set ftext "news.group" 736 } 737 SENDER - 738 RECIPS - 739 NEWSANDTO - 740 RECIPSANDNEWS - 741 NEWSANDRECIPS { 742 set ftext "user@domain" 743 } 744 SCORE { 745 set ftext "50" 746 } 747 SMARTDATE { 748 set ftext "Today" 749 } 750 TOANDNEWS { 751 set ftext TOANDNEWS 752 } 753 default { 754 set ftext [lindex $f 0] 755 } 756 } 757 cgi_td $align $class $width nowrap height=34 colspan=2 "style=\"padding-right: 4; padding-left: 4\"" background="[WPimg bg_index]" $ftext 758 cgi_td width=1 [cgi_img [WPimg dot2] width=1] 759 } 760 } 761 762 cgi_table_row { 763 if {[WPCmd PEInfo feature enable-aggregate-command-set]} { 764 cgi_table_data "bgcolor=#ffffff" { 765 cgi_put [cgi_img [WPimg dot2]] 766 } 767 768 cgi_td width=1 [cgi_img [WPimg dot2] width=1] 769 770 set cols 2 771 } else { 772 set cols 0 773 } 774 775 set fmturl "wp.tcl?page=conf_process&wv=msgl&adjust=Change&cid=[WPCmd PEInfo key]&oncancel=$oncancel&index-format=[WPPercentQuote $fmt]" 776 foreach fme $fmt { 777 cgi_table_data colspan=2 nowrap "bgcolor=#ffffff" align=center valign=middle { 778 set cellurl "${fmturl}&ifield=[lindex $fme 0]" 779 cgi_puts [cgi_url [cgi_img [WPimg if_left] border=0 "alt=Move Field Left" height=11 width=11] "${cellurl}&iop=left" target=_top] 780 cgi_puts [cgi_url [cgi_img [WPimg if_wider] border=0 "alt=Widen Field" height=11 width=11] "${cellurl}&iop=widen" target=_top] 781 cgi_puts [cgi_url [cgi_img [WPimg if_remove] border=0 "alt=Remove Field" height=11 width=11] "${cellurl}&iop=remove" target=_top] 782 cgi_puts [cgi_url [cgi_img [WPimg if_narrow2] border=0 "alt=Narrow Field" height=11 width=11] "${cellurl}&iop=narrow" target=_top] 783 cgi_puts [cgi_url [cgi_img [WPimg if_right] border=0 "alt=Move Field Right" height=11 width=11] "${cellurl}&iop=right" target=_top] 784 } 785 786 cgi_td width=1 [cgi_img [WPimg dot2] width=1] 787 } 788 } 789 } 790 791 if {[catch {WPCmd PEConfig indextokens} tokens] == 0} { 792 cgi_division align=center {style="margin-top: 16; margin-bottom: 10"} { 793 cgi_submit_button "indexadd=Add Field" 794 cgi_image_button "hlp.index_tokens=[WPimg cf_help]" alt="Help for $vardesc" 795 cgi_select indexaddfield { 796 cgi_option {[ Choose Field to Insert ]} "value=" 797 798 foreach af [lsort -dictionary $tokens] { 799 if {[lsearch $fmt $af] < 0} { 800 if {[string compare $af MSGNO]} { 801 cgi_option $af "value=$af" 802 } else { 803 cgi_option $af "value=$af" selected 804 } 805 } 806 } 807 } 808 } 809 } 810 811 cgi_puts "</fieldset>" 812 } 813 } 814 } 815 view-colors { 816 cgi_table_row { 817 cgi_table_data colspan=4 { 818 cgi_puts "<fieldset style=\"margin-left:1%; margin-right:1%\">" 819 #set helpbut [cgi_buffer {cgi_image_button "hlp.$varname=[WPimg cf_help]" alt="Help for $vardesc"}] 820 cgi_puts "<legend>Color Settings </legend>" 821 822 cgi_division class=instr "style=\"padding-bottom: 6\"" { 823 cgi_put [cgi_span "style=padding: 2; background-color: #ffcc66; border: 1px solid black" "1"] 824 cgi_put " Choose text below to color, or[cgi_nbspace]enter[cgi_nbspace]field[cgi_nbspace]" 825 cgi_text newfield= class=instr size=12 maxlength=32 826 cgi_put "[cgi_nbspace]to[cgi_nbspace]" 827 cgi_submit_button "addfield=add to colored headers" 828 } 829 830 set std_hdrs [list Date From To Cc Subject] 831 set samp_hdrs $std_hdrs 832 set samp_text [list normal quote1 quote2 quote3] 833 set colors {} 834 835 foreach goodkolor $samp_text { 836 set tcolor [WPCmd PEConfig colorget "${goodkolor}"] 837 lappend colors [list $goodkolor [lindex $tcolor 0] [lindex $tcolor 1]] 838 } 839 840 set hcolors [WPCmd PEConfig colorget "viewer-hdr-colors"] 841 set hi 0 842 foreach hcolor $hcolors { 843 set i 0 844 set dhdr 0 845 foreach samp_hdr $samp_hdrs { 846 if {[string compare [string tolower [lindex $hcolor 0]] [string tolower [lindex $samp_hdr 0]]] == 0} { 847 if {[string length [lindex $hcolor 3]] == 0} { 848 switch -- $samp_hdr { 849 Date { 850 set samptxt [clock format [clock seconds] -format "%a, %d %b %Y %H:%M:%S %Z"] 851 } 852 From { 853 set samptxt [WPCmd PECompose from] 854 } 855 Subject { 856 set samptxt "Your colors are Fabulous!" 857 } 858 default { 859 set samptxt Sample 860 } 861 } 862 lappend samp_hdr [list [lindex $hcolor 1] [lindex $hcolor 2] $samptxt "" $hi] 863 set samp_hdrs [lreplace $samp_hdrs $i $i $samp_hdr] 864 set dhdr 1 865 break 866 } else { 867 lappend samp_hdr [list [lindex $hcolor 1] [lindex $hcolor 2] [lindex $hcolor 3] [lindex $hcolor 3] $hi] 868 set samp_hdrs [lreplace $samp_hdrs $i $i $samp_hdr] 869 set dhdr 1 870 break 871 } 872 } 873 incr i 874 } 875 if {$dhdr == 0} { 876 set smptxt "Sample" 877 if {[string compare "" [lindex $hcolor 3]]} { 878 set smptxt [lindex $hcolor 3] 879 } 880 lappend samp_hdrs [list [lindex $hcolor 0] [list [lindex $hcolor 1] [lindex $hcolor 2] $smptxt [lindex $hcolor 3] $hi]] 881 } 882 incr hi 883 } 884 885 set dfgc "ffffff" 886 set dbgc "000000" 887 set dq1fgc "ffffff" 888 set dq1bgc "000000" 889 set dq2fgc "ffffff" 890 set dq2bgc "000000" 891 set dq3fgc "ffffff" 892 set dq3bgc "000000" 893 894 foreach color $colors { 895 switch -- [lindex $color 0] { 896 normal { 897 set dfgc [lindex $color 1] 898 set dbgc [lindex $color 2] 899 } 900 quote1 { 901 set dq1fgc [lindex $color 1] 902 set dq1bgc [lindex $color 2] 903 } 904 quote2 { 905 set dq2fgc [lindex $color 1] 906 set dq2bgc [lindex $color 2] 907 } 908 quote3 { 909 set dq3fgc [lindex $color 1] 910 set dq3bgc [lindex $color 2] 911 } 912 } 913 914 set colarr([lindex $color 0]) [list [lindex $color 1] [lindex $color 2]] 915 } 916 917 foreach hcolor $hcolors { 918 set colarr([lindex $color 0]) [list [lindex $color 1] [lindex $color 2]] 919 } 920 921 set butno -1 922 if {[catch {WPCmd PEInfo set config_defground} defground] || ![string length $defground]} { 923 set defground f 924 } 925 926 if {[catch {WPCmd PEInfo set config_deftext} deftext] || ![string length $deftext]} { 927 set deftext normal 928 } 929 930 # paint example text 931 cgi_table cellpadding=0 cellspacing=0 width=100% align=center border=0 { 932 cgi_table_row { 933 cgi_table_data align=center { 934 935 cgi_table border=0 cellpadding=0 cellspacing=0 width=100% align=center bgcolor=#${dbgc} "style=\"border-right: 1px solid black\"" { 936 937 cgi_table_row { 938 cgi_td class=dialog [cgi_img [WPimg dot2]] 939 cgi_td height=1 "bgcolor=#000000" [cgi_img [WPimg dot2] height=1] 940 } 941 942 foreach samp_hdr $samp_hdrs { 943 set field [string tolower [lindex $samp_hdr 0]] 944 incr butno 945 cgi_table_row { 946 cgi_table_data class=dialog align=center nowrap { 947 cgi_radio_button text=hdr.${field} [button_checked $deftext ${field}] 948 if {[llength $samp_hdr] == 1} { 949 set hdrfg $dfgc 950 set hdrbg $dbgc 951 } else { 952 set cp [lindex $samp_hdr end] 953 set hdrfg [lindex $cp 0] 954 set hdrbg [lindex $cp 1] 955 } 956 957 cgi_text "dfg.${field}=$hdrfg" type=hidden notab 958 cgi_text "dbg.${field}=$hdrbg" type=hidden notab 959 } 960 961 cgi_table_data class=vtext "style=\"color: #${dfgc}\; background-color: #${dbgc};\"" { 962 cgi_put "[lindex $samp_hdr 0]: " 963 964 if {[llength $samp_hdr] == 1} { 965 switch -- [lindex $samp_hdr 0] { 966 Date { 967 set samptxt [clock format [clock seconds] -format "%a, %d %b %Y %H:%M:%S %Z"] 968 } 969 From { 970 set samptxt [WPCmd PECompose from] 971 } 972 default { 973 set samptxt Sample 974 } 975 } 976 977 button_text text $butno $dfgc $dbgc [cgi_quote_html $samptxt] 978 cgi_text "add.${field}=1" type=hidden notab 979 } else { 980 cgi_text "hi.${field}=[lindex [lindex $samp_hdr end] end]" type=hidden notab 981 982 set pref "" 983 foreach cp [lrange $samp_hdr 1 end] { 984 button_text text $butno $hdrfg $hdrbg [cgi_quote_html "${pref}[lindex $cp 2]"] 985 set pref ", " 986 } 987 } 988 } 989 } 990 } 991 992 if {0} { 993 cgi_table_row { 994 cgi_td class=dialog [cgi_nbspace] 995 cgi_table_data { 996 cgi_text newfield= class=vtext 997 cgi_submit_button "addfield=Add New Header Field" class=vtext 998 } 999 } 1000 } 1001 1002 cgi_table_row { 1003 cgi_td class=dialog [cgi_nbspace] 1004 cgi_td class=vtext [cgi_nbspace] 1005 } 1006 1007 cgi_table_row { 1008 cgi_table_data class=dialog align=center { 1009 incr butno 1010 cgi_radio_button text=normal [button_checked $deftext normal] 1011 cgi_text "dfg.normal=$dfgc" type=hidden notab 1012 cgi_text "dbg.normal=$dbgc" type=hidden notab 1013 } 1014 1015 cgi_table_data class=vtext "style=\"color: #${dfgc}\; background-color: #${dbgc}\"" { 1016 button_text text $butno $dfgc $dbgc "This is a rather silly message." 1017 } 1018 } 1019 1020 cgi_table_row { 1021 cgi_td class=dialog [cgi_nbspace] 1022 cgi_td class=vtext [cgi_nbspace] 1023 } 1024 1025 cgi_table_row { 1026 cgi_td class=dialog [cgi_img [WPimg dot2]] 1027 cgi_table_data colspan=2 class=vtext "style=\"color: #${dfgc}\; background-color: #${dbgc}\"" { 1028 cgi_put "On Apr 1, 2001, Sample wrote:</a>" 1029 } 1030 } 1031 1032 cgi_table_row { 1033 cgi_table_data class=dialog align=center { 1034 incr butno 1035 cgi_radio_button text=quote3 [button_checked $deftext quote3] 1036 cgi_text "dfg.quote3=[lindex $colarr(quote3) 0]" type=hidden notab 1037 cgi_text "dbg.quote3=[lindex $colarr(quote3) 1]" type=hidden notab 1038 } 1039 1040 cgi_table_data class=vtext "style=\"color: #${dfgc}\; background-color: #${dbgc}\"" { 1041 cgi_put [cgi_span "style=color: #[lindex $colarr(quote1) 0]; background-color: #[lindex $colarr(quote1) 1]" "> "] 1042 cgi_put [cgi_span "style=color: #[lindex $colarr(quote2) 0]; background-color: #[lindex $colarr(quote2) 1]" "> "] 1043 button_text text $butno [lindex $colarr(quote3) 0] [lindex $colarr(quote3) 1] "> This is an example of text that is quoted 3 times" 1044 } 1045 } 1046 1047 cgi_table_row { 1048 cgi_table_data class=dialog align=center { 1049 incr butno 1050 cgi_radio_button text=quote2 [button_checked $deftext quote2] 1051 cgi_text "dfg.quote2=[lindex $colarr(quote2) 0]" type=hidden notab 1052 cgi_text "dbg.quote2=[lindex $colarr(quote2) 1]" type=hidden notab 1053 } 1054 1055 cgi_table_data class=vtext "style=\"color: #${dfgc}\; background-color: #${dbgc}\"" { 1056 cgi_put [cgi_span "style=color: #[lindex $colarr(quote1) 0]; background-color: #[lindex $colarr(quote1) 1]" "> "] 1057 button_text text $butno [lindex $colarr(quote2) 0] [lindex $colarr(quote2) 1] "> This is an example of text that is quoted 2 times" 1058 } 1059 } 1060 1061 cgi_table_row { 1062 cgi_table_data class=dialog align=center { 1063 incr butno 1064 cgi_radio_button text=quote1 [button_checked $deftext quote1] 1065 cgi_text "dfg.quote1=[lindex $colarr(quote1) 0]" type=hidden notab 1066 cgi_text "dbg.quote1=[lindex $colarr(quote1) 1]" type=hidden notab 1067 } 1068 cgi_table_data class=vtext "style=\"color: #${dfgc}\; background-color: #${dbgc}\"" { 1069 button_text text $butno [lindex $colarr(quote1) 0] [lindex $colarr(quote1) 1] "> This is an example of text that is quoted 1 time" 1070 } 1071 } 1072 1073 if {[llength [WPCmd PEInfo signature]]} { 1074 cgi_table_row "style=\"border-right: 1px solid black\"" { 1075 cgi_td class=dialog [cgi_img [WPimg dot2]] 1076 cgi_table_data class=vtext "style=\"color: #${dfgc}\; background-color: #${dbgc}\"" { 1077 foreach i [WPCmd PEInfo signature] { 1078 cgi_puts "$i[cgi_nl]" 1079 } 1080 } 1081 } 1082 } 1083 1084 cgi_table_row { 1085 cgi_td class=dialog [cgi_img [WPimg dot2]] 1086 cgi_td height=1 "bgcolor=#000000" [cgi_img [WPimg dot2] height=1] 1087 } 1088 } 1089 } 1090 } 1091 1092 cgi_table_row { 1093 cgi_table_data align=center "style=\"padding-top: 16\"" { 1094 cgi_table width=100% border=0 { 1095 1096 cgi_table_row colspan=2 { 1097 cgi_td valign=top align=left xrowspan=3 class=instr "style=\"padding-right: 4; background-color: #ffcc66; border: 1px solid black\"" [cgi_span "style=padding: 2;" "2"] 1098 cgi_td width=30% colspan=2 valign=top class=instr "Choose fore- or background..." 1099 cgi_td rowspan=3 width=3% [cgi_img [WPimg dot2]] 1100 cgi_td valign=top align=left xrowspan=3 class=instr "style=\"padding-right: 4; background-color: #ffcc66; border: 1px solid black\"" [cgi_span "style=padding: 2;" "3"] 1101 cgi_table_data valign=middle class=instr nowrap { 1102 cgi_put "Choose item's color below, or[cgi_nbspace]" 1103 cgi_submit_button "reset=restore its default colors" 1104 } 1105 } 1106 1107 cgi_table_row { 1108 cgi_td rowspan=2 [cgi_img [WPimg dot2]] 1109 cgi_table_data align=right { 1110 if {[string compare $defground f] == 0} { 1111 set checked checked 1112 } else { 1113 set checked "" 1114 } 1115 1116 cgi_radio_button ground=f $checked 1117 } 1118 1119 cgi_table_data "style=\"font-size: 10pt\"" { 1120 button_text ground 0 "" "" Foreground 1121 } 1122 1123 cgi_td rowspan=2 [cgi_img [WPimg dot2]] 1124 cgi_table_data rowspan=2 { 1125 cgi_image_button "colormap=[WPimg nondither10x10]" alt="Color Pattern" "style=\"border: 1px solid black\"" 1126 } 1127 } 1128 1129 cgi_table_row { 1130 cgi_table_data align=right { 1131 if {[string compare $defground b] == 0} { 1132 set checked checked 1133 } else { 1134 set checked "" 1135 } 1136 1137 cgi_radio_button ground=b $checked 1138 } 1139 1140 cgi_table_data "style=\"font-size: 10pt\"" { 1141 button_text ground 1 "" "" [cgi_span "style=color: black; background-color: #FFCC66; padding: 4" "Background"] 1142 } 1143 } 1144 } 1145 } 1146 } 1147 1148 cgi_table_row { 1149 cgi_table_data colspan=2 align=center class=instr nowrap "style=\"padding-top: 16; padding-bottom: 10;\"" { 1150 cgi_puts "Alternatively, you can also " 1151 cgi_submit_button "reset=Restore All Color Defaults" 1152 } 1153 } 1154 1155 if {0} { 1156 cgi_table_row { 1157 cgi_table_data class=instr nowrap "style=\"padding-top: 16; padding-bottom: 10;\"" { 1158 cgi_put [cgi_span "style=padding: 2; background-color: #ffcc66; border: 1px solid black" "OR"] 1159 cgi_put " Enter header name[cgi_nbspace]" 1160 cgi_text newfield= class=vtext 1161 cgi_put "[cgi_nbspace]to[cgi_nbspace]" 1162 cgi_submit_button "addfield=Add to Those Being Colored" 1163 } 1164 } 1165 } 1166 } 1167 1168 cgi_puts "</fieldset>" 1169 } 1170 } 1171 } 1172 } 1173 } 1174 } 1175 incr icnt 1176 } 1177 } 1178 } 1179 } 1180 } 1181 } 1182 } 1183} 1184