[!]******************************************************** ** FILE: euca_ext_rev2.2.inc ** By: Euca Design Center ** Description: EDC's standard library of functions for Extending WebDNA ** How To Use: can be "[included]'ed" into the top of any WebDNA template, or can be added to your "FunctionDefs/" directory to be used as a pre-parse script for global access. ** REQUIREMENTS: WebDNA 6.x and above ** function naming convention prefix "euca_" ** Change History: Jul 1 2010 Fixing to be more compatible with the new fastCGI version. - euca_global_id now creates the global ID in the root of where this file is (called by default) Mar 24 2009 Initial revision: Donovan ****************************************************[/!][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_list ** Description: List all function names availabe in this Library. ** Input: none ** ouput: function names [/!][function name=euca_list] [return][grep search=%09&replace=][grep search=[%0D%0A]&replace=
] euca_libversion - the version number of this library. euca_list - List all function names available in this library euca_getdomain - returns the domain name only of the template you are on euca_dtstamp - Tom Duke's, date and time stamp in seconds since epoch. euca_dateback - retreive the date back from euca_dtstamp [raw][euca_dateback dtstamp=%3Cdt in seconds%3E][/raw] euca_timeback - retreive the time back from euca_dtstamp [raw][euca_timeback dtstamp=%3Cdt in seconds%3E][/raw] euca_global_id - ever have problems with relational id's breaking when deleting records? never again! read the description in the .inc file for a detailed description. euca_301redirect - immediately innitiat a 301 (permanent) redirect. Bugs: currently only works on certain platoforms and web servers. euca_vardisplay - put this tag in your template at the bottom of the page (or where appropriate) to see all applicable vars and their values. [/grep][/grep][/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_libversion ** Description: returns the version number of this library ** ouput: number [/!][function name=euca_libversion] [return]2.2[/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_getdomain ** Description: returns the domain name only ("www.yourdomain.com") of the template you have accessed ** Input: none ** ouput: domain name [/!][function name=euca_getdomain] [return][ListMIMEHeaders name=host&exact=F][url][value][/url][/ListMIMEHeaders][/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_dtstamp ** Description: returns a date and time stamp in the form of seconds since (WebDNA) epoch ** Input: none ** ouput: date/time stamp ** credits: Tom Duke [/!][function name=euca_dtstamp] [return][math]((([math]{[date %m/%d/%Y]}[/math])-1)*86400)+([math]{[time]}[/math])[/math][/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_dateback ** Description: returns the euca_dtstamp back to a human readable date ** Input: date and time stamp in seconds since epoch ** params: dtstamp= (required) ** ouput: human readable date ** credits: Tom Duke ** example: [euca_dateback dtstamp=
] [/!][function name=euca_dateback] [return][format days_to_date %m/%d/%Y][format .6d][math]([dtstamp]/86400)+1[/math][/format][/format][/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_timeback ** Description: returns the euca_dtstamp back to a human readable time ** Input: date and time stamp in seconds since epoch ** params: dtstamp= (required) ** ouput: human readable time ** credits: Tom Duke ** example: [euca_timeback dtstamp=
] [/!][function name=euca_timeback] [return][format seconds_to_time][math][stamp]-(86400*[format .6d][math]([stamp]/86400)[/math][/format])[/math][/format][/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_global_id ** Description: guarantee a global unique database ID using this utility. ** autonumber can break relationships of data sets when records are deleted. using euca_global_id ensures that this will never happen. Note, a euca_gid.db will be created in the directory of which this include file is called, by default, and if there is not already one. ** Input: path (can specificaly set the path for the 'euca_gid.db' database. ** ouput: global unique id record ** How to Use: Call this function within a database context (or other?) to create a unique I.D. in the "euca_gid.db" database, and to provide a unique ID for your use. ** Example: [append db=some.db]ID=[euca_global_id path=^][/append] [/!][function name=euca_global_id] [text]tCreateFile=F[/text] [text]t_path=[hideif ||[url][raw][path][/raw][/url]|^|[url][path][/url]|][path][/hideif][/text] [showif [fileinfo file=[t_path]euca_gid.db][exists][/fileinfo]=F] [!] ** create the global ID database ** [/!] [writefile file=[t_path]euca_gid.db]gid [/writefile] [/showif] [exclusivelock db=[t_path]euca_gid.db] [append db=[t_path]euca_gid.db&AUTONUMBER=gid][/append] [/exclusivelock] [commitdatabase db=[t_path]euca_gid.db] [return][LastAutonumber][/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_301redirect ** Description: provides a 301 redirect (perminant move) instead of WebDNA's innate redirect (temporary) ** Input: goto= (full URL to redirect to) ** ouput: immediately redirects to new URL ** BUGS *: Currently, this code only works on certain platforms/OS's ** Example: [euca_301redirect goto=] [/!][function name=euca_301redirect] [hideif ||[url][raw][goto][/raw][/url]|^|[url][goto][/url]|] [text]CRLF=[unurl]%0D%0A[/unurl][/text] [text]result=HTTP/1.1 301 Moved Permanently Location: [goto][/text] [/hideif] [return][returnraw][result][CRLF][CRLF][/returnraw][/return] [/function][!] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FUNCTION Name: euca_vardisplay ** Description: allows immediate viewing of all live variables within their category. ** Input: 'commented' will put the results within elements for more transparent troubleshooting (view source to see it) ** output: values of live variables ** BUGS: none ** Example: [euca_vardisplay] [/!][function name=euca_vardisplay] [if "[url][params_string][/url]"^"[url]commented[/url]"] [then] [return] [/return] [/then] [else] [return]
FormVars:
[formvariables] [index])[name]=[value]
[/formvariables]
MathVars:
[listvariables type=math] [index])[name]=[value]
[/listvariables]
TextVars:
[listvariables type=text] [index])[name]=[value]
[/listvariables]
[/return] [/else] [/if] [/function]