annotate MoinMoin/macro/AdvancedSearch.py @ 3125:40c4670c3410

refactored auth package to use own logger
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 27 Feb 2008 10:05:20 +0100
parents 5cb80bd604b4
children 124d0ef138aa
rev   line source
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
2 """
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
3 MoinMoin - AdvancedSearch Macro
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
4
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2595
diff changeset
5 <<AdvancedSearch>>
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
6 displays advanced search dialog.
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1792
diff changeset
7
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1792
diff changeset
8 @license: GNU GPL, see COPYING for details.
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
9 """
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
10
3040
8608b258f8e6 bug fix of MoinMoinBugs/MoveAttachmentNotWorkingWithModPython (thanks to Boleslaw Kulbabinski) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2725
diff changeset
11 from MoinMoin import wikiutil
1367
4c29aeea8bf7 languages dropdown menu
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1364
diff changeset
12 from MoinMoin.i18n import languages
1509
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
13 from MoinMoin.widget import html
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
14 from MoinMoin.util.web import makeSelection
2595
5e7b45489430 moved python2.3/2.4 compatibility code to MoinMoin.support.python_compatibility (thanks to Heinrich Wendel)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
15 from MoinMoin.support.python_compatibility import sorted
1374
aa33bb2b40d6 mimetype-search is live, i18n fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1373
diff changeset
16 import mimetypes
aa33bb2b40d6 mimetype-search is live, i18n fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1373
diff changeset
17
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
18 Dependencies = ['pages']
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
19
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
20 def getMimetypes():
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
21 # The types will be listed here, instead of parsing mimetypes.types_map
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
22 types = [
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
23 'application',
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
24 'audio',
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
25 'image',
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
26 'message',
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
27 'text',
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
28 'video',
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
29 ]
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
30 return types
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
31
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
32
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
33 def getCategories(request):
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
34 # This will return all pages with "Category" in the title
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
35 cat_filter = request.cfg.cache.page_category_regex.search
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
36 pages = request.rootpage.getPageList(filter=cat_filter)
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
37 pages.sort()
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
38 return pages
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
39
1370
25ad5f5c6e3d py2.4 fix, sorted
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
40
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
41 def form_get(request, name, default=''):
1506
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
42 """ Fetches a form field
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2224
diff changeset
43
1506
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
44 @param request: current request
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
45 @param name: name of the field
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
46 @keyword default: value if not present (default: '')
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
47 """
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
48 return request.form.get(name, [default])[0]
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
49
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
50
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
51 def advanced_ui(macro):
1506
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
52 """ Returns the code for the advanced search user interface
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
53
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
54 @param macro: current macro instance
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
55 """
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
56 _ = macro._
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
57 f = macro.formatter
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
58 request = macro.request
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
59
1491
92c7972c8d54 grey out fields not currently supported by moinSearch if xapian disabled
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1488
diff changeset
60 disabledIfMoinSearch = not request.cfg.xapian_search and \
92c7972c8d54 grey out fields not currently supported by moinSearch if xapian disabled
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1488
diff changeset
61 ' disabled="disabled"' or ''
92c7972c8d54 grey out fields not currently supported by moinSearch if xapian disabled
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1488
diff changeset
62
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
63 search_boxes = ''.join([
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
64 f.table_row(1),
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
65 f.table_cell(1, attrs={'rowspan': '5', 'class': 'searchfor'}),
1460
44a52e7ff380 s/pages/items/g and s/include/exclude/g underlay
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1449
diff changeset
66 f.text(_('Search for items')),
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
67 f.table_cell(0),
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
68 ''.join([''.join([
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
69 f.table_row(1),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
70 f.table_cell(1),
1444
1a3c73509f15 info for last modification date in advanced ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1441
diff changeset
71 f.text(txt),
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
72 f.table_cell(0),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
73 f.table_cell(1),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
74 f.rawHTML(input_field),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
75 f.table_cell(0),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
76 f.table_row(0),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
77 ]) for txt, input_field in (
1374
aa33bb2b40d6 mimetype-search is live, i18n fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1373
diff changeset
78 (_('containing all the following terms'),
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
79 '<input type="text" name="and_terms" size="30" value="%s">'
1506
21e85d9d355e small cleanups, advanced ui can preserve search terms from other ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1501
diff changeset
80 % (form_get(request, 'and_terms') or form_get(request, 'value'))),
1374
aa33bb2b40d6 mimetype-search is live, i18n fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1373
diff changeset
81 (_('containing one or more of the following terms'),
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
82 '<input type="text" name="or_terms" size="30" value="%s">'
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
83 % form_get(request, 'or_terms')),
1374
aa33bb2b40d6 mimetype-search is live, i18n fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1373
diff changeset
84 (_('not containing the following terms'),
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
85 '<input type="text" name="not_terms" size="30" value="%s">'
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
86 % form_get(request, 'not_terms')),
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1372
diff changeset
87 #('containing only one of the following terms',
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
88 # '<input type="text" name="xor_terms" size="30" value="%s">'
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
89 # % form_get(request, 'xor_terms')),
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
90 # TODO: dropdown-box?
1444
1a3c73509f15 info for last modification date in advanced ui
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1441
diff changeset
91 (_('last modified since (e.g. last 2 weeks)'),
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
92 '<input type="text" name="mtime" size="30" value="%s">'
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
93 % form_get(request, 'mtime')),
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
94 )])
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
95 ])
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
96
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
97 # category selection
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
98 categories = form_get(request, 'categories')
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
99 c_select = makeSelection('categories',
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 3113
diff changeset
100 [('', _('any category'))] +
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
101 [(cat, '%s' % cat) for cat in getCategories(request)],
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
102 categories, 3, True)
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
103
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
104 # language selection
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
105 searchedlang = form_get(request, 'language')
1367
4c29aeea8bf7 languages dropdown menu
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1364
diff changeset
106 langs = dict([(lang, lmeta['x-language-in-english'])
1435
17e40b5bf1df reworked language list sorting
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1433
diff changeset
107 for lang, lmeta in languages.items()])
1449
e219092e1a0d a few small fixes to get misc things working with xapian
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1448
diff changeset
108 userlang = macro.request.lang
1509
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
109 lang_select = makeSelection('language',
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 3113
diff changeset
110 [('', _('any language')),
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
111 (userlang, langs[userlang])] + sorted(langs.items(), key=lambda i: i[1]),
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
112 searchedlang, 3, True)
1367
4c29aeea8bf7 languages dropdown menu
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1364
diff changeset
113
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
114 # mimetype selection
1488
2178a0153213 advanced search dialogue preserves state
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1460
diff changeset
115 mimetype = form_get(request, 'mimetype')
1509
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
116 mt_select = makeSelection('mimetype',
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 3113
diff changeset
117 [('', _('any mimetype'))] +
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
118 [(type, 'all %s files' % type) for type in getMimetypes()] +
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
119 [(m[1], '*%s - %s' % m) for m in sorted(mimetypes.types_map.items())],
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
120 mimetype, 3, True)
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
121
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
122 # misc search options (checkboxes)
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
123 search_options = ''.join([
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
124 ''.join([
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
125 f.table_row(1),
1372
6dacf2061124 cosmetic change for language and file type selection
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1371
diff changeset
126 f.table_cell(1, attrs={'class': 'searchfor'}),
6dacf2061124 cosmetic change for language and file type selection
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1371
diff changeset
127 txt[0],
6dacf2061124 cosmetic change for language and file type selection
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1371
diff changeset
128 f.table_cell(0),
6dacf2061124 cosmetic change for language and file type selection
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1371
diff changeset
129 f.table_cell(1, colspan=2),
1509
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
130 unicode(txt[1]),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
131 txt[2],
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
132 f.table_cell(0),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
133 f.table_row(0),
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
134 ]) for txt in (
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3040
diff changeset
135 (_('Categories'), unicode(c_select), ''),
1509
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
136 (_('Language'), unicode(lang_select), ''),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
137 (_('File Type'), unicode(mt_select), ''),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
138 ('', html.INPUT(type='checkbox', name='titlesearch',
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
139 value='1', checked=form_get(request, 'titlesearch'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
140 id='titlesearch'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
141 '<label for="titlesearch">%s</label>' % _('Search only in titles')),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
142 ('', html.INPUT(type='checkbox', name='case', value='1',
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
143 checked=form_get(request, 'case'), id='case'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
144 '<label for="case">%s</label>' % _('Case-sensitive search')),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
145 ('', html.INPUT(type='checkbox', name='excludeunderlay',
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
146 value='1', checked=form_get(request, 'excludeunderlay'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
147 id='excludeunderlay'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
148 '<label for="excludeunderlay">%s</label>' % _('Exclude underlay')),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
149 ('', html.INPUT(type='checkbox', name='nosystemitems',
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
150 value='1', checked=form_get(request, 'nosystemitems'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
151 id='nosystempages'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
152 '<label for="nosystempages">%s</label>' % _('No system items')),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
153 ('', html.INPUT(type='checkbox', name='historysearch',
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
154 value='1', checked=form_get(request, 'historysearch'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
155 disabled=(not request.cfg.xapian_search or
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
156 not request.cfg.xapian_index_history),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
157 id='historysearch'),
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
158 '<label for="historysearch">%s</label>' % _('Search in all page revisions'))
1376
649b60a4064a domain-secific search (for system pages)
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1374
diff changeset
159 )
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
160 ])
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
161
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
162 # the dialogue
1509
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
163 return f.rawHTML('\n'.join([
3040
8608b258f8e6 bug fix of MoinMoinBugs/MoveAttachmentNotWorkingWithModPython (thanks to Boleslaw Kulbabinski) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2725
diff changeset
164 u'<form method="get" action="%s/%s">' % (macro.request.getScriptname(), wikiutil.quoteWikinameURL(macro.request.formatter.page.page_name)),
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
165 u'<div>',
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
166 u'<input type="hidden" name="action" value="fullsearch">',
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
167 u'<input type="hidden" name="advancedsearch" value="1">',
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
168 f.table(1, attrs={'tableclass': 'advancedsearch'}),
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
169 search_boxes,
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
170 search_options,
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
171 f.table_row(1),
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
172 f.table_cell(1, attrs={'class': 'submit', 'colspan': '3'}),
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
173 u'<input type="submit" value="%s">' % _('Go get it!'),
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
174 f.table_cell(0),
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1367
diff changeset
175 f.table_row(0),
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
176 f.table(0),
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
177 u'</div>',
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
178 u'</form>',
1509
6cd9bcede8cf make use of MoinMoin.widget.html and MoinMoin.util.web, clickable labels for advaced ui checkboxes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1506
diff changeset
179 ]))
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
180
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
181
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
182 def execute(macro, needle):
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
183 # for now, just show the advanced ui
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1494
diff changeset
184 return advanced_ui(macro)
1364
12ddd8661ad6 basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
Franz Pletz <fpletz AT franz-pletz DOT org>
parents:
diff changeset
185