From d012fad75b86cf89301d922a2ca2626e1de4554f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de> Date: Thu, 13 Apr 2017 14:40:01 +0200 Subject: [PATCH] Move 'Back to top' pagetool to the end SPR-906 --- tpl.php | 86 ++++++++++++++++++++++++++++++++++++++++++ tpl/nav-page-tools.php | 73 +---------------------------------- 2 files changed, 88 insertions(+), 71 deletions(-) diff --git a/tpl.php b/tpl.php index 98a8663..b5a432f 100644 --- a/tpl.php +++ b/tpl.php @@ -97,4 +97,90 @@ class tpl { return $out; } + + /** + * Assemble the tools for the current page + * + * It also includes the tools for some plugins, if they are installed and enabled. This does currently not trigger + * any events, but should be adjusted to the standard dokuwiki template, once that has svg-functionality implemented. + * + * @return array + */ + static public function assemblePageTools() { + $data = array( + 'view' => 'main-svg', + 'items' => array( + 'edit' => static::pageToolAction('edit'), + 'revert' => static::pageToolAction('revert'), + 'revisions' => static::pageToolAction('revisions'), + 'backlink' => static::pageToolAction('backlink'), + 'subscribe' => static::pageToolAction('subscribe'), + ) + ); + + $data['items'] = array_map(function ($elem) { + return '<li>' . $elem . '</li>'; + },array_filter($data['items'])); + + /** + * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * Begin shims as a temporary solution until the svg-approach is mainlined and the plugins have adapted + * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + */ + global $ACT; + if (act_clean($ACT) === 'show') { + /** @var \action_plugin_move_rename $move */ + $move = plugin_load('action', 'move_rename'); + if ($move && $move->getConf('pagetools_integration')) { + $attr = array( + 'style' => 'background-image: none;', + ); + $item = \dokuwiki\template\sprintdoc\tpl::pageToolItem('', $move->getLang('renamepage'), __DIR__ . '/images/tools/41-format-paint.svg', $attr); + $data['items'][] = '<li class="plugin_move_page">' . $item . '</li>'; + } + + /** @var \action_plugin_odt_export $odt */ + $odt = plugin_load('action', 'odt_export'); + if ($odt && $odt->getConf('showexportbutton')) { + global $ID, $REV; + $params = array('do' => 'export_odt'); + if ($REV) { + $params['rev'] = $REV; + } + $attr = array( + 'class' => 'action export_pdf', + 'style' => 'background-image: none;', + ); + $svg = __DIR__ . '/images/tools/43-file-delimeted.svg'; + $item = \dokuwiki\template\sprintdoc\tpl::pageToolItem(wl($ID, $params, false, '&'), $odt->getLang('export_odt_button'), $svg, $attr); + $data['items'][] = '<li>' . $item . '</li>'; + } + + /** @var \action_plugin_dw2pdf $dw2pdf */ + $dw2pdf = plugin_load('action', 'dw2pdf'); + if ($dw2pdf && $dw2pdf->getConf('showexportbutton')) { + global $ID, $REV; + + $params = array('do' => 'export_pdf'); + if ($REV) { + $params['rev'] = $REV; + } + $attr = array( + 'class' => 'action export_pdf', + 'style' => 'background-image: none;', + ); + $svg = __DIR__ . '/images/tools/40-pdf-file.svg'; + $item = \dokuwiki\template\sprintdoc\tpl::pageToolItem(wl($ID, $params, false, '&'), $dw2pdf->getLang('export_pdf_button'), $svg, $attr); + $data['items'][] = '<li>' . $item . '</li>'; + } + } + /** + * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * End of shims + * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + */ + + $data['items']['top'] = '<li>' . static::pageToolAction('top') . '</li>'; + return $data; + } } diff --git a/tpl/nav-page-tools.php b/tpl/nav-page-tools.php index f57d335..1cd38a8 100755 --- a/tpl/nav-page-tools.php +++ b/tpl/nav-page-tools.php @@ -9,82 +9,13 @@ <?php include('nav-status.php');?> <ul> <?php - $data = array( - 'view' => 'main-svg', - 'items' => array( - 'edit' => dokuwiki\template\sprintdoc\tpl::pageToolAction('edit'), - 'revert' => dokuwiki\template\sprintdoc\tpl::pageToolAction('revert'), - 'revisions' => dokuwiki\template\sprintdoc\tpl::pageToolAction('revisions'), - 'backlink' => dokuwiki\template\sprintdoc\tpl::pageToolAction('backlink'), - 'subscribe' => dokuwiki\template\sprintdoc\tpl::pageToolAction('subscribe'), - 'top' => dokuwiki\template\sprintdoc\tpl::pageToolAction('top'), - ) - ); - + $data = dokuwiki\template\sprintdoc\tpl::assemblePageTools(); foreach ($data['items'] as $k => $html) { - if ($html) { - echo "<li>$html</li>"; - } + echo $html; } - /** - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Begin shims as a temporary solution until the svg-approach is mainlined and the plugins have adapted - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - */ - global $ACT; - if (act_clean($ACT) === 'show') { - /** @var action_plugin_move_rename $move */ - $move = plugin_load('action', 'move_rename'); - if ($move && $move->getConf('pagetools_integration')) { - $attr = array( - 'style' => 'background-image: none;', - ); - $item = \dokuwiki\template\sprintdoc\tpl::pageToolItem('', $move->getLang('renamepage'), __DIR__ . '/../images/tools/41-format-paint.svg', $attr); - echo '<li class="plugin_move_page">' . $item . '</li>'; - } - /** @var action_plugin_odt_export $odt */ - $odt = plugin_load('action', 'odt_export'); - if ($odt && $odt->getConf('showexportbutton')) { - global $ID, $REV; - $params = array('do' => 'export_odt'); - if ($REV) { - $params['rev'] = $REV; - } - $attr = array( - 'class' => 'action export_pdf', - 'style' => 'background-image: none;', - ); - $svg = __DIR__ . '/../images/tools/43-file-delimeted.svg'; - $item = \dokuwiki\template\sprintdoc\tpl::pageToolItem(wl($ID, $params, false, '&'), $odt->getLang('export_odt_button'), $svg, $attr); - echo '<li>' . $item . '</li>'; - } - - /** @var action_plugin_dw2pdf $dw2pdf */ - $dw2pdf = plugin_load('action', 'dw2pdf'); - if ($dw2pdf && $dw2pdf->getConf('showexportbutton')) { - global $ID, $REV; - - $params = array('do' => 'export_pdf'); - if ($REV) { - $params['rev'] = $REV; - } - $attr = array( - 'class' => 'action export_pdf', - 'style' => 'background-image: none;', - ); - $svg = __DIR__ . '/../images/tools/40-pdf-file.svg'; - $item = \dokuwiki\template\sprintdoc\tpl::pageToolItem(wl($ID, $params, false, '&'), $dw2pdf->getLang('export_pdf_button'), $svg, $attr); - echo '<li>' . $item . '</li>'; - } - } - /** - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * End of shims - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - */ ?> </ul>