From e1cc7fc23fe17ccd0fd32ca3cd1ea6f879c79242 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Wed, 2 Jun 2010 14:44:49 +0000
Subject: [PATCH] Make it possible to edit portal type icon from ERP5 UI.
 Encode again as utf-8 random text excerpts.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35904 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../portal_skins/erp5_core/BaseType_view.xml  |  1 +
 .../erp5_core/BaseType_view/my_type_icon.xml  | 99 +++++++++++++++++++
 .../erp5_core/Base_showFoundText.xml          | 10 +-
 product/ERP5/bootstrap/erp5_core/bt/revision  |  2 +-
 4 files changed, 107 insertions(+), 5 deletions(-)
 create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view/my_type_icon.xml

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view.xml
index 6c0301288b..d82add1306 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view.xml
@@ -105,6 +105,7 @@
                         <string>my_type_acquire_local_role</string>
                         <string>my_type_property_sheet_list</string>
                         <string>my_type_base_category_list</string>
+                        <string>my_type_icon</string>
                       </list>
                     </value>
                 </item>
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view/my_type_icon.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view/my_type_icon.xml
new file mode 100644
index 0000000000..8fc2e79d6d
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseType_view/my_type_icon.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>delegated_list</string> </key>
+            <value>
+              <list>
+                <string>title</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_type_icon</string> </value>
+        </item>
+        <item>
+            <key> <string>message_values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>external_validator_failed</string> </key>
+                    <value> <string>The input failed the external validator.</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>overrides</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_string_field</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Icon</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_showFoundText.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_showFoundText.xml
index 54e8359b37..6cca949dfb 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_showFoundText.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_showFoundText.xml
@@ -63,6 +63,7 @@
 """\n
 from Products.ERP5.Document.Document import NotConvertedError\n
 \n
+encoding = \'utf-8\'\n
 is_gadget_mode = context.REQUEST.get(\'is_gadget_mode\', 0)\n
 \n
 if is_gadget_mode:\n
@@ -73,9 +74,9 @@ if is_gadget_mode:\n
 def getRandomDocumentTextExcerpt(document_text):\n
   # try to get somewhat arbitrary choice of searchable attrs\n
   if isinstance(document_text, str) and document_text!=\'\':\n
-    document_text = document_text.decode(\'utf-8\', \'ignore\')\n
+    document_text = document_text.decode(encoding, \'ignore\')\n
     start = min(len(document_text) - 300, 200)\n
-    return \'... %s ...\' %document_text[start:start + max_text_length]\n
+    return \'... %s ...\' %document_text[start:start + max_text_length].encode(encoding)\n
   else:\n
     return \'\'\n
 \n
@@ -124,8 +125,8 @@ else:\n
   result = \' \'.join(map(str, found_text_fragments))\n
 \n
   # Document may contains charactors which utf8 codec cannot decode.\n
-  unicode_result = result.decode(\'utf-8\', \'ignore\')\n
-  result = unicode_result.encode(\'utf-8\')\n
+  unicode_result = result.decode(encoding, \'ignore\')\n
+  result = unicode_result.encode(encoding)\n
 \n
   return result\n
 
@@ -172,6 +173,7 @@ else:\n
                             <string>max_text_length</string>
                             <string>Products.ERP5.Document.Document</string>
                             <string>NotConvertedError</string>
+                            <string>encoding</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>is_gadget_mode</string>
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index 7dbc594e58..1f24d348d3 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-1596
\ No newline at end of file
+1597
\ No newline at end of file
-- 
2.30.9