Commit 54388447 authored by Kevin Deldycke's avatar Kevin Deldycke

Previous version was an empty shell, here is the version with true code in it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8577 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5f029329
...@@ -74,24 +74,62 @@ ...@@ -74,24 +74,62 @@
TODO: add parameters to filter by object type / object visibility (admin or not) and security\n TODO: add parameters to filter by object type / object visibility (admin or not) and security\n
"""\n """\n
\n \n
# Get default site root if no root defined\n def WebDocument_getURI(object):\n
if site_root in (\'\', None):\n """\n
site_root = context.WebSite_getSiteValue()\n This function return the right URI depending of the object type.\n
"""\n
if object.getPortalType() == \'Web Page\':\n
return object.getReference()\n
else:\n
return object.getId()\n
\n \n
# site_map is the tree of sections/subsections/documents of the web site.\n \n
\n
# Get default site root\n
site_root = context.WebSite_getSiteValue()\n
\n
# \'site_content\' is the tree of sections/subsections/documents of the web site.\n
# Here is the description of data structure:\n # Here is the description of data structure:\n
# site_map = [ {} <- first_level object #1\n # site_content = [ {} <- first_level object #1\n
# , {} <- first_level object #2\n # , {} <- first_level object #2\n
# , {\'sub-content\': []} <- first_level object #3 with sub objects\n # , {\'sub-content\': []} <- first_level object #3 with sub objects\n
# ]\n # ]\n
# {dict} contain properties of the object\n # {dict} contain properties of the object\n
# [list] can be ordered\n # [list] can be ordered\n
site_content = []\n
\n \n
site_map = [{ \'sub-content\':\'\'}]\n # Start browsing the site from main sections\n
for section in site_root.WebSite_getMainSectionList():\n
sub_doc_list = section.WebSite_getDocumentValueList() or []\n
sub_content_list = []\n
section_url = section.absolute_url()\n
# Get sub sections and content of each main section\n
for sub_doc in sub_doc_list:\n
sub_content_list.append({\n
\'title\' : sub_doc.ERP5Web_getVerboseTitle()\n
, \'link\' : "%s/%s" % (section_url, WebDocument_getURI(sub_doc))\n
, \'object\' : sub_doc\n
, \'sub-content\': []\n
})\n
site_content.append({\n
\'title\' : section.ERP5Web_getVerboseTitle()\n
, \'link\' : section_url\n
, \'object\' : section\n
, \'sub-content\': sub_content_list\n
})\n
\n \n
main_sections = site_root.WebSite_getMainSection()\n if include_site:\n
# Add the most upper object: the website site itself\n
site_map = {\n
\'title\' : "%s - Home" % (site_root.getTitle())\n
, \'link\' : site_root.absolute_url()\n
, \'object\' : site_root\n
, \'sub-content\' : site_content\n
}\n
else:\n
site_map = site_content\n
\n \n
return repr(main_sections)\n return site_map\n
]]></string> </value> ]]></string> </value>
...@@ -104,17 +142,13 @@ return repr(main_sections)\n ...@@ -104,17 +142,13 @@ return repr(main_sections)\n
</item> </item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_web/WebSite_getSiteMap</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value> <value>
<none/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>site_root=None</string> </value> <value> <string>show_pages=True, include_site=True, depth_limit=None</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -134,19 +168,27 @@ return repr(main_sections)\n ...@@ -134,19 +168,27 @@ return repr(main_sections)\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>1</int> </value> <value> <int>3</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>site_root</string> <string>show_pages</string>
<string>None</string> <string>include_site</string>
<string>depth_limit</string>
<string>WebDocument_getURI</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>site_root</string>
<string>site_content</string>
<string>_getiter_</string>
<string>section</string>
<string>sub_doc_list</string>
<string>sub_content_list</string>
<string>section_url</string>
<string>sub_doc</string>
<string>site_map</string> <string>site_map</string>
<string>main_sections</string>
<string>repr</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -159,6 +201,8 @@ return repr(main_sections)\n ...@@ -159,6 +201,8 @@ return repr(main_sections)\n
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple> <tuple>
<int>1</int>
<int>1</int>
<none/> <none/>
</tuple> </tuple>
</value> </value>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment