From c3709c4977353f10a73f6322315c4a6f99041b34 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Mon, 18 Sep 2006 16:03:03 +0000
Subject: [PATCH] Merge all toolbar code in a page template located at the root
 of the erp5_web_widget_library skin folder, because using sub folder break
 the request and acquisition.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10118 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_web_widget_library/admin_toolbox.xml | 156 ++++++++++++++++--
 1 file changed, 143 insertions(+), 13 deletions(-)

diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml
index a239edb6bd..e5e4d4c6dc 100644
--- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml
@@ -60,8 +60,7 @@
 \n
 <tal:block\n
   tal:define="is_web_mode  python: True;\n
-              portal_type  python: here.getPortalType();\n
-">\n
+              portal_type  python: here.getPortalType();">\n
 <!--              widget_list python: [ \'admin_tool_menus\']"\n
                                            , \'admin_tool_edit\'\n
                                            , \'admin_tool_duplicate_document\'\n
@@ -69,8 +68,8 @@
                                            , \'admin_tool_debug\'\n
                                            ]">\n
 -->\n
-\n
   <tal:block metal:use-macro="here/global_definitions/macros/header_definitions"/>\n
+\n
 \n
   <div id="adminToolBox">\n
 \n
@@ -140,16 +139,6 @@
             <tal:block tal:replace="python: link[\'label\']"/>\n
           </a>\n
         </li>\n
-\n
-        <!--li tal:condition="python: not is_portal_root">\n
-          <a tal:attributes="href python: \'%s/view?editable_mode=1\' % context.WebSite_getSection();"\n
-          ><img src="pictures/section.png"/> Edit <tal:block tal:content="python: (is_webdoc and \'Parent \') or \'Current \'"/>Section</a>\n
-        </li-->\n
-\n
-        <!--li tal:condition="python: (not is_portal_root) and ((is_section and valid_default_doc and not is_edit_mode) or is_webdoc)">\n
-          <a tal:attributes="href python: \'%s/view?editable_mode=1\' % context.WebSite_getDocumentPhysicalPath();"\n
-          ><img src="pictures/webpage.png"/> Edit <tal:block tal:content="python: (is_section and \'Default \') or \'Current \'"/>Page</a>\n
-        </li-->\n
 \n
         <!--li tal:define="context_url   python: context.absolute_url();\n
                         url_list      python: context_url[context_url.find(\'://\')+3:].split(\'/\');\n
@@ -163,12 +152,153 @@
         </li-->\n
       </ul>\n
     </div>\n
+\n
 \n
     <!-- Action drop-down contextual menu -->\n
     <div name="adminSection">\n
       <h3><tal:block tal:content="portal_type"/> Actions</h3>\n
       <tal:block metal:use-macro="here/context_box_render/macros/action"/>\n
     </div>\n
+\n
+\n
+    <!-- Document creation panel -->\n
+    <div name="adminSection">\n
+      <form name="tool_create" method="post" action="WebSite_newContent">\n
+        <input id="document_action_mode" name="document_action_mode" value="clone" type="hidden"/>\n
+\n
+        <h3>\n
+          <span id="create_new_document_title"></span>\n
+          <span id="clone_document_title">Clone <tal:block tal:content="python: (portal_type and \'Default \') or \'Current \'"/>Page</span>\n
+        </h3>\n
+\n
+        <!-- TODO: bad use of table ! Generic css class for forms should be used there -->\n
+        <table cellspacing="1" cellpadding="0" border="0">\n
+          <tr>\n
+            <td>Title</td>\n
+            <td><input class="input" size="15" type="text" name="title"     tal:attributes="value document/getTitle | nothing"/></td>\n
+          </tr>\n
+          <tr>\n
+            <td>Page URI</td>\n
+            <td><input class="input" size="15" type="text" name="reference" tal:attributes="value document/getReference | nothing"/></td>\n
+          </tr>\n
+          <tr>\n
+            <td>Version</td>\n
+            <td><input class="input" size="5"  type="text" name="version"   tal:attributes="value document/getVersion | nothing"/></td>\n
+          </tr>\n
+          <tr>\n
+            <td>Language</td>\n
+            <td><input class="input" size="5"  type="text" name="language"  tal:attributes="value document/getLanguage | nothing"/></td>\n
+              <!-- No required widget (make the form more complex) -->\n
+              <!--select name="language" size="1"\n
+                      tal:define="language_map python: here.Localizer.get_languages_map()">\n
+                <tal:block tal:repeat="language language_map">\n
+                  <tal:block tal:condition="python: document.getLanguage() == language[\'id\'] or language[\'selected\']">\n
+                    <option tal:attributes="value language/id"\n
+                            tal:content="language/id"\n
+                            selected/>\n
+                  </tal:block>\n
+                  <tal:block tal:condition="python: not(document.getLanguage() == language[\'id\'] or language[\'selected\'])">\n
+                    <option tal:attributes="value language/id"\n
+                            tal:content="language/id"/>\n
+                  </tal:block>\n
+                </tal:block>\n
+              </select-->\n
+          </tr>\n
+\n
+          <script type="text/javascript" language="JavaScript">\n
+          <!--\n
+            // preload action icons\n
+            if (document.images) {\n
+              clone_icon = new Image();\n
+              new_icon   = new Image();\n
+              clone_icon.src = "clone-document.png";\n
+              new_icon.src   = "new-document.png";\n
+            }\n
+\n
+            function setCreationMode (sel) {\n
+              // default is cloning\n
+              var action      = \'clone\';\n
+              var action_name = \'Clone &amp; Edit\';\n
+              var icon        = \'clone-document.png\';\n
+              var clone_class = \'\';\n
+              var new_title   = \'\';\n
+\n
+              // a portal type is given, so create a new document\n
+              var portal_type = sel.options[sel.selectedIndex].value;\n
+              if (portal_type != \'None\') {\n
+                action      = \'new\'\n
+                action_name = \'Create New &amp; Edit\';\n
+                icon        = \'new-document.png\';\n
+                clone_class = \'doNotDisplay\';\n
+                new_title   = \'Create New Document\';\n
+              }\n
+\n
+              // update action dependent values\n
+              document.getElementById(\'document_action_mode\'     ).value     = action;\n
+              document.getElementById(\'create_new_document_title\').innerHTML = new_title;\n
+              document.getElementById(\'clone_document_title\'     ).className = clone_class;\n
+              document.getElementById(\'duplicate_document_action\').innerHTML = action_name;\n
+\n
+              // replace the action icon\n
+              document.getElementById(\'clone_action_icon\').src = eval(action + "_icon.src");\n
+\n
+              // update action button alt & title\n
+              var button   = document.getElementById(\'clone_action_button\');\n
+              button.alt   = action_name;\n
+              button.title = action_name;\n
+            }\n
+          -->\n
+          </script>\n
+\n
+          <tr>\n
+            <td>Type</td>\n
+            <td>\n
+              <select class="input" name="new_portal_type" size="1" onchange="setCreationMode(this)">\n
+                <option value="None" selected>&mdash; Same as Current &mdash;</option>\n
+                <tal:block tal:repeat="portal_type python: here.portal_types.objectValues()">\n
+                  <option tal:condition="python: \'web_document\' in getattr(portal_type, \'group_list\', [])"\n
+                          tal:content="portal_type/id"\n
+                          tal:attributes="value portal_type/id"/>\n
+                </tal:block>\n
+              </select>\n
+            </td>\n
+          </tr>\n
+          <tr>\n
+            <td colspan="2" class="centeredInner">\n
+              <button alt=\'Clone &amp; Edit\' id="clone_action_button" title=\'Clone &amp; Edit\'><img src="pictures/clone-document.png" id="clone_action_icon"/> <span id="duplicate_document_action">Clone &amp; Edit</span></button>\n
+              <!--input type="image" alt="Clone &amp; Edit" title="Clone &amp; Edit" src="pictures/clone-document.png" id="clone_action_icon"/> <span id="duplicate_document_action">Clone &amp; Edit</span-->\n
+            </td>\n
+          </tr>\n
+        </table>\n
+\n
+      </form>\n
+    </div>\n
+\n
+\n
+    <!-- Debug panel -->\n
+    <!-- TODO: only display this part for manager -->\n
+    <div name="adminSection">\n
+      <h3>Debug Menu</h3>\n
+      <ul>\n
+        <li>\n
+          <pre>\n
+            <!-- Display erp5 web globals -->\n
+            <b>Globals:</b>\n
+            <tal:block tal:content="python: \'is_web_mode    = \' + repr(is_web_mode)"   />\n
+          </pre>\n
+        </li>\n
+        <!-- XXX should we display this part everytime ? -->\n
+        <!--li>\n
+          <a tal:attributes="href python: \'%s/view?ignore_layout=1\' % context.WebSite_getSection();"\n
+          ><img src="pictures/section.png"/> Edit <tal:block tal:content="python: (is_webdoc and \'Parent \') or \'Current \'"/>Section in ERP5</a>\n
+        </li>\n
+        <li tal:condition="python: (is_section and valid_default_doc and not is_edit_mode) or is_webdoc">\n
+          <a tal:attributes="href python: \'%s/view?ignore_layout=1\' % context.WebSite_getDocumentPhysicalPath();"\n
+          ><img src="pictures/webpage.png" tal:attributes="src string:${portal_url}/pictures/webpage.png"/> Edit <tal:block tal:content="python: (is_section and \'Default \') or \'Current \'"/>Page in ERP5</a>\n
+        </li-->\n
+      </ul>\n
+    </div>\n
+\n
 \n
     <!-- Generic attempt -->\n
     <!--div name="adminSection" tal:repeat="widget python: widget_list">\n
-- 
2.30.9