#!./tclsh
# $Id: filtedit.tcl 1204 2009-02-02 19:54:23Z hubert@u.washington.edu $
# ========================================================================
# Copyright 2006 University of Washington
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ========================================================================
# filtedit.tcl
#
# Purpose: CGI script to generate html form editing of a single filter
#
# include common filter info
source filter.tcl
#
# Input:
set filtedit_vars {
{cid "No cid"}
{oncancel "No oncancel"}
{onfiltcancel {} ""}
{fno {} -1}
{add {} 0}
{filterrtext {} ""}
{filtedit_score {} 0}
{filtedit_indexcolor {} 0}
{fg {} ""}
{bg {} ""}
}
# Output:
#
## read vars
foreach item $filtedit_vars {
if {[catch {cgi_import [lindex $item 0].x}]} {
if {[catch {eval WPImport $item} result]} {
if {[llength $item] > 2} {
set [lindex $item 0] [lindex $item 2]
} else {
error [list _action [lindex $item 1] $result]
}
}
} else {
set [lindex $item 0] 1
}
}
if {$filtedit_score} {
set filttype score
set filttypename Score
} elseif {$filtedit_indexcolor} {
set filttype indexcolor
set filttypename "Index Color"
} else {
set filttype filt
set filttypename Filter
}
if {[info exists filtedit_add]} {
set add $filtedit_add
}
if {[info exists filtedit_fno]} {
set fno $filtedit_fno
}
if {[info exists filtedit_onfiltcancel]} {
set onfiltcancel $filtedit_onfiltcancel
}
if {[info exists filtedit_filterrtext]} {
set filterrtext $filtedit_filterrtext
}
set filterr 0
if {[string length $filterrtext]} {
set filterr 1
}
set filtedit_menu {
{
{}
{
{
# * * * * OK * * * *
#cgi_image_button filt_save=[WPimg but_save] border=0 alt="Save Config"
cgi_submit_button "${filttype}_save=Save"
}
}
}
{
{}
{
{
# * * * * CANCEL * * * *
cgi_submit_button filtcancel=Cancel
}
}
}
{
{}
{
{
# * * * * HELP * * * *
cgi_submit_button "${filttype}help=Get Help"
}
}
}
}
proc wpGetVarAs {_var _varas} {
upvar $_varas varas
if {[catch {cgi_import_as $_var varas} result]} {
set varas ""
}
}
proc freetext_cell {intro varname varval} {
cgi_table_data align=right {
cgi_puts [cgi_bold "$intro :[cgi_nbspace][cgi_nbspace]"]
}
cgi_table_data align=left {
cgi_text "$varname=$varval" "style=margin:2"
}
}
array set idvarnames $pattern_id
array set idvarvals {}
array set patvarnames $pattern_fields
array set patvarvals {}
array set actionvarnames $pattern_actions
array set colvarnames $pattern_colors
array set scorevarnames $pattern_scores
array set actionvals {}
cgi_http_head {
cgi_content_type
cgi_pragma no-cache
}
cgi_html {
cgi_head {
WPStdHtmlHdr "$filttypename List Configuration"
WPStyleSheets
}
if {$add == 0} {
if {$filtedit_score} {
set actions $pattern_scores
set fext [WPCmd PEConfig scoreextended $fno]
} elseif {$filtedit_indexcolor} {
set actions $pattern_colors
set fext [WPCmd PEConfig indexcolorextended $fno]
} else {
set actions $pattern_actions
set fext [WPCmd PEConfig filtextended $fno]
}
foreach fvar $fext {
switch -- [lindex $fvar 0] {
id {
foreach idvar [lindex $fvar 1] {
set idname [lindex $idvar 0]
if {[info exists idvarnames($idname)]} {
set idvarvals($idname) [lindex $idvar 1]
}
}
}
pattern {
foreach patternvar [lindex $fvar 1] {
set patname [lindex $patternvar 0]
if {[info exists patvarnames($patname)]} {
set patvarvals($patname) [lindex $patternvar 1]
}
}
}
filtaction {
foreach actionvar [lindex $fvar 1] {
set actionname [lindex $actionvar 0]
if {[info exists actionvarnames($actionname)]} {
set actionvals($actionname) [lindex $actionvar 1]
}
}
}
indexcolors {
foreach colvar [lindex $fvar 1] {
set colname [lindex $colvar 0]
if {[info exists colvarnames($colname)]} {
set actionvals($colname) [lindex $colvar 1]
}
}
}
scores {
foreach colvar [lindex $fvar 1] {
set actionvals([lindex $colvar 0]) [lindex $colvar 1]
}
}
}
}
} else {
if {$filtedit_score} {
set actions $pattern_scores
} elseif {$filtedit_indexcolor} {
set actions $pattern_colors
} else {
set actions $pattern_actions
}
}
cgi_body BGCOLOR="$_wp(bordercolor)" {
cgi_form $_wp(appdir)/$_wp(ui1dir)/wp method=get name=filtconfig target=_top {
cgi_text "page=conf_process" type=hidden notab
cgi_text "cp_op=${filttype}config" type=hidden notab
cgi_text "cid=$cid" type=hidden notab
cgi_text "oncancel=$oncancel" type=hidden notab
cgi_table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%" {
cgi_table_row {
#
# next comes the menu down the left side
#
eval {
cgi_table_data $_wp(menuargs) rowspan=4 {
WPTFCommandMenu filtedit_menu {}
}
}
#
# In main body of screen goes confg list
#
cgi_table_data valign=top width="100%" class=dialog {
if {[string length $onfiltcancel]} {
cgi_text "onfiltcancel=$onfiltcancel" type=hidden notab
}
cgi_text "fno=$fno" type=hidden notab
cgi_text "subop=[expr {$add ? "add" : "edit"}]" type=hidden notab
cgi_table border=0 cellspacing=0 cellpadding=0 {
# pattern title
cgi_table_row {
cgi_table_data {
cgi_puts "
"
}
}
# Folder Conditions
wpGetVarAs folder folder
wpGetVarAs ftype ftype
cgi_table_row {
cgi_table_data colspan=2 {
cgi_puts ""
}
}
# Message Conditions
cgi_table_row {
cgi_table_data {
cgi_puts ""
}
}
cgi_table_row {
cgi_table_data "style=\"padding-bottom: 40\"" {
cgi_puts ""
}
}
}
}
}
}
}
}
}