From f533c2edddfc22d131c60ebb83e40833bd8f5517 Mon Sep 17 00:00:00 2001 From: Cyrille Giquello Date: Sun, 6 Jan 2019 14:39:47 +0100 Subject: [PATCH 1/3] remove "Edit section" button --- syntax.php | 62 +++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/syntax.php b/syntax.php index 330d831..7b834de 100644 --- a/syntax.php +++ b/syntax.php @@ -3,10 +3,11 @@ /** * Info Alphaindex: Displays the alphabetical index of a specified namespace. * - * Version: 1.2 - * last modified: 2006-06-14 12:00:00 + * Version: 1.3 + * last modified: 2019-01-06 14:00:00 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Hubert Molière + * Modified by Cyrille G. * Modified by Nicolas H. * Modified by Jonesy * Modified by Samuele Tognini @@ -24,11 +25,11 @@ class syntax_plugin_alphaindex extends DokuWiki_Syntax_Plugin { function getType(){ return 'substition';} - + function getAllowedTypes() { return array('baseonly', 'substition', 'formatting', 'paragraphs', 'protected'); } function getPType() { return 'block'; } - + /** * Where to sort in? */ @@ -50,16 +51,16 @@ function handle($match, $state, $pos, Doku_Handler $handler){ $level = 0; $nons = true; $match = substr($match, 13, -2); - + // split namespaces $match = preg_split('/\|/u', $match, 2); - + // split level $ns_opt = preg_split('/\#/u', $match[0], 2); - + // namespace name $ns = $ns_opt[0]; - + // add @NS@ option if(empty($ns) || $ns == '@NS@') { $pos = strrpos($ID,':'); @@ -69,20 +70,20 @@ function handle($match, $state, $pos, Doku_Handler $handler){ $ns = '.'; } } - + // level; if (is_numeric($ns_opt[1])) { $level = $ns_opt[1]; } - - $match = explode(" ", $match[1]); - + + $match = explode(' ', $match[1]); + // namespaces option $nons = in_array('nons', $match); - + // multi-columns option $incol = in_array('incol', $match); - + return array($ns, array('level' => $level, 'nons' => $nons, 'incol' => $incol)); } @@ -101,15 +102,18 @@ function render($mode, Doku_Renderer $renderer, $data) { $n = 'No index for {{ns}}'; } } - + $alpha_data = str_replace('{{ns}}', cleanID($data[0]), $alpha_data); $alpha_data = p_render('xhtml', p_get_instructions($alpha_data), $info); // remove toc, section edit buttons and category tags $patterns = array('!
.*?(
\n)!s', - '##e', - '!
.*?
!s'); + // Remove all comments, to remove the "Edit section" button. + // by that way, it solves too the preg_replace() "/e" modifier deprecation. + //'##e', + '##m', + '!
.*?
!s'); $replace = array('','',''); $alpha_data = preg_replace($patterns, $replace, $alpha_data); $renderer->doc .= '
' ; @@ -119,7 +123,7 @@ function render($mode, Doku_Renderer $renderer, $data) { $renderer->doc .= '
' ; return true; } - + return false; } @@ -161,19 +165,19 @@ function _alpha_index($myns, &$renderer) { } else { $titleTpl = '===== Index ====='; } - + if($this->getConf('begin_letter_tpl')) { $beginLetterTpl = $this->getConf('begin_letter_tpl'); } else { $beginLetterTpl = '==== {{letter}} ===='; } - + if($this->getConf('entry_tpl')) { $entryTpl = $this->getConf('entry_tpl'); } else { $entryTpl = ' * [[{{link}}|{{name}}]]'; } - + if($this->getConf('end_letter_tpl')) { $endLetterTpl = $this->getConf('end_letter_tpl'); } else { @@ -202,7 +206,7 @@ function _alpha_index($myns, &$renderer) { $pos = strrpos(utf8_decode($tmpData), ':'); if($conf['useheading']) { $pageName = p_get_first_heading($tmpData); - + if($pageName == NULL) { if($pos != FALSE) { $pageName = utf8_substr($tmpData, $pos+1, utf8_strlen($tmpData)); @@ -217,7 +221,7 @@ function _alpha_index($myns, &$renderer) { } else { $pageName = $tmpData; } - + $pageName = str_replace('_', ' ', $pageName); } $pageNameArticle = ''; @@ -233,7 +237,7 @@ function _alpha_index($myns, &$renderer) { } } } - + // Fix for useheading - Decide if the heading is used or the pagename if($this->getConf('metadata_title')) { $tmp = p_get_metadata($data[$cpt]['id']); @@ -242,7 +246,7 @@ function _alpha_index($myns, &$renderer) { // R�cup�ration de la premi�re lettre du mot et classement $firstLetter = utf8_deaccent(utf8_strtolower(utf8_substr($pageName, 0, 1))); - + if(is_numeric($firstLetter)) { if($this->getConf('numerical_index')) { $firstLetter = $this->getConf('numerical_index'); @@ -275,7 +279,7 @@ function _alpha_index($myns, &$renderer) { // alphabetical index $alphaOutput .= $titleTpl . "\n"; $nb_data = count($alpha_data); - + foreach($alpha_data as $key => $currentLetter) { // Sorting of $currentLetter array usort($currentLetter, create_function('$a, $b', "return strnatcasecmp(\$a['id2'], \$b['id2']);")); @@ -308,7 +312,7 @@ function _alpha_index($myns, &$renderer) { function alphaindex_search_index(&$data, $base, $file, $type, $lvl, $opts) { $return = true; $item = array(); - + if($type == 'd'){ if ($opts['level'] == $lvl) $return = false; if ($opts['nons']) return $return; @@ -338,6 +342,6 @@ function alphaindex_search_index(&$data, $base, $file, $type, $lvl, $opts) { 'type' => $type, 'level' => $lvl, 'open' => $return); - + return $return; -} \ No newline at end of file +} From ec774f66e0314dc23225f514c39581b6fba7b41a Mon Sep 17 00:00:00 2001 From: Cyrille Giquello Date: Sun, 6 Jan 2019 17:42:52 +0100 Subject: [PATCH 2/3] change fix remove edit section button --- syntax.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/syntax.php b/syntax.php index 7b834de..e3ac80e 100644 --- a/syntax.php +++ b/syntax.php @@ -105,20 +105,30 @@ function render($mode, Doku_Renderer $renderer, $data) { $alpha_data = str_replace('{{ns}}', cleanID($data[0]), $alpha_data); + // Remove Section Edit Buttons + $oldmaxecl = $conf['maxseclevel']; + $conf['maxseclevel'] = 0; + $alpha_data = p_render('xhtml', p_get_instructions($alpha_data), $info); + $conf['maxseclevel'] = $oldmaxecl ; + + /* // remove toc, section edit buttons and category tags $patterns = array('!
.*?(
\n)!s', // Remove all comments, to remove the "Edit section" button. // by that way, it solves too the preg_replace() "/e" modifier deprecation. //'##e', - '##m', - '!
.*?
!s'); - $replace = array('','',''); + //'##', + //'##m', + //'!
.*?
!s' + ); + $replace = array(''); $alpha_data = preg_replace($patterns, $replace, $alpha_data); + */ $renderer->doc .= '
' ; - $renderer->doc .= $ns_data; - $renderer->doc .= '
'; + //$renderer->doc .= $ns_data; + //$renderer->doc .= '
'; $renderer->doc .= $alpha_data; $renderer->doc .= '
' ; return true; @@ -276,6 +286,8 @@ function _alpha_index($myns, &$renderer) { // Display of results + $alphaOutput = '' ; + // alphabetical index $alphaOutput .= $titleTpl . "\n"; $nb_data = count($alpha_data); From dcf1f1166ccc74c21945f0c9382b461a6287d8c6 Mon Sep 17 00:00:00 2001 From: Cyrille Giquello Date: Sun, 6 Jan 2019 18:01:57 +0100 Subject: [PATCH 3/3] do not display in TOC (should be an option) --- syntax.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/syntax.php b/syntax.php index e3ac80e..1ccc3ad 100644 --- a/syntax.php +++ b/syntax.php @@ -108,24 +108,14 @@ function render($mode, Doku_Renderer $renderer, $data) { // Remove Section Edit Buttons $oldmaxecl = $conf['maxseclevel']; $conf['maxseclevel'] = 0; + $oldmaxtoc = $conf['maxtoclevel']; + $conf['maxtoclevel'] = 0 ; $alpha_data = p_render('xhtml', p_get_instructions($alpha_data), $info); $conf['maxseclevel'] = $oldmaxecl ; + $conf['maxtoclevel'] = $oldmaxtoc ; - /* - // remove toc, section edit buttons and category tags - $patterns = array('!
.*?(
\n)!s', - // Remove all comments, to remove the "Edit section" button. - // by that way, it solves too the preg_replace() "/e" modifier deprecation. - //'##e', - //'##', - //'##m', - //'!
.*?
!s' - ); - $replace = array(''); - $alpha_data = preg_replace($patterns, $replace, $alpha_data); - */ $renderer->doc .= '
' ; //$renderer->doc .= $ns_data; //$renderer->doc .= '
';