~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to web/cgi/alpine-2.0/conduit/import

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2008-09-23 12:17:56 UTC
  • mfrom: (2.1.8 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080923121756-6u4x8bwq89qlzt32
Tags: 2.00+dfsg-2
Update to package description: note that Alpine is no longer in
alpha. (Closes: #499640)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./tclsh
 
2
# $Id: import 391 2007-01-25 03:53:59Z mikes@u.washington.edu $
 
3
# ========================================================================
 
4
# Copyright 2008 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
#  import
 
15
#
 
16
#  Purpose:  CGI script that generates a page displaying a message
 
17
#            list of the indicated folder. 
 
18
#
 
19
#  Input:    PATH_INFO: [/<col_number>]/<directory_path>
 
20
#            along with possible search parameters:
 
21
set import_args {
 
22
}
 
23
 
 
24
# inherit global config
 
25
source ../alpine.tcl
 
26
 
 
27
# TEST
 
28
proc cgi_suffix {args} {
 
29
  return ""
 
30
}
 
31
 
 
32
WPEval $import_args {
 
33
 
 
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)"
 
38
    cgi_exit
 
39
  }
 
40
 
 
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"
 
49
        } else {
 
50
          WPCmd PEInfo statmsg "Can't Import File: $result"
 
51
        }
 
52
      } else {
 
53
        WPCmd PEInfo statmsg "Must provide uploaded folder name"
 
54
      }
 
55
    } else {
 
56
      WPCmd PEInfo statmsg "No Import Folder Name: $result"
 
57
    }
 
58
 
 
59
    catch {file delete -force $local_file}
 
60
  } else {
 
61
    WPCmd PEInfo statmsg "Cannot Import: $result"
 
62
  }
 
63
 
 
64
  cgi_html {
 
65
    cgi_head {
 
66
      cgi_javascript {
 
67
        cgi_puts "window.parent.hideLoading();"
 
68
        cgi_puts "window.parent.redrawFolderList();"
 
69
      }
 
70
    }
 
71
    cgi_body {}
 
72
  }
 
73
}