def pageheaderonly(title, navtrail="", description="", keywords="", uid=0,
                   cdspageheaderadd="", language=CFG_SITE_LANG, req=None,
                   secure_page_p=0, verbose=1, navmenuid="admin",
                   navtrail_append_title_p=1, metaheaderadd="",
                   rssurl=CFG_SITE_URL+"/rss", body_css_classes=None):
    """Return just the beginning of page(), with full headers.
       Suitable for the search results page and any long-taking scripts."""

    return webstyle_templates.tmpl_pageheader(req,
                      ln = language,
                      headertitle = title,
                      description = description,
                      keywords = keywords,
                      metaheaderadd = metaheaderadd,
                      userinfobox = create_userinfobox_body(req, uid, language),
                      useractivities_menu = create_useractivities_menu(req, uid, navmenuid, language),
                      adminactivities_menu = create_adminactivities_menu(req, uid, navmenuid, language),
                      navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                            and title or '',
                                                            navtrail,
                                                            language=language),
                      uid = uid,
                      secure_page_p = secure_page_p,
                      pageheaderadd = cdspageheaderadd,
                      navmenuid = navmenuid,
                      rssurl = rssurl,
                      body_css_classes=body_css_classes)
Пример #2
0
def pageheaderonly(title, navtrail="", description="", keywords="", uid=0,
                   cdspageheaderadd="", language=CFG_SITE_LANG, req=None,
                   secure_page_p=0, verbose=1, navmenuid="admin",
                   navtrail_append_title_p=1, metaheaderadd="",
                   rssurl=CFG_SITE_URL+"/rss", body_css_classes=None):
    """Return just the beginning of page(), with full headers.
       Suitable for the search results page and any long-taking scripts."""
    if req is not None:
        if uid is None:
            uid = getUid(uid)
        secure_page_p = req.is_https() and 1 or 0
    return webstyle_templates.tmpl_pageheader(req,
                      ln = language,
                      headertitle = title,
                      description = description,
                      keywords = keywords,
                      metaheaderadd = metaheaderadd,
                      userinfobox = create_userinfobox_body(req, uid, language),
                      useractivities_menu = create_useractivities_menu(req, uid, navmenuid, language),
                      adminactivities_menu = create_adminactivities_menu(req, uid, navmenuid, language),
                      navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                            and title or '',
                                                            navtrail,
                                                            language=language),
                      uid = uid,
                      secure_page_p = secure_page_p,
                      pageheaderadd = cdspageheaderadd,
                      navmenuid = navmenuid,
                      rssurl = rssurl,
                      body_css_classes=body_css_classes)
Пример #3
0
def page(title,
         body,
         navtrail="",
         description="",
         keywords="",
         metaheaderadd="",
         uid=None,
         cdspageheaderadd="",
         cdspageboxlefttopadd="",
         cdspageboxleftbottomadd="",
         cdspageboxrighttopadd="",
         cdspageboxrightbottomadd="",
         cdspagefooteradd="",
         lastupdated="",
         language=CFG_SITE_LANG,
         verbose=1,
         titleprologue="",
         titleepilogue="",
         secure_page_p=0,
         req=None,
         errors=[],
         warnings=[],
         navmenuid="admin",
         navtrail_append_title_p=1,
         of="",
         rssurl=CFG_SITE_URL + "/rss",
         show_title_p=True,
         body_css_classes=None):
    """page(): display CDS web page
        input: title of the page
               body of the page in html format
               description goes to the metadata in the header of the HTML page
               keywords goes to the metadata in the header of the html page
               metaheaderadd goes to further metadata in the header of the html page
               cdspageheaderadd is a message to be displayed just under the page header
               cdspageboxlefttopadd is a message to be displayed in the page body on left top
               cdspageboxleftbottomadd is a message to be displayed in the page body on left bottom
               cdspageboxrighttopadd is a message to be displayed in the page body on right top
               cdspageboxrightbottomadd is a message to be displayed in the page body on right bottom
               cdspagefooteradd is a message to be displayed on the top of the page footer
               lastupdated is a text containing the info on last update (optional)
               language is the language version of the page
               verbose is verbosity of the page (useful for debugging)
               titleprologue is to be printed right before page title
               titleepilogue is to be printed right after page title
               req is the mod_python request object
               errors is the list of error codes as defined in the moduleName_config.py file of the calling module
               log is the string of data that should be appended to the log file (errors automatically logged)
               secure_page_p is 0 or 1 and tells whether we are to use HTTPS friendly page elements or not
               navmenuid the section of the website this page belongs (search, submit, baskets, etc.)
               navtrail_append_title_p is 0 or 1 and tells whether page title is appended to navtrail
               of is an output format (use xx for xml output (e.g. AJAX))
               rssfeed is the url of the RSS feed for this page
               show_title_p is 0 or 1 and tells whether page title should be displayed in body of the page
       output: the final cds page with header, footer, etc.
    """

    _ = gettext_set_language(language)
    if req and uid is None:
        uid = getUid(req)
        if CFG_EXTERNAL_AUTH_USING_SSO and not isGuestUser(uid):
            ## If the user is logged in and we are using SSO
            ## this trick will keep the SSO session alive
            ## (SSO session need an https connection)
            body += """<img src="%s/img/keep_sso_connection_alive.gif"
                    alt=" " width="0" height="0"
                    style="visibility : hidden;" />""" % CFG_SITE_SECURE_URL
    elif uid is None:
        ## 0 means generic guest user.
        uid = 0
    if of == 'xx':
        #xml output (e.g. AJAX calls) => of=xx
        req.content_type = 'text/xml'
        impl = getDOMImplementation()
        output = impl.createDocument(None, "invenio-message", None)
        root = output.documentElement
        body_node = output.createElement('body')
        body_text = output.createCDATASection(unicode(body, 'utf_8'))
        body_node.appendChild(body_text)
        root.appendChild(body_node)
        if errors:
            errors_node = output.createElement('errors')
            errors = get_msgs_for_code_list(errors, 'error', language)
            register_errors(errors, 'error', req)
            for (error_code, error_msg) in errors:
                error_node = output.createElement('error')
                error_node.setAttribute('code', error_code)
                error_text = output.createTextNode(error_msg)
                error_node.appendChild(error_text)
                errors_node.appendChild(error_node)
            root.appendChild(errors_node)
        if warnings:
            warnings_node = output.createElement('warnings')
            warnings = get_msgs_for_code_list(warnings, 'warning', language)
            register_errors(warnings, 'warning')
            for (warning_code, warning_msg) in warnings:
                warning_node = output.createElement('warning')
                warning_node.setAttribute('code', warning_code)
                warning_text = output.createTextNode(warning_msg)
                warning_node.appendChild(warning_text)
                warnings_node.appendChild(warning_node)
            root.appendChild(warnings_node)
        return output.toprettyxml(encoding="utf-8")

    else:
        #usual output
        # if there are event
        if warnings:
            warnings = get_msgs_for_code_list(warnings, 'warning', language)
            register_errors(warnings, 'warning')

        # if there are errors
        if errors:
            errors = get_msgs_for_code_list(errors, 'error', language)
            register_errors(errors, 'error', req)
            body = create_error_box(req, errors=errors, ln=language)

        return webstyle_templates.tmpl_page(req, ln=language,
                          description = description,
                          keywords = keywords,
                          metaheaderadd = metaheaderadd,
                          userinfobox = create_userinfobox_body(req, uid, language),
                          useractivities_menu = create_useractivities_menu(req, uid, navmenuid, language),
                          adminactivities_menu = create_adminactivities_menu(req, uid, navmenuid, language),
                          navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                                and title or '',
                                                                navtrail,
                                                                language=language),
                          uid = uid,
                          secure_page_p = secure_page_p,
                          pageheaderadd = cdspageheaderadd,
                          boxlefttop = CFG_WEBSTYLE_CDSPAGEBOXLEFTTOP,
                          boxlefttopadd = cdspageboxlefttopadd,
                          boxleftbottomadd = cdspageboxleftbottomadd,
                          boxleftbottom = CFG_WEBSTYLE_CDSPAGEBOXLEFTBOTTOM,
                          boxrighttop = CFG_WEBSTYLE_CDSPAGEBOXRIGHTTOP,
                          boxrighttopadd = cdspageboxrighttopadd,
                          boxrightbottomadd = cdspageboxrightbottomadd,
                          boxrightbottom = CFG_WEBSTYLE_CDSPAGEBOXRIGHTBOTTOM,
                          titleprologue = titleprologue,
                          title = title,
                          titleepilogue = titleepilogue,
                          body = body,
                          lastupdated = lastupdated,
                          pagefooteradd = cdspagefooteradd,
                          navmenuid = navmenuid,
                          rssurl = rssurl,
                          show_title_p = show_title_p,
                          body_css_classes=body_css_classes)
def page(title, body, navtrail="", description="", keywords="",
         metaheaderadd="", uid=None,
         cdspageheaderadd="", cdspageboxlefttopadd="",
         cdspageboxleftbottomadd="", cdspageboxrighttopadd="",
         cdspageboxrightbottomadd="", cdspagefooteradd="", lastupdated="",
         language=CFG_SITE_LANG, verbose=1, titleprologue="",
         titleepilogue="", secure_page_p=0, req=None, errors=[], warnings=[], navmenuid="admin",
         navtrail_append_title_p=1, of="", rssurl=CFG_SITE_URL+"/rss", show_title_p=True,
         body_css_classes=None):

    """page(): display CDS web page
        input: title of the page
               body of the page in html format
               description goes to the metadata in the header of the HTML page
               keywords goes to the metadata in the header of the html page
               metaheaderadd goes to further metadata in the header of the html page
               cdspageheaderadd is a message to be displayed just under the page header
               cdspageboxlefttopadd is a message to be displayed in the page body on left top
               cdspageboxleftbottomadd is a message to be displayed in the page body on left bottom
               cdspageboxrighttopadd is a message to be displayed in the page body on right top
               cdspageboxrightbottomadd is a message to be displayed in the page body on right bottom
               cdspagefooteradd is a message to be displayed on the top of the page footer
               lastupdated is a text containing the info on last update (optional)
               language is the language version of the page
               verbose is verbosity of the page (useful for debugging)
               titleprologue is to be printed right before page title
               titleepilogue is to be printed right after page title
               req is the mod_python request object
               errors is the list of error codes as defined in the moduleName_config.py file of the calling module
               log is the string of data that should be appended to the log file (errors automatically logged)
               secure_page_p is 0 or 1 and tells whether we are to use HTTPS friendly page elements or not
               navmenuid the section of the website this page belongs (search, submit, baskets, etc.)
               navtrail_append_title_p is 0 or 1 and tells whether page title is appended to navtrail
               of is an output format (use xx for xml output (e.g. AJAX))
               rssfeed is the url of the RSS feed for this page
               show_title_p is 0 or 1 and tells whether page title should be displayed in body of the page
       output: the final cds page with header, footer, etc.
    """

    _ = gettext_set_language(language)
    if req and uid is None:
        uid = getUid(req)
        if CFG_EXTERNAL_AUTH_USING_SSO and not isGuestUser(uid):
            ## If the user is logged in and we are using SSO
            ## this trick will keep the SSO session alive
            ## (SSO session need an https connection)
            body += """<img src="%s/img/keep_sso_connection_alive.gif"
                    alt=" " width="0" height="0"
                    style="visibility : hidden;" />""" % CFG_SITE_SECURE_URL
    elif uid is None:
        ## 0 means generic guest user.
        uid = 0
    if of == 'xx':
        #xml output (e.g. AJAX calls) => of=xx
        req.content_type = 'text/xml'
        impl = getDOMImplementation()
        output = impl.createDocument(None, "invenio-message", None)
        root = output.documentElement
        body_node = output.createElement('body')
        body_text = output.createCDATASection(unicode(body, 'utf_8'))
        body_node.appendChild(body_text)
        root.appendChild(body_node)
        if errors:
            errors_node = output.createElement('errors')
            errors = get_msgs_for_code_list(errors, 'error', language)
            register_errors(errors, 'error', req)
            for (error_code, error_msg) in errors:
                error_node = output.createElement('error')
                error_node.setAttribute('code', error_code)
                error_text = output.createTextNode(error_msg)
                error_node.appendChild(error_text)
                errors_node.appendChild(error_node)
            root.appendChild(errors_node)
        if warnings:
            warnings_node = output.createElement('warnings')
            warnings = get_msgs_for_code_list(warnings, 'warning', language)
            register_errors(warnings, 'warning')
            for (warning_code, warning_msg) in warnings:
                warning_node = output.createElement('warning')
                warning_node.setAttribute('code', warning_code)
                warning_text = output.createTextNode(warning_msg)
                warning_node.appendChild(warning_text)
                warnings_node.appendChild(warning_node)
            root.appendChild(warnings_node)
        return output.toprettyxml(encoding="utf-8" )

    else:
        #usual output
        # if there are event
        if warnings:
            warnings = get_msgs_for_code_list(warnings, 'warning', language)
            register_errors(warnings, 'warning')

        # if there are errors
        if errors:
            errors = get_msgs_for_code_list(errors, 'error', language)
            register_errors(errors, 'error', req)
            body = create_error_box(req, errors=errors, ln=language)

        return webstyle_templates.tmpl_page(req, ln=language,
                          description = description,
                          keywords = keywords,
                          metaheaderadd = metaheaderadd,
                          userinfobox = create_userinfobox_body(req, uid, language),
                          useractivities_menu = create_useractivities_menu(req, uid, navmenuid, language),
                          adminactivities_menu = create_adminactivities_menu(req, uid, navmenuid, language),
                          navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                                and title or '',
                                                                navtrail,
                                                                language=language),
                          uid = uid,
                          secure_page_p = secure_page_p,
                          pageheaderadd = cdspageheaderadd,
                          boxlefttop = CFG_WEBSTYLE_CDSPAGEBOXLEFTTOP,
                          boxlefttopadd = cdspageboxlefttopadd,
                          boxleftbottomadd = cdspageboxleftbottomadd,
                          boxleftbottom = CFG_WEBSTYLE_CDSPAGEBOXLEFTBOTTOM,
                          boxrighttop = CFG_WEBSTYLE_CDSPAGEBOXRIGHTTOP,
                          boxrighttopadd = cdspageboxrighttopadd,
                          boxrightbottomadd = cdspageboxrightbottomadd,
                          boxrightbottom = CFG_WEBSTYLE_CDSPAGEBOXRIGHTBOTTOM,
                          titleprologue = titleprologue,
                          title = title,
                          titleepilogue = titleepilogue,
                          body = body,
                          lastupdated = lastupdated,
                          pagefooteradd = cdspagefooteradd,
                          navmenuid = navmenuid,
                          rssurl = rssurl,
                          show_title_p = show_title_p,
                          body_css_classes=body_css_classes)
Пример #5
0
def page(title, body, navtrail="", description="", keywords="",
         metaheaderadd="", uid=None,
         cdspageheaderadd="", cdspageboxlefttopadd="",
         cdspageboxleftbottomadd="", cdspageboxrighttopadd="",
         cdspageboxrightbottomadd="", cdspagefooteradd="", lastupdated="",
         language=CFG_SITE_LANG, verbose=1, titleprologue="",
         titleepilogue="", secure_page_p=0, req=None, errors=None, warnings=None, navmenuid="admin",
         navtrail_append_title_p=1, of="", rssurl=CFG_SITE_URL+"/rss", show_title_p=True,
         body_css_classes=None):

    """page(): display CDS web page
        input: title of the page
               body of the page in html format
               description goes to the metadata in the header of the HTML page
               keywords goes to the metadata in the header of the html page
               metaheaderadd goes to further metadata in the header of the html page
               cdspageheaderadd is a message to be displayed just under the page header
               cdspageboxlefttopadd is a message to be displayed in the page body on left top
               cdspageboxleftbottomadd is a message to be displayed in the page body on left bottom
               cdspageboxrighttopadd is a message to be displayed in the page body on right top
               cdspageboxrightbottomadd is a message to be displayed in the page body on right bottom
               cdspagefooteradd is a message to be displayed on the top of the page footer
               lastupdated is a text containing the info on last update (optional)
               language is the language version of the page
               verbose is verbosity of the page (useful for debugging)
               titleprologue is to be printed right before page title
               titleepilogue is to be printed right after page title
               req is the mod_python request object
               log is the string of data that should be appended to the log file (errors automatically logged)
               secure_page_p is 0 or 1 and tells whether we are to use HTTPS friendly page elements or not
               navmenuid the section of the website this page belongs (search, submit, baskets, etc.)
               navtrail_append_title_p is 0 or 1 and tells whether page title is appended to navtrail
               of is an output format (use xx for xml output (e.g. AJAX))
               rssfeed is the url of the RSS feed for this page
               show_title_p is 0 or 1 and tells whether page title should be displayed in body of the page
       output: the final cds page with header, footer, etc.
    """

    _ = gettext_set_language(language)
    if req is not None:
        if uid is None:
            uid = getUid(req)
        secure_page_p = req.is_https() and 1 or 0
    if uid is None:
        ## 0 means generic guest user.
        uid = 0
    if of == 'xx':
        #xml output (e.g. AJAX calls) => of=xx
        req.content_type = 'text/xml'
        impl = getDOMImplementation()
        output = impl.createDocument(None, "invenio-message", None)
        root = output.documentElement
        body_node = output.createElement('body')
        body_text = output.createCDATASection(unicode(body, 'utf_8'))
        body_node.appendChild(body_text)
        root.appendChild(body_node)
        return output.toprettyxml(encoding="utf-8" )

    else:
        return webstyle_templates.tmpl_page(req, ln=language,
                          description = description,
                          keywords = keywords,
                          metaheaderadd = metaheaderadd,
                          userinfobox = create_userinfobox_body(req, uid, language),
                          useractivities_menu = create_useractivities_menu(req, uid, navmenuid, language),
                          adminactivities_menu = create_adminactivities_menu(req, uid, navmenuid, language),
                          navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                                and title or '',
                                                                navtrail,
                                                                language=language),
                          uid = uid,
                          secure_page_p = secure_page_p,
                          pageheaderadd = cdspageheaderadd,
                          boxlefttop = CFG_WEBSTYLE_CDSPAGEBOXLEFTTOP,
                          boxlefttopadd = cdspageboxlefttopadd,
                          boxleftbottomadd = cdspageboxleftbottomadd,
                          boxleftbottom = CFG_WEBSTYLE_CDSPAGEBOXLEFTBOTTOM,
                          boxrighttop = CFG_WEBSTYLE_CDSPAGEBOXRIGHTTOP,
                          boxrighttopadd = cdspageboxrighttopadd,
                          boxrightbottomadd = cdspageboxrightbottomadd,
                          boxrightbottom = CFG_WEBSTYLE_CDSPAGEBOXRIGHTBOTTOM,
                          titleprologue = titleprologue,
                          title = title,
                          titleepilogue = titleepilogue,
                          body = body,
                          lastupdated = lastupdated,
                          pagefooteradd = cdspagefooteradd,
                          navmenuid = navmenuid,
                          rssurl = rssurl,
                          show_title_p = show_title_p,
                          body_css_classes=body_css_classes)
Пример #6
0
def page(title,
         body,
         navtrail="",
         description="",
         keywords="",
         metaheaderadd="",
         uid=None,
         cdspageheaderadd="",
         cdspageboxlefttopadd="",
         cdspageboxleftbottomadd="",
         cdspageboxrighttopadd="",
         cdspageboxrightbottomadd="",
         cdspagefooteradd="",
         lastupdated="",
         language=CFG_SITE_LANG,
         verbose=1,
         titleprologue="",
         titleepilogue="",
         secure_page_p=0,
         req=None,
         errors=None,
         warnings=None,
         navmenuid="admin",
         navtrail_append_title_p=1,
         of="",
         rssurl=CFG_SITE_URL + "/rss",
         show_title_p=True,
         body_css_classes=None):
    """page(): display CDS web page
        input: title of the page
               body of the page in html format
               description goes to the metadata in the header of the HTML page
               keywords goes to the metadata in the header of the html page
               metaheaderadd goes to further metadata in the header of the html page
               cdspageheaderadd is a message to be displayed just under the page header
               cdspageboxlefttopadd is a message to be displayed in the page body on left top
               cdspageboxleftbottomadd is a message to be displayed in the page body on left bottom
               cdspageboxrighttopadd is a message to be displayed in the page body on right top
               cdspageboxrightbottomadd is a message to be displayed in the page body on right bottom
               cdspagefooteradd is a message to be displayed on the top of the page footer
               lastupdated is a text containing the info on last update (optional)
               language is the language version of the page
               verbose is verbosity of the page (useful for debugging)
               titleprologue is to be printed right before page title
               titleepilogue is to be printed right after page title
               req is the mod_python request object
               log is the string of data that should be appended to the log file (errors automatically logged)
               secure_page_p is 0 or 1 and tells whether we are to use HTTPS friendly page elements or not
               navmenuid the section of the website this page belongs (search, submit, baskets, etc.)
               navtrail_append_title_p is 0 or 1 and tells whether page title is appended to navtrail
               of is an output format (use xx for xml output (e.g. AJAX))
               rssfeed is the url of the RSS feed for this page
               show_title_p is 0 or 1 and tells whether page title should be displayed in body of the page
       output: the final cds page with header, footer, etc.
    """

    _ = gettext_set_language(language)
    if req is not None:
        if uid is None:
            uid = getUid(req)
        secure_page_p = req.is_https() and 1 or 0
    if uid is None:
        ## 0 means generic guest user.
        uid = 0
    if of == 'xx':
        #xml output (e.g. AJAX calls) => of=xx
        req.content_type = 'text/xml'
        impl = getDOMImplementation()
        output = impl.createDocument(None, "invenio-message", None)
        root = output.documentElement
        body_node = output.createElement('body')
        body_text = output.createCDATASection(unicode(body, 'utf_8'))
        body_node.appendChild(body_text)
        root.appendChild(body_node)
        return output.toprettyxml(encoding="utf-8")

    else:
        return webstyle_templates.tmpl_page(req, ln=language,
                          description = description,
                          keywords = keywords,
                          metaheaderadd = metaheaderadd,
                          userinfobox = create_userinfobox_body(req, uid, language),
                          useractivities_menu = create_useractivities_menu(req, uid, navmenuid, language),
                          adminactivities_menu = create_adminactivities_menu(req, uid, navmenuid, language),
                          navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                                and title or '',
                                                                navtrail,
                                                                language=language),
                          uid = uid,
                          secure_page_p = secure_page_p,
                          pageheaderadd = cdspageheaderadd,
                          boxlefttop = CFG_WEBSTYLE_CDSPAGEBOXLEFTTOP,
                          boxlefttopadd = cdspageboxlefttopadd,
                          boxleftbottomadd = cdspageboxleftbottomadd,
                          boxleftbottom = CFG_WEBSTYLE_CDSPAGEBOXLEFTBOTTOM,
                          boxrighttop = CFG_WEBSTYLE_CDSPAGEBOXRIGHTTOP,
                          boxrighttopadd = cdspageboxrighttopadd,
                          boxrightbottomadd = cdspageboxrightbottomadd,
                          boxrightbottom = CFG_WEBSTYLE_CDSPAGEBOXRIGHTBOTTOM,
                          titleprologue = titleprologue,
                          title = title,
                          titleepilogue = titleepilogue,
                          body = body,
                          lastupdated = lastupdated,
                          pagefooteradd = cdspagefooteradd,
                          navmenuid = navmenuid,
                          rssurl = rssurl,
                          show_title_p = show_title_p,
                          body_css_classes=body_css_classes)