Changeset 1667

Show
Ignore:
Timestamp:
08/09/08 23:30:28 (5 years ago)
Author:
evdlinden
Message:

SideBar? default properties can now be configured in sideBar.xml.cfm

Location:
coldbox/trunk/CodeDepot/projects/sidebar
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/CodeDepot/projects/sidebar/Application.cfc

    r1666 r1667  
    5555                <cfsetting enablecfoutputonly="no"> 
    5656                 
    57                 <!--- SideBar: Hack. Needs to be in the interceptor buffer ---> 
    58                  
    5957                <cfreturn true> 
    6058        </cffunction> 
  • coldbox/trunk/CodeDepot/projects/sidebar/config/coldbox.xml.cfm

    r1666 r1667  
    237237                 -->     
    238238                <Interceptor class="sidebar.interceptors.sideBar"> 
    239                         <Property name="isEnabled">true</Property> 
     239                        <!-- Enabled true/false, else leave blank --> 
     240                        <Property name="isEnabled"></Property> 
    240241                        <!-- Y offset, else leave blank --> 
    241242                        <Property name="yOffset"></Property> 
    242                         <!-- Links (JSON array of objects), else leave blank --> 
    243                         <Property name="links"> 
     243                        <!-- Links (JSON array of objects), else leave blank 
     244                        e.g.  
    244245                                [ 
    245246                                {"desc":"ColdBox Live Docs","href":"http:\/\/ortus.svnrepository.com\/coldbox\/trac.cgi"} 
    246247                                ,{"desc":"ColdBox API","href":"http:\/\/www.coldboxframework.com\/api\/"} 
    247248                                ,{"desc":"ColdBox Forums","href":"http:\/\/groups.google.com\/group\/coldbox"} 
    248                                 ,{"desc":"Coldfusion Live Docs","href":"http:\/\/livedocs.adobe.com\/coldfusion\/8\/htmldocs\/help.html?content=Part_3_CFML_Ref_1.html"} 
    249                                 ] 
    250                         </Property> 
     249                                ,{"desc":"My API","href":"http:\/\/localhost\/myApi/"} 
     250                                ,{"desc":"My Database Schema","href":"http:\/\/localhost\/myDatabaseSchema.pdf"} 
     251                                ,{"desc":"My Batch File","href":"C:\/\/Batch Files\/myBatch.bat"} 
     252                                ,{"desc":"My Program","href":"C:\/\/Program Files\/My Program.exe"} 
     253                                ]                        
     254                         --> 
     255                        <Property name="links"></Property> 
    251256                         
    252257                        <!-- Width of the sidebar including visible width, else leave blank --> 
  • coldbox/trunk/CodeDepot/projects/sidebar/includes/sidebar/sideBar.cfm

    r1666 r1667  
    6868        <cfset clearCacheHref = currentURL & "&clearCache=1"> 
    6969</cfif> 
    70  
     70                         
    7171<cfoutput> 
    7272<div id="SideBarContainer" style="visibility:hidden;position:absolute;left:0px;top:#sideBar.yOffset#px;z-index:20;width:#sideBar.width#px"> 
  • coldbox/trunk/CodeDepot/projects/sidebar/interceptors/sideBar.cfc

    r1666 r1667  
    55                 
    66Modification History: 
    7  
    8 Todo: implement postRender, so we can discard the plugin 
     708/08/2008 evdlinden : getRenderedSideBar(), onException() 
     808/09/2008 evdlinden : postRender appendToBuffer, onException appendToBuffer, xmlParse of sideBar properties 
    99-----------------------------------------------------------------------> 
    1010<cfcomponent name="sideBar" output="true" extends="coldbox.system.interceptor"> 
     
    1313 
    1414        <cffunction name="Configure" access="public" returntype="void" hint="This is the configuration method for your interceptors" output="false" > 
     15                 
    1516                <cfscript> 
     17                        // Read SideBar XML 
     18                        readSideBarXML(); 
     19                         
    1620                        /* Start processing properties */ 
    17                         if( not propertyExists('isEnabled') or not isBoolean(getproperty('isEnabled')) ){ 
    18                                 setProperty('isEnabled',true); 
     21                        if( not propertyExists( 'isEnabled') or not isBoolean(getproperty('isEnabled') ) ){ 
     22                                setProperty('isEnabled', getPropertyDefault('isEnabled') ); 
    1923                        } 
    20                         if( not propertyExists('yOffset') or not isNumeric(getproperty('yOffset')) ){ 
    21                                 setProperty('yOffset',100); 
     24                        if( not propertyExists( 'yOffset') or not isNumeric(getproperty('yOffset') ) ){ 
     25                                setProperty('yOffset', getPropertyDefault('yOffset')); 
    2226                        } 
    23                         if( not propertyExists('links') or not isArray(getproperty('links')) ){ 
    24                                 setProperty('links',ArrayNew(1)); 
     27                        if( not propertyExists( 'links') or not isArray(getproperty('links') ) ){ 
     28                                setProperty('links', getPropertyDefault('links') ); 
    2529                        } 
    2630                        if( not propertyExists('width') or not isNumeric(getproperty('width')) ){ 
    27                                 setProperty('width',200); 
     31                                setProperty('width', getPropertyDefault('width') ); 
    2832                        } 
    2933                        if( not propertyExists('visibleWidth') or not isNumeric(getproperty('visibleWidth')) ){ 
    30                                 setProperty('visibleWidth',12); 
     34                                setProperty( 'visibleWidth', getPropertyDefault('visibleWidth') ); 
    3135                        } 
    3236                        if( not propertyExists('imagePath') or not REFindNoCase("[A-Z]",getproperty('imagePath')) ){ 
    33                                 setProperty('imagePath',"includes/sideBar/sideBar.png"); 
     37                                setProperty( 'imagePath', getPropertyDefault('imagePath') ); 
    3438                        } 
    3539                        if( not propertyExists('cssPath') or not REFindNoCase("[A-Z]",getproperty('cssPath')) ){ 
    36                                 setProperty('cssPath',"includes/sidebar/sideBar.css"); 
     40                                setProperty( 'cssPath', getPropertyDefault('cssPath') ); 
    3741                        } 
    3842                        if( not propertyExists('imageVAlign') or not ListFindNoCase('top,middle,bottom', getproperty('imageVAlign') ) ){ 
    39                                 setProperty('imageVAlign',"middle"); 
     43                                setProperty( 'imageVAlign', getPropertyDefault('imageVAlign') ); 
    4044                        } 
    4145                </cfscript> 
     
    8690        </cffunction> 
    8791                 
     92        <cffunction name="setPropertyDefault" access="private" returntype="void"> 
     93                <cfargument name="propertyName" required="true" type="string"> 
     94                <cfargument name="propertyValue" required="true" type="any"> 
     95                <cfset StructInsert(getSideBarDefaults(), arguments.propertyName, arguments.propertyValue)>        
     96        </cffunction> 
     97 
     98        <cffunction name="getPropertyDefault" access="private" returntype="any"> 
     99                <cfargument name="propertyName" required="true" type="string"> 
     100                <cfreturn StructFind(getSideBarDefaults(), arguments.propertyName)>    
     101        </cffunction> 
     102         
     103        <cffunction name="getSideBarDefaults" access="private" returntype="struct"> 
     104                <!--- SideBarDefaults exists ? ---> 
     105                <cfif not propertyExists('sideBarDefaults')> 
     106                        <cfset setProperty('sideBarDefaults',StructNew())> 
     107                </cfif>  
     108                <cfreturn getproperty('sideBarDefaults')>        
     109        </cffunction> 
     110                 
     111        <cffunction name="readSideBarXML" access="private" returntype="void"> 
     112                <cfset var i = 0> 
     113                <cfset var k = 0> 
     114                <cfset var sideBarXMLDoc = ''> 
     115                <cfset var sideBarXML = ''> 
     116                <cfset var properties = ''> 
     117                <cfset var property = StructNew()> 
     118                 
     119                <cftry> 
     120                        <!--- Read SideBar XML ---> 
     121                        <cffile action="read" file="#ExpandPath('includes/sidebar/sideBar.xml.cfm')#" variable="sideBarXMLDoc"> 
     122                        <!--- Parse XML ---> 
     123                        <cfset sideBarXML = XmlParse(sideBarXMLDoc)> 
     124                        <!--- Set xml properties array ---> 
     125                        <cfset properties = sideBarXML['Sidebar']['Properties']['Property']> 
     126                 
     127                        <!--- Loop properties ---> 
     128                         <cfloop index="i" from="1" to="#ArrayLen(properties)#"> 
     129                                 <!--- Property has properties? ---> 
     130                                 <cfif properties[i].xmlAttributes['name'] EQ "links"> 
     131                                        <!--- Decode JSON ---> 
     132                                        <cfset property.value = getPlugin('JSON').decode( properties[i].xmlText )> 
     133                                <cfelse> 
     134                                        <cfset property.value = properties[i].xmlText> 
     135                                </cfif> 
     136                                <cfset setPropertyDefault(properties[i].xmlAttributes['name'],property.value)> 
     137                        </cfloop> 
     138                         
     139                        <cfcatch type="any"> 
     140                                <cfthrow message="SideBar: xml file default properties read error. Check default SideBar.xml file ." detail="#cfcatch.message#">  
     141                        </cfcatch> 
     142                </cftry>         
     143        </cffunction>            
    88144</cfcomponent> 
  • coldbox/trunk/CodeDepot/projects/sidebar/views/home.cfm

    r1649 r1667  
    22<h1>#Event.getValue("welcomeMessage")#</h1> 
    33<h5>You are running #getSetting("codename",1)# #getSetting("version",1)# (#getsetting("suffix",1)#)</h5> 
     4 
     5 
     6 
     7 
    48</cfoutput> 
     9 
     10 
     11