From b0c52c13d6b12d925e9a4cc149c847b0ee9d5d29 Mon Sep 17 00:00:00 2001 From: Ivan Tyagov <ivan@nexedi.com> Date: Tue, 15 Mar 2011 08:49:17 +0000 Subject: [PATCH] Use Page Template to render HTML. Show version & language information. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44277 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../erp5_base/Base_getSummaryAsHTML.xml | 125 +++++---------- .../erp5_base/Base_viewSummaryAsHTML.xml | 147 ++++++++++++++++++ bt5/erp5_base/bt/revision | 2 +- 3 files changed, 189 insertions(+), 85 deletions(-) create mode 100644 bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewSummaryAsHTML.xml diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_getSummaryAsHTML.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_getSummaryAsHTML.xml index 9b61bcc503..703356cdbc 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_getSummaryAsHTML.xml +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_getSummaryAsHTML.xml @@ -50,16 +50,13 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string encoding="cdata"><![CDATA[ - -"""\n - Generate a HTML Summary in search result mode.\n + <value> <string>"""\n + Generate a HTML Summary of an object.\n Use "No ZODB" approach if possible. \n """\n request = context.REQUEST\n -is_temp_object = context.isTempObject()\n -is_web_mode = request.get(\'is_web_mode\', False)\n portal = context.getPortalObject()\n +is_temp_object = context.isTempObject()\n \n if not is_temp_object:\n web_site = request.get(\'current_web_site\', context.getWebSiteValue())\n @@ -67,108 +64,68 @@ else:\n web_site = portal.restrictedTraverse(context.web_site)\n web_site_url = web_site.absolute_url()\n \n -\n -def getOwnerHTML():\n - html = []\n - if is_temp_object:\n - html.append(\'<a href="Base_redirectToPersonByReference?reference=%s" class="owner-link"/> %s </a>\' \\\n - %(context.owner, context.owner))\n - else:\n - owners = context.Base_getOwnerInfoList()\n - for owner in owners:\n - html.append(\'<a href="%s" class="owner-link"/>%s</a>\' %(owner[\'url\'], owner[\'title\']))\n - return "".join(html)\n -\n -def getReferenceHTML():\n - html = ""\n - if is_temp_object:\n - reference = context.reference\n - permanent_url = \'%s/%s\' %(web_site_url, context.path)\n - document_web_section_list = [web_site.restrictedTraverse(x) for x in context.section_list]\n - else:\n - reference = context.getReference()\n - permanent_url = web_site.getPermanentURL(context)\n - document_web_section_list = web_site.getWebSectionValueList(context)\n - if reference:\n - html += \'<a href="%s" class="reference-link">%s</a>\' %(permanent_url, reference)\n - for section in document_web_section_list:\n - html += \'<a href="%s" class="section-link">%s</a>\' %(section.absolute_url(), section.getCompactTranslatedTitle())\n - return html\n -\n if is_temp_object:\n uid = context.uid\n url = context.path\n title = context.title\n - popup = \'Loading ..\'\n path = context.path\n - modification_date = context.Base_FormatDate(context.modification_date)\n + version = context.version\n + language = context.language\n + modification_date = context.modification_date\n found = context.text\n portal_type = context.object_portal_type\n - owner_html = getOwnerHTML()\n + # empty as we still have no ZODB object to render it (it will be done with AJAX\n + inline_popup = None\n + owner_url = "Base_redirectToPersonByReference?reference=%s" %context.owner\n + owner_title = context.owner\n + reference = context.reference\n + reference_url = \'%s/%s\' %(web_site_url, path)\n + document_web_section_list = [web_site.restrictedTraverse(x) for x in context.section_list]\n else:\n # a real ZODB object\n uid = context.getUid()\n url = context.absolute_url()\n title = context.getTitle() or (hasattr(context, \'getReference\') and context.getReference()) or context.getId()\n - portal_type = context.getTranslatedPortalType()\n - popup = context.Document_getPopupInfo(web_site)\n - if isinstance(popup, unicode):\n - popup = popup.encode(\'utf-8\')\n + path = context.getRelativeUrl()\n + version = context.getVersion()\n + language = context.getLanguage()\n + modification_date = context.modification_date\n + inline_popup = context.Document_getPopupInfo(web_site)\n + if isinstance(inline_popup, unicode):\n + inline_popup = inline_popup.encode(\'utf-8\')\n found = context.Base_showFoundText()\n - owner_html = getOwnerHTML()\n - modification_date = context.Base_FormatDate(context.modification_date)\n - path = \'\'\n + portal_type = context.getTranslatedPortalType()\n + owner_list = context.Base_getOwnerInfoList()\n + if len(owner_list):\n + owner_url = owner_list[0]["url"]\n + owner_title = owner_list[0]["title"]\n + else:\n + owner_url = None\n + owner_title = None\n + reference = context.getReference\n + reference_url = web_site.getPermanentURL(context)\n + document_web_section_list = web_site.getWebSectionValueList(context)\n \n local_parameter_dict = {\n \'uid\': uid,\n \'url\': url,\n \'title\': title,\n - \'reference_html\': getReferenceHTML(),\n \'portal_type\': portal_type,\n - \'popup\': popup,\n \'found\': found,\n - \'owner_html\': owner_html,\n \'modification_date\': modification_date,\n \'path\': path,\n -}\n -\n -html = """\n - <div onmouseout="showPopik(\'dom_popup_listbox_%(uid)s\', false, \'%(path)s\')" \n - onmouseover="showPopik(\'dom_popup_listbox_%(uid)s\', true, \'%(path)s\')" \n - class="item_nohighlight"> \n - <div id="dom_popup_listbox_%(uid)s"\n - class="search_popup" \n - style="z-index: 100; display: none;">\n - %(popup)s\n - </div>\n - <div> \n - <a href="%(url)s">\n - <span class="search_result_title">%(title)s</span>\n - <span class="search_result_portal_type">%(portal_type)s</span>\n - </a>\n - </div>\n -\n - <span class="searchDetails found">\n - %(found)s\n - </span>\n -\n - <div class="searchDetails coordinates">\n - %(reference_html)s\n -\n - %(owner_html)s\n -\n - <a class="history-link" href="%(url)s/Base_viewHistory">\n - %(modification_date)s\n - </a>\n - \n - </div>\n - \n - </div>""" % local_parameter_dict\n + \'version\': version,\n + \'language\': language,\n + \'owner_url\': owner_url,\n + \'owner_title\': owner_title,\n + \'reference\': reference,\n + \'reference_url\': reference_url,\n + \'document_web_section_list\': document_web_section_list,\n + \'inline_popup\': inline_popup}\n \n +html = context.Base_viewSummaryAsHTML(**local_parameter_dict)\n return html\n - - -]]></string> </value> +</string> </value> </item> <item> <key> <string>_params</string> </key> diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewSummaryAsHTML.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewSummaryAsHTML.xml new file mode 100644 index 0000000000..498a934d23 --- /dev/null +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewSummaryAsHTML.xml @@ -0,0 +1,147 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_text</string> </key> + <value> <unicode encoding="cdata"><![CDATA[ + +<tal:block tal:define="uid options/uid;\n + path options/path;\n + title options/title;\n + portal_type options/portal_type;\n + url options/url;\n + found options/found;\n + version options/version;\n + language options/language;\n + owner_url options/owner_url;\n + owner_title options/owner_title;\n + reference options/reference;\n + reference_url options/reference_url;\n + document_web_section_list options/document_web_section_list;\n + modification_date python: context.Base_FormatDate(options[\'modification_date\']);\n + inline_popup options/inline_popup">\n +\n + <div class="search-text-summary"\n + tal:attributes="id uid;\n + onmouseover string:showPopik(\'${uid}\', \'${path}\')"> \n +\n + <div style="display: none;"\n + tal:condition="inline_popup"\n + tal:attributes="id string:hidden_popup_listbox_${uid}"\n + tal:content="structure inline_popup"/>\n +\n + <div class="search-header"> \n +\n + <a tal:attributes="href url">\n + <span class="search_result_title"\n + tal:content="title"/>\n + <span class="search_result_portal_type"\n + tal:content="portal_type"/>\n + </a>\n +\n + <img src="km_img/find.png" \n + tal:attributes="onClick string:togglePreview(\'${uid}\', \'${path}\')"\n + title="Turn On / Off preview"/>\n +\n + </div>\n +\n + <span class="search-details found"\n + tal:content="structure found"/>\n +\n + <div class="search-details coordinates">\n + \n + <a class="reference-link"\n + tal:content="reference"\n + tal:attributes="href reference_url"\n + title="Reference"/>\n +\n + - <span class="version" \n + tal:content="version"\n + title="Version"/>\n + - <span class="language" \n + tal:content="language"\n + title="Language"/>\n +\n + <tal:block tal:condition="document_web_section_list">\n + - \n + <a class="section-link"\n + tal:repeat="section document_web_section_list"\n + tal:attributes="href section/absolute_url"\n + tal:content="section/getCompactTranslatedTitle"\n + title="Publication section"/>\n + </tal:block>\n +\n + <tal:block tal:condition="python: owner_title is not None and owner_url is not None">\n + -<a class="owner-link" \n + tal:attributes="href owner_url"\n + tal:content="owner_title"\n + title="Owner"/>\n + </tal:block> \n +\n + -<a class="history-link" \n + tal:attributes="href string:${url}/Base_viewHistory"\n + tal:content="modification_date"\n + title="Modification date"/>\n + \n + </div>\n + </div>\n +\n +</tal:block> + +]]></unicode> </value> + </item> + <item> + <key> <string>content_type</string> </key> + <value> <string>text/html</string> </value> + </item> + <item> + <key> <string>expand</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Base_viewSummaryAsHTML</string> </value> + </item> + <item> + <key> <string>output_encoding</string> </key> + <value> <string>iso-8859-15</string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <unicode></unicode> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision index 0c8ddea6ab..36c9eca540 100644 --- a/bt5/erp5_base/bt/revision +++ b/bt5/erp5_base/bt/revision @@ -1 +1 @@ -955 \ No newline at end of file +957 \ No newline at end of file -- 2.30.9