]> err.no Git - sope/blob - sope-appserver/NGObjWeb/DynamicElements/WOxMiscElemBuilder.m
fixed bundle resource lookup on MacOSX, changed resource lookup in
[sope] / sope-appserver / NGObjWeb / DynamicElements / WOxMiscElemBuilder.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 // TODO: multiselection should set the "multiple" binding?
25
26 /*
27   This builder builds control flow elements, eg conditionals and
28   repetitions.
29   
30   Supported tags:
31     <var:string .../>              maps to WOString
32     <var:component-content/>       maps to WOComponentContent
33     <var:entity .../>              maps to WOEntity
34     <var:nbsp .../>                maps to WOEntity
35     <var:popup ../>                maps to WOPopUpButton
36     <var:singleselection ../>      maps to WOBrowser
37     <var:multiselection .../>      maps to WOBrowser
38     <var:radio-button-matrix .../> maps to WORadioButtonMatrix
39     <var:checkbox-list .../>       maps to WOCheckBoxList
40 */
41
42 @interface WOxMiscElemBuilder : WOxTagClassElemBuilder
43 {
44 }
45
46 @end
47
48 #include <SaxObjC/XMLNamespaces.h>
49 #include "common.h"
50
51 @implementation WOxMiscElemBuilder
52
53 - (Class)classForElement:(id<DOMElement>)_element {
54   NSString *nsuri;
55   NSString *tag;
56   unsigned tl;
57
58   if (_element == nil) return nil;
59   
60   nsuri = [_element namespaceURI];
61   if (![nsuri isEqualToString:XMLNS_OD_BIND])
62     return Nil;
63   
64   tag = [_element tagName];
65   tl  = [tag length];
66
67   if (tl < 5)
68     return Nil;
69   
70   switch ([tag characterAtIndex:0]) {
71     case 'c':
72       if ([tag isEqualToString:@"component-content"])
73         return NSClassFromString(@"WOComponentContent");
74       if ([tag isEqualToString:@"checkbox-list"])
75         return NSClassFromString(@"WOCheckBoxList");
76       break;
77       
78     case 'e':
79       if ([tag isEqualToString:@"entity"])
80         return NSClassFromString(@"WOEntity");
81       break;
82
83     case 'm':
84       if ([tag isEqualToString:@"multiselection"])
85         return NSClassFromString(@"WOBrowser");
86       break;
87       
88     case 'n':
89       if ([tag isEqualToString:@"nbsp"]) {
90         [self warnWithFormat:@"%s: found <var:nbsp/>, "
91                 @"use <var:entity name='nbsp'/> !",
92                 __PRETTY_FUNCTION__];
93         return NSClassFromString(@"WOEntity");
94       }
95       break;
96
97     case 'p':
98       if ([tag isEqualToString:@"popup"])
99         return NSClassFromString(@"WOPopUpButton");
100       break;
101
102     case 'r':
103       if ([tag isEqualToString:@"radio-button-matrix"])
104         return NSClassFromString(@"WORadioButtonMatrix");
105       break;
106       
107     case 's':
108       if ([tag isEqualToString:@"string"])
109         return NSClassFromString(@"WOString");
110       if ([tag isEqualToString:@"singleselection"])
111         return NSClassFromString(@"WOBrowser");
112       break;
113   }
114   return Nil;
115 }
116
117 @end /* SxMiscElemBuilder */