Home directory for Malawi's wwwroot
Duncan Ewan
2021-02-19 3e758c29e0fde36fc088efcfc88f9a3014432b64
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<cfcomponent displayname="menuNode">
 
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        default constructor code used to make sure that variables exists
        if the user does not call init()
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cfscript>
        // constructor code
        // Parent and children
        variables.parent = "";
        variables.children = arrayNew(1);
        variables.key = "";
        variables.name = "";
        variables.cfc = "";
        variables.method= "";
        variables.mode= "enter";
    </cfscript>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        init(String, String, String, String): call this method as a default constructor
            input: 
                String (name) -> menu node name that is displayed
                String (key) -> char that is used to access this node
                String (cfc) -> path to CFC that will be invoked when this node is selected
                Stirng (method) -> method to invoke on the CFC
            output: the created instance of the menuNode CFC
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->    
    <cffunction access="public" name="init" output="true" returntype="menuNode" hint="call this method as a default constructor">
        <cfargument name="name" type="string" required="yes" default="" hint="menu node name that is displayed" />
        <cfargument name="key" type="string" required="no" default="" hint="char that is used to access this node" />
        <cfargument name="cfc" type="string" required="no" default="" hint="path to CFC that will be invoked when this node is selected" />
        <cfargument name="method" type="string" required="no" default="" hint="method to invoke on the CFC" />
        <cfargument name="mode" type="string" required="no" default="enter" hint="automatically invoke the enter method for this node" />
        <cfscript>
            // Parent and children
            variables.parent = "";
            variables.children = arrayNew(1);
            variables.name = arguments.name;
            variables.key = arguments.key;
            variables.cfc = arguments.cfc;
            variables.method= arguments.method;
            variables.mode= arguments.mode;
        </cfscript>
        <cfreturn this />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        getParent(): returns the parent of the menuNode
            input: none
            output: menuNode -> the parent menuNode of this menuNode
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="getParent" access="public" returntype="any" output="false" hint="returns the parent of the menuNode">
        <cfreturn variables.parent />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        setParent(menuNode): sets the parent of this node to the passed in node
            input: menuNode (newParent) -> menuNode that is the parent of this node
            output: void
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="setParent" access="public" output="false" returntype="void" hint="sets the parent of this node to the passed in node">
        <cfargument name="newParent" type="any" required="yes" hint="menuNode that is the parent of this node" />
        <cfset variables.parent = newParent />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        isRoot(): check to see if this node is the root node
            input: none
            output: boolean -> whether or not this node is the root node
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="isRoot" access="public" returntype="boolean" output="false" hint="check to see if this node is the root node">
        <cfif isSimpleValue(variables.parent)>
            <cfreturn false />
        <cfelse>
            <cfreturn true />
        </cfif>
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        isLeaf(): check to see if this node is a leaf node (no children)
            input: none
            output: boolean -> whether or not this node is a leaf node
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="isLeaf" access="public" returntype="boolean" output="false" hint="check to see if this node is a leaf node (no children)">
        <cfif arrayLen(variables.children) NEQ 0>
            <cfreturn false />
        <cfelse>
            <cfreturn true />
        </cfif>
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        isEnterMode(): check to see if this node should execute the default enter method, 
                        useful for nodes that need the user to enter data.
            input: none
            output: boolean -> whether or not this node is a leaf node
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->    
    <cffunction name="isEnterMode" access="public" returntype="boolean" output="No">
        <cfif variables.mode eq "enter">
            <cfreturn true>
        </cfif>
        <cfreturn false>
    </cffunction>
    
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        addChild(menuNode, String, String, String, String): 
                adds the specified menuNode as a child or creates a node with the
                specified information
            input: 
                menuNode (newNode) -> existing menuNode to add as a child
                String (name) -> menu node name that is displayed
                String (key) -> char that is used to access this node
                String (cfc) -> path to CFC that will be invoked when this node is selected
                Stirng (method) -> method to invoke on the CFC
            output: menuNode -> the menuNode that was added as a child
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="addChild" access="public" output="true" returntype="menunode" hint="adds the specified menuNode as a child or creates a node with the specified information">
        <cfargument name="newNode" type="any" required="no" hint="existing menuNode to add as a child" />
        <cfargument name="name" type="string" required="no" hint="menu node name that is displayed" />
        <cfargument name="key" type="string" required="no" default="" hint="char that is used to access this node" />
        <cfargument name="cfc" type="string" required="no" default="" hint="path to CFC that will be invoked when this node is selected" />
        <cfargument name="method" type="string" required="no" default="" hint="method to invoke on the CFC" />
        <cfargument name="mode" type="string" required="no" default="enter" hint="automatically invoke the enter method for this node" />
        <cfscript>
            if (isDefined("name"))
            {
                newNode = createObject("component", "CFIDE.componentutils.gatewaymenu.menunode").init(name=arguments.name, key=arguments.key, cfc=arguments.cfc, method=arguments.method, mode=arguments.mode);
            } 
            newNode.setParent(this);
            arrayAppend(children, newNode);
           </cfscript>
        <cfreturn newNode />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        getChildren(): returns an array of child menuNodes
            input: none
            output: menuNode[] -> array of menuNodes
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="getChildren" access="public" output="false" returntype="array" hint="returns an array of child menuNodes">
        <cfreturn variables.children />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        getKey(): returns the single character key for this node
            input: none
            output: String -> key that is used to access this menuNode
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="getKey" access="public" output="false" returntype="string" hint="returns the single character key for this node">
        <cfreturn variables.key />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        setKey(String): sets the single character key for this node
            input: String (newKey) -> key that is used to access this menuNode
            output: void
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="setKey" access="public" output="false" returntype="void" hint="sets the single character key for this node">
        <cfargument name="newKey" type="string" required="yes" default="" hint="key that is used to access this menuNode" />
        <cfset variables.key = newKey>
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        getName(): returns the display name for this node
            input: none
            output: String -> the display name for this menuNode
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="getName" access="public" output="false" returntype="string" hint="returns the display name for this node">
        <cfreturn variables.name />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        setName(String): sets the display name for this node
            input: String (newName) -> display name that is used for this menuNode
            output: void
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="setName" access="public" output="false" hint="sets the display name for this node">
        <cfargument name="newName" type="string" required="yes" default="" hint="display name that is used for this menuNode">
        <cfset variables.name = newName />
    </cffunction>
 
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        getName(): returns the CFC method to invoke for this node
            input: none
            output: String -> the display name for this menuNode
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction name="getMethod" access="public" output="false" returntype="string" hint="returns the display name for this node">
        <cfreturn variables.method />
    </cffunction>
 
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        invokeCFC(): invokes the CFC that is tied to this menuNode
            input: none
            output: String -> the return string from the CFC that was invoked
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction access="public" name="invokeCFC" output="true" returntype="string" hint="invokes the CFC that is tied to this menuNode">
        <cfargument name="message" required="yes" default="" />
        <cfargument name="message_from" required="no" default="" />
        <cfargument name="message_to" required="no" default="" />
        <cfargument name="networkInfo" required="no" default="" />
        <cfargument name="method" required="no" default="" />
                
        <cfif len(arguments.method) EQ 0>
            <cfinvoke component="#variables.cfc#" method="#variables.method#" returnvariable="str">
                <cfinvokeargument name="message" value="#arguments.message#" />
                <cfinvokeargument name="message_from" value="#arguments.message_from#" />
                <cfinvokeargument name="message_to" value="#arguments.message_to#" />
                <cfinvokeargument name="networkInfo" value="#arguments.networkInfo#" />
            </cfinvoke>
        <cfelse>
            <cfinvoke component="#variables.cfc#" method="#arguments.method#" returnvariable="str">
                <cfinvokeargument name="message" value="#arguments.message#" />
                <cfinvokeargument name="message_from" value="#arguments.message_from#" />
                <cfinvokeargument name="message_to" value="#arguments.message_to#" />
                <cfinvokeargument name="networkInfo" value="#arguments.networkInfo#" />
            </cfinvoke>
        </cfif>
 
        <cfreturn str />
    </cffunction>
    
    <!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        dumpTree(): debug method that displays the menu tree
            input: void
            output: String -> string representation of the menu tree
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
    <cffunction access="public" name="dumpTree" output="true" returntype="string" hint="debug method that displays the menu tree">
        <cfargument name="level" default="0" />
        <cfscript>
            returnString = repeatString("----", level) &"(" & getKey() & ") " & getName() & "<br/>";
            aChildren = getChildren();
            for(i = 1; i LTE arrayLen(aChildren); i = i + 1)
            {
                returnString = returnString & aChildren[i].dumpTree(level+1);
            }
        </cfscript>
        <cfreturn returnString />
    </cffunction>
 
</cfcomponent>