123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ps
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <xsl:stylesheet version="1.0"
- xmlns:out="dummy-uri"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:sr="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/search"
- xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
- xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
- xmlns:cml="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cml/1/"
- xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:xts="http://developer.cognos.com/schemas/xts/">
- <xsl:output method="xml" encoding="UTF-8" indent="no"/>
- <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
- <!--
- This stylesheet (search.xsl) consists of the following templates:
- mt:search - generate main search area for page.
- mt:directPath - used in lieu of path control in search dialog (only tools).
- mt:scopes - generates select element
- mt:scope - generate scope list for tools search dialog.
- mt:stypes - placeholder.
- mt:stype - generate type list for tools search dialog.
- -->
- <!--
- Template - search:gen-search-exp:
- This template generates the expression when a search is launched
- Operation:
- Generates /root/search/expression search results or /root/search/emptySearchExpression when there are no search results.
- -->
- <xsl:template match="sr:generate-exp" priority="1">
- <xts:append>
- <search>
- <out:variable name="search_string" select="/root/env/param[@name = 'search_text']"/>
- <out:variable name="search_modified_filter" select="/root/env/param[@name = 'search_modified']"/>
- <out:variable name="search_type_filter" select="/root/env/param[@name = 'search_type']"/>
- <out:variable name="search_show_filter" select="/root/env/param[@name = 'search_show']"/>
- <!-- if there is something to search on then build a search expression and append it to the imput doc. -->
- <out:choose>
- <out:when test="$search_string != '' or $search_modified_filter != 'any' or $search_type_filter != 'any' or $search_show_filter != ''">
- <out:variable name="sq">'</out:variable>
- <!-- must escape the ' to '' to make the search expression CM safe. -->
- <out:variable name="text" select=" xtsext:replace(string($search_string), string($sq), concat($sq,$sq)) "/>
- <expression>
- <!-- Scope ==== -->
- <out:variable name="scope" select="string(/root/env/param[@name = 'search_scope'])"/>
- <out:variable name="isAdminUser" select="boolean(/root/session/param[@name='capabilities']/canUseAdministrationPortal)"/>
- <out:variable name="defaultContentRoot">
- <out:choose>
- <out:when test="/root/session/param[@name='e_root'] and /root/session/param[@name='e_root'] != ''">
- <out:value-of select="/root/session/param[@name='e_root']"/>
- </out:when>
- <out:otherwise>
- <out:value-of select="'/content'"/>
- </out:otherwise>
- </out:choose>
- </out:variable>
- <out:choose>
- <!-- current folder and subfolders -->
- <out:when test="$scope = 'fb'"><out:value-of select="$path"/>/descendant::*</out:when>
- <!-- current folder only -->
- <out:when test="$scope = 'fo'"><out:value-of select="$path"/>/*</out:when>
- <!-- personal folders -->
- <out:when test="$scope = 'm'">~/folder/descendant::*</out:when>
- <!-- public folders -->
- <out:when test="$scope = 'p'"><out:value-of select="$defaultContentRoot"/>/descendant::*</out:when>
- <!-- tool root ( i.e. /configuration for server admin tool, /content for schedule tool, /directory for directory tool -->
- <out:when test="$scope = 'any'"><out:value-of select="$defaultPath"/>/descendant::*</out:when>
- <!-- no scope is defined, default to tool root -->
- <out:otherwise>
- <xsl:choose>
- <xsl:when test="@defaultRoot and @defaultRoot != '$defaultPath'">
- <out:value-of select="concat('/', {@defaultRoot}, '/descendant::*')"/>
- </xsl:when>
- <xsl:otherwise>/descendant::*</xsl:otherwise>
- </xsl:choose>
- </out:otherwise>
- </out:choose>
- <!-- Field / Search Type ==== -->
- <out:if test="$text != ''">
- <out:variable name="method" select="string(/root/env/param[@name = 'search_method'])"/>
- <out:choose>
- <out:when test="string(/root/env/param[@name = 'sfield'])='' or /root/env/param[@name = 'sfield'] = 'n'">
- <out:choose>
- <out:when test="$method = '3'">[@defaultName = '<out:value-of select="$text"/>']</out:when>
- <out:when test="$method = '2'">[starts-with(@defaultName, '<out:value-of select="$text"/>' )]</out:when>
- <out:otherwise>[contains(@defaultName, '<out:value-of select="$text"/>' )]</out:otherwise>
- </out:choose>
- </out:when>
- <out:when test="/root/env/param[@name = 'sfield'] = 'd'">
- <out:choose>
- <out:when test="$method = '3'">[@defaultDescription = '<out:value-of select="$text"/>']</out:when>
- <out:when test="$method = '2'">[starts-with(@defaultDescription, '<out:value-of select="$text"/>' )]</out:when>
- <out:otherwise>[contains(@defaultDescription, '<out:value-of select="$text"/>' )]</out:otherwise>
- </out:choose>
- </out:when>
- <out:otherwise>
- <out:choose>
- <out:when test="$method = '3'">[@defaultDescription = '<out:value-of select="$text"/>' or @defaultName = '<out:value-of select="$text"/>']</out:when>
- <out:when test="$method = '2'">[starts-with(@defaultDescription, '<out:value-of select="$text"/>' ) or starts-with(@defaultName, '<out:value-of select="$text"/>' )]</out:when>
- <out:otherwise>[contains(@defaultDescription, '<out:value-of select="$text"/>' ) or contains(@defaultName, '<out:value-of select="$text"/>' )]</out:otherwise>
- </out:choose>
- </out:otherwise>
- </out:choose>
- </out:if>
- <!-- Object Filter ==== -->
- <out:choose>
- <out:when test="$search_type_filter != 'any'">
- <out:choose>
- <out:when test="$search_type_filter = 'service' ">
- <out:text>[</out:text>
- <out:for-each select="/root/system/param[@name='ui_objects']/object[@service='T'][position()!=last()]">
- <out:value-of select="concat('@objectClass="', @class, '" or ')"/>
- </out:for-each>
- <out:text>@objectClass="</out:text>
- <out:value-of select="/root/system/param[@name='ui_objects']/object[@service='T'][position()=last()]/@class"/>
- <out:text>"]</out:text>
- </out:when>
- <out:otherwise>
- <out:text/>[@objectClass = '<out:value-of select="$search_type_filter"/>']<out:text/>
- </out:otherwise>
- </out:choose>
- </out:when>
- <out:otherwise>
- <xsl:choose>
- <xsl:when test="sr:defaultTypes">
- <out:text/>[<out:text/>
- <!--xsl:apply-templates select="sr:defaultTypes/child::node()"/-->
- <xsl:apply-templates select="sr:defaultTypes/child::node()"/>
- <out:text/>]<out:text/>
- </xsl:when>
- <xsl:otherwise>
- <out:text/>[@usage != 'subObject']<out:text/>
- </xsl:otherwise>
- </xsl:choose>
- </out:otherwise>
- </out:choose>
- <!-- Modified date ==== -->
- <out:if test="$search_modified_filter != 'any'">
- <out:variable name="offsetamt">
- <out:choose>
- <out:when test="$search_modified_filter = 't'">0</out:when>
- <out:when test="$search_modified_filter = 'l3d'">-259200</out:when>
- <out:when test="$search_modified_filter = 'lw'">-604800</out:when>
- <out:when test="$search_modified_filter = 'lm'">-2629743</out:when>
- <out:when test="$search_modified_filter = 'l3m'">-7889231</out:when>
- <out:when test="$search_modified_filter = 'l6m'">-15778463</out:when>
- <out:when test="$search_modified_filter = 'ly'">-31556926</out:when>
- <out:when test="$search_modified_filter = 'l3y'">-94670777</out:when>
- </out:choose>
- </out:variable>
- <out:variable name="offsetunit">second</out:variable>
- <out:text/>[@modificationTime > '<out:value-of select="xtsext:formatDateToUTC(xtsext:getDateTimeOffset(concat(xtsext:substringBeforeLast(xtsext:getCurrentDateTime(/root/user/param[@name='timeZoneID']), 'T'), 'T00:00:00Z'), $offsetamt, $offsetunit),/root/user/param[@name='timeZoneID'])"/>']<out:text/>
- </out:if>
- <!-- Default security filters ==== -->
- <xsl:choose>
- <xsl:when test="not(@defaultRoot)">
- <out:value-of select="$visibility-predicate"/>
- </xsl:when>
- <xsl:otherwise>
- <out:if test="starts-with($path, "CAMID(':") or starts-with($path, 'CAMID(":')">
- <!-- only add the security filter if we're in the Cognos namespace -->
- <out:value-of select="$visibility-predicate"/>
- </out:if>
- <!-- no need to check for permissions in a third party namespace. Security is configured by the third party tool -->
- </xsl:otherwise>
- </xsl:choose>
- </expression>
- </out:when>
- <!-- when we only search on one object then there won't be an stype -->
- <out:when test="$search_string = '' and $search_modified_filter = 'any' and ($search_type_filter = 'any' or not(/root/env/param[@name = 'stype']))">
- <emptySearchExpression/>
- </out:when>
- </out:choose>
- </search>
- </xts:append>
- </xsl:template>
- <xsl:template match="sr:defaultType" priority="1">
- <xsl:choose>
- <xsl:when test="string(.) = 'service' ">
- <out:for-each select="/root/system/param[@name='ui_objects']/object[@service='T'][position()!=last()]">
- <out:text>@objectClass='</out:text>
- <out:value-of select="@class"/>
- <out:text>' or </out:text>
- </out:for-each>
- <out:text>@objectClass='</out:text>
- <out:value-of select="/root/system/param[@name='ui_objects']/object[@service='T'][position()=last()]/@class"/>
- <out:text>'</out:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="preceding-sibling::sr:defaultType"><out:text/> or <out:text/></xsl:if>
- <out:text/>@objectClass='<xsl:value-of select="string(.)"/>'<out:text/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates/>
- </xsl:copy>
- </xsl:template>
- </xsl:stylesheet>
|