Ok hope this isn't too messy on screen but here is the code with fixes
for 5.1.x....

Not a lot of big changes, really just updates to the way 5.1.x works.
We've tested this in CF8, IIS, mySQL on FarCry 5.1.0. If you want more
info on what we changed then let me know.

Cheers,
James

---------

<cfsetting enablecfoutputonly="yes">
<!---
|| LEGAL ||
$Copyright: e-dynamics B.V., http://www.e-dynamics.nl $
$License: Released Under the "Common Public License 1.0",
http://www.opensource.org/licenses/cpl.php$

|| VERSION CONTROL ||
$Header: /cvs/farcry/farcry_edynamics/includedObj/googlesitemap.cfm,v
0.5 2005/06/06 12:10:50 Vincent Egt $
$Date: 2005-06-30 13:41:12 +0930 (Thu, 30 Jun 2005) $
$Revision: 43 $

|| DESCRIPTION ||
Cron job definition to generate googleSitemap

|| DEVELOPER ||
Vincent Egt ([email protected])
GZipping - David Whiterod ([email protected])

|| ATTRIBUTES ||
in:
out:
        - valid xml sitemap file which is written in www root
--->
<cfimport taglib="/farcry/core/tags/webskin" prefix="skin">

<cfparam name="URL.depth" type="numeric" default="0" />
<cfparam name="URL.compress" type="numeric" default="0" />
<cfparam name="URL.fileName" type="string" default="sitemap" />
<cfparam name="URL.startPoint" type="string"
default="#application.navid.home#" />

<cfscript>
        sColumns = "objectid,nlevel,nleft,datetimelastupdated,externallink";
        sSort = "nleft,objectname";
        sSiteMapVersion = "0.84";
        sSiteMapFile = "#URL.fileName#.xml";
</cfscript>

<cfoutput><p class="FormTitle">Updating Google Sitemap (Version
#sSiteMapVersion#)</p></cfoutput>

<cftry>

        <cfscript>
                // get navigation elements to root
                navFilter=arrayNew(1);
                navfilter[1]="status IN 
(#listQualify(request.mode.lvalidstatus, "'")
#)";
                qNavUnsorted = application.factory.oTree.getDescendants
(objectid=URL.startPoint, depth=URL.depth, bIncludeSelf="1",
afilter=navFilter, lcolumns="externallink,datetimelastupdated");
        </cfscript>
        <!--- VE: sort query through a requery; externallink may not be
filled because we would get double URL's in the sitemap this is
prohibited by google.--->
        <cfquery name="qNavSorted" dbtype="query">
                SELECT DISTINCT #sColumns#
                FROM qNavUnsorted
                WHERE externallink = ''
                ORDER BY #sSort# ASC
        </cfquery>

        <cfscript>
                lv0 = listFirst(listSort(valueList
(qNavSorted.nlevel),"numeric","asc")); //sort the value list and grab
the first value as nlevel for plateau
                depth = listFirst(listSort(valueList
(qNavSorted.nlevel),"numeric","asc")); // sort the value list and grab
the first value as the default depth ie. plateau
        </cfscript>

<cfsavecontent variable="xmlString"><cfoutput><?xml version='1.0'
encoding='UTF-8'?>
<urlset
        xmlns="http://www.google.com/schemas/sitemap/#sSiteMapVersion#";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://www.google.com/schemas/sitemap/
#sSiteMapVersion#
        http://www.google.com/schemas/sitemap/#sSiteMapVersion#/sitemap.xsd";>
</cfoutput>
<cfloop query="qNavSorted">
<cfsavecontent variable="strUrl"><skin:buildlink includedomain="true"
urlOnly="true" objectid="#qNavSorted.objectid#"
externallink="#qNavSorted.externallink#" /></cfsavecontent>
<cfoutput>
        <url>
                <loc>#XmlFormat(strUrl)#</loc>
                <priority><cfif qNavSorted.nlevel LTE 2>1.0<cfelseif
qNavSorted.nlevel LTE 3>0.9<cfelse>#numberformat(log10
(qNavSorted.nlevel),'0._')#</cfif></priority>
                
<lastmod>#DateFormat(qNavSorted.datetimelastupdated,'yyyy-mm-dd')
#T#TimeFormat(qNavSorted.datetimelastupdated,'HH:mm:ss')#+00:00</
lastmod>
                <changefreq><cfif qNavSorted.nlevel LTE 2>daily<cfelse>weekly</
cfif></changefreq>
        </url></cfoutput>
</cfloop>
<cfoutput></urlset></cfoutput>
</cfsavecontent>

        <cfcatch type="Any">
                <cfdump var="#cfcatch#">
        </cfcatch>
</cftry>

<cfoutput><span class="frameMenuBullet">&raquo;</span> Created XML
file (#qNavSorted.RecordCount# entries).<p></cfoutput>


<!--- 
https://www.google.com/webmasters/sitemaps/docs/en/protocol.html#faq_sitemap_location
--->
<!--- <cfset sPathSiteRoot = "#application.path.project#/www"> --->
<!--- TODO: Would be better if this was a default value and the user
could repoint through the webtop --->
<cfset sPathSiteRoot = "#application.path.project#/files/siteMap" />

<cftry>
        <cfset outputFile = "#sPathSiteRoot#/#sSiteMapFile#">
        <!--- generate file --->
        <cffile action="write" file="#outputFile#" output="#xmlString#"
addnewline="no" nameconflict="OVERWRITE">
        <cfcatch>
                <cfoutput>#sPathSiteRoot# directory doesn't exist. Please create
before trying to export.</cfoutput>
        </cfcatch>
</cftry>

<cfif FileExists(outputFile)>
        <cfoutput><span class="frameMenuBullet">&raquo;</span> XML file
written to #outputFile#
        <a href="http://www.google.com/webmasters/sitemaps/ping?
sitemap=#URLEncodedFormat('http://
#cgi.http_host##application.url.webroot#/#sSiteMapFile#')#"
target="_blank">Submit #sSiteMapFile# to Google</a>.<p></cfoutput>
<cfelse>
        <cfoutput><span class="frameMenuBullet">&raquo;</span> Could not
create #outputFile#.<p></cfoutput>
</cfif>


<cfif FileExists(outputFile) AND URL.compress>

        <cfoutput><span class="frameMenuBullet">&raquo;</span> GZipping
file.<p></cfoutput>

        <cftry>

                <cfscript>

                        function copyInputStream(inStream, outStream) {
                                var buffer = repeatString(" ",1024).getBytes();
                                var len = inStream.read(buffer);

                                while(len GTE 0) {
                                        outStream.write(buffer, 0, len);
                                        len = inStream.read(buffer);
                                }
                                inStream.close();
                                outStream.close();
                        }

                        sInFilename = "#sSiteMapFile#";
                        sOutFilename = "#sSiteMapFile#.gz";
                        oInput = 
createObject("java","java.io.FileInputStream").init
("#sPathSiteRoot#/#sInFilename#");
                        oOutput = 
createObject("java","java.io.FileOutputStream").init
("#sPathSiteRoot#/#sOutFilename#");
                        // Create the GZIP output stream
                        oGZIPOutputStream = createObject("java",
"java.util.zip.GZIPOutputStream").init(oOutput);
                        //read contents of the input stream to GZIP output 
stream
                        copyInputStream(oInput, oGZIPOutputStream);
                </cfscript>
        <cfcatch>
                <cfdump var="#cfcatch#">
        </cfcatch>

        </cftry>

        <cfoutput><span class="frameMenuBullet">&raquo;</span> Created
#sPathSiteRoot#/#sOutFilename# <a href="http://www.google.com/
webmasters/sitemaps/ping?sitemap=#URLEncodedFormat('http://
#cgi.http_host##application.url.webroot#/#sOutFilename#')#"
target="_blank">Submit #sOutFilename# to Google</a>.<p></cfoutput>

</cfif>

<cfoutput><p>All done.</p></cfoutput>

<cfparam name="URL.depth" type="numeric" default="0" />
<cfparam name="URL.compress" type="numeric" default="0" />
<cfparam name="URL.fileName" type="string" default="sitemap" />
<cfparam name="URL.startPoint" type="string"
default="#application.navid.home#" />

<cfoutput>
<hr />
<p><a href="http://google.com/webmasters/sitemaps/";
target="_blank">Google sitemaps</a>.</p>

<form action="/webmasters/sitemaps/addsitemap?hl=en_US" id="thisform"
name="thisform" method="post">

<p class="FormTitle">Usage Arguments</p>
<ul>
        <li>startPoint - OPTIONAL UUID - (default: application.navid.home)</
li>
        <li>depth - OPTIONAL Integer - Number of FarCry tree levels to add to
the sitemap (default: 0 - all levels)</li>
        <li>compress - OPTIONAL Boolean - Create a GZipped version of the
sitemap XML file (default: 0 - don't create GZip file)</li>
        <li>fileName - OPTIONAL String - file name of the sitemap XML file
(default: sitemap)</li>
</ul>
</cfoutput>

<cfsetting enablecfoutputonly="no">
--~--~---------~--~----~------------~-------~--~----~
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: [email protected]
To unsubscribe, email: [email protected]
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
-~----------~----~----~----~------~----~------~--~---

Reply via email to