Commit 40a635fd authored by Ivan Tyagov's avatar Ivan Tyagov

Use existing script (WebSection_getSiteMapTree) to get tree of Web Sections.

Allow gadget to be configured (i.e. max depth, where to show collapse down / up tree icons).
parent 6f010bd7
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts04498752.63</string> </value>
<value> <string>ts07623168.89</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/css; charset=utf-8</string> </value>
<value> <string>text/css</string> </value>
</item>
<item>
<key> <string>data</string> </key>
......@@ -574,32 +574,40 @@ fieldset.gadget div.text{\n
\n
/* Gadget Browser */\n
div.gadget-website-browser {\n
padding-left:0.8em;\n
margin-top: 0.5em;\n
}\n
div.gadget-website-browser ul {\n
\n
div.gadget-website-browser ul,\n
div.gadget-website-browser li {\n
margin: 0em;\n
padding: 0em;\n
}\n
\n
div.gadget-website-browser li {\n
padding-left: 0em;\n
div.gadget-website-browser ul.level-1 {\n
padding-bottom: 0.5em;\n
}\n
\n
div.gadget-website-browser ul.first_level, \n
div.gadget-website-browser ul.second_level{\n
list-style-type: none;\n
div.gadget-website-browser ul.level-1,\n
div.gadget-website-browser ul.level-2,\n
div.gadget-website-browser ul.level-3,\n
div.gadget-website-browser ul.level-4,\n
div.gadget-website-browser ul.level-5,\n
div.gadget-website-browser ul.level-6{\n
padding-left:1em;\n
}\n
\n
div.gadget-website-browser ul.first_level {\n
padding-bottom: 0.5em;\n
div.gadget-website-browser ul.collapse-list-node{\n
list-style-type: none;\n
margin-left:-1.1em;\n
}\n
\n
div.gadget-website-browser ul.second_level{\n
padding-left: 0.7em;\n
div.gadget-website-browser .collapse-content{\n
padding-left:1em;\n
}\n
\n
div.gadget-website-browser ul.third_level{\n
padding-left: 1.4em;\n
div.gadget-website-browser .collapse-link{\n
cursor:pointer;\n
margin-left: 0.5em;\n
}\n
\n
div.gadget-website-browser a,div.gadget-website-browser a:link,\n
......@@ -607,10 +615,6 @@ div.gadget-website-browser a:active,div.gadget-website-browser a:visited {\n
font-weight: normal;\n
color: inherit;\n
}\n
div.gadget-website-browser .empty-list-node{\n
list-style-type: square;\n
margin-left: 1.4em;\n
}\n
\n
/* Gadget SubSection */\n
div.gadget-subsection {\n
......@@ -705,7 +709,7 @@ div.block fieldset.gadget-profile div.field{\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>11966</int> </value>
<value> <int>12118</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -36,62 +36,55 @@
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block metal:define-macro="renderer">\n
<ul class="first_level">\n
<li>\n
<a class="section-link"\n
tal:content="section/Base_getTitle"\n
tal:attributes="href section/absolute_url;\n
title section/Base_getTitle;"/></li>\n
<ul class="second_level">\n
<tal:block tal:define="section_list python:options.get(\'section_list\');\n
collapse_depth python:options.get(\'collapse_depth\')" >\n
\n
<tal:block tal:repeat="root_section python: filter(lambda x:x.isVisible(), section.contentValues(portal_type=\'Web Section\', sort_on=\'int_index\',checked_permission=\'View\'))">\n
<tal:block \n
tal:define="section_dom_id python: root_section.getRelativeUrl().replace(\'/\', \'_\');\n
image_dom_id python: \'image_%s\' %section_dom_id;\n
siblings python: filter(lambda x:x.isVisible(), root_section.contentValues(portal_type=\'Web Section\', sort_on=\'int_index\',checked_permission=\'View\'));\n
exists_siblings python: len(siblings)">\n
<li class="empty-list-node"\n
tal:condition="not: exists_siblings">\n
<a tal:content="root_section/Base_getTitle"\n
tal:attributes="href root_section/absolute_url;\n
title root_section/Base_getTitle"/>\n
</li>\n
<li class="non-empty-list-node"\n
tal:condition="exists_siblings"\n
tal:define="section_title root_section/Base_getTitle">\n
<img src="images/tree_closed.png" \n
alt=""\n
tal:attributes="id image_dom_id;\n
onclick python: \'toggleSection(\\\'%s\\\', \\\'%s\\\')\' %(section_dom_id, image_dom_id)"/>\n
<span tal:content="section_title"\n
style="cursor:pointer;"\n
tal:attributes="onclick python: \'toggleSection(\\\'%s\\\', \\\'%s\\\')\' %(section_dom_id, image_dom_id);\n
title section_title"/>\n
<div style="display:none;"\n
tal:attributes="id section_dom_id">\n
<ul class="third_level">\n
<li tal:repeat="sibling siblings">\n
<tal:block tal:define="sibling_section_title sibling/Base_getTitle;\n
sibling_section_url sibling/absolute_url">\n
<a href="#" \n
tal:content="sibling_section_title"\n
tal:attributes="href sibling_section_url;\n
title sibling_section_title"/>\n
</tal:block>\n
</li>\n
</ul>\n
</div>\n
</li>\n
<tal:block tal:repeat="section section_list">\n
\n
</tal:block>\n
</tal:block>\n
<ul tal:define="exists_subsections python: section[\'subsection\'] is not None;\n
show_collapse python: collapse_depth==section[\'level\'] and exists_subsections;\n
class_name string:level-${section/level};\n
class python: test(show_collapse, \'collapse-list-node %s\' %class_name , class_name);\n
subsection_html python: here.WebSection_viewSubsectionRenderer(section_list = section[\'subsection\'],\n
collapse_depth=collapse_depth);"\n
tal:attributes="class class">\n
\n
</ul>\n
</ul>\n
</tal:block>\n
<li>\n
<a class="section-link"\n
tal:condition="not: show_collapse"\n
tal:content="section/translated_title"\n
tal:attributes="href section/url;\n
title section/translated_title">\n
</a>\n
\n
<tal:block tal:condition="show_collapse"\n
tal:define="section_dom_id python: section[\'url\'].replace(\'http://\', \'\').replace(\'/\', \'_\');\n
image_dom_id string:image_${section_dom_id};">\n
\n
<img src="images/tree_closed.png" \n
tal:attributes="id image_dom_id;\n
onclick string:toggleSection(\'${section_dom_id}\', \'${image_dom_id}\')"/>\n
<span tal:content="section/translated_title"\n
class="collapse-link"\n
tal:attributes="onclick string:toggleSection(\'${section_dom_id}\', \'${image_dom_id}\');\n
title section/translated_title"/>\n
\n
<div class="collapse-content"\n
style="display:none;"\n
tal:attributes="id section_dom_id"\n
tal:content="structure subsection_html"/>\n
\n
</tal:block>\n
\n
<span tal:condition="not: show_collapse"\n
tal:replace="structure subsection_html"/>\n
\n
</li>\n
\n
</ul>\n
</tal:block>\n
\n
</tal:block>
]]></unicode> </value>
</item>
......@@ -105,11 +98,11 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewKnowledgeManagementMacroLibrary</string> </value>
<value> <string>WebSection_viewSubsectionRenderer</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
<value> <string>iso-8859-15</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -42,29 +42,21 @@
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<!-- XXX: read depth from gadget preferences -->\n
<div class="gadget-website-browser"\n
tal:define="\n
section_list python:here.contentValues(portal_type=\'Web Section\', sort_on=\'int_index\');\n
section_list python:filter(lambda x:x.isVisible(), section_list);\n
half_count python:len(section_list) / 2">\n
tal:define="depth python: 10;\n
include_subsection python: 1;\n
collapse_depth python: 1;\n
section_list python: here.WebSection_getSiteMapTree(depth=depth, include_subsection=include_subsection)">\n
\n
<tal:block tal:repeat="section python:section_list[0:half_count]">\n
<tal:block metal:use-macro="container/Base_viewKnowledgeManagementMacroLibrary/macros/renderer">Macro goes here</tal:block> \n
</tal:block>\n
\n
<tal:block tal:repeat="section python:section_list[half_count:]">\n
<tal:block metal:use-macro="container/Base_viewKnowledgeManagementMacroLibrary/macros/renderer">Macro goes here</tal:block>\n
</tal:block>\n
<tal:block tal:content="structure python: here.WebSection_viewSubsectionRenderer(section_list = section_list, \n
collapse_depth=collapse_depth)"/>\n
\n
<tal:block tal:condition="python: len(section_list)==0">\n
<p i18n:domain="erp5_ui" i18n:translate=""> No subsections found. </p>\n
</tal:block>\n
\n
</div>\n
\n
\n
\n
\n
</div>
]]></unicode> </value>
</item>
......@@ -82,7 +74,7 @@
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
<value> <string>iso-8859-15</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
1805
\ No newline at end of file
1806
\ No newline at end of file
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