def widgetActivateViewGeneration(self, params): widget_id = int(params[0]) view_id = int(params[1]) space_id = int(params[2]) view = View.get_from_id(view_id) widget = ModuleManager.get_widget(widget_id) widget.activate_viewgeneration(view, space_id) return
def get_answer(self): """ Handles an AJAX call """ widget = ModuleManager.get_widget(self._widget_id) html = widget.render_html(self._params) js = widget.render_javascript(self._params) answer = {'h':html, 'j':js} answer = json.dumps(answer) return answer
def create_action(cls, actionlist=None, view_id=None, url=None, widget_id = None, space_id = None): """ This method creates a new Action and returns it. You can create an action based on either: 1. A Page Id 2. An URL 3. A widgetId combined with a SpaceId (Both applies to the site the menu is showed in) If the combination is not valid this function will return null and not do anything in db The action will be inserted with the lowest order (execution priority) """ if actionlist is None: return None action = Action() action.set_action_list_id(actionlist.get_id()) if view_id is not None: view = View.get_from_id(view_id) if view is not None: action.set_view_id(view_id) else: return None elif url is not None: action.set_url(str(url),True) elif widget_id is not None and space_id is not None: widget = ModuleManager.get_widget(widget_id) if widget is not None: action.set_widget_space_constellation(widget_id,space_id,True) else: return None action.set_name("new action",True) db = Database() new_id = db.get_seq_next("ACT_GEN") stmnt = "SELECT MAX(ACT_ORDER) AS MAXORDER FROM ACTIONS WHERE ACT_ATL_ID = ? ;" cur = db.query(stmnt, (action.get_action_list_id(),)) row = cur.fetchonemap() if row["MAXORDER"] is not None: new_order = row["MAXORDER"]+1 else: new_order = 0 action.set_id(new_id) action.set_order(new_order) stmnt = "INSERT INTO ACTIONS (ACT_ID, ACT_NAME, ACT_ATL_ID, \ ACT_VIE_ID, ACT_SPA_ID, ACT_WGT_ID, ACT_URL, ACT_ORDER) \ VALUES (?,?,?,?,?,?,?,?) ;" db.query(stmnt, (action.get_id(), action.get_name(), action.get_action_list_id(), action.get_view_id(), action.get_space(), action.get_widget_id(), action.get_url(), action.get_order()),commit=True) PokeManager.add_activity(ActivityType.MENU) return action
def widgetDeactivateViewGeneration(self, params): widget_id = int(params[0]) widget = ModuleManager.get_widget(widget_id) widget.deactivate_viewgeneration() return
def deleteWidget(self, params): widget_id = int(params[0]) widget = ModuleManager.get_widget(widget_id) widget.delete() return
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}