<s> from gluon import * <EOL> from gluon . storage import Storage <EOL> from s3 import * <EOL> from s3theme import NAV , SECTION <EOL> class S3MainMenuLayout ( S3NavigationItem ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def layout ( item ) : <EOL> """<STR_LIT>""" <EOL> if not item . authorized : <EOL> item . enabled = False <EOL> item . visible = False <EOL> elif item . enabled is None or item . enabled : <EOL> item . enabled = True <EOL> item . visible = True <EOL> if item . enabled and item . visible : <EOL> items = item . render_components ( ) <EOL> if item . parent is not None : <EOL> classes = [ ] <EOL> if item . parent . parent is None : <EOL> toplevel = True <EOL> if item . opts . left : <EOL> classes . append ( "<STR_LIT>" ) <EOL> else : <EOL> toplevel = False <EOL> if item . components : <EOL> classes . append ( "<STR_LIT>" ) <EOL> if item . selected : <EOL> classes . append ( "<STR_LIT>" ) <EOL> if item . opts . icon : <EOL> classes . append ( "<STR_LIT>" ) <EOL> title = item . label <EOL> item . label = ICON ( item . opts . icon ) <EOL> else : <EOL> title = None <EOL> _class = "<STR_LIT:U+0020>" . join ( classes ) <EOL> if item . get_first ( enabled = True ) : <EOL> _href = item . url ( ) <EOL> return LI ( A ( item . label , <EOL> _href = _href , <EOL> _id = item . attr . _id , <EOL> _title = title , <EOL> ) , <EOL> UL ( items , <EOL> _class = "<STR_LIT>" <EOL> ) , <EOL> _class = _class , <EOL> ) <EOL> else : <EOL> if toplevel : <EOL> item_url = item . url ( ) <EOL> if item_url == URL ( c = "<STR_LIT:default>" , f = "<STR_LIT:index>" ) : <EOL> classes . append ( "<STR_LIT>" ) <EOL> if item . selected : <EOL> classes . append ( "<STR_LIT>" ) <EOL> _class = "<STR_LIT:U+0020>" . join ( classes ) <EOL> return LI ( A ( item . label , <EOL> _href = item_url , <EOL> _id = item . attr . _id , <EOL> ) , <EOL> _class = _class , <EOL> ) <EOL> else : <EOL> if isinstance ( item . label , dict ) : <EOL> if "<STR_LIT:name>" in item . label : <EOL> label = item . label [ "<STR_LIT:name>" ] <EOL> else : <EOL> return None <EOL> else : <EOL> label = item . label <EOL> link = A ( label , _href = item . url ( ) , _id = item . attr . _id ) <EOL> return LI ( link ) <EOL> else : <EOL> right = [ ] <EOL> left = [ ] <EOL> for item in items : <EOL> if "<STR_LIT>" in item [ "<STR_LIT>" ] : <EOL> item . remove_class ( "<STR_LIT>" ) <EOL> left . append ( item ) <EOL> else : <EOL> right . append ( item ) <EOL> if current . response . s3 . rtl : <EOL> right , left = left , right <EOL> return NAV ( UL ( LI ( A ( "<STR_LIT:U+0020>" , <EOL> _href = URL ( c = "<STR_LIT:default>" , f = "<STR_LIT:index>" ) , <EOL> ) , <EOL> _class = "<STR_LIT:name>" <EOL> ) , <EOL> LI ( A ( SPAN ( current . T ( "<STR_LIT>" ) ) ) , <EOL> _class = "<STR_LIT>" , <EOL> ) , <EOL> _class = "<STR_LIT>" , <EOL> ) , <EOL> SECTION ( UL ( left , _class = "<STR_LIT:left>" ) , <EOL> UL ( right , _class = "<STR_LIT:right>" ) , <EOL> _class = "<STR_LIT>" , <EOL> ) , <EOL> _class = "<STR_LIT>" , <EOL> data = { "<STR_LIT>" : "<STR_LIT:U+0020>" } , <EOL> ) <EOL> else : <EOL> return None <EOL> @ staticmethod <EOL> def checkbox_item ( item ) : <EOL> """<STR_LIT>""" <EOL> name = item . label <EOL> link = item . url ( ) <EOL> _id = name [ "<STR_LIT:id>" ] <EOL> if "<STR_LIT:name>" in name : <EOL> _name = name [ "<STR_LIT:name>" ] <EOL> else : <EOL> _name = "<STR_LIT>" <EOL> if "<STR_LIT:value>" in name : <EOL> _value = name [ "<STR_LIT:value>" ] <EOL> else : <EOL> _value = False <EOL> if "<STR_LIT>" in name : <EOL> _request_type = name [ "<STR_LIT>" ] <EOL> else : <EOL> _request_type = "<STR_LIT>" <EOL> if link : <EOL> if _request_type == "<STR_LIT>" : <EOL> _onchange = '''<STR_LIT>''' % ( _id , link ) <EOL> else : <EOL> _onchange = "<STR_LIT>" % link <EOL> else : <EOL> _onchange = None <EOL> return LI ( A ( INPUT ( _type = "<STR_LIT>" , <EOL> _id = _id , <EOL> _onchange = _onchange , <EOL> value = _value , <EOL> ) , <EOL> "<STR_LIT:%s>" % _name , <EOL> _nowrap = "<STR_LIT>" , <EOL> ) , <EOL> _class = "<STR_LIT>" , <EOL> ) <EOL> class S3FooterMenuLayout ( S3NavigationItem ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def layout ( item ) : <EOL> """<STR_LIT>""" <EOL> if not item . authorized : <EOL> item . enabled = item . visible = False <EOL> elif item . enabled is None or item . enabled : <EOL> item . enabled = item . visible = True <EOL> if item . enabled and item . visible : <EOL> if item . parent is not None : <EOL> return LI ( A ( item . label , <EOL> _href = item . url ( ) , <EOL> _id = item . attr . _id , <EOL> _class = "<STR_LIT>" , <EOL> ) ) <EOL> else : <EOL> items = item . render_components ( ) <EOL> logo = "<STR_LIT>" % current . request . application <EOL> return TAG [ "<STR_LIT>" ] ( UL ( items , <EOL> _class = "<STR_LIT>" , <EOL> ) , <EOL> A ( IMG ( _src = logo ) , <EOL> _href = URL ( "<STR_LIT:default>" , "<STR_LIT:index>" ) , <EOL> _class = "<STR_LIT>" , <EOL> ) , <EOL> ) <EOL> else : <EOL> return None <EOL> MF = S3FooterMenuLayout <EOL> class S3LanguageMenuLayout ( S3NavigationItem ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def layout ( item ) : <EOL> """<STR_LIT>""" <EOL> if item . enabled : <EOL> if item . components : <EOL> T = current . T <EOL> items = item . render_components ( ) <EOL> select = SELECT ( items , <EOL> _name = "<STR_LIT>" , <EOL> _title = T ( "<STR_LIT>" ) , <EOL> _onchange = '''<STR_LIT>''' , <EOL> value = T . accepted_language , <EOL> ) <EOL> form = FORM ( select , <EOL> _class = "<STR_LIT>" , <EOL> _name = "<STR_LIT>" , <EOL> _action = "<STR_LIT>" , <EOL> _method = "<STR_LIT>" , <EOL> ) <EOL> return form <EOL> else : <EOL> return OPTION ( item . opts . lang_name , <EOL> _value = item . opts . lang_code , <EOL> ) <EOL> else : <EOL> return None <EOL> def check_enabled ( self ) : <EOL> """<STR_LIT>""" <EOL> if current . deployment_settings . get_L10n_display_toolbar ( ) : <EOL> return True <EOL> else : <EOL> return False <EOL> ML = S3LanguageMenuLayout </s>
