1 # -*- coding: utf-8 -*-
2 #######################################################################################
3 # Plinn - http://plinn.org #
4 # Copyright (C) 2005-2007 Benoît PIN <benoit.pin@ensmp.fr> #
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. #
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. #
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.
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
38 import RegistrationTool
43 from PloneMisc
import IndexIterator
, Batch
46 from AccessControl
import allow_module
, allow_class
49 contentClasses
= (File
.File
, Folder
.PlinnFolder
, HugePlinnFolder
.HugePlinnFolder
, Topic
.Topic
)
51 contentConstructors
= (File
.addFile
, Folder
.manage_addPlinnFolder
, HugePlinnFolder
.manage_addHugePlinnFolder
, Topic
.addTopic
)
53 tools
= ( MembershipTool
.MembershipTool
54 , MemberDataTool
.MemberDataTool
55 , GroupsTool
.GroupsTool
56 , GroupDataTool
.GroupDataTool
57 , RegistrationTool
.RegistrationTool
58 , CalendarTool
.CalendarTool
59 , AttachmentTool
.AttachmentTool
63 # register files extensions
64 registerFileExtension('ttf', FSFile
)
65 registerFileExtension('eot', FSFile
)
66 registerFileExtension('cur', FSFile
)
68 def initialize(registrar
) :
70 allow_module('quopri')
71 allow_module('Products.Plinn.PloneMisc')
72 allow_class(IndexIterator
)
75 core_cmf_utils
.ContentInit(
77 content_types
= contentClasses
,
78 permission
= AddPortalContent
,
79 extra_constructors
= contentConstructors
,
80 ).initialize(registrar
)
82 core_cmf_utils
.ToolInit('Plinn Tool',
85 ).initialize(registrar
)
92 validTags
= default_cmf_utils
.NASTY_TAGS
.copy()
93 for tag
in validTags
.keys() :
96 VALID_TAGS
= {'font': 1, 'param' : 1, 'iframe' : 1}
98 validTags
.update(VALID_TAGS
)
100 default_cmf_utils
.NASTY_TAGS
= {}
101 default_cmf_utils
.VALID_TAGS
.update(validTags
)
103 # the plinn portal_calendar is a also a "SPECIAL PROVIDER"
104 # TODO: vérifier l'impact
105 # import Products.CMFCore.exportimport.actions
106 # Products.CMFCore.exportimport.actions._SPECIAL_PROVIDERS += ('portal_calendar',)
109 # monkey-patch de getIcon qui est foirasse dans CMF2.2 :
110 # les icônes ne s'affichent pas correctement dans la ZMI
111 # lorqu'on y accède par un virtual host apache.
112 from urllib
import quote
113 from Products
.CMFCore
.utils
import getToolByName
115 def getIcon(self
, relative_to_portal
=0):
117 Using this method allows the content class
118 creator to grab icons on the fly instead of using a fixed
119 attribute on the class.
121 ti
= self
.getTypeInfo()
123 icon
= quote(ti
.getIcon())
125 if relative_to_portal
:
128 # Relative to REQUEST['BASEPATH1']
129 portal_url
= getToolByName( self
, 'portal_url' )
130 res
= portal_url(relative
=1) + '/' + icon
131 while res
[:1] == '/':
134 return 'misc_/OFSP/dtmldoc.gif'
136 icon
= getIcon
# For the ZMI
138 from Products
.CMFCore
.DynamicType
import DynamicType
139 DynamicType
.getIcon
= getIcon
140 DynamicType
.icon
= getIcon