~ubuntu-branches/debian/squeeze/alpine/squeeze

« back to all changes in this revision

Viewing changes to web/cgi/alpine/common.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./tclsh
 
2
# $Id: common.tcl 391 2007-01-25 03:53:59Z mikes@u.washington.edu $
 
3
# ========================================================================
 
4
# Copyright 2006 University of Washington
 
5
#
 
6
# Licensed under the Apache License, Version 2.0 (the "License");
 
7
# you may not use this file except in compliance with the License.
 
8
# You may obtain a copy of the License at
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# ========================================================================
 
13
 
 
14
#  common.tcl
 
15
#
 
16
#  Purpose:  CGI script snippet to generate html output associated
 
17
#            with the WebPine message view/index ops frame
 
18
#
 
19
#  Input:
 
20
set ops_vars {
 
21
}
 
22
 
 
23
 
 
24
# inherit global config
 
25
source ./alpine.tcl
 
26
source cmdfunc.tcl
 
27
 
 
28
set padleft 3px
 
29
 
 
30
#
 
31
# Command Menu definition for Message View Screen
 
32
#
 
33
set view_menu {
 
34
}
 
35
 
 
36
set common_menu {
 
37
  {
 
38
    {expr {0}}
 
39
    {
 
40
      {
 
41
        # * * * * UBIQUITOUS INBOX LINK * * * *
 
42
        if {[string compare inbox [string tolower [WPCmd PEMailbox mailboxname]]]} {
 
43
          cgi_put [cgi_url INBOX open.tcl?folder=INBOX&colid=0&cid=[WPCmd PEInfo key] target=_top class=navbar]
 
44
        } else {
 
45
          cgi_put [cgi_url INBOX fr_index.tcl target=spec class=navbar]
 
46
        }
 
47
      }
 
48
    }
 
49
  }
 
50
  {
 
51
    {expr {0}}
 
52
    {
 
53
      {
 
54
        # * * * * FOLDER LIST * * * *
 
55
        cgi_puts [cgi_url "Folder List" "wp.tcl?page=folders&cid=[WPCmd PEInfo key]" target=_top class=navbar]
 
56
      }
 
57
    }
 
58
  }
 
59
  {
 
60
    {}
 
61
    {
 
62
      {
 
63
        # * * * * COMPOSE * * * *
 
64
        cgi_puts [cgi_url Compose wp.tcl?page=compose&oncancel=main.tcl&cid=[WPCmd PEInfo key] target=_top class=navbar]
 
65
      }
 
66
    }
 
67
  }
 
68
  {
 
69
    {}
 
70
    {
 
71
      {
 
72
        # * * * * RESUME * * * *
 
73
        cgi_puts [cgi_url Resume wp.tcl?page=resume&oncancel=main.tcl&cid=[WPCmd PEInfo key] target=_top class=navbar]
 
74
      }
 
75
    }
 
76
  }
 
77
  {
 
78
    {}
 
79
    {
 
80
      {
 
81
        # * * * * Addr books * * * *
 
82
        cgi_puts [cgi_url "Address Book" wp.tcl?page=addrbook&oncancel=main.tcl target=_top class=navbar]
 
83
      }
 
84
    }
 
85
  }
 
86
}
 
87
 
 
88
 
 
89
WPEval $ops_vars {
 
90
  cgi_http_head {
 
91
    WPStdHttpHdrs {} 60
 
92
  }
 
93
 
 
94
  cgi_html {
 
95
    cgi_head {
 
96
      if {[info exists _wp(exitonclose)]} {
 
97
        WPExitOnClose top.spec.body
 
98
      }
 
99
 
 
100
      WPStyleSheets
 
101
      cgi_script  type="text/javascript" language="JavaScript" {
 
102
        cgi_puts "function flip(n){"
 
103
        cgi_put  " var d = top.spec.body.document;"
 
104
        cgi_put  " var f = d.index;"
 
105
        cgi_put  " if(f && document.implementation){"
 
106
        cgi_put  "  var e = d.createElement('input');"
 
107
        cgi_put  "  var ver = navigator.appVersion;"
 
108
        cgi_put  "  if(!((ver.indexOf('MSIE')+1) && (ver.indexOf('Macintosh')+1))) e.type = 'hidden';"
 
109
        cgi_put  "  e.name = 'bod_'+n;"
 
110
        cgi_put  "  e.value = '1';"
 
111
        cgi_put  "  f.appendChild(e);"
 
112
        cgi_put  "  f.submit();"
 
113
        cgi_put  "  return false;"
 
114
        cgi_puts " }"
 
115
        cgi_puts " return true;"
 
116
        cgi_puts "}"
 
117
      }
 
118
 
 
119
      if {$_wp(keybindings)} {
 
120
        set kequiv {
 
121
          {{l} {top.location = 'wp.tcl?page=folders'}}
 
122
          {{a} {top.location = 'wp.tcl?page=addrbook'}}
 
123
          {{?} {top.location = 'wp.tcl?page=help'}}
 
124
          {{n} {if(flip('next')) top.spec.body.location = 'wp.tcl?page=body&bod_next=1'}}
 
125
          {{p} {if(flip('prev')) top.spec.body.location = 'wp.tcl?page=body&bod_prev=1'}}
 
126
          {{i} {if(top.spec.cmds) top.spec.location = 'fr_index.tcl'}}
 
127
          {{s} {if(top.spec.cmds) top.spec.cmds.document.saveform.f_name.focus()}}
 
128
          {{d} {if(top.spec.cmds) top.spec.cmds.document.delform.op[0].click()}}
 
129
          {{u} {if(top.spec.cmds) top.spec.cmds.document.delform.op[1].click()}}
 
130
          {{r} {if(top.spec.cmds) top.spec.cmds.document.replform.op.click()}}
 
131
          {{f} {if(top.spec.cmds) top.spec.cmds.document.forwform.op.click()}}
 
132
          {{ } {if(top.spec.body.document.index && flip('next')) top.spec.body.location = 'wp.tcl?page=body&bod_next=1'}}
 
133
          {{-} {if(top.spec.body.document.index && flip('prev')) top.spec.body.location = 'wp.tcl?page=body&bod_prev=1'}}
 
134
          {{z} {if(top.spec.body.document.index && top.spec.body.document.index.zoom) top.spec.body.document.index.zoom.click()}}
 
135
        }
 
136
 
 
137
        lappend kequiv [list {c} "top.location = 'wp.tcl?page=compose&oncancel=main.tcl&cid=[WPCmd PEInfo key]'"]
 
138
 
 
139
        if {[WPCmd PEInfo feature enable-full-header-cmd]} {
 
140
          lappend kequiv [list {h} "if(top.spec.cmds.document.saveform) top.spec.body.location = 'wp.tcl?page=view&fullhdr=flip'"]
 
141
        }
 
142
 
 
143
        set onload "onLoad=[WPTFKeyEquiv $kequiv {} top.spec.body] top.gen.focus();"
 
144
      }
 
145
    }
 
146
 
 
147
    cgi_body bgcolor=$_wp(bordercolor) $onload {
 
148
 
 
149
      cgi_put [cgi_url [cgi_imglink smalllogo] wp.tcl?page=help&topic=about class=navbar target=_top]
 
150
 
 
151
      cgi_br
 
152
 
 
153
      cgi_division class=navbar "style=\"background-color: $_wp(menucolor)\"" {
 
154
        cgi_division "style=\"padding: 8px 0 2px $padleft\"" {
 
155
          cgi_puts [cgi_span "style=font-weight: bold" "Current Folder"]
 
156
        }
 
157
 
 
158
        set mbn [WPCmd PEMailbox mailboxname]
 
159
        if {[string length $mbn] > 16} {
 
160
          set mbn "[string range $mbn 0 14]..."
 
161
        }
 
162
 
 
163
        cgi_division align=center {
 
164
          cgi_put [cgi_url $mbn fr_index.tcl target=spec class=navbar]
 
165
 
 
166
          switch -exact -- [WPCmd PEMailbox state] {
 
167
            readonly {
 
168
              cgi_br
 
169
              cgi_put [cgi_span "style=color: yellow; font-weight: bold" "(Read Only)"]
 
170
            }
 
171
            closed {
 
172
              cgi_br
 
173
              cgi_put [cgi_span "style=color: yellow; font-weight: bold" "(Closed)"]
 
174
            }
 
175
            ok -
 
176
            default {}
 
177
          }
 
178
        }
 
179
 
 
180
        cgi_hr "width=75%" "style=\"margin-top:8px\""
 
181
 
 
182
        # Common Navigation controls
 
183
        cgi_division align=center "style=\"padding-bottom: 4px\"" {
 
184
          cgi_put [cgi_img [WPimg but_rnd_block] border=0 "usemap=#nav" "alt=Navigation Controls"]
 
185
          cgi_map nav {
 
186
            cgi_area shape=rect coords=0,0,37,38 "href=wp.tcl?page=body&bod_prev=1" target=body "onClick=\"return flip('prev')\"" "alt=Previous"
 
187
            cgi_area shape=rect coords=0,40,32,74 "href=wp.tcl?page=body&bod_next=1" target=body "onClick=\"return flip('next')\"" "alt=Next"
 
188
            cgi_area shape=rect coords=50,0,82,38 "href=wp.tcl?page=body&bod_first=1" target=body "onClick=\"return flip('first')\"" "alt=First"
 
189
            cgi_area shape=rect coords=50,40,82,74 "href=wp.tcl?page=body&bod_last=1" target=body "onClick=\"return flip('last')\"" "alt=Last"
 
190
          }
 
191
 
 
192
          # Jump option
 
193
          if {[WPCmd PEInfo feature enable-jump-cmd]} {
 
194
            cgi_br
 
195
            cgi_form $_wp(appdir)/wp method=get target=body name=goform "style=margin-top:6" {
 
196
              cgi_text "page=body" type=hidden notab
 
197
              cgi_text gonum= class=navtext size=4 maxlength=6 "onClick=this.select()"
 
198
              if {0} {
 
199
                cgi_br
 
200
                cgi_submit_button "goto=Jump to Msg \#" class=navtext "style=margin-right:2;margin-top:6"
 
201
              } else {
 
202
                cgi_submit_button "goto=Jump" class=navtext "style=margin-right:2"
 
203
              }
 
204
            }
 
205
          }
 
206
        }
 
207
 
 
208
        cgi_hr "width=75%"
 
209
 
 
210
        cgi_division "style=\"padding: 0 0 6px $padleft\"" {
 
211
          cgi_puts [cgi_span "style=font-weight: bold" "Folders"]
 
212
          cgi_division "style=\"padding-left: 4px\"" {
 
213
            # UBIQUITOUS INBOX LINK
 
214
            if {[string compare inbox [string tolower [WPCmd PEMailbox mailboxname]]]} {
 
215
              cgi_put [cgi_url INBOX open.tcl?folder=INBOX&colid=0&cid=[WPCmd PEInfo key] target=_top class=navbar]
 
216
            } else {
 
217
              cgi_put [cgi_url INBOX fr_index.tcl target=spec class=navbar]
 
218
            }
 
219
 
 
220
            set n 0
 
221
            set fc [WPTFGetFolderCache]
 
222
            for {set i 0} {$i < [llength $fc]} {incr i} {
 
223
              set f [lindex $fc $i]
 
224
 
 
225
              if {0 == [catch {WPCmd PEFolder exists [lindex $f 0] [lindex $f 1]} result] && $result} {
 
226
                cgi_br
 
227
 
 
228
                set fn [lindex $f 1]
 
229
                if {[string length $fn] > 15} {
 
230
                  set fn "...[string range $fn end-15 end]"
 
231
                }
 
232
 
 
233
                if {[string compare [lindex $f 1] [WPCmd PEMailbox mailboxname]]} {
 
234
                  cgi_put [cgi_url $fn "open.tcl?folder=[lindex $f 1]&colid=[lindex $f 0]&cid=[WPCmd PEInfo key]" target=_top class=navbar]
 
235
                } else {
 
236
                  cgi_put [cgi_url $fn fr_index.tcl target=spec class=navbar]
 
237
                }
 
238
 
 
239
                if {[incr n] >= $_wp(fldr_cache_max)} {
 
240
                  break
 
241
                }
 
242
              }
 
243
            }
 
244
 
 
245
            cgi_br
 
246
            cgi_puts [cgi_url "More Folders..." "wp.tcl?page=folders&cid=[WPCmd PEInfo key]" target=_top class=navbar]
 
247
          }
 
248
        }
 
249
 
 
250
        cgi_hr "width=75%"
 
251
 
 
252
        # Common Operations
 
253
        cgi_division "style=\"padding: 0 0 0 $padleft\"" {
 
254
          # * * * * COMPOSE * * * *
 
255
          cgi_puts [cgi_url Compose wp.tcl?page=compose&oncancel=main.tcl&cid=[WPCmd PEInfo key] target=_top class=navbar]
 
256
          cgi_br
 
257
          # * * * * RESUME * * * *
 
258
          cgi_puts [cgi_url Resume wp.tcl?page=resume&oncancel=main.tcl&cid=[WPCmd PEInfo key] target=_top class=navbar]
 
259
          cgi_br
 
260
          # * * * * Addr books * * * *
 
261
          cgi_puts [cgi_url "Address Book" wp.tcl?page=addrbook&oncancel=main.tcl target=_top class=navbar]
 
262
        }
 
263
 
 
264
        cgi_division "style=\"padding: 12px 0 0 $padleft\"" {
 
265
          cgi_put [cgi_url "Configure" wp.tcl?page=conf_process&newconf=1&oncancel=main.tcl&cid=[WPCmd PEInfo key] class=navbar target=_top]
 
266
          cgi_br
 
267
          cgi_put [cgi_url "Get Help" wp.tcl?page=help class=navbar target=_top]
 
268
        }
 
269
 
 
270
        cgi_division "style=\"padding: 12px 0 10px $padleft\"" {
 
271
          if {[WPCmd PEInfo feature quit-without-confirm]} {
 
272
            cgi_puts [cgi_url "Quit $_wp(appname)" $_wp(serverpath)/session/logout.tcl?cid=[WPCmd PEInfo key]&sessid=$sessid target=_top class=navbar]
 
273
          } else {
 
274
            cgi_puts [cgi_url "Quit $_wp(appname)" wp.tcl?page=quit&cid=[WPCmd PEInfo key] target=_top class=navbar]
 
275
          }
 
276
        }
 
277
      }
 
278
    }
 
279
  }
 
280
}