diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml index e17ab5c7bde3d220771d9bc1b7bdf4b66e29c11f..7553dd587a6fdfbd1d6018c1c831aff8d7dbd347 100644 --- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml +++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml @@ -54,96 +54,108 @@ <item> <key> <string>_body</string> </key> <value> <string>"""\n -This script receives a request from advanced search form and \n -puts together a search string in a search syntax, depending on\n -parameters received. It is the reverse of Base_parseSearchString external\n -method.\n + This script receives a request from advanced search form and \n + puts together a search string in a search syntax, depending on\n + parameters received. It is the reverse of Base_parseSearchString external\n + method.\n """\n -req = context.REQUEST\n +MARKER = [\'\', None]\n +request = context.REQUEST\n \n -search_straight = req.get(\'searchabletext\', \'\')\n -if search_straight != \'\':\n - return search_straight\n +# one can specify a direct search string, \n +# in this case simply returning it is expected\n +searchabletext = kw.get(\'searchabletext\', \n + request.get(\'searchabletext\', None))\n +if searchabletext not in MARKER:\n + return searchabletext\n \n # words to search in \'any of the words\' form - left intact\n -search_string = req.get(\'searchabletext_any\',\'\')\n +searchabletext_any = kw.get(\'searchabletext_any\', \n + request.get(\'searchabletext_any\', \'\'))\n +search_string = searchabletext_any\n \n -# exact phrase to search for - double-quoted\n -search_phrase = req.get(\'searchabletext_phrase\',\'\')\n -if search_phrase != "":\n - search_string += \' "\' + search_phrase + \'"\'\n +# exact phrase to search for double-quoted\n +searchabletext_phrase = kw.get(\'searchabletext_phrase\', \n + request.get(\'searchabletext_phrase\', None))\n +if searchabletext_phrase not in MARKER:\n + search_string += \' \\"%s\\"\' %searchabletext_phrase\n \n # search "with all of the words" - each word prefixed by "+"\n -search_all = req.get(\'searchabletext_all\',\'\')\n -if search_all != "":\n - search_string += \' \' + \' \'.join(\'+\' + word for word in search_all.split(\' \'))\n +searchabletext_all = kw.get(\'searchabletext_all\',\n + request.get(\'searchabletext_all\', None))\n +if searchabletext_all not in MARKER:\n + search_string += \' %s\' %\' \'.join(\'+%s\' %word for word in searchabletext_all.split(\' \'))\n \n # search without these words - every word prefixed by "-"\n -search_without = req.get(\'searchabletext_without\',\'\')\n -if search_without!="":\n - search_string += \' \' + \' \'.join(\'-\' + word for word in search_without.split(\' \'))\n +searchabletext_without = kw.get(\'searchabletext_without\',\n + request.get(\'searchabletext_without\', None))\n +if searchabletext_without not in MARKER:\n + search_string += \' %s\' %\' \'.join(\'-%s\' %word for word in searchabletext_without.split(\' \'))\n \n # search limited to a certain date range - add "created:xxx"\n -daterange = req.get(\'created_within\',\'\')\n -if daterange!=\'\':\n - search_string += \' created:\' + daterange\n +created_within = kw.get(\'created_within\', request.get(\'created_within\', None))\n +if created_within not in MARKER:\n + search_string += \' created:%s\' %created_within\n \n # only given portal_types - add "type:Type" or type:(Type1,Type2...)\n -portal_type_list = req.get(\'search_portal_type\')\n +portal_type_list = kw.get(\'search_portal_type\', \n + request.get(\'search_portal_type\'))\n if portal_type_list == \'all\':\n portal_type_list=None\n -if isinstance(portal_type_list,str):\n +if isinstance(portal_type_list, str):\n portal_type_list=[portal_type_list]\n if portal_type_list:\n if len(portal_type_list)==1:\n search_string += \' type:"%s"\' % portal_type_list[0]\n else:\n - search_string += \' type:(%s)\' % \',\'.join(portal_type_list)\n + search_string += \' type:(%s)\' %\',\'.join(portal_type_list)\n \n # search by reference\n -ref = req.get(\'reference\')\n -if ref:\n - search_string += \' reference:%s\' % ref\n +reference = kw.get(\'reference\', request.get(\'reference\', None))\n +if reference not in MARKER:\n + search_string += \' reference:%s\' % reference\n \n # search by version\n -ver = req.get(\'version\')\n -if ver:\n - search_string += \' version:%s\' % ver\n +version = kw.get(\'version\', request.get(\'version\'))\n +if version not in MARKER:\n + search_string += \' version:%s\' %version\n \n # search by language\n -lng=req.get(\'language\')\n -if lng and lng != \'0\':\n - search_string += \' language:%s\' % lng\n +language=kw.get(\'language\', request.get(\'language\', None))\n +if language not in MARKER and language != \'0\':\n + search_string += \' language:%s\' % language\n \n # category search\n for category in (\'group\', \'site\', \'function\', \'publication_section\', \'classification\'):\n - category_value = req.get(\'subfield_field_your_category_list_\' + category)\n - if category_value:\n + category_field_id = \'subfield_field_your_category_list_%s\' %category\n + category_value = kw.get(category_field_id, request.get(category_field_id, None))\n + if category_value not in MARKER:\n search_string += \' %s:%s\' % (category, category_value)\n \n # Category title search\n -for category in (\'contributor_title\', ):\n - category_value = req.get(category)\n - if category_value:\n - search_string += \' %s:%s\' % (category, category_value)\n -\n +for category in (\'contributor_title\',):\n + category_value = kw.get(category, request.get(category, None))\n + if category_value not in MARKER:\n + search_string += \' %s:%s\' %(category, category_value)\n \n #only my docs\n -mine = req.get(\'mine\')\n -if mine:\n +mine = kw.get(\'mine\', request.get(\'mine\', None))\n +if mine not in MARKER:\n search_string += \' mine:yes\'\n \n # only newest versions\n -newest = req.get(\'newest\')\n -if newest:\n +newest = kw.get(\'newest\', request.get(\'newest\', None))\n +if newest not in MARKER:\n search_string += \' newest:yes\'\n \n # search mode\n -search_mode = req.get(\'search_mode\')\n -search_mode_map={\'in_boolean_mode\':\'boolean\',\'with_query_expansion\':\'expanded\'}\n -if search_mode and search_mode_map.has_key(search_mode):\n +search_mode = kw.get(\'search_mode\', request.get(\'search_mode\', None))\n +search_mode_map={\'in_boolean_mode\':\'boolean\',\n + \'with_query_expansion\':\'expanded\'}\n +if search_mode not in MARKER and search_mode_map.has_key(search_mode):\n search_string += \' mode:%s\' % search_mode_map[search_mode]\n \n +context.log(search_string)\n return search_string\n </string> </value> </item> @@ -155,7 +167,7 @@ return search_string\n </item> <item> <key> <string>_params</string> </key> - <value> <string>*a,**kw</string> </value> + <value> <string>**kw</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -181,29 +193,31 @@ return search_string\n <key> <string>co_varnames</string> </key> <value> <tuple> - <string>a</string> <string>kw</string> + <string>None</string> + <string>MARKER</string> <string>_getattr_</string> <string>context</string> - <string>req</string> - <string>search_straight</string> + <string>request</string> + <string>searchabletext</string> + <string>searchabletext_any</string> <string>search_string</string> - <string>search_phrase</string> + <string>searchabletext_phrase</string> <string>_inplacevar_</string> - <string>search_all</string> + <string>searchabletext_all</string> <string>_getiter_</string> - <string>search_without</string> - <string>daterange</string> + <string>searchabletext_without</string> + <string>created_within</string> <string>portal_type_list</string> - <string>None</string> <string>isinstance</string> <string>str</string> <string>len</string> <string>_getitem_</string> - <string>ref</string> - <string>ver</string> - <string>lng</string> + <string>reference</string> + <string>version</string> + <string>language</string> <string>category</string> + <string>category_field_id</string> <string>category_value</string> <string>mine</string> <string>newest</string> diff --git a/bt5/erp5_dms/bt/revision b/bt5/erp5_dms/bt/revision index 013e5e6abd0c372b1e1cae1829ebbdc81a8ca3f6..8ad8919fabbe51e78943adf627224340cef0dcce 100644 --- a/bt5/erp5_dms/bt/revision +++ b/bt5/erp5_dms/bt/revision @@ -1 +1 @@ -1077 \ No newline at end of file +1078 \ No newline at end of file