예제 #1
0
    def __init__(self, defaultMedia = None):
        Idevice.__init__(self, 
                         x_(u"MP3"), 
                         x_(u"Auckland University of Technology"), 
                         x_(u"The MP3 iDevice allows you to attach an MP3 " 
                            "media file to your content along with relevant textual"
                            "learning instructions."),
                         u"", 
                         u"")
        self.emphasis                    = Idevice.NoEmphasis
        self.group                       = Idevice.Media
        self.media                       = MultimediaField(
                                           x_(u"Choose an MP3 file"),
                                           x_(u""
            "<ol>"
            "  <li>Click &lt;Select an MP3&gt; and browse to the MP3 "
            "      file you wish to insert</li>"
            " <li>Click on the dropdown menu to select the position "
            "       that you want the file displayed on screen.</li>"
            "  <li>Enter an optional caption for your file.</li>"
            " <li>Associate any relevant text to the MP3 file.</li>"
            " <li>Choose the type of style you would like the iDevice to"
            "       display e.g. 'Some emphasis' "
            "applies a border and icon to the iDevice content displayed.</li>"
            "</ol>"
            ))
        self.media.idevice               = self
        self.text                        = TextAreaField(x_(u"Text"),
                                           x_("""Enter the text you wish to 
associate with the file."""))
        self.text.idevice                = self
        self.float                       = u"left"
        self.caption                     = u""
        self.icon                        = u"multimedia"
        self._captionInstruc             = x_(u"""Provide a caption for the 
MP3 file. This will appear in the players title bar as well.""")
       
        self._alignInstruc               = x_(u"""Alignment allows you to 
choose where on the screen the media player will be positioned.""")
        self.systemResources += ['xspf_player.swf']
    def process(self, request, status):
        """
        Process
        """

        log.debug("process " + repr(request.args))
        self.message = ""

        if status == "old":
            for element in self.elements:
                element.process(request)

            if "title" in request.args:
                self.idevice.title = unicode(request.args["title"][0], 'utf8')

            if "tip" in request.args:
                self.idevice.tip = unicode(request.args["tip"][0], 'utf8')

            if "emphasis" in request.args:
                self.idevice.emphasis = int(request.args["emphasis"][0])
                if self.idevice.emphasis == 0:
                    self.idevice.icon = ""

        if "addText" in request.args:
            field = TextField(_(u"Enter the label here"),
                              _(u"Enter instructions for completion here"))
            field.setIDevice(self.idevice)
            self.idevice.addField(field)
            self.idevice.edit = True

        if "addTextArea" in request.args:
            field = TextAreaField(
                _(u"Enter the label here"),
                _(u"Enter the instructions for completion here"))
            field.setIDevice(self.idevice)
            self.idevice.addField(field)
            self.idevice.edit = True

        if "addFeedback" in request.args:
            field = FeedbackField(
                _(u"Enter the label here"),
                _(u"""Feedback button will not appear if no 
data is entered into this field."""))
            field.setIDevice(self.idevice)
            self.idevice.addField(field)
            self.idevice.edit = True

        #if "addFlash" in request.args:
        #print "add a flash"
        #field = FlashField(_(u"Enter the label here"),
        #_(u"Enter the instructions for completion here"))
        #field.setIDevice(self.idevice)
        #self.idevice.addField(field)

        if "addMP3" in request.args:

            field = MultimediaField(
                _(u"Enter the label here"),
                _(u"Enter the instructions for completion here"))
            field.setIDevice(self.idevice)
            self.idevice.addField(field)
            if not 'xspf_player.swf' in self.idevice.systemResources:
                self.idevice.systemResources += ['xspf_player.swf']
            self.idevice.edit = True

        if "addAttachment" in request.args:

            field = AttachmentField(
                _(u"Enter the label here"),
                _(u"Enter the instructions for completion here"))
            field.setIDevice(self.idevice)
            self.idevice.addField(field)
            self.idevice.edit = True

        if ("action" in request.args
                and request.args["action"][0] == "selectIcon"):
            self.idevice.icon = request.args["object"][0]

        if "preview" in request.args:
            if self.idevice.title == "":
                self.message = _("Please enter<br />an idevice name.")
            else:
                self.idevice.edit = False

        if "edit" in request.args:
            self.idevice.edit = True

        if "cancel" in request.args:
            ideviceId = self.idevice.id
            self.idevice = self.originalIdevice.clone()
            self.idevice.id = ideviceId
            self.parent.showHide = False

        if ("action" in request.args
                and request.args["action"][0] == "changeStyle"):
            self.style = self.styles[int(request.args["object"][0])]

        self.__buildElements()