add contents

This commit is contained in:
Trevor Batley
2025-10-09 15:04:29 +11:00
parent 170362eec1
commit bce7dd054a
2537 changed files with 301282 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
DokuWiki plugin Encrypted Passwords
=======================
By Wolfgang Reszel
This plugin let you store 256 bit AES encrypted passwords in your DokuWiki pages. The password can be decrypted by clicking them (Javascript must be enabled). Based on the encryption library by Vincent Cheung (http://www.vincentcheung.ca/jsencryption) which incorporates the Gibberish AES library by Mark Percival (https://github.com/mdp/gibberish-aes).
----
The code of Encrypted Passwords Plugin by Wolfgang Reszel is licensed under the GNU Public License (GPL) version 2.
The Gibberish AES library by Mark Percival is separately licensed under MIT.
More infomation is available:
* https://www.dokuwiki.org/plugin:encryptedpasswords

View File

@@ -0,0 +1,72 @@
<?php
use dokuwiki\Form\Form;
/**
* Encrypted Passwords Plugin: Store encrypted passwords with syntax <decrypt></decrypt>
*
* @license GPL2 (http://www.gnu.org/licenses/gpl.html)
* @author Wolfgang Reszel <reszel@werbeagentur-willers.de>
*/
class action_plugin_encryptedpasswords extends DokuWiki_Action_Plugin
{
/**
* Register its handlers with the DokuWiki's event controller
*/
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handleToolbar');
$controller->register_hook('FORM_EDIT_OUTPUT', 'BEFORE', $this, 'disableAutoDraft');
// legacy support
$controller->register_hook('HTML_EDITFORM_OUTPUT', 'BEFORE', $this, 'disableAutoDraft');
}
/**
* Adds toolbar button
*/
public function handleToolbar(Doku_Event $event, $param)
{
$event->data[] = array(
'type' => 'encryptButtonClick',
'title' => $this->getLang('toolbar_icon_title'),
'icon' => DOKU_REL.'lib/plugins/encryptedpasswords/encrypt.png',
);
}
/**
* Disable auto draft saving
*/
public function disableAutoDraft(Doku_Event $event, $param)
{
global $conf;
$form =& $event->data;
if (is_a($form, Form::class) // $event->name is 'FORM_EDIT_OUTPUT'
&& ($pos = $form->findPositionByAttribute('id', 'wiki__text')) !== false
) {
// applicable to DW development snapshot 2020-10-13 or later
$wikitext = $form->getElementAt($pos)->val();
} elseif (is_a($form, 'Doku_Form') // $event->name == 'HTML_EDITFORM_OUTPUT'
&& ($pos = $form->findElementByType('wikitext')) !== false
) {
// applicable to DW release 2020-07-29 "Hogfather" and older
$textarea = $form->getElementAt($pos);
$wikitext = $textarea['_text'];
} else {
return;
}
// check <decrypt></decriprt> used in wiki text
$ptn = '#<decrypt>[\s\S]*?</decrypt>#';
if (preg_match($ptn, $wikitext) && $conf['usedraft']) {
$conf['usedraft'] = 0;
if ($this->getConf('notify')) {
msg($this->getPluginName().': '.$this->getLang('msg_AutoDraftDisabled'), 2);
}
}
}
}

View File

@@ -0,0 +1,4 @@
<?php
$conf['reload_seconds'] = 120;
$conf['notify'] = 0; // message off

View File

@@ -0,0 +1,4 @@
<?php
$meta['reload_seconds'] = array('numeric','_pattern' => '/\d{1,3}/');
$meta['notify'] = array('onoff');

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,310 @@
/**
* JavaScript Encryption and Decryption 2.0
* http://www.vincentcheung.ca/jsencryption/
*
* The backend is Gibberish AES by Mark Percival (https://github.com/mdp/gibberish-aes)
*
* Copyright 2008 Vincent Cheung
* Dec. 16, 2008
*
* + Modified for full localization by Wolfgang Reszel on Mai 6, 2010
* + Compatibility with Dokuwiki Weatherwax RC1 (Mar 13, 2013)
*
*/
var decryptElementId;
function decryptText(a, b, c) {
decryptElementId = a;
if (b == null) {
b = LANG.plugins.encryptedpasswords['enterKey']
}
if (c != null && c) {
var d = prompt(b, "");
decrypt(d)
} else {
vcPrompt(b)
}
}
function decrypt(a) {
if (a != "" && a != null) {
// if (decryptElementId.constructor != Array) {
// decryptElementId = [decryptElementId]
// }
var b = false;
for (var i = 0; i < decryptElementId.length; i++) {
if (typeof decryptElementId[i] == 'object') {
c = decryptElementId[i]
} else {
var c = document.getElementById(decryptElementId[i])
}
var d = c.title;
try {
var e = GibberishAES.dec(d, a);
b = true;
jQuery(c).text(e).after(' <span class="recrypt"><a href="." onclick="location.reload(); return false;">['+LANG.plugins.encryptedpasswords['recrypt']+']</a></span>');
c.title = "";
} catch(err) {}
}
if (!b) {
alert(LANG.plugins.encryptedpasswords['invalidKey'])
}
}
}
var overlayElt = null;
var winElt = null;
var passElt = null;
var promptElt = null;
function vcPrompt(a,a2,a3,vcClick) {
if (overlayElt == null || winElt == null || passElt == null || promptElt == null) {
vcCreateDialog(a,a2,a3,vcClick)
}
promptElt.innerHTML = a != null ? a : "Enter password:";
pageSize = getPageSize();
winElt.style.marginTop = Math.round(pageSize[3] * 0.3) + "px";
winElt.style.marginLeft = Math.round((pageSize[2] - 400) / 2) + "px";
isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
if (isIE6) {
pageScroll = getPageScroll();
overlayElt.style.position = "absolute";
overlayElt.style.width = pageSize[0] + "px";
overlayElt.style.height = pageSize[1] + "px";
winElt.style.position = "absolute";
winElt.style.top = pageScroll[1] + "px";
winElt.style.left = pageScroll[0] + "px"
}
passElt.value = "";
overlayElt.style.display = "block";
winElt.style.display = "block";
passElt.focus();
passElt.select()
}
function vcCreateDialog(a,a2,a3,vcClick) {
if (vcClick == undefined) vcClick = vcClick_func;
overlayElt = document.createElement("div");
overlayElt.setAttribute("id", "vcOverlay");
var s = overlayElt.style;
s.backgroundColor = "black";
s.MozOpacity = 0.1;
s.opacity = 0.1;
s.filter = "alpha(opacity=10)";
s.position = "fixed";
s.top = 0;
s.left = 0;
s.width = "100%";
s.height = "100%";
s.zIndex = 254;
s.textAlign = "left";
s.margin = 0;
s.padding = 0;
var a = document.getElementsByTagName("body").item(0);
a.insertBefore(overlayElt, a.firstChild);
winElt = document.createElement("div");
winElt.setAttribute("id", "vcWin");
s = winElt.style;
s.position = "fixed";
s.top = 0;
s.left = 0;
s.width = "400px";
s.zIndex = 255;
s.border = "1px solid black";
s.backgroundColor = "#fbfcfd";
s.textAlign = "left";
s.margin = 0;
s.padding = 0;
a.insertBefore(winElt, a.firstChild);
var b = document.createElement("div");
b.setAttribute("id", "vcInWin");
s = b.style;
s.border = "5px solid #808080";
s.padding = "15px";
s.margin = 0;
winElt.appendChild(b);
promptElt = document.createElement("p");
promptElt.setAttribute("id", "vcPrompt");
s = promptElt.style;
s.padding = 0;
s.margin = 0;
s.fontFamily = "Arial, sans-serif";
s.fontSize = "14px";
s.textAlign = "left";
s.color = "black";
b.appendChild(promptElt);
passElt = document.createElement("input");
passElt.setAttribute("id", "vcPass");
passElt.setAttribute("tabindex", "1001");
passElt.type = "password";
passElt.onkeyup = function(c) {
if (c == null) {
c = window.event
}
if ((c.keyCode == 10) || (c.keyCode == 13)) {
vcClick(1)
}
if (c.keyCode == 27) {
vcClick(0)
}
};
s = passElt.style;
s.position = "relative";
s.width = "345px";
s.padding = "5px";
s.margin = "5px 0 10px 0";
s.fontFamily = "monospace";
s.fontSize = "14px";
s.textAlign = "left";
s.color = "black";
s.border = "2px solid #808080";
s.backgroundColor = "white";
b.appendChild(passElt);
if (a3 == 2) {
passElt2 = document.createElement("input");
passElt2.setAttribute("id", "vcPass2");
passElt2.setAttribute("tabindex", "1002");
passElt2.type = "password";
passElt2.onkeyup = function(c) {
if (c == null) {
c = window.event
}
if ((c.keyCode == 10) || (c.keyCode == 13)) {
vcClick(1)
}
if (c.keyCode == 27) {
vcClick(0)
}
};
s = passElt2.style;
s.position = "relative";
s.width = "345px";
s.padding = "5px";
s.margin = "5px 0 10px 0";
s.fontFamily = "monospace";
s.fontSize = "14px";
s.textAlign = "left";
s.color = "black";
s.border = "2px solid #808080";
s.backgroundColor = "white";
b.appendChild(passElt2);
}
var c = document.createElement("div");
c.style.textAlign = "right";
c.style.fontFamily = "Arial, sans-serif";
c.style.fontSize = "14px";
b.appendChild(c);
var d = document.createElement("input");
d.setAttribute("tabindex", "1003");
d.type = "button";
d.value = LANG.plugins.encryptedpasswords['cancel'];
d.onclick = function() {
vcClick(0)
};
d.style.margin = "0 0 0 0.5em";
d.style.padding = "5px";
d.style.color = "black";
c.appendChild(d);
d = document.createElement("input");
d.setAttribute("tabindex", "1004");
d.type = "button";
d.value = a2 != null ? a2 : LANG.plugins.encryptedpasswords['decrypt'];
d.onclick = function() {
vcClick(1)
};
d.style.margin = "0 0 0 0.5em";
d.style.padding = "5px";
d.style.color = "black";
c.appendChild(d)
}
function vcClick_func(a) {
overlayElt.style.display = "none";
winElt.style.display = "none";
if (a) {
decrypt(passElt.value)
} else {}
overlayElt.parentNode.removeChild(overlayElt);
winElt.parentNode.removeChild(winElt);
passElt.parentNode.removeChild(passElt);
promptElt.parentNode.removeChild(promptElt);
overlayElt = null;
winElt = null;
passElt = null;
promptElt = null;
}
function getPageScroll() {
var a;
if (self.pageYOffset) {
a = self.pageYOffset
} else {
if (document.documentElement && document.documentElement.scrollTop) {
a = document.documentElement.scrollTop
} else {
if (document.body) {
a = document.body.scrollTop
}
}
}
var b;
if (self.pageXOffset) {
b = self.pageXOffset
} else {
if (document.documentElement && document.documentElement.scrollLeft) {
b = document.documentElement.scrollLeft
} else {
if (document.body) {
b = document.body.scrollLeft
}
}
}
arrayPageScroll = new Array(b, a);
return arrayPageScroll
}
function getPageSize() {
var a, b;
if (window.innerHeight && window.scrollMaxY) {
a = document.body.scrollWidth;
b = window.innerHeight + window.scrollMaxY
} else {
if (document.body.scrollHeight > document.body.offsetHeight) {
a = document.body.scrollWidth;
b = document.body.scrollHeight
} else {
a = document.body.offsetWidth;
b = document.body.offsetHeight
}
}
var c, d;
if (self.innerHeight) {
c = self.innerWidth;
d = self.innerHeight
} else {
if (document.documentElement && document.documentElement.clientHeight) {
c = document.documentElement.clientWidth;
d = document.documentElement.clientHeight
} else {
if (document.body) {
c = document.body.clientWidth;
d = document.body.clientHeight
}
}
}
if (b < d) {
pageHeight = d
} else {
pageHeight = b
}
if (a < c) {
pageWidth = c
} else {
pageWidth = a
}
arrayPageSize = new Array(pageWidth, pageHeight, c, d);
return arrayPageSize
}

View File

@@ -0,0 +1,23 @@
<?php
/*
* DokuWiki plugin Encrypted Passwords;
* German language
*/
$lang['toolbar_icon_title'] = 'Markiertes Passwort verschlüsseln oder entschlüsseln';
$lang['decrypt'] = 'Entschlüsseln';
$lang['js']['enterKey'] = 'Passwort für die Entschlüsselung:';
$lang['js']['decrypt'] = 'Entschlüsseln';
$lang['js']['encrypt'] = 'Verschlüsseln';
$lang['js']['cancel'] = 'Abbrechen';
$lang['js']['encryptKey'] = 'Passwort für die Verschlüsselung zweimal eingeben:';
$lang['js']['keyErr'] = 'Verschlüsselungs-Passwörter sind nicht identisch.<br />Bitte zweimal das identische Passwort eingeben!';
$lang['js']['emptyKey'] = 'Bitte ein Verschlüsselungs-Passwort eingeben!';
$lang['js']['invalidKey'] = 'Ungültiges Entschlüsselungs-Passwort';
$lang['js']['noSelection'] = 'Bitte den Text auswählen, welcher verschlüsselt werden soll';
$lang['js']['recrypt'] = 'verschlüsseln';
$lang['msg_AutoDraftDisabled'] = 'Das automatische Speichern des Entwurfs wird vorübergehend deaktiviert. Dadruch wird unterbunden, dass entschlüsselte Passwörter an den Server übertragen werden.';

View File

@@ -0,0 +1,9 @@
<?php
/*
* DokuWiki plugin Encrypted Passwords;
* German language for settings
*/
$lang['reload_seconds'] = 'Zeit (in Sekunden) nach der die Seite neu geladen wird. Durch das Neuladen der Seite, wird der entschlüsselte Text wieder verschlüsselt. Verwendet man 0, wird das automatische Neuladen der Seite deaktiviert.';
$lang['notify'] = 'Benachrichtigung anzeigen, wenn das automatische Speichern des Entwurfes deaktiviert wird?';

View File

@@ -0,0 +1,23 @@
<?php
/*
* DokuWiki plugin Encrypted Passwords;
* German language
*/
$lang['toolbar_icon_title'] = 'Markiertes Passwort verschlüsseln oder entschlüsseln';
$lang['decrypt'] = 'Entschlüsseln';
$lang['js']['enterKey'] = 'Passwort für die Entschlüsselung:';
$lang['js']['decrypt'] = 'Entschlüsseln';
$lang['js']['encrypt'] = 'Verschlüsseln';
$lang['js']['cancel'] = 'Abbrechen';
$lang['js']['encryptKey'] = 'Passwort für die Verschlüsselung zweimal eingeben:';
$lang['js']['keyErr'] = 'Verschlüsselungs-Passwörter sind nicht identisch.<br />Bitte zweimal das identische Passwort eingeben!';
$lang['js']['emptyKey'] = 'Bitte ein Verschlüsselungs-Passwort eingeben!';
$lang['js']['invalidKey'] = 'Ungültiges Entschlüsselungs-Passwort';
$lang['js']['noSelection'] = 'Bitte den Text auswählen, welcher verschlüsselt werden soll';
$lang['js']['recrypt'] = 'verschlüsseln';
$lang['msg_AutoDraftDisabled'] = 'Das automatische Speichern des Entwurfs wird vorübergehend deaktiviert. Dadruch wird unterbunden, dass entschlüsselte Passwörter an den Server übertragen werden.';

View File

@@ -0,0 +1,10 @@
<?php
/*
* DokuWiki plugin Encrypted Passwords;
* German language for settings
*/
$lang['reload_seconds'] = 'Zeit (in Sekunden) nach der die Seite neu geladen wird. Durch das Neuladen der Seite, wird der entschlüsselte Text wieder verschlüsselt. Verwendet man 0, wird das automatische Neuladen der Seite deaktiviert.';
$lang['notify'] = 'Benachrichtigung anzeigen, wenn das automatische Speichern des Entwurfes deaktiviert wird?';

View File

@@ -0,0 +1,17 @@
<?php
$lang['toolbar_icon_title'] = 'Encrypt or decrypt selected password';
$lang['decrypt'] = 'Decrypt';
$lang['js']['enterKey'] = 'Enter the decryption key:';
$lang['js']['decrypt'] = 'Decrypt';
$lang['js']['encrypt'] = 'Encrypt';
$lang['js']['cancel'] = 'Cancel';
$lang['js']['encryptKey'] = 'Enter the encryption key.<br />Enter it twice:';
$lang['js']['keyErr'] = 'The keys are not identical.<br />Enter it twice!';
$lang['js']['emptyKey'] = 'Please enter a key!';
$lang['js']['invalidKey'] = 'Invalid decryption key';
$lang['js']['noSelection'] = 'Please select the text to be encrypted';
$lang['js']['recrypt'] = 'recrypt';
$lang['msg_AutoDraftDisabled'] = 'Auto draft saving has been temporally disabled.';

View File

@@ -0,0 +1,8 @@
<?php
/*
* DokuWiki plugin Encrypted Passwords;
* English language for settings
*/
$lang['reload_seconds'] = 'Automatic page reload timeout (in seconds) after decryption to get back encrypted again. Set 0 to disable auto-reload.';
$lang['notify'] = 'Notify when Auto Draft saving is disabled by this plugin.';

View File

@@ -0,0 +1,17 @@
<?php
$lang['toolbar_icon_title'] = 'Kiválasztott szöveg titkosítása/visszafejtése';
$lang['decrypt'] = 'Visszafejtés';
$lang['js']['enterKey'] = 'Adja meg a kulcsot:';
$lang['js']['decrypt'] = 'Visszafejtés';
$lang['js']['encrypt'] = 'Titkosítás';
$lang['js']['cancel'] = 'Mégse';
$lang['js']['encryptKey'] = 'Titkosító kulcs megadása kétszer:';
$lang['js']['keyErr'] = 'A két kulcs nem egyezik meg!';
$lang['js']['emptyKey'] = 'Adjon meg egy kulcsot!';
$lang['js']['invalidKey'] = 'Hibás kulcs';
$lang['js']['noSelection'] = 'Válassza ki a titkosítandó szöveget';
$lang['js']['recrypt'] = 'újra titkosítás';
$lang['msg_AutoDraftDisabled'] = 'Automatikus piszkozat mentés átmenetileg kikapcsolva.';

View File

@@ -0,0 +1,8 @@
<?php
/*
* DokuWiki plugin Encrypted Passwords;
* Hungarian language for settings
*/
$lang['reload_seconds'] = 'Ennyi másodperc elteltével lesz ismét titkosított a visszafejtett szöveg. Kikapcsoláshoz: 0.';
$lang['notify'] = 'Értesítés, ha az automatikus piszkozat mentést kikapcsolta a plugin.';

View File

@@ -0,0 +1,23 @@
<?php
/**
* Jpapanese language file for encryptedpassword plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Satoshi Sahara <sahara.satoshi@gmail.com>
*/
$lang['toolbar_icon_title'] = '選択テキストの暗号化または復号';
$lang['decrypt'] = '復号';
$lang['js']['enterKey'] = '復号キーを入力:';
$lang['js']['decrypt'] = '復号';
$lang['js']['encrypt'] = '暗号化';
$lang['js']['cancel'] = 'キャンセル';
$lang['js']['encryptKey'] = '暗号化/復号に使用するキーを入力してください.<br />同じキーを2度入力します:';
$lang['js']['keyErr'] = '2つにキーが同一でありません.<br />同じキーを2度入力してください!';
$lang['js']['emptyKey'] = 'キーを入力してください!';
$lang['js']['invalidKey'] = '復号キーが不正です';
$lang['js']['noSelection'] = '暗号化するテキストを選択してください';
$lang['js']['recrypt'] = '暗号状態に戻す';
$lang['msg_AutoDraftDisabled'] = '自動ドラフト保存機能は一時的に無効化されています';

View File

@@ -0,0 +1,8 @@
<?php
/*
* DokuWiki plugin Encrypted Passwords;
* Japanese language for settings
*/
$lang['reload_seconds'] = '暗号解除後、再度暗号化状態に戻すためにページをリロードするまでの秒数. 0 を指定すると自動ではリロードしません.';
$lang['notify'] = '自動ドラフト保存機能が無効化された時に通知する';

View File

@@ -0,0 +1,7 @@
base encryptedpasswords
name Encrypted Passwords Plugin
author Wolfgang Reszel
email reszel@werbeagentur-willers.de
date 2020-11-02
desc This plugin let you store 256 bit AES encrypted passwords in your DokuWiki pages. The password can be decrypted by clicking them (Javascript must be enabled).
url https://www.dokuwiki.org/plugin:encryptedpasswords

View File

@@ -0,0 +1,71 @@
/**
* Encrypted Passwords Plugin: Store encrypted passwords with syntax <decrypt></decrypt>
*
* @license GPL2 (http://www.gnu.org/licenses/gpl.html)
* @author Wolfgang Reszel <reszel@werbeagentur-willers.de>
*/
/* DOKUWIKI:include gibberish-aes.js */
/* DOKUWIKI:include jsencryption.js */
// Add a toolbar button to insert a encrypted password
function addBtnActionEncryptButtonClick(btn, props, edid) {
jQuery(btn).click(function(){
var sample = '';
if (typeof DWgetSelection == 'function') {
var selection = DWgetSelection(document.getElementById('wiki__text'));
} else {
var selection = getSelection(document.getElementById('wiki__text'));
}
if (selection.getLength()) {
sample = selection.getText();
}
if (sample=='') {
alert(LANG.plugins.encryptedpasswords['noSelection']);
return false;
}
if (sample.indexOf('<decrypt>') == 0 && sample.indexOf('</decrypt>') == sample.length-10) {
vcPrompt(LANG.plugins.encryptedpasswords['enterKey'], LANG.plugins.encryptedpasswords['decrypt'], 1, vcFunc = function(a) {
if (a) {
document.getElementById('wiki__text').focus();
try {
decText = GibberishAES.dec((sample.substr(9,sample.length-19)),passElt.value);
} catch(err) { decText = null }
if (decText) {
pasteText(selection, decText);
vcClick_func(0);
decText = null;
} else {
alert(LANG.plugins.encryptedpasswords['invalidKey'])
}
} else {
vcClick_func(0);
document.getElementById('wiki__text').focus();
};
});
} else {
vcPrompt(LANG.plugins.encryptedpasswords['encryptKey'], LANG.plugins.encryptedpasswords['encrypt'], 2, vcFunc = function(a) {
if (a) {
if (passElt.value !== passElt2.value) {
alert(LANG.plugins.encryptedpasswords['keyErr']);
return false;
}
if (passElt.value == '') {
alert(LANG.plugins.encryptedpasswords['emptyKey']);
return false;
}
document.getElementById('wiki__text').focus();
pasteText(selection,'<decrypt>'+GibberishAES.enc(sample,passElt.value).replace(/\n$|\r$|\r\n$/g,'')+'</decrypt>');
vcClick_func(0);
} else {
vcClick_func(0);
document.getElementById('wiki__text').focus();
};
});
}
return false;
});
return true;
}

View File

@@ -0,0 +1,29 @@
.encryptedpasswords {
position: relative;
display: inline-block;
background-color: __background_alt__;
padding: 0 3px;
}
.encryptedpasswords a:hover {
text-decoration: underline;
}
.encryptedpasswords .recrypt {
display: none;
font-size: 80%;
color: __text_alt__;
}
.encryptedpasswords:hover .recrypt {
display: inline;
}
.encryptedpasswords[title=""] {
/* show decrypted text like formatted code block */
font-family: Consolas, "Andale Mono WT", "Andale Mono",
"Bitstream Vera Sans Mono", "Nimbus Mono L",
Monaco, "Courier New", monospace;
white-space:pre-wrap;
word-wrap: break-word;
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* Encrypted Passwords Plugin: Store encrypted passwords with syntax <decrypt></decrypt>
*
* @license GPL2 (http://www.gnu.org/licenses/gpl.html)
* @author Wolfgang Reszel <reszel@werbeagentur-willers.de>
*/
class syntax_plugin_encryptedpasswords extends DokuWiki_Syntax_Plugin
{
public function getType()
{ // Syntax Type
return 'protected';
}
/**
* Connect pattern to lexer
*/
protected $mode, $pattern;
public function preConnect()
{
// syntax mode, drop 'syntax_' from class name
$this->mode = substr(get_class($this), 7);
// syntax pattern
$this->pattern = array(
1 => '<decrypt>(?=.*?</decrypt>)', // DOKU_LEXER_ENTER
4 => '</decrypt>', // DOKU_LEXER_EXIT
);
}
public function connectTo($mode)
{
$this->Lexer->addEntryPattern($this->pattern[1], $mode, $this->mode);
}
public function postConnect()
{
$this->Lexer->addExitPattern($this->pattern[4], $this->mode);
}
public function getSort()
{ // sort number used to determine priority of this mode
return 65;
}
/**
* Handle the match
*/
public function handle($match, $state, $pos, Doku_Handler $handler)
{
switch ($state) {
case DOKU_LEXER_ENTER :
return $data = array($state, '');
break;
case DOKU_LEXER_UNMATCHED :
return $data = array($state, $match);
break;
case DOKU_LEXER_EXIT :
return $data = array($state, '');
break;
}
return $data = false;
}
/**
* Create output
*/
public function render($format, Doku_Renderer $renderer, $data)
{
if ($format == 'xhtml') {
list($state, $match) = $data;
switch ($state) {
case DOKU_LEXER_ENTER :
$renderer->doc.= '';
break;
case DOKU_LEXER_UNMATCHED :
$id = uniqid();
$script = "decryptText(jQuery('.encryptedpasswords'));";
if ($this->getConf('reload_seconds') > 0) {
$script.= "window.setTimeout('location.reload()',"
.$this->getConf('reload_seconds')."000);";
}
$renderer->doc.= '<span class="encryptedpasswords" title="'.$match.'">';
$renderer->doc.= '<a title="'.$this->getLang('decrypt').'" onclick="'
.$script.'">••••••••••</a>';
$renderer->doc.= '</span>';
break;
case DOKU_LEXER_EXIT :
$renderer->doc .= '';
break;
}
return true;
}
return false;
}
}