X-Git-Url: https://scm.cri.ensmp.fr/git/MosaicDocument.git/blobdiff_plain/155c6ba3d7e8e9693d30b3cf70f591f0153610b6:/ImageSlot.py..99b3ba92670e19c1f86f5de83b8e6bbe4fdc297f:/Products/MosaicDocument/static/gitweb.css diff --git a/ImageSlot.py b/ImageSlot.py deleted file mode 100755 index d9616cc..0000000 --- a/ImageSlot.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- -# (c) 2003 Centre de Recherche en Informatique ENSMP Fontainebleau -# (c) 2003 Benoît PIN -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. -# - -from OFS.Image import cookId -from Globals import InitializeClass - -from Products.CMFCore.permissions import View, ModifyPortalContent -from AccessControl import ClassSecurityInfo -from Products.Photo import Photo -from BaseSlot import BaseSlot - -factory_type_information = ( {'id' : 'Image Slot', - 'meta_type' : 'Image Slot', - 'description' : "Image Slot for Mosaic Document", - 'icon' : 'mosaic_tool/photo_icon.gif', - 'product' : 'MosaicDocument', - 'factory' : 'addImageSlot', - 'immediate_view' : 'view', - 'actions' : - ({'id' : 'view', - 'name' : 'View', - 'action' : 'slot_image_view', - 'permissions' : (View, ) - }, - - {'id' : 'edit', - 'name' : 'Edit', - 'action' : 'slot_image_form', - 'permissions' : (ModifyPortalContent, ) - }, - ) - }, - ) - -class ImageSlot(BaseSlot, Photo) : - """Slot""" - meta_type = 'Image Slot' - manage_options = Photo.manage_options - - _indexableFields = ('title',) - - security = ClassSecurityInfo() - - - def __init__(self, parentContainer, id, title='', file='', - content_type='', precondition='', blankThumbnail = '', **kw) : - blankThumbnailOb = None - if blankThumbnail : - blankThumbnailOb = parentContainer.restrictedTraverse(blankThumbnail) - Photo.__init__(self, id, title=title, file=file, - defaultBlankThumbnail = blankThumbnailOb, **kw) - - - # This method is overloaded to manage file upload. - # It's necessary to use manage_upload method from image - # because manage_upload invoke update_data and the overload of - # update_data in Photo product update the internal thumbnail image. - security.declareProtected(ModifyPortalContent, 'edit') - def edit(self, title='', thumb_width='440', thumb_height='440', file='', REQUEST=None): - """ Edit image slot""" - if file : - self.manage_upload(file=file) - - if self.thumb_height != thumb_height or thumb_width != thumb_width : - if thumb_width <= thumb_height : - self.manage_editProperties(thumb_width=thumb_width, thumb_height=thumb_height) - else : - self.manage_editProperties(thumb_width=thumb_height, thumb_height=thumb_width) - if title : - self.manage_editProperties(title = title, no_refresh = 1) - - view = index_html = __call__ = Photo.index_html - -InitializeClass(ImageSlot) - -def addImageSlot(dispatcher, id, file='', title='', - precondition='', content_type='', REQUEST=None, **kw) : - """ - Add a new Photo object. - Creates a new Photo object 'id' with the contents of 'file'. - """ - id=str(id) - title=str(title) - content_type=str(content_type) - precondition=str(precondition) - - id, title = cookId(id, title, file) - parentContainer = dispatcher.Destination() - - # First, we create the image without data: - parentContainer._setObject(id, ImageSlot(parentContainer, id,title,'',content_type, precondition, **kw)) - - # Now we "upload" the data. By doing this in two steps, we - # can use a database trick to make the upload more efficient. - if file: - parentContainer._getOb(id).manage_upload(file) - if content_type: - parentContainer._getOb(id).content_type=content_type - - if REQUEST is not None: - try: url=dispatcher.DestinationURL() - except: url=REQUEST['URL1'] - REQUEST.RESPONSE.redirect('%s/manage_main' % url) - return id