Catégories
Function Init(node)
On Error Resume Next
Dim strTopCategoriesSqlQuery
strTopCategoriesSqlQuery = _
" SELECT " & vbCRLF & _
" ""DAV:href"", ""DAV:displayname"", ""DAV:contentclass"", ""urn:schemas-microsoft-com:office:office#Description"" " & vbCRLF & _
" FROM SCOPE('SHALLOW TRAVERSAL OF ""/" & GetWorkspaceName() & "/" & GetWorkspacePropertyByUri(g_cdostrURI_CategoriesFolder) & strCategoryPath & """')" & vbCRLF & _
" WHERE ""DAV:contentclass"" = 'urn:content-classes:categoryfolder'" & vbCRLF & _
" ORDER BY ""DAV:displayname"" ASC" & vbCRLF
Dim dsqTopCategories
Set dsqTopCategories = CreateAndStartAndCacheSearchQuery(strTopCategoriesSqlQuery, "TOP_CATEGORIES", Empty, Empty, Empty, True)
If Err.Number <> 0 Then SaveCurrentErrorContext "Init() - Error initializing the top level categories query." : Exit Function
If dsqTopCategories Is Nothing Then Err.Raise 11, "Init()", "Reason: Error initializing the query." : Exit Function
End Function
Function GetContent(nod)
On Error Resume Next
GetContent = " "
Dim strTopCategoriesXml, cTotal, fHasMore
strTopCategoriesXml = GetContentAndRangeFromCachedSearchQuery("TOP_CATEGORIES", cTotal, fHasMore)
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error getting content and range from saved query object." : Exit Function
If Not IsEmpty(strTopCategoriesXml) Then
GetContent = InsertXmlContextValues(strTopCategoriesXml, _
GetSupportedFileTypeImagesXml() & vbCRLF & _
"<TotalItems>" & cTotal & "</TotalItems>" & vbCRLF & _
"<LocStringForNone>" & L_StartPagePartHasNoContents_TEXT & "</LocStringForNone>")
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error adding the context info." : Exit Function
End If
End Function
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="uri:xsl"
xmlns:dav="DAV:"
xmlns:office="urn:schemas-microsoft-com:office:office"
xmlns:fulltext="urn:schemas.microsoft.com:fulltextqueryinfo:"
xmlns:attributes="urn:schemas-microsoft-com:publishing:">
<xsl:template match="/">
<TABLE>
<xsl:for-each select="dav:multistatus">
<xsl:choose>
<xsl:when test="/dav:multistatus/TotalItems[. != '0']">
<xsl:apply-templates match="a:response" />
</xsl:when>
<xsl:otherwise>
<TR>
<TD width="10">
</TD>
<TD valign="top" align="left">
<xsl:value-of select="LocStringForNone"/>
</TD>
</TR>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template match="a:response">
<TR>
<TD valign="center"><IMG src="SquareBullet.gif"/></TD>
<TD valign="top" align="left">
<A>
<xsl:attribute name="href"><xsl:for-each select="dav:propstat/dav:prop/dav:href"><xsl:eval>safeUnicodeUrlFromUtf8CanonicalizedUrl(this.text);</xsl:eval></xsl:for-each>
</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="dav:propstat/dav:prop/office:Description"/></xsl:attribute>
<B><xsl:value-of select="dav:propstat/dav:prop/dav:displayname"/></B>
</A>
</TD>
</TR>
</xsl:template>
<xsl:script language="JScript">
<![CDATA[
function canonicalizeForUrlParameter(strToEncode)
{
// Canonicalize everything. Also escape the '+' which is not escaped by jscript.
return escape(strToEncode).replace(/\+/g, "%2B");
}
function canonicalizeForUrl(strToEncode)
{
// Just canonicalize percent and space.
return (strToEncode.replace(/%/, "%25")).replace(/ /g, "%20");
}
function safeUnicodeUrlFromUnicodeUrl(strUnicodeUrl)
{
// A Unicode URL may have special chars, they need to be canonicalized
// to work for (all) browsers.
return (strUnicodeUrl.replace(/%/, "%25")).replace(/ /g, "%20").replace(/\+/g, "%2B").replace(/#/g, "%23");
}
function safeUnicodeUrlFromUtf8CanonicalizedUrl( strUtf8CanonicalizedUrl )
{
// Convert from a UTF8 canonicalized URL to a Unicode URL with (only) special chars canonicalized.
// in the result URL, DBCS chars are still DBCS chars as not canonicalized.
return safeUnicodeUrlFromUnicodeUrl(unicodeFromUtf8(unescape(strUtf8CanonicalizedUrl))) ;
}
function encodeForJScriptStringLiteral(strToEncode)
{
// Replace embedded double and single quotes with \ prefixes.
return strToEncode.replace(/(['"])/g, "\\$1").replace(/%27/g, "\\%27");
}
function encodeForHtml(strToEncode)
{
return strToEncode.replace(/</g, "<");
}
function canonicalizedUtf8FromUnicode(strURL)
{
var strSpecialUrl = " <>\"#%{}|^~[]`&?+";
var strEncode="";
var i;
var chUrl;
var iCode;
var num;
var iCodeBin;
var tempBin;
var j, leadingzeros;
strURL+="";
for (i=0; i<strURL.length; i++) {
chUrl = strURL.charAt(i);
iCode = chUrl.charCodeAt(0);
if (iCode<=parseInt("0x7F")) {
if (strSpecialUrl.indexOf(chUrl)!=-1) {
//chUrl is a special character that needs to be Url encoded
strEncode+="%"+iCode.toString(16).toUpperCase();
} else {
//otherwise chrUrl is normal
strEncode+=chUrl;
}
} else {
leadingzeros="";
iCodeBin=iCode.toString(2)
if (iCode<=parseInt(0x7FF)) {
//glyph is represented by two chars
//check leading zeros on iCodeBin (should be 11 digits)
for (j=11; j>iCodeBin.length; j--) leadingzeros+="0";
iCodeBin=leadingzeros+iCodeBin
tempBin="110"+iCodeBin.substr(0,5);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(5,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
} else {
if (iCode<=parseInt(0xFFFF)) {
//glyph is represented by three chars
//check leading zeros on iCodeBin (should be 16 digits)
for (j=16; j>iCodeBin.length; j--) leadingzeros+="0";
iCodeBin=leadingzeros+iCodeBin
tempBin="1110"+iCodeBin.substr(0,4);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(4,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(10,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
} else {
if (iCode<=parseInt(0x1FFFFF)) {
//glyph is represented by four chars
//check leading zeros on iCodeBin (should be 21 digits)
for (j=21; j>iCodeBin.length; j--) leadingzeros+="0";
iCodeBin=leadingzeros+iCodeBin
tempBin="11110"+iCodeBin.substr(0,3);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(3,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(9,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(15,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
} else {
if (iCode<=parseInt(0x3FFFFFF)) {
//glyph is represented by five chars
//check leading zeros on iCodeBin (should be 26 digits)
for (j=26; j>iCodeBin.length; j--) leadingzeros+="0";
iCodeBin=leadingzeros+iCodeBin
tempBin="111110"+iCodeBin.substr(0,2);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(2,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(8,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(14,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(20,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
} else {
if (iCode<=parseInt(0x7FFFFFFF)) {
//glyph is represented by six chars
//check leading zeros on iCodeBin (should be 31 digits)
for (j=31; j>iCodeBin.length; j--) leadingzeros+="0";
iCodeBin=leadingzeros+iCodeBin
tempBin="1111110"+iCodeBin.substr(0,1);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(1,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(7,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(13,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(19,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
tempBin="10"+iCodeBin.substr(25,6);
strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()
}
}
}
}
}
}
}
return strEncode;
}
function unicodeFromUtf8(strUtf8)
{
var bstr = "";
var nTotalChars = strUtf8.length; // total chars to be processed.
var nOffset = 0; // processing point on strUtf8
var nRemainingBytes = nTotalChars; // how many bytes left to be converted
var nOutputPosition = 0;
var iCode, iCode1, iCode2; // the value of the unicode.
while (nOffset < nTotalChars)
{
iCode = strUtf8.charCodeAt(nOffset);
if ((iCode & 0x80) == 0) // 1 byte.
{
if ( nRemainingBytes < 1 ) // not enough data
break;
bstr += String.fromCharCode(iCode & 0x7F);
nOffset ++;
nRemainingBytes -= 1;
}
else if ((iCode & 0xE0) == 0xC0) // 2 bytes
{
iCode1 = strUtf8.charCodeAt(nOffset + 1);
if ( nRemainingBytes < 2 || // not enough data
(iCode1 & 0xC0) != 0x80 ) // invalid pattern
{
break;
}
bstr += String.fromCharCode(((iCode & 0x3F) << 6) | ( iCode1 & 0x3F));
nOffset += 2;
nRemainingBytes -= 2;
}
else if ((iCode & 0xF0) == 0xE0) // 3 bytes
{
iCode1 = strUtf8.charCodeAt(nOffset + 1);
iCode2 = strUtf8.charCodeAt(nOffset + 2);
if ( nRemainingBytes < 3 || // not enough data
(iCode1 & 0xC0) != 0x80 || // invalid pattern
(iCode2 & 0xC0) != 0x80 )
{
break;
}
bstr += String.fromCharCode(((iCode & 0x0F) << 12) |
((iCode1 & 0x3F) << 6) |
(iCode2 & 0x3F));
nOffset += 3;
nRemainingBytes -= 3;
}
else // 4 or more bytes -- unsupported
break;
}
if (nRemainingBytes != 0)
{
// bad UTF8 string.
return "";
}
return bstr;
}
]]>
</xsl:script>
</xsl:stylesheet>
0
1
1
0
1
0
0
1
1
2
2
3600