Commit 572ef8a2 authored by Bartek Górny's avatar Bartek Górny

implemented Google-like operation of search/advanced search (adv. form submits...

implemented Google-like operation of search/advanced search (adv. form submits parametrs from which a proper search string is assembled and then the search uses the string)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11053 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 641b8d7f
......@@ -81,7 +81,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DMS_searchDialog</string> </value>
<value> <string>string:${object_url}/Base_searchDialog</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.Form</string>
<string>ERP5Form</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_processAdvancedSearch</string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>SearchableText</string>
<string>my_document_type</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list>
<string>creation_from</string>
<string>creation_to</string>
<string>modification_from</string>
<string>modification_to</string>
<string>search_mode</string>
<string>mine</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_advancedSearchDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_advancedSearchDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Advanced Document Search</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.StandardFields</string>
<string>CheckBoxField</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mine</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>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Only my documents</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -73,9 +73,12 @@
tags=(\'<div style="font-weight:bold;display:inline;">\',\'</div>\')\n
trail=5\n
maxlines=5\n
\n
txt=brain.getObject().SearchableText()\n
sw=context.REQUEST.get(\'SearchableText\',None)\n
st=selection.params.get(\'SearchableText\')\n
if st is None:\n
return \'\'\n
args=context.parseSearchString(st)\n
sw=args.get(\'SearchableText\')\n
if sw is None:\n
return \'\'\n
res=context.cutFound(context,txt,sw,tags,trail,maxlines)\n
......@@ -131,8 +134,10 @@ return \' \'.join(map(str,res))\n
<string>maxlines</string>
<string>_getattr_</string>
<string>txt</string>
<string>context</string>
<string>st</string>
<string>None</string>
<string>context</string>
<string>args</string>
<string>sw</string>
<string>res</string>
<string>map</string>
......
......@@ -70,14 +70,22 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
mine=context.REQUEST.get(\'mine\',\'\')\n
# if no args we return emtpy list\n
if kw.get(\'SearchableText\',\'\')==\'\' and mine==\'\':return []\n
# if no args we return empty list\n
# we use only SearchableText - all params are passed through this\n
\n
args=context.parseSearchString(kw.get(\'SearchableText\',\'\'))\n
sstr=context.REQUEST.get(\'SearchableText\')\n
if not sstr:\n
sstr=kw.get(\'SearchableText\')\n
if not sstr:return []\n
context.log(sstr)\n
\n
args=context.parseSearchString(sstr)\n
\n
# if no portal type specified, take all\n
if not args.has_key(\'portal_type\') or args[\'portal_type\']==():\n
args[\'portal_type\']=context.getPortalDocumentTypeList()+(\'Conference\',\'Project\')\n
\n
# process searching by category\n
cats=[]\n
bases=context.portal_categories.getBaseCategoryList()\n
for k,v in args.items():\n
......@@ -85,6 +93,13 @@ for k,v in args.items():\n
cats.append(\'/\'.join((k,v)))\n
if cats!=[]:\n
args[\'category\']=cats\n
\n
# expand simplified notation of search mode\n
mode=args.get(\'mode\')\n
modemap={\'natural\':0,\'boolean\':\'in_boolean_mode\',\'expanded\':\'with_query_expansion\'}\n
if mode and modemap.has_key(mode):\n
args[\'search_mode\']=modemap[mode]\n
\n
kw.update(args)\n
\n
# a hack because SQLCatalog wants table.key now \n
......@@ -93,6 +108,7 @@ if kw.has_key(\'SearchableText\'):\n
kw[\'full_text.SearchableText\']=kw[\'SearchableText\']\n
kw.pop(\'SearchableText\')\n
\n
# this will go out, most likely\n
cf=kw.get(\'creation_from\')\n
ct=kw.get(\'creation_to\')\n
mf=kw.get(\'modification_from\')\n
......@@ -110,15 +126,18 @@ if mt:\n
if wheres!=[]:\n
kw[\'where_expression\']=\' AND \'.join(wheres)\n
\n
# now we search\n
res=context.portal_catalog(**kw)\n
\n
if mine not in (0,\'\'): # user wants only his documents\n
# user wants only his documents\n
if args.get(\'mine\'): \n
from AccessControl import getSecurityManager\n
sm=getSecurityManager()\n
u=sm.getUser()\n
# now we need to filter by owner\n
# some day we will do it in catalog\n
res=[r for r in res if u.allowed(r,(\'Owner\',))]\n
res=[r for r in res if u.allowed(r.getObject(),(\'Owner\',))]\n
\n
\n
return res\n
......@@ -174,7 +193,7 @@ return res\n
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>mine</string>
<string>sstr</string>
<string>args</string>
<string>_getitem_</string>
<string>_write_</string>
......@@ -183,6 +202,8 @@ return res\n
<string>_getiter_</string>
<string>k</string>
<string>v</string>
<string>mode</string>
<string>modemap</string>
<string>cf</string>
<string>ct</string>
<string>mf</string>
......
294
\ No newline at end of file
298
\ 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