About this, in order to have the same results as expected in the original attempt of TMurNGon, I would advise doing [(search group={p}.* fmt=toc when='! inlist header,footer, side,license,support,links,comments,invites,attachments {+page}' type=-number)] instead of [(search group={p}.* type=-header,footer,side,license,support,links,comments,invites,attachments fmt=toc when='! number {+page}')] since some.page.1-123 will be accepted by when="! number {+page}" but rejected by type=-number Cheers, Tiffany
Le mardi 26 janvier 2016 06:56:13 UTC+1, TMurNGon a écrit : > > Great, thanks Dan. I will give it a go. > > On Monday, 25 January 2016 16:48:08 UTC+2, Dan wrote: >> >> The number type is a special case rule and it doesn't work with a list >> like you have given. Either you check for a number/-number or you check for >> a list of types/-list of types. >> >> To do what you want, you have two options-- >> >> 1) Create a custom type rule which does what you want. More trouble but >> probably faster if you have a bunch of pages to process. >> >> 2) Use the when parameter to exclude numbers. >> >> [(search group={p}.* >> type=-header,footer,side,license,support,links,comments,invites,attachments >> fmt=toc when='! number {+page}')] >> >> For that matter, just for fun, you should be able to do: >> >> [(search group={p}.* fmt=toc when='! number {+page} && ! inlist >> header,footer,side,license,support,links,comments,invites,attachments >> {+page}')] >> >> Cheers, >> Dan >> >> On Mon, Jan 25, 2016 at 3:53 AM TMurNGon <tmur...@gmail.com> wrote: >> >>> Hi Dan, >>> >>> Given all of the above, how would I structure a 'page search' to exclude >>> both a few named pages and number pages? >>> I tried: >>> >>> [(search group={p}.* >>> type=-number,header,footer,side,license,support,links,comments,invites,attachments >>> >>> fmt=toc)] >>> >>> but this does not seem to interpret 'number' as a being a numeric page >>> name. It does exclude the named pages (footer, side, etc), but does not >>> exclude numeric pages; as [(search group={p}.* type=-number fmt=toc)] would. >>> >>> Also, what would be the appropriate syntax for specifically including >>> some pages and excluding others? Once the '-' is specified it seems to >>> exclude all mentioned pages. >>> >>> Thanks. >>> Jan >>> >>> >>> >>> On Sunday, 8 November 2015 13:35:32 UTC+2, Tiffany Grenier wrote: >>>> >>>> Hi again, >>>> It takes much longer to retrieve the results of [(search >>>> group=some.page when="number {+p}")] than [(search group=some.page >>>> type=number)]. Also, the results are slightly different because a page >>>> named "some.page.1-0" would pass the second example and be removed from >>>> the >>>> first one. I need to discriminate between pages like "some.page.1" and >>>> "some.page.1-0", and I wrote a BOLTCthread function that would validate >>>> both, while BOLTCnumber only validates the one without the dash, and I >>>> wanted these conditionals inside the search function. >>>> So I first thought about added "type=thread" (and modifying >>>> "type=number"). >>>> And then I considered putting in the type argument other conditions in >>>> order to go much faster. Like for example type=subthread as replacement >>>> for >>>> when="thread {+parent} && thread {+p}", which led me to separated the >>>> parat >>>> of searchResults that does this check and use instead a hookable function. >>>> >>>> Thus I propose the following change: >>>> --- library.php Sun Nov 08 12:29:55 2015 >>>> +++ library.php Sun Nov 08 12:30:48 2015 >>>> @@ -1775,20 +1775,6 @@ >>>> } >>>> if (count($outarray) == 0) return; >>>> if ($args['type'] == '') $args['type'] = BOLTconfig('searchType'); >>>> - $outarray = BOLTsearchResultsType($outarray,$args); >>>> - if (count($outarray) == 0) return; >>>> - if ($args['sort'] == '') natcasesort($outarray); >>>> - elseif ($args['sort'] != 'false') $outarray = >>>> BOLTsearchResultsSort($outarray, $args); >>>> - if ($args['order'] != '') { >>>> - if ($args['order'] == 'reverse' xor $args['sort'] == 'lastmodified') >>>> $outarray = array_reverse($outarray); >>>> - if ($args['order'] == 'random') shuffle($outarray); >>>> - } >>>> - if ($args['when'] != '' || $args['count'] != '') $outarray = >>>> BOLTsearchResultsWhenCount($outarray, $args); >>>> - return $outarray; >>>> - } >>>> - >>>> -function BOLTsearchResultsType($outarray,$args) { >>>> - if (function_exists('myBOLTsearchResultsType')) return >>>> myBOLTsearchResultsType($outarray, $args); >>>> if ($args['type'] == 'number') { >>>> foreach ($outarray as $p => $page) { >>>> $page = substr($page, strrpos($page, '.') + 1); >>>> @@ -1813,6 +1799,14 @@ >>>> elseif (strpos($type, $page) !== false) unset($outarray[$p]); >>>> } >>>> } >>>> + if (count($outarray) == 0) return; >>>> + if ($args['sort'] == '') natcasesort($outarray); >>>> + elseif ($args['sort'] != 'false') $outarray = >>>> BOLTsearchResultsSort($outarray, $args); >>>> + if ($args['order'] != '') { >>>> + if ($args['order'] == 'reverse' xor $args['sort'] == 'lastmodified') >>>> $outarray = array_reverse($outarray); >>>> + if ($args['order'] == 'random') shuffle($outarray); >>>> + } >>>> + if ($args['when'] != '' || $args['count'] != '') $outarray = >>>> BOLTsearchResultsWhenCount($outarray, $args); >>>> return $outarray; >>>> } >>>> >>>> And now I would very simply be able to write in a plugin: >>>> function myBOLTsearchResultsType($outarray,$args) { >>>> if ($args['type'] == 'subthread') { >>>> foreach ($outarray as $p => $page) { >>>> $parent = substr($page,0,strrpos($page, '.')); >>>> $page = substr($page, strrpos($page, '.') + 1); >>>> $page = str_replace('-', '', $page); >>>> if (! is_numeric($page)) unset($outarray[$p]); >>>> } >>>> } >>>> elseif ($args['type'] == 'thread') { >>>> foreach ($outarray as $p => $page) { >>>> $page = substr($page, strrpos($page, '.') + 1); >>>> $page = str_replace('-', '', $page); >>>> if (! is_numeric($page)) unset($outarray[$p]); >>>> } >>>> } >>>> elseif ($args['type'] == 'number') { >>>> foreach ($outarray as $p => $page) { >>>> $page = substr($page, strrpos($page, '.') + 1); >>>> if (! is_numeric($page)) unset($outarray[$p]); >>>> } >>>> } >>>> elseif ($args['type'] != '') { >>>> $type = strtolower(BOLTutf2url($args['type'])); >>>> $excludeType = true; >>>> if (substr($type, 0, 1) == '-') { >>>> $type = substr($type, 1); >>>> $excludeType = false; >>>> } >>>> $type = ',' . $type . ','; >>>> foreach ($outarray as $p => $page) { >>>> if (strpos($page, '.') !== false) $page = ',' . substr($page, >>>> strrpos($page, '.') + 1) . ','; >>>> else $page = ',' . $page . ','; >>>> if ($excludeType) { >>>> if (strpos($type, $page) === false) unset($outarray[$p]); >>>> } >>>> elseif (strpos($type, $page) !== false) unset($outarray[$p]); >>>> } >>>> } >>>> return $outarray; >>>> } >>>> >>>> >>>> Cheers, >>>> Tiffany/Maelite >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "BoltWire" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to boltwire+u...@googlegroups.com. >>> To post to this group, send email to bolt...@googlegroups.com. >>> Visit this group at https://groups.google.com/group/boltwire. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- You received this message because you are subscribed to the Google Groups "BoltWire" group. To unsubscribe from this group and stop receiving emails from it, send an email to boltwire+unsubscr...@googlegroups.com. To post to this group, send email to boltwire@googlegroups.com. Visit this group at https://groups.google.com/group/boltwire. For more options, visit https://groups.google.com/d/optout.