Esempio n. 1
0
    def render_GET(self, request=None):
        """
        Returns an XHTML string for viewing this page
        if 'request' is not passed, will generate psedo/debug html
        """
        log.debug(u"render_GET " + repr(request))

        topNode = self.package.root
        if request is not None:
            # Process args
            for key, value in request.args.items():
                request.args[key] = [unicode(value[0], 'utf8')]
            topNode = self._process(request)

        #Update other authoring pages that observes the current package
        activeClient = None
        if "action" in request.args:
            if request.args['clientHandleId'][0] == "":
                raise (Exception("Not clientHandleId defined"))
            for client in self.parent.clientHandleFactory.clientHandles.values(
            ):
                if request.args['clientHandleId'][0] != client.handleId:
                    if client.handleId in self.parent.authoringPages:
                        destNode = None
                        if request.args["action"][0] == "move":
                            destNode = request.args[
                                "move" + request.args["object"][0]][0]
                        client.call('eXe.app.getController("MainTab").updateAuthoring', request.args["action"][0], \
                            request.args["object"][0], request.args["isChanged"][0], request.args["currentNode"][0], destNode)
                else:
                    activeClient = client

            if request.args["action"][0] == "done":
                if activeClient:
                    return "<body onload='location.replace(\"" + request.path + "?clientHandleId=" + activeClient.handleId + "\")'/>"
                else:
                    log.error("No active client")

        self.blocks = []
        self.__addBlocks(topNode)
        html = self.__renderHeader()
        html += u'<body onload="onLoadHandler();" class="exe-authoring-page js">\n'
        html += u"<form method=\"post\" "

        if request is None:
            html += u'action="NO_ACTION"'
        else:
            html += u"action=\"" + request.path + "#currentBlock\""
        html += u" id=\"contentForm\">"
        html += u'<div id="main">\n'
        html += common.hiddenField(u"action")
        html += common.hiddenField(u"object")
        html += common.hiddenField(u"isChanged", u"0")
        html += common.hiddenField(u"currentNode", unicode(topNode.id))
        html += common.hiddenField(u'clientHandleId',
                                   request.args['clientHandleId'][0])
        html += u'<!-- start authoring page -->\n'
        html += u'<div id="nodeDecoration">\n'
        html += u'<div id="headerContent">\n'
        html += u'<h1 id="nodeTitle">'
        html += escape(topNode.titleLong)
        html += u'</h1>\n'
        html += u'</div>\n'
        html += u'</div>\n'
        counter = 0
        msg = ''
        for block in self.blocks:
            # If we don't have a client, try to get it from request
            if activeClient is None:
                for client in self.parent.clientHandleFactory.clientHandles.values(
                ):
                    if request.args['clientHandleId'][0] == client.handleId:
                        activeClient = client

            if not activeClient is None:
                for resources in block.idevice.userResources:
                    if resources.warningMsg != u'':
                        counter += 1
                        msg += (_('Warning: %s') % resources.warningMsg)
                        # Remove warning message
                        resources.warningMsg = ''
            if counter > 0:
                activeClient.alert(msg)
            html += block.render(self.package.style)

        html += u'</div>'
        style = G.application.config.styleStore.getStyle(self.package.style)

        html += common.renderLicense(self.package.license, "authoring")
        html += common.renderFooter(self.package.footer)

        if style.hasValidConfig:
            html += style.get_edition_extra_body()
        html += '<script type="text/javascript">$exeAuthoring.ready()</script>\n'
        html += common.footer()

        html = html.encode('utf8')
        return html
Esempio n. 2
0
    def render_GET(self, request=None):
        """
        Returns an XHTML string for viewing this page
        if 'request' is not passed, will generate psedo/debug html
        """
        log.debug(u"render_GET "+repr(request))

        topNode = self.package.root
        if request is not None:
            # Process args
            for key, value in request.args.items():
                request.args[key] = [unicode(value[0], 'utf8')]
            topNode = self._process(request)

        #Update other authoring pages that observes the current package
        if "action" in request.args:
            if request.args['clientHandleId'][0] == "":
                raise(Exception("Not clientHandleId defined"))
            activeClient = None
            for client in self.parent.clientHandleFactory.clientHandles.values():
                if request.args['clientHandleId'][0] != client.handleId:
                    if client.handleId in self.parent.authoringPages:
                        destNode = None
                        if request.args["action"][0] == "move":
                            destNode = request.args["move" + request.args["object"][0]][0]
                        client.call('eXe.app.getController("MainTab").updateAuthoring', request.args["action"][0], \
                            request.args["object"][0], request.args["isChanged"][0], request.args["currentNode"][0], destNode)
                else:
                    activeClient = client

            if request.args["action"][0] == "done":
                if activeClient:
                    return "<body onload='location.replace(\"" + request.path + "?clientHandleId=" + activeClient.handleId + "\")'/>"
                else:
                    log.error("No active client")

        self.blocks = []
        self.__addBlocks(topNode)
        html  = self.__renderHeader()
        html += u'<body onload="onLoadHandler();" class="exe-authoring-page js">\n'
        html += u"<form method=\"post\" "

        if request is None:
            html += u'action="NO_ACTION"'
        else:
            html += u"action=\""+request.path+"#currentBlock\""
        html += u" id=\"contentForm\">"
        html += u'<div id="main">\n'
        html += common.hiddenField(u"action")
        html += common.hiddenField(u"object")
        html += common.hiddenField(u"isChanged", u"0")
        html += common.hiddenField(u"currentNode", unicode(topNode.id))
        html += common.hiddenField(u'clientHandleId', request.args['clientHandleId'][0])
        html += u'<!-- start authoring page -->\n'
        html += u'<div id="nodeDecoration">\n'
        html += u'<div id="headerContent">\n'
        html += u'<h1 id="nodeTitle">\n'
        html += escape(topNode.titleLong)
        html += u'</h1>\n'
        html += u'</div>\n'
        html += u'</div>\n'

        for block in self.blocks:
            html += block.render(self.package.style)

        html += u'</div>'
        style = G.application.config.styleStore.getStyle(self.package.style)
        
        html += common.renderLicense(self.package.license,"authoring")
        html += common.renderFooter(self.package.footer)
        
        if style.hasValidConfig:
            html += style.get_edition_extra_body()
        html += '<script type="text/javascript">$exeAuthoring.ready()</script>\n'
        html += common.footer()

        html = html.encode('utf8')
        return html
Esempio n. 3
0
 def renderLicense(self):
     """
     Returns an XHTML string rendering the license.
     """
     return common.renderLicense(self.node.package.license)
Esempio n. 4
0
 def renderLicense(self):
     """
     Returns an XHTML string rendering the license.
     """
     return common.renderLicense(self.node.package.license)