Compare commits
No commits in common. "b91a53b1a24d84e937f8da3fd59653bcd21f9f94" and "c24b382c3b98c453f711745dbb106875cd03401b" have entirely different histories.
b91a53b1a2
...
c24b382c3b
10 changed files with 53 additions and 44 deletions
16
MenuItem.php
16
MenuItem.php
|
@ -5,11 +5,6 @@ namespace dokuwiki\plugin\childrenpages;
|
||||||
use dokuwiki\Menu\Item\AbstractItem;
|
use dokuwiki\Menu\Item\AbstractItem;
|
||||||
|
|
||||||
class MenuItem extends 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
|
* Generate a menu item from a passed string
|
||||||
*
|
*
|
||||||
|
@ -29,7 +24,6 @@ class MenuItem extends AbstractItem {
|
||||||
$this->label = $label;
|
$this->label = $label;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->setTargetFromType($type, $strip_namespace);
|
$this->setTargetFromType($type, $strip_namespace);
|
||||||
$this->setIsActive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,16 +69,6 @@ class MenuItem extends AbstractItem {
|
||||||
$this->params = [];
|
$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
|
* Convenience method to get the attributes for constructing an <a> element
|
||||||
* Parent method is declared in dokuwiki\Menu\Item\AbstractItem
|
* Parent method is declared in dokuwiki\Menu\Item\AbstractItem
|
||||||
|
|
50
README.md
50
README.md
|
@ -5,30 +5,64 @@ through links in the page menu.
|
||||||
|
|
||||||
[![thumbnail]][screenshot]
|
[![thumbnail]][screenshot]
|
||||||
|
|
||||||
[thumbnail]: https://git.vv221.fr/dokuwiki-childrenpages/plain/img/thumbnail.png
|
[thumbnail]: img/thumbnail.png
|
||||||
[screenshot]: https://git.vv221.fr/dokuwiki-childrenpages/plain/img/screenshot.png
|
[screenshot]: img/screenshot.png
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Requirements
|
### 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
|
||||||
|
|
||||||
* `git`
|
* `git`
|
||||||
|
|
||||||
### Current stable version (1.2.1)
|
#### Current stable version (1.1.0)
|
||||||
|
|
||||||
Assuming the root directory of your DokuWiki installation is `/srv/dokuwiki`:
|
Assuming the root directory of your DokuWiki installation is `/srv/dokuwiki`:
|
||||||
```
|
```
|
||||||
DOKUWIKI_PATH=/srv/dokuwiki
|
DOKUWIKI_PATH=/srv/dokuwiki
|
||||||
REPO_URL=https://git.vv221.fr/dokuwiki-childrenpages
|
REPO_URL=https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages.git
|
||||||
git clone --branch 1.2.1 --depth 1 "$REPO_URL" "$DOKUWIKI_PATH/lib/plugins/childrenpages"
|
git clone --branch 1.1.0 --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`:
|
Assuming the root directory of your DokuWiki installation is `/srv/dokuwiki`:
|
||||||
```
|
```
|
||||||
DOKUWIKI_PATH=/srv/dokuwiki
|
DOKUWIKI_PATH=/srv/dokuwiki
|
||||||
REPO_URL=https://git.vv221.fr/dokuwiki-childrenpages
|
REPO_URL=https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages.git
|
||||||
git clone --branch master --depth 1 "$REPO_URL" "$DOKUWIKI_PATH/lib/plugins/childrenpages"
|
git clone --branch master --depth 1 "$REPO_URL" "$DOKUWIKI_PATH/lib/plugins/childrenpages"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
17
action.php
17
action.php
|
@ -3,7 +3,7 @@
|
||||||
* Children pages plugin: Shows links to children pages in the page menu
|
* Children pages plugin: Shows links to children pages in the page menu
|
||||||
*
|
*
|
||||||
* @license BSD 2-Clause
|
* @license BSD 2-Clause
|
||||||
* @author Antoine Le Gonidec <vv221.dokuwiki@vv221.fr>
|
* @author Antoine Le Gonidec <vv221.dokuwiki@dotslashplay.it>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// must be run within Dokuwiki
|
// must be run within Dokuwiki
|
||||||
|
@ -40,19 +40,17 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
if ( $event->data['view'] !== 'page' ) {
|
if ( $event->data['view'] !== 'page' ) {
|
||||||
return;
|
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
|
// If the current page is included in a reserved namespace, add a link back to main page
|
||||||
$children_types = $this->getConf('children_list');
|
$children_types = $this->getConf('children_list');
|
||||||
$top_namespace = $this->getTopLevelNamespace();
|
$top_namespace = $this->getTopLevelNamespace();
|
||||||
$is_child_page = in_array($top_namespace, $children_types);
|
$is_child_page = in_array($top_namespace, $children_types);
|
||||||
if ( $show_all_links || $is_child_page ) {
|
if ( $is_child_page ) {
|
||||||
$main_label = $this->getLang('btn_main');
|
$main_label = $this->getLang('btn_main');
|
||||||
$this->addMenuItem($event, '_main', $main_label, $is_child_page);
|
$this->addMenuItem($event, '_main', $main_label, $top_namespace);
|
||||||
}
|
}
|
||||||
// Add menu items for each child page
|
// Add menu items for each child page
|
||||||
foreach ( $children_types as $child_type ) {
|
foreach ( $children_types as $child_type ) {
|
||||||
if ( $show_all_links || $child_type !== $top_namespace ) {
|
if ( $child_type !== $top_namespace ) {
|
||||||
$child_label = $this->getLang("btn_$child_type");
|
$child_label = $this->getLang("btn_$child_type");
|
||||||
$this->addMenuItem($event, $child_type, $child_label, $is_child_page);
|
$this->addMenuItem($event, $child_type, $child_label, $is_child_page);
|
||||||
}
|
}
|
||||||
|
@ -93,13 +91,10 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
$language = $translation_plugin->getLangPart($INFO['id']);
|
$language = $translation_plugin->getLangPart($INFO['id']);
|
||||||
}
|
}
|
||||||
// Skip top-level language namespace if one is in use
|
// Skip top-level language namespace if one is in use
|
||||||
$namespace = explode(':', $INFO['namespace']);
|
|
||||||
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
|
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
|
||||||
// FIXME: $namespace is sometimes shorter than expected,
|
return explode(':', $INFO['namespace'])[1];
|
||||||
// this might be the symptom of some bug.
|
|
||||||
return ( count($namespace) > 1 ) ? $namespace[1] : null;
|
|
||||||
} else {
|
} else {
|
||||||
return $namespace[0];
|
return explode(':', $INFO['namespace'])[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$conf['children_list'] = array('animation', 'gameplay', 'dev', 'talk');
|
$conf['children_list'] = array('animation', 'gameplay', 'dev', 'talk');
|
||||||
$conf['show_link_to_current_page'] = 0;
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$meta['children_list'] = [ 'array' ];
|
$meta['children_list'] = [ 'array' ];
|
||||||
$meta['show_link_to_current_page'] = [ 'onoff' ];
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$lang['btn_main'] = 'Main article';
|
$lang['btn_main'] = 'Back to main page';
|
||||||
|
|
||||||
$lang['btn_animation'] = 'Animation';
|
$lang['btn_animation'] = 'Animation';
|
||||||
$lang['btn_dev'] = 'Dev';
|
$lang['btn_dev'] = 'Dev';
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$lang['children_list'] = 'List of namespaces reserved for children pages';
|
$lang['children_list'] = 'List of namespaces reserved for children pages';
|
||||||
$lang['show_link_to_current_page'] = 'Include a link to the page currently shown';
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$lang['btn_main'] = 'Article principal';
|
$lang['btn_main'] = 'Retour à la page principale';
|
||||||
|
|
||||||
$lang['btn_animation'] = 'Animation';
|
$lang['btn_animation'] = 'Animation';
|
||||||
$lang['btn_dev'] = 'Dev';
|
$lang['btn_dev'] = 'Dev';
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$lang['children_list'] = 'Liste des espaces de nom réservés aux pages enfants';
|
$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';
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
base childrenpages
|
base childrenpages
|
||||||
author Antoine Le Gonidec
|
author Antoine Le Gonidec
|
||||||
email numenaute@vv221.fr
|
email vv221.dokuwiki@dotslashplay.it
|
||||||
date 2024-10-04
|
date 2020-04-03
|
||||||
name Children pages
|
name Children pages
|
||||||
desc For each page, this plugin adds children pages in pre-set namespaces, reachable through links in the page menu
|
desc For each page, this plugin adds children pages in pre-set namespaces, reachable through links in the page menu
|
||||||
url https://port.numenaute.org/dokuwiki/dokuwiki-plugin-childrenpages
|
url https://forge.dotslashplay.it/vv221/dokuwiki-childrenpages
|
||||||
|
|
Loading…
Reference in a new issue