# -*- coding: utf-8 # Copyright 2006 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import FileField from Products.Archetypes.public import FileWidget from Products.Archetypes.public import OrderedBaseFolder, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME schema = BaseSchema class Presentation(OrderedBaseFolder): """ E-Portfolio Presentations""" meta_type = "Presentation" archetype_name = "Presentation" global_allow = 0 exclude_from_nav = True filter_content_types = True allowed_content_types = ('Sheet','Image') security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/presentation_view', 'permissions': ('View',), }, { 'id':'edit', 'name':'Edit', 'action':'string:${object_url}/presentation_edit', 'permissions': ('Manage Portal',), }, { 'id':'metadata', 'name':'Properties', 'action':'string:${object_url}/base_metadata', 'permissions': ('Access Denied',), }, ) def __init__(self, id): self.id = id self.largeIcon = "presentation.gif" self.background = "#FFFFFF" self.fontColor = "#000000" self.fontFace = "Arial" def getLargeIcon(self): """ returns large icon name """ return self.largeIcon def getLargeIconById(self, id): """ returns large icon name """ object = getattr(self, id) largeIcon = object.largeIcon if object.getLargeIcon(): if (object.getLargeIcon()=='drawer.gif' and object.meta_type!='Drawer'): if object.meta_type in ['Folder', 'ATFolder']: largeIcon = 'folder.gif' if object.meta_type in ['File', 'ATFile', 'ATImage']: if object.content_type in ['application/pdf']: largeIcon = 'pdffile.gif' elif object.content_type in ['text/html','text/xml','text/javascript','text/css']: largeIcon = 'htmlfile.gif' elif object.content_type in ['application/msword','text/rtf','text/richtext','application/rtf']: largeIcon = 'textfile.gif' elif object.content_type in ['application/vnd.ms-excel']: largeIcon = 'tablefile.gif' elif object.content_type in ['image/jpeg','image/png','image/gif','image/tiff','image/x-ms-bmp']: largeIcon = 'imagefile.gif' elif object.content_type in ['application/zip','application/x-tar']: largeIcon = 'zipfile.gif' return largeIcon def getStyle(self): """ returs background color """ style = 'background: '+str(self.background)+'; color: '+str(self.fontColor)+'; font-family: '+str(self.fontFace) return style def getTextStyle(self): """ returs text style color """ style = 'color: '+str(self.fontColor)+'; font-family: '+str(self.fontFace) return style def getBackground(self): """ returs background color """ return self.background def getFontColor(self): """ returs fontColor color """ return self.fontColor def getFontFace(self): """ returs fontFace color """ return self.fontFace def savePresentation(self,REQUEST): """ saves presentation """ self.background = REQUEST.get('background') self.fontColor = REQUEST.get('fontcolor') self.fontFace = REQUEST.get('fontface') self._p_changed = 1 ob=getattr(self,self.id) ob.setTitle(REQUEST.get('title')) ob.reindexObject() def getColors(self): """Colors""" symbols = ['00','33','66','99','CC','FF'] colors = [] for j in range(0, 6): for k in range(0, 6): colors.append('#'+symbols[0]+symbols[j]+symbols[k]) for k in range(0, 6): colors.append('#'+symbols[5]+symbols[j]+symbols[k]) return colors def getFonts(self): """Fonts""" fonts = ['Arial', 'Arial Black', 'Comic Sans MS', 'Courier', 'Georgia', 'Impact', 'Lucida Console', 'Palatino Linotype', 'Tahoma', 'Times New Roman', 'Verdana', 'MS Sans Serif'] return fonts def makeHTML(self, fullscreen): """make html for presentation""" HTML='' allSheets = self.getFolderContents() if not allSheets: return "You have no Sheets" id = 1 headers = 0 HTML = HTML + '\n' HTML = HTML + '\n' HTML = HTML + '\n' for sheet in allSheets: if id==1: style = "display:block" else: style = "display:none" if fullscreen: size = "height:100%; width:100%" else: size = "height:550px; width:100%" HTML = HTML + '