dokufreaks / plugin-include

A DokuWiki plugin for including other wiki pages into the current one.
http://www.dokuwiki.org/plugin:include
GNU General Public License v2.0
62 stars 54 forks source link

Add 'exclude' option #243

Closed louwers closed 4 years ago

louwers commented 4 years ago

This PR adds an 'exclude' option that takes a regular expression as value. Pages of which the id matches the regular expression will be excluded. E.g.:

{{namespace>test&exclude=/test:some_page/}}

Looking at the diff, my editor also removed some trailing whitespace...

louwers commented 4 years ago

Here's a link to hide whitespace changes:

https://github.com/dokufreaks/plugin-include/pull/243/files?diff=split&w=1

michitux commented 4 years ago

Sorry for requesting yet another change. The include plugin is just really complex and while thinking about it I noticed that it would be beneficial to filter pages earlier. While the current implementation should work and should be okay, I think it would be much cleaner to do the exclusion in _get_included_pages in helper.php, more precisely in line 735, i.e., after collecting the pages but before sorting. We already have $flags passed to this function, so all necessary data should be there. Apart from being slightly cleaner software design imho, this has two benefits:

You should be able to use array_filter with a simple lambda to filter the pages.

louwers commented 4 years ago

No problem! I'll look into it. :+1:

michitux commented 4 years ago

Thank you very much for your contribution and for adapting the code! The code could be further improved by moving the check if the flag is set out of the loop and instead of returning true/false, the (negation of) the condition could be returned directly, but this is minor nitpicking and I will just merge it as it is. Could you then please also adapt the documentation?