Code source wiki de ClassSheet

Modifié par Administrator le 2006/12/15 11:10

Afficher les derniers auteurs
1 #set( $class = $doc.name.substring(0,$doc.name.indexOf("Class")))
2 #set( $doc1new = $xwiki.getDocument("${doc.space}.${class}ClassSheet").isNew())
3 #set( $doc2new = $xwiki.getDocument("${doc.space}.${class}ClassTemplate").isNew())
4 #if (!$defaultweb)
5 #set($defaultweb = "Main")
6 #end
7 #if (!$defaultparent)
8 #set($defaultparent = "${doc.space}.${class}Class")
9 #end
10
11 1 Class: $doc.name
12
13 The first thing to do is to <a href="$doc.getURL("edit", "xpage=editclass")">Edit the Class</a> to add properties to it.
14
15 #if (!($doc1new||$doc2new))
16
17 1.1 Create a new document
18
19 To create a new document, you should first choose a name for you document
20
21 <form action="" id="newdoc" method="post">
22 <div>
23 <input type="hidden" name="parent" value="${defaultparent}"/>
24 <input type="hidden" name="template" value="${doc.space}.${class}ClassTemplate"/>
25 <input type="hidden" name="sheet" value="1"/>
26 Space: <input type="text" name="webname" value="${defaultweb}" size="8"/>
27 Document: <input type="text" name="name" value="Name of your document"/>
28 <br/>
29 <br/>
30 ## TODO: remove this onclick
31 <input type="button" value="Create this document" onclick='if (updateName(this.form.name)) {this.form.action="../../inline/" + this.form.webname.value + "/" + this.form.name.value; this.form.submit(); }'/>
32 </div>
33 </form>
34
35 1.1 Sheet and Template
36
37 #set($templatedoc = $xwiki.getDocument("${doc.space}.${class}ClassTemplate"))
38 #set($hasobj = $templatedoc.getObject("${doc.space}.${class}Class"))
39 #if(!$hasobj)
40 #set($xredirect = $request.getRequestURL())
41 #set($createUrl = $templatedoc.getURL("objectadd", "classname=${doc.space}.${class}Class&amp;xredirect=${xredirect}"))
42 #set($m = "The template does not have an object of class ${class}Class. <a href='$createUrl'>Click here to add it</a>.")
43 #warning($m)
44 #end
45
46 * Sheet: [${doc.space}.${class}ClassSheet]
47 * Template: [${doc.space}.${class}ClassTemplate]
48 * [View the sample code to show the document list and create new documents>XWiki.ClassSheet?xpage=code]
49
50 1.1 Existing documents
51
52 #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='${doc.space}.${class}Class' and obj.name<>'${doc.space}.${class}ClassTemplate'")
53 #foreach ($item in $xwiki.searchDocuments($sql))
54 * [$item]
55 #end
56 #else
57 1.1 Create templates and sheets
58
59 Before using this class you must first create the sheet and template for it. Follow the instructions below to do this.
60
61 #if ($doc1new)
62 <form action="$xwiki.getURL("${doc.space}.${class}ClassSheet","edit")" method="post">
63 <div>
64 <input type="hidden" name="parent" value="${doc.space}.${class}Class"/>
65 <input type="hidden" name="template" value="XWiki.ClassItemSheet"/>
66 <input type="hidden" name="sheet" value="1"/>
67 <input type="submit" value="Create the document sheet"/>
68 </div>
69 </form>
70 #else
71 The Sheet allows to control the presentation of documents using the class you define. You can use the default presentation which looks for all available fields and presents them in a table, or you can decide to write your own presentation showing only part of the fields. You can also decide to have a different presentation for the viewing and for the editing modes.
72 * [${class}ClassSheet]
73 #end
74
75 #if ($doc2new)
76 <form action="$xwiki.getURL("${doc.space}.${class}ClassTemplate","edit")" method="post">
77 <div>
78 <input type="hidden" name="parent" value="${doc.space}.${class}Class"/>
79 <input type="hidden" name="template" value="XWiki.ClassItemTemplate"/>
80 <input type="hidden" name="sheet" value="1"/>
81 <input type="submit" value="Create the document template"/>
82 </div>
83 </form>
84 #else
85 The template is the document that will be "copied" into the new document that you create. It will automatically contain a reference to the Sheet defined previously and an instance of the object of your Class.
86
87 You need to add the instance of your class manually using the "Edit Objects" link in the right menu and also modify the content of the template to reference update the class name. You should also customize the parent field which will be the default parent of all documents that are created using the class.
88 * [${class}ClassTemplate]
89 #end
90 #end
#getBlogDocument($space $blogDoc)