autorisation des tags form, input et textarea.
[Plinn.git] / __init__.py
1 # -*- coding: utf-8 -*-
2 #######################################################################################
3 # Plinn - http://plinn.org #
4 # Copyright (C) 2005-2007 Benoît PIN <benoit.pin@ensmp.fr> #
5 # #
6 # This program is free software; you can redistribute it and/or #
7 # modify it under the terms of the GNU General Public License #
8 # as published by the Free Software Foundation; either version 2 #
9 # of the License, or (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program; if not, write to the Free Software #
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
19 #######################################################################################
20 """ Plinn implementation of CMFCore.
21
22
23
24 """
25
26 import exceptions
27
28 from Products.CMFCore import utils as core_cmf_utils
29 from Products.CMFDefault import utils as default_cmf_utils
30 from Products.CMFCore.permissions import AddPortalContent
31 from Products.CMFCore.FSFile import FSFile
32 from Products.CMFCore.DirectoryView import registerFileExtension
33 import File, Folder, HugePlinnFolder, Topic
34 import MembershipTool
35 import MemberDataTool
36 import GroupsTool
37 import GroupDataTool
38 import RegistrationTool
39 import CalendarTool
40 import AttachmentTool
41 try :
42 import catalog
43 __solr_ok = True
44 except ImportError :
45 __solr_ok = False
46
47 from PloneMisc import IndexIterator, Batch
48 import patch
49
50 from AccessControl import allow_module, allow_class
51
52
53 contentClasses = (File.File, Folder.PlinnFolder, HugePlinnFolder.HugePlinnFolder, Topic.Topic )
54
55 contentConstructors = (File.addFile, Folder.manage_addPlinnFolder, HugePlinnFolder.manage_addHugePlinnFolder, Topic.addTopic)
56
57 tools = ( MembershipTool.MembershipTool
58 , MemberDataTool.MemberDataTool
59 , GroupsTool.GroupsTool
60 , GroupDataTool.GroupDataTool
61 , RegistrationTool.RegistrationTool
62 , CalendarTool.CalendarTool
63 , AttachmentTool.AttachmentTool
64 )
65 if __solr_ok :
66 tools += (catalog.CatalogTool,)
67
68 # register files extensions
69 registerFileExtension('ttf', FSFile)
70 registerFileExtension('eot', FSFile)
71 registerFileExtension('cur', FSFile)
72
73 def initialize(registrar) :
74
75 allow_module('quopri')
76 allow_module('Products.Plinn.PloneMisc')
77 allow_class(IndexIterator)
78 allow_class(Batch)
79
80 core_cmf_utils.ContentInit(
81 'Plinn',
82 content_types = contentClasses,
83 permission = AddPortalContent,
84 extra_constructors = contentConstructors,
85 ).initialize(registrar)
86
87 core_cmf_utils.ToolInit('Plinn Tool',
88 tools = tools,
89 icon = 'tool.gif'
90 ).initialize(registrar)
91
92
93
94
95 # Monkey...
96 # all tags are good !
97 validTags = default_cmf_utils.NASTY_TAGS.copy()
98 for tag in validTags.keys() :
99 validTags[tag] = 1
100
101 VALID_TAGS = {'font': 1,
102 'param' : 1,
103 'iframe' : 1,
104 'form' : 1,
105 'input' : 1,
106 'textarea' : 1}
107
108 validTags.update(VALID_TAGS)
109
110 default_cmf_utils.NASTY_TAGS = {}
111 default_cmf_utils.VALID_TAGS.update(validTags)
112
113 # the plinn portal_calendar is a also a "SPECIAL PROVIDER"
114 # TODO: vérifier l'impact
115 # import Products.CMFCore.exportimport.actions
116 # Products.CMFCore.exportimport.actions._SPECIAL_PROVIDERS += ('portal_calendar',)
117
118
119 # monkey-patch de getIcon qui est foirasse dans CMF2.2 :
120 # les icônes ne s'affichent pas correctement dans la ZMI
121 # lorqu'on y accède par un virtual host apache.
122 from urllib import quote
123 from Products.CMFCore.utils import getToolByName
124
125 def getIcon(self, relative_to_portal=0):
126 """
127 Using this method allows the content class
128 creator to grab icons on the fly instead of using a fixed
129 attribute on the class.
130 """
131 ti = self.getTypeInfo()
132 if ti is not None:
133 icon = quote(ti.getIcon())
134 if icon:
135 if relative_to_portal:
136 return icon
137 else:
138 # Relative to REQUEST['BASEPATH1']
139 portal_url = getToolByName( self, 'portal_url' )
140 res = portal_url(relative=1) + '/' + icon
141 while res[:1] == '/':
142 res = res[1:]
143 return res
144 return 'misc_/OFSP/dtmldoc.gif'
145
146 icon = getIcon # For the ZMI
147
148 from Products.CMFCore.DynamicType import DynamicType
149 DynamicType.getIcon = getIcon
150 DynamicType.icon = getIcon