Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.macro.FullSearch Namespace Reference

Functions

def search_box
def execute

Variables

list Dependencies = ["pages"]

Function Documentation

def MoinMoin.macro.FullSearch.execute (   macro,
  needle 
)

Definition at line 84 of file FullSearch.py.

00084 
00085 def execute(macro, needle):
00086     request = macro.request
00087     _ = request.getText
00088 
00089     # if no args given, invoke "classic" behavior
00090     if needle is None:
00091         return search_box("fullsearch", macro)
00092 
00093     # With empty arguments, simulate title click (backlinks to page)
00094     elif needle == '':
00095         needle = '"%s"' % macro.formatter.page.page_name
00096 
00097     # With whitespace argument, show error message like the one used in the search box
00098     # TODO: search should implement those errors message for clients
00099     elif needle.isspace():
00100         err = _('Please use a more selective search term instead of '
00101                 '{{{"%s"}}}', wiki=True) % needle
00102         return '<span class="error">%s</span>' % err
00103 
00104     needle = needle.strip()
00105 
00106     # Search the pages and return the results
00107     results = search.searchPages(request, needle, sort='page_name')
00108 
00109     return results.pageList(request, macro.formatter, paging=False)
00110 
00111 

Here is the call graph for this function:

def MoinMoin.macro.FullSearch.search_box (   type,
  macro 
)
Make a search box

Make both Title Search and Full Search boxes, according to type.

@param type: search box type: 'titlesearch' or 'fullsearch'
@rtype: unicode
@return: search box html fragment

Definition at line 35 of file FullSearch.py.

00035 
00036 def search_box(type, macro):
00037     """ Make a search box
00038 
00039     Make both Title Search and Full Search boxes, according to type.
00040 
00041     @param type: search box type: 'titlesearch' or 'fullsearch'
00042     @rtype: unicode
00043     @return: search box html fragment
00044     """
00045     _ = macro._
00046     if 'value' in macro.request.values:
00047         default = wikiutil.escape(macro.request.values["value"], quote=1)
00048     else:
00049         default = ''
00050 
00051     # Title search settings
00052     boxes = ''
00053     button = _("Search Titles")
00054 
00055     # Special code for fullsearch
00056     if type == "fullsearch":
00057         boxes = [
00058             u'<br>',
00059             u'<input type="checkbox" name="context" value="160" checked="checked">',
00060             _('Display context of search results'),
00061             u'<br>',
00062             u'<input type="checkbox" name="case" value="1">',
00063             _('Case-sensitive searching'),
00064             ]
00065         boxes = u'\n'.join(boxes)
00066         button = _("Search Text")
00067 
00068     # Format
00069     type = (type == "titlesearch")
00070     html = [
00071         u'<form method="get" action="%s">' % macro.request.href(macro.request.formatter.page.page_name),
00072         u'<div>',
00073         u'<input type="hidden" name="action" value="fullsearch">',
00074         u'<input type="hidden" name="titlesearch" value="%i">' % type,
00075         u'<input type="text" name="value" size="30" value="%s">' % default,
00076         u'<input type="submit" value="%s">' % button,
00077         boxes,
00078         u'</div>',
00079         u'</form>',
00080         ]
00081     html = u'\n'.join(html)
00082     return macro.formatter.rawHTML(html)
00083 

Here is the caller graph for this function:


Variable Documentation

Definition at line 32 of file FullSearch.py.