Пример #1
0
    def upgradeToVersion1(self):
        """
        Called to upgrade from 0.3 release
        """
        self._nextNodeId = 0
        self._nodeIdDict = {}
        draft = getattr(self, "draft")
        draft._id = self._regNewNode(draft)
        draft._package = self
        setattr(self, "editor", Node(self, None, _(u"iDevice Editor")))
        idevice = GenericIdevice("", "", "", "", "")
        editor = getattr(self, "editor")
        idevice.parentNode = editor
        editor.addIdevice(idevice)

        def superReg(node):
            """Registers all our nodes
            because in v0 they were not registered
            in this way"""
            node._id = self._regNewNode(node)
            node._package = self
            for child in node.children:
                superReg(child)

        superReg(self.root)
    def upgradeToVersion1(self):
        """
        Called to upgrade from 0.3 release
        """
        self._nextNodeId = 0
        self._nodeIdDict = {}

        # Also upgrade all the nodes.
        # This needs to be done here so that draft gets id 0
        # If it's done in the nodes, the ids are assigned in reverse order
        draft = getattr(self, 'draft')
        draft._id = self._regNewNode(draft)
        draft._package = self
        setattr(self, 'editor', Node(self, None, _(u"iDevice Editor")))

        # Add a default idevice to the editor
        idevice = GenericIdevice("", "", "", "", "")
        editor = getattr(self, 'editor')
        idevice.parentNode = editor
        editor.addIdevice(idevice)
        def superReg(node):
            """Registers all our nodes
            because in v0 they were not registered
            in this way"""
            node._id = self._regNewNode(node)
            node._package = self
            for child in node.children:
                superReg(child)
        superReg(self.root)
    def upgradeToVersion1(self):
        """
        Called to upgrade from 0.3 release
        """
        self._nextNodeId = 0
        self._nodeIdDict = {}

        # Also upgrade all the nodes.
        # This needs to be done here so that draft gets id 0
        # If it's done in the nodes, the ids are assigned in reverse order
        draft = getattr(self, "draft")
        draft._id = self._regNewNode(draft)
        draft._package = self
        setattr(self, "editor", Node(self, None, _(u"iDevice Editor")))

        # Add a default idevice to the editor
        idevice = GenericIdevice("", "", "", "", "")
        editor = getattr(self, "editor")
        idevice.parentNode = editor
        editor.addIdevice(idevice)

        def superReg(node):
            """Registers all our nodes
            because in v0 they were not registered
            in this way"""
            node._id = self._regNewNode(node)
            node._package = self
            for child in node.children:
                superReg(child)

        superReg(self.root)
Пример #4
0
 def __createNewIdevice(self, request):
     """
     Create a new idevice and add to idevicestore
     """
     idevice = GenericIdevice("", "", "", "", "")
     idevice.icon = ""
     idevice.id = self.ideviceStore.getNewIdeviceId()
     self.editorPane.setIdevice(idevice)
     self.editorPane.process(request, "new")
     self.isNewIdevice = True
Пример #5
0
 def __createNewIdevice(self, request):
     """
     Create a new idevice and add to idevicestore
     """
     idevice = GenericIdevice("", "", "", "", "")
     idevice.icon = ""
     idevice.id = self.ideviceStore.getNewIdeviceId()
     self.editorPane.setIdevice(idevice)
     self.editorPane.process(request, "new")      
     self.isNewIdevice = True
Пример #6
0
 def __init__(self, webServer):
     """
     Initialize
     """
     self.ideviceStore = webServer.application.ideviceStore
     self.webDir = webServer.application.config.webDir
     self.styles = webServer.application.config.styles
     self.elements = []
     self.idevice = GenericIdevice("", "", "", "", "")
     self.idevice.id = self.ideviceStore.getNewIdeviceId()
     self.originalIdevice = GenericIdevice("", "", "", "", "")
     self.purpose = ""
     self.tip = ""
     self.message = ""
     self._nameInstruc = x_(
         u"Your new iDevice will appear in the iDevice "
         u"pane with this title. This is a compulsory field "
         u"and you will be prompted to enter a label if you try "
         u"to submit your iDevice without one."
     )
     self._authorInstruc = x_(u"This is an optional field.")
     self._purposeInstruc = x_(
         u"The purpose dialogue allows you to describe"
         u" your intended purpose of the iDevice to other"
         u" potential users."
     )
     self._emphasisInstruc = x_(
         u"Use this pulldown to select whether or not "
         u" the iDevice should have any formatting "
         u" applied to it to distinguish "
         u"it; ie. a border and an icon."
     )
     self._tipInstruc = x_(
         u"Use this field to describe "
         u"your intended use and the pedagogy behind "
         u"the device's development. This can be useful "
         u"if your iDevice is to be exported for others "
         u"to use."
     )
     self._lineInstruc = x_(
         u"Add a single text line to an iDevice. "
         u"Useful if you want the ability to place a "
         u"label within the iDevice."
     )
     self._textBoxInstruc = x_(
         u"Add a text entry box to an iDevice. " u"Used for entering larger amounts of textual " u"content."
     )
     self._imageInstruc = x_(
         u"Add an image to your iDevice. Enables " u"the user to insert an image into the  " u"iDevice."
     )
     self._feedbackInstruc = x_(u"Add an interactive feedback field to your iDevice.")
     self._flashInstruc = x_(u"Add a flash video to your iDevice.")
     self._mp3Instruc = x_(u"Add an mp3 file to your iDevice.")
     self.style = "default"
    def __init__(self, webServer, parent):
        """
        Initialize
        JR: anado parente para poder acceder a algunos atributos de editorpag, en concreto a showHide
        """
        self.ideviceStore = webServer.application.ideviceStore
        self.webDir = webServer.application.config.webDir
        self.styles = webServer.application.config.styleStore.getStyles()
        self.elements = []
        self.idevice = GenericIdevice("", "", "", "", "")
        self.idevice.id = self.ideviceStore.getNewIdeviceId()
        self.originalIdevice = GenericIdevice("", "", "", "", "")
        self.purpose = ""
        self.tip = ""
        self.message = ""
        self.parent = parent
        self._nameInstruc     = \
           x_(u"Your new iDevice will appear in the iDevice "
              u"pane with this title. This is a compulsory field "
              u"and you will be prompted to enter a label if you try "
              u"to submit your iDevice without one.")
        self._authorInstruc = x_(u"This is an optional field.")
        self._purposeInstruc = x_(
            u"The purpose dialogue allows you to describe"
            u" your intended purpose of the iDevice to other"
            u" potential users.")
        self._emphasisInstruc = x_(
            u"Use this pulldown to select whether or not "
            u" the iDevice should have any formatting "
            u" applied to it to distinguish "
            u"it; ie. a border and an icon.")
        self._tipInstruc = x_(u"Use this field to describe "
                              u"your intended use and the pedagogy behind "
                              u"the device's development. This can be useful "
                              u"if your iDevice is to be exported for others "
                              u"to use.")
        self._lineInstruc = x_(u"Add a single text line to an iDevice. "
                               u"Useful if you want the ability to place a "
                               u"label within the iDevice.")
        self._textBoxInstruc = x_(
            u"Add a text entry box to an iDevice. "
            u"Used for entering larger amounts of textual "
            u"content.")
        self._feedbackInstruc = x_(
            u"Add an interactive feedback field to your iDevice.")
        self._flashInstruc = x_(u"Add a flash video to your iDevice.")
        self._mp3Instruc = x_(u"Add an mp3 file to your iDevice.")
        self._attachInstruc = x_(u"Add an attachment file to your iDevice.")

        self.style = self.styles[0]
Пример #8
0
 def __init__(self, webServer):
     """
     Initialize
     """
     self.ideviceStore     = webServer.application.ideviceStore
     self.webDir           = webServer.application.config.webDir
     self.styles           = webServer.application.config.styles
     self.elements         = []
     self.idevice          = GenericIdevice("", "", "", "", "")
     self.idevice.id       = self.ideviceStore.getNewIdeviceId()
     self.originalIdevice  = GenericIdevice("", "", "", "", "")
     self.purpose          = ""
     self.tip              = ""
     self.message          = ""
     self._nameInstruc     = \
        x_(u"Your new iDevice will appear in the iDevice "
           u"pane with this title. This is a compulsory field "
           u"and you will be prompted to enter a label if you try "
           u"to submit your idevice without one.")
     self._authorInstruc   = x_(u"This is an optional field.")
     self._purposeInstruc  = x_(u"The purpose dialogue allows you to describe"
                              u" your intended purpose of the device to other"
                              u" potential users.")
     self._emphasisInstruc = x_(u"Use Emphasis to distinguish the importance "
                              u" of the information being presented in the "
                              u"iDevice.")
     self._tipInstruc      = x_(u"A pedagogical tip allows you to describe "
                              u"your intended use and the pedagogy behind "
                              u"the devices development.")
     self._lineInstruc     = x_(u"Add a single text line to an iDevice. "
                              u"Useful if you want the ability to place a "
                              u"label within the device.")
     self._textBoxInstruc  = x_(u"Add a text entry box to an iDevice. "
                              u"Used for entering description textual "
                              u"content.")
     self._imageInstruc    = x_(u"Add an image to your iDevice. Enables "
                              u"the selection of an image from your stored "
                              u"picture files.")
     self._feedbackInstruc = x_(u"Add interactive feedback to your iDevice.")
     self._flashInstruc = x_(u"Add a flash video to your iDevice.")
     self._mp3Instruc = x_(u"Add a mp3 file to your iDevice.")
     self.style            = "default"
Пример #9
0
    def __createReading011(self):
        """
        Create the Reading Activity 0.11
        We do this only once when the user first runs eXe 0.11
        """
        from exe.engine.genericidevice import GenericIdevice

        readingAct = GenericIdevice(_(u"Reading Activity 0.11"), 
                                    u"reading",
                                    _(u"University of Auckland"), 
                                    x_(u"""<p>The reading activity, as the name 
suggests, should ask the learner to perform some form of activity. This activity 
should be directly related to the text the learner has been asked to read. 
Feedback to the activity where appropriate, can provide the learner with some 
reflective guidance.</p>"""),
                                    x_(u"Teachers should keep the following "
                                        "in mind when using this iDevice: "
                                        "<ol>"
                                        "<li>"
                                        "Think about the number of "
                                        "different types of activity "
                                        "planned for your resource that "
                                        "will be visually signalled in the "
                                        "content. Avoid using too many "
                                        "different types or classification "
                                        "of activities otherwise learner "
                                        "may become confused. Usually three "
                                        "or four different types are more "
                                        "than adequate for a teaching "
                                        "resource."
                                        "</li>"
                                        "<li>"
                                        "From a visual design "
                                        "perspective, avoid having two "
                                        "iDevices immediately following "
                                        "each other without any text in "
                                        "between. If this is required, "
                                        "rather collapse two questions or "
                                        "events into one iDevice. "
                                        "</li>"
                                        "<li>"
                                        "Think "
                                        "about activities where the "
                                        "perceived benefit of doing the "
                                        "activity outweighs the time and "
                                        "effort it will take to complete "
                                        "the activity. "
                                        "</li>"
                                        "</ol>")) 
        readingAct.emphasis = Idevice.SomeEmphasis
        readingAct.addField(TextAreaField(_(u"What to read"), 
_(u"""Enter the details of the reading including reference details. The 
referencing style used will depend on the preference of your faculty or 
department.""")))
        readingAct.addField(TextAreaField(_(u"Activity"), 
_(u"""Describe the tasks related to the reading learners should undertake. 
This helps demonstrate relevance for learners.""")))

        readingAct.addField(FeedbackField(_(u"Feedback"), 
_(u"""Use feedback to provide a summary of the points covered in the reading, 
or as a starting point for further analysis of the reading by posing a question 
or providing a statement to begin a debate.""")))
    
        objectives = GenericIdevice(_(u"Objectives"), 
                                    u"objectives",
                                    _(u"University of Auckland"), 
_(u"""Objectives describe the expected outcomes of the learning and should
define what the learners will be able to do when they have completed the
learning tasks."""), 
                                    u"")
        objectives.emphasis = Idevice.SomeEmphasis

        objectives.addField(TextAreaField(_(u"Objectives"),
_(u"""Type the learning objectives for this resource.""")))
        self.generic.append(objectives)

        preknowledge = GenericIdevice(_(u"Preknowledge"), 
                                      u"preknowledge",
                                      "", 
_(u"""Prerequisite knowledge refers to the knowledge learners should already
have in order to be able to effectively complete the learning. Examples of
pre-knowledge can be: <ul>
<li>        Learners must have level 4 English </li>
<li>        Learners must be able to assemble standard power tools </li></ul>
"""), u"")
        preknowledge.emphasis = Idevice.SomeEmphasis
        preknowledge.addField(TextAreaField(_(u"Preknowledge"), 
_(u"""Describe the prerequisite knowledge learners should have to effectively
complete this learning.""")))
        self.generic.append(preknowledge)
        
        activity = GenericIdevice(_(u"Activity"), 
                                  u"activity",
                                  _(u"University of Auckland"), 
_(u"""An activity can be defined as a task or set of tasks a learner must
complete. Provide a clear statement of the task and consider any conditions
that may help or hinder the learner in the performance of the task."""),
u"")
        activity.emphasis = Idevice.SomeEmphasis
        activity.addField(TextAreaField(_(u"Activity"),
_(u"""Describe the tasks the learners should complete.""")))
        self.generic.append(activity)
Пример #10
0
    def __createGeneric(self):
        """
        Create the Generic iDevices which you get for free
        (not created using the iDevice editor, but could have been)
        Called when we can't find 'generic.data', generates an initial set of 
        free/builtin idevices and writes the new 'generic.data' file
        
        JRJ: Modifico este método para que acepte otro parámetro que será la lista 
        en la que añadimos los idevices genéricos
        (Modify this method so it accepts a new parameter, the list
        to which we add the generic iDevices)
        """
        
        idevices = []

        from exe.engine.genericidevice import GenericIdevice

        readingAct = GenericIdevice(x_(u"Reading Activity"), 
                                    u"reading",
                                    x_(u"University of Auckland"), 
                                    x_(u"""<p>The Reading Activity will primarily 
be used to check a learner's comprehension of a given text. This can be done 
by asking the learner to reflect on the reading and respond to questions about 
the reading, or by having them complete some other possibly more physical task 
based on the reading.</p>"""),
                                    x_(u"<p>Teachers should keep the following "
                                        "in mind when using this iDevice: </p>"
                                        "<ol>"
                                        "<li>"
                                        "Think about the number of "
                                        "different types of activity "
                                        "planned for your resource that "
                                        "will be visually signalled in the "
                                        "content. Avoid using too many "
                                        "different types or classification "
                                        "of activities otherwise learner "
                                        "may become confused. Usually three "
                                        "or four different types are more "
                                        "than adequate for a teaching "
                                        "resource."
                                        "</li>"
                                        "<li>"
                                        "From a visual design "
                                        "perspective, avoid having two "
                                        "iDevices immediately following "
                                        "each other without any text in "
                                        "between. If this is required, "
                                        "rather collapse two questions or "
                                        "events into one iDevice. "
                                        "</li>"
                                        "<li>"
                                        "Think "
                                        "about activities where the "
                                        "perceived benefit of doing the "
                                        "activity outweighs the time and "
                                        "effort it will take to complete "
                                        "the activity. "
                                        "</li>"
                                        "</ol>")) 
        readingAct.emphasis = Idevice.SomeEmphasis
        readingAct.addField(TextAreaField(x_(u"What to read"), 
x_(u"""Enter the details of the reading including reference details. The 
referencing style used will depend on the preference of your faculty or 
department.""")))
        readingAct.addField(TextAreaField(x_(u"Activity"), 
x_(u"""Describe the tasks related to the reading learners should undertake. 
This helps demonstrate relevance for learners.""")))

        readingAct.addField(FeedbackField(x_(u"Feedback"), 
x_(u"""Use feedback to provide a summary of the points covered in the reading, 
or as a starting point for further analysis of the reading by posing a question 
or providing a statement to begin a debate.""")))

        idevices.append(readingAct)
    
        objectives = GenericIdevice(x_(u"Objectives"), 
                                    u"objectives",
                                    x_(u"University of Auckland"), 
x_(u"""Objectives describe the expected outcomes of the learning and should
define what the learners will be able to do when they have completed the
learning tasks."""), 
                                    u"")
        objectives.emphasis = Idevice.SomeEmphasis

        objectives.addField(TextAreaField(x_(u"Objectives"),
x_(u"""Type the learning objectives for this resource.""")))
        idevices.append(objectives)

        preknowledge = GenericIdevice(x_(u"Preknowledge"), 
                                      u"preknowledge",
                                      "", 
x_(u"""Prerequisite knowledge refers to the knowledge learners should already
have in order to be able to effectively complete the learning. Examples of
pre-knowledge can be: <ul>
<li>        Learners must have level 4 English </li>
<li>        Learners must be able to assemble standard power tools </li></ul>
"""), u"")
        preknowledge.emphasis = Idevice.SomeEmphasis
        preknowledge.addField(TextAreaField(x_(u"Preknowledge"), 
x_(u"""Describe the prerequisite knowledge learners should have to effectively
complete this learning.""")))
        idevices.append(preknowledge)
        
        activity = GenericIdevice(x_(u"Activity"), 
                                  u"activity",
                                  x_(u"University of Auckland"), 
x_(u"""An activity can be defined as a task or set of tasks a learner must
complete. Provide a clear statement of the task and consider any conditions
that may help or hinder the learner in the performance of the task."""),
u"")
        activity.emphasis = Idevice.SomeEmphasis
        activity.addField(TextAreaField(x_(u"Activity"),
x_(u"""Describe the tasks the learners should complete.""")))
        idevices.append(activity)

        #self.save()
        return idevices
Пример #11
0
    def __createReading011(self):
        """
        Create the Reading Activity 0.11
        We do this only once when the user first runs eXe 0.11
        """
        from exe.engine.genericidevice import GenericIdevice

        readingAct = GenericIdevice(_(u"Reading Activity 0.11"), 
                                    u"reading",
                                    _(u"University of Auckland"), 
                                    x_(u"""<p>The reading activity, as the name 
suggests, should ask the learner to perform some form of activity. This activity 
should be directly related to the text the learner has been asked to read. 
Feedback to the activity where appropriate, can provide the learner with some 
reflective guidance.</p>"""),
                                    x_(u"Teachers should keep the following "
                                        "in mind when using this iDevice: "
                                        "<ol>"
                                        "<li>"
                                        "Think about the number of "
                                        "different types of activity "
                                        "planned for your resource that "
                                        "will be visually signalled in the "
                                        "content. Avoid using too many "
                                        "different types or classification "
                                        "of activities otherwise learner "
                                        "may become confused. Usually three "
                                        "or four different types are more "
                                        "than adequate for a teaching "
                                        "resource."
                                        "</li>"
                                        "<li>"
                                        "From a visual design "
                                        "perspective, avoid having two "
                                        "iDevices immediately following "
                                        "each other without any text in "
                                        "between. If this is required, "
                                        "rather collapse two questions or "
                                        "events into one iDevice. "
                                        "</li>"
                                        "<li>"
                                        "Think "
                                        "about activities where the "
                                        "perceived benefit of doing the "
                                        "activity outweighs the time and "
                                        "effort it will take to complete "
                                        "the activity. "
                                        "</li>"
                                        "</ol>")) 
        readingAct.emphasis = Idevice.SomeEmphasis
        readingAct.addField(TextAreaField(_(u"What to read"), 
_(u"""Enter the details of the reading including reference details. The 
referencing style used will depend on the preference of your faculty or 
department.""")))
        readingAct.addField(TextAreaField(_(u"Activity"), 
_(u"""Describe the tasks related to the reading learners should undertake. 
This helps demonstrate relevance for learners.""")))

        readingAct.addField(FeedbackField(_(u"Feedback"), 
_(u"""Use feedback to provide a summary of the points covered in the reading, 
or as a starting point for further analysis of the reading by posing a question 
or providing a statement to begin a debate.""")))
    
        objectives = GenericIdevice(_(u"Objectives"), 
                                    u"objectives",
                                    _(u"University of Auckland"), 
_(u"""Objectives describe the expected outcomes of the learning and should
define what the learners will be able to do when they have completed the
learning tasks."""), 
                                    u"")
        objectives.emphasis = Idevice.SomeEmphasis

        objectives.addField(TextAreaField(_(u"Objectives"),
_(u"""Type the learning objectives for this resource.""")))
        self.generic.append(objectives)

        preknowledge = GenericIdevice(_(u"Preknowledge"), 
                                      u"preknowledge",
                                      "", 
_(u"""Prerequisite knowledge refers to the knowledge learners should already
have in order to be able to effectively complete the learning. Examples of
pre-knowledge can be: <ul>
<li>        Learners must have level 4 English </li>
<li>        Learners must be able to assemble standard power tools </li></ul>
"""), u"")
        preknowledge.emphasis = Idevice.SomeEmphasis
        preknowledge.addField(TextAreaField(_(u"Preknowledge"), 
_(u"""Describe the prerequisite knowledge learners should have to effectively
complete this learning.""")))
        self.generic.append(preknowledge)
        
        activity = GenericIdevice(_(u"Activity"), 
                                  u"activity",
                                  _(u"University of Auckland"), 
_(u"""An activity can be defined as a task or set of tasks a learner must
complete. Provide a clear statement of the task and consider any conditions
that may help or hinder the learner in the performance of the task."""),
u"")
        activity.emphasis = Idevice.SomeEmphasis
        activity.addField(TextAreaField(_(u"Activity"),
_(u"""Describe the tasks the learners should complete.""")))
        self.generic.append(activity)

        self.save()
Пример #12
0
    def __createGeneric(self):
        """
        Create the Generic iDevices which you get for free
        (not created using the iDevice editor, but could have been)
        Called when we can't find 'generic.data', generates an initial set of 
        free/builtin idevices and writes the new 'generic.data' file
        """
        from exe.engine.genericidevice import GenericIdevice

        readingAct = GenericIdevice(_(u"Reading Activity"), 
                                    u"reading",
                                    _(u"University of Auckland"), 
                                    x_(u"""<p>The Reading Activity will primarily 
be used to check a learner's comprehension of a given text. This can be done 
by asking the learner to reflect on the reading and respond to questions about 
the reading, or by having them complete some other possibly more physical task 
based on the reading.</p>"""),
                                    x_(u"<p>Teachers should keep the following "
                                        "in mind when using this iDevice: </p>"
                                        "<ol>"
                                        "<li>"
                                        "Think about the number of "
                                        "different types of activity "
                                        "planned for your resource that "
                                        "will be visually signalled in the "
                                        "content. Avoid using too many "
                                        "different types or classification "
                                        "of activities otherwise learner "
                                        "may become confused. Usually three "
                                        "or four different types are more "
                                        "than adequate for a teaching "
                                        "resource."
                                        "</li>"
                                        "<li>"
                                        "From a visual design "
                                        "perspective, avoid having two "
                                        "iDevices immediately following "
                                        "each other without any text in "
                                        "between. If this is required, "
                                        "rather collapse two questions or "
                                        "events into one iDevice. "
                                        "</li>"
                                        "<li>"
                                        "Think "
                                        "about activities where the "
                                        "perceived benefit of doing the "
                                        "activity outweighs the time and "
                                        "effort it will take to complete "
                                        "the activity. "
                                        "</li>"
                                        "</ol>"), Idevice.Content) 
        readingAct.emphasis = Idevice.SomeEmphasis
        readingAct.group = Idevice.Content
        readingAct.addField(TextAreaField(_(u"What to read"), 
_(u"""Enter the details of the reading including reference details. The 
referencing style used will depend on the preference of your faculty or 
department.""")))
        readingAct.addField(TextAreaField(_(u"Activity"), 
_(u"""Describe the tasks related to the reading learners should undertake. 
This helps demonstrate relevance for learners.""")))

        readingAct.addField(FeedbackField(_(u"Feedback"), 
_(u"""Use feedback to provide a summary of the points covered in the reading, 
or as a starting point for further analysis of the reading by posing a question 
or providing a statement to begin a debate.""")))

        self.generic.append(readingAct)
    
        objectives = GenericIdevice(_(u"Objectives"), 
                                    u"objectives",
                                    _(u"University of Auckland"), 
_(u"""Objectives describe the expected outcomes of the learning and should
define what the learners will be able to do when they have completed the
learning tasks."""), 
                                    u"", group=Idevice.Didactics)
        objectives.emphasis = Idevice.SomeEmphasis

        objectives.addField(TextAreaField(_(u"Objectives"),
_(u"""Type the learning objectives for this resource.""")))
	objectives.addField(ExportOptionField(_(u"Export Option"), _(u"Choose export type for this iDevice")))
        self.generic.append(objectives)

        preknowledge = GenericIdevice(_(u"Preknowledge"), 
                                      u"preknowledge",
                                      "", 
_(u"""Prerequisite knowledge refers to the knowledge learners should already
have in order to be able to effectively complete the learning. Examples of
pre-knowledge can be: <ul>
<li>        Learners must have level 4 English </li>
<li>        Learners must be able to assemble standard power tools </li></ul>
"""), u"", group=Idevice.Didactics)
        preknowledge.emphasis = Idevice.SomeEmphasis
        preknowledge.addField(TextAreaField(_(u"Preknowledge"), 
_(u"""Describe the prerequisite knowledge learners should have to effectively
complete this learning.""")))
        self.generic.append(preknowledge)
        
        activity = GenericIdevice(_(u"Activity"), 
                                  u"activity",
                                  _(u"University of Auckland"), 
_(u"""An activity can be defined as a task or set of tasks a learner must
complete. Provide a clear statement of the task and consider any conditions
that may help or hinder the learner in the performance of the task."""),
u"", Idevice.Content)
        activity.emphasis = Idevice.SomeEmphasis
        activity.addField(TextAreaField(_(u"Activity"),
_(u"""Describe the tasks the learners should complete.""")))
        self.generic.append(activity)

        self.save()
Пример #13
0
class EditorPane(object):
    """
    The EditorPane is responsible for creating new idevice
    """
    def __init__(self, webServer, parent):
        """
        Initialize
        JR: anado parente para poder acceder a algunos atributos de editorpag, en concreto a showHide
        """
        self.ideviceStore     = webServer.application.ideviceStore
        self.webDir           = webServer.application.config.webDir
        self.styles           = webServer.application.config.styleStore.getStyles()
        self.elements         = []
        self.idevice          = GenericIdevice("", "", "", "", "")
        self.idevice.id       = self.ideviceStore.getNewIdeviceId()
        self.originalIdevice  = GenericIdevice("", "", "", "", "")
        self.purpose          = ""
        self.tip              = ""
        self.message          = ""
        self.parent           = parent
        self._nameInstruc     = \
           x_(u"Your new iDevice will appear in the iDevice "
              u"pane with this title. This is a compulsory field "
              u"and you will be prompted to enter a label if you try "
              u"to submit your iDevice without one.")
        self._authorInstruc   = x_(u"This is an optional field.")
        self._purposeInstruc  = x_(u"The purpose dialogue allows you to describe"
                                 u" your intended purpose of the iDevice to other"
                                 u" potential users.")
        self._emphasisInstruc = x_(u"Use this pulldown to select whether or not "
                                 u" the iDevice should have any formatting "
                                 u" applied to it to distinguish "
                                 u"it; ie. a border and an icon.")
        self._tipInstruc      = x_(u"Use this field to describe "
                                 u"your intended use and the pedagogy behind "
                                 u"the device's development. This can be useful "
                                 u"if your iDevice is to be exported for others "
                                 u"to use.")
        self._lineInstruc     = x_(u"Add a single text line to an iDevice. "
                                 u"Useful if you want the ability to place a "
                                 u"label within the iDevice.")
        self._textBoxInstruc  = x_(u"Add a text entry box to an iDevice. "
                                 u"Used for entering larger amounts of textual "
                                 u"content.")
        self._feedbackInstruc = x_(u"Add an interactive feedback field to your iDevice.")
        self._flashInstruc    = x_(u"Add a flash video to your iDevice.")
        self._mp3Instruc      = x_(u"Add an mp3 file to your iDevice.")
        self._attachInstruc   = x_(u"Add an attachment file to your iDevice.")

        self.style            = self.styles[0]
   
    # Properties
    
    nameInstruc     = lateTranslate('nameInstruc')    
    authorInstruc   = lateTranslate('authorInstruc')
    purposeInstruc  = lateTranslate('purposeInstruc')
    emphasisInstruc = lateTranslate('emphasisInstruc')
    tipInstruc      = lateTranslate('tipInstruc')
    lineInstruc     = lateTranslate('lineInstruc')
    textBoxInstruc  = lateTranslate('textBoxInstruc')
    feedbackInstruc = lateTranslate('feedbackInstruc')
    flashInstruc    = lateTranslate('flashInstruc')
    mp3Instruc      = lateTranslate('mp3Instruc')
    attachInstruc   = lateTranslate('attachInstruc')
    
    def setIdevice(self, idevice):
        """
        Sets the iDevice to edit
        """
        self.idevice         = idevice.clone()
        self.idevice.id      = idevice.id
        self.originalIdevice = idevice
        
    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()  
            
        
    def __buildElements(self):
        """
        Building up element array
        """
        self.elements  = []
        elementTypeMap = {TextField:       TextEditorElement,
                          TextAreaField:   TextAreaEditorElement,
                          ImageField:      ImageEditorElement,
                          FeedbackField:   FeedbackEditorElement,
                          MultimediaField: MultimediaEditorElement,
                          FlashField:      FlashEditorElement,
                          AttachmentField: AttachmentEditorElement}
        
        for field in self.idevice.fields:
            elementType = elementTypeMap.get(field.__class__)

            if elementType:
                # Create an instance of the appropriate element class
                log.debug(u"createElement "+elementType.__class__.__name__+
                          u" for "+field.__class__.__name__)
                self.elements.append(elementType(field))
            else:
                log.error(u"No element type registered for " +
                          field.__class__.__name__)
        
            
    def renderButtons(self, request):
        """
        Render the idevice being edited
        """
        html = "<font color=\"red\"><b>"+self.message+"</b></font>"
        
        html += "<fieldset><legend><b>" + _("Add Field")+ "</b></legend>"
        html += common.submitButton("addText", _("Text Line"))
        html += common.elementInstruc(self.lineInstruc) + "<br/>"
        html += common.submitButton("addTextArea", _("Text Box"))
        html += common.elementInstruc(self.textBoxInstruc) + "<br/>"
        html += common.submitButton("addFeedback", _("Feedback"))
        html += common.elementInstruc(self.feedbackInstruc) + "<br/>"
        #  Attachments are now embeddable:
        #html += common.submitButton("addAttachment", _("Attachment"))
        #html += common.elementInstruc(self.attachInstruc) + "<br/>"
        #  MP3 fields are now embeddable:
        #html += common.submitButton("addMP3", _("MP3"))
        #html += common.elementInstruc(self.mp3Instruc) + "<br/>"
        html += "</fieldset>\n"

        html += "<fieldset><legend><b>" + _("Actions") + "</b></legend>"

        if self.idevice.edit:
            html += common.submitButton("preview", _("Preview"), not self.parent.isGeneric)
        else:
            html += common.submitButton("edit", _("Edit"))

        html += "<br/>"
        html += common.submitButton("cancel", _("Cancel"))
        #html += "</fieldset>"

        return html


    def renderIdevice(self, request):
        """
        Returns an XHTML string for rendering the new idevice
        """
        html  = "<div id=\"editorWorkspace\">\n"
        html += "<script type=\"text/javascript\">\n"
        html += "<!--\n"
        html += """
            function selectStyleIcon(icon,e) {
                var div = document.getElementById("styleIcons");
                var imgs = div.getElementsByTagName("IMG");
                for (var i=0;i<imgs.length;i++) {
                    imgs[i].style.border = "1px solid #E8E8E8";
                }
                e.style.border = "1px solid #333333";            
                submitLink("selectIcon",icon,1);
            }        
            function submitLink(action, object, changed) 
            {
                var form = document.getElementById("contentForm")
                form.action.value = action;
                form.object.value = object;
                form.isChanged.value = changed;
                form.submit();
            }\n"""
        html += """
            function submitIdevice() 
            {
                var form = document.getElementById("contentForm")
                if (form.ideviceSelect.value == "newIdevice")
                    form.action.value = "newIdevice"
                else
                    form.action.value = "changeIdevice"
                form.object.value = form.ideviceSelect.value;
                form.isChanged.value = 1;
                form.submit();
            }\n"""
        html += """
            function submitStyle()
            {
                var form = document.getElementById("contentForm")
                form.action.value = "changeStyle";
                form.object.value = form.styleSelect.value;
                form.isChanged.value = 0;
                form.submit();
            }\n"""
        html += "//-->\n"
        html += "</script>\n"
        
        self.purpose = self.idevice.purpose.replace("\r", "")
        self.purpose = self.purpose.replace("\n","\\n")
        
        self.tip     = self.idevice.tip.replace("\r", "")
        self.tip     = self.tip.replace("\n","\\n")
        
        if self.idevice.edit:
            html += "<b>" + _("Name") + ": </b>\n"
            html += common.elementInstruc(self.nameInstruc) + "<br/>"
            html += '<input type="text" name= "title" id="title" value="%s"/>' % self.idevice.title
   
            this_package = None
            html += common.formField('richTextArea', this_package,
                                     _(u"Pedagogical Tip"),'tip',
                                     '', self.tipInstruc, self.tip)
     
            html += "<b>" + _("Emphasis") + ":</b> "
            html += "<select onchange=\"submit();\" name=\"emphasis\">\n"

            emphasisValues = {Idevice.NoEmphasis:     _(u"No emphasis"),
                              Idevice.SomeEmphasis:   _(u"Some emphasis")}
            for value, description in emphasisValues.items():
                html += "<option value=\""+unicode(value)+"\" "
                if self.idevice.emphasis == value:
                    html += "selected "
                html += ">" + description + "</option>\n"

            html += "</select> \n"
            html += common.elementInstruc(self.emphasisInstruc)
            html += "<br/><br/>\n"
            
            if self.idevice.emphasis > 0:
                html += self.__renderStyles() + " "
                html += u'<a style="margin-right:.5em" href="javascript:void(0)" '
                html += u'onclick="showMessageBox(\'iconpanel\');">'
                html += u'%s</a>' % _('Select an icon')
                icon = self.idevice.icon
                if icon != "":
                
                    iconExists = False
                    myIcon = Path(G.application.config.stylesDir/self.style.get_dirname()/"icon_" + self.idevice.icon + ".gif")
                    if myIcon.exists():
                        iconExists = True
                    else:
                        myIcon = Path(G.application.config.stylesDir/self.style.get_dirname()/"icon_" + self.idevice.icon + ".png")
                        if myIcon.exists():
                            iconExists = True
                    if iconExists:
                        html += '<img style="vertical-align:middle;max-width:60px;height:auto" '
                        html += 'src="/style/%s/icon_%s' % (self.style.get_dirname(), icon)
                        html += '%s"/><br />' % myIcon.ext
                        
                html += u'<div style="display:none;z-index:99;">'
                html += u'<div id="iconpaneltitle">'+_("Icons")+'</div>'
                html += u'<div id="iconpanelcontent">'
                html += self.__renderIcons()
                html += u'</div>'
                html += u'</div>\n'
                html += u'<br style="clear:both;margin-bottom:10px" />'
            for element in self.elements:
                html += element.renderEdit()       
        else:
            html += "<b>" + self.idevice.title + "</b><br/><br/>"
            for element in self.elements:
                html += element.renderPreview()               
            if self.idevice.purpose != "" or self.idevice.tip != "":
                html += "<a title=\""+_("Pedagogical Help")+"\" "
                html += "onclick=\"showMessageBox('phelp');\" " 
                html += "href=\"javascript:void(0)\" style=\"cursor:help;\">\n " 
                html += '<img alt="%s" src="/images/info.png" border="0" ' % _('Info')
                html += "align=\"middle\" /></a>\n"
                html += "<div style='display:none;'>"
                if self.idevice.purpose != "":
                    html += "<div id='phelptitle'>"+_('Purpose')+"</div>"
                    html += "<div id='phelpcontent'>"+self.purpose+"</div>"
                if self.idevice.tip != "":
                    html += "<div id='phelptitle'>"+_('Tip:')+"</div>"
                    html += "<div id='phelpcontent'>"+self.idevice.tip+"</div>"
                html += "</div>"  
                html += "</div>\n"
        html += "</div>\n"
        self.message = ""

        return html
    
    def __renderStyles(self):
        """
        Return xhtml string for rendering styles select
        """
        html  = '<select onchange="submitStyle();" style="display:none" name="styleSelect" id="styleSelect">\n'
        idx = 0
        isSelected = False
        for style in self.styles:
            html += "<option value='%d' " % idx
            if self.style.get_name() == style.get_name():
                html += "selected "
                isSelected = True
            html += ">" + style.get_name() + "~" + style.get_dirname() + "</option>\n"
            idx = idx + 1
        html += "</select> \n"
        # Auto-select the current style
        # This should be done with Python, not JavaScript
        # It's just a provisional solution so the user does not have to choose the right Style
        html += "<script type='text/javascript'>\
            function autoSelectStyle(){\
                var autoSelectStyle = document.getElementById('styleSelect');\
                if (autoSelectStyle.options[autoSelectStyle.value].innerHTML.split('~')[1]==top.exe_style_dirname) return false;\
                var currentStyleFolder;\
                for (var i=0; i<autoSelectStyle.options.length; i++) {\
                    currentStyleFolder = autoSelectStyle.options[i].innerHTML.split('~')[1];\
                    if (top.exe_style_dirname==currentStyleFolder) {\
                        autoSelectStyle.value=i;\
                        submitStyle();\
                    }\
                }\
            }\
            if (typeof(top.exe_style_dirname)!='undefined') {\
                autoSelectStyle();\
            }\
            \
        </script>";
        
        return html
    
    def __renderIcons(self):
        """
        Return xhtml string for dispay all icons
        """
        iconpath  = self.style.get_style_dir()
        iconfiles = iconpath.files("icon_*")
        html = '<div id="styleIcons"><div style="height:300px;overflow:auto">'
        
        for iconfile in iconfiles:
            iconname = iconfile.namebase
            icon     = iconname.split("_", 1)[1]
            
            iconExists = False
            iconExtension = "gif"
            myIcon = Path(G.application.config.stylesDir/self.style.get_dirname()/iconname + ".gif")
            if myIcon.exists():
                iconExists = True
            else:
                myIcon = Path(G.application.config.stylesDir/self.style.get_dirname()/iconname + ".png")
                if myIcon.exists():
                    iconExists = True 
                    iconExtension = "png"
            
            if iconExists:
                filename = "/style/%s/%s.%s" % (self.style.get_dirname(), iconname, iconExtension)
                html += u'<div style="float:left; text-align:center; width:105px;\n'
                html += u'margin-right:10px; margin-bottom:15px" > '
                html += u'<img src="%s" \n' % filename
                # html += u' alt="%s" ' % _("Submit")
                # window[1] because we use Ext.MessageBox instead of libot_drag.js
                html += u"style=\"border:1px solid #E8E8E8;padding:5px;cursor:pointer;max-width:60px;height:auto\" onclick=\"window[1].selectStyleIcon('%s',this)\" title=\"%s.%s\">\n" % (icon, icon, iconExtension)
                # html += u"style=\"cursor:pointer\" onclick=\"window[1].submitLink('selectIcon','%s',1)\">\n" % icon
                html += u'<br /><span style="display:inline-block;width:100px;overflow:hidden;text-overflow:ellipsis">%s.%s</span></div>\n' % (icon, iconExtension)
        
        html += '</div></div>'
        
        return html
Пример #14
0
class EditorPane(object):
    """
    The EditorPane is responsible for creating new idevice
    """
    def __init__(self, webServer, parent):
        """
        Initialize
        JR: anado parente para poder acceder a algunos atributos de editorpag, en concreto a showHide
        """
        self.ideviceStore = webServer.application.ideviceStore
        self.webDir = webServer.application.config.webDir
        self.styles = webServer.application.config.styleStore.getStyles()
        self.elements = []
        self.idevice = GenericIdevice("", "", "", "", "")
        self.idevice.id = self.ideviceStore.getNewIdeviceId()
        self.originalIdevice = GenericIdevice("", "", "", "", "")
        self.purpose = ""
        self.tip = ""
        self.message = ""
        self.parent = parent
        self._nameInstruc     = \
           x_(u"Your new iDevice will appear in the iDevice "
              u"pane with this title. This is a compulsory field "
              u"and you will be prompted to enter a label if you try "
              u"to submit your iDevice without one.")
        self._authorInstruc = x_(u"This is an optional field.")
        self._purposeInstruc = x_(
            u"The purpose dialogue allows you to describe"
            u" your intended purpose of the iDevice to other"
            u" potential users.")
        self._emphasisInstruc = x_(
            u"Use this pulldown to select whether or not "
            u" the iDevice should have any formatting "
            u" applied to it to distinguish "
            u"it; ie. a border and an icon.")
        self._tipInstruc = x_(u"Use this field to describe "
                              u"your intended use and the pedagogy behind "
                              u"the device's development. This can be useful "
                              u"if your iDevice is to be exported for others "
                              u"to use.")
        self._lineInstruc = x_(u"Add a single text line to an iDevice. "
                               u"Useful if you want the ability to place a "
                               u"label within the iDevice.")
        self._textBoxInstruc = x_(
            u"Add a text entry box to an iDevice. "
            u"Used for entering larger amounts of textual "
            u"content.")
        self._feedbackInstruc = x_(
            u"Add an interactive feedback field to your iDevice.")
        self._flashInstruc = x_(u"Add a flash video to your iDevice.")
        self._mp3Instruc = x_(u"Add an mp3 file to your iDevice.")
        self._attachInstruc = x_(u"Add an attachment file to your iDevice.")

        self.style = self.styles[0]

    # Properties

    nameInstruc = lateTranslate('nameInstruc')
    authorInstruc = lateTranslate('authorInstruc')
    purposeInstruc = lateTranslate('purposeInstruc')
    emphasisInstruc = lateTranslate('emphasisInstruc')
    tipInstruc = lateTranslate('tipInstruc')
    lineInstruc = lateTranslate('lineInstruc')
    textBoxInstruc = lateTranslate('textBoxInstruc')
    feedbackInstruc = lateTranslate('feedbackInstruc')
    flashInstruc = lateTranslate('flashInstruc')
    mp3Instruc = lateTranslate('mp3Instruc')
    attachInstruc = lateTranslate('attachInstruc')

    def setIdevice(self, idevice):
        """
        Sets the iDevice to edit
        """
        self.idevice = idevice.clone()
        self.idevice.id = idevice.id
        self.originalIdevice = idevice

    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()

    def __buildElements(self):
        """
        Building up element array
        """
        self.elements = []
        elementTypeMap = {
            TextField: TextEditorElement,
            TextAreaField: TextAreaEditorElement,
            ImageField: ImageEditorElement,
            FeedbackField: FeedbackEditorElement,
            MultimediaField: MultimediaEditorElement,
            FlashField: FlashEditorElement,
            AttachmentField: AttachmentEditorElement
        }

        for field in self.idevice.fields:
            elementType = elementTypeMap.get(field.__class__)

            if elementType:
                # Create an instance of the appropriate element class
                log.debug(u"createElement " + elementType.__class__.__name__ +
                          u" for " + field.__class__.__name__)
                self.elements.append(elementType(field))
            else:
                log.error(u"No element type registered for " +
                          field.__class__.__name__)

    def renderButtons(self, request):
        """
        Render the idevice being edited
        """
        html = "<font color=\"red\"><b>" + self.message + "</b></font>"

        html += "<fieldset><legend><b>" + _("Add Field") + "</b></legend>"
        html += common.submitButton("addText", _("Text Line"))
        html += common.elementInstruc(self.lineInstruc) + "<br/>"
        html += common.submitButton("addTextArea", _("Text Box"))
        html += common.elementInstruc(self.textBoxInstruc) + "<br/>"
        html += common.submitButton("addFeedback", _("Feedback"))
        html += common.elementInstruc(self.feedbackInstruc) + "<br/>"
        #  Attachments are now embeddable:
        #html += common.submitButton("addAttachment", _("Attachment"))
        #html += common.elementInstruc(self.attachInstruc) + "<br/>"
        #  MP3 fields are now embeddable:
        #html += common.submitButton("addMP3", _("MP3"))
        #html += common.elementInstruc(self.mp3Instruc) + "<br/>"
        html += "</fieldset>\n"

        html += "<fieldset><legend><b>" + _("Actions") + "</b></legend>"

        if self.idevice.edit:
            html += common.submitButton("preview", _("Preview"),
                                        not self.parent.isGeneric)
        else:
            html += common.submitButton("edit", _("Edit"))

        html += "<br/>"
        html += common.submitButton("cancel", _("Cancel"))
        #html += "</fieldset>"

        return html

    def renderIdevice(self, request):
        """
        Returns an XHTML string for rendering the new idevice
        """
        html = "<div id=\"editorWorkspace\">\n"
        html += "<script type=\"text/javascript\">\n"
        html += "<!--\n"
        html += """
            function submitLink(action, object, changed) 
            {
                var form = document.getElementById("contentForm")
            
                form.action.value = action;
                form.object.value = object;
                form.isChanged.value = changed;
                form.submit();
            }\n"""
        html += """
            function submitIdevice() 
            {
                var form = document.getElementById("contentForm")
                if (form.ideviceSelect.value == "newIdevice")
                    form.action.value = "newIdevice"
                else
                    form.action.value = "changeIdevice"
                form.object.value = form.ideviceSelect.value;
                form.isChanged.value = 1;
                form.submit();
            }\n"""
        html += """
            function submitStyle()
            {
                var form = document.getElementById("contentForm")
                form.action.value = "changeStyle";
                form.object.value = form.styleSelect.value;
                form.isChanged.value = 0;
                form.submit();
            }\n"""
        html += "//-->\n"
        html += "</script>\n"

        self.purpose = self.idevice.purpose.replace("\r", "")
        self.purpose = self.purpose.replace("\n", "\\n")

        self.tip = self.idevice.tip.replace("\r", "")
        self.tip = self.tip.replace("\n", "\\n")

        if self.idevice.edit:
            html += "<b>" + _("Name") + ": </b>\n"
            html += common.elementInstruc(self.nameInstruc) + "<br/>"
            html += '<input type="text" name= "title" id="title" value="%s"/>' % self.idevice.title

            this_package = None
            html += common.formField('richTextArea', this_package,
                                     _(u"Pedagogical Tip"), 'tip', '',
                                     self.tipInstruc, self.tip)

            html += "<b>" + _("Emphasis") + ":</b> "
            html += "<select onchange=\"submit();\" name=\"emphasis\">\n"

            emphasisValues = {
                Idevice.NoEmphasis: _(u"No emphasis"),
                Idevice.SomeEmphasis: _(u"Some emphasis")
            }
            for value, description in emphasisValues.items():
                html += "<option value=\"" + unicode(value) + "\" "
                if self.idevice.emphasis == value:
                    html += "selected "
                html += ">" + description + "</option>\n"

            html += "</select> \n"
            html += common.elementInstruc(self.emphasisInstruc)
            html += "<br/><br/>\n"

            if self.idevice.emphasis > 0:
                html += self.__renderStyles() + " "
                html += u'<a href="#" '
                html += u'onmousedown="Javascript:updateCoords(event);"\n'
                html += u'onclick="Javascript:showMe(\'iconpanel\', 350, 100);">'
                html += u'Select an icon:</a> \n'
                icon = self.idevice.icon
                if icon != "":
                    html += '<img align="middle" '
                    html += 'src="/style/%s/icon_%s' % (
                        self.style.get_dirname(), icon)
                    html += '.gif"/><br/>'
                html += u'<div id="iconpanel" style="display:none; z-index:99;">'
                html += u'<div style="float:right;" >\n'
                html += u'<img alt="%s" ' % _("Close")
                html += u'src="/images/stock-stop.png" title="%s"\n' % _(
                    "Close")
                html += u'onmousedown="Javascript:hideMe();"/></div><br/> \n'
                html += u'<div align="center"><b>%s:</b></div><br/>' % _(
                    "Icons")
                html += self.__renderIcons()
                html += u'</div><br/>\n'
            for element in self.elements:
                html += element.renderEdit()
        else:
            html += "<b>" + self.idevice.title + "</b><br/><br/>"
            for element in self.elements:
                html += element.renderPreview()
            if self.idevice.purpose != "" or self.idevice.tip != "":
                html += "<a title=\"" + _("Pedagogical Help") + "\" "
                html += "onmousedown=\"Javascript:updateCoords(event);\" \n"
                html += "onclick=\"Javascript:showMe('phelp', 380, 240);\" \n"
                html += "href=\"Javascript:void(0)\" style=\"cursor:help;\">\n "
                html += '<img alt="%s" src="/images/info.png" border="0" \n' % _(
                    'Info')
                html += "align=\"middle\" /></a>\n"
                html += "<div id=\"phelp\" style=\"display:none;\">\n"
                html += "<div style=\"float:right;\" "
                html += '<img alt="%s" src="/images/stock-stop.png" \n' % _(
                    'Close')
                html += " title='" + _(
                    "Close") + "' border='0' align='middle' \n"
                html += "onmousedown=\"Javascript:hideMe();\"/></div>\n"
                if self.idevice.purpose != "":
                    html += "<b>Purpose:</b><br/>%s<br/>" % self.purpose

                if self.idevice.tip != "":
                    html += "<b>Tip:</b><br/>%s<br/>" % self.idevice.tip

                html += "</div>\n"
        html += "</div>\n"
        self.message = ""

        return html

    def __renderStyles(self):
        """
        Return xhtml string for rendering styles select
        """
        html = '<select onchange="submitStyle();" name="styleSelect">\n'
        idx = 0
        for style in self.styles:
            html += "<option value='%d' " % idx
            if self.style.get_name() == style.get_name():
                html += "selected "
            html += ">" + style.get_name() + "</option>\n"
            idx = idx + 1
        html += "</select> \n"

        return html

    def __renderIcons(self):
        """
        Return xhtml string for dispay all icons
        """
        iconpath = self.style.get_style_dir()
        iconfiles = iconpath.files("icon_*")
        html = ""
        for iconfile in iconfiles:
            iconname = iconfile.namebase
            icon = iconname.split("_", 1)[1]
            filename = "/style/%s/%s.gif" % (self.style.get_dirname(),
                                             iconname)
            html += u'<div style="float:left; text-align:center; width:80px;\n'
            html += u'margin-right:10px; margin-bottom:10px" > '
            html += u'<img src="%s" \n' % filename
            html += u' alt="%s" ' % _("Submit")
            html += u"onclick=\"submitLink('selectIcon','%s',1)\">\n" % icon
            html += u'<br/>%s.gif</div>\n' % icon
        return html
Пример #15
0
class EditorPane(object):
    """
    The EditorPane is responsible for creating new idevice
    """
    def __init__(self, webServer):
        """
        Initialize
        """
        self.ideviceStore     = webServer.application.ideviceStore
        self.webDir           = webServer.application.config.webDir
        self.styles           = webServer.application.config.styles
        self.elements         = []
        self.idevice          = GenericIdevice("", "", "", "", "")
        self.idevice.id       = self.ideviceStore.getNewIdeviceId()
        self.originalIdevice  = GenericIdevice("", "", "", "", "")
        self.purpose          = ""
        self.tip              = ""
        self.message          = ""
        self._nameInstruc     = \
           x_(u"Your new iDevice will appear in the iDevice "
              u"pane with this title. This is a compulsory field "
              u"and you will be prompted to enter a label if you try "
              u"to submit your idevice without one.")
        self._authorInstruc   = x_(u"This is an optional field.")
        self._purposeInstruc  = x_(u"The purpose dialogue allows you to describe"
                                 u" your intended purpose of the device to other"
                                 u" potential users.")
        self._emphasisInstruc = x_(u"Use Emphasis to distinguish the importance "
                                 u" of the information being presented in the "
                                 u"iDevice.")
        self._tipInstruc      = x_(u"A pedagogical tip allows you to describe "
                                 u"your intended use and the pedagogy behind "
                                 u"the devices development.")
        self._lineInstruc     = x_(u"Add a single text line to an iDevice. "
                                 u"Useful if you want the ability to place a "
                                 u"label within the device.")
        self._textBoxInstruc  = x_(u"Add a text entry box to an iDevice. "
                                 u"Used for entering description textual "
                                 u"content.")
        self._imageInstruc    = x_(u"Add an image to your iDevice. Enables "
                                 u"the selection of an image from your stored "
                                 u"picture files.")
        self._feedbackInstruc = x_(u"Add interactive feedback to your iDevice.")
        self.style            = "default"
    nameInstruc     = lateTranslate('nameInstruc')    
    authorInstruc   = lateTranslate('authorInstruc')
    purposeInstruc  = lateTranslate('purposeInstruc')
    emphasisInstruc = lateTranslate('emphasisInstruc')
    tipInstruc      = lateTranslate('tipInstruc')
    lineInstruc     = lateTranslate('lineInstruc')
    textBoxInstruc  = lateTranslate('textBoxInstruc')
    imageInstruc    = lateTranslate('imageInstruc')
    feedbackInstruc = lateTranslate('feedbackInstruc')
    def setIdevice(self, idevice):
        """
        Sets the iDevice to edit
        """
        self.idevice         = idevice.clone()
        self.idevice.id      = idevice.id
        self.originalIdevice = idevice
    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 "author" in request.args:
                self.idevice.author = unicode(request.args["author"][0], 'utf8')
            if "purpose" in request.args:
                self.idevice.purpose = unicode(request.args["purpose"][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:
            self.idevice.addField(TextField(_(u"Enter the label here"),
                 _(u"Enter instructions for completion here")))
        if "addTextArea" in request.args:
            self.idevice.addField(TextAreaField(_(u"Enter the label here"), 
                 _(u"Enter the instructions for completion here")))
        if "addImage" in request.args:
            field = ImageField(_(u"Enter the label here"),
                               _(u"Enter the instructions for completion here"))
            imagePath = self.webDir/"images"/ImageEditorElement.DefaultImage
            field.defaultImage = unicode(imagePath.abspath())
            self.idevice.addField(field)
        if "addFeedback" in request.args:
            self.idevice.addField(FeedbackField(_(u"Enter the label here"), 
                 _(u"""Feedback button will not appear if no 
data is entered into this field.""")))
        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 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 
        if ("action" in request.args and 
            request.args["action"][0] == "changeStyle"):
            self.style = request.args["object"][0]
        self.__buildElements()  
    def __buildElements(self):
        """
        Building up element array
        """
        self.elements  = []
        elementTypeMap = {TextField:      TextEditorElement,
                          TextAreaField:  TextAreaEditorElement,
                          ImageField:     ImageEditorElement,
                          FeedbackField:  FeedbackEditorElement}
        for field in self.idevice.fields:
            elementType = elementTypeMap.get(field.__class__)
            if elementType:
                log.debug(u"createElement "+elementType.__class__.__name__+
                          u" for "+field.__class__.__name__)
                self.elements.append(elementType(field))
            else:
                log.error(u"No element type registered for " +
                          field.__class__.__name__)
    def renderButtons(self, request):
        """
        Render the idevice being edited
        """
        html = "<font color=\"red\"<b>"+self.message+"</b></font>"
        html += "<fieldset><legend><b>" + _("Add")+ "</b></legend>"
        html += common.submitButton("addText", _("Text Line"))
        html += common.elementInstruc(self.lineInstruc) + "<br/>"
        html += common.submitButton("addTextArea", _("Text Box"))
        html += common.elementInstruc(self.textBoxInstruc) + "<br/>"
        html += common.submitButton("addImage", _("Image"))  
        html += common.elementInstruc(self.imageInstruc) + "<br/>"
        html += common.submitButton("addFeedback", _("Feedback"))
        html += common.elementInstruc(self.feedbackInstruc) + "<br/>"
        html += "</fieldset>\n"
        html += "<fieldset><legend><b>" + _("Actions") + "</b></legend>"
        if self.idevice.edit:
            html += common.submitButton("preview", _("Preview"))
        else:
            html += common.submitButton("edit", _("Edit"))
        html += "<br/>"
        html += common.submitButton("cancel", _("Cancel"))
        return html
    def renderIdevice(self, request):
        """
        Returns an XHTML string for rendering the new idevice
        """
        html  = "<div id=\"editorWorkspace\">\n"
        html += "<script type=\"text/javascript\">\n"
        html += "<!--\n"
        html += """
            function submitLink(action, object, changed) 
            {
                var form = document.getElementById("contentForm")
                form.action.value = action;
                form.object.value = object;
                form.isChanged.value = changed;
                form.submit();
            }\n"""
        html += """
            function submitIdevice() 
            {
                var form = document.getElementById("contentForm")
                if (form.ideviceSelect.value == "newIdevice")
                    form.action.value = "newIdevice"
                else
                    form.action.value = "changeIdevice"
                form.object.value = form.ideviceSelect.value;
                form.isChanged.value = 1;
                form.submit();
            }\n"""
        html += """
            function submitStyle()
            {
                var form = document.getElementById("contentForm")
                form.action.value = "changeStyle";
                form.object.value = form.styleSelect.value;
                form.isChanged.value = 0;
                form.submit();
            }\n"""
        html += "//-->\n"
        html += "</script>\n"
        self.purpose = self.idevice.purpose.replace("\r", "")
        self.purpose = self.purpose.replace("\n","\\n")
        self.tip     = self.idevice.tip.replace("\r", "")
        self.tip     = self.tip.replace("\n","\\n")
        if self.idevice.edit:
            html += "<b>" + _("Name") + ": </b>\n"
            html += common.elementInstruc(self.nameInstruc) + "<br/>"
            html += common.textInput("title", self.idevice.title) + "<br/>\n"
            html += "<b>" + _("Author") + ": </b>\n"
            html += common.elementInstruc(self.authorInstruc) + "<br/>"
            html += common.textInput("author", self.idevice.author) + "<br/>\n"
            html += common.formField('richTextArea', _(u"Purpose"),'purpose',
                                     '', self.purposeInstruc, self.purpose)
            html += common.formField('richTextArea', _(u"Pedagogical Tip"),'tip',
                                     '', self.tipInstruc, self.tip)
            html += "<b>" + _("Emphasis") + ":</b> "
            html += "<select onchange=\"submit();\" name=\"emphasis\">\n"
            emphasisValues = {Idevice.NoEmphasis:     _(u"No emphasis"),
                              Idevice.SomeEmphasis:   _(u"Some emphasis"),
                              Idevice.StrongEmphasis: _(u"Strong emphasis")}
            for value, description in emphasisValues.items():
                html += "<option value=\""+unicode(value)+"\" "
                if self.idevice.emphasis == value:
                    html += "selected "
                html += ">" + description + "</option>\n"
            html += "</select> \n"
            html += common.elementInstruc(self.emphasisInstruc)
            html += "<br/><br/>\n"
            if self.idevice.emphasis > 0:
                html += self.__renderStyles() + " "
                html += u'<a href="#" '
                html += u'onmousedown="Javascript:updateCoords(event);"\n'
                html += u'onclick="Javascript:showMe(\'iconpanel\', 350, 100);">'
                html += u'Select an icon:</a> \n'
                icon = self.idevice.icon
                if icon != "":
                    html += '<img align="middle" '
                    html += 'src="/style/%s/icon_%s' % (self.style, icon)
                    html += '.gif"/><br/>'
                html += u'<div id="iconpanel" style="display:none; z-index:99;">'
                html += u'<div style="float:right;" >\n'
                html += u'<img alt="%s" ' % _("Close")
                html += u'src="/images/stock-stop.png" title="%s"\n' % _("Close")
                html += u'onmousedown="Javascript:hideMe();"/></div><br/> \n'
                html += u'<div align="center"><b>%s:</b></div><br/>' % _("Icons")
                html += self.__renderIcons()
                html += u'</div><br/>\n'
            for element in self.elements:
                html += element.renderEdit()       
        else:
            html += "<b>" + self.idevice.title + "</b><br/><br/>"
            for element in self.elements:
                html += element.renderPreview()               
            if self.idevice.purpose != "" or self.idevice.tip != "":
                html += "<a title=\""+_("Pedagogical Help")+"\" "
                html += "onmousedown=\"Javascript:updateCoords(event);\" \n"
                html += "onclick=\"Javascript:showMe('phelp', 380, 240);\" \n" 
                html += "href=\"Javascript:void(0)\" style=\"cursor:help;\">\n " 
                html += '<img alt="%s" src="/images/info.png" border="0" \n' % _('Info')
                html += "align=\"middle\" /></a>\n"
                html += "<div id=\"phelp\" style=\"display:none;\">\n"
                html += "<div style=\"float:right;\" "
                html += '<img alt="%s" src="/images/stock-stop.png" \n' % _('Close')
                html += " title='"+_("Close")+"' border='0' align='middle' \n"
                html += "onmousedown=\"Javascript:hideMe();\"/></div>\n"
                if self.idevice.purpose != "":
                    html += "<b>Purpose:</b><br/>%s<br/>" % self.purpose
                if self.idevice.tip != "":
                    html += "<b>Tip:</b><br/>%s<br/>" % self.idevice.tip
                html += "</div>\n"  
        html += "</div>\n"
        self.message = ""
        return html
    def __renderStyles(self):
        """
        Return xhtml string for rendering styles select
        """
        html  = '<select onchange="submitStyle();" name="styleSelect">\n'
        for style in self.styles:
            html += "<option value=\""+style+"\" "
            if self.style == style:
                html += "selected "
            html += ">" + style + "</option>\n"
        html += "</select> \n"
        return html
    def __renderIcons(self):
        """
        Return xhtml string for dispay all icons
        """
        iconpath  = Path(self.webDir).joinpath("style", self.style)
        iconfiles = iconpath.files("icon_*")
        html = ""
        for iconfile in iconfiles:
            iconname = iconfile.namebase
            icon     = iconname.split("_", 1)[1]
            filename = "/style/%s/%s.gif" % (self.style, iconname)
            html += u'<div style="float:left; text-align:center; width:80px;\n'
            html += u'margin-right:10px; margin-bottom:10px" > '
            html += u'<img src="%s" \n' % filename
            html += u' alt="%s" ' % _("Submit")
            html += u"onclick=\"submitLink('selectIcon','%s',1)\">\n" % icon
            html += u'<br/>%s.gif</div>\n' % icon
        return html
Пример #16
0
class EditorPane(object):
    """
    The EditorPane is responsible for creating new idevice
    """
    def __init__(self, webServer, parent):
        """
        Initialize
        JR: anado parente para poder acceder a algunos atributos de editorpag, en concreto a showHide
        """
        self.ideviceStore     = webServer.application.ideviceStore
        self.webDir           = webServer.application.config.webDir
        self.styles           = webServer.application.config.styles
        self.elements         = []
        self.idevice          = GenericIdevice("", "", "", "", "")
        self.idevice.id       = self.ideviceStore.getNewIdeviceId()
        self.originalIdevice  = GenericIdevice("", "", "", "", "")
        self.purpose          = ""
        self.tip              = ""
        self.message          = ""
        self.parent           = parent
        self._nameInstruc     = \
           x_(u"Your new iDevice will appear in the iDevice "
              u"pane with this title. This is a compulsory field "
              u"and you will be prompted to enter a label if you try "
              u"to submit your iDevice without one.")
        self._authorInstruc   = x_(u"This is an optional field.")
        self._purposeInstruc  = x_(u"The purpose dialogue allows you to describe"
                                 u" your intended purpose of the iDevice to other"
                                 u" potential users.")
        self._emphasisInstruc = x_(u"Use this pulldown to select whether or not "
                                 u" the iDevice should have any formatting "
                                 u" applied to it to distinguish "
                                 u"it; ie. a border and an icon.")
        self._tipInstruc      = x_(u"Use this field to describe "
                                 u"your intended use and the pedagogy behind "
                                 u"the device's development. This can be useful "
                                 u"if your iDevice is to be exported for others "
                                 u"to use.")
        self._lineInstruc     = x_(u"Add a single text line to an iDevice. "
                                 u"Useful if you want the ability to place a "
                                 u"label within the iDevice.")
        self._textBoxInstruc  = x_(u"Add a text entry box to an iDevice. "
                                 u"Used for entering larger amounts of textual "
                                 u"content.")
        self._feedbackInstruc = x_(u"Add an interactive feedback field to your iDevice.")
        self._flashInstruc    = x_(u"Add a flash video to your iDevice.")
        self._mp3Instruc      = x_(u"Add an mp3 file to your iDevice.")
        self._attachInstruc   = x_(u"Add an attachment file to your iDevice.")

        self.style            = "default"
   
    # Properties
    
    nameInstruc     = lateTranslate('nameInstruc')    
    authorInstruc   = lateTranslate('authorInstruc')
    purposeInstruc  = lateTranslate('purposeInstruc')
    emphasisInstruc = lateTranslate('emphasisInstruc')
    tipInstruc      = lateTranslate('tipInstruc')
    lineInstruc     = lateTranslate('lineInstruc')
    textBoxInstruc  = lateTranslate('textBoxInstruc')
    feedbackInstruc = lateTranslate('feedbackInstruc')
    flashInstruc    = lateTranslate('flashInstruc')
    mp3Instruc      = lateTranslate('mp3Instruc')
    attachInstruc   = lateTranslate('attachInstruc')
    
    def setIdevice(self, idevice):
        """
        Sets the iDevice to edit
        """
        self.idevice         = idevice.clone()
        self.idevice.id      = idevice.id
        self.originalIdevice = idevice
        
    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 = request.args["object"][0]
            
        self.__buildElements()  
            
        
    def __buildElements(self):
        """
        Building up element array
        """
        self.elements  = []
        elementTypeMap = {TextField:       TextEditorElement,
                          TextAreaField:   TextAreaEditorElement,
                          ImageField:      ImageEditorElement,
                          FeedbackField:   FeedbackEditorElement,
                          MultimediaField: MultimediaEditorElement,
                          FlashField:      FlashEditorElement,
                          AttachmentField: AttachmentEditorElement}
        
        for field in self.idevice.fields:
            elementType = elementTypeMap.get(field.__class__)

            if elementType:
                # Create an instance of the appropriate element class
                log.debug(u"createElement "+elementType.__class__.__name__+
                          u" for "+field.__class__.__name__)
                self.elements.append(elementType(field))
            else:
                log.error(u"No element type registered for " +
                          field.__class__.__name__)
        
            
    def renderButtons(self, request, showHide):
        """
        Render the idevice being edited
        """
        html = "<font color=\"red\"><b>"+self.message+"</b></font>"
        
        html += "<fieldset><legend><b>" + _("Add Field")+ "</b></legend>"
        html += common.submitButton("addText", _("Text Line"), not showHide)
        html += common.elementInstruc(self.lineInstruc) + "<br/>"
        html += common.submitButton("addTextArea", _("Text Box"), not showHide)
        html += common.elementInstruc(self.textBoxInstruc) + "<br/>"
        html += common.submitButton("addFeedback", _("Feedback"), not showHide)
        html += common.elementInstruc(self.feedbackInstruc) + "<br/>"
        #  Attachments are now embeddable:
        #html += common.submitButton("addAttachment", _("Attachment"))
        #html += common.elementInstruc(self.attachInstruc) + "<br/>"
        #  MP3 fields are now embeddable:
        #html += common.submitButton("addMP3", _("MP3"))
        #html += common.elementInstruc(self.mp3Instruc) + "<br/>"
        html += "</fieldset>\n"

        html += "<fieldset><legend><b>" + _("Actions") + "</b></legend>"

        if self.idevice.edit:
            html += common.submitButton("preview", _("Preview"), not (showHide or self.parent.isGeneric))
        else:
            html += common.submitButton("edit", _("Edit"), not showHide)

        html += "<br/>"
        html += common.submitButton("cancel", _("Cancel"))
        #html += "</fieldset>"

        return html


    def renderIdevice(self, request):
        """
        Returns an XHTML string for rendering the new idevice
        """
        html  = "<div id=\"editorWorkspace\">\n"
        html += "<script type=\"text/javascript\">\n"
        html += "<!--\n"
        html += """
            function submitLink(action, object, changed) 
            {
                var form = document.getElementById("contentForm")
            
                form.action.value = action;
                form.object.value = object;
                form.isChanged.value = changed;
                form.submit();
            }\n"""
        html += """
            function submitIdevice() 
            {
                var form = document.getElementById("contentForm")
                if (form.ideviceSelect.value == "newIdevice")
                    form.action.value = "newIdevice"
                else
                    form.action.value = "changeIdevice"
                form.object.value = form.ideviceSelect.value;
                form.isChanged.value = 1;
                form.submit();
            }\n"""
        html += """
            function submitStyle()
            {
                var form = document.getElementById("contentForm")
                form.action.value = "changeStyle";
                form.object.value = form.styleSelect.value;
                form.isChanged.value = 0;
                form.submit();
            }\n"""
        html += "//-->\n"
        html += "</script>\n"
        
        self.purpose = self.idevice.purpose.replace("\r", "")
        self.purpose = self.purpose.replace("\n","\\n")
        
        self.tip     = self.idevice.tip.replace("\r", "")
        self.tip     = self.tip.replace("\n","\\n")
        
        if self.idevice.edit:
            html += "<b>" + _("Name") + ": </b>\n"
            html += common.elementInstruc(self.nameInstruc) + "<br/>"
            html += '<input type="text" name= "title" id="title" value="%s"/>' % self.idevice.title
   
            this_package = None
            html += common.formField('richTextArea', this_package,
                                     _(u"Pedagogical Tip"),'tip',
                                     '', self.tipInstruc, self.tip)
     
            html += "<b>" + _("Emphasis") + ":</b> "
            html += "<select onchange=\"submit();\" name=\"emphasis\">\n"

            emphasisValues = {Idevice.NoEmphasis:     _(u"No emphasis"),
                              Idevice.SomeEmphasis:   _(u"Some emphasis")}
            for value, description in emphasisValues.items():
                html += "<option value=\""+unicode(value)+"\" "
                if self.idevice.emphasis == value:
                    html += "selected "
                html += ">" + description + "</option>\n"

            html += "</select> \n"
            html += common.elementInstruc(self.emphasisInstruc)
            html += "<br/><br/>\n"
            
            if self.idevice.emphasis > 0:
                html += self.__renderStyles() + " "
                html += u'<a href="#" '
                html += u'onmousedown="Javascript:updateCoords(event);"\n'
                html += u'onclick="Javascript:showMe(\'iconpanel\', 350, 100);">'
                html += u'Select an icon:</a> \n'
                icon = self.idevice.icon
                if icon != "":
                    html += '<img align="middle" '
                    html += 'src="/style/%s/icon_%s' % (self.style, icon)
                    html += '.gif"/><br/>'
                html += u'<div id="iconpanel" style="display:none; z-index:99;">'
                html += u'<div style="float:right;" >\n'
                html += u'<img alt="%s" ' % _("Close")
                html += u'src="/images/stock-stop.png" title="%s"\n' % _("Close")
                html += u'onmousedown="Javascript:hideMe();"/></div><br/> \n'
                html += u'<div align="center"><b>%s:</b></div><br/>' % _("Icons")
                html += self.__renderIcons()
                html += u'</div><br/>\n'
            for element in self.elements:
                html += element.renderEdit()       
        else:
            html += "<b>" + self.idevice.title + "</b><br/><br/>"
            for element in self.elements:
                html += element.renderPreview()               
            if self.idevice.purpose != "" or self.idevice.tip != "":
                html += "<a title=\""+_("Pedagogical Help")+"\" "
                html += "onmousedown=\"Javascript:updateCoords(event);\" \n"
                html += "onclick=\"Javascript:showMe('phelp', 380, 240);\" \n" 
                html += "href=\"Javascript:void(0)\" style=\"cursor:help;\">\n " 
                html += '<img alt="%s" src="/images/info.png" border="0" \n' % _('Info')
                html += "align=\"middle\" /></a>\n"
                html += "<div id=\"phelp\" style=\"display:none;\">\n"
                html += "<div style=\"float:right;\" "
                html += '<img alt="%s" src="/images/stock-stop.png" \n' % _('Close')
                html += " title='"+_("Close")+"' border='0' align='middle' \n"
                html += "onmousedown=\"Javascript:hideMe();\"/></div>\n"
                if self.idevice.purpose != "":
                    html += "<b>Purpose:</b><br/>%s<br/>" % self.purpose
                    
                if self.idevice.tip != "":
                    html += "<b>Tip:</b><br/>%s<br/>" % self.idevice.tip
                    
                html += "</div>\n"  
        html += "</div>\n"
        self.message = ""

        return html
    
    def __renderStyles(self):
        """
        Return xhtml string for rendering styles select
        """
        html  = '<select onchange="submitStyle();" name="styleSelect">\n'
        for style in self.styles:
            html += "<option value=\""+style+"\" "
            if self.style == style:
                html += "selected "
            html += ">" + style + "</option>\n"
        html += "</select> \n"
        
        return html
    
    def __renderIcons(self):
        """
        Return xhtml string for dispay all icons
        """
        iconpath  = Path(self.webDir).joinpath("style", self.style)
        iconfiles = iconpath.files("icon_*")
        html = ""
        for iconfile in iconfiles:
            iconname = iconfile.namebase
            icon     = iconname.split("_", 1)[1]
            filename = "/style/%s/%s.gif" % (self.style, iconname)
            html += u'<div style="float:left; text-align:center; width:80px;\n'
            html += u'margin-right:10px; margin-bottom:10px" > '
            html += u'<img src="%s" \n' % filename
            html += u' alt="%s" ' % _("Submit")
            html += u"onclick=\"submitLink('selectIcon','%s',1)\">\n" % icon
            html += u'<br/>%s.gif</div>\n' % icon
        return html
    
    def renderShowHideiDevices(self, idevices):
        """
        JR: Funcion que muestra la lista de idevices para mostrarlos y ocultarlos
        """
        html = "<div id=\"editorWorkspace\">\n"
        html += "<br/><br/><strong>%s</strong>\n" % _("Check iDevices you want to display:")
        html += "<ul style=\"list-style:none;\">\n"
        idevices_sort = sorted(idevices, key=lambda idevice: idevice.title)
        idevices_show = self.ideviceStore.generic + self.ideviceStore.extended
        for idevice in idevices_sort:
            html += "<li>\n"
            html += "<input type=checkbox name=\"%s\"" % idevice.title
            checked = False
            for i in idevices_show:
                if (i.title == idevice.title):
                    checked = True
            if checked:
                html += " checked=\"checked\" "
            html += ">%s</input>\n" % idevice.title
            html += "</li>\n" 
        html += "</ul>"
        html += "</div>"
        return html
Пример #17
0
class EditorPane(object):
    """
    The EditorPane is responsible for creating new idevice
    """
    def __init__(self, webServer, parent):
        """
        Initialize
        JR: anado parente para poder acceder a algunos atributos de editorpag, en concreto a showHide
        """
        self.ideviceStore = webServer.application.ideviceStore
        self.webDir = webServer.application.config.webDir
        self.styles = webServer.application.config.styleStore.getStyles()
        self.elements = []
        self.idevice = GenericIdevice("", "", "", "", "")
        self.idevice.id = self.ideviceStore.getNewIdeviceId()
        self.originalIdevice = GenericIdevice("", "", "", "", "")
        self.purpose = ""
        self.tip = ""
        self.message = ""
        self.parent = parent
        self._nameInstruc     = \
           x_(u"Your new iDevice will appear in the iDevice "
              u"pane with this title. This is a compulsory field "
              u"and you will be prompted to enter a label if you try "
              u"to submit your iDevice without one.")
        self._authorInstruc = x_(u"This is an optional field.")
        self._purposeInstruc = x_(
            u"The purpose dialogue allows you to describe"
            u" your intended purpose of the iDevice to other"
            u" potential users.")
        self._emphasisInstruc = x_(
            u"Use this pulldown to select whether or not "
            u" the iDevice should have any formatting "
            u" applied to it to distinguish "
            u"it; ie. a border and an icon.")
        self._tipInstruc = x_(u"Use this field to describe "
                              u"your intended use and the pedagogy behind "
                              u"the device's development. This can be useful "
                              u"if your iDevice is to be exported for others "
                              u"to use.")
        self._lineInstruc = x_(u"Add a single text line to an iDevice. "
                               u"Useful if you want the ability to place a "
                               u"label within the iDevice.")
        self._textBoxInstruc = x_(
            u"Add a text entry box to an iDevice. "
            u"Used for entering larger amounts of textual "
            u"content.")
        self._feedbackInstruc = x_(
            u"Add an interactive feedback field to your iDevice.")
        self._flashInstruc = x_(u"Add a flash video to your iDevice.")
        self._mp3Instruc = x_(u"Add an mp3 file to your iDevice.")
        self._attachInstruc = x_(u"Add an attachment file to your iDevice.")

        self.style = self.styles[0]

    # Properties

    nameInstruc = lateTranslate('nameInstruc')
    authorInstruc = lateTranslate('authorInstruc')
    purposeInstruc = lateTranslate('purposeInstruc')
    emphasisInstruc = lateTranslate('emphasisInstruc')
    tipInstruc = lateTranslate('tipInstruc')
    lineInstruc = lateTranslate('lineInstruc')
    textBoxInstruc = lateTranslate('textBoxInstruc')
    feedbackInstruc = lateTranslate('feedbackInstruc')
    flashInstruc = lateTranslate('flashInstruc')
    mp3Instruc = lateTranslate('mp3Instruc')
    attachInstruc = lateTranslate('attachInstruc')

    def setIdevice(self, idevice):
        """
        Sets the iDevice to edit
        """
        self.idevice = idevice.clone()
        self.idevice.id = idevice.id
        self.originalIdevice = idevice

    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()

    def __buildElements(self):
        """
        Building up element array
        """
        self.elements = []
        elementTypeMap = {
            TextField: TextEditorElement,
            TextAreaField: TextAreaEditorElement,
            ImageField: ImageEditorElement,
            FeedbackField: FeedbackEditorElement,
            MultimediaField: MultimediaEditorElement,
            FlashField: FlashEditorElement,
            AttachmentField: AttachmentEditorElement
        }

        for field in self.idevice.fields:
            elementType = elementTypeMap.get(field.__class__)

            if elementType:
                # Create an instance of the appropriate element class
                log.debug(u"createElement " + elementType.__class__.__name__ +
                          u" for " + field.__class__.__name__)
                self.elements.append(elementType(field))
            else:
                log.error(u"No element type registered for " +
                          field.__class__.__name__)

    def renderButtons(self, request):
        """
        Render the idevice being edited
        """
        html = "<font color=\"red\"><b>" + self.message + "</b></font>"

        html += "<fieldset><legend><b>" + _("Add Field") + "</b></legend>"
        html += common.submitButton("addText", _("Text Line"))
        html += common.elementInstruc(self.lineInstruc) + "<br/>"
        html += common.submitButton("addTextArea", _("Text Box"))
        html += common.elementInstruc(self.textBoxInstruc) + "<br/>"
        html += common.submitButton("addFeedback", _("Feedback"))
        html += common.elementInstruc(self.feedbackInstruc) + "<br/>"
        #  Attachments are now embeddable:
        #html += common.submitButton("addAttachment", _("Attachment"))
        #html += common.elementInstruc(self.attachInstruc) + "<br/>"
        #  MP3 fields are now embeddable:
        #html += common.submitButton("addMP3", _("MP3"))
        #html += common.elementInstruc(self.mp3Instruc) + "<br/>"
        html += "</fieldset>\n"

        html += "<fieldset><legend><b>" + _("Actions") + "</b></legend>"

        if self.idevice.edit:
            html += common.submitButton("preview", _("Preview"),
                                        not self.parent.isGeneric)
        else:
            html += common.submitButton("edit", _("Edit"))

        html += "<br/>"
        html += common.submitButton("cancel", _("Cancel"))
        #html += "</fieldset>"

        return html

    def renderIdevice(self, request):
        """
        Returns an XHTML string for rendering the new idevice
        """
        html = "<div id=\"editorWorkspace\">\n"
        html += "<script type=\"text/javascript\">\n"
        html += "<!--\n"
        html += """
            function selectStyleIcon(icon,e) {
                var div = document.getElementById("styleIcons");
                var imgs = div.getElementsByTagName("IMG");
                for (var i=0;i<imgs.length;i++) {
                    imgs[i].style.border = "1px solid #E8E8E8";
                }
                e.style.border = "1px solid #333333";            
                submitLink("selectIcon",icon,1);
            }        
            function submitLink(action, object, changed) 
            {
                var form = document.getElementById("contentForm")
                form.action.value = action;
                form.object.value = object;
                form.isChanged.value = changed;
                form.submit();
            }\n"""
        html += """
            function submitIdevice() 
            {
                var form = document.getElementById("contentForm")
                if (form.ideviceSelect.value == "newIdevice")
                    form.action.value = "newIdevice"
                else
                    form.action.value = "changeIdevice"
                form.object.value = form.ideviceSelect.value;
                form.isChanged.value = 1;
                form.submit();
            }\n"""
        html += """
            function submitStyle()
            {
                var form = document.getElementById("contentForm")
                form.action.value = "changeStyle";
                form.object.value = form.styleSelect.value;
                form.isChanged.value = 0;
                form.submit();
            }\n"""
        html += "//-->\n"
        html += "</script>\n"

        self.purpose = self.idevice.purpose.replace("\r", "")
        self.purpose = self.purpose.replace("\n", "\\n")

        self.tip = self.idevice.tip.replace("\r", "")
        self.tip = self.tip.replace("\n", "\\n")

        if self.idevice.edit:
            html += "<b>" + _("Name") + ": </b>\n"
            html += common.elementInstruc(self.nameInstruc) + "<br/>"
            html += '<input type="text" name= "title" id="title" value="%s"/>' % self.idevice.title

            this_package = None
            html += common.formField('richTextArea', this_package,
                                     _(u"Pedagogical Tip"), 'tip', '',
                                     self.tipInstruc, self.tip)

            html += "<b>" + _("Emphasis") + ":</b> "
            html += "<select onchange=\"submit();\" name=\"emphasis\">\n"

            emphasisValues = {
                Idevice.NoEmphasis: _(u"No emphasis"),
                Idevice.SomeEmphasis: _(u"Some emphasis")
            }
            for value, description in emphasisValues.items():
                html += "<option value=\"" + unicode(value) + "\" "
                if self.idevice.emphasis == value:
                    html += "selected "
                html += ">" + description + "</option>\n"

            html += "</select> \n"
            html += common.elementInstruc(self.emphasisInstruc)
            html += "<br/><br/>\n"

            if self.idevice.emphasis > 0:
                html += self.__renderStyles() + " "
                html += u'<a style="margin-right:.5em" href="javascript:void(0)" '
                html += u'onclick="showMessageBox(\'iconpanel\');">'
                html += u'%s</a>' % _('Select an icon')
                icon = self.idevice.icon
                if icon != "":

                    iconExists = False
                    myIcon = Path(G.application.config.stylesDir /
                                  self.style.get_dirname() / "icon_" +
                                  self.idevice.icon + ".gif")
                    if myIcon.exists():
                        iconExists = True
                    else:
                        myIcon = Path(G.application.config.stylesDir /
                                      self.style.get_dirname() / "icon_" +
                                      self.idevice.icon + ".png")
                        if myIcon.exists():
                            iconExists = True
                    if iconExists:
                        html += '<img style="vertical-align:middle;max-width:60px;height:auto" '
                        html += 'src="/style/%s/icon_%s' % (
                            self.style.get_dirname(), icon)
                        html += '%s"/><br />' % myIcon.ext

                html += u'<div style="display:none;z-index:99;">'
                html += u'<div id="iconpaneltitle">' + _("Icons") + '</div>'
                html += u'<div id="iconpanelcontent">'
                html += self.__renderIcons()
                html += u'</div>'
                html += u'</div>\n'
                html += u'<br style="clear:both;margin-bottom:10px" />'
            for element in self.elements:
                html += element.renderEdit()
        else:
            html += "<b>" + self.idevice.title + "</b><br/><br/>"
            for element in self.elements:
                html += element.renderPreview()
            if self.idevice.purpose != "" or self.idevice.tip != "":
                html += "<a title=\"" + _("Pedagogical Help") + "\" "
                html += "onclick=\"showMessageBox('phelp');\" "
                html += "href=\"javascript:void(0)\" style=\"cursor:help;\">\n "
                html += '<img alt="%s" src="/images/info.png" border="0" ' % _(
                    'Info')
                html += "align=\"middle\" /></a>\n"
                html += "<div style='display:none;'>"
                if self.idevice.purpose != "":
                    html += "<div id='phelptitle'>" + _('Purpose') + "</div>"
                    html += "<div id='phelpcontent'>" + self.purpose + "</div>"
                if self.idevice.tip != "":
                    html += "<div id='phelptitle'>" + _('Tip:') + "</div>"
                    html += "<div id='phelpcontent'>" + self.idevice.tip + "</div>"
                html += "</div>"
                html += "</div>\n"
        html += "</div>\n"
        self.message = ""

        return html

    def __renderStyles(self):
        """
        Return xhtml string for rendering styles select
        """
        html = '<select onchange="submitStyle();" style="display:none" name="styleSelect" id="styleSelect">\n'
        idx = 0
        isSelected = False
        for style in self.styles:
            html += "<option value='%d' " % idx
            if self.style.get_name() == style.get_name():
                html += "selected "
                isSelected = True
            html += ">" + style.get_name() + "~" + style.get_dirname(
            ) + "</option>\n"
            idx = idx + 1
        html += "</select> \n"
        # Auto-select the current style
        # This should be done with Python, not JavaScript
        # It's just a provisional solution so the user does not have to choose the right Style
        html += "<script type='text/javascript'>\
            function autoSelectStyle(){\
                var autoSelectStyle = document.getElementById('styleSelect');\
                if (autoSelectStyle.options[autoSelectStyle.value].innerHTML.split('~')[1]==top.exe_style_dirname) return false;\
                var currentStyleFolder;\
                for (var i=0; i<autoSelectStyle.options.length; i++) {\
                    currentStyleFolder = autoSelectStyle.options[i].innerHTML.split('~')[1];\
                    if (top.exe_style_dirname==currentStyleFolder) {\
                        autoSelectStyle.value=i;\
                        submitStyle();\
                    }\
                }\
            }\
            if (typeof(top.exe_style_dirname)!='undefined') {\
                autoSelectStyle();\
            }\
            \
        </script>"

        return html

    def __renderIcons(self):
        """
        Return xhtml string for dispay all icons
        """
        iconpath = self.style.get_style_dir()
        iconfiles = iconpath.files("icon_*")
        html = '<div id="styleIcons"><div style="height:300px;overflow:auto">'

        for iconfile in iconfiles:
            iconname = iconfile.namebase
            icon = iconname.split("_", 1)[1]

            iconExists = False
            iconExtension = "gif"
            myIcon = Path(G.application.config.stylesDir /
                          self.style.get_dirname() / iconname + ".gif")
            if myIcon.exists():
                iconExists = True
            else:
                myIcon = Path(G.application.config.stylesDir /
                              self.style.get_dirname() / iconname + ".png")
                if myIcon.exists():
                    iconExists = True
                    iconExtension = "png"

            if iconExists:
                filename = "/style/%s/%s.%s" % (self.style.get_dirname(),
                                                iconname, iconExtension)
                html += u'<div style="float:left; text-align:center; width:105px;\n'
                html += u'margin-right:10px; margin-bottom:15px" > '
                html += u'<img src="%s" \n' % filename
                # html += u' alt="%s" ' % _("Submit")
                # window[1] because we use Ext.MessageBox instead of libot_drag.js
                html += u"style=\"border:1px solid #E8E8E8;padding:5px;cursor:pointer;max-width:60px;height:auto\" onclick=\"window[1].selectStyleIcon('%s',this)\" title=\"%s.%s\">\n" % (
                    icon, icon, iconExtension)
                # html += u"style=\"cursor:pointer\" onclick=\"window[1].submitLink('selectIcon','%s',1)\">\n" % icon
                html += u'<br /><span style="display:inline-block;width:100px;overflow:hidden;text-overflow:ellipsis">%s.%s</span></div>\n' % (
                    icon, iconExtension)

        html += '</div></div>'

        return html