Posted by BenNadelPost on Thu 10 Jul 16:30
report abuse | download | new post
- <cfcomponent
- displayname="StatsFilter"
- output="false"
- hint="A bean which models the StatsFilter form.">
- <!---
- PROPERTIES
- --->
- <cfset variables.instance = StructNew() />
- <!---
- INITIALIZATION / CONFIGURATION
- --->
- <cffunction name="init" access="public" returntype="StatsFilter" output="false">
- <cfargument name="ActivityTypeID" type="string" required="false" default="" />
- <cfargument name="DateRangeCode" type="string" required="false" default="" />
- <cfargument name="ActivityCode" type="string" required="false" default="" />
- <cfargument name="ChallengerID" type="string" required="false" default="" />
- <cfargument name="SelectedValueType" type="string" required="false" default="" />
- <cfargument name="ShowStandardMetric" type="string" required="false" default="" />
- <cfargument name="layout" type="string" required="false" default="" />
- <!--- run setters --->
- <cfset setActivityTypeID(arguments.ActivityTypeID) />
- <cfset setDateRangeCode(arguments.DateRangeCode) />
- <cfset setActivityCode(arguments.ActivityCode) />
- <cfset setChallengerID(arguments.ChallengerID) />
- <cfset setSelectedValueType(arguments.SelectedValueType) />
- <cfset setShowStandardMetric(arguments.ShowStandardMetric) />
- <cfset setLayout(arguments.layout) />
- <cfreturn this />
- </cffunction>
- <!---
- PUBLIC FUNCTIONS
- --->
- <cffunction name="setMemento" access="public" returntype="StatsFilter" output="false">
- <cfargument name="memento" type="struct" required="yes"/>
- <cfset variables.instance = arguments.memento />
- <cfreturn this />
- </cffunction>
- <cffunction name="getMemento" access="public"returntype="struct" output="false" >
- <cfreturn variables.instance />
- </cffunction>
- <!---
- ACCESSORS
- --->
- <cffunction name="setActivityTypeID" access="public" returntype="void" output="false">
- <cfargument name="ActivityTypeID" type="string" required="true" />
- <cfset variables.instance.ActivityTypeID = arguments.ActivityTypeID />
- </cffunction>
- <cffunction name="getActivityTypeID" access="public" returntype="string" output="false">
- <cfreturn variables.instance.ActivityTypeID />
- </cffunction>
- <cffunction name="setDateRangeCode" access="public" returntype="void" output="false">
- <cfargument name="DateRangeCode" type="string" required="true" />
- <cfset variables.instance.DateRangeCode = arguments.DateRangeCode />
- </cffunction>
- <cffunction name="getDateRangeCode" access="public" returntype="string" output="false">
- <cfreturn variables.instance.DateRangeCode />
- </cffunction>
- <cffunction name="getDateRangeStruct" access="public" returntype="struct" output="false">
- <cfset var drs = structNew() />
- <cfset var x = "" />
- <cfloop from="0" to="#max(0, getDaysInRange())#" index="x">
- <cfset drs[ x ] = 0 />
- </cfloop>
- <cfreturn drs />
- </cffunction>
- <cffunction name="getDaysInRange" access="public" returntype="string" output="false">
- <cfreturn ceiling( getEndDate() - getStartDate() ) />
- </cffunction>
- <cffunction name="getActivityCode" access="public" output="false" returntype="string">
- <cfreturn variables.instance.ActivityCode />
- </cffunction>
- <cffunction name="setActivityCode" access="public" output="false" returntype="void">
- <cfargument name="ActivityCode" type="string" required="true" />
- <cfset variables.instance.ActivityCode = arguments.ActivityCode />
- </cffunction>
- <cffunction name="getEndDate" output="false" access="public" returntype="string" hint="I calculate the start date">
- <cfreturn now() />
- </cffunction>
- <cffunction name="getStartDate" output="false" access="public" returntype="string" hint="I calulate the end date">
- <cfset var drc = getDateRangeCode() />
- <cfset var rtnDate = dateFormat( now(), 'yyyy/mm/dd') />
- <cfif drc IS "Yesterday">
- <cfset rtnDate = dateFormat( now() -1, 'yyyy/mm/dd') />
- <cfelseif drc IS "LastWeek">
- <cfset rtnDate = dateFormat( now() -7, 'yyyy/mm/dd') />
- <cfelseif drc IS "Last2Weeks">
- <cfset rtnDate = dateFormat( now() -14, 'yyyy/mm/dd') />
- <cfelseif drc IS "LastMonth">
- <cfset rtnDate = dateFormat( dateAdd("m", -1, now() ) -1, 'yyyy/mm/dd') />
- <cfelseif drc IS "Last2Months">
- <cfset rtnDate = dateFormat( dateAdd("m", -2, now() ) -1, 'yyyy/mm/dd') />
- <cfelseif drc IS "Last3Months">
- <cfset rtnDate = dateFormat( dateAdd("m", -3, now() ) -1, 'yyyy/mm/dd') />
- <cfelseif drc IS "AllTime">
- <cfset rtnDate = dateFormat( createDate(2007, 12, 26) , 'yyyy/mm/dd') />
- </cfif>
- <cfreturn rtnDate />
- </cffunction>
- <cffunction name="setChallengerID" access="public" returntype="void" output="false">
- <cfargument name="ChallengerID" type="string" required="true" />
- <cfset variables.instance.ChallengerID = arguments.ChallengerID />
- </cffunction>
- <cffunction name="getChallengerID" access="public" returntype="string" output="false">
- <cfreturn variables.instance.ChallengerID />
- </cffunction>
- <cffunction name="getChallenger" access="public" output="false" returntype="any">
- <cfreturn getTransfer().get("Member", getChallengerID() ) />
- </cffunction>
- <cffunction name="getCurrentMemberID" access="public" returntype="string" output="false">
- <cfreturn getCurrentMember().getMemberID() />
- </cffunction>
- <cffunction name="getCurrentMember" access="public" output="false" returntype="any">
- <cfreturn variables.instance.CurrentMember />
- </cffunction>
- <cffunction name="setCurrentMember" access="public" output="false" returntype="void">
- <cfargument name="CurrentMember" type="any" required="true" />
- <cfset variables.instance.CurrentMember = arguments.CurrentMember />
- </cffunction>
- <cffunction name="getMemberIDList" access="public" output="false" returntype="string">
- <cfset var midList = getCurrentMember().getMemberID() />
- <cfif hasChallengerID()>
- <cfset midList = listAppend( midlist, getChallengerID() ) />
- </cfif>
- <cfreturn midList />
- </cffunction>
- <cffunction name="getSelectedValueType" access="public" output="false" returntype="string">
- <cfset var rtn = "distance" />
- <cfif len( trim ( variables.instance.SelectedValueType ) ) AND variables.instance.SelectedValueType IS "time" OR variables.instance.SelectedValueType IS "weight">
- <cfset rtn = variables.instance.SelectedValueType />
- </cfif>
- <cfreturn rtn />
- </cffunction>
- <cffunction name="setSelectedValueType" access="public" output="false" returntype="void">
- <cfargument name="SelectedValueType" type="string" required="true" />
- <cfset variables.instance.SelectedValueType = arguments.SelectedValueType />
- </cffunction>
- <cffunction name="getShowStandardMetric" access="public" output="false" returntype="string">
- <cfset var rtn = true />
- <cfif len( trim( variables.instance.ShowStandardMetric ) )>
- <cfset rtn = variables.instance.ShowStandardMetric />
- </cfif>
- <cfreturn rtn />
- </cffunction>
- <cffunction name="setShowStandardMetric" access="public" output="false" returntype="void">
- <cfargument name="ShowStandardMetric" type="string" required="true" />
- <cfset variables.instance.ShowStandardMetric = arguments.ShowStandardMetric />
- </cffunction>
- <cffunction name="getStatColumn" access="public" output="false" returntype="string">
- <cfset var rtn = "ElapsedTimeHours" />
- <cfif hasSelectedValueType() AND getSelectedValueType() IS NOT "ElapsedTimeHours">
- <cfset rtn = "standardValue" />
- <cfif hasShowStandardMetric() AND getShowStandardMetric() IS false>
- <cfset rtn = "metricValue" />
- </cfif>
- </cfif>
- <cfreturn rtn />
- </cffunction>
- <cffunction name="getUnitColumn" access="public" output="false" returntype="string">
- <cfset var rtn = "Hours" />
- <cfif hasSelectedValueType() AND getSelectedValueType() IS NOT "ElapsedTimeHours">
- <cfset rtn = "standardUnit" />
- <cfif hasShowStandardMetric() AND getShowStandardMetric() IS false>
- <cfset rtn = "metricUnit" />
- </cfif>
- </cfif>
- <cfreturn rtn />
- </cffunction>
- <cffunction name="getLayout" access="public" output="false" returntype="string">
- <cfreturn variables.instance.Layout />
- </cffunction>
- <cffunction name="setLayout" access="public" output="false" returntype="void">
- <cfargument name="Layout" type="string" required="true" />
- <cfset variables.instance.Layout = arguments.Layout />
- </cffunction>
- <cffunction name="hasDateRange" output="false" access="public" returntype="boolean" hint="">
- <cfreturn len( trim( getDateRangeCode() ) ) GT 0 />
- </cffunction>
- <cffunction name="hasActivityTypeID" output="false" access="public" returntype="boolean" hint="">
- <cfreturn val( getActivityTypeID() ) GT 0 />
- </cffunction>
- <cffunction name="hasActivityCode" output="false" access="public" returntype="boolean" hint="">
- <cfreturn len( trim(getActivityCode() ) ) GT 0 />
- </cffunction>
- <cffunction name="hasChallengerID" output="false" access="public" returntype="boolean" hint="">
- <cfreturn val( getChallengerID() ) GT 0 />
- </cffunction>
- <cffunction name="hasSelectedValueType" output="false" access="public" returntype="boolean" hint="">
- <cfreturn len( trim(getSelectedValueType() ) ) GT 0 />
- </cffunction>
- <cffunction name="hasShowStandardMetric" output="false" access="public" returntype="boolean" hint="">
- <cfreturn len( trim(getShowStandardMetric() ) ) GT 0 />
- </cffunction>
- <cffunction name="hasLayout" output="false" access="public" returntype="boolean" hint="">
- <cfreturn len( trim(getLayout() ) ) GT 0 />
- </cffunction>
- <cffunction name="hasTypeRequirements" output="false" access="public" returntype="boolean" hint="">
- <cfreturn hasSelectedValueType() />
- </cffunction>
- <cffunction name="requireTime" output="false" access="public" returntype="boolean" hint="">
- <cfset var rtnVal = false />
- <cfif listFind( getSelectedValueType(), "time") >
- <cfset rtnVal = true />
- </cfif>
- <cfreturn rtnVal />
- </cffunction>
- <cffunction name="requireDistance" output="false" access="public" returntype="boolean" hint="">
- <cfset var rtnVal = false />
- <cfif listFind( getSelectedValueType(), "distance") >
- <cfset rtnVal = true />
- </cfif>
- <cfreturn rtnVal />
- </cffunction>
- <cffunction name="requireWeight" output="false" access="public" returntype="boolean" hint="">
- <cfset var rtnVal = false />
- <cfif listFind( getSelectedValueType(), "weight") >
- <cfset rtnVal = true />
- </cfif>
- <cfreturn rtnVal />
- </cffunction>
- <cffunction name="getTransfer" access="public" output="false" returntype="any">
- <cfreturn variables.instance.Transfer />
- </cffunction>
- <cffunction name="setTransfer" access="public" output="false" returntype="void">
- <cfargument name="Transfer" type="any" required="true" />
- <cfset variables.instance.Transfer = arguments.Transfer />
- </cffunction>
- <cffunction name="makeHumanFilterString" output="false" access="public" returntype="any" hint="I make a human readable string ">
- <cfset var rtn = "" />
- <cfif hasDateRange()>
- <cfset rtn = " #spaceCap(getDateRangeCode())#" />
- </cfif>
- <cfif hasActivityCode() >
- <cfset rtn = " #spaceCap(getActivityCode())#" />
- </cfif>
- <cfif len( trim( rtn ) )>
- <cfset rtn = " for #rtn#" />
- </cfif>
- <cfreturn rtn />
- </cffunction>
- <cffunction name="makeFilterString" output="false" access="public" returntype="string" hint="">
- <cfargument name="exceptionList" type="string" default=""/>
- <cfset var rtn = "" />
- <cfif hasDateRange() AND ListFindNoCase( exceptionList, "DateRangeCode" ) IS false>
- <cfset rtn = rtn & "&DateRangeCode=#getDateRangeCode()#" />
- </cfif>
- <cfif hasActivityTypeID() AND ListFindNoCase( exceptionList, "ActivityTypeID" ) IS false>
- <cfset rtn = rtn & "&ActivityTypeID=#getActivityTypeID()#" />
- </cfif>
- <cfif hasChallengerID() AND ListFindNoCase( exceptionList, "ChallengerID" ) IS false>
- <cfset rtn = rtn & "&ChallengerID=#getChallengerID()#" />
- </cfif>
- <cfif hasShowStandardMetric() AND ListFindNoCase( exceptionList, "ShowStandardMetric" ) IS false>
- <cfset rtn = rtn & "&ShowStandardMetric=#getShowStandardMetric()#" />
- </cfif>
- <cfif hasSelectedValueType() AND ListFindNoCase( exceptionList, "SelectedValueType" ) IS false>
- <cfset rtn = rtn & "&SelectedValueType=#getSelectedValueType()#" />
- </cfif>
- <cfreturn rtn />
- </cffunction>
- <cffunction name="loadChartStyleSheet" output="false" access="public" returntype="string" hint="">
- <cfset var sheet = "white_pipe" />
- <cfif hasSelectedValueType()>
- <cfset sheet = sheet & "_" & getSelectedValueType() />
- <cfif getShowStandardMetric() is true AND listfind("distance,time", getSelectedValueType()) >
- <cfset sheet = sheet & "_standard" />
- <cfelseif listfind("distance,time", getSelectedValueType()) >
- <cfset sheet = sheet & "_metric" />
- </cfif>
- </cfif>
- <cfreturn lcase(sheet) & ".xml" />
- </cffunction>
- <!--- Date: 5/23/2008 Usage: --->
- <cffunction name="SpaceCap" output="false" access="private" returntype="string" hint="">
- <cfargument name="text" type="string" default=""/>
- <cfreturn REReplace( REReplace(text, "([.^[:digit:]])", " \1","all"), "([.^[:upper:]])", " \1","all") />
- </cffunction>
- </cfcomponent>
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.