""" A more advanced menu based theme """ import pyflag.conf config=pyflag.conf.ConfObject() import pyflag.FlagFramework as FlagFramework import pyflag.Registry as Registry import pyflag.Theme as Theme import pyflag.DB as DB class Menu(Theme.BasicTheme): """ Class to implement the Menus theme """ def make_menu_javascript(self,query): """ Creates the javascript function required to generate the menu """ result = '''''' submenus = '' ## Find all families: module_list = Registry.REPORTS.get_families() Theme.order_families(module_list) for k in module_list: items = 0 submenu_text = '\n' % k ## Add the reports in the family: report_list = Registry.REPORTS.family[k] for r in report_list: if r.hidden: continue submenu_text+="\n" % (r.name, k, r.name) items += 1 continue if items > 0: result += "\n" % (k,k,k.replace(" "," ")) submenus += submenu_text + "
" return result + "" + submenus def menu(self,flag,query, result): """ We just draw the main page for the database here """ result.heading("PyFlag - Forensic and Log Analysis GUI") left = result.__class__(result) tmp = result.__class__(result) tmp.icon("logo.png") left.link(tmp,url="http://www.pyflag.net/") right = result.__class__(result) right.text("PyFlag is a GPL Project maintained at http://www.pyflag.net/ . \nThis is version %s" % config.VERSION ,style="red",font="bold") result.row(tmp,right,align="center") return result def raw_render(self,data='',ui=None,title="FLAG - Forensic Log Analysis GUI. %s" % config.VERSION): return data def naked_render(self,data='',ui=None,title=None): """ Render the ui with minimal interventions. We put a toolbar here only if we need it. We will only need it if some of our UIs need to draw a toolbar icon - otherwise it would be lost. """ if ui.toolbar_ui: toolbar_str = ui.toolbar_ui.__str__ () else: toolbar_str = '' result = u''' ''' if toolbar_str: result += '''
%s
''' % (toolbar_str) result += data ## result +="
" result += u"" return result def render(self, ui=None, data='', title="FLAG - Forensic Log Analysis GUI. %s" % config.VERSION): self.menu_javascript = self.make_menu_javascript(ui.defaults) if not ui.toolbar_ui: toolbar_str='  ' else: toolbar_str=ui.toolbar_ui.__str__() case_selector = ui.__class__(ui) try: case_selector.case_selector() except:pass try: query = ui.defaults except: query = {} result = ''' %s \n''' % (title, query.get("__pyflag_parent","main"), query.get("__pyflag_name", "main")) result += self.menu_javascript result += '''
%s
%s
''' % (toolbar_str,case_selector) result += data result += "
" + self.footer # print result return result