Hi *, I wrote a patch for a namespace restricted search as requested here [1] and here [2]. It uses "@" to separate the searchword form the namespace. eg: word@namespace will return all pagenames containing "word" inside the given namespace and performs a fulltext-search for "word" on them. @namespace will return a list of all pages inside the given namespace and fulltext-search is skipped (no given searchword). The patch is attached to this email (patched agains current darcs-version all patches applied). Maybe it could be improved somehow, any feedback/advice would be highly appreciated. Best Regards Michael [1] http://bugs.splitbrain.org/?do=details&id=627 [2] http://wiki.splitbrain.org/wiki:discussion:usability#search_only_a_namespace -- Michael Klier mail: chi@xxxxxxxxxxx www: http://www.chimeric.de icq: 206179334 key: http://www.chimeric.de/chi.asc key-id: 0x8308F551
New patches: [enhanced search 'Michael Klier <chi@xxxxxxxxxxx>'**20060518101059 - the search can now be restricted to a given namespace using '@' as separator Examples: word@namespace - search for pages containing "word" inside the given namespace and perform fulltext-search for "word" in the found pages @namespace - returns a list of all pages inside the given namespace fulltext-search is skipped ] { hunk ./inc/fulltext.php 150 -function ft_pageLookup($id,$pageonly=true){ +function ft_pageLookup($id,$ns='',$pageonly=true){ hunk ./inc/fulltext.php 153 + if(!empty($ns)) $ns = preg_quote($ns,'/'); hunk ./inc/fulltext.php 155 - $pages = array_values(preg_grep('/'.$id.'/',$pages)); + $pages = array_values(preg_grep('/^'.$ns.'.*?'.$id.'.*?$/',$pages)); hunk ./inc/html.php 378 - $data = ft_pageLookup(cleanID($QUERY)); + + if(preg_match('/^(.*?)@(.*?)$/',$QUERY,$match)) { + $QUERY = $match[1]; + $NS = $match[2]; + } + + $data = ft_pageLookup(cleanID($QUERY),cleanID($NS)); + hunk ./inc/html.php 403 - //do fulltext search - $data = ft_pageSearch($QUERY,$poswords); - if(count($data)){ - $num = 1; - foreach($data as $id => $cnt){ - print '<div class="search_result">'; - print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); - print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; - if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? - print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; + //skip fulltext search if QUERY is empty + if(!empty($QUERY)) { + //do fulltext search + $data = ft_pageSearch($QUERY,$poswords); + if(count($data)){ + $num = 1; + foreach($data as $id => $cnt){ + if(preg_match('/^'.$NS.'.*?$/',$id)) { + print '<div class="search_result">'; + print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); + print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; + if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? + print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; + } + print '</div>'; + flush(); + $num++; + } + } + }else{ + print '<div class="nothing">'.$lang['nothingfound'].'</div>'; hunk ./inc/html.php 425 - print '</div>'; - flush(); - $num++; - } - }else{ - print '<div class="nothing">'.$lang['nothingfound'].'</div>'; } Context: [gzip content-encoding option Ben Coburn <btcoburn@xxxxxxxxxxxxx>**20060516084132 - Enables gzip compression of output xhtml for browsers that support it. For example the wiki:syntax page takes up 46.80KB raw, but only 9.88KB gzip encoded. - Setting is configurable through the config plugin. ] [javascript fix to mak sumarry checking use addEvent Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060512073949] [avoid trolling in io_lock() Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060517165023] [lt lang update Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060517105635] [jpg quality option Ben Coburn <btcoburn@xxxxxxxxxxxxx>**20060516062321 - Adds a jpg quality setting for scaled images (Some images were getting too many jpg artifacts at the hard-coded compression setting.) - Creates a group for the media settings in the config plugin. ] [fr update Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060515190136] [nl update Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060515185820] [add config plugin support for plugin defined setting classes chris@xxxxxxxxxxxxx**20060511083209] [more info is gathered on metaupdate in background indexer Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060511191450 The background indexer now gathers info on contributors and modification dates from the changelog when adding the missing meta info. A new io_grep function was added which might be useful for other parts in the Wiki as well. ] [config plugin ui organization Ben Coburn <btcoburn@xxxxxxxxxxxxx>**20060510065732 - organizes the configuration settings list into chunks - provides a table of contents for the configuration chunks - provides one chunk for each plugin with configurable settings - provides one chunk for the active template (if it has settings) - provides the config file setting as a tool-tip on the setting label ex. $conf['start'] - provides for localization of useful strings - generates a "smart" fallback name for plugins and templates - plugin and template sections are only shown if they have settings - current configuration list is organized into chunks Note: There are NEW strings to translate into the non-english language files. ] [TAG develsnap 2006-05-07 Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060507173508] Patch bundle hash: 3cb2b89cfed4d8384e67e31e460dc2aabe669047