2
# $Id: import 391 2007-01-25 03:53:59Z mikes@u.washington.edu $
3
# ========================================================================
4
# Copyright 2008 University of Washington
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
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# ========================================================================
16
# Purpose: CGI script that generates a page displaying a message
17
# list of the indicated folder.
19
# Input: PATH_INFO: [/<col_number>]/<directory_path>
20
# along with possible search parameters:
24
# inherit global config
28
proc cgi_suffix {args} {
34
# grok PATH_INFO for collection 'c' and folder path 'p'
35
if {!([info exists env(PATH_INFO)] && [string length $env(PATH_INFO)]
36
&& [regexp {^/([0-9]+)/(.*)$} $env(PATH_INFO) dummy c p])} {
37
WPCmd PEInfo statmsg "Invalid Detach: $env(SCRIPT_NAME)"
41
if {[catch {WPImport file "Missing File Upload"} result] == 0} {
42
set local_file [lindex $file 0]
43
if {[catch {WPImport newFolder "import name"} result] == 0} {
44
set iname [string trim $newFolder]
45
if {[string length $iname]} {
46
set fldr [eval "file join $p $iname"]
47
if {[catch {WPCmd PEFolder import $local_file $c $fldr} result] == 0} {
48
WPCmd PEInfo statmsg "Imported folder $iname"
50
WPCmd PEInfo statmsg "Can't Import File: $result"
53
WPCmd PEInfo statmsg "Must provide uploaded folder name"
56
WPCmd PEInfo statmsg "No Import Folder Name: $result"
59
catch {file delete -force $local_file}
61
WPCmd PEInfo statmsg "Cannot Import: $result"
67
cgi_puts "window.parent.hideLoading();"
68
cgi_puts "window.parent.redrawFolderList();"