123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (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).
- -->
- <!-- $Header: //cpscrn/main/templates/cps4/portlets/utility/portlet-impl/rss/view.xslt#1 $ -->
- <!-- $DateTime: 2008/10/22 11:12:04 $ -->
- <!-- $Change: 25109 $ -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:rss09="http://my.netscape.com/rdf/simple/0.9/"
- xmlns:rss10="http://purl.org/rss/1.0/"
- xmlns:atom="http://www.w3.org/2005/Atom"
- xmlns:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:string="java:java.lang.String"
- exclude-result-prefixes="rdf rss09 rss10 atom ui xts xtsext string">
- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:attribute-set name="anchor">
- <xsl:attribute name="class">cognos-anchor</xsl:attribute>
- <xsl:attribute name="onmouseover">window.status='';return true;</xsl:attribute>
- <xsl:attribute name="onmouseout">window.status='';return true;</xsl:attribute>
- </xsl:attribute-set>
- <ui:property name="target-frame" select="'target'"/>
-
- <xsl:attribute-set name="target">
- <xsl:attribute name="target">
- <xsl:choose>
- <xsl:when test="$open-links = 'new'">_blank</xsl:when>
- <xsl:when test="$open-links = 'current' and not($ui-is-myportal)">_top</xsl:when>
- <xsl:when test="$open-links = 'target'"><xsl:value-of select="$target-frame"/></xsl:when>
- <xsl:when test="$open-links = 'channel'"></xsl:when>
- <xsl:otherwise>_blank</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:attribute-set>
- <ui:property name="rss-entries" select="'rss_entries'"/>
- <ui:property name="rss-prefs" select="'rss_entries'" exclude-nav-state="'true'"/>
- <ui:property name="rss-show-desc" select="'rss_show_desc'"/>
- <ui:property name="rss-show-image" select="'rss_show_image'"/>
- <ui:property name="rss-alternate" select="'rss_alternate'"/>
- <ui:property name="open-links" select="'open_links'"/>
- <ui:property name="channel" select="'channel'"/>
- <xsl:variable name="rss-disable-escaping" select="/root/configuration/property[@name='CPSRssAllowUnsafeCharacters'] = 'true'"/>
-
- <xsl:variable name="valid-link-expr">(([hH][tT][tT][pP][sS]?)://(\S+))|(.{0})</xsl:variable>
-
- <xsl:template match="/">
- <xsl:choose>
- <xsl:when test="/root/rss/*[local-name()='channel'] | /root/rdf:RDF/*[local-name()='channel'] | /root/atom:feed">
- <xsl:call-template name="render-rss"/>
- </xsl:when>
- <xsl:otherwise>
- <table border="0" cellspacing="0" cellpadding="0" width="100%">
- <tr>
- <td class="portlet-font" align="center" valign="middle" height="100"><xts:string id="IDS_UTI_RSS_NO_CONTENT"/></td>
- </tr>
- </table>
- </xsl:otherwise>
- </xsl:choose>
-
- <ui:preview/>
- </xsl:template>
- <xsl:template name="render-rss">
- <script language="javascript">
- function wsrp_rewrite_select(href,e) {
- <xsl:if test="$open-links = 'channel'">
- document.wsrp_rewrite_form.url.value = href;
- document.wsrp_rewrite_form.submit();
- if (e.srcElement) {
- e.returnValue = false;
- } else {
- e.preventDefault();
- }
- </xsl:if>
- }
- </script>
- <xsl:if test="$rss-show-desc = 'true'">
- <style>
- .wsrp_rewrite_border
- {
- border-top: black 1px solid;
- border-left: black 1px solid;
- border-bottom: black 1px solid;
- border-right: black 1px solid;
- display:none;
- width:100%;
- }
- .wsrp_rewrite_padding {
- padding: 3px 3px 3px 3px;
- }
- .wsrp_rewrite_anim
- {
- padding: 0px 0px 0px 0px;
- border-top: black 1px solid;
- border-left: black 1px solid;
- border-bottom: black 1px solid;
- border-right: black 1px solid;
- display:none;
- position:absolute;
- }
- </style>
- <script language="javascript">
- <![CDATA[
- var wsrp_rewrite_rss_height=0;
- var wsrp_rewrite_rss_div=null;
- var wsrp_rewrite_rss_sid="";
- function wsrp_rewrite_rss_start(id) {
- if (wsrp_rewrite_rss_div != null) {
- wsrp_rewrite_rss_div.style.display="none";
- }
- wsrp_rewrite_rss_div=document.getElementById(id);
- wsrp_rewrite_rss_div.style.visibility="hidden";
- wsrp_rewrite_rss_div.style.display="block";
- var ga=document.getElementById("wsrp_rewrite_anim");
- var p = wsrp_rewrite_rss_div.offsetParent;
- var x = 0;
- var y = 0;
- while (p != null) {
- x += p.offsetLeft;
- y += p.offsetTop;
- p = p.offsetParent;
- }
- ga.style.left = wsrp_rewrite_rss_div.offsetLeft + x;
- ga.style.top = wsrp_rewrite_rss_div.offsetTop + y;
- ga.style.width = wsrp_rewrite_rss_div.offsetWidth;
- ga.style.height = 0;
- ga.style.display = "inline";
- wsrp_rewrite_rss_height = 0;
- wsrp_rewrite_rss_sid = window.setInterval(wsrp_rewrite_rss_anim, 10);
- }
-
- function wsrp_rewrite_rss_anim(sID) {
- var ga=document.getElementById("wsrp_rewrite_anim");
- if (wsrp_rewrite_rss_height < wsrp_rewrite_rss_div.offsetHeight) {
- ga.style.height = wsrp_rewrite_rss_height;
- wsrp_rewrite_rss_height += (wsrp_rewrite_rss_div.offsetHeight / 25);
- } else {
- wsrp_rewrite_rss_div.style.visibility="inherit";
- ga.style.display="none";
- window.clearInterval(wsrp_rewrite_rss_sid);
- }
- }
- ]]>
- </script>
- <div id="wsrp_rewrite_anim" class="portlet-font wsrp_rewrite_anim"><br/></div>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="$open-links = 'channel'">
- <form name="wsrp_rewrite_form" method="post" action="wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=set:{ $channel }&wsrp-windowState={ $ui-window-state }/wsrp_rewrite">
- <input type="hidden" name="url" value=""/>
- <input type="hidden" name="rss_entries" value="{ $rss-entries }"/>
- <xsl:apply-templates select="/root/rss | /root/rdf:RDF | /root/atom:feed"/>
- </form>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="/root/rss | /root/rdf:RDF | /root/atom:feed"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="rss|rdf:RDF">
- <script type="text/javascript">
- <xsl:attribute name="src">
- <xsl:value-of select="$ui-webcontent"/>/../ccl/i18n/bidi/BidiUtils.js<xsl:text/>
- </xsl:attribute>
- </script>
- <script language="javascript">
-
- function wsrp_rewrite_setRSSTableDirection()
- {
- var isBidiEnabled = <xsl:value-of select="boolean($ui-portlet-isBidiEnabled='true')"/>;
- if (isBidiEnabled){
- var el = document.getElementById("wsrp_rewrite_RSSTable");
- if (el)
- {
- var baseTextDirection = '<xsl:value-of select="$ui-portlet-baseTextDirection"/>';
- if (baseTextDirection == "auto")
- {
- var bidi = BidiUtils.getInstance();
- bidi.setProperties(baseTextDirection,
- '<xsl:value-of select="xtsext:getBTD('', $ui-portlet-baseTextDirection, $ui-portlet-product-locale)"/>',
- '<xsl:value-of select="$ui-portlet-product-locale"/>');
- var txtContent = el.textContent || el.innerText;
- baseTextDirection = bidi.resolveStrBtd(txtContent);
- }
- el.dir = baseTextDirection;
- }
- }
- }
- if (window.attachEvent) {
- window.attachEvent("onload", wsrp_rewrite_setRSSTableDirection);
- } else if (window.addEventListener) {
- window.addEventListener("load", wsrp_rewrite_setRSSTableDirection, null);
- }
- </script>
-
- <table id="wsrp_rewrite_RSSTable" border="0" cellpadding="0" cellspacing="0" width="100%">
- <xsl:apply-templates select="channel|rss09:channel|rss10:channel|atom:feed"/>
- <xsl:apply-templates select="textinput|rss09:textinput|rss10:textinput"/>
- </table>
- </xsl:template>
- <xsl:template match="atom:feed">
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- <xsl:call-template name="render-feed-content"/>
- </table>
- </xsl:template>
-
- <xsl:template match="channel" name="render-feed-content">
- <xsl:variable name="description" select="concat(description, atom:subtitle)"/>
- <tr>
- <td class="portlet-font">
- <xsl:variable name="url">
- <xsl:call-template name="create-link">
- <xsl:with-param name="link" select="link|atom:link[@rel='alternate' and @type='text/html']/@href"/>
- </xsl:call-template>
- </xsl:variable>
- <a xsl:use-attribute-sets="anchor target">
- <xsl:if test="$url != ''">
- <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
- <xsl:attribute name="onclick">
- <xsl:text>wsrp_rewrite_select('</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode( string($url))"/>
- <xsl:text>',event)</xsl:text>
- </xsl:attribute>
- </xsl:if>
-
- <xsl:if test="$rss-show-image = 'true'">
- <xsl:variable name="image-url">
- <xsl:choose>
- <xsl:when test="*[local-name() = 'image']">
- <xsl:value-of select="*[local-name() = 'image']/*[local-name() = 'url']"/>
- </xsl:when>
- <xsl:when test="atom:icon">
- <xsl:value-of select="atom:icon"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="../*[local-name() = 'image'][1]/*[local-name() = 'url']"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$image-url != ''">
- <img border="0" src="{ $image-url }" style="float:right;"/>
- </xsl:if>
- </xsl:if>
- <b>
- <xsl:apply-templates select="title|atom:title" mode="rss-markup"/>
- </b>
- </a>
- <xsl:if test="$rss-show-desc = 'true' and $description != ''">
- <br/>
- <xsl:value-of select="$description"/>
- <xsl:if test="concat(copyright, atom:rights)!=''">
- <br/>
- <xsl:value-of select="concat(copyright, atom:rights)"/>
- </xsl:if>
- </xsl:if>
- </td>
- </tr>
-
- <xsl:variable name="rss-entries-value">
- <xsl:call-template name="cal-rss-entries-value">
- <xsl:with-param name="count" select="count(item|atom:entry)"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:apply-templates select="item[number($rss-entries-value)>=position()] | atom:entry[number($rss-entries-value)>=position()]"/>
- <xsl:call-template name="generate-footer">
- <xsl:with-param name="count" select="count(item|atom:entry)"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="rss09:channel">
- <xsl:variable name="description" select="rss09:description"/>
- <xsl:if test="$description != ''">
- <tr>
- <td class="portlet-table-header">
- <b>
- <xsl:value-of select="$description"/>
- </b>
- </td>
- </tr>
- </xsl:if>
- <xsl:variable name="rss-entries-value">
- <xsl:call-template name="cal-rss-entries-value">
- <xsl:with-param name="count" select="count(../rss09:item)"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:apply-templates select="../rss09:item[$rss-entries-value>=position()]"/>
- <xsl:call-template name="generate-footer">
- <xsl:with-param name="count" select="count(../rss09:item)"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="rss10:channel">
- <xsl:variable name="description" select="rss10:description"/>
- <tr>
- <td class="portlet-table-header">
- <xsl:variable name="url">
- <xsl:call-template name="create-link">
- <xsl:with-param name="link" select="rss10:link"/>
- </xsl:call-template>
- </xsl:variable>
- <a xsl:use-attribute-sets="anchor target">
- <xsl:if test="$url != ''">
- <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
- <xsl:attribute name="onclick">
- <xsl:text>wsrp_rewrite_select('</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode( string($url))"/>
- <xsl:text>',event)</xsl:text>
- </xsl:attribute>
- </xsl:if>
-
-
- <b>
- <xsl:value-of select="rss10:title"/>
- </b>
- </a>
- <xsl:if test="$rss-show-desc = 'true' and $description != ''">
- <br/>
- <xsl:value-of select="$description"/>
- </xsl:if>
- </td>
- </tr>
-
- <xsl:variable name="rss-entries-value">
- <xsl:call-template name="cal-rss-entries-value">
- <xsl:with-param name="count" select="count(../rss10:item)"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:apply-templates select="../rss10:item[$rss-entries-value>=position()]"/>
- <xsl:call-template name="generate-footer">
- <xsl:with-param name="count" select="count(../rss10:item)"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="item|rss09:item|rss10:item|atom:entry">
- <xsl:variable name="description">
- <xsl:choose>
- <xsl:when test="*[local-name() = 'description']"><xsl:copy-of select="*[local-name() = 'description']"/></xsl:when>
- <xsl:when test="atom:content[contains(@type, 'text') or contains(@type, 'html')]">
- <xsl:copy-of select="atom:content"/>
- </xsl:when>
- <xsl:when test="atom:summary"><xsl:copy-of select="atom:summary"/></xsl:when>
- </xsl:choose>
- </xsl:variable>
- <tr>
- <td class="portlet-table-text">
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="position() mod 2 = 0 and $rss-alternate = 'true'">portlet-table-alternate</xsl:when>
- <xsl:otherwise>portlet-table-text</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:variable name="author">
- <xsl:choose>
- <xsl:when test="atom:contributor/atom:name">
- <xsl:value-of select="atom:contributor/atom:name"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="*[local-name()='author' or local-name()='creator' and .!=''][1]"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$author != ''">
- <xsl:text/><xts:string id="IDS_UTI_RSS_TITLE_BY"><xts:param name="title"><xsl:call-template name="render-link"/></xts:param><xts:param name="author"><xsl:value-of select="$author"/></xts:param></xts:string>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="render-link"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="($rss-show-desc = 'true')">
- <br/>
- <div id="wsrp_rewrite_{generate-id()}" class="wsrp_rewrite_border">
- <div class="portlet-font wsrp_rewrite_padding">
- <xsl:if test="*[local-name() = 'link']">
- <xsl:variable name="url">
- <xsl:call-template name="create-link">
- <xsl:with-param name="link" select="atom:link[@rel='alternate' and @type='text/html']/@href | *[local-name() = 'link' and namespace-uri() != 'http://www.w3.org/2005/Atom']"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:if test=" $url != ''">
- <a xsl:use-attribute-sets="anchor target" href="{ $url }" onclick="wsrp_rewrite_select('{ xtsext:javascriptencode(string($url)) }',event)"><xts:string id="IDS_UTI_RSS_READ_FEED"/></a><br/>
- </xsl:if>
- </xsl:if>
- <xsl:apply-templates select="$description" mode="rss-markup"/>
- </div>
- </div>
- </xsl:if>
- </td>
- </tr>
- </xsl:template>
- <xsl:template name="render-link">
-
-
- <xsl:variable name="url">
- <xsl:call-template name="create-link">
- <xsl:with-param name="link" select="atom:link[@rel='alternate' and @type='text/html']/@href | *[local-name() = 'link' and namespace-uri() != 'http://www.w3.org/2005/Atom']"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="$rss-show-desc = 'true'">
- <a xsl:use-attribute-sets="anchor" href="javascript:wsrp_rewrite_rss_start('wsrp_rewrite_{generate-id()}')">
- <xsl:apply-templates select="*[local-name() = 'title']" mode="rss-markup"/>
- </a>
- </xsl:when>
- <xsl:when test="not(*[local-name() = 'link'])">
- <xsl:apply-templates select="*[local-name() = 'title']" mode="rss-markup"/>
- </xsl:when>
- <xsl:when test=" $url != '' ">
- <a xsl:use-attribute-sets="anchor target" href="{ $url }" onclick="wsrp_rewrite_select('{ xtsext:javascriptencode(string($url)) }',event)">
- <xsl:apply-templates select="*[local-name() = 'title']" mode="rss-markup"/>
- </a>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="*[local-name() = 'title']" mode="rss-markup"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="textinput|rss09:textinput|rss10:textinput">
- <tr>
- <td class="portlet-form-text">
- <form name="wsrp_rewrite_{ generate-id() }" method="get" action="{ normalize-space(*[local-name() = 'link']) }" target="_blank">
- <br/>
- <xsl:value-of select="*[local-name() = 'description']"/>
- <br/>
- <input class="portlet-form-input-field" type="text" name="{*[local-name() = 'name']}" value=""/>
- <xsl:text> </xsl:text>
- <input class="portlet-form-button" type="submit" name="submit" value="{*[local-name() = 'title']}"/>
- </form>
- </td>
- </tr>
- </xsl:template>
- <!-- We ignore images unless we are inside a channel -->
- <xsl:template match="rss09:image | rss10:image"/>
- <xsl:template name="generate-footer">
- <xsl:param name="count"/>
-
- <xsl:variable name="rss-entries-value">
- <xsl:call-template name="cal-rss-entries-value">
- <xsl:with-param name="count" select="$count"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="number($count)>number($rss-entries-value)">
- <tr>
- <td class="portlet-font" align="center">
- <br/>
- <ui:create-nav-state name="state">
- <ui:param name="rss_entries">
- <xsl:value-of select="$count"/>
- </ui:param>
- </ui:create-nav-state>
- <a xsl:use-attribute-sets="anchor" href="wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState={xtsext:urlencode($state)}/wsrp_rewrite"><xts:string id="IDS_UTI_RSS_LINK_DISPLAY_ALL"/></a>
- </td>
- </tr>
- </xsl:when>
- <xsl:when test="number($rss-entries-value)>number($rss-prefs)">
- <tr>
- <td class="portlet-font" align="center">
- <br/>
- <ui:create-nav-state name="state">
- <ui:param name="rss_entries">
- <xsl:value-of select="$rss-prefs"/>
- </ui:param>
- </ui:create-nav-state>
- <a xsl:use-attribute-sets="anchor" href="wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState={xtsext:urlencode($state)}/wsrp_rewrite"><xts:string id="IDS_UTI_RSS_LINK_DISPLAY_PARTIAL"><xts:param name="count"><xsl:value-of select="$rss-prefs"/></xts:param></xts:string></a>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="cal-rss-entries-value">
- <xsl:param name="count"/>
- <xsl:choose>
- <xsl:when test="number($count)>number($rss-entries) and number($rss-prefs) != number($rss-entries)">
- <xsl:value-of select="$rss-prefs"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$rss-entries"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template match="*" mode="rss-markup">
- <xsl:choose>
- <xsl:when test="$rss-disable-escaping">
- <xsl:value-of select="." disable-output-escaping="yes"/>
- </xsl:when>
- <xsl:when test="*">
- <xsl:copy-of select="."/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="create-link">
- <xsl:param name="link"/>
- <xsl:if test="boolean(string:matches( string:new( normalize-space($link) ), $valid-link-expr ))">
- <xsl:value-of select="normalize-space($link)"/>
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>
|