Example #1
0
File: skin.py Project: hforge/itws
    def build_footer_namespace(self, context):
        data = self.footer_data
        ns = get_menu_namespace(context,
            data['depth'], data['show_first_child'],
            flat=data['flat'], src=data['src'])

        here = context.resource
        # Manipulate directly the table handler
        footer = context.site_root.get_resource('%s/menu' % data['src'])
        handler = footer.handler
        records = list(handler.get_records_in_order())
        get_value = handler.get_record_value
        prefix = here.get_pathto(footer)
        # HOOK the namespace
        for index, item in enumerate(ns.get('items', [])):
            record = records[index]
            title = get_value(record, 'title')
            path = get_value(record, 'path')
            html_content = get_value(record, 'html_content')
            item['html'] = None
            if not path and not title and html_content:
                html = set_prefix(html_content, '%s/' % prefix)
                item['html'] = html
        ns['separator'] = data.get('separator', '|')

        # admin bar
        ns['admin_bar'] = get_admin_bar(footer.parent) # menu folder

        return ns
Example #2
0
    def get_namespace(self, resource, context):
        # title
        title = resource.get_title(fallback=False)
        menu = resource.get_resource(resource.order_path)
        handler = menu.handler

        is_active = resource.get_property('active')
        ids = list(handler.get_record_ids_in_order())
        if not ids or not is_active:
            return {'content': None,
                    'title': title,
                    'display': False,
                    'admin_bar': None}

        if resource.get_property('random'):
            id = choice(ids)
        else:
            id = ids[0]

        record = handler.get_record(id)
        data = handler.get_record_value(record, 'data')
        here = context.resource
        content = set_prefix(data, prefix='%s/' % here.get_pathto(menu))
        # admin bar
        admin_bar = get_admin_bar(resource)

        return {'content': content,
                'title': title,
                'display': True,
                'admin_bar': admin_bar}
Example #3
0
    def build_footer_namespace(self, context):
        data = self.footer_data
        ns = get_menu_namespace(context, data["depth"], data["show_first_child"], flat=data["flat"], src=data["src"])

        here = context.resource
        # Manipulate directly the table handler
        footer = context.site_root.get_resource("%s/menu" % data["src"])
        handler = footer.handler
        records = list(handler.get_records_in_order())
        get_value = handler.get_record_value
        prefix = here.get_pathto(footer)
        # HOOK the namespace
        for index, item in enumerate(ns.get("items", [])):
            record = records[index]
            title = get_value(record, "title")
            path = get_value(record, "path")
            html_content = get_value(record, "html_content")
            item["html"] = None
            if not path and not title and html_content:
                html = set_prefix(html_content, "%s/" % prefix)
                item["html"] = html
        ns["separator"] = data.get("separator", "|")

        # admin bar
        ns["admin_bar"] = get_admin_bar(footer.parent)  # menu folder

        return ns