~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/web/static/htdocs/applets/FCKeditor/editor/filemanager/connectors/perl/io.pl

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#####
2
 
#  FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 
#  Copyright (C) 2003-2010 Frederico Caldeira Knabben
4
 
#
5
 
#  == BEGIN LICENSE ==
6
 
#
7
 
#  Licensed under the terms of any of the following licenses at your
8
 
#  choice:
9
 
#
10
 
#   - GNU General Public License Version 2 or later (the "GPL")
11
 
#     http://www.gnu.org/licenses/gpl.html
12
 
#
13
 
#   - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
 
#     http://www.gnu.org/licenses/lgpl.html
15
 
#
16
 
#   - Mozilla Public License Version 1.1 or later (the "MPL")
17
 
#     http://www.mozilla.org/MPL/MPL-1.1.html
18
 
#
19
 
#  == END LICENSE ==
20
 
#
21
 
#  This is the File Manager Connector for Perl.
22
 
#####
23
 
 
24
 
sub GetUrlFromPath
25
 
{
26
 
        local($resourceType, $folderPath) = @_;
27
 
 
28
 
        if($resourceType eq '') {
29
 
                $rmpath = &RemoveFromEnd($GLOBALS{'UserFilesPath'},'/');
30
 
                return("$rmpath$folderPath");
31
 
        } else {
32
 
                return("$GLOBALS{'UserFilesPath'}$resourceType$folderPath");
33
 
        }
34
 
}
35
 
 
36
 
sub RemoveExtension
37
 
{
38
 
        local($fileName) = @_;
39
 
        local($path, $base, $ext);
40
 
        if($fileName !~ /\./) {
41
 
                $fileName .= '.';
42
 
        }
43
 
        if($fileName =~ /([^\\\/]*)\.(.*)$/) {
44
 
                $base = $1;
45
 
                $ext  = $2;
46
 
                if($fileName =~ /(.*)$base\.$ext$/) {
47
 
                        $path = $1;
48
 
                }
49
 
        }
50
 
        return($path,$base,$ext);
51
 
 
52
 
}
53
 
 
54
 
sub ServerMapFolder
55
 
{
56
 
        local($resourceType,$folderPath) = @_;
57
 
 
58
 
        # Get the resource type directory.
59
 
        $sResourceTypePath = $GLOBALS{'UserFilesDirectory'} . $resourceType . '/';
60
 
 
61
 
        # Ensure that the directory exists.
62
 
        &CreateServerFolder($sResourceTypePath);
63
 
 
64
 
        # Return the resource type directory combined with the required path.
65
 
        $rmpath = &RemoveFromStart($folderPath,'/');
66
 
        return("$sResourceTypePath$rmpath");
67
 
}
68
 
 
69
 
sub GetParentFolder
70
 
{
71
 
        local($folderPath) = @_;
72
 
 
73
 
        $folderPath =~ s/[\/][^\/]+[\/]?$//g;
74
 
        return $folderPath;
75
 
}
76
 
 
77
 
sub CreateServerFolder
78
 
{
79
 
        local($folderPath) = @_;
80
 
 
81
 
        $sParent = &GetParentFolder($folderPath);
82
 
        # Check if the parent exists, or create it.
83
 
        if(!(-e $sParent)) {
84
 
                $sErrorMsg = &CreateServerFolder($sParent);
85
 
                if($sErrorMsg == 1) {
86
 
                        return(1);
87
 
                }
88
 
        }
89
 
        if(!(-e $folderPath)) {
90
 
                if (defined $CHMOD_ON_FOLDER_CREATE && !$CHMOD_ON_FOLDER_CREATE) {
91
 
                        mkdir("$folderPath");
92
 
                }
93
 
                else {
94
 
                        umask(000);
95
 
                        if (defined $CHMOD_ON_FOLDER_CREATE) {
96
 
                                mkdir("$folderPath",$CHMOD_ON_FOLDER_CREATE);
97
 
                        }
98
 
                        else {
99
 
                                mkdir("$folderPath",0777);
100
 
                        }
101
 
                }
102
 
 
103
 
                return(0);
104
 
        } else {
105
 
                return(1);
106
 
        }
107
 
}
108
 
 
109
 
sub GetRootPath
110
 
{
111
 
#use Cwd;
112
 
 
113
 
#       my $dir = getcwd;
114
 
#       print $dir;
115
 
#       $dir  =~ s/$ENV{'DOCUMENT_ROOT'}//g;
116
 
#       print $dir;
117
 
#       return($dir);
118
 
 
119
 
#       $wk = $0;
120
 
#       $wk =~ s/\/connector\.cgi//g;
121
 
#       if($wk) {
122
 
#               $current_dir = $wk;
123
 
#       } else {
124
 
#               $current_dir = `pwd`;
125
 
#       }
126
 
#       return($current_dir);
127
 
use Cwd;
128
 
 
129
 
        if($ENV{'DOCUMENT_ROOT'}) {
130
 
                $dir = $ENV{'DOCUMENT_ROOT'};
131
 
        } else {
132
 
                my $dir = getcwd;
133
 
                $workdir =~ s/\/connector\.cgi//g;
134
 
                $dir  =~ s/$workdir//g;
135
 
        }
136
 
        return($dir);
137
 
 
138
 
 
139
 
 
140
 
}
141
 
1;