<commit_before><?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This 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 software 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.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<xwikidoc version="1.1">
  <web>XWiki</web>
  <name>ClassSheet</name>
  <language/>
  <defaultLanguage/>
  <translation>0</translation>
  <creator>xwiki:XWiki.Admin</creator>
  <creationDate>1375383737000</creationDate>
  <parent>XWiki.XWikiClasses</parent>
  <author>xwiki:XWiki.Admin</author>
  <contentAuthor>xwiki:XWiki.Admin</contentAuthor>
  <date>1375447727000</date>
  <contentUpdateDate>1375447727000</contentUpdateDate>
  <version>1.1</version>
  <title>#sheetTitle('Default Class Sheet')</title>
  <comment/>
  <minorEdit>false</minorEdit>
  <syntaxId>xwiki/2.0</syntaxId>
  <hidden>true</hidden>
  <content>{{velocity}}
## This document can be copied in order to be customized so we cannot rely on its name to determine if the currently
## displayed document is a class or the class sheet itself. We look for the sheet descriptor instead.
#set ($isSheet = $doc.getObject('XWiki.SheetDescriptorClass'))
#if ($isSheet)
  ## Viewing the sheet document itself.
  You can edit this document to change the default presentation of classes, or you can copy it to create a customized view just for one or several classes.
#elseif ("$!request.bindSheet" != '' &amp;&amp; $hasEdit)
  #if ($services.csrf.isTokenValid($request.getParameter('form_token')))
    ## Bind the sheet to the class.
    #set ($classSheetReference = $services.model.resolveDocument($request.bindSheet))
    #if ($services.sheet.bindClassSheet($doc, $classSheetReference))
      $doc.save('Bind class sheet.')
    #end
    $response.sendRedirect($request.xredirect)
  #else
    $response.sendRedirect($services.csrf.getResubmissionURL())
  #end
  ## Stop processing, since we already sent a redirect.
  #stop
#elseif("$!request.docName" != '')
  ## Request for creating a new instance. We don't actually create a new instance here, we just redirect to the edit mode.
  #set($targetDocName = "${request.spaceName}.${request.docName}")
  #if(!$xwiki.exists($targetDocName) &amp;&amp; $xwiki.hasAccessLevel('edit', $xcontext.user, $targetDocName))
    ## Compute the default edit mode to ensure backward compatibility with documents still using the deprecated inline action.
    #set($editAction = $xwiki.getDocument($request.template).getDefaultEditMode())
    $response.sendRedirect($xwiki.getURL($targetDocName, $editAction, "template=$!escapetool.url($request.template)&amp;parent=$!escapetool.url($request.parent)&amp;title=$!escapetool.url($request.docName)"))
    ## Stop processing, since we already sent a redirect.
    #stop
  #end
#end
{{/velocity}}

{{velocity}}
## If this sheet is explicitly bound to the displayed class then print the class document content before the
## sheet output. Class authors can put the description of the class in the class document content.
#set($classSheetReference = $services.model.createDocumentReference($doc.wiki, 'XWiki', 'ClassSheet'))
#if($services.sheet.getDocumentSheets($doc).contains($classSheetReference))
  {{include reference="" /}}
#end
{{/velocity}}

{{velocity}}
#if (!$isSheet)
  #set($className = $stringtool.removeEnd($doc.name, 'Class'))
  ## Determine the class sheets.
  #set($classSheetReferences = $services.sheet.getClassSheets($doc))
  #if ($classSheetReferences.isEmpty())
    ## There is no class sheet explicitly bound to this class. Fall-back on naming convention.
    ## Before XWiki 2.0, the default class sheet was suffixed with "ClassSheet". Since 2.0, the suffix is just "Sheet".
    #set($defaultClassSheetReference = $services.model.resolveDocument("${className}ClassSheet"))
    #if(!$xwiki.exists($defaultClassSheetReference))
      #set($defaultClassSheetReference = $services.model.resolveDocument("${className}Sheet"))
    #end
  #end
  ## Determine the template using naming convention.
  ## Before XWiki 2.0, the default class template was suffixed with "ClassTemplate". Since 2.0, the suffix is just "Template".
  #set($classTemplateReference = $services.model.resolveDocument("${className}ClassTemplate"))
  #if(!$xwiki.exists($classTemplateReference))
    #set($classTemplateReference = $services.model.resolveDocument("${className}Template"))
  #end
  #set($classTemplateDoc = $xwiki.getDocument($classTemplateReference))
  #set($hasClassSheets = !$classSheetReferences.isEmpty() || $xwiki.exists($defaultClassSheetReference))
  #set($hasClassTemplate = !$classTemplateDoc.isNew())
  #if(!$defaultSpace)
    #set($defaultSpace = 'Main')
  #end<commit_msg>Revert "XWIKI-12204: Add support for nested spaces in XWiki.ClassSheet."<commit_after><?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This 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 software 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.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<xwikidoc version="1.1">
  <web>XWiki</web>
  <name>ClassSheet</name>
  <language/>
  <defaultLanguage/>
  <translation>0</translation>
  <creator>xwiki:XWiki.Admin</creator>
  <creationDate>1375383737000</creationDate>
  <parent>XWiki.XWikiClasses</parent>
  <author>xwiki:XWiki.Admin</author>
  <contentAuthor>xwiki:XWiki.Admin</contentAuthor>
  <date>1375447727000</date>
  <contentUpdateDate>1375447727000</contentUpdateDate>
  <version>1.1</version>
  <title>#sheetTitle('Default Class Sheet')</title>
  <comment/>
  <minorEdit>false</minorEdit>
  <syntaxId>xwiki/2.0</syntaxId>
  <hidden>true</hidden>
  <content>{{velocity}}
## This document can be copied in order to be customized so we cannot rely on its name to determine if the currently
## displayed document is a class or the class sheet itself. We look for the sheet descriptor instead.
#set ($isSheet = $doc.getObject('XWiki.SheetDescriptorClass'))
#if ($isSheet)
  ## Viewing the sheet document itself.
  You can edit this document to change the default presentation of classes, or you can copy it to create a customized view just for one or several classes.
#elseif ("$!request.bindSheet" != '' &amp;&amp; $hasEdit)
  #if ($services.csrf.isTokenValid($request.getParameter('form_token')))
    ## Bind the sheet to the class.
    #set ($classSheetReference = $services.model.resolveDocument($request.bindSheet))
    #if ($services.sheet.bindClassSheet($doc, $classSheetReference))
      $doc.save('Bind class sheet.')
    #end
    $response.sendRedirect($request.xredirect)
  #else
    $response.sendRedirect($services.csrf.getResubmissionURL())
  #end
  ## Stop processing, since we already sent a redirect.
  #stop
#elseif("$!request.docName" != '')
  ## Request for creating a new instance. We don't actually create a new instance here, we just redirect to the edit mode.
  #set($targetDocName = "${request.spaceName}.${request.docName}")
  #if(!$xwiki.exists($targetDocName) &amp;&amp; $xwiki.hasAccessLevel('edit', $xcontext.user, $targetDocName))
    ## Compute the default edit mode to ensure backward compatibility with documents still using the deprecated inline action.
    #set($editAction = $xwiki.getDocument($request.template).getDefaultEditMode())
    $response.sendRedirect($xwiki.getURL($targetDocName, $editAction, "template=$!escapetool.url($request.template)&amp;parent=$!escapetool.url($request.parent)&amp;title=$!escapetool.url($request.docName)"))
    ## Stop processing, since we already sent a redirect.
    #stop
  #end
#end
{{/velocity}}

{{velocity}}
## If this sheet is explicitly bound to the displayed class then print the class document content before the
## sheet output. Class authors can put the description of the class in the class document content.
#set($classSheetReference = $services.model.createDocumentReference($doc.wiki, 'XWiki', 'ClassSheet'))
#if($services.sheet.getDocumentSheets($doc).contains($classSheetReference))
  {{include reference="" /}}
#end
{{/velocity}}

{{velocity}}
#if (!$isSheet)
  #set($className = $stringtool.removeEnd($doc.name, 'Class'))
  ## Determine the class sheets.
  #set($classSheetReferences = $services.sheet.getClassSheets($doc))
  #if ($classSheetReferences.isEmpty())
    ## There is no class sheet explicitly bound to this class. Fall-back on naming convention.
    ## Before XWiki 2.0, the default class sheet was suffixed with "ClassSheet". Since 2.0, the suffix is just "Sheet".
    #set($defaultClassSheetReference = $services.model.createDocumentReference($doc.wiki, $doc.space, "${className}ClassSheet"))
    #if(!$xwiki.exists($defaultClassSheetReference))
      #set($defaultClassSheetReference = $services.model.createDocumentReference($doc.wiki, $doc.space, "${className}Sheet"))
    #end
  #end
  ## Determine the template using naming convention.
  ## Before XWiki 2.0, the default class template was suffixed with "ClassTemplate". Since 2.0, the suffix is just "Template".
  #set($classTemplateReference = $services.model.createDocumentReference($doc.wiki, $doc.space, "${className}ClassTemplate"))
  #if(!$xwiki.exists($classTemplateReference))
    #set($classTemplateReference = $services.model.createDocumentReference($doc.wiki, $doc.space, "${className}Template"))
  #end
  #set($classTemplateDoc = $xwiki.getDocument($classTemplateReference))
  #set($hasClassSheets = !$classSheetReferences.isEmpty() || $xwiki.exists($defaultClassSheetReference))
  #set($hasClassTemplate = !$classTemplateDoc.isNew())
  #if(!$defaultSpace)
    #set($defaultSpace = 'Main')
  #end
{'fraction_non_alphanumeric': 0.12814645308924486, 'fraction_numerical': 0.013272311212814645, 'mean_word_length': 5.257731958762887, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 2, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1700696', 'n_tokens_mistral': 3234, 'n_tokens_neox': 3116, 'n_words': 965}