67 lines
2.5 KiB
Python
67 lines
2.5 KiB
Python
# w.c.s. - web application for online forms
|
|
# Copyright (C) 2005-2010 Entr'ouvert
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from quixote import get_response, get_request, get_publisher, get_session
|
|
from quixote.html import htmltext, TemplateIO
|
|
|
|
from qommon import get_cfg
|
|
from qommon import _
|
|
|
|
def generate_header_menu(selected = None):
|
|
return get_publisher().get_backoffice_root().generate_header_menu(selected=selected)
|
|
|
|
def generate_user_info():
|
|
if not get_request().user:
|
|
return ''
|
|
|
|
user = get_request().user
|
|
if user:
|
|
user = get_session().get_user_object()
|
|
username = user.display_name
|
|
else:
|
|
username = _('Unknown')
|
|
|
|
r = TemplateIO(html=True)
|
|
logout_url = get_publisher().get_root_url() + 'logout'
|
|
r += htmltext('<ul class="user-info">')
|
|
r += htmltext('<li class="ui-name">%s</li>') % username
|
|
r += htmltext('<li class="ui-logout"><a href="%s">%s</a></li>') % (logout_url, _('logout'))
|
|
|
|
if get_publisher().backoffice_help_url and \
|
|
get_request().language in get_publisher().backoffice_help_url:
|
|
help_url = get_publisher().backoffice_help_url[get_request().language]
|
|
get_response().add_javascript(['jquery-ui.js'])
|
|
r += htmltext('<li class="ui-help"><a href="%s">%s</a></li>') % (help_url, _('help'))
|
|
r += htmltext('</ul>')
|
|
return r.getvalue()
|
|
|
|
|
|
def html_top(section, title = None, scripts = None):
|
|
header_menu = generate_header_menu(section)
|
|
user_info = generate_user_info()
|
|
if not scripts:
|
|
script = ''
|
|
else:
|
|
script = '\n'.join(['<script src="%s" type="text/javascript"></script>' % x for x in scripts])
|
|
|
|
org_name = get_cfg('sp', {}).get('organization_name', get_publisher().APP_NAME)
|
|
site_name = get_cfg('misc', {}).get('sitename', org_name)
|
|
sitetitle = _('Back Office of %s') % site_name
|
|
if title:
|
|
sitetitle += ' - '
|
|
|
|
get_response().filter.update(locals())
|