plugin:pageindex
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
plugin:pageindex [2010-04-21 13:12] – 93.128.239.158 | plugin:pageindex [2021-03-17 17:45] – Added a download link to a github gist, changed the update date, did NOT change the downloadUrl. jeffmikels | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== pageindex |
---- plugin ---- | ---- plugin ---- | ||
Line 6: | Line 6: | ||
email : kite@puzzlers.org | email : kite@puzzlers.org | ||
type : syntax | type : syntax | ||
- | lastupdate : 2006-08-01 | + | lastupdate : 2021-03-17 |
compatible : | compatible : | ||
depends | depends | ||
Line 12: | Line 12: | ||
similar | similar | ||
tags : navigation, menu, listing, namespace | tags : navigation, menu, listing, namespace | ||
+ | |||
+ | downloadurl: | ||
+ | bugtracker : | ||
+ | sourcerepo : | ||
+ | donationurl: | ||
+ | |||
+ | screenshot_img: | ||
---- | ---- | ||
+ | |||
+ | ===== Notes on this Updated Version (2021-03-17) ===== | ||
+ | |||
+ | The download link above is for the version released on 2006-08-01. | ||
+ | |||
+ | Below, I have added my 1.3 version, and I have also uploaded the code for // | ||
+ | |||
+ | https:// | ||
+ | |||
+ | < | ||
===== Usage ===== | ===== Usage ===== | ||
- | You can use one of two tag styles: | + | You can use one of four tag styles: |
- | * ~~PAGEINDEX=section: | + | |
- | * ~~PAGEINDEX~~ | + | |
- | I found that on the [[http://www.puzzlers.org]] website, we have sections which get lots of pages over a short time and cross-referencing was a chore since some users aren't as wiki-oriented as others. Now I just add a tag to each page and they automatically update over time. | + | * '' |
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
- | The list will //not// include the current page, either, to reduce confusion. | + | I found that on the [[http:// |
+ | |||
+ | The list will //never// include the current page, either, to reduce confusion. | ||
+ | |||
+ | **NOTE:** To keep your index up to date, you might want to add %%~~NOCACHE~~%% to pages where you use it. | ||
===== Installation ===== | ===== Installation ===== | ||
Line 29: | Line 51: | ||
Put the following code into **lib/ | Put the following code into **lib/ | ||
+ | ===== The Code ===== | ||
+ | ==== Version 1.3 ==== | ||
+ | <file php syntax.php> | ||
+ | <?php | ||
+ | /** | ||
+ | * Plugin page index: index table for pages in a name space | ||
+ | * | ||
+ | * @license | ||
+ | * @author | ||
+ | * @based_on | ||
+ | */ | ||
+ | |||
+ | if(!defined(' | ||
+ | define(' | ||
+ | } | ||
+ | if(!defined(' | ||
+ | define(' | ||
+ | } | ||
+ | require_once(DOKU_PLUGIN.' | ||
+ | require_once(DOKU_INC.' | ||
+ | function search_list_index(& | ||
+ | global $ID; | ||
+ | //we do nothing with directories | ||
+ | if($type == ' | ||
+ | if(preg_match('# | ||
+ | //check ACL | ||
+ | $id = pathID($file); | ||
+ | if(auth_quickaclcheck($id) < AUTH_READ){ | ||
+ | return false; | ||
+ | } | ||
+ | if($opts[' | ||
+ | $data[] = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | /** | ||
+ | * All DokuWiki plugins to extend the parser/ | ||
+ | * need to inherit from this class | ||
+ | */ | ||
+ | class syntax_plugin_pageindex extends DokuWiki_Syntax_Plugin { | ||
+ | |||
+ | /** | ||
+ | * return some info | ||
+ | */ | ||
+ | function getInfo(){ | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * What kind of syntax are we? | ||
+ | */ | ||
+ | function getType(){ | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | // Just before build in links | ||
+ | function getSort(){ return 299; } | ||
+ | |||
+ | /** | ||
+ | * What about paragraphs? | ||
+ | */ | ||
+ | function getPType(){ | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | function connectTo($mode) { | ||
+ | | ||
+ | // | ||
+ | } | ||
+ | |||
+ | |||
+ | /** | ||
+ | * Handle the match | ||
+ | */ | ||
+ | function handle($match, | ||
+ | $match = preg_replace(" | ||
+ | //echo " | ||
+ | return $match; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Create output | ||
+ | */ | ||
+ | function render($mode, | ||
+ | if($mode == ' | ||
+ | $text=$this-> | ||
+ | $renderer-> | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | |||
+ | function _pageindex(& | ||
+ | global $conf; | ||
+ | global $ID; | ||
+ | | ||
+ | // | ||
+ | |||
+ | /* | ||
+ | MODIFIED BY JEFF MIKELS TO CHANGE THE WAY THE PARAMETERS ARE HANDLED | ||
+ | ~~PAGEINDEX[=namespace[; | ||
+ | where excluded-pages are a semicolon-separated list of pages to exclude | ||
+ | and DESC (case insensitive) will reverse the sort order of the rendered index | ||
+ | */ | ||
+ | $dataparams = explode(',', | ||
+ | $parameters = explode(';', | ||
+ | $ns = cleanID(getNS(" | ||
+ | |||
+ | #fixme use appropriate function | ||
+ | if(empty($ns)){ | ||
+ | $ns = dirname(str_replace(':', | ||
+ | if($ns == ' | ||
+ | } | ||
+ | // | ||
+ | // | ||
+ | |||
+ | $search_data = array(); | ||
+ | $dir = $conf[' | ||
+ | $ns = str_replace(DIRECTORY_SEPARATOR,':', | ||
+ | $renderer-> | ||
+ | search($search_data, | ||
+ | $dir, | ||
+ | ' | ||
+ | array(' | ||
+ | ); | ||
+ | |||
+ | $checked = []; | ||
+ | |||
+ | // Remove the items not wanted in the list | ||
+ | if(is_array($parameters)) { | ||
+ | $skipitems = array_slice($parameters, | ||
+ | foreach($search_data as $item) { | ||
+ | $found = false; | ||
+ | // Add ns if user didn't | ||
+ | foreach($skipitems as $skip) { | ||
+ | $skip = strpos($skip,":" | ||
+ | if($item[' | ||
+ | $found = true; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if(!$found) { | ||
+ | // Pass this one through | ||
+ | $checked[] = $item; | ||
+ | } else { | ||
+ | // | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // use the filtered data rather than $search_data | ||
+ | if(count($checked)) { | ||
+ | |||
+ | // sort properly | ||
+ | if (!empty($dataparams[1]) && strtolower($dataparams[1]) == ' | ||
+ | $checked = array_reverse($checked); | ||
+ | } | ||
+ | |||
+ | /* Option to use an HTML List */ | ||
+ | $renderer-> | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | /* Option to use the PageList plugin */ | ||
+ | /* | ||
+ | $pages = $checked; | ||
+ | $pagelist =& plugin_load(' | ||
+ | if (!$pagelist) return false; // failed to load plugin | ||
+ | $pagelist-> | ||
+ | foreach ($pages as $page){ | ||
+ | $pagelist-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | */ | ||
+ | } else { | ||
+ | $renderer-> | ||
+ | } | ||
+ | } // _pageindex() | ||
+ | } // syntax_plugin_pageindex | ||
+ | </ | ||
- | ===== The Code ===== | ||
==== Version 1.2 ==== | ==== Version 1.2 ==== | ||
Line 98: | Line 317: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
); | ); | ||
} | } | ||
Line 218: | Line 437: | ||
</ | </ | ||
+ | |||
==== Version 1 ==== | ==== Version 1 ==== | ||
- | <code php> | + | <file php syntax.php> |
<?php | <?php | ||
/** | /** | ||
Line 281: | Line 501: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
); | ); | ||
} | } | ||
Line 401: | Line 621: | ||
} // syntax_plugin_pageindex | } // syntax_plugin_pageindex | ||
- | </code> | + | </file> |
===== Updates ===== | ===== Updates ===== | ||
+ | |||
+ | ==== March 17, 2021 ==== | ||
+ | |||
+ | I added another option to the pageindex code to change the page sorting of the generated indexes. | ||
+ | |||
+ | You can now write your pageindex code like this: | ||
+ | |||
+ | %%~~pageindex=namespace; | ||
+ | |||
+ | to get all the pages in // | ||
+ | |||
+ | |||
==== Oct 3, 2006 ==== | ==== Oct 3, 2006 ==== | ||
Line 420: | Line 652: | ||
I need also a listing of the namespace under the current namespace. How i have to modify the code? Can you show me an example. Thanks, Johann. | I need also a listing of the namespace under the current namespace. How i have to modify the code? Can you show me an example. Thanks, Johann. | ||
- | < | + | < |
*** syntax.php | *** syntax.php | ||
--- syntax.php | --- syntax.php | ||
Line 459: | Line 691: | ||
---- | ---- | ||
- | |||
- | |||
- | |||
- | |||
Line 469: | Line 697: | ||
We had to replace the line | We had to replace the line | ||
- | < | + | <code php> |
// New Oct 3, 2006 -- end | // New Oct 3, 2006 -- end | ||
$ns = cleanID(getNS(" | $ns = cleanID(getNS(" | ||
Line 476: | Line 704: | ||
with | with | ||
- | < | + | <code php> |
// New Oct 3, 2006 -- end | // New Oct 3, 2006 -- end | ||
$ns = cleanID(getNS(" | $ns = cleanID(getNS(" | ||
Line 511: | Line 739: | ||
- Stephen (stephen-dot-leedle-at-gmx-dot-de) | - Stephen (stephen-dot-leedle-at-gmx-dot-de) | ||
---- | ---- | ||
- | I prefer the [[http:// | + | I prefer the [[plugin: |
Just replace theses lines : | Just replace theses lines : | ||
< | < | ||
Line 555: | Line 783: | ||
---------------- | ---------------- | ||
+ | |||
+ | :!: It's not a bug, it's a feature | ||
+ | |||
+ | If you use some templates that make a sitemap on the right or on the left ... beware of redefinition of function search_list_index() | ||
+ | workaround is vi regexp in the pasted syntax.php : | ||
+ | <code bash> | ||
+ | : | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---------------- | ||
+ | |||
+ | |||
+ | |||
:!: Possible bug: No unicode (cyrillics, for example) support. | :!: Possible bug: No unicode (cyrillics, for example) support. | ||
+ | |||
+ | ---------------- | ||
+ | |||
+ | :!: Possible bug: Not obeying config: | ||
+ |
plugin/pageindex.txt · Last modified: 2023-12-16 23:13 by Aleksandr