def format_element(
        bfo,
        separator,
        display_email='yes',
        email_obfuscation_mode=CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE):
    """Display article author(s).

    @param separator: separator between authors
    @param display_email: if yes, display link to authors' emails
    @param email_obfuscation_mode: how email are protected.
    See possible values in CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE
    in invenio.conf.
    """
    ln = bfo.lang
    _ = gettext_set_language(ln)

    try:
        email_obfuscation_mode_int = int(str(email_obfuscation_mode))
    except:
        email_obfuscation_mode_int = (
            CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE)

    email_subject = _("About your article at %(x_url)s",
                      x_url=CFG_SITE_URL + bfo.user_info['uri'])

    authors = bfo.fields('100__a', escape=1)
    emails = bfo.fields('859__a', escape=1)
    # Add empty items to match length of authors list
    emails += [''] * (len(authors) - len(emails))

    authors_list = []
    for author, email in zip(authors, emails):
        if not author:
            continue
        if email.strip() and display_email.lower() == 'yes':
            authors_list.append(
                create_html_mailto(
                    email,
                    link_label=author,
                    subject=email_subject,
                    email_obfuscation_mode=email_obfuscation_mode_int))
        else:
            authors_list.append(author)

    return separator.join(authors_list)
def __add_email_button(title, uri, ln):
    """
    adds an email this article button, providing a standard subject text,
    title and a link to the article.
    """
    _ = gettext_set_language(ln)

    email_button = '<li id="mail">'
    email_body = _('''Hi,

Have a look at the following article:
<%(url)s>''') % uri
    email_button += create_html_mailto('',
                                       subject=title,
                                       body=email_body,
                                       link_label=_("Send this article"))
    email_button += '</li>'

    return email_button
def format_element(
        bfo, separator, display_email='yes',
        email_obfuscation_mode=CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE):
    """Display article author(s).

    @param separator: separator between authors
    @param display_email: if yes, display link to authors' emails
    @param email_obfuscation_mode: how email are protected.
    See possible values in CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE
    in invenio.conf.
    """
    ln = bfo.lang
    _ = gettext_set_language(ln)

    try:
        email_obfuscation_mode_int = int(str(email_obfuscation_mode))
    except:
        email_obfuscation_mode_int = (
            CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE
        )

    email_subject = _("About your article at %(x_url)s",
                      x_url=CFG_SITE_URL + bfo.user_info['uri'])

    authors = bfo.fields('100__a', escape=1)
    emails = bfo.fields('859__a', escape=1)
    # Add empty items to match length of authors list
    emails += ['']*(len(authors) - len(emails))

    authors_list = []
    for author, email in zip(authors, emails):
        if not author:
            continue
        if email.strip() and display_email.lower() == 'yes':
            authors_list.append(create_html_mailto(
                email,
                link_label=author,
                subject=email_subject,
                email_obfuscation_mode=email_obfuscation_mode_int))
        else:
            authors_list.append(author)

    return separator.join(authors_list)