Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion action.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ function _indexmenu_list_toc($item) {
* @author Samuele Tognini <samuele@samuele.netsons.org>
* @author Andreas Gohr <andi@splitbrain.org>
* @author Rene Hadler <rene.hadler@iteas.at>
* @author Ekkart Kleinod <ekleinod@edgesoft.de>
*/
function print_index($ns) {
require_once(DOKU_PLUGIN.'indexmenu/syntax/indexmenu.php');
Expand All @@ -301,6 +302,7 @@ function print_index($ns) {
$data = array();
$skipfile = array();
$skipns = array();
$maxcount = 0;

if($_REQUEST['max'] > 0) {
$max = $_REQUEST['max'];
Expand Down Expand Up @@ -333,6 +335,10 @@ function print_index($ns) {
$skipns[$index] = substr($skipn, 1);
}

if($_REQUEST['maxcount'] > 0) {
$maxcount = $_REQUEST['maxcount'];
}

$opts = array(
'level' => $level,
'nons' => $_REQUEST['nons'],
Expand All @@ -351,14 +357,19 @@ function print_index($ns) {
search($data, $conf['datadir'], array($idxm, '_search_index'), $opts, $fsdir);
}

if($maxcount > 0) {
// reduce items in array to maxcount, preserving keys
$data = array_slice($data, 0, $maxcount, true);
}

$out = '';
if($_REQUEST['nojs']) {
require_once(DOKU_INC.'inc/html.php');
$out_tmp = html_buildlist($data, 'idx', array($idxm, "_html_list_index"), "html_li_index");
$out .= preg_replace('/<ul class="idx">(.*)<\/ul>/s', "$1", $out_tmp);
} else {
$nodes = $idxm->_jsnodes($data, '', 0);
$out = "ajxnodes = [";
$out .= "ajxnodes = [";
$out .= rtrim($nodes[0], ",");
$out .= "];";
}
Expand Down
3 changes: 2 additions & 1 deletion lang/de-informal/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*
* @author Thomas Templin <templin@gnuwhv.de>
* @author Dana <dannax3@gmx.de>
*/
Expand Down Expand Up @@ -52,6 +52,7 @@
$lang['js']['nons'] = 'Nur Seiten zeigen';
$lang['js']['nopg'] = 'Nur Namensr&auml;ume zeigen';
$lang['js']['max'] = 'Wieviele Ebenen sollen mit Ajax geholt werden, wenn ein Knoten ge&ouml;ffnet wird? Au&szlig;erdem: wieviele Unterebenen unterhalb dieser Ebene sollen mit Ajax geholt werden anstatt w&auml;hrend des Seitenaufbaus?';
$lang['js']['maxcount'] = 'Wieviele Seiten sollen angezeigt werden?';
$lang['js']['maxjs'] = 'Wieviele Ebenen sollen im Browser statt auf dem Server gerendert werden, wenn ein Knoten ge&ouml;ffnet wird?';
$lang['js']['id'] = 'Benutzerspezifische Cookie-ID f&uml;r dieses indexmenu';
$lang['js']['insert'] = 'Indexmenu einf&uml;gen';
Expand Down
3 changes: 2 additions & 1 deletion lang/de/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*
* @author Fabian Pfannes <fpfannes@web.de>
* @author Dennis Plöger <develop@dieploegers.de>
* @author Kilian Maier <kilian.maier1@web.de>
Expand Down Expand Up @@ -55,6 +55,7 @@
$lang['js']['nons'] = 'Nur Seiten zeigen';
$lang['js']['nopg'] = 'Nur Namensräume zeigen';
$lang['js']['max'] = 'Wieviele Ebenen sollen mit AJAX geholt werden, wenn ein Knoten geöffnet wird? Außerdem: wieviele Unterebenen unterhalb dieser Ebene sollen mit AJAX geholt werden anstatt während des Seitenaufbaus?';
$lang['js']['maxcount'] = 'Wieviele Seiten sollen angezeigt werden?';
$lang['js']['maxjs'] = 'Wieviele Ebenen sollen im Browser statt auf dem Server gerendert werden, wenn ein Knoten geöffnet wird?';
$lang['js']['id'] = 'Benutzerspezifische Cookie-ID für dieses Indexmenu';
$lang['js']['insert'] = 'Indexmenu einfügen';
Expand Down
1 change: 1 addition & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
$lang['js']['nons'] = 'Show only pages';
$lang['js']['nopg'] = 'Show only namespaces';
$lang['js']['max'] = 'How many levels to render with ajax when a node is opened. Additional are how many sublevels below that level are retrieved with AJAX instead of in one go. ';
$lang['js']['maxcount'] = 'How many pages to show?';
$lang['js']['maxjs'] = 'How many levels to render in the client browser when a node is opened';
$lang['js']['id'] = 'Self defined cookie id for this indexmenu';
$lang['js']['insert'] = 'Insert indexmenu';
Expand Down
23 changes: 21 additions & 2 deletions syntax/indexmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function connectTo($mode) {
/**
* Handler to prepare matched data for the rendering process
*
* @author Samuele Tognini <samuele@samuele.netsons.org>
* @author Ekkart Kleinod <ekleinod@edgesoft.de>
*
* @param string $match The text matched by the patterns
* @param int $state The lexer state for the match
* @param int $pos The character position of the matched text
Expand All @@ -71,6 +74,7 @@ public function handle($match, $state, $pos, Doku_Handler $handler) {
$nss = array();
$skipns = array();
$skipfile = array();
$maxcount = 0;

$defaultsstr = $this->getConf('defaultoptions');
$defaults = explode(' ', $defaultsstr);
Expand Down Expand Up @@ -236,6 +240,12 @@ public function handle($match, $state, $pos, Doku_Handler $handler) {
$jsajax .= "&skipfile=" . utf8_encodeFN(($action == '+' ? '+' : '=') . $sf[1]);
}

// check maxcount option
if($maxcountvalue = $this->getOption($defaultsstr, $optsstr, '/maxcount#(\d+)/u')) {
$maxcount = $maxcountvalue;
}


//js options
$js_opts = compact('theme', 'identifier', 'nocookie', 'navbar', 'noscroll', 'maxjs', 'notoc', 'jsajax', 'context', 'nomenu');

Expand All @@ -258,7 +268,8 @@ public function handle($match, $state, $pos, Doku_Handler $handler) {
'headpage' => $this->getConf('headpage'),
'hide_headpage' => $this->getConf('hide_headpage')
),
$hsort
$hsort,
$maxcount
);
}

Expand Down Expand Up @@ -380,6 +391,7 @@ public function render($mode, Doku_Renderer $renderer, $data) {
*
* This function is a simple hack of Dokuwiki @see html_index($ns)
* @author Andreas Gohr <andi@splitbrain.org>
* @author Ekkart Kleinod <ekleinod@edgesoft.de>
*
* @param array $myns the options for indexmenu
* @return bool|string return html for a nojs index and when enabled the js rendered index, otherwise false
Expand All @@ -394,6 +406,7 @@ private function _indexmenu($myns) {
$this->nsort = $myns[5];
$opts = $myns[6]; //level, nons, nopg, nss, max, js, skip_index, skip_file, headpage, hide_headpage
$this->hsort = $myns[7];
$this->maxcount = $myns[8];
$data = array();
$js_name = "indexmenu_".$js_opts['identifier'];
$fsdir = "/".utf8_encodeFN(str_replace(':', '/', $ns));
Expand All @@ -402,6 +415,12 @@ private function _indexmenu($myns) {
} else {
search($data, $conf['datadir'], array($this, '_search_index'), $opts, $fsdir);
}

if($this->maxcount > 0) {
// reduce items in array to maxcount, preserving keys
$data = array_slice($data, 0, $this->maxcount, true);
}

if(!$data) return false;

// javascript index
Expand Down Expand Up @@ -965,4 +984,4 @@ private function _setorder($item) {
if($sort === false) $sort = noNS($item['id']);
return $sort;
}
} //Indexmenu class end
} //Indexmenu class end