Permalink
Browse files

Fixed asset paths because Adobe CF file tags don't support relative p…

…aths.
  • Loading branch information...
1 parent 740ecff commit e795403d48c82821f55222e0dbbc77dc6ece539e @jordanclark jordanclark committed Sep 23, 2011
Showing with 125 additions and 122 deletions.
  1. +125 −122 StatesAndCountries.cfc
View
@@ -1,123 +1,126 @@
-<!--- @@Copyright: Copyright (c) 2011 ImageAid. All rights reserved. --->
-<!--- @@License: Free :). Whatever. It's just a stupid little helper plugin --->
-<cfcomponent output="false" mixin="controller">
-
- <cfproperty name="us_states" type="query" displayname="US States" hint="I am a query representing all US states" />
- <cfproperty name="canadian_provinces" type="query" displayname="Canadian Provinces" hint="I am a query representing all Canadian Provinces" />
- <cfproperty name="us_states_and_canadian_provinces" type="query" displayname="US States and Canadian Provinces" hint="I am a query representing all Canadian Provinces and US States" />
- <cfproperty name="countries" type="query" displayname="Countries" hint="I am a query representing all countries" />
-
- <cffunction access="public" returntype="StatesAndCountries" name="init">
- <cfscript>
- this.version = "1.0.4,1.0.5,,1.1,1.1.1,1.1.2";//sets the Wheels versions the plugin is compatible with.
- return this;
- </cfscript>
- </cffunction>
-
- <cffunction name="getUSStates" returntype="query" access="public" output="false" displayname="getUSStates" hint="I return a query of structures for US states">
- <cfscript>
- return $loadElements("us_states");
- </cfscript>
- </cffunction>
-
- <cffunction name="getCanadianProvinces" returntype="query" access="public" output="false" displayname="getCanadianProvinces" hint="I return a query of structures for Canadian provinces">
- <cfscript>
- return $loadElements("canadian_provinces");
- </cfscript>
- </cffunction>
-
- <cffunction name="getUSStatesAndCanadianProvinces" returntype="query" access="public" output="false" displayname="getUSStatesAndCanadianProvinces" hint="I return a query of structures for US states and Canadian provinces">
- <cfscript>
- return $loadElements("us_states_and_canadian_provinces");
- </cfscript>
- </cffunction>
-
- <cffunction name="getCountries" returntype="query" access="public" output="false" displayname="getCountries" hint="I return a query of structures countries">
- <cfscript>
- return $loadElements("countries");
- </cfscript>
- </cffunction>
-
- <!--- PRIVATE METHODS -- sort of --->
- <cffunction name="$loadElements" access="public" returntype="query" output="false" displayname="$loadElements" hint="I setup the arrays">
- <cfargument name="item_to_load" type="string" required="false" default="us_states" displayname="item_to_load" hint="I represend the items to load" />
- <cfscript>
- var us_states_xml = xmlNew();
- var canadian_provinces_xml = xmlNew();
- var countries_xml = xmlNew();
- variables.us_states = queryNew("name,abbreviation");
- variables.canadian_provinces = queryNew("name,abbreviation");
- variables.us_states_and_canadian_provinces = queryNew("name,abbreviation");
- variables.countries = queryNew("name,abbreviation");
- </cfscript>
- <cfswitch expression="#trim(lcase(arguments.item_to_load))#">
- <cfcase value="us_states">
- <cffile action="read" file="assets/us_states.xml" variable="us_states_content" />
- <cfscript>
- if(!structKeyExists(application,"usStates")){
- us_states_xml = xmlParse(us_states_content);
- for(i = 1; i lte arrayLen(us_states_xml.XMLChildren[1].XMLChildren); i = i + 1){
- queryAddRow(variables.us_states);
- querySetCell(variables.us_states,"name",us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText);
- querySetCell(variables.us_states,"abbreviation",us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText);
- }
- application.usStates = variables.us_states;
- }
- return application.usStates;
- </cfscript>
- </cfcase>
- <cfcase value="canadian_provinces">
- <cffile action="read" file="assets/canadian_provinces.xml" variable="canadian_provinces_content" />
- <cfscript>
- if(!structKeyExists(application,"canadianProvinces")){
- canadian_provinces_xml = xmlParse(canadian_provinces_content);
- for(i = 1; i lte arrayLen(canadian_provinces_xml.XMLChildren[1].XMLChildren); i = i + 1){
- queryAddRow(variables.canadian_provinces);
- querySetCell(variables.canadian_provinces,"name",canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText);
- querySetCell(variables.canadian_provinces,"abbreviation",canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText);
- }
- application.canadianProvinces = variables.canadian_provinces;
- }
- return application.canadianProvinces;
- </cfscript>
- </cfcase>
- <cfcase value="us_states_and_canadian_provinces">
-
- <cfscript>
- if(!structKeyExists(application,"usStatesAndCanadianProvinces")){
- us_states_xml = xmlParse(us_states_content);
- canadian_provinces_xml = xmlParse(canadian_provinces_content);
- for(i = 1; i lte arrayLen(us_states_xml.XMLChildren[1].XMLChildren); i = i + 1){
- queryAddRow(variables.us_states_and_canadian_provinces);
- querySetCell(variables.us_states_and_canadian_provinces,"name",us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText);
- querySetCell(variables.us_states_and_canadian_provinces, "abbreviation", us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText);
- }
- for(i = 1; i lte arrayLen(canadian_provinces_xml.XMLChildren[1].XMLChildren); i = i + 1){
- queryAddRow(variables.us_states_and_canadian_provinces);
- querySetCell( variables.us_states_and_canadian_provinces, "name", canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText );
- querySetCell( variables.us_states_and_canadian_provinces, "abbreviation", canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText );
- }
- application.usStatesAndCanadianProvinces = variables.us_states_and_canadian_provinces;
- }
- return application.usStatesAndCanadianProvinces;
- </cfscript>
- </cfcase>
- <cfcase value="countries">
- <cffile action="read" file="assets/countries.xml" variable="countries_content" />
- <cfscript>
- if(!structKeyExists(application,"countries")){
- countries_xml = xmlParse(countries_content);
- for(i = 1; i lte arrayLen(countries_xml.XMLChildren[1].XMLChildren); i = i + 1){
- queryAddRow(variables.countries);
- querySetCell(variables.countries,"name",countries_xml.XMLChildren[1].XMLChildren[i].xmlText);
- querySetCell(variables.countries,"abbreviation",countries_xml.XMLChildren[1].XMLChildren[i].XMLAttributes.code);
- }
- application.countries = variables.countries;
- }
- return application.countries;
- </cfscript>
- </cfcase>
- </cfswitch>
- </cffunction>
-
+<!--- @@Copyright: Copyright (c) 2011 ImageAid. All rights reserved. --->
+<!--- @@License: Free :). Whatever. It's just a stupid little helper plugin --->
+<cfcomponent output="false" mixin="controller">
+
+ <cfproperty name="us_states" type="query" displayname="US States" hint="I am a query representing all US states" />
+ <cfproperty name="canadian_provinces" type="query" displayname="Canadian Provinces" hint="I am a query representing all Canadian Provinces" />
+ <cfproperty name="us_states_and_canadian_provinces" type="query" displayname="US States and Canadian Provinces" hint="I am a query representing all Canadian Provinces and US States" />
+ <cfproperty name="countries" type="query" displayname="Countries" hint="I am a query representing all countries" />
+
+ <cffunction access="public" returntype="StatesAndCountries" name="init">
+ <cfscript>
+ this.version = "1.0.4,1.0.5,1.1,1.1.1,1.1.2,1.1.5";
+ return this;
+ </cfscript>
+ </cffunction>
+
+ <cffunction name="getUSStates" returntype="query" access="public" output="false" displayname="getUSStates" hint="I return a query of structures for US states">
+ <cfscript>
+ return $loadElements("us_states");
+ </cfscript>
+ </cffunction>
+
+ <cffunction name="getCanadianProvinces" returntype="query" access="public" output="false" displayname="getCanadianProvinces" hint="I return a query of structures for Canadian provinces">
+ <cfscript>
+ return $loadElements("canadian_provinces");
+ </cfscript>
+ </cffunction>
+
+ <cffunction name="getUSStatesAndCanadianProvinces" returntype="query" access="public" output="false" displayname="getUSStatesAndCanadianProvinces" hint="I return a query of structures for US states and Canadian provinces">
+ <cfscript>
+ return $loadElements("us_states_and_canadian_provinces");
+ </cfscript>
+ </cffunction>
+
+ <cffunction name="getCountries" returntype="query" access="public" output="false" displayname="getCountries" hint="I return a query of structures countries">
+ <cfscript>
+ return $loadElements("countries");
+ </cfscript>
+ </cffunction>
+
+ <!--- PRIVATE METHODS -- sort of --->
+ <cffunction name="$loadElements" access="public" returntype="query" output="false" displayname="$loadElements" hint="I setup the arrays">
+ <cfargument name="item_to_load" type="string" required="false" default="us_states" displayname="item_to_load" hint="I represend the items to load" />
+ <cfscript>
+ var us_states_xml = xmlNew();
+ var canadian_provinces_xml = xmlNew();
+ var countries_xml = xmlNew();
+ variables.us_states = queryNew("name,abbreviation");
+ variables.canadian_provinces = queryNew("name,abbreviation");
+ variables.us_states_and_canadian_provinces = queryNew("name,abbreviation");
+ variables.countries = queryNew("name,abbreviation");
+
+ </cfscript>
+ <cfswitch expression="#trim(lcase(arguments.item_to_load))#">
+ <cfcase value="us_states">
+ <cffile action="read" file="#getDirectoryFromPath(getCurrentTemplatePath())#/assets/us_states.xml" variable="us_states_content" />
+ <cfscript>
+ if(!structKeyExists(application,"usStates")){
+ us_states_xml = xmlParse(us_states_content);
+ for(i = 1; i lte arrayLen(us_states_xml.XMLChildren[1].XMLChildren); i = i + 1){
+ queryAddRow(variables.us_states);
+ querySetCell(variables.us_states,"name",us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText);
+ querySetCell(variables.us_states,"abbreviation",us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText);
+ }
+ application.usStates = variables.us_states;
+ }
+ return application.usStates;
+ </cfscript>
+ </cfcase>
+ <cfcase value="canadian_provinces">
+ <cffile action="read" file="#expandPath( './#application.wheels.pluginPath#/StatesAndCountries/assets/canadian_provinces.xml' )#" variable="canadian_provinces_content" />
+ <cfscript>
+ if(!structKeyExists(application,"canadianProvinces")){
+ canadian_provinces_xml = xmlParse(canadian_provinces_content);
+ for(i = 1; i lte arrayLen(canadian_provinces_xml.XMLChildren[1].XMLChildren); i = i + 1){
+ queryAddRow(variables.canadian_provinces);
+ querySetCell(variables.canadian_provinces,"name",canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText);
+ querySetCell(variables.canadian_provinces,"abbreviation",canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText);
+ }
+ application.canadianProvinces = variables.canadian_provinces;
+ }
+ return application.canadianProvinces;
+ </cfscript>
+ </cfcase>
+ <cfcase value="us_states_and_canadian_provinces">
+ <cffile action="read" file="#getDirectoryFromPath(getCurrentTemplatePath())#/assets/canadian_provinces.xml" variable="canadian_provinces_content" />
+ <cffile action="read" file="#getDirectoryFromPath(getCurrentTemplatePath())#/assets/us_states.xml" variable="us_states_content" />
+ <cfscript>
+ if(!structKeyExists(application,"usStatesAndCanadianProvinces")){
+ us_states_xml = xmlParse(us_states_content);
+ canadian_provinces_xml = xmlParse(canadian_provinces_content);
+ for(i = 1; i lte arrayLen(us_states_xml.XMLChildren[1].XMLChildren); i = i + 1){
+ queryAddRow(variables.us_states_and_canadian_provinces);
+ querySetCell(variables.us_states_and_canadian_provinces,"name",us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText);
+ querySetCell(variables.us_states_and_canadian_provinces, "abbreviation", us_states_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText);
+ }
+ for(i = 1; i lte arrayLen(canadian_provinces_xml.XMLChildren[1].XMLChildren); i = i + 1){
+ queryAddRow(variables.us_states_and_canadian_provinces);
+ querySetCell( variables.us_states_and_canadian_provinces, "name", canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[1].xmlText );
+ querySetCell( variables.us_states_and_canadian_provinces, "abbreviation", canadian_provinces_xml.XMLChildren[1].XMLChildren[i].XMLChildren[2].xmlText );
+ }
+ application.usStatesAndCanadianProvinces = variables.us_states_and_canadian_provinces;
+ }
+ return application.usStatesAndCanadianProvinces;
+ </cfscript>
+ </cfcase>
+ <cfcase value="countries">
+ <cffile action="read" file="#getDirectoryFromPath(getCurrentTemplatePath())#/assets/countries.xml" variable="countries_content" />
+ <cfscript>
+ if(!structKeyExists(application,"countries")){
+ countries_xml = xmlParse(countries_content);
+ for(i = 1; i lte arrayLen(countries_xml.XMLChildren[1].XMLChildren); i = i + 1){
+ queryAddRow(variables.countries);
+ querySetCell(variables.countries,"name",countries_xml.XMLChildren[1].XMLChildren[i].xmlText);
+ querySetCell(variables.countries,"abbreviation",countries_xml.XMLChildren[1].XMLChildren[i].XMLAttributes.code);
+ }
+ application.countries = variables.countries;
+ }
+ return application.countries;
+ </cfscript>
+ </cfcase>
+ </cfswitch>
+
+ </cffunction>
+
</cfcomponent>

0 comments on commit e795403

Please sign in to comment.