123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732 |
- <?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/fragments/pagelayout/pagelayout.xts#1 $ -->
- <!-- $DateTime: 2008/10/22 11:12:04 $ -->
- <!-- $Change: 25109 $ -->
- <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/">
- <!--
- Page Layout Fragment
- -->
- <xts:block id="decode" processor="XSLT" type="exec" mode="interpret"
- condition="/root/env/param[@name = 'pagexml']" mandatory="false"
- nodelist="env">
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- exclude-result-prefixes="xts xtsext">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:template match="/">
- <xts:sequence>
- <xts:append>
- <pagelet>
- <xsl:value-of select="/root/env/param[@name = 'pagexml']" disable-output-escaping="yes"/>
- </pagelet>
- </xts:append>
- </xts:sequence>
- </xsl:template>
- </xsl:stylesheet>
- </xts:block>
-
- <xts:block id="default-layouts" processor="XML" type="exec" mode="input" path="/fragments/pagelayout/layouts.xml"/>
- <xts:block id="response" type="exec" mode="interpret" processor="XSLT"
- dependency="decode default-layouts"
- nodelist="env, pagelet, layouts">
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
- xmlns:cps="http://developer.cognos.com/schemas/cps/asm/objects/1/"
- xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"
- xmlns:cpsext="http://developer.cognos.com/schemas/cps/wsrp/extensions/1/"
- exclude-result-prefixes="xts xtsext cps xos wsrp cpsext">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:key name="env-param" match="/root/env/param" use="@name"/>
- <xsl:key name="http-param" match="/root/http/param" use="@name"/>
- <xsl:variable name="frag-id" select="key('env-param', 'frag-id')"/>
- <xsl:variable name="frag-state" select="key('env-param', 'frag-state')"/>
- <xsl:variable name="frag-pagemode" select="key('env-param', 'frag-pagemode')"/>
- <xsl:variable name="frag-agent" select="key('env-param', 'frag-agent')"/>
- <xsl:variable name="read-only" select="key('env-param', 'readonly') = 'true'"/>
- <xsl:variable name="pagelet" select="/root/pagelet/*"/>
- <xsl:variable name="default-layouts" select="/root/layouts/layout"/>
- <!--
- if the pagelet layout is not found in the default layouts,
- the pagelet layout is added to the list of available layouts
- and the current selection index is set to the last entry
- otherwise the layout was found in the default layouts
- set the index to the matching default layout
- -->
- <xsl:variable name="pagelet-layout-id">
- <xsl:apply-templates select="$pagelet/cps:layout/layout" mode="id"/>
- </xsl:variable>
- <xsl:variable name="pagelet-layout-index">
- <xsl:apply-templates select="$default-layouts" mode="compare-ids">
- <xsl:with-param name="id" select="$pagelet-layout-id"/>
- </xsl:apply-templates>
- </xsl:variable>
-
- <xsl:variable name="calculated-layouts">
- <xsl:copy-of select="$default-layouts"/>
- <xsl:if test="$pagelet-layout-index = ''">
- <xsl:copy-of select="$pagelet/cps:layout/layout"/>
- </xsl:if>
- </xsl:variable>
-
- <xsl:variable name="layouts" select="$calculated-layouts/*"/>
- <xsl:variable name="layout-index">
- <xsl:choose>
- <xsl:when test="not($pagelet)">
- <xsl:value-of select="0"/>
- </xsl:when>
- <xsl:when test="$pagelet-layout-index = ''">
- <xsl:value-of select="count($default-layouts)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$pagelet-layout-index"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- parameters not to be passed into assembler call -->
- <xsl:variable name="params-excluded" select="' encoding frag-id frag-state '"/>
- <xsl:variable name="interaction-params" select="/root/env/param[not(contains($params-excluded, concat(' ', @name, ' ')))]"/>
- <xsl:template match="/">
- <xts:sequence>
- <xts:append select="/root/output">
- <xos:part>
- <xos:entityHeader>
- <xos:param name="Content-type">text/xml</xos:param>
- </xos:entityHeader>
- <xos:entityBody>
- <xsl:call-template name="fragment"/>
- </xos:entityBody>
- </xos:part>
- </xts:append>
- </xts:sequence>
- </xsl:template>
- <xsl:template name="fragment">
- <fragment xmlns="http://developer.cognos.com/fragments/1/">
- <info>
- <title>Page Layout Editor</title>
- <description></description>
- </info>
- <css type="text/css" media="all" href="$CGI$/css/portlet?skin=$SKIN$"/>
- <library type="text/javascript" href="$WEB$/fragments/fragments.js"/>
- <library type="text/javascript" href="$WEB$/common/framework/validator/CValidator.js"/>
- <library type="text/javascript" href="$WEB$/fragments/pagelayout/script/pagelayout.js"/>
- <markup>
- <validator>
- <param name="readonly">
- <validate xmlns:val="http://developer.cognos.com/schemas/validator/1/" skipJavaScript="true">
- <val:name>readonly</val:name>
- <val:rule>
- <val:enumeration emptyValid="false">
- <val:list>true,false</val:list>
- </val:enumeration>
- </val:rule>
- </validate>
- </param>
- <param name="id">
- <validate xmlns:val="http://developer.cognos.com/schemas/validator/1/" skipJavaScript="true">
- <val:name>id</val:name>
- <val:ruleRef xmlns:fragment="urn:cognos:fragments:validator" id="fragment:frag-id"/>
- </validate>
- </param>
- </validator>
- <mimeType>text/html</mimeType>
- <markupXml>
- <script>
- var RESOURCE_URI = "_THIS?frag-resource=/fragments/THIS_";
- //-------------------------------------------------------------
- // Page Layout Editor
- // the current CPage object
- var _THIS_page = null;
- // generate unique ids for the current page session
- var _THIS_idcount = 0;
- function _THIS_genID()
- {
- return "P<xsl:value-of select="xtsext:generateGUID()"/>" + (_THIS_idcount++);
- }
- //-------------------------------------------------------------
- // layout menu
- <xsl:if test="not ($read-only)">
- var _THIS_layouts = [ <xsl:apply-templates select="$layouts" mode="layout"/> ] ;
- var _THIS_layoutMenu =
- {
- current: "<xsl:value-of select="$layout-index"/>",
- selectDivs: null,
- menu: null,
- menuDivs: null,
- //- void init()
- init: function()
- {
- this.menu = $("_THIS_layoutmenu");
- var container = $("_THIS_layoutselect");
- var list = container.childNodes;
- this.selectDivs = new Array(list.length);
- this.menuDivs = new Array(list.length);
- var i, l = list.length;
- for (i = 0; i < l; i++)
- {
- this.selectDivs[i] = list[i];
- var div = $("_THIS_layoutitem" + i);
- this.menuDivs[i] = div;
- div.menuIndex = i;
- xAddEventListener(div, "mouseover", function(e) { _THIS_layoutMenu.menuOver(e) }, false);
- xAddEventListener(div, "mouseout", function(e) { _THIS_layoutMenu.menuOut(e) }, false);
- xAddEventListener(div, "mousedown", function(e) { _THIS_layoutMenu.menuDown(e) }, false);
- }
- },
-
- //- void select(int index)
- select: function(index)
- {
- if (index == this.current)
- return;
-
- if (this.current > -1)
- {
- xDisplay(this.selectDivs[this.current], "none");
- xBackground(this.menuDivs[this.current], "white");
- }
- if (index > -1)
- {
- xDisplay(this.selectDivs[index], "block");
- xBackground(this.menuDivs[index], "lightgrey");
- }
- this.current = index;
- },
-
- //- void setLayout(index)
- setLayout: function(index)
- {
- this.select(index);
- _THIS_page.setLayout("_THIS_page", _THIS_layouts[index]);
- },
-
- //- boolean visible()
- visible: function()
- {
- return xVisibility(this.menu) != 'hidden';
- },
-
- //- void show()
- show: function()
- {
- xShow(this.menu);
-
- if (!this.menuMDfunc)
- {
- this.menuMDfunc = function(e)
- {
- xRemoveEventListener(document, "mousedown", _THIS_layoutMenu.menuMDfunc, false);
- _THIS_layoutMenu.hide();
- };
- }
- xAddEventListener(document, "mousedown", this.menuMDfunc, false);
- },
-
- //- void hide()
- hide: function()
- {
- xHide(this.menu);
- },
-
- //- void toggle()
- toggle: function()
- {
- if (this.visible())
- this.hide();
- else
- this.show();
- },
-
- //- void menuOver(Event evt)
- menuOver: function(evt)
- {
- var e = new xEvent(evt);
- var ele = e.target;
- var obj = _F_findParentObj(ele, "_THIS_layoutitem");
- var index = obj.menuIndex;
- if (this.menuDivs[index])
- {
- var div = this.menuDivs[index];
-
- var td = xParent(div, true);
- td.style.backgroundColor = "lightblue";
- }
- },
- //- void menuOut(Event evt)
- menuOut: function(evt)
- {
- var e = new xEvent(evt);
- var ele = e.target;
- var obj = _F_findParentObj(ele, "_THIS_layoutitem");
- var index = obj.menuIndex;
- if (this.menuDivs[index])
- {
- var div = this.menuDivs[index];
-
- var td = xParent(div, true);
- td.style.backgroundColor = "white";
- }
- },
-
- //- void menuDown(Event evt)
- menuDown: function(evt)
- {
- xPreventDefault(evt);
- var e = new xEvent(evt);
- var ele = e.target;
- var obj = _F_findParentObj(ele, "_THIS_layoutitem");
- var index = obj.menuIndex;
- this.setLayout(index);
- }
- };
- </xsl:if>
- //-------------------------------------------------------------
- // init
- _THIS_.ondrop =
- function(context)
- {
- var x = context.xevent.pageX;
- var y = context.xevent.pageY;
-
- if (context.type == "portlet" || context.type == "pagelet")
- {
- switch (context.dropType)
- {
- case context.ENTER:
- _THIS_page.startSelection(x, y);
- break;
-
- case context.MOVE:
- _THIS_page.moveSelection(x, y);
- context.canDrop(_THIS_page.hasSelection());
- break;
-
- case context.LEAVE:
- _THIS_page.endSelection();
- break;
-
- case context.DROP:
- var sLayoutId = _THIS_genID();
- var sId = "_THIS_" + sLayoutId;
- var sPortletId = context.payload.substring(1);
- var sTitle = context.title;
-
- var portlet = new CPortlet(sId, sLayoutId, sPortletId, sTitle);
- _THIS_page.insertPortlet(portlet);
- portlet.retrieve();
-
- _THIS_page.endSelection();
- break;
- }
- }
- };
- _THIS_.onresize =
- function()
- {
- _THIS_page.reflow();
- };
- _THIS_.setOnloadHandler(
- function()
- {
- if (window._THIS_layoutMenu)
- _THIS_layoutMenu.init();
-
- <xsl:choose>
- <xsl:when test="$pagelet">
- _THIS_page = new CPage("_THIS_", "<xsl:value-of select="xtsext:javascriptencode(/root/env/param[@name = 'id'])"/>", _THIS_.div, [ <xsl:apply-templates select="$pagelet//column[not(row)]" mode="zone"/> ]);
- <xsl:if test="$read-only">
- _THIS_page.isReadOnly=true;
- </xsl:if>
- _THIS_page.initZones("_THIS_page", <xsl:apply-templates select="$pagelet/cps:layout/layout" mode="layout"/>);
- </xsl:when>
- <xsl:otherwise>
- _THIS_page = new CPage("_THIS_", null, _THIS_.div);
- _THIS_page.setLayout("_THIS_page", _THIS_layouts[<xsl:value-of select="$layout-index"/>]);
- if(window._THIS_layoutMenu)
- _THIS_layoutMenu.setLayout(<xsl:value-of select="$layout-index"/>);
- </xsl:otherwise>
- </xsl:choose>
- }
- );
- </script>
- <!-- Layout Menu -->
- <xsl:variable name="MINISELECT_WIDTH" select="16"/>
- <xsl:variable name="MINISELECT_HEIGHT" select="20"/>
- <xsl:variable name="MINI_WIDTH" select="20"/>
- <xsl:variable name="MINI_HEIGHT" select="24"/>
- <xsl:variable name="cols" select="3"/>
- <xsl:variable name="rows" select="ceiling(count($layouts) div $cols)"/>
- <xsl:if test="not($read-only)">
- <table cellspacing="0" cellpadding="0" border="0">
- <tr>
- <td>
- <div style="border: 1px solid silver;" onclick="_THIS_layoutMenu.toggle();">
- <table cellspacing="0" cellpadding="0" border="0">
- <tr>
- <td>
- <div id="_THIS_layoutselect">
- <xsl:for-each select="$layouts">
- <xsl:variable name="display">
- <xsl:choose>
- <xsl:when test="(position() - 1) = $layout-index">block</xsl:when>
- <xsl:otherwise>none</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <div style="width:{ $MINISELECT_WIDTH + 2 }px; height:{ $MINISELECT_HEIGHT + 5 }px; margin:3px; display:{ $display };">
- <xsl:apply-templates select="." mode="mini">
- <xsl:with-param name="width" select="$MINISELECT_WIDTH"/>
- <xsl:with-param name="height" select="$MINISELECT_HEIGHT"/>
- </xsl:apply-templates>
- </div>
- </xsl:for-each>
- </div>
- </td>
- <td width="10px" align="middle" valign="center">
- <img src="_THIS?frag-resource=/fragments/common/images/dropdown.gif/THIS_"/>
- </td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
- </table>
-
- <div id="_THIS_layoutmenu" style="position: absolute; overflow: hidden; visibility: hidden; z-index:100; width: { ($MINI_WIDTH + 11) * $cols }px; border:1px solid black; background-color: white;">
- <table border="0" cellpadding="0" cellspacing="0">
- <xsl:for-each select="$layouts[position() mod $cols = 1]">
- <xsl:variable name="outer" select="(position() - 1) * $cols"/>
- <tr>
- <xsl:for-each select=". | following-sibling::layout[position() < $cols]">
- <xsl:variable name="index" select="$outer + position() - 1"/>
- <td>
- <xsl:variable name="style-selected">
- <xsl:if test="$index = $layout-index">
- <xsl:text> background-color: lightgrey;</xsl:text>
- </xsl:if>
- </xsl:variable>
- <div id="_THIS_layoutitem{ $index }" style="width:{ $MINI_WIDTH }px; margin:5px;{ $style-selected }">
- <xsl:apply-templates select="." mode="mini">
- <xsl:with-param name="width" select="$MINI_WIDTH"/>
- <xsl:with-param name="height" select="$MINI_HEIGHT"/>
- </xsl:apply-templates>
- </div>
- </td>
- </xsl:for-each>
- </tr>
- </xsl:for-each>
- </table>
- </div>
- </xsl:if>
- <!-- Layout pieces -->
- <div id="_THIS_page"/>
- <div id="_THIS_selector" style="visibility:hidden; position:absolute; border: 2px solid black; z-index: 80"/>
- <div id="_THIS_shadow" style="visibility:hidden; position:absolute; border: 2px dashed black; z-index: 22"/>
- <div id="_THIS_resizeBar" style="position:absolute; visibility: hidden; cursor: w-resize; width: 4px; background-color:#999999; z-index:80"/>
- <div id="_THIS_resizeBox" style="position:absolute; visibility: hidden; border: 4px solid #999999; z-index:79"/>
- <div id="_THIS_resizeInfo" style="position:absolute; visibility: hidden; width: 60px; height: 20px; border: 1px solid black; background-color:#ffff99; z-index:79">
- <table cellspacing="0" cellpadding="2" border="0" width="100%">
- <tr>
- <td width="50%" align="left" valign="middle"><span id="_THIS_resizeLeft">0%</span></td>
- <td width="50%" align="right" valign="middle"><span id="_THIS_resizeRight">0%</span></td>
- </tr>
- </table>
- </div>
- <div id="_THIS_blur" style="position:absolute; background-color:#eeeeee; filter:alpha(opacity=50); opacity:0.3; z-index:80;"/>
- </markupXml>
- </markup>
- </fragment>
- </xsl:template>
-
- <!--
- deserialize pagelet xml into a CPage object
- -->
- <xsl:template match="cps:pagelet">
- <xsl:text>new CPage("_THIS_", _THIS_.div, </xsl:text>
- <xsl:apply-templates select="cps:layout" mode="layout"/>
- <xsl:text>, [ </xsl:text>
- <xsl:apply-templates select="cps:layout//column[not(self::row)]" mode="zone"/>
- <xsl:text>], { id: "</xsl:text>
- <xsl:value-of select="cps:id"/>
- <xsl:text>", name: "</xsl:text>
- <xsl:value-of select="cps:name"/>
- <xsl:if test="cps:description">
- <xsl:text>", description: "</xsl:text>
- <xsl:value-of select="cps:description"/>
- </xsl:if>
- <xsl:if test="cps:screenTip">
- <xsl:text>", screenTip: "</xsl:text>
- <xsl:value-of select="cps:screenTip"/>
- </xsl:if>
- <xsl:text>" } ) </xsl:text>
- </xsl:template>
-
- <xsl:template match="cps:layout">
- <xsl:apply-templates mode="layout"/>
- </xsl:template>
-
- <!--
- deserialize layout xml into CLayout objects
- -->
- <xsl:template match="layout" mode="layout">
- <xsl:text>new CLayout( [ </xsl:text>
- <xsl:choose>
- <xsl:when test="row">
- <xsl:apply-templates select="row" mode="layout"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>new CRow( [ </xsl:text>
- <xsl:apply-templates select="column" mode="layout"/>
- <xsl:text>] ) </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>], { </xsl:text>
- <xsl:apply-templates select="title | instructions | portletOptions" mode="json"/>
- <xsl:text>} )</xsl:text>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
-
- <xsl:template match="row" mode="layout">
- <xsl:text>new CRow( [ </xsl:text>
- <xsl:apply-templates select="column" mode="layout"/>
- <xsl:text> ] )</xsl:text>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
-
- <xsl:template match="column" mode="layout">
- <xsl:text>new CColumn("</xsl:text>
- <xsl:value-of select="@width"/>
- <xsl:text>"</xsl:text>
- <xsl:if test="row">
- <xsl:text>, [ </xsl:text>
- <xsl:apply-templates select="row" mode="layout"/>
- <xsl:text>] </xsl:text>
- </xsl:if>
- <xsl:text>) </xsl:text>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
- <!--
- deserialize column xml into CZone objects
- -->
- <xsl:template match="column" mode="zone">
- <xsl:text>new CZone( [ </xsl:text>
- <xsl:apply-templates select="portlet" mode="zone"/>
- <xsl:text>] )</xsl:text>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
-
- <xsl:template match="portlet" mode="zone">
- <xsl:variable name="layout-id" select="@id"/>
- <xsl:variable name="portlet-instance" select="$pagelet/cps:portletInstance[cps:id = $layout-id]"/>
- <xsl:text>new CPortlet( { id: "_THIS_portlet_</xsl:text>
- <xsl:value-of select="$layout-id"/>
- <xsl:text>", layoutId: "</xsl:text>
- <xsl:value-of select="$layout-id"/>
- <xsl:text>", portletId: "</xsl:text>
- <xsl:value-of select="$portlet-instance/cps:portletId"/>
- <xsl:text>"</xsl:text>
- <xsl:variable name="context" select="$portlet-instance/wsrp:portletContext"/>
- <xsl:if test="$context">
- <xsl:text>, context: { portletHandle: "</xsl:text>
- <xsl:value-of select="$context/wsrp:portletHandle"/>
- <xsl:text>", portletState: "</xsl:text>
- <xsl:value-of select="$context/wsrp:portletState"/>
- <xsl:text>"</xsl:text>
- <xsl:variable name="type" select="$context/wsrp:extensions/cpsext:info/cpsext:type"/>
- <xsl:if test="$type">
- <xsl:text>, portletType: "</xsl:text>
- <xsl:value-of select="$type"/>
- <xsl:text>"</xsl:text>
- </xsl:if>
- <xsl:text> } </xsl:text>
- </xsl:if>
- <xsl:text>} ) </xsl:text>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
-
- <!--
- render mini layouts
- -->
- <xsl:template match="layout" mode="mini">
- <xsl:param name="width"/>
- <xsl:param name="height"/>
- <xsl:choose>
- <xsl:when test="row">
- <xsl:apply-templates select="row" mode="mini">
- <xsl:with-param name="width" select="$width"/>
- <xsl:with-param name="height" select="$height"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="row-mini">
- <xsl:with-param name="width" select="$width"/>
- <xsl:with-param name="height" select="$height"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="row" name="row-mini" mode="mini">
- <xsl:param name="width"/>
- <xsl:param name="height"/>
- <xsl:variable name="pixel-height" select="$height div last()"/>
- <table cellpadding="0" cellspacing="0" border="1" width="100%">
- <tr height="{ $pixel-height - 1 }px">
- <xsl:apply-templates select="column" mode="mini">
- <xsl:with-param name="width" select="$width"/>
- <xsl:with-param name="height" select="$pixel-height"/>
- </xsl:apply-templates>
- </tr>
- </table>
- </xsl:template>
-
- <xsl:template match="column" mode="mini">
- <xsl:param name="width"/>
- <xsl:param name="height"/>
- <xsl:variable name="pixel-width" select="($width * @width div 100) - count(ancestor::row)"/>
- <td width="{ $pixel-width }px" val="{ count(ancestor::row) }">
- <xsl:if test="position() = last()">
- <xsl:attribute name="align">right</xsl:attribute>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="row">
- <xsl:apply-templates select="row" mode="mini">
- <xsl:with-param name="width" select="$pixel-width"/>
- <xsl:with-param name="height" select="$height"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <img width="1" height="1" alt="" src="_THIS?frag-resource=/fragments/pagelayout/images/space.gif/THIS_"/>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- </xsl:template>
- <!--
- calc layout ids
- -->
- <xsl:template match="layout" mode="compare-ids">
- <xsl:param name="id"/>
- <xsl:variable name="layout-id">
- <xsl:apply-templates select="." mode="id"/>
- </xsl:variable>
- <xsl:if test="$id = $layout-id">
- <xsl:value-of select="position() - 1"/>
- </xsl:if>
- </xsl:template>
- <xsl:template match="layout" mode="layout-ids">
- <xsl:text>"</xsl:text>
- <xsl:apply-templates select="." mode="id"/>
- <xsl:text>"</xsl:text>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
-
- <xsl:template match="layout" mode="id">
- <xsl:choose>
- <xsl:when test="row">
- <xsl:apply-templates select="row" mode="id"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="row-id"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="row" name="row-id" mode="id">
- <xsl:param name="level" select="0"/>
- <xsl:value-of select="concat('R', $level)"/>
- <xsl:apply-templates select="column" mode="id">
- <xsl:with-param name="level" select="$level"/>
- </xsl:apply-templates>
- </xsl:template>
-
- <xsl:template match="column" mode="id">
- <xsl:param name="level" select="0"/>
- <xsl:value-of select="concat('C', $level)"/>
- <xsl:apply-templates select="row" mode="id">
- <xsl:with-param name="level" select="$level + 1"/>
- </xsl:apply-templates>
- </xsl:template>
- <!--
- json serialization
- -->
- <xsl:template match="*" mode="json">
- <xsl:value-of select="concat(name(), ': { ')"/>
- <xsl:apply-templates select="@* | * | text()" mode="json"/>
- <xsl:text>}</xsl:text>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
- <xsl:template match="text()" mode="json">
- <xsl:value-of select="concat('"_text_": "', xtsext:javascriptencode(.), '"')"/>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
- <xsl:template match="@*" mode="json">
- <xsl:value-of select="concat('"', name(), '": "', xtsext:javascriptencode(.), '"')"/>
- <xsl:if test="position() != last()">,</xsl:if>
- <xsl:text> </xsl:text>
- </xsl:template>
-
- </xsl:stylesheet>
- </xts:block>
- </xts:morphlet>
|