1 package org.paneris.melati.site.model;
2
3 import java.util.Enumeration;
4 import java.util.Vector;
5
6 import org.melati.Melati;
7 import org.melati.admin.AdminSpecialised;
8 import org.melati.poem.CachedSelection;
9 import org.melati.poem.util.ArrayUtils;
10 import org.melati.poem.util.EmptyEnumeration;
11 import org.melati.template.MarkupLanguage;
12 import org.melati.util.StringUtils;
13 import org.melati.poem.Treeable;
14 import org.paneris.melati.site.model.generated.PageBase;
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public class Page extends PageBase implements AdminSpecialised, Treeable,
60 Templated {
61
62
63
64
65
66
67 public Page() {
68 }
69
70
71
72
73
74
75 public SiteDatabaseTables getSiteDatabase() {
76 return (SiteDatabaseTables) getDatabase();
77 }
78
79
80
81
82
83
84
85
86
87
88
89 public Enumeration getAncestors() {
90 Vector v = new Vector();
91 Page p = getParent();
92 while (p != null) {
93 v.addElement(p);
94 p = p.getParent();
95 }
96 Vector reversed = new Vector();
97 for (Enumeration e = v.elements(); e.hasMoreElements();) {
98 reversed.insertElementAt(e.nextElement(), 0);
99 }
100 return reversed.elements();
101 }
102
103
104
105
106 public String getRelativeDisplayUrlById() {
107 return "Display/page/" + troid() + ".html";
108 }
109
110
111
112
113 public String getRelativeDisplayUrlByContent() {
114 return getUrlName() + ".html";
115 }
116
117
118
119 public String getUrlName() {
120 return StringUtils.tr(getDisplayname(), ' ', '_');
121 }
122
123
124
125 public String getJavaName() {
126 return StringUtils.tr(getUrlName(), '-', '_');
127 }
128
129
130
131
132
133
134 public String getXmlId() {
135 return StringUtils.tr(toString(), '/', '.');
136 }
137
138 private CachedSelection divs = null;
139
140
141
142
143 public Enumeration getDivs() {
144 if (getTroid() == null)
145 return EmptyEnumeration.it;
146 else {
147 if (divs == null)
148 divs = getSiteDatabase().getDivTable().getPageColumn()
149 .cachedSelectionWhereEq(getTroid());
150 return divs.objects();
151 }
152 }
153
154
155
156
157
158 public Treeable[] getChildren() {
159 Treeable[] children = null;
160 Object[] kids = ArrayUtils.arrayOf(getPageTable().getParentColumn()
161 .referencesTo(this));
162 int j = 0;
163 for (int i = 0; i < kids.length; i++) {
164 if (((Page) kids[i]).getDisplay().booleanValue()) {
165 j++;
166 }
167 }
168 children = new Treeable[j];
169 int k = 0;
170 for (int i = 0; i < kids.length; i++) {
171 if (((Page) kids[i]).getDisplay().booleanValue()) {
172 children[k] = (Treeable) kids[i];
173 k++;
174 }
175 }
176 return children;
177 }
178
179 public String adminHandle(Melati melati, MarkupLanguage markupLanguage)
180 throws Exception {
181 return null;
182 }
183
184 public String adminSpecialFacilities(Melati melati,
185 MarkupLanguage markupLanguage) throws Exception {
186 return "org/paneris/melati/site/model/Page.adminSpecial.wm";
187 }
188
189
190 }