<commit_before><!--
  Copyright (C) 2011 Orbeon, Inc.

  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU Lesser General Public License as published by the Free Software Foundation; either version
  2.1 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU Lesser General Public License for more details.

  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
  -->
<xsl:stylesheet
        version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xf="http://www.w3.org/2002/xforms"
        xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:xh="http://www.w3.org/1999/xhtml"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xbl="http://www.w3.org/ns/xbl"
        xmlns:frf="java:org.orbeon.oxf.fr.FormRunner"
        xmlns:d="DAV:">

    <xsl:variable name="view"           select="(/xh:html/xh:body/fr:view)[1]"       as="element(fr:view)?"/>
    <xsl:variable name="fluid"          select="$view/@fluid = 'true'"/>
    <xsl:variable name="body"           select="($view/fr:body, $view)[1]"           as="element()?"/>
    <xsl:variable name="custom-buttons" select="$view/fr:buttons"                    as="element()*"/>

    <!-- Template for the default layout of a form -->
    <xsl:variable name="default-page-template" as="element(*)*">
        <fr:navbar/>

        <fr:description/>

        <!-- Error summary (if at top) -->
        <xsl:if test="$error-summary-top">
            <fr:error-summary position="top"/>
        </xsl:if>

        <fr:row>
            <fr:toc/>
        </fr:row>
        <fr:row>
            <fr:body/>
        </fr:row>
        <fr:row>
            <fr:captcha/>
        </fr:row>

        <!-- Error summary (if at bottom) -->
        <!-- If we configuration tells us the bottom error summary should not be shown, still include it but hide it with 'display: none'.
             This is necessary because the persistence model relies on the error summary to know if the data is valid. -->
        <xh:div>
            <xsl:if test="not($error-summary-bottom)">
                <xsl:attribute name="class">xforms-hidden</xsl:attribute>
            </xsl:if>
            <fr:error-summary position="bottom"/>
        </xh:div>

        <fr:row>
            <fr:noscript-help/>
        </fr:row>
        <fr:row>
            <fr:messages/>
        </fr:row>
        <fr:row>
            <fr:buttons-bar/>
        </fr:row>
        <fr:row>
            <fr:version/>
        </fr:row>
    </xsl:variable>

    <xsl:template match="fr:row">
        <xh:div class="row{if ($fluid) then '-fluid' else ''}">
            <xh:div class="span12">
                <xsl:apply-templates select="@* | node()"/>
            </xh:div>
        </xh:div>
    </xsl:template>

    <xsl:template match="fr:body">

        <xf:var name="persistence-instance"    value="xxf:instance('fr-persistence-instance')"/>
        <xf:var name="lease-enabled"           value="$persistence-instance/lease-enabled = 'true'"/>
        <xf:var name="lease-state-elem"        value="$persistence-instance/lease-state"/>
        <xf:var name="show-lease-current-user" value="    $lease-enabled  and $lease-state-elem = 'current-user'"/>
        <xf:var name="show-lease-other-user"   value="    $lease-enabled  and $lease-state-elem = 'other-user'"/>
        <xf:var name="show-lease-relinquished" value="    $lease-enabled  and $lease-state-elem = 'relinquished'"/>
        <xf:var name="show-form-data"          value="not($lease-enabled) or  $lease-state-elem = 'current-user'"/>

        <xf:group
            ref="if ($lease-enabled) then . else ()"
            class="alert alert-info fr-lease"
            xxf:element="div"
        >
            <xh:i class="fa fa-lock" aria-hidden="true"/>

            <xh:div class="fr-lease-message">
                <xf:switch caseref="$lease-state-elem">
                    <xf:case value="'current-user'">
                        <xh:div>
                            You own a lease on this document for another
                            <fr:countdown ref="$persistence-instance/lease-end-time">
                                <xf:setvalue
                                    event="fr-countdown-ended"
                                    ref="$lease-state-elem"
                                    value="'relinquished'"/>
                            </fr:countdown>.
                        </xh:div>
                    </xf:case>
                    <xf:case value="'relinquished'">
                        You don't own a lease on this document anymore.
                    </xf:case>
                    <xf:case value="'other-user'">
                        Another user, with username
                        <xf:output value="xxf:instance('fr-lockinfo-response')/d:owner/fr:username"/>,
                        currently owns the lease on this document.
                    </xf:case>
                </xf:switch>
            </xh:div>

            <xh:div class="fr-lease-buttons">
                <xf:switch caseref="
                        if ($lease-state-elem = 'current-user')
                        then 'has-lease'
                        else 'does-not-have-lease'">
                    <xf:case value="'has-lease'">
                        <xf:trigger>
                            <xf:label>Relinquish lease</xf:label>
                            <xf:action event="DOMActivate">
                                <xf:send submission="fr-relinquish-lease-submission"/>
                                <xf:setvalue ref="$lease-state-elem">relinquished</xf:setvalue>
                            </xf:action>
                            <xf:send event="DOMActivate" submission="fr-relinquish-lease-submission"/>
                        </xf:trigger>
                        <xf:trigger>
                            <xf:label>Renew lease</xf:label><commit_msg>For #1067: (minor) improve wording<commit_after><!--
  Copyright (C) 2011 Orbeon, Inc.

  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU Lesser General Public License as published by the Free Software Foundation; either version
  2.1 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU Lesser General Public License for more details.

  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
  -->
<xsl:stylesheet
        version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xf="http://www.w3.org/2002/xforms"
        xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:xh="http://www.w3.org/1999/xhtml"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xbl="http://www.w3.org/ns/xbl"
        xmlns:frf="java:org.orbeon.oxf.fr.FormRunner"
        xmlns:d="DAV:">

    <xsl:variable name="view"           select="(/xh:html/xh:body/fr:view)[1]"       as="element(fr:view)?"/>
    <xsl:variable name="fluid"          select="$view/@fluid = 'true'"/>
    <xsl:variable name="body"           select="($view/fr:body, $view)[1]"           as="element()?"/>
    <xsl:variable name="custom-buttons" select="$view/fr:buttons"                    as="element()*"/>

    <!-- Template for the default layout of a form -->
    <xsl:variable name="default-page-template" as="element(*)*">
        <fr:navbar/>

        <fr:description/>

        <!-- Error summary (if at top) -->
        <xsl:if test="$error-summary-top">
            <fr:error-summary position="top"/>
        </xsl:if>

        <fr:row>
            <fr:toc/>
        </fr:row>
        <fr:row>
            <fr:body/>
        </fr:row>
        <fr:row>
            <fr:captcha/>
        </fr:row>

        <!-- Error summary (if at bottom) -->
        <!-- If we configuration tells us the bottom error summary should not be shown, still include it but hide it with 'display: none'.
             This is necessary because the persistence model relies on the error summary to know if the data is valid. -->
        <xh:div>
            <xsl:if test="not($error-summary-bottom)">
                <xsl:attribute name="class">xforms-hidden</xsl:attribute>
            </xsl:if>
            <fr:error-summary position="bottom"/>
        </xh:div>

        <fr:row>
            <fr:noscript-help/>
        </fr:row>
        <fr:row>
            <fr:messages/>
        </fr:row>
        <fr:row>
            <fr:buttons-bar/>
        </fr:row>
        <fr:row>
            <fr:version/>
        </fr:row>
    </xsl:variable>

    <xsl:template match="fr:row">
        <xh:div class="row{if ($fluid) then '-fluid' else ''}">
            <xh:div class="span12">
                <xsl:apply-templates select="@* | node()"/>
            </xh:div>
        </xh:div>
    </xsl:template>

    <xsl:template match="fr:body">

        <xf:var name="persistence-instance"    value="xxf:instance('fr-persistence-instance')"/>
        <xf:var name="lease-enabled"           value="$persistence-instance/lease-enabled = 'true'"/>
        <xf:var name="lease-state-elem"        value="$persistence-instance/lease-state"/>
        <xf:var name="show-lease-current-user" value="    $lease-enabled  and $lease-state-elem = 'current-user'"/>
        <xf:var name="show-lease-other-user"   value="    $lease-enabled  and $lease-state-elem = 'other-user'"/>
        <xf:var name="show-lease-relinquished" value="    $lease-enabled  and $lease-state-elem = 'relinquished'"/>
        <xf:var name="show-form-data"          value="not($lease-enabled) or  $lease-state-elem = 'current-user'"/>

        <xf:group
            ref="if ($lease-enabled) then . else ()"
            class="alert alert-info fr-lease"
            xxf:element="div"
        >
            <xh:i class="fa fa-lock" aria-hidden="true"/>

            <xh:div class="fr-lease-message">
                <xf:switch caseref="$lease-state-elem">
                    <xf:case value="'current-user'">
                        <xh:div>
                            You own a lease on this document for another
                            <fr:countdown ref="$persistence-instance/lease-end-time">
                                <xf:setvalue
                                    event="fr-countdown-ended"
                                    ref="$lease-state-elem"
                                    value="'relinquished'"/>
                            </fr:countdown>.
                        </xh:div>
                    </xf:case>
                    <xf:case value="'relinquished'">
                        You don't own a lease on this document anymore.
                    </xf:case>
                    <xf:case value="'other-user'">
                        Another user, with username
                        "<xf:output value="xxf:instance('fr-lockinfo-response')/d:owner/fr:username"/>",
                        currently owns a lease on this document.
                    </xf:case>
                </xf:switch>
            </xh:div>

            <xh:div class="fr-lease-buttons">
                <xf:switch caseref="
                        if ($lease-state-elem = 'current-user')
                        then 'has-lease'
                        else 'does-not-have-lease'">
                    <xf:case value="'has-lease'">
                        <xf:trigger>
                            <xf:label>Relinquish lease</xf:label>
                            <xf:action event="DOMActivate">
                                <xf:send submission="fr-relinquish-lease-submission"/>
                                <xf:setvalue ref="$lease-state-elem">relinquished</xf:setvalue>
                            </xf:action>
                            <xf:send event="DOMActivate" submission="fr-relinquish-lease-submission"/>
                        </xf:trigger>
                        <xf:trigger>
                            <xf:label>Renew lease</xf:label>
{'fraction_non_alphanumeric': 0.14671150387111911, 'fraction_numerical': 0.007038398373347931, 'mean_word_length': 1.652561709188965, 'pattern_counts': {'":': 0, '<': 191, '<?xml version=': 0, '>': 191, 'https://': 0, 'lorem ipsum': 0, 'www.': 16, 'xml': 32}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6271016', 'n_tokens_mistral': 3883, 'n_tokens_neox': 3627, 'n_words': 765}