Ignore:
Timestamp:
2011-09-26T11:35:25+13:00 (13 years ago)
Author:
sjm84
Message:

Some major changes to document.xsl to make it easier to modify more specific parts to be modified in the collectionConfig.xml files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl

    r24473 r24650  
    5858        </xsl:choose>
    5959    </xsl:template>
     60   
     61    <!-- Used to make sure that regardless what the collection designer uses for the title and content we can wrap it properly -->
     62    <!-- If editing, be aware that the Document Basket looks for specific classes that this template bakes in (key points marked with ***) -->
     63    <xsl:template name="wrapDocumentNodes">
     64        <xsl:for-each select="documentNode">
     65            <a name="{@nodeID}"><xsl:text> </xsl:text></a>
     66            <!-- Section header -->
     67            <table class="sectionHeader"><tr>
     68           
     69                <!-- Expand/collapse button -->
     70                <td class="headerTD">
     71                    <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">         
     72                        <xsl:attribute name="src">
     73                            <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
     74                        </xsl:attribute>
     75                    </img>
     76                </td>
     77               
     78                <!-- Title -->
     79                <td id="header{@nodeID}" class="headerTD sectionTitle"><!-- *** -->
     80                    <!-- Get the title from the title sectionTitle template -->
     81                    <xsl:choose>
     82                        <xsl:when test="not(/page/pageRequest/paramList/param[@name = 'db']) or /page/pageRequest/paramList/param[@name = 'db']/@value = 'false'">
     83                            <xsl:apply-templates select="." mode="sectionTitleFormat"/>
     84                        </xsl:when>
     85                        <xsl:otherwise>
     86                            <xsl:apply-templates select="." mode="sectionTitle"/>
     87                        </xsl:otherwise>
     88                    </xsl:choose>
     89                </td>
     90               
     91                <!-- "back to top" link -->
     92                <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
     93                    <td class="backToTop headerTD">
     94                        <a href="#top">
     95                            <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
     96                        </a>
     97                    </td>
     98                </xsl:if>
     99            </tr></table>
     100           
     101            <div id="doc{@nodeID}" class="sectionContainer" style="display:block;"><!-- *** -->
     102                <div id="text{@nodeID}" class="sectionText"><!-- *** -->
     103                    <!-- Get the section content from the document template -->
     104                    <xsl:apply-templates select="." mode="document"/>
     105                </div>
     106                <xsl:if test="documentNode">
     107                    <xsl:call-template name="wrapDocumentNodes"/>
     108                </xsl:if>
     109            </div> 
     110        </xsl:for-each>
     111    </xsl:template>
    60112
    61113    <!-- the page content -->
     
    66118            <script type="text/javascript" src="interfaces/{$interface_name}/js/document_scripts.js"><xsl:text> </xsl:text></script>
    67119           
    68             <!-- Adds the realistic books javascript if necessary ( *** in document-scripts.xsl *** ) -->
    69120            <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
    70121                <script type="text/javascript">
     
    81132            <xsl:call-template name="documentBerryForDocumentPage"/>
    82133
    83             <table id="rightSidebar">
    84                 <tr><td>
    85                     <xsl:call-template name="viewOptions"/>
    86                 </td></tr>
    87                 <tr><td>
    88                     <!-- the sidebar -->
    89                     <div id="contentsArea">             
    90                         <!-- show the berry basket if it's turned on -->
    91                         <gslib:berryBasket/>
    92 
    93                         <!-- the book's cover image -->
    94                         <xsl:choose>
    95                             <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
    96                                 <div id="coverImage" class="visible"><gslib:coverImage/></div>
    97                             </xsl:when>
    98                             <xsl:otherwise>
    99                                 <div id="coverImage" class="hidden"><gslib:coverImage/></div>
    100                             </xsl:otherwise>   
    101                         </xsl:choose>
    102 
    103                         <!-- the contents (if enabled) -->
    104                         <xsl:choose>
    105                             <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
    106                                 <div id="tableOfContents" class="visible">
    107                                     <xsl:apply-templates select="documentNode" mode="TOC"/>
    108                                 </div>
    109                             </xsl:when>   
    110                             <xsl:otherwise>
    111                                 <div id="tableOfContents" class="hidden">
    112                                     <xsl:apply-templates select="documentNode" mode="TOC"/>
    113                                 </div>
    114                             </xsl:otherwise>   
    115                         </xsl:choose>
    116                     </div>
    117                 </td></tr>
    118             </table>
     134            <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']) or /page/pageResponse/format[@type='display']/gsf:option[@name='sideBar']/@value='true'">
     135                <table id="rightSidebar">
     136                    <tr><td>
     137                        <xsl:call-template name="viewOptions"/>
     138                    </td></tr>
     139                    <tr><td>
     140                        <div id="contentsArea">
     141
     142                            <!-- show the berry basket if it's turned on -->
     143                            <gslib:berryBasket/>
     144
     145                            <!-- the book's cover image -->
     146                            <xsl:choose>
     147                                <xsl:when test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']) or /page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
     148                                    <div id="coverImage" class="visible"><gslib:coverImage/></div>
     149                                </xsl:when>
     150                                <xsl:otherwise>
     151                                    <div id="coverImage" class="hidden"><gslib:coverImage/></div>
     152                                </xsl:otherwise>   
     153                            </xsl:choose>
     154
     155                            <!-- the contents (if enabled) -->
     156                            <xsl:choose>
     157                                <xsl:when test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
     158                                    <div id="tableOfContents" class="visible">
     159                                        <xsl:apply-templates select="documentNode" mode="TOC"/>
     160                                    </div>
     161                                </xsl:when>   
     162                                <xsl:otherwise>
     163                                    <div id="tableOfContents" class="hidden">
     164                                        <xsl:apply-templates select="documentNode" mode="TOC"/>
     165                                    </div>
     166                                </xsl:otherwise>   
     167                            </xsl:choose>
     168                        </div>
     169                    </td></tr>
     170                </table>
     171            </xsl:if>
    119172        </xsl:if>
    120173       
     
    143196            <xsl:otherwise>
    144197                <div id="gs-document-text" class="documenttext">
    145                     <xsl:apply-templates select="documentNode" mode="document"/>
     198                    <xsl:call-template name="wrapDocumentNodes"/>
    146199                </div> 
    147200            </xsl:otherwise>
     
    163216    </xsl:template>
    164217   
    165     <!-- This template is used to display the document content -->
     218    <xsl:template match="documentNode" mode="sectionTitleFormat">
     219        <p>
     220            <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
     221           
     222            <xsl:if test="util:hashToSectionId(@nodeID)">
     223                <span class="sectionNumberSpan">
     224                    <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
     225                    <xsl:text> </xsl:text>
     226                </span>
     227            </xsl:if>
     228            <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
     229            <span><xsl:apply-templates select="." mode="sectionTitle"/></span>
     230        </p>
     231    </xsl:template>
     232   
     233    <!-- The default template for displaying section titles -->
     234    <xsl:template match="documentNode" mode="sectionTitle">
     235        <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
     236    </xsl:template>
     237   
     238    <!-- The default template for displaying the document content -->
    166239    <xsl:template match="documentNode" mode="document">
    167         <a name="{@nodeID}"><xsl:text> </xsl:text></a>
    168         <!-- Section header -->
    169         <table class="sectionHeader"><tr>
    170             <!-- Expand/collapse button -->
    171             <td class="headerTD">
    172                 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">         
    173                     <xsl:attribute name="src">
    174                         <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
    175                     </xsl:attribute>
    176                 </img>
    177             </td>
    178            
    179             <!-- Automatic section number -->
    180             <td class="headerTD">
    181                 <p>
    182                     <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
    183                    
    184                     <xsl:if test="util:hashToSectionId(@nodeID)">
    185                         <span class="sectionNumberSpan">
    186                             <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
    187                             <xsl:text> </xsl:text>
    188                         </span>
    189                     </xsl:if>
    190                     <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
    191                     <span class="sectionTitle"><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/></span>
    192                 </p>
    193             </td>
    194            
    195             <!-- "back to top" link -->
    196             <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
    197                 <td class="backToTop headerTD">
    198                     <a href="#top">
    199                         <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
    200                     </a>
    201                 </td>
    202             </xsl:if>
    203         </tr></table>
    204        
    205240        <!-- Section text -->
    206         <div id="doc{@nodeID}" class="sectionContainer" style="display:block;">     
    207             <xsl:for-each select="nodeContent">
    208                 <xsl:for-each select="node()">
    209                     <xsl:choose>
    210                         <xsl:when test="not(name())">
    211                             <xsl:value-of select="." disable-output-escaping="yes"/>
    212                         </xsl:when>
    213                         <xsl:otherwise>
    214                             <xsl:apply-templates select="."/>
    215                         </xsl:otherwise>
    216                     </xsl:choose>
    217                 </xsl:for-each>
     241        <xsl:for-each select="nodeContent">
     242            <xsl:for-each select="node()">
     243                <xsl:choose>
     244                    <xsl:when test="not(name())">
     245                        <xsl:value-of select="." disable-output-escaping="yes"/>
     246                    </xsl:when>
     247                    <xsl:otherwise>
     248                        <xsl:apply-templates select="."/>
     249                    </xsl:otherwise>
     250                </xsl:choose>
    218251            </xsl:for-each>
    219             <xsl:if test="documentNode">
    220                 <xsl:apply-templates select="documentNode" mode="document"/>
    221             </xsl:if>
    222         </div> 
    223 
     252        </xsl:for-each><xsl:text> </xsl:text>
    224253    </xsl:template>
    225254
     
    283312                            <xsl:text> </xsl:text>
    284313                        </xsl:if>
    285                         <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
     314                        <xsl:apply-templates select="." mode="sectionTitle"/>
    286315                    </a>
    287316                </td>
     
    373402                </td>
    374403            </xsl:if>
     404            <td style="vertical-align:top;">
     405                <a id="sidebarMinimizeButton" href="javascript:minimizeSidebar();" style="float: right; font-size:0.6em;">
     406                    <img class="icon">
     407                        <xsl:attribute name="src">
     408                            <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
     409                        </xsl:attribute>
     410                    </img>
     411                </a>
     412                <a id="sidebarMaximizeButton" href="javascript:maximizeSidebar();" style="float: right; font-size:0.6em; display:none;">
     413                    <img class="icon">
     414                        <xsl:attribute name="src">
     415                            <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
     416                        </xsl:attribute>
     417                    </img>
     418                </a>
     419            </td>
    375420        </tr></table>   
    376421    </xsl:template>
Note: See TracChangeset for help on using the changeset viewer.