root/trunk/website/soundings/includes/udf.cfm @ 5

Revision 5, 2.6 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfsetting enablecfoutputonly=true>
2<!---
3        Name         : udf.cfm
4        Author       : Raymond Camden
5        Created      : June 01, 2004
6        Last Updated : August 22, 2007
7        History      :
8        Purpose          :
9--->
10
11<cfscript>
12function isLoggedOn() {
13        return getAuthUser() neq "";
14}
15request.udf.isLoggedOn = isLoggedOn;
16
17/**
18 * Tests passed value to see if it is a valid e-mail address (supports subdomain nesting and new top-level domains).
19 * Update by David Kearns to support '
20 * SBrown@xacting.com pointing out regex still wasn't accepting ' correctly.
21 *
22 * @param str    The string to check. (Required)
23 * @return Returns a boolean.
24 * @author Jeff Guillaume (jeff@kazoomis.com)
25 * @version 2, August 15, 2002
26 */
27function IsEmail(str) {
28//supports new top level tlds
29if (REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$",str)) return TRUE;
30        else return FALSE;
31}
32request.udf.isEmail = isEmail;
33
34function isValidUsername(str) {
35        if(reFindNoCase("[^a-z0-9]",str)) return false;
36        return true;
37}
38request.udf.isValidUsername = isValidUsername;
39
40function cleanStruct(s) {
41        var key = "";
42        for(key in s) {
43                s[key] = trim(htmlEditFormat(s[key]));
44        }
45        return s;
46}
47request.udf.cleanStruct = cleanStruct;
48
49/**
50 * Returns a XHTML compliant string wrapped with properly formatted paragraph tags.
51 *
52 * @param string         String you want XHTML formatted.
53 * @param attributeString        Optional attributes to assign to all opening paragraph tags (i.e. style=""font-family: tahoma"").
54 * @return Returns a string.
55 * @author Jeff Howden (jeff@members.evolt.org)
56 * @version 1.1, January 10, 2002
57 */
58function XHTMLParagraphFormat(string) {
59  var attributeString = '';
60  var returnValue = '';
61 
62  //added by me to support different line breaks
63  string = replace(string, chr(10) & chr(10), chr(13) & chr(10), "all");
64 
65  if(ArrayLen(arguments) GTE 2) attributeString = ' ' & arguments[2];
66  if(Len(Trim(string)))
67    returnValue = '<p' & attributeString & '>' & Replace(string, Chr(13) & Chr(10), '</p>' & Chr(13) & Chr(10) & '<p' & attributeString & '>', 'ALL') & '</p>';
68  return returnValue;
69}
70
71request.udf.XHTMLParagraphFormat = XHTMLParagraphFormat;
72
73function arrayDefinedAt(arr,pos) {
74        var temp = "";
75        try {
76                temp = arr[pos];
77                return true;
78        }
79        catch(coldfusion.runtime.UndefinedElementException ex) {
80                return false;
81        }
82        catch(coldfusion.runtime.CfJspPage$ArrayBoundException ex) {
83                return false;
84        }
85}
86request.udf.arrayDefinedAt = arrayDefinedAt;
87</cfscript>
88
89<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.