From 43b2911cc70ed6a925fdcf6af008181d21018904 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Thu, 25 Nov 2010 13:03:35 +0000
Subject: [PATCH] Make a genericKnowledge Pad column renderer rather than
 support 3 different hard coded ones .

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40684 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../WebSection_viewColumnThree.xml            | 115 -----------------
 .../WebSection_viewColumnTwo.xml              | 116 ------------------
 ... => WebSection_viewKnowledgePadColumn.xml} |  30 +++--
 bt5/erp5_knowledge_pad/bt/revision            |   2 +-
 4 files changed, 18 insertions(+), 245 deletions(-)
 delete mode 100644 bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnThree.xml
 delete mode 100644 bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnTwo.xml
 rename bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/{WebSection_viewColumnOne.xml => WebSection_viewKnowledgePadColumn.xml} (85%)

diff --git a/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnThree.xml b/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnThree.xml
deleted file mode 100644
index ad2f926b65..0000000000
--- a/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnThree.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<?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  \n
-   tal:define="mode python: \'web_section\';\n
-               default_pad_group python: options.get(\'default_pad_group\', None);\n
-               isAnonymousKnowledgePadUsed python: options.get(\'use_anonymous_knowledge_pad\', False);\n
-               dummy python: request.set(\'is_anonymous_knowledge_pad_used\', isAnonymousKnowledgePadUsed);\n
-               knowledge_pads python: here.ERP5Site_getKnowledgePadListForUser(\n
-                                             mode=mode,\n
-                                             default_pad_group=default_pad_group);\n
-               struct python:  here.WebSite_getActiveKnowledgePadForUser(knowledge_pads, \n
-                                                                        default_pad_group);\n
-               active_knowledge_pad python: struct[0];\n
-               knowledge_pads python: struct[1];\n
-               hasUserActivity python: here.ERP5Site_hasUserActivity(\n
-                                               active_knowledge_pad,\n
-                                               mode=mode,\n
-                                               default_pad_group=default_pad_group);\n
-               isAnon python: context.portal_membership.isAnonymousUser();\n
-               createDefaultPadForUser python: len(knowledge_pads)==0 and\n
-                                               not hasUserActivity;\n
-               waitForActivitiesOnServer python: active_knowledge_pad is None and\n
-                                                 hasUserActivity;\n
-               current_web_section python:\n
-                  context.REQUEST.get(\'current_web_section\', here);\n
-               current_web_section python:\n
-                  test(current_web_section.getPortalType()==\'Web Site\',\n
-                                               here, current_web_section);\n
-               current_web_section_url python: current_web_section.absolute_url();\n
-               cancel_url current_web_section_url;">\n
-\n
-    <tal:block tal:condition="python: not createDefaultPadForUser and \n
-                                      not waitForActivitiesOnServer and\n
-                                      active_knowledge_pad is not None">\n
-      <div class="portal-column" \n
-           id="portal-column-2"\n
-           tal:attributes="class python: test((isAnon or isAnonymousKnowledgePadUsed), \n
-                                         \'portal-column-undraggable\', \n
-                                         \'portal-column\')"\n
-           tal:define="layout active_knowledge_pad/KnowledgePad_getBoxColumnLayout;">\n
-\n
-        <span tal:condition="python: len(layout)>=3"\n
-              tal:replace="structure python:\n
-                  active_knowledge_pad.KnowledgePad_viewColumnWidget(section_layout=layout[2],\n
-                                                                     real_context=here,\n
-                                                                     cancel_url=cancel_url)"/>\n
-      </div>\n
-    </tal:block>\n
-\n
-  </tal:block>\n
-\n
-
-
-]]></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>WebSection_viewColumnThree</string> </value>
-        </item>
-        <item>
-            <key> <string>output_encoding</string> </key>
-            <value> <string>utf-8</string> </value>
-        </item>
-        <item>
-            <key> <string>title</string> </key>
-            <value> <unicode>Right Column</unicode> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnTwo.xml b/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnTwo.xml
deleted file mode 100644
index a525eb6589..0000000000
--- a/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnTwo.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-<?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  \n
-   tal:define="mode python: \'web_section\';\n
-               default_pad_group python: options.get(\'default_pad_group\', None);\n
-               isAnonymousKnowledgePadUsed python: options.get(\'use_anonymous_knowledge_pad\', False);\n
-               dummy python: request.set(\'is_anonymous_knowledge_pad_used\', isAnonymousKnowledgePadUsed);\n
-               knowledge_pads python: here.ERP5Site_getKnowledgePadListForUser(\n
-                                          mode=mode,\n
-                                          default_pad_group=default_pad_group);\n
-               struct python:  here.WebSite_getActiveKnowledgePadForUser(knowledge_pads, \n
-                                                                        default_pad_group);\n
-               active_knowledge_pad python: struct[0];\n
-               knowledge_pads python: struct[1];\n
-               hasUserActivity python: here.ERP5Site_hasUserActivity(\n
-                                              active_knowledge_pad,\n
-                                              mode=mode,\n
-                                              default_pad_group=default_pad_group);\n
-               isAnon python: context.portal_membership.isAnonymousUser();\n
-               createDefaultPadForUser python: len(knowledge_pads)==0 and\n
-                                              not hasUserActivity;\n
-               waitForActivitiesOnServer python: active_knowledge_pad is None and\n
-                                                 hasUserActivity;\n
-               current_web_section python:\n
-                  context.REQUEST.get(\'current_web_section\', here);\n
-               current_web_section python:\n
-                  test(current_web_section.getPortalType()==\'Web Site\',\n
-                                               here, current_web_section);\n
-               current_web_section_url python: current_web_section.absolute_url();\n
-               cancel_url current_web_section_url;">\n
-\n
-    <tal:block tal:condition="python: not createDefaultPadForUser and \n
-                                      not waitForActivitiesOnServer and\n
-                                      active_knowledge_pad is not None">\n
-\n
-      <div class="portal-column" \n
-           id="portal-column-1"\n
-           tal:attributes="class python: test((isAnon or isAnonymousKnowledgePadUsed), \n
-                                              \'portal-column-undraggable\', \n
-                                              \'portal-column\')"\n
-           tal:define="layout active_knowledge_pad/KnowledgePad_getBoxColumnLayout;">\n
-\n
-        <span tal:condition="python: len(layout)>=2"\n
-              tal:replace="structure python:\n
-                  active_knowledge_pad.KnowledgePad_viewColumnWidget(section_layout=layout[1],\n
-                                                                     real_context=here,\n
-                                                                     cancel_url=cancel_url)"/>\n
-      </div>\n
-    </tal:block>\n
-\n
-  </tal:block>\n
-\n
-
-
-]]></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>WebSection_viewColumnTwo</string> </value>
-        </item>
-        <item>
-            <key> <string>output_encoding</string> </key>
-            <value> <string>utf-8</string> </value>
-        </item>
-        <item>
-            <key> <string>title</string> </key>
-            <value> <unicode>Center Column</unicode> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnOne.xml b/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewKnowledgePadColumn.xml
similarity index 85%
rename from bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnOne.xml
rename to bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewKnowledgePadColumn.xml
index 8aa8e64500..328d67ec5a 100644
--- a/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewColumnOne.xml
+++ b/bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad_web/WebSection_viewKnowledgePadColumn.xml
@@ -37,13 +37,16 @@
             <value> <unicode encoding="cdata"><![CDATA[
 
 <tal:block \n
-  tal:define="mode python: \'web_section\';\n
+  tal:define="mode python: options.get(\'mode\', \'web_section\');\n
               default_pad_group python: options.get(\'default_pad_group\', None);\n
               isAnonymousKnowledgePadUsed python: options.get(\'use_anonymous_knowledge_pad\', False);\n
+              pad_column python: options.get(\'pad_column\', 0);\n
+              create_default_pad python: options.get(\'create_default_pad\', False);\n
+              make_security_check python: options.get(\'make_security_check\', False);\n
               dummy python: request.set(\'is_anonymous_knowledge_pad_used\', isAnonymousKnowledgePadUsed);\n
               knowledge_pads python: here.ERP5Site_getKnowledgePadListForUser(\n
-                                          mode=mode,\n
-                                          default_pad_group=default_pad_group);\n
+                                            mode=mode,\n
+                                            default_pad_group=default_pad_group);\n
               struct python:  here.WebSite_getActiveKnowledgePadForUser(knowledge_pads, \n
                                                                         default_pad_group);\n
               active_knowledge_pad python: struct[0];\n
@@ -54,7 +57,7 @@
                                              default_pad_group=default_pad_group);\n
               isAnon python: context.portal_membership.isAnonymousUser();\n
               createDefaultPadForUser python: len(knowledge_pads)==0 and\n
-                                              not hasUserActivity;\n
+                                              not hasUserActivity and create_default_pad;\n
               waitForActivitiesOnServer python: active_knowledge_pad is None and\n
                                                 hasUserActivity;\n
               current_web_section python:\n
@@ -76,15 +79,15 @@
       <span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/disable_server_integration"> Disable slot</span>\n
 \n
       <div class="portal-column" \n
-           id="portal-column-0"\n
            tal:attributes="class python: test(isAnon or isAnonymousKnowledgePadUsed, \n
                                               \'portal-column-undraggable\', \n
-                                              \'portal-column\')"\n
+                                              \'portal-column\');\n
+                           id python: \'portal-column-%s\' %pad_column"\n
            tal:define="layout active_knowledge_pad/KnowledgePad_getBoxColumnLayout;">\n
 \n
-        <span tal:condition="python: len(layout)>=1"\n
+        <span tal:condition="python: len(layout)>=pad_column+1"\n
               tal:replace="structure python:\n
-                  active_knowledge_pad.KnowledgePad_viewColumnWidget(section_layout=layout[0],  \n
+                  active_knowledge_pad.KnowledgePad_viewColumnWidget(section_layout=layout[pad_column],  \n
                                                                      real_context=here,\n
                                                                      cancel_url=cancel_url)"/>\n
     </div>\n
@@ -113,9 +116,10 @@
       </div>\n
 \n
     </div>\n
-    \n
-   <span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/knowledge_pad_security_check"> Security check\n
-   </span>\n
+\n
+     <tal:block tal:condition="make_security_check">\n
+       <span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/knowledge_pad_security_check"/>\n
+    </tal:block>\n
     \n
   </tal:block>
 
@@ -131,7 +135,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>WebSection_viewColumnOne</string> </value>
+            <value> <string>WebSection_viewKnowledgePadColumn</string> </value>
         </item>
         <item>
             <key> <string>output_encoding</string> </key>
@@ -139,7 +143,7 @@
         </item>
         <item>
             <key> <string>title</string> </key>
-            <value> <unicode>Left Column</unicode> </value>
+            <value> <unicode>Pad column renderer</unicode> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_knowledge_pad/bt/revision b/bt5/erp5_knowledge_pad/bt/revision
index e25083957d..5156988895 100644
--- a/bt5/erp5_knowledge_pad/bt/revision
+++ b/bt5/erp5_knowledge_pad/bt/revision
@@ -1 +1 @@
-618
\ No newline at end of file
+619
\ No newline at end of file
-- 
2.30.9