add contents
This commit is contained in:
11
lib/plugins/hidden/README.md
Normal file
11
lib/plugins/hidden/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
I'm looking for a new maintainer!
|
||||
|
||||
If you're a user of this plugin, don't worry: I'm still keeping an eye on it, and I'll try to make sure it keeps working fine with future versions of Dokuwiki. But my time is now dedicated to other projects so I will likely not add other features.
|
||||
|
||||
If you're interested in maintaining this plugin, just send me an email (adress available in the commit log) and I'll make sure to give all the information you will need.
|
||||
|
||||
----
|
||||
|
||||
Plugin for Dokuwiki
|
||||
|
||||
See https://www.dokuwiki.org/plugin:hidden for more info about installation and usage.
|
29
lib/plugins/hidden/action.php
Normal file
29
lib/plugins/hidden/action.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* action.php for Plugin hidden
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Guillaume Turri <guillaume.turri@gmail.com>
|
||||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die();
|
||||
require_once(DOKU_PLUGIN.'action.php');
|
||||
|
||||
class action_plugin_hidden extends Dokuwiki_Action_Plugin {
|
||||
function register(Doku_Event_Handler $controller) {
|
||||
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a toolbar button
|
||||
*/
|
||||
function insert_button(&$event, $param) {
|
||||
$event->data[] = array (
|
||||
'type' => 'format',
|
||||
'title' => $this->getLang('button'),
|
||||
'icon' => '../../plugins/hidden/images/hidden.png',
|
||||
'open' => '<hidden>',
|
||||
'close' => '</hidden>',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
4
lib/plugins/hidden/conf/default.php
Normal file
4
lib/plugins/hidden/conf/default.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
$conf['default_text_when_hidden'] = $this->getlang('onHidden');
|
||||
$conf['default_text_when_displayed'] = $this->getlang('onVisible');
|
4
lib/plugins/hidden/conf/metadata.php
Normal file
4
lib/plugins/hidden/conf/metadata.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
$meta['default_text_when_hidden'] = array('string');
|
||||
$meta['default_text_when_displayed'] = array('string');
|
BIN
lib/plugins/hidden/images/enlarge2.png
Normal file
BIN
lib/plugins/hidden/images/enlarge2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 325 B |
BIN
lib/plugins/hidden/images/hidden.png
Normal file
BIN
lib/plugins/hidden/images/hidden.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 B |
BIN
lib/plugins/hidden/images/shrink2.png
Normal file
BIN
lib/plugins/hidden/images/shrink2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 332 B |
15
lib/plugins/hidden/lang/da/lang.php
Normal file
15
lib/plugins/hidden/lang/da/lang.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Søren Birk <soer9648@eucl.dk>
|
||||
* @author Jacob Palm <mail@jacobpalm.dk>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Klik for at vise ⇲';
|
||||
$lang['onVisible'] = 'Klik for at skjule ⇱';
|
||||
$lang['edit'] = 'Redigér skjult sektion';
|
||||
$lang['button'] = 'Skjult sektion';
|
||||
$lang['switch.default'] = 'Klik for at vise/skjule alle elementer';
|
15
lib/plugins/hidden/lang/de/lang.php
Normal file
15
lib/plugins/hidden/lang/de/lang.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Tim Weinhold <tim.weinhold@gmail.com>
|
||||
* @author Matthias Schulte <dokuwiki@lupo49.de>
|
||||
*/
|
||||
$lang['encoding'] = 'UTF-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Zum Anzeigen hier klicken ⇲';
|
||||
$lang['onVisible'] = 'Zum Verstecken hier klicken ⇱';
|
||||
$lang['edit'] = 'Bearbeite versteckten Absatz';
|
||||
$lang['button'] = 'Versteckter Absatz';
|
||||
$lang['switch.default'] = 'Alle anzeigen / alle verstecken';
|
14
lib/plugins/hidden/lang/en/lang.php
Normal file
14
lib/plugins/hidden/lang/en/lang.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Guillaume Turri <guillaume.turri@gmail.com>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Click to display ⇲';
|
||||
$lang['onVisible'] = 'Click to hide ⇱';
|
||||
$lang['edit'] = 'Edit hidden section';
|
||||
$lang['button'] = 'Hidden section';
|
||||
$lang['switch.default'] = 'Click to display/hide all elements';
|
13
lib/plugins/hidden/lang/eo/lang.php
Normal file
13
lib/plugins/hidden/lang/eo/lang.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Robert Bogenschneider <bogi@uea.org>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Klaku por montri ⇲';
|
||||
$lang['onVisible'] = 'Klaku por kaŝi ⇱';
|
||||
$lang['edit'] = 'Modifi la kaŝitan sekcion';
|
||||
$lang['button'] = 'Kaŝita sekcio';
|
14
lib/plugins/hidden/lang/fa/lang.php
Normal file
14
lib/plugins/hidden/lang/fa/lang.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Sam01 <m.sajad079@gmail.com>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8 ';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'کلیک برای نمایش دادن ⇲';
|
||||
$lang['onVisible'] = 'کلیک برای مخفی کردن ⇱';
|
||||
$lang['edit'] = 'ویرایش بخش مخفی شده';
|
||||
$lang['button'] = 'بخش مخفی شده';
|
||||
$lang['switch.default'] = 'کلیک برای نمایش/مخفی کردن همهی عناصر';
|
14
lib/plugins/hidden/lang/fr/lang.php
Normal file
14
lib/plugins/hidden/lang/fr/lang.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Guillaume Turri <guillaume.turri@gmail.com>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Cliquez pour afficher ⇲';
|
||||
$lang['onVisible'] = 'Cliquez pour masquer ⇱';
|
||||
$lang['edit'] = 'Éditer la section masquée';
|
||||
$lang['button'] = 'Section masquée';
|
||||
$lang['switch.default'] = 'Cliquer pour afficher/masquer tous les éléments';
|
11
lib/plugins/hidden/lang/it/lang.php
Normal file
11
lib/plugins/hidden/lang/it/lang.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Sebastiano Pistore <olatusrooc@virgilio.it>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['onHidden'] = 'Fai click per rendere visibile ⇲';
|
||||
$lang['onVisible'] = 'Fai click per nascondere ⇱';
|
||||
$lang['switch.default'] = 'Fai click per mostrare/nascondere tutti gli elementi';
|
14
lib/plugins/hidden/lang/ja/lang.php
Normal file
14
lib/plugins/hidden/lang/ja/lang.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Hideaki SAWADA <chuno@live.jp>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = '表示クリック ⇲';
|
||||
$lang['onVisible'] = '非表示クリック ⇱';
|
||||
$lang['edit'] = '非表示部の編集';
|
||||
$lang['button'] = '非表示部';
|
||||
$lang['switch.default'] = '全項目の表示・非表示';
|
15
lib/plugins/hidden/lang/ko/lang.php
Normal file
15
lib/plugins/hidden/lang/ko/lang.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Myeongjin <aranet100@gmail.com>
|
||||
* @author Erial <erial2@gmail.com>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = '표시하려면 클릭 ⇲';
|
||||
$lang['onVisible'] = '숨기려면 클릭 ⇱';
|
||||
$lang['edit'] = '숨겨진 문단 편집';
|
||||
$lang['button'] = '숨겨진 문단';
|
||||
$lang['switch.default'] = '모든 요소를 표시하거나 숨기려면 클릭';
|
15
lib/plugins/hidden/lang/nl/lang.php
Normal file
15
lib/plugins/hidden/lang/nl/lang.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author mprins <mprins@users.sf.net>
|
||||
* @author Mark C. Prins <mprins@users.sf.net>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Klik om te tonen ⇲';
|
||||
$lang['onVisible'] = 'Klik om te verbergen ⇱';
|
||||
$lang['edit'] = 'Verborgen sectie aanpassen';
|
||||
$lang['button'] = 'Verborgen sectie';
|
||||
$lang['switch.default'] = 'Klik om alle elementen te tonen/verbergen';
|
14
lib/plugins/hidden/lang/oc/lang.php
Normal file
14
lib/plugins/hidden/lang/oc/lang.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author En Matt <heartattack@free.fr>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Clicar per mostrar ⇲';
|
||||
$lang['onVisible'] = 'Clicar per rescondre ⇱';
|
||||
$lang['edit'] = 'Modificar la seccion resconduda';
|
||||
$lang['button'] = 'Seccion resconduda';
|
||||
$lang['switch.default'] = 'Clicar per mostrar/rescondre totes los elements';
|
17
lib/plugins/hidden/lang/pt-br/lang.php
Normal file
17
lib/plugins/hidden/lang/pt-br/lang.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Brazilian portuguese language file
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Alexandre Belchior <alexbelchior@gmail.com>
|
||||
* @author Benedito Carneiro <ctsbc@yahoo.com.br>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Clique para exibir ⇲';
|
||||
$lang['onVisible'] = 'Clique para esconder ⇱';
|
||||
$lang['edit'] = 'Editar a seção escondida';
|
||||
$lang['button'] = 'Seção escondida';
|
||||
$lang['switch.default'] = 'Clique para exibir / ocultar todos os elementos';
|
15
lib/plugins/hidden/lang/ru/lang.php
Normal file
15
lib/plugins/hidden/lang/ru/lang.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Aleksandr Selivanov <alexgearbox@gmail.com>
|
||||
* @author Aleksandr Selivanov <alexgearbox@yandex.ru>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Нажмите, чтобы отобразить ';
|
||||
$lang['onVisible'] = 'Нажмите, чтобы скрыть';
|
||||
$lang['edit'] = 'Править скрытый раздел';
|
||||
$lang['button'] = 'Скрытый раздел';
|
||||
$lang['switch.default'] = 'Нажмите для отображения или скрытия всех элементов';
|
14
lib/plugins/hidden/lang/sv/lang.php
Normal file
14
lib/plugins/hidden/lang/sv/lang.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Tor Härnqvist <tor@harnqvist.se>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'ltr';
|
||||
$lang['onHidden'] = 'Klicka för att visa ⇲';
|
||||
$lang['onVisible'] = 'Klicka för att dölja ⇱';
|
||||
$lang['edit'] = 'Redigera dold sektion';
|
||||
$lang['button'] = 'Dold sektion';
|
||||
$lang['switch.default'] = 'Klicka för visa/dölja alla delar';
|
13
lib/plugins/hidden/lang/tr/lang.php
Normal file
13
lib/plugins/hidden/lang/tr/lang.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author ilker rifat kapaç <irifat@gmail.com>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['direction'] = 'soldan sağa';
|
||||
$lang['onHidden'] = 'Göstermek için tıklayın ⇲';
|
||||
$lang['onVisible'] = 'Gizlemek için tıklayın ⇱';
|
||||
$lang['edit'] = 'Gizlenmiş bölümü düzenle';
|
||||
$lang['button'] = 'Gizlenmiş bölüm';
|
12
lib/plugins/hidden/lang/zh/lang.php
Normal file
12
lib/plugins/hidden/lang/zh/lang.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Yuwei Sun <yuwei@hrz.tu-chemnitz.de>
|
||||
*/
|
||||
$lang['encoding'] = 'utf-8';
|
||||
$lang['onHidden'] = '点击以显示 ⇲';
|
||||
$lang['onVisible'] = '点击以隐藏 ⇱';
|
||||
$lang['edit'] = '编辑隐藏区域';
|
||||
$lang['button'] = '隐藏区域';
|
7
lib/plugins/hidden/plugin.info.txt
Normal file
7
lib/plugins/hidden/plugin.info.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
base hidden
|
||||
author Guillaume Turri
|
||||
email guillaume.turri@gmail.com
|
||||
date 2019-03-31
|
||||
name hidden Plugin
|
||||
desc Enable to hide/show details
|
||||
url http://www.dokuwiki.org/plugin:hidden
|
40
lib/plugins/hidden/print.css
Normal file
40
lib/plugins/hidden/print.css
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* style.css for Plugin hidden
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Guillaume Turri <guillaume.turri@gmail.com>
|
||||
*
|
||||
*/
|
||||
|
||||
.hiddenHead{
|
||||
background-color:__background_alt__;
|
||||
}
|
||||
|
||||
.hiddenBody{
|
||||
border-top:1px solid __border__;
|
||||
padding:1px;
|
||||
}
|
||||
|
||||
.hiddenGlobal{
|
||||
border:1px solid __border__;
|
||||
}
|
||||
|
||||
.hiddenOnHidden{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.hiddenOnVisible{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.hiddenElements{
|
||||
display:none;
|
||||
}
|
||||
|
||||
div.hiddenGlobal div.hiddenHead p{
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.hiddenNoPrint {
|
||||
display:none;
|
||||
}
|
21
lib/plugins/hidden/script.js
Normal file
21
lib/plugins/hidden/script.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* script.js for Plugin hidden
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Guillaume Turri <guillaume.turri@gmail.com>
|
||||
*
|
||||
*/
|
||||
jQuery(function(){
|
||||
jQuery("div.hiddenSinceBeginning").parent().addClass('hiddenHidden');
|
||||
jQuery('div.hiddenActive>div.hiddenHead').on('click', function(){
|
||||
jQuery(this).parent().toggleClass('hiddenHidden');
|
||||
});
|
||||
jQuery(".hiddenSwitch").on('click', function() {
|
||||
var weShallHide = (jQuery('div.hiddenGlobal.hiddenHidden').length == 0);
|
||||
if(weShallHide) {
|
||||
jQuery('.hiddenActive').addClass('hiddenHidden');
|
||||
} else {
|
||||
jQuery('.hiddenActive').removeClass('hiddenHidden');
|
||||
}
|
||||
});
|
||||
});
|
64
lib/plugins/hidden/style.css
Normal file
64
lib/plugins/hidden/style.css
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* style.css for Plugin hidden
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Guillaume Turri <guillaume.turri@gmail.com>
|
||||
*
|
||||
*/
|
||||
|
||||
div.hiddenGlobal {
|
||||
border: 1px solid __border__;
|
||||
}
|
||||
|
||||
div.hiddenOnVisible,
|
||||
div.hiddenOnHidden {
|
||||
display: inline;
|
||||
color: __link__;
|
||||
}
|
||||
|
||||
div.hiddenGlobal div.hiddenHead p{
|
||||
margin:0;
|
||||
}
|
||||
|
||||
div.hiddenHead {
|
||||
background-color: __background_alt__;
|
||||
}
|
||||
div.hiddenHead:hover {
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
div.hiddenHead p:after {
|
||||
display: inline-block;
|
||||
background-size: 1.2em 1.2em;
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
content:"";
|
||||
}
|
||||
div.hiddenGlobal:not(.hiddenHidden)>div.hiddenHead p:after {
|
||||
background-image: url('images/shrink2.png');
|
||||
}
|
||||
div.hiddenGlobal:not(.hiddenHidden)>div.hiddenHead>div.hiddenOnHidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.hiddenGlobal.hiddenHidden>div.hiddenHead p:after {
|
||||
background-image: url('images/enlarge2.png');
|
||||
}
|
||||
div.hiddenGlobal.hiddenHidden>div.hiddenHead>div.hiddenOnVisible {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
div.hiddenBody {
|
||||
border-top:1px solid __border__;
|
||||
padding:1px;
|
||||
}
|
||||
div.hiddenBody p {
|
||||
margin: 0;
|
||||
}
|
||||
div.hiddenGlobal.hiddenHidden>div.hiddenBody {
|
||||
display: none;
|
||||
}
|
244
lib/plugins/hidden/syntax.php
Normal file
244
lib/plugins/hidden/syntax.php
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin hidden: Enable to hide details
|
||||
* v2.4
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Guillaume Turri <guillaume.turri@gmail.com>
|
||||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
|
||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||
require_once(DOKU_INC.'inc/parserutils.php');
|
||||
require_once(DOKU_PLUGIN.'syntax.php');
|
||||
|
||||
/**
|
||||
* All DokuWiki plugins to extend the parser/rendering mechanism
|
||||
* need to inherit from this class
|
||||
*/
|
||||
class syntax_plugin_hidden extends DokuWiki_Syntax_Plugin {
|
||||
|
||||
function getType(){ return 'container'; }
|
||||
function getPType(){ return 'stack'; }
|
||||
function getAllowedTypes() {
|
||||
return array('container', 'baseonly', 'substition','protected','disabled','formatting','paragraphs');
|
||||
}
|
||||
function getSort(){
|
||||
//make sure it's greater than hiddenSwitch plugin's one in order to avoid a confusion between "<hidden.*" and "<hiddenSwitch.*"
|
||||
return 189;
|
||||
}
|
||||
|
||||
// override default accepts() method to allow nesting
|
||||
// - ie, to get the plugin accepts its own entry syntax
|
||||
function accepts($mode) {
|
||||
if ($mode == substr(get_class($this), 7)) return true;
|
||||
return parent::accepts($mode);
|
||||
}
|
||||
|
||||
function connectTo($mode) {
|
||||
$this->Lexer->addEntryPattern('<hidden\b.*?>(?=.*?</hidden>)', $mode,'plugin_hidden');
|
||||
$this->Lexer->addSpecialPattern('<hiddenSwitch[^>]*>', $mode,'plugin_hidden');
|
||||
}
|
||||
function postConnect() {
|
||||
$this->Lexer->addExitPattern('</hidden>','plugin_hidden');
|
||||
}
|
||||
|
||||
function handle($match, $state, $pos, Doku_Handler $handler) {
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_SPECIAL:
|
||||
//hiddenSwitch
|
||||
$return = array('text' => $this->getLang('switch.default'), 'type' => 'switch');
|
||||
$match = trim(utf8_substr($match, 14, -1)); //14 = strlen("<hiddenSwitch ")
|
||||
if ( $match !== '' ){
|
||||
$return['text'] = $match;
|
||||
}
|
||||
$return['text'] = htmlspecialchars($return['text']);
|
||||
return $return;
|
||||
|
||||
case DOKU_LEXER_ENTER :
|
||||
$return = array(
|
||||
'active' => 'true',
|
||||
'element'=>Array(),
|
||||
'onHidden'=>'',
|
||||
'onVisible'=>'',
|
||||
'initialState'=>'hidden',
|
||||
'state'=>$state,
|
||||
'printHead' => true,
|
||||
'bytepos_start' => $pos,
|
||||
'edit' => false,
|
||||
'editText' => $this->getLang('edit'),
|
||||
'onExportPdf' => ''
|
||||
);
|
||||
$match = substr($match, 7, -1); //7 = strlen("<hidden")
|
||||
|
||||
//Looking for the initial state
|
||||
preg_match("/initialState *= *\"([^\"]*)\" ?/i", $match, $initialState);
|
||||
if ( count($initialState) != 0) {
|
||||
$match = str_replace($initialState[0], '', $match);
|
||||
$initialState = strtolower(trim($initialState[1]));
|
||||
if ( $initialState == 'visible'
|
||||
|| $initialState == 'true'
|
||||
|| $initialState == 'expand' ) {
|
||||
$return['initialState'] = 'visible';
|
||||
}
|
||||
}
|
||||
|
||||
//Looking for the -noPrint option
|
||||
if ( preg_match('/-noprint/i', $match, $found) ){
|
||||
$return['printHead'] = false;
|
||||
$match = str_replace($found[0], '', $match);
|
||||
}
|
||||
|
||||
//Looking for the -editable option
|
||||
if ( preg_match('/-edit(able)?( *= *"([^"]*)")?/i', $match, $found) ){
|
||||
if ( count($found) > 1 ){
|
||||
$return['editText'] = end($found);
|
||||
}
|
||||
$return['edit'] = true;
|
||||
$match = str_replace($found[0], '', $match);
|
||||
}
|
||||
|
||||
//Looking if this block is active
|
||||
preg_match("/active *= *\"([^\"]*)\" ?/i", $match, $active);
|
||||
if( count($active) != 0 ){
|
||||
$match = str_replace($active[0], '', $match);
|
||||
$active = strtolower(trim($active[1]));
|
||||
if($active=='false' || $active=='f' || $active=='0' || $active=='n'){
|
||||
$return['active'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Looking for the element(s) of the block (ie: which switches may activate this element)
|
||||
preg_match("/element *= *\"([^\"]*)\" ?/i", $match, $element);
|
||||
if( count($element) != 0 ){
|
||||
$match = str_replace($element[0], '', $match);
|
||||
$element[1] = htmlspecialchars($element[1]);
|
||||
$return['element'] = explode(' ', $element[1]);
|
||||
}
|
||||
|
||||
//Looking for the texts to display
|
||||
$this->_grepOption($return, 'onHidden', $match);
|
||||
$this->_grepOption($return, 'onVisible', $match);
|
||||
$this->_grepOption($return, 'onExportPdf', $match);
|
||||
|
||||
//If there were neither onHidden nor onVisible, take what's left
|
||||
if( $return['onHidden']=='' && $return['onVisible']=='' ){
|
||||
$text = trim($match);
|
||||
if($text != ''){
|
||||
$return['onHidden'] = $text;
|
||||
$return['onVisible'] = $text;
|
||||
} else { //if there's nothing left, take the default texts
|
||||
$return['onHidden'] = $this->getConf('default_text_when_hidden');
|
||||
$return['onVisible'] = $this->getConf('default_text_when_displayed');
|
||||
}
|
||||
} else { //if one string is specified but not the other, take the defaul text
|
||||
$return['onHidden'] = ($return['onHidden']!='') ? $return['onHidden'] : $this->getConf('default_text_when_hidden');
|
||||
$return['onVisible'] = ($return['onVisible']!='') ? $return['onVisible'] : $this->getConf('default_text_when_displayed');
|
||||
}
|
||||
|
||||
//If we don't have an exportPdf text, take the onVisible one, since the block will be exported unfolded
|
||||
if ( $return['onExportPdf'] == '' ){
|
||||
$return['onExportPdf'] = $return['onVisible'];
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
case DOKU_LEXER_UNMATCHED :
|
||||
return array('state'=>$state, 'text'=>$match);
|
||||
|
||||
default:
|
||||
return array('state'=>$state, 'bytepos_end' => $pos + strlen($match));
|
||||
}
|
||||
} // handle()
|
||||
|
||||
private function _grepOption(&$options, $tag, &$match){
|
||||
preg_match("/$tag *= *\"([^\"]*)\" ?/i", $match, $text);
|
||||
if ( count($text) != 0 ){
|
||||
$match = str_replace($text[0], '', $match);
|
||||
$options[$tag] = $text[1];
|
||||
}
|
||||
}
|
||||
|
||||
function render($mode, Doku_Renderer $renderer, $data) {
|
||||
if ( $this->_exportingPDF() ){
|
||||
$data['onVisible'] = $data['onExportPdf'];
|
||||
}
|
||||
|
||||
if($mode == 'xhtml' && $data['type'] == 'switch') {
|
||||
$renderer->doc .= '<button class="button hiddenSwitch">'.$data['text'].'</button>';
|
||||
return true;
|
||||
}
|
||||
if($mode == 'xhtml'){
|
||||
switch ($data['state']) {
|
||||
case DOKU_LEXER_ENTER :
|
||||
$this->editableBlocks[] = $data['edit'];
|
||||
$classEdit = ($data['edit'] ? $renderer->startSectionEdit($data['bytepos_start'], 'section', $data['editText']) : '');
|
||||
$tab = array();
|
||||
$onVisible = p_render('xhtml', p_get_instructions($data['onVisible']), $tab);
|
||||
$onHidden = p_render('xhtml', p_get_instructions($data['onHidden']), $tab);
|
||||
|
||||
// "\n" are inside tags to avoid whitespaces in the DOM with FF
|
||||
$renderer->doc .= '<div class="hiddenGlobal '.$classEdit;
|
||||
$renderer->doc .= $data['active'] ? ' hiddenActive' : '';
|
||||
$renderer->doc .= '">';
|
||||
|
||||
|
||||
|
||||
$renderer->doc .= '<div class="hiddenElements">';
|
||||
foreach($data['element'] as $element){
|
||||
$renderer->doc .= ' '.$element;
|
||||
}
|
||||
$renderer->doc .= "</div>";
|
||||
|
||||
$renderer->doc .= '<div class="hiddenHead ';
|
||||
$renderer->doc .= $data['printHead'] ? '' : 'hiddenNoPrint';
|
||||
$renderer->doc .= ($data['initialState'] == 'hidden') ? ' hiddenSinceBeginning' : '';
|
||||
$renderer->doc .= '">';
|
||||
$renderer->doc .= '<div class="hiddenOnHidden">'.$onHidden."</div>"; //text displayed when hidden
|
||||
$renderer->doc .= '<div class="hiddenOnVisible">'.$onVisible."</div>"; //text displayed when expanded
|
||||
$renderer->doc .= '</div> <!-- .hiddenHead -->';
|
||||
|
||||
$renderer->doc .= '<div class="hiddenBody">';
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_UNMATCHED :
|
||||
$text = $renderer->_xmlEntities($data['text']);
|
||||
if ( preg_match("/^[ \t]*={2,}[^\n]+={2,}[ \t]*$/", $text, $match) ){
|
||||
$title = trim($match[0]);
|
||||
$level = 7 - strspn($title,'=');
|
||||
if($level < 1) $level = 1;
|
||||
$title = trim($title,'=');
|
||||
$title = trim($title);
|
||||
$renderer->header($title, $level, 0);
|
||||
} else {
|
||||
$renderer->doc .= $text;
|
||||
}
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_EXIT :
|
||||
$renderer->doc .= "</div></div>"; //close hiddenBody and hiddenGlobal
|
||||
if ( array_pop($this->editableBlocks) ){
|
||||
$renderer->finishSectionEdit($data['bytepos_end']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($mode == 'odt') {
|
||||
if ($data['state'] == DOKU_LEXER_UNMATCHED && $data['type'] != 'switch') {
|
||||
$renderer->doc .= $renderer->_xmlEntities($data['text']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} // render()
|
||||
|
||||
private function _exportingPDF(){
|
||||
global $ACT;
|
||||
return ($ACT == 'export_pdf' || $ACT == 'export_pdfbook' || $ACT == 'export_odt');
|
||||
}
|
||||
|
||||
var $editableBlocks = array();
|
||||
|
||||
} // class syntax_plugin_nspages
|
Reference in New Issue
Block a user