-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.lc
167 lines (139 loc) · 5.51 KB
/
index.lc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?lc
global gRigA -- array keys are: EXT, FCPATH, SELF, BASEPATH, APPPATH, errorData, databaseID, docTypes, systemFolder
-- controller, handler, module, COOKIE, segments, rSegments, applicationFolder, activeRecord, CLI, IsCreate
##
#---------------------------------------------------------------
# SYSTEM FOLDER NAME
#---------------------------------------------------------------
#
# This variable must contain the name of your "system" folder.
# Include the path if the folder is not in the same directory
# as this file.
#
# NO TRAILING SLASH!
# PATH MUST USE UNIX STYLE DIRECTORY SEPARATORS
#
##
put "system" into gRigA["systemFolder"]
##
#---------------------------------------------------------------
# APPLICATION FOLDER NAME
#---------------------------------------------------------------
#
# If you want this front controller to use a different "application"
# folder then the default one you can set its name here. The folder
# can also be renamed or relocated anywhere on your server.
# For more info please see the user guide:
# http://www.revigniter.com/userGuide/general/managing_apps.html
#
#
# NO TRAILING SLASH!
# PATH MUST USE UNIX STYLE DIRECTORY SEPARATORS
#
##
put "application" into gRigA["applicationFolder"]
##
#===============================================================
# END OF USER CONFIGURABLE SETTINGS
#===============================================================
##
##
#---------------------------------------------------------------
# SET THE SERVER PATH
#---------------------------------------------------------------
#
# Let's attempt to determine the full-server path to the "system"
# folder in order to reduce the possibility of path problems.
# Note: We only attempt this if the user hasn't specified a
# full server path.
#
##
put $_SERVER["PATH_TRANSLATED"] into sTempPath
# CHECK IF THE APPLICATION IS LOADED VIA THE CLI
#
if sTempPath is empty then
put TRUE into gRigA["CLI"]
if the outputLineEndings = "cr" then
set the outputLineEndings to "lf"
end if
put the defaultFolder & "/index.lc" into sTempPath
end if -- if sTempPath is empty
##
put (the platform is "Win32") into sIsWin
if sIsWin is TRUE then
replace "\" with "/" in sTempPath
end if
set the itemdel to "/"
# IN RARE CASES THE SERVER GLOBAL GIVES THE WRONG PATH
# TO THE CURRENT SCRIPT (index.lc). SO, REMOVE URI SEGMENT STRINGS
# AND STORE THE CORRECT PATH IN gRigA TO BE USED BY OTHER SCRIPTS
if "index" is not in item -1 of sTempPath then
put (char 1 to (offset("index.lc", sTempPath ) - 1) of sTempPath) & "index.lc" into sTempPath
end if
put sTempPath into gRigA["pathTranslated"]
if ((sIsWin is FALSE) and (char 1 of gRigA["systemFolder"] is not "/")) or ((sIsWin is TRUE) and (char 2 of gRigA["systemFolder"] is not ":")) then
put item 1 to -2 of sTempPath & "/" & gRigA["systemFolder"] into gRigA["systemFolder"]
end if
##
#---------------------------------------------------------------
# DEFINE APPLICATION (CONSTANTS) GLOBALS
#---------------------------------------------------------------
#
# SHOULD BE CONSTANTS, BUT AS VALUES MUST BE LITERAL STRINGS
# AND THE VALUES ARE VARIABLES WE DECLARE GLOBALS
# TO USE MERGE IS NO SOLUTION AS THIS DOES NOT WORK WITH iRev
# EXT - The file extension. Typically ".lc"
# FCPATH - The full server path to THIS file
# SELF - The name of THIS file (typically "index.lc")
# BASEPATH - The full server path to the "system" folder
# APPPATH - The full server path to the "application" folder
#
##
put item -1 of sTempPath into sTempFileName
set the itemdel to "."
--constant EXT = "." & item -1 of sTempFileName
--constant FCPATH = sTempPath
--constant SELF = sTempFileName
--constant BASEPATH = gRigA["systemFolder"] & "/"
--constant EXT = "[[" & quote & "." & quote && "item -1 of sTempFileName]]"
--constant FCPATH = "[[sTempPath]]"
--constant SELF = "[[sTempFileName]]"
--constant BASEPATH = "[[gRigA["systemFolder"]" && quote & "/" & quote & "]]"
put "." & item -1 of sTempFileName into gRigA["EXT"]
put sTempPath into gRigA["FCPATH"]
put sTempFileName into gRigA["SELF"]
put gRigA["systemFolder"] & "/" into gRigA["BASEPATH"]
if (char 1 of gRigA["applicationFolder"] is "/") or ((sIsWin is TRUE) and (char 2 of gRigA["applicationFolder"] is ":")) then
# Absolute path
-- constant APPPATH = gRigA["applicationFolder"] & "/"
put gRigA["applicationFolder"] & "/" into gRigA["APPPATH"]
else
# Relative path
if gRigA["applicationFolder"] is "" then put "application" into gRigA["applicationFolder"]
set the itemDel to slash
# look for app folder relative to the index folder
if there is a folder (item 1 to -2 of sTempPath & "/" & gRigA["applicationFolder"]) then
-- constant APPPATH = index folder & "/" & gRigA["applicationFolder"] & "/"
put item 1 to -2 of sTempPath & "/" & gRigA["applicationFolder"] & "/" into gRigA["APPPATH"]
else
# app folder must me relative to system folder
-- constant APPPATH = BASEPATH & gRigA["applicationFolder"] & "/"
put gRigA["BASEPATH"] & gRigA["applicationFolder"] & "/" into gRigA["APPPATH"]
end if
end if
set the itemDel to comma
delete variable sTempPath
delete variable sIsWin
delete variable sTempFileName
##
#---------------------------------------------------------------
# LOAD THE FRONT CONTROLLER
#---------------------------------------------------------------
#
# And away we go...
#
##
include gRigA["BASEPATH"] & "revigniter/RevIgniter" & gRigA["EXT"]
--| END OF index.lc
--| Location: ./index.lc
----------------------------------------------------------------------