I've been lurking here since mid August, and finally have a chance to dive
in. I've got this working fine, but since i'm starting out with CFC's in
earnest, i was wondering if anyone would mind critiquing this component to
get me on the right track. Being in Switzerland, we need to support a few
different languages in the back end interface (uLan = user language), and
decided the best way to go would be to keep the admin texts in a wddx file
right next to the form or back end display file.
Only users with "allowAdmin" permission level are allowed to edit the back
end texts, so the linked edit dots are hidden otherwise.
TIA,
Nando
<cfcomponent hint="I'm the AdminText Manager">
<cffunction name="init" access="public" returntype="com.AdminText">
<cfargument name="path" type="string" required="yes">
<cfargument name="arrLen" type="numeric" required="yes">
<cfargument name="ulan" type="string" required="yes">
<cfset variables.aText = ArrayNew(1)>
<cfset variables.path = arguments.path>
<cfset variables.ulan = arguments.ulan>
<cfset variables.arrLen = arguments.arrLen>
<cfset variables.d = LCase(ListLast(GetDirectoryFromPath(path),"\"))>
<cfset variables.f = LCase(ListFirst(GetFileFromPath(path),"."))>
<cfset wddxPath = Left(path, Len(path)-4)&'.wddx'>
<cfif FileExists(wddxPath)>
<cffile action="READ" file="#wddxPath#"
variable="adminText_wddx">
<cfif Len(Trim(adminText_wddx))>
<cfwddx action="WDDX2CFML" input="#adminText_wddx#"
output="adminText">
<cfscript>
aText = arrayNew(1);
for(i=1; i lte #ArrayLen(adminText)#; i=i+1) {
if(IsStruct(adminText[i])) {
if(StructKeyExists(adminText[i], #ulan#) AND
Len(StructFind(adminText[i], '#ulan#'))) {
aText[i] =
StructFind(adminText[i], '#ulan#');
}
else {
aText[i] =
StructFind(adminText[i], 'en');
}
}
else { aText[i] = '';}
}
</cfscript>
<cfelse>
<cfscript>
aText = arrayNew(1);
temp = ArrayResize(aText,#arrLen#);
for(i=1; i lte #arrLen#; i=i+1) {
aText[i] = "";
}
</cfscript>
</cfif>
<cfelse>
<cfscript>
aText = arrayNew(1);
temp = ArrayResize(aText,#arrLen#);
for(i=1; i lte #arrLen#; i=i+1) {
aText[i] = "";
}
</cfscript>
</cfif>
<cfset variables.aText = aText>
<cfreturn this>
</cffunction>
<cffunction name="getTextDot" access="public" output="yes">
<cfargument name="pos" required="Yes" type="numeric">
<cfif request.allowAdmin><a
href="#request.self#?fuseaction=editAdminText.edit&d=#variables.d#&f=#variab
les.f#&pos=#pos#&arrLen=#variables.arrLen#" style="width:10;"><img
src="admin/icons/editDot4.gif" width="4" height="4" hspace="3" vspace="2"
border="0"></a></cfif>#variables.aText[pos]#
</cffunction>
<cffunction name="getDot" access="public" output="yes">
<cfargument name="pos" required="Yes" type="numeric">
<cfif request.allowAdmin><a
href="#request.self#?fuseaction=editAdminText.edit&d=#variables.d#&f=#variab
les.f#&pos=#pos#&arrLen=#variables.arrLen#"><img
src="admin/icons/editDot4.gif" width="4" height="4" hspace="1" vspace="2"
border="0"></a></cfif>
</cffunction>
<cffunction access="public" name="getText">
<cfargument name="pos" required="Yes" type="numeric">
<cfreturn variables.aText[pos]>
</cffunction>
</cfcomponent>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]