Ejemplo n.º 1
0
    def getCssPropertySet(self,params):
        try:
            module_id = int(params[0])
        except TypeError:
            module_id = None

        try:
            widget_id = int(params[1])
        except TypeError:
            widget_id = None

        if params[2] is not None:
            session = str(params[2])
        else:
            session = None

        session_user = Session.get_current_session_user()
        if session_user.check_permission('skarphed.css.edit'):
            css_manager = CSSManager()
            if module_id == None and widget_id == None and session == None:
                css_propertyset = css_manager.get_csspropertyset()
            else:
                css_propertyset = css_manager.get_csspropertyset(module_id,widget_id,session)
            data = css_propertyset.serialize_set()
            return data
Ejemplo n.º 2
0
    def setCssPropertySet(self, params):
        data = params[0]

        session_user = Session.get_current_session_user()
        if session_user.check_permission('skarphed.css.edit'):
            css_propertyset = CSSManager().create_csspropertyset_from_serial(data)
            css_propertyset.store()
Ejemplo n.º 3
0
    def delete(self):
        db = Database()

        if self._id is None:
            raise ModuleCoreException(ModuleCoreException.get_msg(2))

        Action.delete_actions_with_widget(self)

        View.delete_mappings_with_widget(self)

        css_manager = CSSManager()
        css_manager.delete_definitions_with_widget(self)

        stmnt = "DELETE FROM WIDGETS WHERE WGT_ID = ? ;"
        db.query(stmnt,(self._id,),commit=True)
        PokeManager.add_activity(ActivityType.WIDGET)
Ejemplo n.º 4
0
            cleanup(temp_installpath)
            return errorlog
        manifest_file.close()

        #BEGIN TO VALIDATE DATA

        try:
            f = open(temp_installpath+"/general.css")
            general_css = f.read()
            f.close()
        except IOError,e:
            errorlog.append({'severity':1,
                           'type':'PackageFile',
                           'msg':'File not in Package general.css'})
        
        css_manager = CSSManager()
        general_csspropertyset = None
        try:
            general_csspropertyset = css_manager.create_csspropertyset_from_css(general_css)
            general_csspropertyset.set_type_general()
        except Exception, e:
            errorlog.append({'severity':1,
                           'type':'CSS-Data',
                           'msg':'General CSS File does not Contain Valid CSS '+str(e)})
        
        pagedata = [] # Prepared filedata for execution into Database

        for page in manifest['pages']:
            if page['filename'].endswith(".html"):
                name = page['filename'].replace(".html","",1)
            elif page['filename'].endswith(".htm"):
Ejemplo n.º 5
0
    def render(self, environ):
        View.set_currently_rendering_view(self)
        frame = """
        <!DOCTYPE html>
        <html>
          <head>
            <title>%(title)s</title>
            <link href="/static/%(page_css)s" rel="stylesheet" type="text/css">
            <link href="%(scv_css)s" rel="stylesheet" type="text/css">
            %(head)s
            <script type="text/javascript">%(ajax_script)s</script>
          </head>
          <body>
            %(body)s
          </body>
        </html>
        """
        js_frame = """<script type="text/javascript" id="%d_scr">%s</script>"""
        page = Page.get_page(self._page) 

        head = page.get_html_head()
        body = page.get_html_body()

        # Find placeholders to substitute
        
        space_name_map = page.get_space_names()
        for space, widget_id in self._space_widget_mapping.items():
            space_name = space_name_map[space]
            widget = ModuleManager.get_widget(widget_id)

            args = {} 
            if self._widget_param_mapping.has_key(widget_id):
                args.update(self._widget_param_mapping[widget_id])
            elif self._widget_param_mapping.has_key(str(widget_id)):
                args.update(self._widget_param_mapping[str(widget_id)])
            
            if self._post_widget_id == widget_id:
                # Check whether the viewjson-string is included here, too:
                # if so, eliminate it.
                post_args = FieldStorage(fp=environ['wsgi.input'],environ=environ)
                for key in post_args.keys():
                    args[key] = post_args[key].value

            widget_html = widget.render_html(args)
            widget_js = widget.render_javascript(args)
            widget_html += js_frame%(widget.get_id(), widget_js)
            body = re.sub(r"<%%\s?space:%s\s?%%>"%space_name,widget_html,body)

        for box, boxcontent in self._box_mapping.items():
            box_orientation, box_name = self.get_box_info(box)
            box_html = StringIO.StringIO()
            for widget_id in boxcontent:
                widget = ModuleManager.get_widget(widget_id)

                args = {} 
                if self._widget_param_mapping.has_key(widget_id):
                    args.update(self._widget_param_mapping[widget_id])
                elif self._widget_param_mapping.has_key(str(widget_id)):
                    args.update(self._widget_param_mapping[str(widget_id)])

                if self._post_widget_id == widget_id:
                    # Check whether the viewjson-string is included here, too:
                    # if so, eliminate it.
                    post_args = FieldStorage(fp=environ['wsgi.input'],environ=environ)
                    for key in post_args.keys():
                        args[key] = post_args[key].value
            
                widget_html = widget.render_html(args)
                widget_js = widget.render_javascript(args)
                widget_html += js_frame%(widget.get_id(), widget_js)
                box_html.write(widget_html)
                if box_orientation == BoxOrientation.VERTICAL:
                    box_html.write("<br>")

            if box_orientation == BoxOrientation.HORIZONTAL:
                body = re.sub(r"<%%\s?hbox:%s\s?%%>"%box_name,box_html.getvalue(),body)
            elif box_orientation == BoxOrientation.VERTICAL:
                body = re.sub(r"<%%\s?vbox:%s\s?%%>"%box_name,box_html.getvalue(),body)

        body = re.sub(r"<%[^%>]+%>","",body) #Replace all unused spaces with emptystring

        css_manager = CSSManager()
        css_url = css_manager.get_css_url()

        configuration = Configuration()
        title = configuration.get_entry("core.name")

        page_css = page.get_css_filename()
        View.set_currently_rendering_view(None)
        return frame%{'title':title,
                      'scv_css':css_url,
                      'page_css':page_css,
                      'ajax_script':AJAXScript,
                      'head':head,
                      'body':body}