]> err.no Git - sope/blob - sope-appserver/WOExtensions/WOxExtElemBuilder.m
updated framework version
[sope] / sope-appserver / WOExtensions / WOxExtElemBuilder.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include <NGObjWeb/WOxElemBuilder.h>
23
24 /*
25   This builder builds various elements from the WOExtensions library.
26
27   All tags are mapped into the <var:> namespace (XMLNS_OD_BIND).
28
29   Supported tags:
30     <var:js-alert-panel     .../> maps to JSAlertPanel
31     <var:js-confirm-panel   .../> maps to JSConfirmPanel
32     <var:js-img-flyover     .../> maps to JSImageFlyover
33     <var:js-text-flyover    .../> maps to JSTextFlyover
34     <var:js-modal-window    .../> maps to JSModalWindow
35     <var:js-validated-field .../> maps to JSValidatedField
36
37     <var:threshold-colored-number .../> maps to WOThresholdColoredNumber
38
39     <var:collapsible .../>  maps to WOCollapsibleComponentContent
40     <var:checkbox-matrix../>maps to WOCheckBoxMatrix
41     <var:radio-matrix .../> maps to WORadioButtonMatrix
42     
43     <var:foreach-key .../>  maps to WODictionaryRepetition
44     <var:if-key      .../>  maps to WOKeyValueConditional
45
46     <var:tab-panel   .../>  maps to WOTabPanel
47
48     <var:table        .../> maps to WOTable
49     <var:table-header  ../> maps to WOTableHeader
50     <var:table-content ../> maps to WOTableContent
51     <var:table-ctx-key ../> maps to WOTableContextKey
52     
53     //JSKeyHandler : WODynamicElement
54 */
55
56 @interface WOxExtElemBuilder : WOxTagClassElemBuilder
57 {
58 }
59
60 @end
61
62 #include <SaxObjC/XMLNamespaces.h>
63 #include "common.h"
64
65 @implementation WOxExtElemBuilder
66
67 - (Class)classForElement:(id<DOMElement>)_element {
68   NSString *tagName;
69   unsigned tl;
70   unichar  c1;
71   
72   if (![[_element namespaceURI] isEqualToString:XMLNS_OD_BIND])
73     return Nil;
74   
75   tagName = [_element tagName];
76   if ((tl = [tagName length]) < 3)
77     return Nil;
78
79   c1 = [tagName characterAtIndex:0];
80   switch (c1) {
81     case 'c':
82       if (tl > 10) {
83         if ([tagName isEqualToString:@"collapsible"])
84           return NSClassFromString(@"WOCollapsibleComponentContent");
85         if ([tagName isEqualToString:@"checkbox-matrix"])
86           return NSClassFromString(@"WOCheckBoxMatrix");
87       }
88       break;
89
90     case 'f':
91       if (tl > 10) {
92         if ([tagName isEqualToString:@"foreach-key"])
93           return NSClassFromString(@"WODictionaryRepetition");
94       }
95       break;
96
97     case 'i':
98       if (tl == 6) {
99         if ([tagName isEqualToString:@"if-key"])
100           return NSClassFromString(@"WOKeyValueConditional");
101       }
102       break;
103       
104     case 'j':
105       if (tl > 13 && [tagName hasPrefix:@"js-"]) {
106         if ([tagName isEqualToString:@"js-alert-panel"])
107           return NSClassFromString(@"JSAlertPanel");
108         if ([tagName isEqualToString:@"js-confirm-panel"])
109           return NSClassFromString(@"JSConfirmPanel");
110         if ([tagName isEqualToString:@"js-img-flyover"])
111           return NSClassFromString(@"JSImageFlyover");
112         if ([tagName isEqualToString:@"js-text-flyover"])
113           return NSClassFromString(@"JSTextFlyover");
114         if ([tagName isEqualToString:@"js-modal-window"])
115           return NSClassFromString(@"JSModalWindow");
116         if ([tagName isEqualToString:@"js-validated-field"])
117           return NSClassFromString(@"JSValidatedField");
118       }
119       break;
120
121     case 'r':
122       if (tl > 10) {
123         if ([tagName isEqualToString:@"radio-matrix"])
124           return NSClassFromString(@"WORadioButtonMatrix");
125       }
126       break;
127
128     case 't':
129       if (tl > 20) {
130         if ([tagName isEqualToString:@"threshold-colored-number"])
131           return NSClassFromString(@"WOThresholdColoredNumber");
132       }
133       if (tl > 8) {
134         if ([tagName isEqualToString:@"tab-panel"])
135           return NSClassFromString(@"WOTabPanel");
136       }
137       if (tl > 4) {
138         if ([tagName hasPrefix:@"table"]) {
139           if (tl == 5)
140             return NSClassFromString(@"WOTable");
141           
142           if (tl > 11) {
143             if ([tagName isEqualToString:@"table-content"])
144               return NSClassFromString(@"WOTableContent");
145             if ([tagName isEqualToString:@"table-header"])
146               return NSClassFromString(@"WOTableHeader");
147             if ([tagName isEqualToString:@"table-ctx-key"])
148               return NSClassFromString(@"WOTableContextKey");
149           }
150         }
151       }
152       break;
153   }
154   return Nil;
155 }
156
157 @end /* WOxExtElemBuilder */