Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63602721
webstyle_templates.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, May 21, 07:05
Size
28 KB
Mime Type
text/x-python
Expires
Thu, May 23, 07:05 (2 d)
Engine
blob
Format
Raw Data
Handle
17793757
Attached To
R3600 invenio-infoscience
webstyle_templates.py
View Options
## $Id$
## CDS Invenio WebStyle templates.
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN.
##
## CDS Invenio 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.
##
## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
__revision__
=
\
"$Id$"
import
time
import
cgi
import
traceback
import
urllib
import
sys
import
string
from
invenio.config
import
\
CFG_SITE_LANG
,
\
CFG_SITE_NAME
,
\
CFG_SITE_NAME_INTL
,
\
CFG_SITE_SUPPORT_EMAIL
,
\
sweburl
,
\
weburl
,
\
CFG_VERSION
from
invenio.messages
import
gettext_set_language
,
language_list_long
from
invenio.urlutils
import
make_canonical_urlargd
,
create_html_link
from
invenio.dateutils
import
convert_datecvs_to_datestruct
,
\
convert_datestruct_to_dategui
from
invenio.bibformat
import
format_record
from
invenio
import
template
websearch_templates
=
template
.
load
(
'websearch'
)
class
Template
:
def
tmpl_navtrailbox_body
(
self
,
ln
,
title
,
previous_links
,
separator
,
prolog
,
epilog
):
"""Create navigation trail box body
Parameters:
- 'ln' *string* - The language to display
- 'title' *string* - page title;
- 'previous_links' *string* - the trail content from site title until current page (both ends exlusive)
- 'prolog' *string* - HTML code to prefix the navtrail item with
- 'epilog' *string* - HTML code to suffix the navtrail item with
- 'separator' *string* - HTML code that separates two navtrail items
Output:
- text containing the navtrail
"""
# load the right message language
_
=
gettext_set_language
(
ln
)
out
=
""
if
title
!=
CFG_SITE_NAME_INTL
.
get
(
ln
,
CFG_SITE_NAME
):
out
+=
create_html_link
(
weburl
,
{
'ln'
:
ln
},
_
(
"Home"
),
{
'class'
:
'navtrail'
})
if
previous_links
:
if
out
:
out
+=
separator
out
+=
previous_links
if
title
:
if
out
:
out
+=
separator
if
title
==
CFG_SITE_NAME_INTL
.
get
(
ln
,
CFG_SITE_NAME
):
# hide site name, print Home instead
out
+=
cgi
.
escape
(
_
(
"Home"
))
else
:
out
+=
cgi
.
escape
(
title
)
return
cgi
.
escape
(
prolog
)
+
out
+
cgi
.
escape
(
epilog
)
def
tmpl_page
(
self
,
req
=
None
,
ln
=
CFG_SITE_LANG
,
description
=
""
,
keywords
=
""
,
userinfobox
=
""
,
navtrailbox
=
""
,
pageheaderadd
=
""
,
boxlefttop
=
""
,
boxlefttopadd
=
""
,
boxleftbottom
=
""
,
boxleftbottomadd
=
""
,
boxrighttop
=
""
,
boxrighttopadd
=
""
,
boxrightbottom
=
""
,
boxrightbottomadd
=
""
,
titleprologue
=
""
,
title
=
""
,
titleepilogue
=
""
,
body
=
""
,
lastupdated
=
None
,
pagefooteradd
=
""
,
uid
=
0
,
secure_page_p
=
0
,
navmenuid
=
""
,
metaheaderadd
=
""
,
rssurl
=
weburl
+
"/rss"
):
"""Creates a complete page
Parameters:
- 'ln' *string* - The language to display
- 'description' *string* - description goes to the metadata in the header of the HTML page
- 'keywords' *string* - keywords goes to the metadata in the header of the HTML page
- 'userinfobox' *string* - the HTML code for the user information box
- 'navtrailbox' *string* - the HTML code for the navigation trail box
- 'pageheaderadd' *string* - additional page header HTML code
- 'boxlefttop' *string* - left-top box HTML code
- 'boxlefttopadd' *string* - additional left-top box HTML code
- 'boxleftbottom' *string* - left-bottom box HTML code
- 'boxleftbottomadd' *string* - additional left-bottom box HTML code
- 'boxrighttop' *string* - right-top box HTML code
- 'boxrighttopadd' *string* - additional right-top box HTML code
- 'boxrightbottom' *string* - right-bottom box HTML code
- 'boxrightbottomadd' *string* - additional right-bottom box HTML code
- 'title' *string* - the title of the page
- 'titleprologue' *string* - what to print before page title
- 'titleepilogue' *string* - what to print after page title
- 'body' *string* - the body of the page
- 'lastupdated' *string* - when the page was last updated
- 'uid' *int* - user ID
- 'pagefooteradd' *string* - additional page footer HTML code
- 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not?
- 'navmenuid' *string* - the id of the navigation item to highlight for this page
- 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page
- 'rssurl' *string* - the url of the RSS feed for this page
Output:
- HTML code of the page
"""
# load the right message language
_
=
gettext_set_language
(
ln
)
out
=
self
.
tmpl_pageheader
(
req
,
ln
=
ln
,
headertitle
=
title
,
description
=
description
,
keywords
=
keywords
,
metaheaderadd
=
metaheaderadd
,
userinfobox
=
userinfobox
,
navtrailbox
=
navtrailbox
,
pageheaderadd
=
pageheaderadd
,
secure_page_p
=
secure_page_p
,
navmenuid
=
navmenuid
,
rssurl
=
rssurl
)
+
"""
<div class="pagebody">
<div class="pagebodystripeleft">
<div class="pageboxlefttop">%(boxlefttop)s</div>
<div class="pageboxlefttopadd">%(boxlefttopadd)s</div>
<div class="pageboxleftbottomadd">%(boxleftbottomadd)s</div>
<div class="pageboxleftbottom">%(boxleftbottom)s</div>
</div>
<div class="pagebodystriperight">
<div class="pageboxrighttop">%(boxrighttop)s</div>
<div class="pageboxrighttopadd">%(boxrighttopadd)s</div>
<div class="pageboxrightbottomadd">%(boxrightbottomadd)s</div>
<div class="pageboxrightbottom">%(boxrightbottom)s</div>
</div>
<div class="pagebodystripemiddle">
%(titleprologue)s
<h1 class="headline">%(title)s</h1>
%(titleepilogue)s
%(body)s
</div>
</div>
"""
%
{
'boxlefttop'
:
boxlefttop
,
'boxlefttopadd'
:
boxlefttopadd
,
'boxleftbottom'
:
boxleftbottom
,
'boxleftbottomadd'
:
boxleftbottomadd
,
'boxrighttop'
:
boxrighttop
,
'boxrighttopadd'
:
boxrighttopadd
,
'boxrightbottom'
:
boxrightbottom
,
'boxrightbottomadd'
:
boxrightbottomadd
,
'titleprologue'
:
titleprologue
,
'title'
:
cgi
.
escape
(
title
),
'titleepilogue'
:
titleepilogue
,
'body'
:
body
,
}
+
self
.
tmpl_pagefooter
(
req
,
ln
=
ln
,
lastupdated
=
lastupdated
,
pagefooteradd
=
pagefooteradd
)
return
out
def
tmpl_pageheader
(
self
,
req
,
ln
=
CFG_SITE_LANG
,
headertitle
=
""
,
description
=
""
,
keywords
=
""
,
userinfobox
=
""
,
navtrailbox
=
""
,
pageheaderadd
=
""
,
uid
=
0
,
secure_page_p
=
0
,
navmenuid
=
"admin"
,
metaheaderadd
=
""
,
rssurl
=
weburl
+
"/rss"
):
"""Creates a page header
Parameters:
- 'ln' *string* - The language to display
- 'headertitle' *string* - the second part of the page HTML title
- 'description' *string* - description goes to the metadata in the header of the HTML page
- 'keywords' *string* - keywords goes to the metadata in the header of the HTML page
- 'userinfobox' *string* - the HTML code for the user information box
- 'navtrailbox' *string* - the HTML code for the navigation trail box
- 'pageheaderadd' *string* - additional page header HTML code
- 'uid' *int* - user ID
- 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not?
- 'navmenuid' *string* - the id of the navigation item to highlight for this page
- 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page
- 'rssurl' *string* - the url of the RSS feed for this page
Output:
- HTML code of the page headers
"""
# load the right message language
_
=
gettext_set_language
(
ln
)
if
headertitle
==
CFG_SITE_NAME_INTL
.
get
(
ln
,
CFG_SITE_NAME
):
headertitle
=
_
(
"Home"
)
out
=
"""\
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>%(sitename)s: %(headertitle)s</title>
<link rev="made" href="mailto:%(sitesupportemail)s" />
<link rel="stylesheet" href="%(cssurl)s/img/cds.css" type="text/css" />
<link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="%(description)s" />
<meta name="keywords" content="%(keywords)s" />
%(metaheaderadd)s
</head>
<body>
<div class="pageheader">
<!-- replaced page header -->
<div style="background-image: url(%(cssurl)s/img/header_background.gif);">
<table class="headerbox">
<tr>
<td class="headerboxbodylogo">
%(sitename)s
</td>
<td align="right" valign="top" class="userinfoboxbody">
%(userinfobox)s
</td>
</tr>
<tr>
<td class="headerboxbody" valign="bottom" align="left">
<table class="headermodulebox" width="100%%"><tr><td class="headermoduleboxbodyblanklast"> </td></tr></table>
</td>
<td class="headerboxbody" valign="bottom" align="left">
<table class="headermodulebox">
<tr>
<td class="headermoduleboxbodyblank">
</td>
<td class="headermoduleboxbodyblank">
</td>
<td class="headermoduleboxbody%(search_selected)s">
<a class="header%(search_selected)s" href="%(weburl)s/?ln=%(ln)s">%(msg_search)s</a>
</td>
<td class="headermoduleboxbodyblank">
</td>
<td class="headermoduleboxbody%(submit_selected)s">
<a class="header%(submit_selected)s" href="%(weburl)s/submit?ln=%(ln)s">%(msg_submit)s</a>
</td>
<td class="headermoduleboxbodyblank">
</td>
<td class="headermoduleboxbody%(personalize_selected)s">
<a class="header%(personalize_selected)s" href="%(sweburl)s/youraccount/display?ln=%(ln)s">%(msg_personalize)s</a>
</td>
<td class="headermoduleboxbodyblank">
</td>
<td class="headermoduleboxbody%(help_selected)s">
<a class="header%(help_selected)s" href="%(weburl)s/help/%(langlink)s">%(msg_help)s</a>
</td>
<td class="headermoduleboxbodyblanklast">
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<table class="navtrailbox">
<tr>
<td class="navtrailboxbody">
%(navtrailbox)s
</td>
</tr>
</table>
<!-- end replaced page header -->
%(pageheaderadd)s
</div>
"""
%
{
'weburl'
:
weburl
,
'sweburl'
:
sweburl
,
'cssurl'
:
secure_page_p
and
sweburl
or
weburl
,
'rssurl'
:
rssurl
,
'ln'
:
ln
,
'langlink'
:
ln
!=
CFG_SITE_LANG
and
'?ln='
+
ln
or
''
,
'sitename'
:
CFG_SITE_NAME_INTL
.
get
(
ln
,
CFG_SITE_NAME
),
'headertitle'
:
cgi
.
escape
(
headertitle
),
'sitesupportemail'
:
CFG_SITE_SUPPORT_EMAIL
,
'description'
:
cgi
.
escape
(
description
),
'keywords'
:
cgi
.
escape
(
keywords
),
'metaheaderadd'
:
metaheaderadd
,
'userinfobox'
:
userinfobox
,
'navtrailbox'
:
navtrailbox
,
'pageheaderadd'
:
pageheaderadd
,
'search_selected'
:
navmenuid
==
'search'
and
"selected"
or
""
,
'submit_selected'
:
navmenuid
==
'submit'
and
"selected"
or
""
,
'personalize_selected'
:
navmenuid
.
startswith
(
'your'
)
and
"selected"
or
""
,
'help_selected'
:
navmenuid
==
'help'
and
"selected"
or
""
,
'msg_search'
:
_
(
"Search"
),
'msg_submit'
:
_
(
"Submit"
),
'msg_personalize'
:
_
(
"Personalize"
),
'msg_help'
:
_
(
"Help"
),
'languagebox'
:
self
.
tmpl_language_selection_box
(
req
,
ln
),
}
return
out
def
tmpl_pagefooter
(
self
,
req
=
None
,
ln
=
CFG_SITE_LANG
,
lastupdated
=
None
,
pagefooteradd
=
""
):
"""Creates a page footer
Parameters:
- 'ln' *string* - The language to display
- 'lastupdated' *string* - when the page was last updated
- 'pagefooteradd' *string* - additional page footer HTML code
Output:
- HTML code of the page headers
"""
# load the right message language
_
=
gettext_set_language
(
ln
)
if
lastupdated
:
if
lastupdated
.
startswith
(
"$Date: "
)
or
\
lastupdated
.
startswith
(
"$Id: "
):
lastupdated
=
convert_datestruct_to_dategui
(
\
convert_datecvs_to_datestruct
(
lastupdated
),
ln
=
ln
)
msg_lastupdated
=
_
(
"Last updated"
)
+
": "
+
lastupdated
else
:
msg_lastupdated
=
""
out
=
"""
<div class="pagefooter">
%(pagefooteradd)s
<!-- replaced page footer -->
<div class="pagefooterstripeleft">
%(sitename)s :: <a class="footer" href="%(weburl)s/?ln=%(ln)s">%(msg_search)s</a> :: <a class="footer" href="%(weburl)s/submit?ln=%(ln)s">%(msg_submit)s</a> :: <a class="footer" href="%(sweburl)s/youraccount/display?ln=%(ln)s">%(msg_personalize)s</a> :: <a class="footer" href="%(weburl)s/help/%(langlink)s">%(msg_help)s</a>
<br />
%(msg_poweredby)s <a class="footer" href="http://cdsware.cern.ch/">CDS Invenio</a> v%(version)s
<br />
%(msg_maintainedby)s <a class="footer" href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a>
<br />
%(msg_lastupdated)s
</div>
<div class="pagefooterstriperight">
%(languagebox)s
</div>
<!-- replaced page footer -->
</div>
</body>
</html>
"""
%
{
'weburl'
:
weburl
,
'sweburl'
:
sweburl
,
'ln'
:
ln
,
'langlink'
:
ln
!=
CFG_SITE_LANG
and
'?ln='
+
ln
or
''
,
'sitename'
:
CFG_SITE_NAME_INTL
.
get
(
ln
,
CFG_SITE_NAME
),
'sitesupportemail'
:
CFG_SITE_SUPPORT_EMAIL
,
'msg_search'
:
_
(
"Search"
),
'msg_submit'
:
_
(
"Submit"
),
'msg_personalize'
:
_
(
"Personalize"
),
'msg_help'
:
_
(
"Help"
),
'msg_poweredby'
:
_
(
"Powered by"
),
'msg_maintainedby'
:
_
(
"Maintained by"
),
'msg_lastupdated'
:
msg_lastupdated
,
'languagebox'
:
self
.
tmpl_language_selection_box
(
req
,
ln
),
'version'
:
CFG_VERSION
,
'pagefooteradd'
:
pagefooteradd
,
}
return
out
def
tmpl_language_selection_box
(
self
,
req
,
language
=
CFG_SITE_LANG
):
"""Take URLARGS and LANGUAGE and return textual language
selection box for the given page.
Parameters:
- 'req' - The mod_python request object
- 'language' *string* - The selected language
"""
# load the right message language
_
=
gettext_set_language
(
language
)
# Work on a copy in order not to bork the arguments of the caller
argd
=
{}
if
req
and
req
.
args
:
argd
.
update
(
cgi
.
parse_qs
(
req
.
args
))
parts
=
[]
for
(
lang
,
lang_namelong
)
in
language_list_long
():
if
lang
==
language
:
parts
.
append
(
'<span class="langinfo">
%s
</span>'
%
lang_namelong
)
else
:
# Update the 'ln' argument in the initial request
argd
[
'ln'
]
=
lang
if
req
and
req
.
uri
:
args
=
urllib
.
quote
(
req
.
uri
,
'/:?'
)
+
make_canonical_urlargd
(
argd
,
{})
else
:
args
=
""
parts
.
append
(
create_html_link
(
args
,
{},
lang_namelong
,
{
'class'
:
"langinfo"
}))
return
_
(
"This site is also available in the following languages:"
)
+
\
"<br />"
+
' '
.
join
(
parts
)
def
tmpl_error_box
(
self
,
ln
,
title
,
verbose
,
req
,
errors
):
"""Produces an error box.
Parameters:
- 'title' *string* - The title of the error box
- 'ln' *string* - The selected language
- 'verbose' *bool* - If lots of information should be displayed
- 'req' *object* - the request object
- 'errors' list of tuples (error_code, error_message)
"""
# load the right message language
_
=
gettext_set_language
(
ln
)
info_not_available
=
_
(
"N/A"
)
if
title
is
None
:
if
errors
:
title
=
_
(
"Error"
)
+
':
%s
'
%
errors
[
0
][
1
]
else
:
title
=
_
(
"Internal Error"
)
browser_s
=
_
(
"Browser"
)
if
req
:
try
:
if
req
.
headers_in
.
has_key
(
'User-Agent'
):
browser_s
+=
': '
+
req
.
headers_in
[
'User-Agent'
]
else
:
browser_s
+=
': '
+
info_not_available
host_s
=
req
.
hostname
page_s
=
req
.
unparsed_uri
client_s
=
req
.
connection
.
remote_ip
except
:
# FIXME: bad except
browser_s
+=
': '
+
info_not_available
host_s
=
page_s
=
client_s
=
info_not_available
else
:
browser_s
+=
': '
+
info_not_available
host_s
=
page_s
=
client_s
=
info_not_available
error_s
=
''
sys_error_s
=
''
traceback_s
=
''
if
verbose
>=
1
:
if
sys
.
exc_info
()[
0
]:
sys_error_s
=
_
(
"System Error"
)
+
':
%s
%s
\n
'
%
\
(
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
])
if
errors
:
errs
=
''
for
error_tuple
in
errors
:
try
:
errs
+=
"
%s%s
:
%s
\n
"
%
(
' '
*
6
,
error_tuple
[
0
],
error_tuple
[
1
])
except
:
errs
+=
"
%s%s
\n
"
%
(
' '
*
6
,
error_tuple
)
errs
=
errs
[
6
:
-
2
]
# get rid of trainling ','
error_s
=
_
(
"Error"
)
+
':
%s
")'
%
errs
+
"
\n
"
else
:
error_s
=
_
(
"Error"
)
+
': '
+
info_not_available
if
verbose
>=
9
:
traceback_s
=
_
(
"Traceback"
)
+
':
\n
%s
'
%
\
string
.
join
(
traceback
.
format_tb
(
sys
.
exc_info
()[
2
]),
"
\n
"
)
out
=
"""
<table class="errorbox">
<thead>
<tr>
<th class="errorboxheader">
<p> %(title)s %(sys1)s %(sys2)s</p>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="errorboxbody">
<p>%(contact)s</p>
<blockquote><pre>
URI: http://%(host)s%(page)s
%(time_label)s: %(time)s
%(browser)s
%(client_label)s: %(client)s
%(error)s%(sys_error)s%(traceback)s
</pre></blockquote>
</td>
</tr>
<tr>
<td>
<form action="%(weburl)s/error/send" method="post">
%(send_error_label)s
<input class="adminbutton" type="submit" value="%(send_label)s" />
<input type="hidden" name="header" value="%(esc_title)s %(esc_sys1)s %(esc_sys2)s" />
<input type="hidden" name="url" value="URI: http://%(host)s%(page)s" />
<input type="hidden" name="time" value="Time: %(time)s" />
<input type="hidden" name="browser" value="%(browser)s" />
<input type="hidden" name="client" value="Client: %(client)s" />
<input type="hidden" name="error" value="%(esc_error)s" />
<input type="hidden" name="sys_error" value="%(sys_error)s" />
<input type="hidden" name="traceback" value="%(esc_traceback)s" />
<input type="hidden" name="referer" value="%(referer)s" />
</form>
</td>
</tr>
</tbody>
</table>
"""
%
{
'title'
:
title
,
'esc_title'
:
title
.
replace
(
'"'
,
'"'
),
'time_label'
:
_
(
"Time"
),
'client_label'
:
_
(
"Client"
),
'send_error_label'
:
\
_
(
"Please send an error report to the Administrator."
),
'send_label'
:
_
(
"Send error report"
),
'sys1'
:
sys
.
exc_info
()[
0
]
or
''
,
'sys2'
:
sys
.
exc_info
()[
1
]
or
''
,
'esc_sys1'
:
str
((
sys
.
exc_info
()[
0
]
or
''
))
.
replace
(
'"'
,
'""'
),
'esc_sys2'
:
str
((
sys
.
exc_info
()[
1
]
or
''
))
.
replace
(
'"'
,
'""'
),
'contact'
:
\
_
(
"Please contact
%s
quoting the following information:"
)
%
\
(
'<a href="mailto:'
+
urllib
.
quote
(
CFG_SITE_SUPPORT_EMAIL
)
+
'">'
+
\
CFG_SITE_SUPPORT_EMAIL
+
'</a>'
),
'host'
:
host_s
,
'page'
:
page_s
,
'time'
:
time
.
strftime
(
"
%d
/%b/%Y:%H:%M:%S %z"
),
'browser'
:
browser_s
,
'client'
:
client_s
,
'esc_error'
:
error_s
,
'error'
:
error_s
.
replace
(
'"'
,
'""'
),
'traceback'
:
traceback_s
,
'esc_traceback'
:
traceback_s
.
replace
(
'"'
,
'""'
),
'sys_error'
:
sys_error_s
,
'weburl'
:
weburl
,
'referer'
:
page_s
!=
info_not_available
and
\
(
"http://"
+
host_s
+
page_s
)
or
\
info_not_available
}
return
out
def
detailed_record_container
(
self
,
content
,
recid
,
tabs
,
ln
=
CFG_SITE_LANG
,
show_similar_rec_p
=
True
,
creationdate
=
None
,
modificationdate
=
None
,
show_short_rec_p
=
True
):
"""Prints the box displayed in detailed records pages, with tabs at the top.
Parameters:
- content *string* - the content displayed inside the box
- recid *int* - the id of the displayed record
- tabs ** - the tabs displayed at the top of the box.
- ln *string* - the language of the page in which the box is displayed
- show_similar_rec_p *bool* print 'similar records' link in the box
- creationdate *string* - the creation date of the displayed record
- modificationdate *string* - the last modification date of the displayed record
- show_short_rec_p *boolean* - prints a very short version of the record as reminder.
"""
# load the right message language
_
=
gettext_set_language
(
ln
)
# If no tabs, simply returns the content
if
len
(
tabs
)
==
0
:
return
content
# Build the tabs at the top of the page
out_tabs
=
''
if
len
(
tabs
)
>
1
:
first_tab
=
True
for
(
label
,
url
,
selected
,
enabled
)
in
tabs
:
css_class
=
[]
if
selected
:
css_class
.
append
(
'on'
)
if
first_tab
:
css_class
.
append
(
'first'
)
first_tab
=
False
if
not
enabled
:
css_class
.
append
(
'disabled'
)
css_class
=
' class="
%s
"'
%
' '
.
join
(
css_class
)
if
not
enabled
:
out_tabs
+=
'<li
%(class)s
><a>
%(label)s
</a></li>'
%
\
{
'class'
:
css_class
,
'label'
:
label
}
else
:
out_tabs
+=
'<li
%(class)s
><a href="
%(url)s
">
%(label)s
</a></li>'
%
\
{
'class'
:
css_class
,
'url'
:
url
,
'label'
:
label
}
if
out_tabs
!=
''
:
out_tabs
=
''' <div class="detailedrecordtabs">
<div>
<ul class="detailedrecordtabs">%s</ul>
<div style="clear:both;height:00px"> </div></div>
</div>'''
%
out_tabs
# Add the clip icon and the brief record reminder if necessary
if
show_short_rec_p
:
record_details
=
format_record
(
recID
=
recid
,
of
=
'hs'
,
ln
=
ln
)
content
=
'''<div id="detailedrecordshortreminder">
<div id="clip"> </div>
<div id="HB">
%(record_details)s
</div>
</div>
<div style="clear:both;height:1px"> </div>
%(content)s
'''
%
{
'content'
:
content
,
'record_details'
:
record_details
}
# Print the content
out
=
"""
<div class="detailedrecordbox">
%(tabs)s
<div class="detailedrecordboxcontent">
<div class="top-left-folded"></div>
<div class="top-right-folded"></div>
<div class="inside">
<!--<div style="height:0.1em;"> </div>
<p class="notopgap"> </p>-->
%(content)s
<p class="nobottomgap" > </p>
</div>
<div class="bottom-left-folded">%(dates)s</div>
<div class="bottom-right-folded" style="text-align:right"><span class="moreinfo" style="margin-right:25px">%(similar)s</span></div>
</div>
</div>
<br/>
"""
%
{
'tabs'
:
out_tabs
,
'content'
:
content
,
'similar'
:
create_html_link
(
websearch_templates
.
build_search_url
(
p
=
'recid:
%d
'
%
\
recid
,
rm
=
'wrd'
,
ln
=
ln
),
{},
_
(
"Similar records"
),
{
'class'
:
"moreinfo"
}),
'dates'
:
creationdate
and
'<div class="recordlastmodifiedbox" style="float:left;position:relative;margin-left:1px">
%(dates)s
</div>'
%
{
'dates'
:
_
(
"Record created
%(x_date_creation)s
, last modified
%(x_date_modification)s
"
)
%
\
{
'x_date_creation'
:
creationdate
,
'x_date_modification'
:
modificationdate
},
}
or
''
}
return
out
def
detailed_record_mini_panel
(
self
,
recid
,
ln
=
CFG_SITE_LANG
,
format
=
'hd'
,
files
=
''
,
reviews
=
''
,
actions
=
''
):
"""Displays the actions dock at the bottom of the detailed record
pages.
Parameters:
- recid *int* - the id of the displayed record
- ln *string* - interface language code
- format *string* - the format used to display the record
- files *string* - the small panel representing the fulltext
- reviews *string* - the small panel representing the reviews
- actions *string* - the small panel representing the possible user's action
"""
# load the right message language
_
=
gettext_set_language
(
ln
)
out
=
"""
<br />
<div class="detailedrecordminipanel">
<div class="top-left"></div><div class="top-right"></div>
<div class="inside">
<div id="detailedrecordminipanelfile" style="width:33%%;float:left;text-align:center;margin-top:0">
%(files)s
</div>
<div id="detailedrecordminipanelreview" style="width:33%%;float:left;text-align:center">
%(reviews)s
</div>
<div id="detailedrecordminipanelactions" style="width:33%%;float:right;text-align:right;">
%(actions)s
</div>
<div style="clear:both;margin-bottom: 0;"></div>
</div>
<div class="bottom-left"></div><div class="bottom-right"></div>
</div>
"""
%
{
'weburl'
:
weburl
,
'ln'
:
ln
,
'recid'
:
recid
,
'files'
:
files
,
'reviews'
:
reviews
,
'actions'
:
actions
,
}
return
out
Event Timeline
Log In to Comment