コード例 #1
0
ファイル: context_processors.py プロジェクト: HiPiH/life
def cp_xml_menu(request):
    menu = Menu()
    menu.load_from_xml()
    menu.select(request.path)
    
    num = 1
    for m in menu.root_item:
        m.num = u'%s' % num
        if num == 1:
            m.margin_left_px = 0
        elif num == 2:
            m.margin_left_px = 95
        elif num == 3:
            m.margin_left_px = 175
        elif num == 4:
            m.margin_left_px = 380
        elif num == 5:
            m.margin_left_px = 470
        elif num == 6:
            m.margin_left_px = 440
        elif num == 7:
            m.margin_left_px = 510
        else:
            m.margin_left_px = 0
        
        num = num + 1
    
    return {
        'cp_xml_menu': menu.root_item,
    }
コード例 #2
0
class CPXMPMenu(object):
    def __init__(self, req):
        self.req = req
    
    def root(self):
        if not hasattr(self, "_menu"):
            self._menu = Menu(self.req)
            self._menu.load_from_xml()
            self._menu.select(self.req.path)
        return self._menu.root_item
    
    def get_selected(self):
        for item in self.root():
            if item.selected:
                return item
        return None;
コード例 #3
0
ファイル: context_processors.py プロジェクト: HiPiH/life
def cp_xml_menu(request):
    menu = Menu()
    menu.load_from_xml()
    menu.select(request.path)

    num = 1
    for m in menu.root_item:
        m.num = u'%s' % num
        if num == 1:
            m.margin_left_px = 0
        elif num == 2:
            m.margin_left_px = 95
        elif num == 3:
            m.margin_left_px = 175
        elif num == 4:
            m.margin_left_px = 380
        elif num == 5:
            m.margin_left_px = 470
        elif num == 6:
            m.margin_left_px = 440
        elif num == 7:
            m.margin_left_px = 510
        else:
            m.margin_left_px = 0

        num = num + 1

    return {
        'cp_xml_menu': menu.root_item,
    }
コード例 #4
0
 def root(self):
     if not hasattr(self, "_menu"):
         self._menu = Menu(self.req)
         self._menu.load_from_xml()
         self._menu.select(self.req.path)
     return self._menu.root_item