| Package: machii_info_sample.model |
| I wrap UDFs |
| Method Summary | |
|---|---|
| public udf | init() |
| public string |
ParagraphFormat2(string stringToFormat)
I convert line feeds to BR and make html safe |
| public string |
ubbFormat(string stringToFormat, [string codeClass="codeBox"])
I convert UBB tags to html |
| Method Detail |
|---|
| init |
|---|
public udf init( )
Parameters:
Code:
<cffunction name="init" access="public" returntype="udf" output="false" displayname="" hint=""> <cfreturn this /> </cffunction>
| ParagraphFormat2 |
|---|
public string ParagraphFormat2( string stringToFormat )
I convert line feeds to BR and make html safe
Parameters:
| string stringToFormat |
Code:
<cffunction name="ParagraphFormat2" access="public" returntype="string" output="false" displayname="ParagraphFormat2" hint="I convert line feeds to BR and make html safe">
<cfargument name="stringToFormat" type="string" required="true" />
<cfscript>
var str = arguments.stringToFormat;
var spaces = "";
var regExString = "";
var nonBreakingSpaces = "";
// make html safe
str = replace(str,"<","<","ALL");
str = replace(str,">",">","ALL");
//make Windows style into Unix style
str = replace(str,chr(13)&chr(10),chr(10),"ALL");
//now make Macintosh style into Unix style
str = replace(str,chr(13),chr(10),"ALL");
//now fix tabs
str = replace(str,chr(9)," ","ALL");
// fix multiple spaces, convert up to 8 multiple spaces to
for (i=2; i LTE 8; i = i+ 1){
spaces = repeatString(" ", i - 1);
regExString = "[ ][#spaces#]";
nonBreakingSpaces = repeatString(" ",i);
str = REReplace(str, regExString, nonBreakingSpaces , "ALL");
}
//convert LFs
str = replace(str,chr(10),"<br />","ALL");
</cfscript>
<cfreturn str />
</cffunction>
| ubbFormat |
|---|
public string ubbFormat( string stringToFormat, [string codeClass="codeBox"] )
I convert UBB tags to html
Parameters:
| string stringToFormat |
| [string codeClass="codeBox"] |
Code:
<cffunction name="ubbFormat" access="public" returntype="string" output="false" displayname="ubbFormat" hint="I convert UBB tags to html"> <cfargument name="stringToFormat" type="string" required="true" /> <cfargument name="codeClass" type="string" required="false" default="codeBox" /> <cfscript> // regular expressions from http://www.depressedpress.com/DepressedPress/Content/ColdFusion/CustomTags/DP_ParseBBML/Index.cfm var formattedString = arguments.stringToFormat; //bold formattedString = rereplaceNoCase(formattedString , "\[(b|bold)\]([^[]*)\[/\1\]", "<b>\2</b>", "All"); // italics formattedString = rereplaceNoCase(formattedString , "\[(i|em)\]([^[]*)\[/\1\]", "<em>\2</em>", "All"); // underline formattedString = rereplaceNoCase(formattedString , "\[(u)\]([^[]*)\[/\1\]", "<u>\2</u>", "All"); //Quote formattedString = rereplaceNoCase(formattedString , "\[(q|quote)\]([^[]*)\[/\1\]", '<BLOCKQUOTE>\2</BLOCKQUOTE>', "All"); //code formattedString = rereplaceNoCase(formattedString , "\[(code)\]([^[]*)\[/\1\]", '<div id="codebox" class="#arguments.codeClass#"><pre>\2</pre></div>', "All"); //convert links formattedString = rereplaceNoCase(formattedString , "\[(url|link)=([^]]*)\]([^[<]*)\[/\1\]", '<a href="\2" target="_blank">\3</a>', "All"); formattedString = rereplaceNoCase(formattedString, "\[(url|link)\]([^[<]*)\[/\1\]", '<a href="\2" target="_blank">\2</a>', "All"); //convert email formattedString = ReReplaceNoCase(formattedString , "\[email=([^]]*)\]([^[]*)\[/email\]", '<a href="mailto:\1">\2</a>', "All"); formattedString = ReReplaceNoCase(formattedString , "\[email\]([^[(<]*)\[/email\]", '<a href="mailto:\1">\1</a>', "All"); //convert images formattedString = rereplaceNoCase(formattedString , "\[(img|image)\]([^[<]*)\[/(img|image)\]", '<img src="\2">', "All"); //formattedString = rereplaceNoCase(formattedString , "[ ]+(www[[:graph:]]+)[ ]+", ' <a href="http://\1">\1</a> ', "ALL"); // auto-hyperlink //formattedString = rereplaceNoCase(formattedString , "[ ]+(http://[[:graph:]]+)[ ]+", ' <a href="\1">\1</a> ', "ALL"); // auto-hyperlink </cfscript> <cfreturn formattedString /> </cffunction>