Compare commits

...

10 commits

Author SHA1 Message Date
b91a53b1a2
2024-10-04 bugfix release
* Prevent PHP warnings triggered by trying to fetch unset array entries.
2024-10-04 20:47:06 +02:00
047a5be134
Prevent PHP warnings triggered by trying to fetch unset array entries 2024-10-04 20:45:57 +02:00
77a903816c
Update metadata to target the new git repository
Since tarballs are not provided by this new repository, only installation instructions using git are kept.
2024-04-24 20:06:28 +02:00
3243439d75
[README] Fix images integration 2023-10-09 10:49:34 +02:00
035c6ab484 1.2.1 release
* Drop requirement on PHP ≥ 7.4.0
* Fix generation of link back to main page
2020-05-01 20:21:12 +02:00
02692388ca Fix generation of link back to main page 2020-05-01 20:20:18 +02:00
c10599048e Drop requirement on PHP ≥ 7.4.0 2020-05-01 20:18:58 +02:00
3e901fd66e 1.2.0 release
* Allow identification of links to non-existing pages
* Add ability to display current page in menu
2020-04-28 13:47:48 +02:00
04af95e6f3 A link to the current page can be shown
This is configurable through the administration panel.
Default is to not include a link to the current page.
2020-04-28 13:26:30 +02:00
9e5c7a32e3 Add ability to identify a link to the current page
A new MenuItem boolean property is available, $is_active:
- its value is true if the link points to the current page
- its value is false otherwise
2020-04-28 13:11:30 +02:00
10 changed files with 44 additions and 53 deletions

View file

@ -5,6 +5,11 @@ namespace dokuwiki\plugin\childrenpages;
use dokuwiki\Menu\Item\AbstractItem;
class MenuItem extends AbstractItem {
/**
* @var bool $is_active True if it is a link to the current page
*/
public $is_active;
/**
* Generate a menu item from a passed string
*
@ -24,6 +29,7 @@ class MenuItem extends AbstractItem {
$this->label = $label;
parent::__construct();
$this->setTargetFromType($type, $strip_namespace);
$this->setIsActive();
}
/**
@ -69,6 +75,16 @@ class MenuItem extends AbstractItem {
$this->params = [];
}
/**
* Set the active status of the link
*/
protected function setIsActive() : void {
global $INFO;
$current_page_id = $INFO['id'];
$target_page_id = $this->id;
$this->is_active = ( $target_page_id === $current_page_id );
}
/**
* Convenience method to get the attributes for constructing an <a> element
* Parent method is declared in dokuwiki\Menu\Item\AbstractItem

View file

@ -5,64 +5,30 @@ through links in the page menu.
[![thumbnail]][screenshot]
[thumbnail]: img/thumbnail.png
[screenshot]: img/screenshot.png
[thumbnail]: https://git.vv221.fr/dokuwiki-childrenpages/plain/img/thumbnail.png
[screenshot]: https://git.vv221.fr/dokuwiki-childrenpages/plain/img/screenshot.png
## Installation
### Installation using archives
#### Requirements
* `curl`
* `tar`
* `gzip`
#### Current stable version (1.1.0)
Assuming the root directory of your DokuWiki installation is `/srv/dokuwiki`:
```
DOKUWIKI_PATH=/srv/dokuwiki
TARBALL_URL=https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages/-/archive/1.0.0/dokuwiki-childrenpages-1.1.0.tar.gz
curl "$TARBALL_URL" > dokuwiki-childrenpages-1.1.0.tar.gz
mkdir --parents "$DOKUWIKI_PATH/lib/plugins/childrenpages"
gzip --stdout --decompress dokuwiki-childrenpages-1.1.0.tar.gz | tar xf - --strip-components=1 --directory="$DOKUWIKI_PATH/lib/plugins/childrenpages"
rm dokuwiki-childrenpages-1.1.0.tar.gz
```
#### Latest development version
Assuming the root directory of your DokuWiki installation is `/srv/dokuwiki`:
```
DOKUWIKI_PATH=/srv/dokuwiki
TARBALL_URL=https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages/-/archive/master/dokuwiki-childrenpages-master.tar.gz
curl "$TARBALL_URL" > dokuwiki-childrenpages-master.tar.gz
mkdir --parents "$DOKUWIKI_PATH/lib/plugins/childrenpages"
gzip --stdout --decompress dokuwiki-childrenpages-master.tar.gz | tar xf - --strip-components=1 --directory="$DOKUWIKI_PATH/lib/plugins/childrenpages"
rm dokuwiki-childrenpages-master.tar.gz
```
### Installation using git
#### Requirements
### Requirements
* `git`
#### Current stable version (1.1.0)
### Current stable version (1.2.1)
Assuming the root directory of your DokuWiki installation is `/srv/dokuwiki`:
```
DOKUWIKI_PATH=/srv/dokuwiki
REPO_URL=https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages.git
git clone --branch 1.1.0 --depth 1 "$REPO_URL" "$DOKUWIKI_PATH/lib/plugins/childrenpages"
REPO_URL=https://git.vv221.fr/dokuwiki-childrenpages
git clone --branch 1.2.1 --depth 1 "$REPO_URL" "$DOKUWIKI_PATH/lib/plugins/childrenpages"
```
#### Latest development version
### Latest development version
Assuming the root directory of your DokuWiki installation is `/srv/dokuwiki`:
```
DOKUWIKI_PATH=/srv/dokuwiki
REPO_URL=https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages.git
REPO_URL=https://git.vv221.fr/dokuwiki-childrenpages
git clone --branch master --depth 1 "$REPO_URL" "$DOKUWIKI_PATH/lib/plugins/childrenpages"
```

View file

@ -3,7 +3,7 @@
* Children pages plugin: Shows links to children pages in the page menu
*
* @license BSD 2-Clause
* @author Antoine Le Gonidec <vv221.dokuwiki@dotslashplay.it>
* @author Antoine Le Gonidec <vv221.dokuwiki@vv221.fr>
*/
// must be run within Dokuwiki
@ -40,17 +40,19 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
if ( $event->data['view'] !== 'page' ) {
return;
}
// Check if all links should be shown, or if the one to the current page shoud be excluded
$show_all_links = (bool) $this->getConf('show_link_to_current_page');
// If the current page is included in a reserved namespace, add a link back to main page
$children_types = $this->getConf('children_list');
$top_namespace = $this->getTopLevelNamespace();
$is_child_page = in_array($top_namespace, $children_types);
if ( $is_child_page ) {
if ( $show_all_links || $is_child_page ) {
$main_label = $this->getLang('btn_main');
$this->addMenuItem($event, '_main', $main_label, $top_namespace);
$this->addMenuItem($event, '_main', $main_label, $is_child_page);
}
// Add menu items for each child page
foreach ( $children_types as $child_type ) {
if ( $child_type !== $top_namespace ) {
if ( $show_all_links || $child_type !== $top_namespace ) {
$child_label = $this->getLang("btn_$child_type");
$this->addMenuItem($event, $child_type, $child_label, $is_child_page);
}
@ -91,10 +93,13 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
$language = $translation_plugin->getLangPart($INFO['id']);
}
// Skip top-level language namespace if one is in use
$namespace = explode(':', $INFO['namespace']);
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
return explode(':', $INFO['namespace'])[1];
// FIXME: $namespace is sometimes shorter than expected,
// this might be the symptom of some bug.
return ( count($namespace) > 1 ) ? $namespace[1] : null;
} else {
return explode(':', $INFO['namespace'])[0];
return $namespace[0];
}
}
}

View file

@ -1,3 +1,4 @@
<?php
$conf['children_list'] = array('animation', 'gameplay', 'dev', 'talk');
$conf['show_link_to_current_page'] = 0;

View file

@ -1,3 +1,4 @@
<?php
$meta['children_list'] = [ 'array' ];
$meta['show_link_to_current_page'] = [ 'onoff' ];

View file

@ -1,6 +1,6 @@
<?php
$lang['btn_main'] = 'Back to main page';
$lang['btn_main'] = 'Main article';
$lang['btn_animation'] = 'Animation';
$lang['btn_dev'] = 'Dev';

View file

@ -1,3 +1,4 @@
<?php
$lang['children_list'] = 'List of namespaces reserved for children pages';
$lang['show_link_to_current_page'] = 'Include a link to the page currently shown';

View file

@ -1,6 +1,6 @@
<?php
$lang['btn_main'] = 'Retour à la page principale';
$lang['btn_main'] = 'Article principal';
$lang['btn_animation'] = 'Animation';
$lang['btn_dev'] = 'Dev';

View file

@ -1,3 +1,4 @@
<?php
$lang['children_list'] = 'Liste des espaces de nom réservés aux pages enfants';
$lang['show_link_to_current_page'] = 'Inclure un lien vers la page actuellement affichée';

View file

@ -1,7 +1,7 @@
base childrenpages
author Antoine Le Gonidec
email vv221.dokuwiki@dotslashplay.it
date 2020-04-03
email numenaute@vv221.fr
date 2024-10-04
name Children pages
desc For each page, this plugin adds children pages in pre-set namespaces, reachable through links in the page menu
url https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages
url https://port.numenaute.org/dokuwiki/dokuwiki-plugin-childrenpages