# -*- coding: utf-8
# Copyright 2006 by Meelis Mets
from Products.Archetypes.public import BaseSchema, Schema
from Products.Archetypes.public import BooleanField, ImageField, StringField, FileField
from Products.Archetypes.public import BooleanWidget, ImageWidget, StringWidget, SelectionWidget, FileWidget
from Products.Archetypes.public import BaseContent, registerType
from Globals import InitializeClass
from Products.CMFCore.utils import getToolByName
from AccessControl import ClassSecurityInfo, Unauthorized
from config import PROJECT_NAME
from BaseTest import BaseStimulus
schema = BaseStimulus.schema + Schema((
FileField('soundFile',
accessor = 'getSoundFile',
required = 1,
widget = FileWidget(
label = 'Sound file',
description = 'Upload sound file here',
label_mgsid = 'label_sound_file',
description_msgid = 'desc_sound_file',
i18n_domain = 'psyhvel',
visible = {'view':'invisible', 'edit':'visible'}
),
),
BooleanField('autoPlay',
accessor = 'getAutoPlay',
widget = BooleanWidget(
label = 'Play sound automatically',
description = 'If not checked sound will wait for clicking PLAY',
label_msgid="label_auto_play",
description_msgid="desc_auto_play",
i18n_domain="psyhvel",
visible = {'view': 'invisible', 'edit':'visible'},
),
),
))
class SoundStimulus(BaseStimulus):
""" Psyhvel sound stimulus"""
meta_type = "SoundStimulus"
archetype_name = "Sound Stimulus"
global_allow = 0
exclude_from_nav = True
filter_content_types = True
allowed_content_types = ()
security = ClassSecurityInfo()
schema = schema
actions = (
{
'id':'view',
'name':'View',
'action':'string:${object_url}/sound_stimulus',
'permissions': ('View',),
},
{
'id':'edit',
'name':'Configuration',
'action':'string:${object_url}/base_edit',
'permissions': ('Modify portal content',),
},
{
'id':'metadata',
'name':'Info',
'action':'string:${object_url}/base_metadata',
'permissions': ('Modify portal content',),
},
)
def getObjectsXML(self, files):
"""special xml"""
xml = self.getBaseXML()
snd = self.getField('soundFile')
fname = snd.getFilename(self)
soundfile = snd.getBaseUnit(self)
xml += '\n'
xml += '\n'
xml += '\n'
xml += '\n'
xml += ''
files.append({'filename':fname, 'file':str(soundfile)})
return [xml, files]
registerType(SoundStimulus, PROJECT_NAME)