summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/www/conf/local.php3
-rw-r--r--platform/www/conf/local.php.bak.php4
-rw-r--r--platform/www/lib/plugins/pageredirect/ChangeLog.md113
-rw-r--r--platform/www/lib/plugins/pageredirect/README.md30
-rw-r--r--platform/www/lib/plugins/pageredirect/action.php260
-rw-r--r--platform/www/lib/plugins/pageredirect/conf/default.php6
-rw-r--r--platform/www/lib/plugins/pageredirect/conf/metadata.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/images/important_small.pngbin0 -> 708 bytes
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/de-informal/lang.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/de-informal/settings.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/de/lang.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/de/settings.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/en/lang.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/en/settings.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/eo/lang.php11
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/eo/settings.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/fr/lang.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/fr/settings.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/ja/lang.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/ja/settings.php8
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/ko/lang.php11
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/ko/settings.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/pt-br/lang.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/ru/lang.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/ru/settings.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/zh-tw/lang.php10
-rw-r--r--platform/www/lib/plugins/pageredirect/lang/zh-tw/settings.php9
-rw-r--r--platform/www/lib/plugins/pageredirect/manager.dat2
-rw-r--r--platform/www/lib/plugins/pageredirect/plugin.info.txt7
-rw-r--r--platform/www/lib/plugins/pageredirect/style.css21
-rw-r--r--platform/www/lib/plugins/pageredirect/syntax.php157
31 files changed, 792 insertions, 3 deletions
diff --git a/platform/www/conf/local.php b/platform/www/conf/local.php
index d4bc65f..3d8358a 100644
--- a/platform/www/conf/local.php
+++ b/platform/www/conf/local.php
@@ -3,7 +3,7 @@
* Dokuwiki's Main Configuration File - Local Settings
* Auto-generated by config plugin
* Run for user: admin
- * Date: Mon, 07 Mar 2022 01:33:50 +0000
+ * Date: Tue, 08 Mar 2022 19:07:53 +0000
*/
$conf['title'] = 'The Acervus Project';
@@ -19,6 +19,7 @@ $conf['htmlok'] = 1;
$conf['userewrite'] = '1';
$conf['plugin']['authldap']['attributes'] = array();
$conf['plugin']['fastwiki']['save'] = 1;
+$conf['plugin']['pageredirect']['show_note'] = 0;
$conf['plugin']['translation']['translations'] = 'en es';
$conf['plugin']['translation']['display'] = 'langcode,name';
$conf['plugin']['translation']['translateui'] = 1;
diff --git a/platform/www/conf/local.php.bak.php b/platform/www/conf/local.php.bak.php
index 8649c89..d4bc65f 100644
--- a/platform/www/conf/local.php.bak.php
+++ b/platform/www/conf/local.php.bak.php
@@ -3,10 +3,10 @@
* Dokuwiki's Main Configuration File - Local Settings
* Auto-generated by config plugin
* Run for user: admin
- * Date: Mon, 07 Mar 2022 01:32:28 +0000
+ * Date: Mon, 07 Mar 2022 01:33:50 +0000
*/
-$conf['title'] = 'Acervus2';
+$conf['title'] = 'The Acervus Project';
$conf['start'] = 'index';
$conf['template'] = 'acervus';
$conf['license'] = '';
diff --git a/platform/www/lib/plugins/pageredirect/ChangeLog.md b/platform/www/lib/plugins/pageredirect/ChangeLog.md
new file mode 100644
index 0000000..c9a58f4
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/ChangeLog.md
@@ -0,0 +1,113 @@
+# Dokuwiki pageredirect plugin change log
+
+When writing entries, refer to [Keep a CHANGELOG](http://keepachangelog.com/) for guidelines.
+
+All notable changes to this project will be documented in this file.
+
+## [UNRELEASED]
+
+[UNRELEASED]: https://github.com/glensc/dokuwiki-plugin-pageredirect/compare/20220103...master
+
+## [20220103]
+
+- Partial support for backlinks with redirects by @michitux in #26
+- Esperanto translation in #30
+- Add informal german language by @ebroda in #33
+- Add redirection target to link metadata by @alexdraconian in #39
+
+[UNRELEASED]: https://github.com/glensc/dokuwiki-plugin-pageredirect/compare/20170512...20220103
+
+## [20170512]
+
+ - plugin now requires dokuwiki 2014-05-05 (Ponder Stibbons)
+ - revert broken implementation of adding `GET` parameters to url from [#16], fixes [#24], [#25]
+ - do not add parameters to url if the redirect is external. [133a129], [#25]
+ - fix fatal error when showing redirected message. [a04bcd9], [#23]
+ - fix plugin conflict with creole plugin. [36ebf4a], [#18]
+ - resolve page names to be absolute. [#19]
+ - added german translation [#27]
+
+[20170512]: https://github.com/glensc/dokuwiki-plugin-pageredirect/compare/20160924...20170512
+[#18]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/18
+[#19]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/19
+[#23]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/23
+[#24]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/24
+[#25]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/25
+[#27]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/27
+[133a129]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/133a129
+[36ebf4a]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/36ebf4a
+[a04bcd9]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/a04bcd9
+
+## [20160924]
+
+ - add French translations. [#14]
+ - display pagename if heading is undefined. [#15], [#9], [#13]
+ - preserve `GET` parameters when redirecting. [#16]
+ - add Russian translations. [#17]
+ - update Korean translations. [#21]
+ - fix test which is not passing with new version of Dokuwiki. [#22]
+
+[20160924]: https://github.com/glensc/dokuwiki-plugin-pageredirect/compare/20140414...20160924
+[#13]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/13
+[#14]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/14
+[#15]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/15
+[#16]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/16
+[#17]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/17
+[#21]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/21
+[#22]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/22
+[#9]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/9
+
+## [20140414]
+
+ - add `<br/>` tag to the redirect note to avoid being covered by page TOC. [#4]
+ - add Japanese translations. [#7]
+ - make `~~REDIRECT` pattern non-greedy. [#5], [#8]
+ - honour `conf['useheading']` for redirect note. [#6], [#8]
+ - basic support for external redirects. [#8]
+ - fix access to protected variable after [dokuwiki#555]. [#10], [#11]
+
+[20140414]: https://github.com/glensc/dokuwiki-plugin-pageredirect/compare/20120816...20140414
+[dokuwiki#555]: https://github.com/splitbrain/dokuwiki/pull/555
+[#10]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/10
+[#11]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/11
+[#4]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/4
+[#5]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/5
+[#6]: https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/6
+[#7]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/7
+[#8]: https://github.com/glensc/dokuwiki-plugin-pageredirect/pull/8
+
+## [20120816]
+
+ - allow `#redirect` syntax to be lowercase, but it must be start on line. [1362442]
+
+[20120816]: https://github.com/glensc/dokuwiki-plugin-pageredirect/compare/20120612...20120816
+[1362442]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/1362442
+
+## [20120612]
+
+ - match anything in page name, to wiki path it is converted internally. [f423934]
+ - preserve `#section` anchors on redirect. [c31b525]
+ - make redirects 301 redirect permanently to be SEO friendly, [9796335]
+ - apply prevent conflict patch from wiki comments. [87145da]
+ - add alternative `#REDIRECT namespace/pagename` syntax. [01efce2]
+ - add zh-tw translations. [82539ae]
+ - add Korean translations. [6aa688d]
+ - add portugese translations. [e22f33a]
+ - fix matching page with `#REDIRECT` syntax. [4dca632]
+
+[20120612]: https://github.com/glensc/dokuwiki-plugin-pageredirect/compare/20070124...20120612
+[01efce2]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/01efce2
+[4dca632]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/4dca632
+[6aa688d]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/6aa688d
+[82539ae]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/82539ae
+[87145da]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/87145da
+[9796335]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/9796335
+[c31b525]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/c31b525
+[e22f33a]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/e22f33a
+[f423934]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commit/f423934
+
+## [20070124]
+
+ - Build 2
+
+[20070124]: https://github.com/glensc/dokuwiki-plugin-pageredirect/commits/20070124
diff --git a/platform/www/lib/plugins/pageredirect/README.md b/platform/www/lib/plugins/pageredirect/README.md
new file mode 100644
index 0000000..6dc268c
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/README.md
@@ -0,0 +1,30 @@
+Page Redirect Plugin for DokuWiki
+=================================
+
+[![Build Status](https://travis-ci.org/glensc/dokuwiki-plugin-pageredirect.svg?branch=master)](https://travis-ci.org/glensc/dokuwiki-plugin-pageredirect)
+
+Redirects page requests based on content
+
+All documentation for this plugin can be found at
+https://www.dokuwiki.org/plugin:pageredirect
+
+If you install this plugin manually, make sure it is installed in
+`lib/plugins/pageredirect/` - if the folder is called different it
+will not work!
+
+Please refer to http://www.dokuwiki.org/plugins for additional info
+on how to install plugins in DokuWiki.
+
+----
+Copyright (C) Elan Ruusamäe <glen@delfi.ee>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; version 2 of the License
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+See the COPYING file in your DokuWiki folder for details
diff --git a/platform/www/lib/plugins/pageredirect/action.php b/platform/www/lib/plugins/pageredirect/action.php
new file mode 100644
index 0000000..735a89c
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/action.php
@@ -0,0 +1,260 @@
+<?php
+/**
+ * DokuWiki Plugin pageredirect (Action Component)
+ *
+ * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
+ * @author Elan Ruusamäe <glen@delfi.ee>
+ * @author David Lorentsen <zyberdog@quakenet.org>
+ */
+
+// must be run within Dokuwiki
+if(!defined('DOKU_INC')) die();
+
+class action_plugin_pageredirect extends DokuWiki_Action_Plugin {
+ /**
+ * Registers a callback function for a given event
+ *
+ * @param Doku_Event_Handler $controller DokuWiki's event controller object
+ */
+ public function register(Doku_Event_Handler $controller) {
+ /* @see action_plugin_pageredirect::handle_dokuwiki_started() */
+ $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handle_dokuwiki_started');
+ /* @see action_plugin_pageredirect::handle_parser_metadata_render() */
+ $controller->register_hook('PARSER_METADATA_RENDER', 'BEFORE', $this, 'handle_parser_metadata_render');
+
+ // This plugin goes first, PR#555, requires dokuwiki 2014-05-05 (Ponder Stibbons)
+ /* @see action_plugin_pageredirect::handle_tpl_act_render() */
+ $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'handle_tpl_act_render', null, PHP_INT_MIN);
+
+ $controller->register_hook('INDEXER_PAGE_ADD', 'BEFORE', $this, 'handle_indexer');
+
+ // Handle move plugin
+ $controller->register_hook('PLUGIN_MOVE_HANDLERS_REGISTER', 'BEFORE', $this, 'handle_move_register');
+
+ }
+
+ public function handle_dokuwiki_started(&$event, $param) {
+ global $ID, $ACT, $REV;
+
+ // skip when looking page history or action is not 'show'
+ if(($ACT != 'show' && $ACT != '') || $REV) {
+ return;
+ }
+
+ $metadata = $this->get_metadata($ID);
+
+ // return if no redirection data
+ if(!$metadata) {
+ return;
+ }
+ list($page, $is_external) = $metadata;
+
+ global $INPUT;
+ $redirect = $INPUT->get->str('redirect', '0');
+
+ // return if redirection is temporarily disabled,
+ // or we have been redirected 5 times in a row
+ if($redirect == 'no' || $redirect > 4) {
+ return;
+ }
+ $redirect = (int)$redirect+1;
+
+ // verify metadata currency
+ // FIXME: why
+ if(@filemtime(metaFN($ID, '.meta')) < @filemtime(wikiFN($ID))) {
+ throw new Exception('should not get here');
+ return;
+ }
+
+ // preserve #section from $page
+ list($page, $section) = explode('#', $page, 2);
+ if(isset($section)) {
+ $section = '#' . $section;
+ } else {
+ $section = '';
+ }
+
+ // prepare link for internal redirects, keep external targets
+ if(!$is_external) {
+ $page = wl($page, array('redirect' => $redirect), true, '&');
+
+ if($this->getConf('show_note')) {
+ $this->flash_message($ID);
+ }
+
+ // add anchor if not external redirect
+ $page .= $section;
+ }
+
+ $this->redirect($page);
+ }
+
+ public function handle_tpl_act_render(&$event, $param) {
+ global $ACT;
+
+ // handle on do=show
+ if($ACT != 'show' && $ACT != '') {
+ return true;
+ }
+
+ if($this->getConf('show_note')) {
+ $this->render_flash();
+ }
+
+ return true;
+ }
+
+ public function handle_parser_metadata_render(&$event, $param) {
+ if(isset($event->data->meta['relation'])) {
+ // FIXME: why is this needed here?!
+ unset($event->data->meta['relation']['isreplacedby']);
+ }
+ }
+
+ public function handle_indexer(Doku_Event $event, $param) {
+ $new_references = array();
+ foreach ($event->data['metadata']['relation_references'] as $target) {
+ $redirect_target = $this->get_metadata($target);
+
+ if ($redirect_target) {
+ list($page, $is_external) = $redirect_target;
+
+ if (!$is_external) {
+ $new_references[] = $page;
+ }
+ }
+ }
+
+ if (count($new_references) > 0) {
+ $event->data['metadata']['relation_references'] = array_unique(array_merge($new_references, $event->data['metadata']['relation_references']));
+ }
+
+ // FIXME: if the currently indexed page contains a redirect, all pages pointing to it need a new backlink entry!
+ // Note that these entries need to be added for every source page separately.
+ // An alternative could be to force re-indexing of all source pages by removing their ".indexed" file but this will only happen when they are visited.
+ }
+
+ /**
+ * remember to show note about being redirected from another page
+ * @param string $ID page id from where the redirect originated
+ */
+ private function flash_message($ID) {
+ if(headers_sent()) {
+ // too late to do start session
+ // and following code requires session
+ return;
+ }
+
+ session_start();
+ $_SESSION[DOKU_COOKIE]['redirect'] = $ID;
+ }
+
+ /**
+ * show note about being redirected from another page
+ */
+ private function render_flash() {
+ global $INPUT;
+
+ $redirect = $INPUT->get->str('redirect');
+
+ // loop counter
+ if($redirect <= 0 || $redirect > 5) {
+ return;
+ }
+
+ $ID = isset($_SESSION[DOKU_COOKIE]['redirect']) ? $_SESSION[DOKU_COOKIE]['redirect'] : null;
+ if(!$ID) {
+ return;
+ }
+ unset($_SESSION[DOKU_COOKIE]['redirect']);
+
+ $page = cleanID($ID);
+ $use_heading = useHeading('navigation') && p_get_first_heading($page);
+ $title = hsc($use_heading ? p_get_first_heading($page) : $page);
+
+ $url = wl($page, array('redirect' => 'no'), true, '&');
+ $link = '<a href="' . $url . '" class="wikilink1" title="' . $page . '">' . $title . '</a>';
+ echo '<div class="noteredirect">' . sprintf($this->getLang('redirected_from'), $link) . '</div><br/>';
+ }
+
+ private function get_metadata($ID) {
+ // make sure we always get current metadata, but simple cache logic (i.e. render when page is newer than metadata) is enough
+ $metadata = p_get_metadata($ID, 'relation isreplacedby', METADATA_RENDER_USING_SIMPLE_CACHE|METADATA_RENDER_UNLIMITED);
+
+ // legacy compat
+ if(is_string($metadata)) {
+ $metadata = array($metadata);
+ }
+
+ return $metadata;
+ }
+
+ /**
+ * Redirect to url.
+ * @param string $url
+ */
+ private function redirect($url) {
+ header("HTTP/1.1 301 Moved Permanently");
+ send_redirect($url);
+ }
+
+ public function handle_move_register(Doku_Event $event, $params) {
+ $event->data['handlers']['pageredirect'] = array($this, 'rewrite_redirect');
+ }
+
+ public function rewrite_redirect($match, $state, $pos, $plugin, helper_plugin_move_handler $handler) {
+
+ $metadata = $this->get_metadata($ID);
+ if ($metadata[1]) return $match; // Fail-safe for external redirection (Do not rewrite)
+
+ $match = trim($match);
+
+ if (substr($match, 0, 1) == "~") {
+ // "~~REDIRECT>pagename#anchor~~" pattern
+
+ // Strip syntax
+ $match = substr($match, 2, strlen($match) - 4);
+
+ list($syntax, $src, $anchor) = array_pad(preg_split("/>|#/", $match), 3, "");
+
+ // Resolve new source.
+ if (method_exists($handler, 'adaptRelativeId')) {
+ $new_src = $handler->adaptRelativeId($src);
+ } else {
+ $new_src = $handler->resolveMoves($src, 'page');
+ $new_src = $handler->relativeLink($src, $new_src, 'page');
+ }
+
+ $result = "~~".$syntax.">".$new_src;
+ if (!empty($anchor)) $result .= "#".$anchor;
+ $result .= "~~";
+
+ return $result;
+
+ } else if (substr($match, 0, 1) == "#") {
+ // "#REDIRECT pagename#anchor" pattern
+
+ // Strip syntax
+ $match = substr($match, 1);
+
+ list($syntax, $src, $anchor) = array_pad(preg_split("/ |#/", $match), 3, "");
+
+ // Resolve new source.
+ if (method_exists($handler, 'adaptRelativeId')) {
+ $new_src = $handler->adaptRelativeId($src);
+ } else {
+ $new_src = $handler->resolveMoves($src, 'page');
+ $new_src = $handler->relativeLink($src, $new_src, 'page');
+ }
+
+ $result = "\n#".$syntax." ".$new_src;
+ if (!empty($anchor)) $result .= "#".$anchor;
+
+ return $result;
+ }
+
+ // Fail-safe
+ return $match;
+
+ }
+}
diff --git a/platform/www/lib/plugins/pageredirect/conf/default.php b/platform/www/lib/plugins/pageredirect/conf/default.php
new file mode 100644
index 0000000..75ec719
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/conf/default.php
@@ -0,0 +1,6 @@
+<?php
+/**
+ * Options for the Page Redirect plugin
+ */
+
+$conf['show_note'] = 1; // Display a note about having been redirected on the new page.
diff --git a/platform/www/lib/plugins/pageredirect/conf/metadata.php b/platform/www/lib/plugins/pageredirect/conf/metadata.php
new file mode 100644
index 0000000..2de251f
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/conf/metadata.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * Metadata for configuration manager plugin
+ * Additions for the Page Redirect plugin
+ *
+ * @author David Lorentsen <zyberdog@quakenet.org>
+ */
+
+$meta['show_note'] = array('onoff');
diff --git a/platform/www/lib/plugins/pageredirect/images/important_small.png b/platform/www/lib/plugins/pageredirect/images/important_small.png
new file mode 100644
index 0000000..80e4c08
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/images/important_small.png
Binary files differ
diff --git a/platform/www/lib/plugins/pageredirect/lang/de-informal/lang.php b/platform/www/lib/plugins/pageredirect/lang/de-informal/lang.php
new file mode 100644
index 0000000..8f76915
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/de-informal/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * German language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Oliver Völker <info@ovtec.it>
+ */
+
+$lang['redirect_to'] = "Diese Seite wurde verschoben, die neue URL lautet %s.";
+$lang['redirected_from'] = "Du wurdest von %s hierher umgeleitet.";
diff --git a/platform/www/lib/plugins/pageredirect/lang/de-informal/settings.php b/platform/www/lib/plugins/pageredirect/lang/de-informal/settings.php
new file mode 100644
index 0000000..0d825c8
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/de-informal/settings.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * German language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Oliver Völker <info@ovtec.it>
+ */
+
+$lang['show_note'] = 'Auf der Zielseite einen Hinweis zur Umleitung anzeigen?';
diff --git a/platform/www/lib/plugins/pageredirect/lang/de/lang.php b/platform/www/lib/plugins/pageredirect/lang/de/lang.php
new file mode 100644
index 0000000..986f73a
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/de/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * German language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Oliver Völker <info@ovtec.it>
+ */
+
+$lang['redirect_to'] = "Diese Seite wurde verschoben, die neue URL lautet %s.";
+$lang['redirected_from'] = "Sie wurden von %s hierher umgeleitet.";
diff --git a/platform/www/lib/plugins/pageredirect/lang/de/settings.php b/platform/www/lib/plugins/pageredirect/lang/de/settings.php
new file mode 100644
index 0000000..0d825c8
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/de/settings.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * German language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Oliver Völker <info@ovtec.it>
+ */
+
+$lang['show_note'] = 'Auf der Zielseite einen Hinweis zur Umleitung anzeigen?';
diff --git a/platform/www/lib/plugins/pageredirect/lang/en/lang.php b/platform/www/lib/plugins/pageredirect/lang/en/lang.php
new file mode 100644
index 0000000..ef0d944
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/en/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * English language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : David Lorentsen <zyberdog@quakenet.org>
+ */
+
+$lang['redirect_to'] = "This page has been moved, the new location is %s.";
+$lang['redirected_from'] = "You were redirected here from %s.";
diff --git a/platform/www/lib/plugins/pageredirect/lang/en/settings.php b/platform/www/lib/plugins/pageredirect/lang/en/settings.php
new file mode 100644
index 0000000..a12a101
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/en/settings.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * English language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : David Lorentsen <zyberdog@quakenet.org>
+ */
+
+$lang['show_note'] = 'Display note on page you are redirected to?';
diff --git a/platform/www/lib/plugins/pageredirect/lang/eo/lang.php b/platform/www/lib/plugins/pageredirect/lang/eo/lang.php
new file mode 100644
index 0000000..58881f7
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/eo/lang.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Esperanto language for Page Redirect plugin
+ * Lingvo Esperanto por kromaĵo Page Redirect
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Reedych <reedych@ya.ru>
+ */
+
+$lang['redirect_to'] = "Ĉi tiu paĝo estas movita, nova loko estas %s.";
+$lang['redirected_from'] = "Vi estas alidirektita ĉi tien el %s."; \ No newline at end of file
diff --git a/platform/www/lib/plugins/pageredirect/lang/eo/settings.php b/platform/www/lib/plugins/pageredirect/lang/eo/settings.php
new file mode 100644
index 0000000..0273dc8
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/eo/settings.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Esperanto language for Page Redirect plugin
+ * Lingvo Esperanto por kromaĵo Page Redirect
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Reedych <reedych@ya.ru>
+ */
+
+$lang['show_note'] = 'Montri rimarkon sur paĝo ke vi estas alidirektita?'; \ No newline at end of file
diff --git a/platform/www/lib/plugins/pageredirect/lang/fr/lang.php b/platform/www/lib/plugins/pageredirect/lang/fr/lang.php
new file mode 100644
index 0000000..025dd3b
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/fr/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * French language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Cinlloc Melnec <cinlloc@gmail.com>
+ */
+
+$lang['redirect_to'] = "Cette page a été déplacée, le nouvel emplacement est %s.";
+$lang['redirected_from'] = "Vous avez été redirigé depuis %s.";
diff --git a/platform/www/lib/plugins/pageredirect/lang/fr/settings.php b/platform/www/lib/plugins/pageredirect/lang/fr/settings.php
new file mode 100644
index 0000000..a11304a
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/fr/settings.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * French language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Cinlloc Melnec <cinlloc@gmail.com>
+ */
+
+$lang['show_note'] = 'Afficher une note sur la page vers laquelle vous êtes redirigé ?';
diff --git a/platform/www/lib/plugins/pageredirect/lang/ja/lang.php b/platform/www/lib/plugins/pageredirect/lang/ja/lang.php
new file mode 100644
index 0000000..62a892c
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/ja/lang.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * Japanese language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Ikuo Obataya https://github.com/iobataya
+ */
+$lang['redirect_to'] = "このページは移動しました。新しいページは %s です。";
+$lang['redirected_from'] = "ページ「%s」からリダイレクトされました。";
diff --git a/platform/www/lib/plugins/pageredirect/lang/ja/settings.php b/platform/www/lib/plugins/pageredirect/lang/ja/settings.php
new file mode 100644
index 0000000..c9d84b2
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/ja/settings.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Japanese language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Ikuo Obataya https://github.com/iobataya
+ */
+$lang['show_note'] = 'リダイレクトされたことを表示する。';
diff --git a/platform/www/lib/plugins/pageredirect/lang/ko/lang.php b/platform/www/lib/plugins/pageredirect/lang/ko/lang.php
new file mode 100644
index 0000000..7a04274
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/ko/lang.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Korean language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : wincomi <http://forum.dokuwiki.org/user/8622>
+ * @author : Myeongjin <aranet100@gmail.com>
+ */
+
+$lang['redirect_to'] = "이 문서는 옮겨졌으며, 새 위치는 %s입니다.";
+$lang['redirected_from'] = "%s에서 넘어왔습니다.";
diff --git a/platform/www/lib/plugins/pageredirect/lang/ko/settings.php b/platform/www/lib/plugins/pageredirect/lang/ko/settings.php
new file mode 100644
index 0000000..27e93bd
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/ko/settings.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Korean language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : wincomi <http://forum.dokuwiki.org/user/8622>
+ * @author : Myeongjin <aranet100@gmail.com>
+ */
+
+$lang['show_note'] = '넘어오는 문서에 메모를 보여줄까요?';
diff --git a/platform/www/lib/plugins/pageredirect/lang/pt-br/lang.php b/platform/www/lib/plugins/pageredirect/lang/pt-br/lang.php
new file mode 100644
index 0000000..ad1ae86
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/pt-br/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Portuguese-br language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Juliano Cezar <jcp%40live.de>
+ */
+
+$lang['redirect_to'] = "Esta página é um redirecionador para %s.";
+$lang['redirected_from'] = "Você foi redirecionado de %s.";
diff --git a/platform/www/lib/plugins/pageredirect/lang/ru/lang.php b/platform/www/lib/plugins/pageredirect/lang/ru/lang.php
new file mode 100644
index 0000000..bcd5b29
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/ru/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Russian language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Sergey Slipchenko <faergeek@gmail.com>
+ */
+
+$lang['redirect_to'] = "Страница была перемещена по адресу %s.";
+$lang['redirected_from'] = "Вы были перенаправлены сюда со страницы %s.";
diff --git a/platform/www/lib/plugins/pageredirect/lang/ru/settings.php b/platform/www/lib/plugins/pageredirect/lang/ru/settings.php
new file mode 100644
index 0000000..30635be
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/ru/settings.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * Russian language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Sergey Slipchenko <faergeek@gmail.com>
+ */
+
+$lang['show_note'] = 'Показывать примечание на странице, на которую было сделано перенаправление?';
diff --git a/platform/www/lib/plugins/pageredirect/lang/zh-tw/lang.php b/platform/www/lib/plugins/pageredirect/lang/zh-tw/lang.php
new file mode 100644
index 0000000..f6e1e87
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/zh-tw/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Traditional Chinese language for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Danny Lin <danny0838[at]pchome[dot]com[dot]tw>
+ */
+
+$lang['redirect_to'] = "本頁已重定向至 %s。";
+$lang['redirected_from'] = "本頁重定向自 %s。";
diff --git a/platform/www/lib/plugins/pageredirect/lang/zh-tw/settings.php b/platform/www/lib/plugins/pageredirect/lang/zh-tw/settings.php
new file mode 100644
index 0000000..3476b3e
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/lang/zh-tw/settings.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * Traditional Chinese for Page Redirect plugin
+ *
+ * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author : Danny Lin <danny0838[at]pchome[dot]com[dot]tw>
+ */
+
+$lang['show_note'] = '在重定向目標頁顯示提示?';
diff --git a/platform/www/lib/plugins/pageredirect/manager.dat b/platform/www/lib/plugins/pageredirect/manager.dat
new file mode 100644
index 0000000..8d0a3bf
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/manager.dat
@@ -0,0 +1,2 @@
+downloadurl=https://github.com/glensc/dokuwiki-plugin-pageredirect/zipball/master
+installed=Tue, 08 Mar 2022 19:05:47 +0000
diff --git a/platform/www/lib/plugins/pageredirect/plugin.info.txt b/platform/www/lib/plugins/pageredirect/plugin.info.txt
new file mode 100644
index 0000000..9a60edf
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/plugin.info.txt
@@ -0,0 +1,7 @@
+base pageredirect
+author Elan Ruusamäe, David Lorentsen
+email glen@delfi.ee
+date 2022-01-03
+name Page Redirect
+desc Redirects page requests based on content
+url https://www.dokuwiki.org/plugin:pageredirect
diff --git a/platform/www/lib/plugins/pageredirect/style.css b/platform/www/lib/plugins/pageredirect/style.css
new file mode 100644
index 0000000..9008a39
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/style.css
@@ -0,0 +1,21 @@
+.noteredirect {
+ margin: 1em;
+ margin-left: auto;
+ margin-right: auto;
+ width: 70% !important;
+ min-height: 18px;
+ clear: both;
+ text-align: justify;
+ vertical-align: middle;
+ border-collapse: collapse;
+ padding: 7px 10px 5px 32px;
+ background-position: 10px 50%;
+ background-repeat: no-repeat;
+ -moz-border-radius: 10px;
+ -khtml-border-radius: 10px;
+ border-radius: 10px;
+
+ /*border: 1px solid #B5E0FF;*/
+ background-color: #B5E0FF;
+ background-image: url(images/important_small.png);
+}
diff --git a/platform/www/lib/plugins/pageredirect/syntax.php b/platform/www/lib/plugins/pageredirect/syntax.php
new file mode 100644
index 0000000..4b34a9c
--- /dev/null
+++ b/platform/www/lib/plugins/pageredirect/syntax.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * DokuWiki Plugin pageredirect (Syntax Component)
+ *
+ * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
+ * @author Elan Ruusamäe <glen@delfi.ee>
+ * @author David Lorentsen <zyberdog@quakenet.org>
+ */
+
+// must be run within Dokuwiki
+if(!defined('DOKU_INC')) die();
+
+class syntax_plugin_pageredirect extends DokuWiki_Syntax_Plugin {
+ /**
+ * @return string Syntax mode type
+ */
+ public function getType() {
+ return 'substition';
+ }
+
+ /**
+ * @return string Paragraph type
+ */
+ public function getPType() {
+ return 'block';
+ }
+
+ /**
+ * @return int Sort order - Low numbers go before high numbers
+ */
+ public function getSort() {
+ return 1;
+ }
+
+ /**
+ * Connect lookup pattern to lexer.
+ *
+ * @param string $mode Parser mode
+ */
+ public function connectTo($mode) {
+ // NOTE: each document is surrounted with \n by dokuwiki parser
+ // so it's safe to use \n in the pattern
+ // this fixes creole greedyness:
+ // https://github.com/glensc/dokuwiki-plugin-pageredirect/issues/18#issuecomment-249386268
+ $this->Lexer->addSpecialPattern('(?:~~REDIRECT>.+?~~|\n#(?i:redirect) [^\r\n]+)', $mode, 'plugin_pageredirect');
+ }
+
+ /**
+ * Handler to prepare matched data for the rendering process
+ *
+ * This function can only pass data to render() via its return value
+ * render() may be not be run during the object's current life.
+ *
+ * Usually you should only need the $match param.
+ *
+ * @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
+ * @param Doku_Handler $handler Reference to the Doku_Handler object
+ * @return array Return an array with all data you want to use in render
+ */
+ public function handle($match, $state, $pos, Doku_Handler $handler) {
+ // strip leading "\n" from creole-compatible pattern
+ $match = trim($match);
+
+ // extract target page from match pattern
+ if($match[0] == '#') {
+ # #REDIRECT PAGE
+ $id = substr($match, 10);
+ } else {
+ # ~~REDIRECT>PAGE~~
+ $id = substr($match, 11, -2);
+ }
+ $id = trim($id);
+
+ $is_external = preg_match('#^https?://#i', $id);
+
+ // resolve and clean the $id if it is not external
+ if(!$is_external) {
+ global $ID;
+ resolve_pageid(getNS($ID), $id, $exists);
+ }
+
+ return array($id, $is_external);
+ }
+
+ /**
+ * Handles the actual output creation.
+ *
+ * The function must not assume any other of the classes methods have been run
+ * during the object's current life. The only reliable data it receives are its
+ * parameters.
+ *
+ * The function should always check for the given output format and return false
+ * when a format isn't supported.
+ *
+ * $renderer contains a reference to the renderer object which is
+ * currently handling the rendering. You need to use it for writing
+ * the output. How this is done depends on the renderer used (specified
+ * by $format
+ *
+ * The contents of the $data array depends on what the handler() function above
+ * created
+ *
+ * @param string $format output format being rendered
+ * @param Doku_Renderer $renderer reference to the current renderer object
+ * @param array $data data created by handler()
+ * @return boolean return true if rendered correctly
+ */
+ public function render($format, Doku_Renderer $renderer, $data) {
+ if($format == 'xhtml') {
+ // add prepared note about redirection
+ $renderer->doc .= $this->redirect_message($data);
+
+ // hook into the post render event to allow the page to be redirected
+ global $EVENT_HANDLER;
+ /** @var action_plugin_pageredirect $action */
+ $action = plugin_load('action', 'pageredirect');
+ $EVENT_HANDLER->register_hook('TPL_ACT_RENDER', 'AFTER', $action, 'handle_dokuwiki_started');
+
+ return true;
+ }
+
+ if($format == 'metadata') {
+ // add redirection to metadata
+ $renderer->meta['relation']['isreplacedby'] = $data;
+ if (!$data[1]) {
+ $page = preg_split("/\?|#/", $data[0])[0];
+ $renderer->meta['relation']['references'][$page] = page_exists($page);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Create redirection message html
+ *
+ * @param string $page
+ * @return string
+ */
+ private function redirect_message($metadata) {
+ list($page, $is_external) = $metadata;
+ if(!$is_external) {
+ $link = html_wikilink($page);
+ } else {
+ $link = '<a href="' . hsc($page) . '" class="urlextern">' . hsc($page) . '</a>';
+ }
+
+ // prepare message here instead of in render
+ $message = '<div class="noteredirect">' . sprintf($this->getLang('redirect_to'), $link) . '</div>';
+
+ return $message;
+ }
+}