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,6 @@
root = true
[*.{js,php}]
indent_style = space
indent_size = 4
charset = utf-8

View File

@@ -0,0 +1 @@
DokuWiki Plugin ToDo

198
lib/plugins/todo/action.php Normal file
View File

@@ -0,0 +1,198 @@
<?php
/**
* ToDo Action Plugin: Inserts button for ToDo plugin into toolbar
*
* Original Example: http://www.dokuwiki.org/devel:action_plugins
* @author Babbage <babbage@digitalbrink.com>
* @date 20130405 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* replace old sack() method with new jQuery method and use post instead of get \n
* @date 20130408 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* remove getInfo() call because it's done by plugin.info.txt (since dokuwiki 2009-12-25 Lemming)
*/
if(!defined('DOKU_INC')) die();
/**
* Class action_plugin_todo registers actions
*/
class action_plugin_todo extends DokuWiki_Action_Plugin {
/**
* Register the eventhandlers
*/
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array());
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, '_ajax_call', array());
}
/**
* Inserts the toolbar button
*/
public function insert_button(&$event, $param) {
$event->data[] = array(
'type' => 'format',
'title' => $this->getLang('qb_todobutton'),
'icon' => '../../plugins/todo/todo.png',
// key 't' is already used for going to top of page, bug #76
// 'key' => 't',
'open' => '<todo>',
'close' => '</todo>',
'block' => false,
);
}
/**
* Handles ajax requests for to do plugin
*
* @brief This method is called by ajax if the user clicks on the to-do checkbox or the to-do text.
* It sets the to-do state to completed or reset it to open.
*
* POST Parameters:
* index int the position of the occurrence of the input element (starting with 0 for first element/to-do)
* checked int should the to-do set to completed (1) or to open (0)
* path string id/path/name of the page
*
* @date 20140317 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* use todo content as change description \n
* @date 20131008 Gerrit Uitslag <klapinklapin@gmail.com> \n
* move ajax.php to action.php, added lock and conflict checks and improved saving
* @date 20130405 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* replace old sack() method with new jQuery method and use post instead of get \n
* @date 20130407 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* add user assignment for todos \n
* @date 20130408 Christian Marg <marg@rz.tu-clausthal.de> \n
* change only the clicked to-do item instead of all items with the same text \n
* origVal is not used anymore, we use the index (occurrence) of input element \n
* @date 20130408 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* migrate changes made by Christian Marg to current version of plugin \n
*
*
* @param Doku_Event $event
* @param mixed $param not defined
*/
public function _ajax_call(&$event, $param) {
global $ID, $conf, $lang;
if($event->data !== 'plugin_todo') {
return;
}
//no other ajax call handlers needed
$event->stopPropagation();
$event->preventDefault();
#Variables
// by einhirn <marg@rz.tu-clausthal.de> determine checkbox index by using class 'todocheckbox'
if(isset($_REQUEST['index'], $_REQUEST['checked'], $_REQUEST['pageid'])) {
// index = position of occurrence of <input> element (starting with 0 for first element)
$index = (int) $_REQUEST['index'];
// checked = flag if input is checked means to do is complete (1) or not (0)
$checked = (boolean) urldecode($_REQUEST['checked']);
// path = page ID
$ID = cleanID(urldecode($_REQUEST['pageid']));
} else {
return;
}
$date = 0;
if(isset($_REQUEST['date'])) $date = (int) $_REQUEST['date'];
$INFO = pageinfo();
#Determine Permissions
if(auth_quickaclcheck($ID) < AUTH_EDIT) {
echo "You do not have permission to edit this file.\nAccess was denied.";
return;
}
// Check, if page is locked
if(checklock($ID)) {
$locktime = filemtime(wikiLockFN($ID));
$expire = dformat($locktime + $conf['locktime']);
$min = round(($conf['locktime'] - (time() - $locktime)) / 60);
$msg = $this->getLang('lockedpage').'
'.$lang['lockedby'] . ': ' . editorinfo($INFO['locked']) . '
' . $lang['lockexpire'] . ': ' . $expire . ' (' . $min . ' min)';
$this->printJson(array('message' => $msg));
return;
}
//conflict check
if($date != 0 && $INFO['meta']['date']['modified'] > $date) {
$this->printJson(array('message' => $this->getLang('refreshpage')));
return;
}
#Retrieve Page Contents
$wikitext = rawWiki($ID);
#Determine position of tag
if($index >= 0) {
$index++;
// index is only set on the current page with the todos
// the occurances are counted, untill the index-th input is reached which is updated
$todoTagStartPos = $this->_strnpos($wikitext, '<todo', $index);
$todoTagEndPos = strpos($wikitext, '>', $todoTagStartPos) + 1;
if($todoTagEndPos > $todoTagStartPos) {
// @date 20140714 le add todo text to minorchange
$todoTextEndPos = strpos( $wikitext, '</todo', $todoTagEndPos );
$todoText = substr( $wikitext, $todoTagEndPos, $todoTextEndPos-$todoTagEndPos );
// update text
$oldTag = substr($wikitext, $todoTagStartPos, ($todoTagEndPos - $todoTagStartPos));
$newTag = $this->_buildTodoTag($oldTag, $checked);
$wikitext = substr_replace($wikitext, $newTag, $todoTagStartPos, ($todoTagEndPos - $todoTagStartPos));
// save Update (Minor)
lock($ID);
// @date 20140714 le add todo text to minorchange, use different message for checked or unchecked
saveWikiText($ID, $wikitext, $this->getLang($checked?'checkboxchange_on':'checkboxchange_off').': '.$todoText, $minoredit = true);
unlock($ID);
$return = array(
'date' => @filemtime(wikiFN($ID)),
'succeed' => true
);
$this->printJson($return);
}
}
}
/**
* Encode and print an arbitrary variable into JSON format
*
* @param mixed $return
*/
private function printJson($return) {
$json = new JSON();
echo $json->encode($return);
}
/**
* @brief gets current to-do tag and returns a new one depending on checked
* @param $todoTag string current to-do tag e.g. <todo @user>
* @param $checked int check flag (todo completed=1, todo uncompleted=0)
* @return string new to-do completed or uncompleted tag e.g. <todo @user #>
*/
private function _buildTodoTag($todoTag, $checked) {
$user = '';
if($checked == 1) {
if(!empty($_SERVER['REMOTE_USER'])) { $user = $_SERVER['REMOTE_USER']; }
$newTag = preg_replace('/>/', ' #'.$user.':'.date('Y-m-d').'>', $todoTag);
} else {
$newTag = preg_replace('/[\s]*[#].*>/', '>', $todoTag);
}
return $newTag;
}
/**
* Find position of $occurance-th $needle in haystack
*/
private function _strnpos($haystack, $needle, $occurance, $pos = 0) {
for($i = 1; $i <= $occurance; $i++) {
$pos = strpos($haystack, $needle, $pos) + 1;
}
return $pos - 1;
}
}

View File

@@ -0,0 +1,16 @@
<?php
/**
* Options for the ToDo Plugin
*/
$conf['AllowLinks'] = 0; // Should the Todo's also Link to Files
$conf['ActionNamespace'] = ''; //What should the default namespace for actions be
$conf['Strikethrough'] = 1; // Should text have strikethrough when checked
$conf['CheckboxText'] = 1; //Should we allow action text to check the checkbox
$conf['Checkbox'] = 1; // Should the Checkbox be rendered in list view
$conf['Header'] = 'id'; // How should the header of list be rendered ID/FIRSTHEADER
$conf['Username'] = 'user'; //How should the name of the assigned user be rendered USER/REALNAME/NONE
$conf['ShowdateTag'] = 1; // Should the Start/Due-Date be rendered in a tag
$conf['ShowdateList'] = 0; // Should the Start/Due-Date be rendered in list view
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,19 @@
<?php
/**
* Metadata for configuration manager plugin
* Additions for the ToDo Plugin
*
* @author Babbage <babbage@digitalbrink.com>
*/
$meta['AllowLinks'] = array('onoff');
$meta['ActionNamespace'] = array('string');
$meta['Strikethrough'] = array('onoff');
$meta['CheckboxText'] = array('onoff');
$meta['Checkbox'] = array('onoff');
$meta['Header'] = array('multichoice', '_choices' => array('id','firstheader','none'));
$meta['Username'] = array('multichoice', '_choices' => array('user','real','none'));
$meta['ShowdateTag'] = array('onoff');
$meta['ShowdateList'] = array('onoff');
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Jaroslav Lichtblau <jlichtblau@seznam.cz>
*/
$lang['qb_todobutton'] = 'Označit text jako Úkol';
$lang['refreshpage'] = 'Je dostupná novější verze této stránky, před pokračováním ji obnovte.';
$lang['checkboxchange_on'] = 'Úkol zaškrtnut';
$lang['checkboxchange_off'] = 'Úkol nezaškrtnut';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Jaroslav Lichtblau <jlichtblau@seznam.cz>
*/
$lang['AllowLinks'] = 'Povolit akcím také odkazovat na stránky se stejným jménem?';
$lang['ActionNamespace'] = 'V jakém jmenném prostoru mají být vaše akce vytvořeny (".:" = Current NS, Blank = Root NS)';
$lang['Strikethrough'] = 'Má být text akce přešrktnut po jejím zaškrtnutí?';
$lang['CheckboxText'] = 'Pokud je AllowLinks vypnut, má být akce označena za hotovou po kliknutí na její text?';
$lang['Checkbox'] = '(Výchozí hodnota pro nastavení "checkbox") Má být CheckBox zobrazen jako seznam?';
$lang['Header'] = '(Výchozí hodnota pro nastavení "header") Jak má být pojmenována hlavička seznamu? Jako "id" nebo jako první hlavička na stránce "firstheader" nebo bez hlavičky "none".';
$lang['Username'] = '(Výchozí hodnota pro nastavení "username") Jak má být zobrazeno jméno přiděleného uživatele? Jako "username", celé jméno "real" nebo vůbec "none"';
$lang['ShowdateTag'] = '(Výchozí hodnota pro nastavení "shodate") Má být datum začátku/splnění zobrazeno v náhledu definice tagu?';
$lang['ShowdateList'] = '(Výchozí hodnota pro nastavení "showdate") Má být datum začátku/splnění vykresleno v zobrazení seznamu?';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Søren Birk <soer9648@eucl.dk>
*/
$lang['qb_todobutton'] = 'Markér tekst som gøremål';
$lang['refreshpage'] = 'En nyere version af denne side er tilgængelig. Opdater din side, før du prøver igen.';
$lang['checkboxchange_on'] = 'Gøremål tjekket';
$lang['checkboxchange_off'] = 'Gøremål ikke tjekket';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Søren Birk <soer9648@eucl.dk>
*/
$lang['AllowLinks'] = 'Tillad at handlinger også linker til sider med samme navn?';
$lang['ActionNamespace'] = 'I hvilket navnerum skal dine handlinger oprettes (".:" = Nuværende NR, Blankt = Rod-NR)';
$lang['Strikethrough'] = 'Skal handlingerne gennemstreges, når de er tjekket?';
$lang['CheckboxText'] = 'Skal klik på handling markere handlingen som fuldført, hvis AllowLinks er deaktiveret?';
$lang['Checkbox'] = '(Standardværdi for indstilling "checkbox") Skal CheckBox vises i en listevisning?';
$lang['Header'] = '(Standardværdi for indstilling "header") Hvordan skal headeren for en liste navngives? Som "id" eller som titel for siden "firstheader" eller ingen header "none".';
$lang['Username'] = '(Standardværdi for indstilling "username") Hvordan skal navnet for den tildelte bruger vises? Som brugernavn "username", fuldt navn "real" eller ikke "none".';
$lang['ShowdateTag'] = '(Standardværdi for indstilling "showdate") Skal start/forfaldsdato vises i tag definitionsvisningen?';
$lang['ShowdateList'] = '(Standardværdi for indstilling "showdate") Skal start/forfaldsdatoen vises i en listevisning?';

View File

@@ -0,0 +1,19 @@
<?php
/**
* German language file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Leo Eibler <dokuwiki@sprossenwanne.at>
* @date 20130405 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* create german language file \n
* @date 20140317 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* add 'refreshpage', 'checkboxchange_on' and 'checkboxchange_off' \n
*/
// custom language strings for the plugin
$lang['qb_todobutton'] = 'Markierten Text als Aufgabe/Todo';
$lang['refreshpage'] = 'Eine neue Version dieser Seite ist verfügbar. Bitte laden Sie die Seite neu.';
$lang['checkboxchange_on'] = 'ToDo erledigt';
$lang['checkboxchange_off'] = 'ToDo unerledigt';
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,20 @@
<?php
/**
* English language strings for the ToDo Plugin
*
* @author Leo Eibler <dokuwiki@sprossenwanne.at>
* @date 20130405 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* create german language file \n
*/
$lang['AllowLinks'] = 'Sollen Aufgaben/Todos auch auf Seiten mit dem gleichen Namen verlinken?';
$lang['ActionNamespace'] = 'Wenn AllowLinks aktiv ist, mit welchem Namespace sollen die Aufgaben-Seiten erstellt werden (".:" = Aktueller NS, leer = Root NS)';
$lang['Strikethrough'] = 'Sollen erledigte Aufgaben durchgestrichen werden?';
$lang['CheckboxText'] = 'Wenn AllowLinks nicht aktiv ist, soll dann ein Klick auf die Aufgabe, die Aufgabe als erledigt markieren?';
$lang['Checkbox'] = '(Default Wert für Option "checkbox") Soll in Listen die CheckBox aufscheinen?';
$lang['Header'] = '(Default Wert für Option "header) Wie soll der Kopf bei Listen beschriftet werden? Als "id" oder mit der ersten Kopfzeile der Seite "firstheader" oder ohne Kopfzeile "none"".';
$lang['Username'] = '(Default Wert für Option "username") Wie soll der Username ausgegeben werden? Als "username", voller Name "real" oder garnicht "none"';
$lang['ShowdateTag'] = '(Default Wert für Option "showdate") Soll das Start/Fällig-Datum bei Tag-Definitionen ausgegeben werden?';
$lang['ShowdateList'] = '(Default Wert für Option "showdate") Soll das Start/Fällig-Datum bei Listen ausgegeben werden?';
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,17 @@
<?php
/**
* English language file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Babbage <babbage@digitalbrink.com>
* @date 20140317 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* replace 'checkboxchange' with 'checkboxchange_on' and 'checkboxchange_off' \n
*/
// custom language strings for the plugin
$lang['qb_todobutton'] = 'Mark text as ToDo';
$lang['refreshpage'] = 'A newer version of this page is available, refresh your page before trying again.';
$lang['checkboxchange_on'] = 'ToDo checked';
$lang['checkboxchange_off'] = 'ToDo unchecked';
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,17 @@
<?php
/**
* English language strings for the ToDo Plugin
*
* @author Babbage <babbage@digitalbrink.com>
*/
$lang['AllowLinks'] = 'Allow actions to also link to pages with the same name?';
$lang['ActionNamespace'] = 'What namespace should your actions be created in (".:" = Current NS, Blank = Root NS)';
$lang['Strikethrough'] = 'Should the actions have strikethrough applied when checked?';
$lang['CheckboxText'] = 'If AllowLinks is disabled, should clicking the actions\' text mark the action complete?';
$lang['Checkbox'] = '(Default value for option "checkbox") Should the CheckBox be rendered in a list view?';
$lang['Header'] = '(Default value for option "header") How should the header of a list be named? As "id" or as the first header of the page "firstheader" or no header at all "none".';
$lang['Username'] = '(Default value for option "username") How should the name of the assigned user be rendered? As "username", full name "real" oder not at all "none"';
$lang['ShowdateTag'] = '(Default value for option "showdate") Should the Start/Due-date be rendered in tag definition view?';
$lang['ShowdateList'] = '(Default value for option "showdate") Should the Start/Due-date be rendered in list view?';
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Robert Bogenschneider <bogi@uea.org>
*/
$lang['qb_todobutton'] = 'Marki tekston kiel taskon';
$lang['refreshpage'] = 'Pli freŝa versio de tiu paĝo haveblas, reŝargu la paĝon antaŭ ol reprovi.';
$lang['checkboxchange_on'] = 'Plenumita tasko';
$lang['checkboxchange_off'] = 'Neplenumita tasko';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Robert Bogenschneider <bogi@uea.org>
*/
$lang['AllowLinks'] = 'Ĉu taskoj rajtas ligi al samnomaj paĝoj?';
$lang['ActionNamespace'] = 'En kiu nomspaco viaj taskoj kreiĝu? (",:" = momenta NS, malplena = ĉefa NS)';
$lang['Strikethrough'] = 'Ĉu plenumitaj taskoj estu trastrekitaj?';
$lang['CheckboxText'] = 'Se AllowLinks malaktivas, ĉu klaki la tekston de la tasko marku ĝin plenumita?';
$lang['Checkbox'] = '(Defaŭlta valoro por la opcio "checkbox") Ĉu CheckBox estu montrata kiel listo?';
$lang['Header'] = '(Defaŭlta valoro por la opcio "header") Kiel nomi la listkapon? Ĉu "id", kiel unuan titolon de la paĝo "firstheader", aŭ ĉu neniu kaplinio "none"';
$lang['Username'] = '(Defaŭlta valoro por la opcio "username") Kiel montri la uzantonomon? Ĉu "username", plena nomo ("real") aŭ neniu ("none")?';
$lang['ShowdateTag'] = '(Defaŭlta valoro por la opcio "showdate") Ĉu montri la komencon/limdaton en la etiked-listigo?';
$lang['ShowdateList'] = '(Defaŭlta valoro por la opcio "showdate") Ĉu montri la komencon/limdaton en lista aspekto?';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Schplurtz le Déboulonné <schplurtz@laposte.net>
*/
$lang['qb_todobutton'] = 'Marquer le texte comme tâche.';
$lang['refreshpage'] = 'Une nouvelle révision de cette page est disponible. Veuillez rafraîchir la page avant d\'essayer à nouveau.';
$lang['checkboxchange_on'] = 'tâche cochée';
$lang['checkboxchange_off'] = 'tâche décochée';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Schplurtz le Déboulonné <schplurtz@laposte.net>
*/
$lang['AllowLinks'] = 'Autoriser les tâches à pointer également vers des pages de même nom.';
$lang['ActionNamespace'] = 'Dans quelle catégorie créer les tâches. (".:" = catégorie courante, vide = racine)';
$lang['Strikethrough'] = 'Les tâches devraient-elles être barrées lorsqu\'elles sont cochées ?';
$lang['CheckboxText'] = 'Si "autoriser les liens" (AllowLinks) est désactivée, est-ce que cliquer sur le texte d\'une tâche devrait marquer la tâche comme réalisée ?';
$lang['Checkbox'] = 'Valeur par défaut de l\'option "Case à cocher" ("checkbox"). Faut-il montrer les cases à cocher dans les vues en liste ? ';
$lang['Header'] = 'Valeur par défaut de l\'option "Entête" ("header"). Comment nommer l\'entête d\'une liste ? par son identifiant ("id"), comme le premier entête de la page "firstheader", ou pas d\'entête du tout "none" ?';
$lang['Username'] = 'Valeur par défaut de l\'option "nom d\'utilisateur" ("username"). Comment afficher le nom d\'utilisateur ? Identifiant "username", nom complet "real" ou rien du tout "none" ?';
$lang['ShowdateTag'] = 'Valeur par défaut de l\'option "Affichage des dates" ("showdate"). Faut-il afficher les dates de début et de réalisation attendue dans les vues des définitions ?';
$lang['ShowdateList'] = 'Valeur par défaut de l\'option "Affichage des dates". Faut-il afficher les dates de début et de réalisation attendue dans les vues en liste ?';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author OlatusRooc <olatusrooc@virgilio.it>
*/
$lang['qb_todobutton'] = 'Marca come ToDo';
$lang['refreshpage'] = 'È disponibile una versione più recente di questa pagina, prima di procedere è necessario ricaricare la pagina.';
$lang['checkboxchange_on'] = 'Marcato come ToDo';
$lang['checkboxchange_off'] = 'Rimossa la spunta ToDo';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Hideaki SAWADA <chuno@live.jp>
*/
$lang['qb_todobutton'] = 'ToDo';
$lang['refreshpage'] = 'このページには新バージョンがあります。再試行前に再読込をしてください。';
$lang['checkboxchange_on'] = 'タスクを完了に';
$lang['checkboxchange_off'] = 'タスクを未完に';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Hideaki SAWADA <chuno@live.jp>
*/
$lang['AllowLinks'] = 'タスクを同じ名前のページにリンクすることを許可しますか?';
$lang['ActionNamespace'] = 'タスクを作成する名前空間(".:" = 現在の名前空間、空白 = ルート名前空間)';
$lang['Strikethrough'] = 'チェックした時、タスクに取り消し線を引きますか?';
$lang['CheckboxText'] = 'AllowLinks が無効な場合、文字をクリックするとタスクを完了にしますか?';
$lang['Checkbox'] = '"checkbox" オプションのデフォルト値リスト表示の場合、CheckBox を表示しますか?';
$lang['Header'] = '"header" オプションのデフォルト値)リストの見出しの命名方法?"id"ページID、"firstheader":ページ内の最初の見出し、"none":なし。';
$lang['Username'] = '"username" オプションのデフォルト値)任命されたユーザーの表示方法?"username":ユーザー名、"real":氏名、"none":非表示。';
$lang['ShowdateTag'] = '"showdate" オプションのデフォルト値)タグ定義表示の場合、開始日・締切日を表示しますか?';
$lang['ShowdateList'] = '"showdate" オプションのデフォルト値)リスト表示の場合、開始日・締切日を表示しますか?';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Myeongjin <aranet100@gmail.com>
*/
$lang['qb_todobutton'] = '텍스트를 할 일로 표시';
$lang['refreshpage'] = '이 문서의 최신 판을 사용할 수 있습니다, 다시 시도하기 전에 문서를 새로 고치세요.';
$lang['checkboxchange_on'] = '할 일 선택됨';
$lang['checkboxchange_off'] = '할 일 선택되지 않음';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Myeongjin <aranet100@gmail.com>
*/
$lang['AllowLinks'] = '같은 이름으로 된 문서에도 링크하도록 동작할까요?';
$lang['ActionNamespace'] = '행동이 만들어져야 하는 이름공간 (".:" = 현재 이름공간, 비움 = 루트 이름공간)';
$lang['Strikethrough'] = '선택되었을 때 행동에 취소선을 적용해야 합니까?';
$lang['CheckboxText'] = 'AllowLinks가 비활성화되어 있으면, 행동을 완료하기 위해 행동의 텍스트 표시를 클릭해야 합니까?';
$lang['Checkbox'] = '("checkbox" 옵션에 대한 기본값) CheckBox가 목록 보기에 렌더되어야 합니까?';
$lang['Header'] = '("header" 옵션에 대한 기본값) 어떻게 목록의 머리글이 이르러야 합니까? "id"나 문서의 첫 머리글로 하려면 "firstheader"나 모든 곳에 머리글이 없으려면 "none"입니다.';
$lang['Username'] = '("username" 옵션에 대한 기본값) 어떻게 할당된 사용자의 이름이 렌더되어야 합니까? "username"으로나, 실명으로 하려면 "real"이나 모든 곳에 없으려면 "none"입니다.';
$lang['ShowdateTag'] = '("showdate" 옵션에 대한 기본값) 시작 날짜/기한이 태그 정의 보기에 렌더되어야 합니까?';
$lang['ShowdateList'] = '("showdate" 옵션에 대한 기본값) 시작 날짜/기한이 목록 보기에 렌더되어야 합니까?';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Mijndert <mijndert@mijndertstuij.nl>
*/
$lang['qb_todobutton'] = 'Markeer tekst als ToDo';
$lang['refreshpage'] = 'Een nieuwere versie van deze pagina is beschikbaar. Ververs de pagina alvorens opnieuw te proberen.';
$lang['checkboxchange_on'] = 'ToDo geselecteerd';
$lang['checkboxchange_off'] = 'ToDo niet geselecteerd';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Peter van Diest <peter.van.diest@xs4all.nl>
*/
$lang['AllowLinks'] = 'Acties toestaan om ook te linken naar pagina\'s met dezelfde naam?';
$lang['ActionNamespace'] = 'In welke namespace moeten je acties worden aangemaakt? (".:" = huidige ns, leeg = root ns)';
$lang['Strikethrough'] = 'Moeten de acties worden doorgehaald als ze worden afgevinkt?';
$lang['CheckboxText'] = 'Als LinksToestaan is uitgeschakeld, moet een klik op de actie deze dan als gedaan markeren?';
$lang['Checkbox'] = '(Standaardwaarde voor de optie "checkbox") Moet de checkbox getoond worden in een lijstweergave?';
$lang['Header'] = '(Standaardwaarde voor de optie "header") Hoe moet de kop van een lijst worden aangeduid? Als "id", of als de eerste kop van de pagina ("firstheader"), of helemaal niet ("none").';
$lang['Username'] = '(Standaardwaarde voor de optie "username") Hoe moet de naam van de toegewezen gebruiker worden getoond? Als "username", volledige naam ("real"), of helemaal niet ("none").';
$lang['ShowdateTag'] = '(Standaardwaarde voor de optie "showdate") Moet de Start/Due-date worden getoond in tag-definitieweergave?';
$lang['ShowdateList'] = '(Standaardwaarde voor de optie "showdate") Moet de Start/Due-date worden getoond in lijstweergave?';

View File

@@ -0,0 +1,15 @@
<?php
/**
* Portuguese (Brazilian) language strings
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Maíra <maira@maira.st>
*/
// custom language strings for the plugin
$lang['qb_todobutton'] = 'Marcar texto como tarefa';
$lang['refreshpage'] = 'Uma nova versão desta página está disponível. Atualize a página antes de tentar novamente.';
$lang['checkboxchange_on'] = 'Tarefa marcada';
$lang['checkboxchange_off'] = 'Tarefa desmarcada';
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,18 @@
<?php
/**
* Portuguese (Brazilian) language strings for the ToDo Plugin's settings
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Maíra <maira@maira.st>
*/
$lang['AllowLinks'] = 'Permitir ações a linkar para páginas com o mesmo nome?';
$lang['ActionNamespace'] = 'Em que namespace suas ações devem ser criadas? (".:" = Namespace atual, Vazio = Namespace raiz)';
$lang['Strikethrough'] = 'Exibir ações marcadas como finalizadas riscadas?';
$lang['CheckboxText'] = 'Se a opção AllowLinks estiver desabilitada, clicar no texto da tarefa deve marcar a tarefa como completa?';
$lang['Checkbox'] = '(Valor padrão para a opção "checkbox") A checkbox deve ser exibida em listas?';
$lang['Header'] = '(Valor padrão para a opção "header") Qual deve ser o nome do cabeçalho de uma lista? Como "id", o primeiro cabeçalho da página ("firstheader") ou nenhum ("none")?';
$lang['Username'] = '(Valor padrão para a opção "username") Como o nome dos usuários associados às tarefas devem ser exibidos: seu nome de usuário ("username"), nome completo ("real"), ou não devem ser exibidos ("none")?';
$lang['ShowdateTag'] = '(Valor padrão para a opção "showdate") As datas de início (start-date) e conclusão (due-date) devem ser exibidas nas definições de tarefas?';
$lang['ShowdateList'] = '(Valor padrão para a opção "showdate") As datas de início (start-date) e conclusão (due-date) devem ser exibidas em listas de tarefas?';
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author serg <sergey_art82@inbox.ru>
*/
$lang['qb_todobutton'] = 'Отметить текст как Задача (ToDo)';
$lang['refreshpage'] = 'Доступна более новая версия этой страницы. Обновите страницу перед новой попыткой.';
$lang['checkboxchange_on'] = 'Проверенные задачи';
$lang['checkboxchange_off'] = 'Непроверенные задачи';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Tor Härnqvist <tor@harnqvist.se>
*/
$lang['qb_todobutton'] = 'Markera text som Att göra';
$lang['refreshpage'] = 'En nyare version av denna sida är tillgänglig, uppdaterad din sidan innan du försöker igen';
$lang['checkboxchange_on'] = 'Att göra-markerad';
$lang['checkboxchange_off'] = 'Att göra-avmarkerad';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author Tor Härnqvist <tor@harnqvist.se>
*/
$lang['AllowLinks'] = 'Tillåt händelser att också länka till samma sida?';
$lang['ActionNamespace'] = 'Vilken namnrymd ska dina händelser skapas i (".:" = Nuvarande namnrymd, Blank = Grundnamnrymd)';
$lang['Strikethrough'] = 'Ska händelserna bli genomstrukna när de är markerade?';
$lang['CheckboxText'] = 'Om AllowLinks är avaktiverad ska händelsens text markeras som åtgärdad/avklarad vid klick?';
$lang['Checkbox'] = '(Standardvärde för "checkbox") Ska kryssrutan renderas i listvisning?';
$lang['Header'] = '(Standardvärde för "header") Hur ska rubriken på en lista namnges? Som "id", som den första rubriken på sidan "firstheader" eller inte alls "none".';
$lang['Username'] = '(Standardvärde för "username") Hur ska namnet på den valda användaren visas? Som "username", fullständigt namn "real" eller inte alls "none"';
$lang['ShowdateTag'] = '(Standardvärde för "showdate") Ska start-/förfallodatum renderas i taggdefinitionsvisning?';
$lang['ShowdateList'] = '(Standardvärde för "showdate") Ska start-/förfallodatum renderas i listvisning?';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author İlker Kapaç <irifat@gmail.com>
*/
$lang['qb_todobutton'] = 'Metni görev olarak işaretle';
$lang['refreshpage'] = 'Bu sayfanın daha güncel bir hali bulunmaktadır, tekrar denemeden önce sayfayı tazeleyin.';
$lang['checkboxchange_on'] = 'Görev işaretlendi';
$lang['checkboxchange_off'] = 'Görevin işareti kaldırıldı';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author İlker Kapaç <irifat@gmail.com>
*/
$lang['AllowLinks'] = 'Görevler aynı isme sahip sayfaya bağlantı versin mi?';
$lang['ActionNamespace'] = 'Görevlerin oluşturulacağı isim alanı (".:" = Bulunduğu isim alanı, Boş = Kök dizini)';
$lang['Strikethrough'] = 'Tamamlandı olarak işaretlenen görev metni, üzeri çizilmiş olarak gösterilsin mi?';
$lang['CheckboxText'] = 'Aynı isimli sayfaya bağlantı verme kapalıysa görev metnine tıklamak görevi tamamlandı olarak işaretlesin mi?';

View File

@@ -0,0 +1,12 @@
<?php
/**
* Traditional Chinese language strings for the ToDo Plugin
*
* @author ToroLiu <aecho.1028@gmail.com>
*/
$lang['AllowLinks'] = 'AllowLinks: ToDo是否與同名的page建立超連結';
$lang['ActionNamespace'] = 'ToDo應該建立在哪個NS(namespace)下? (".:" =目前的NS, 空白 = Root NS)';
$lang['Strikethrough'] = '當ToDo完成後是否套用刪除線';
$lang['CheckboxText'] = '如果AllowLinks關閉點擊ToDo的文字是否代表該事件己完成';

View File

@@ -0,0 +1,11 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author HL <tohelong@gmail.com>
*/
$lang['qb_todobutton'] = '标记为待办事项';
$lang['refreshpage'] = '本页面有新版本,请尝试刷新页面。';
$lang['checkboxchange_on'] = '选择待办';
$lang['checkboxchange_off'] = '取消选择待办';

View File

@@ -0,0 +1,16 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
* @author HL <tohelong@gmail.com>
*/
$lang['AllowLinks'] = '是否用同名链接到动作';
$lang['ActionNamespace'] = '动作的名字 (".:" = Current NS, Blank = Root NS)';
$lang['Strikethrough'] = '当动作选中时是否打上删除线';
$lang['CheckboxText'] = '如果不允许链接,点击动作时讲此项标记完成?';
$lang['Checkbox'] = '(“复选框”的默认值)复选框是否在列表中呈现?';
$lang['Header'] = '列表标题的名称';
$lang['Username'] = '用户名的名称';
$lang['ShowdateTag'] = '是否在标签视图显示日期';
$lang['ShowdateList'] = '是否在列表视图显示日期';

View File

@@ -0,0 +1,7 @@
base todo
author Leo Eibler, Christian Marg, Markus Gschwendt
email dokuwiki@sprossenwanne.at, marg@rz.tu-clausthal.de
date 2020-06-17
name ToDo
desc Create a checkbox based todo list with optional user assignment (by using <todo>This is a ToDo</todo>). In combination with dokuwiki searchpattern plugin it is a lightweight task list management system.
url https://www.dokuwiki.org/plugin:todo

132
lib/plugins/todo/script.js Normal file
View File

@@ -0,0 +1,132 @@
/**
* @date 20130405 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* replace old sack() method with new jQuery method and use post instead of get - see https://www.dokuwiki.org/devel:jqueryfaq \n
* @date 20130407 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* use jQuery for finding the elements \n
* @date 20130408 Christian Marg <marg@rz.tu-clausthal.de> \n
* change only the clicked todoitem instead of all items with the same text \n
* @date 20130408 Leo Eibler <dokuwiki@sprossenwanne.at> \n
* migrate changes made by Christian Marg to current version of plugin (use jQuery) \n
* @date 20130410 by Leo Eibler <dokuwiki@sprossenwanne.at> / http://www.eibler.at \n
* bugfix: encoding html code (security risk <todo><script>alert('hi')</script></todo>) - bug reported by Andreas \n
* @date 20130413 Christian Marg <marg@rz.tu-clausthal.de> \n
* bugfix: chk.attr('checked') returns checkbox state from html - use chk.is(':checked') - see http://www.unforastero.de/jquery/checkbox-angehakt.php \n
* @date 20130413 by Leo Eibler <dokuwiki@sprossenwanne.at> / http://www.eibler.at \n
* bugfix: config option Strikethrough \n
*/
/**
* html-layout:
*
* +input[checkbox].todocheckbox
* +span.todotext
* -del
* --span.todoinnertext
* ---anchor with text or text only
*/
var ToDoPlugin = {
/**
* lock to prevent simultanous requests
*/
locked: false,
/**
* @brief onclick method for input element
*
* @param {jQuery} $chk the jQuery input element
*/
todo: function ($chk) {
//skip when locked
if (ToDoPlugin.locked) {
return;
}
//set lock
ToDoPlugin.locked = true;
var $spanTodoinnertext = $chk.nextAll("span.todotext:first").find("span.todoinnertext"),
param = $chk.data(), // contains: index, pageid, date, strikethrough
checked = !$chk.is(':checked');
// if the data-index attribute is set, this is a call from the page where the todos are defined
if (param.index === undefined) param.index = -1;
if ($spanTodoinnertext.length) {
/**
* Callback function update the todoitem when save request succeed
*
* @param {Array} data returned by ajax request
*/
var whenCompleted = function (data) {
//update date after edit and show alert when needed
if (data.date) {
jQuery('input.todocheckbox').data('date', data.date);
}
if (data.message) {
alert(data.message);
}
//apply styling, or undo checking checkbox
if (data.succeed) {
$chk.prop('checked', checked);
if (checked) {
if (param.strikethrough && !$spanTodoinnertext.parent().is("del")) {
$spanTodoinnertext.wrap("<del></del>");
}
} else {
if ($spanTodoinnertext.parent().is("del")) {
$spanTodoinnertext.unwrap();
}
}
}
//release lock
ToDoPlugin.locked = false;
};
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_todo',
index: param.index,
pageid: param.pageid,
checked: checked ? "1" : "0",
date: param.date
},
whenCompleted,
'json'
);
} else {
alert("Appropriate javascript element not found.\nReverting checkmark.");
}
}
};
jQuery(function(){
// add handler to checkbox
jQuery('input.todocheckbox').click(function(e){
e.preventDefault();
e.stopPropagation();
var $this = jQuery(this);
// undo checking the checkbox
$this.prop('checked', !$this.is(':checked'));
ToDoPlugin.todo($this);
});
// add click handler to todotext spans when marked with 'clickabletodo'
jQuery('span.todotext.clickabletodo').click(function(){
//Find the checkbox node we need
var $chk = jQuery(this).prevAll('input.todocheckbox:first');
ToDoPlugin.todo($chk);
});
});

View File

@@ -0,0 +1,9 @@
/*
** @date 20130407 Leo Eibler <dokuwiki@sprossenwanne.at> \n
** add todouser for user assignment css class \n
*/
span.todohlght:hover{background:#DDD; cursor:default; }
span.todouser { font-size: x-small; cursor:default; font-style: italic; padding-left: 3px; padding-right: 3px; margin-right: 4px; }
span.tododates { font-size: x-small; padding-left: 3px; padding-right: 3px; margin-right: 4px; }
span.todostarted { background:#EEA; font-weight: bold; }
span.tododue { background:#EAA; font-weight: bold; }

View File

@@ -0,0 +1,511 @@
<?php
/**
* DokuWiki Plugin todo_list (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
/**
* Class syntax_plugin_todo_list
*/
class syntax_plugin_todo_list extends syntax_plugin_todo_todo {
/**
* @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 250;
}
/**
* Connect lookup pattern to lexer.
*
* @param string $mode Parser mode
*/
public function connectTo($mode) {
$this->Lexer->addSpecialPattern('~~TODOLIST[^~]*~~', $mode, 'plugin_todo_list');
}
/**
* Handle matches of the todolist syntax
*
* @param string $match The match of the syntax
* @param int $state The state of the handler
* @param int $pos The position in the document
* @param Doku_Handler $handler The handler
* @return array Data for the renderer
*/
public function handle($match, $state, $pos, Doku_Handler $handler) {
$options = substr($match, 10, -2); // strip markup
$options = explode(' ', $options);
$data = array(
'header' => $this->getConf("Header"),
'completed' => 'all',
'assigned' => 'all',
'completeduserlist' => 'all',
'ns' => 'all',
'showdate' => $this->getConf("ShowdateList"),
'checkbox' => $this->getConf("Checkbox"),
'username' => $this->getConf("Username"),
'short' => false,
);
$allowedvalues = array('yes', 'no');
foreach($options as $option) {
@list($key, $value) = explode(':', $option, 2);
switch($key) {
case 'header': // how should the header be rendered?
if(in_array($value, array('id', 'firstheader', 'none'))) {
$data['header'] = $value;
}
break;
case 'short':
if(in_array($value, $allowedvalues)) {
$data['short'] = ($value == 'yes');
}
break;
case 'showdate':
if(in_array($value, $allowedvalues)) {
$data['showdate'] = ($value == 'yes');
}
break;
case 'checkbox': // should checkbox be rendered?
if(in_array($value, $allowedvalues)) {
$data['checkbox'] = ($value == 'yes');
}
break;
case 'completed':
if(in_array($value, $allowedvalues)) {
$data['completed'] = ($value == 'yes');
}
break;
case 'username': // how should the username be rendered?
if(in_array($value, array('user', 'real', 'none'))) {
$data['username'] = $value;
}
break;
case 'assigned':
if(in_array($value, $allowedvalues)) {
$data['assigned'] = ($value == 'yes');
break;
}
//assigned?
$data['assigned'] = explode(',', $value);
// @date 20140317 le: if check for logged in user, also check for logged in user email address
if( in_array( '@@USER@@', $data['assigned'] ) ) {
$data['assigned'][] = '@@MAIL@@';
}
$data['assigned'] = array_map( array($this,"__todolistTrimUser"), $data['assigned'] );
break;
case 'completeduser':
$data['completeduserlist'] = explode(',', $value);
// @date 20140317 le: if check for logged in user, also check for logged in user email address
if(in_array('@@USER@@', $data['completeduserlist'])) {
$data['completeduserlist'][] = '@@MAIL@@';
}
$data['completeduserlist'] = array_map( array($this,"__todolistTrimUser"), $data['completeduserlist'] );
break;
case 'ns':
$data['ns'] = $value;
break;
case 'startbefore':
list($data['startbefore'], $data['startignore']) = $this->analyseDate($value);
break;
case 'startafter':
list($data['startafter'], $data['startignore']) = $this->analyseDate($value);
break;
case 'startat':
list($data['startat'], $data['startignore']) = $this->analyseDate($value);
break;
case 'duebefore':
list($data['duebefore'], $data['dueignore']) = $this->analyseDate($value);
break;
case 'dueafter':
list($data['dueafter'], $data['dueignore']) = $this->analyseDate($value);
break;
case 'dueat':
list($data['dueat'], $data['dueignore']) = $this->analyseDate($value);
break;
case 'completedbefore':
list($data['completedbefore']) = $this->analyseDate($value);
break;
case 'completedafter':
list($data['completedafter']) = $this->analyseDate($value);
break;
case 'completedat':
list($data['completedat']) = $this->analyseDate($value);
break;
}
}
return $data;
}
/**
* Render xhtml output or metadata
*
* @param string $mode Renderer mode (supported modes: xhtml)
* @param Doku_Renderer $renderer The renderer
* @param array $data The data from the handler() function
* @return bool If rendering was successful.
*/
public function render($mode, Doku_Renderer $renderer, $data) {
global $conf;
if($mode != 'xhtml') return false;
/** @var Doku_Renderer_xhtml $renderer */
$opts['pattern'] = '/<todo([^>]*)>(.*?)<\/todo[\W]*?>/'; //all todos in a wiki page
$opts['ns'] = $data['ns'];
//TODO check if storing subpatterns doesn't cost too much resources
// search(&$data, $base, $func, $opts,$dir='',$lvl=1,$sort='natural')
search($todopages, $conf['datadir'], array($this, 'search_todos'), $opts); //browse wiki pages with callback to search_pattern
$todopages = $this->filterpages($todopages, $data);
foreach($todopages as &$page) {
uasort($page['todos'], function($a, $b) {
if(isset($a['due']) && isset($b['due'])) {
return $a['due'] <=> $b['due'];
} else if (isset($a['due']) xor isset($b['due'])) {
return isset($a['due']) ? -1 : 1;
} else {
return 0;
}
});
}
if($data['short']) {
$this->htmlShort($renderer, $todopages, $data);
} else {
$this->htmlTodoTable($renderer, $todopages, $data);
}
return true;
}
/**
* Custom search callback
*
* This function is called for every found file or
* directory. When a directory is given to the function it has to
* decide if this directory should be traversed (true) or not (false).
* Return values for files are ignored
*
* All functions should check the ACL for document READ rights
* namespaces (directories) are NOT checked (when sneaky_index is 0) as this
* would break the recursion (You can have an nonreadable dir over a readable
* one deeper nested) also make sure to check the file type (for example
* in case of lockfiles).
*
* @param array &$data - Reference to the result data structure
* @param string $base - Base usually $conf['datadir']
* @param string $file - current file or directory relative to $base
* @param string $type - Type either 'd' for directory or 'f' for file
* @param int $lvl - Current recursion depht
* @param array $opts - option array as given to search()
* @return bool if this directory should be traversed (true) or not (false). Return values for files are ignored.
*/
public function search_todos(&$data, $base, $file, $type, $lvl, $opts) {
$item['id'] = pathID($file); //get current file ID
//we do nothing with directories
if($type == 'd') return true;
//only search txt files
if(substr($file, -4) != '.txt') return true;
//check ACL
if(auth_quickaclcheck($item['id']) < AUTH_READ) return false;
// filter namespaces
if(!$this->filter_ns($item['id'], $opts['ns'])) return false;
$wikitext = rawWiki($item['id']); //get wiki text
// check if ~~NOTODO~~ is set on the page to skip this page
if(1 == preg_match('/~~NOTODO~~/', $wikitext)) return false;
$item['count'] = preg_match_all($opts['pattern'], $wikitext, $matches); //count how many times appears the pattern
if(!empty($item['count'])) { //if it appears at least once
$item['matches'] = $matches;
$data[] = $item;
}
return true;
}
/**
* filter namespaces
*
* @param $todopages array pages with all todoitems
* @param $item string listing parameters
* @return boolean if item id is in namespace
*/
private function filter_ns($item, $ns) {
global $ID;
// check if we should accept currant namespace+subnamespaces or only subnamespaces
$wildsubns = substr($ns, -2) == '.:';
$onlysubns = !$wildsubns && (substr($ns, -1) == ':' || substr($ns, -2) == ':.');
// $onlyns = $onlysubns && substr($ns, -1) == '.';
// if first char of ns is '.'replace it with current ns
if ($ns[0] == '.') {
$ns = substr($ID, 0, strrpos($ID, ':')+1).ltrim($ns, '.:');
}
$ns = trim($ns, '.:');
$len = strlen($ns);
$parsepage = false;
if ($parsepage = $ns == 'all') {
// Always return the todo pages
} elseif ($ns == '/') {
// Only return the todo page if it's in the root namespace
$parsepage = strpos($item, ':') === FALSE;
} elseif ($wildsubns) {
$p = strpos($item.':', ':', $len+1);
$x = substr($item, $len+1, $p-$len);
$parsepage = 0 === strpos($item, rtrim($ns.':'.$x, ':').':');
} elseif ($onlysubns) {
$parsepage = 0 === strpos($item, $ns.':');
} elseif ($parsepage = substr($item, 0, $len) == $ns) {
}
return $parsepage;
}
/**
* Expand assignee-placeholders
*
* @param $user String to be worked on
* @return expanded string
*/
private function __todolistExpandAssignees($user) {
global $USERINFO;
if($user == '@@USER@@' && !empty($_SERVER['REMOTE_USER'])) { //$INPUT->server->str('REMOTE_USER')
return $_SERVER['REMOTE_USER'];
}
// @date 20140317 le: check for logged in user email address
if( $user == '@@MAIL@@' && isset( $USERINFO['mail'] ) ) {
return $USERINFO['mail'];
}
return $user;
}
/**
* Trim input if it's a user
*
* @param $user String to be worked on
* @return trimmed string
*/
private function __todolistTrimUser($user) {
//placeholder (inspired by replacement-patterns - see https://www.dokuwiki.org/namespace_templates#replacement_patterns)
if( $user == '@@USER@@' || $user == '@@MAIL@@' ) {
return $user;
}
//user
return trim(ltrim($user, '@'));
}
/**
* filter the pages
*
* @param $todopages array pages with all todoitems
* @param $data array listing parameters
* @return array filtered pages
*/
private function filterpages($todopages, $data) {
$pages = array();
if(count($todopages)>0) {
foreach($todopages as $page) {
$todos = array();
// contains 3 arrays: an array with complete matches and 2 arrays with subpatterns
foreach($page['matches'][1] as $todoindex => $todomatch) {
$todo = array_merge(array('todotitle' => trim($page['matches'][2][$todoindex]), 'todoindex' => $todoindex), $this->parseTodoArgs($todomatch), $data);
if($this->isRequestedTodo($todo)) { $todos[] = $todo; }
}
if(count($todos) > 0) {
$pages[] = array('id' => $page['id'], 'todos' => $todos);
}
}
return $pages;
}
return null;
}
private function htmlShort($R, $todopages, $data) {
$done = 0; $todo = 0;
foreach($todopages as $page) {
foreach($page['todos'] as $value) {
$todo++;
if ($value['checked']) {
$done++;
}
}
}
$R->cdata("($done/$todo)");
}
/**
* Create html for table with todos
*
* @param Doku_Renderer_xhtml $R
* @param array $todopages
* @param array $data array with rendering options
*/
private function htmlTodoTable($R, $todopages, $data) {
if (is_null($todopages)) return;
$R->table_open();
foreach($todopages as $page) {
if ($data['header']!='none') {
$R->tablerow_open();
$R->tableheader_open();
$R->internallink(':'.$page['id'], ($data['header']=='firstheader' ? p_get_first_heading($page['id']) : $page['id']));
$R->tableheader_close();
$R->tablerow_close();
}
foreach($page['todos'] as $todo) {
//echo "<pre>";var_dump($todo);echo "</pre>";
$R->tablerow_open();
$R->tablecell_open();
$R->doc .= $this->createTodoItem($R, $page['id'], array_merge($todo, $data));
$R->tablecell_close();
$R->tablerow_close();
}
}
$R->table_close();
}
/**
* Check the conditions for adding a todoitem
*
* @param $data array the defined filters
* @param $checked bool completion status of task; true: finished, false: open
* @param $todouser string user username of user
* @return bool if the todoitem should be listed
*/
private function isRequestedTodo($data) {
//completion status
$condition1 = $data['completed'] === 'all' //all
|| $data['completed'] === $data['checked']; //yes or no
// resolve placeholder in assignees
$requestedassignees = array();
if(is_array($data['assigned'])) {
$requestedassignees = array_map( array($this,"__todolistExpandAssignees"), $data['assigned'] );
}
//assigned
$condition2 = $condition2
|| $data['assigned'] === 'all' //all
|| (is_bool($data['assigned']) && $data['assigned'] == $data['todouser']); //yes or no
if (!$condition2 && is_array($data['assigned']) && is_array($data['todousers']))
foreach($data['todousers'] as $todouser) {
if(in_array($todouser, $requestedassignees)) { $condition2 = true; break; }
}
//completed by
if($condition2 && is_array($data['completeduserlist']))
$condition2 = in_array($data['completeduser'], $data['completeduserlist']);
//compare start/due dates
if($condition1 && $condition2) {
$condition3s = true; $condition3d = true;
if(isset($data['startbefore']) || isset($data['startafter']) || isset($data['startat'])) {
if(is_object($data['start'])) {
if($data['startignore'] != '!') {
if(isset($data['startbefore'])) { $condition3s = $condition3s && new DateTime($data['startbefore']) > $data['start']; }
if(isset($data['startafter'])) { $condition3s = $condition3s && new DateTime($data['startafter']) < $data['start']; }
if(isset($data['startat'])) { $condition3s = $condition3s && new DateTime($data['startat']) == $data['start']; }
}
} else {
if(!$data['startignore'] == '*') { $condition3s = false; }
if($data['startignore'] == '!') { $condition3s = false; }
}
}
if(isset($data['duebefore']) || isset($data['dueafter']) || isset($data['dueat'])) {
if(is_object($data['due'])) {
if($data['dueignore'] != '!') {
if(isset($data['duebefore'])) { $condition3d = $condition3d && new DateTime($data['duebefore']) > $data['due']; }
if(isset($data['dueafter'])) { $condition3d = $condition3d && new DateTime($data['dueafter']) < $data['due']; }
if(isset($data['dueat'])) { $condition3d = $condition3d && new DateTime($data['dueat']) == $data['due']; }
}
} else {
if(!$data['dueignore'] == '*') { $condition3d = false; }
if($data['dueignore'] == '!') { $condition3d = false; }
}
}
$condition3 = $condition3s && $condition3d;
}
// compare completed date
$condition4 = true;
if(isset($data['completedbefore'])) {
$condition4 = $condition4 && new DateTime($data['completedbefore']) > $data['completeddate'];
}
if(isset($data['completedafter'])) {
$condition4 = $condition4 && new DateTime($data['completedafter']) < $data['completeddate'];
}
if(isset($data['completedat'])) {
$condition4 = $condition4 && new DateTime($data['completedat']) == $data['completeddate'];
}
return $condition1 AND $condition2 AND $condition3 AND $condition4;
}
/**
* Analyse of relative/absolute Date and return an absolute date
*
* @param $date string absolute/relative value of the date to analyse
* @return array absolute date or actual date if $date is invalid
*/
private function analyseDate($date) {
$result = array($date, '');
if(is_string($date)) {
if($date == '!') {
$result = array('', '!');
} elseif ($date =='*') {
$result = array('', '*');
} else {
if(substr($date, -1) == '*') {
$date = substr($date, 0, -1);
$result = array($date, '*');
}
if(date('Y-m-d', strtotime($date)) == $date) {
$result[0] = $date;
} elseif(preg_match('/^[\+\-]\d+$/', $date)) { // check if we have a valid relative value
$newdate = date_create(date('Y-m-d'));
date_modify($newdate, $date . ' day');
$result[0] = date_format($newdate, 'Y-m-d');
} else {
$result[0] = date('Y-m-d');
}
}
} else { $result[0] = date('Y-m-d'); }
return $result;
}
}

View File

@@ -0,0 +1,473 @@
<?php
/**
* ToDo Plugin: Creates a checkbox based todo list
*
* Syntax: <todo [@username] [#]>Name of Action</todo> -
* Creates a Checkbox with the "Name of Action" as
* the text associated with it. The hash (#, optional)
* will cause the checkbox to be checked by default.
* The @ sign followed by a username can be used to assign this todo to a user.
* examples:
* A todo without user assignment
* <todo>Something todo</todo>
* A completed todo without user assignment
* <todo #>Completed todo</todo>
* A todo assigned to user User
* <todo @leo>Something todo for Leo</todo>
* A completed todo assigned to user User
* <todo @leo #>Todo completed for Leo</todo>
*
* In combination with dokuwiki searchpattern plugin version (at least v20130408),
* it is a lightweight solution for a task management system based on dokuwiki.
* use this searchpattern expression for open todos:
* ~~SEARCHPATTERN#'/<todo[^#>]*>.*?<\/todo[\W]*?>/'?? _ToDo ??~~
* use this searchpattern expression for completed todos:
* ~~SEARCHPATTERN#'/<todo[^#>]*#[^>]*>.*?<\/todo[\W]*?>/'?? _ToDo ??~~
* do not forget the no-cache option
* ~~NOCACHE~~
*
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Babbage <babbage@digitalbrink.com>; Leo Eibler <dokuwiki@sprossenwanne.at>
*/
if(!defined('DOKU_INC')) die();
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_todo_todo extends DokuWiki_Syntax_Plugin {
/**
* Get the type of syntax this plugin defines.
*
* @return String
*/
public function getType() {
return 'substition';
}
/**
* Paragraph Type
*
* 'normal' - The plugin can be used inside paragraphs
* 'block' - Open paragraphs need to be closed before plugin output
* 'stack' - Special case. Plugin wraps other paragraphs.
*/
function getPType(){
return 'normal';
}
/**
* Where to sort in?
*
* @return Integer
*/
public function getSort() {
return 999;
}
/**
* Connect lookup pattern to lexer.
*
* @param $mode String The desired rendermode.
* @return void
* @see render()
*/
public function connectTo($mode) {
$this->Lexer->addEntryPattern('<todo[\s]*?.*?>(?=.*?</todo>)', $mode, 'plugin_todo_todo');
$this->Lexer->addSpecialPattern('~~NOTODO~~', $mode, 'plugin_todo_todo');
}
public function postConnect() {
$this->Lexer->addExitPattern('</todo>', 'plugin_todo_todo');
}
/**
* Handler to prepare matched data for the rendering process.
*
* @param $match string The text matched by the patterns.
* @param $state int The lexer state for the match.
* @param $pos int The character position of the matched text.
* @param $handler Doku_Handler Reference to the Doku_Handler object.
* @return int The current lexer state for the match.
*/
public function handle($match, $state, $pos, Doku_Handler $handler) {
switch($state) {
case DOKU_LEXER_ENTER :
#Search to see if the '#' is in the todotag (if so, this means the Action has been completed)
$x = preg_match('%<todo([^>]*)>%i', $match, $tododata);
if($x) {
$handler->todoargs = $this->parseTodoArgs($tododata[1]);
}
if(!is_numeric($handler->todo_index)) {
$handler->todo_index = 0;
}
break;
case DOKU_LEXER_MATCHED :
break;
case DOKU_LEXER_UNMATCHED :
/**
* Structure:
* input(checkbox)
* <span>
* -<a> (if links is on) or <span> (if links is off)
* --<del> (if strikethrough is on) or --NOTHING--
* -</a> or </span>
* </span>
*/
#Make sure there is actually an action to create
if(trim($match) != '') {
$data = array_merge(array ($state, 'todotitle' => $match, 'todoindex' => $handler->todo_index, 'todouser' => $handler->todo_user, 'checked' => $handler->checked), $handler->todoargs);
$handler->todo_index++;
return $data;
}
break;
case DOKU_LEXER_EXIT :
#Delete temporary checked variable
unset($handler->todo_user);
unset($handler->checked);
unset($handler->todoargs);
//unset($handler->todo_index);
break;
case DOKU_LEXER_SPECIAL :
break;
}
return array();
}
/**
* Handle the actual output creation.
*
* @param $mode String The output format to generate.
* @param $renderer Doku_Renderer A reference to the renderer object.
* @param $data Array The data created by the <tt>handle()</tt> method.
* @return Boolean true: if rendered successfully, or false: otherwise.
*/
public function render($mode, Doku_Renderer $renderer, $data) {
global $ID;
list($state, $todotitle) = $data;
if($mode == 'xhtml') {
/** @var $renderer Doku_Renderer_xhtml */
if($state == DOKU_LEXER_UNMATCHED) {
#Output our result
$renderer->doc .= $this->createTodoItem($renderer, $ID, array_merge($data, array('checkbox'=>'yes')));
return true;
}
} elseif($mode == 'metadata') {
/** @var $renderer Doku_Renderer_metadata */
if($state == DOKU_LEXER_UNMATCHED) {
$id = $this->_composePageid($todotitle);
$renderer->internallink($id, $todotitle);
}
}
return false;
}
/**
* Parse the arguments of todotag
*
* @param string $todoargs
* @return array(bool, false|string) with checked and user
*/
protected function parseTodoArgs($todoargs) {
$data['checked'] = false;
unset($data['start']);
unset($data['due']);
unset($data['completeddate']);
$data['showdate'] = $this->getConf("ShowdateTag");
$data['username'] = $this->getConf("Username");
$options = explode(' ', $todoargs);
foreach($options as $option) {
$option = trim($option);
if($option[0] == '@') {
$data['todousers'][] = substr($option, 1); //fill todousers array
if(!isset($data['todouser'])) $data['todouser'] = substr($option, 1); //set the first/main todouser
}
elseif($option[0] == '#') {
$data['checked'] = true;
@list($completeduser, $completeddate) = explode(':', $option, 2);
$data['completeduser'] = substr($completeduser, 1);
if(date('Y-m-d', strtotime($completeddate)) == $completeddate) {
$data['completeddate'] = new DateTime($completeddate);
}
}
else {
@list($key, $value) = explode(':', $option, 2);
switch($key) {
case 'username':
if(in_array($value, array('user', 'real', 'none'))) {
$data['username'] = $value;
}
break;
case 'start':
if(date('Y-m-d', strtotime($value)) == $value) {
$data['start'] = new DateTime($value);
}
break;
case 'due':
if(date('Y-m-d', strtotime($value)) == $value) {
$data['due'] = new DateTime($value);
}
break;
case 'showdate':
if(in_array($value, array('yes', 'no'))) {
$data['showdate'] = ($value == 'yes');
}
break;
}
}
}
return $data;
}
/**
* @param Doku_Renderer_xhtml $renderer
* @param string $id of page
* @param array $data data for rendering options
* @return string html of an item
*/
protected function createTodoItem($renderer, $id, $data) {
//set correct context
global $ID, $INFO;
$oldID = $ID;
$ID = $id;
$todotitle = $data['todotitle'];
$todoindex = $data['todoindex'];
$checked = $data['checked'];
if($data['checkbox']) {
$return = '<input type="checkbox" class="todocheckbox"'
. ' data-index="' . $todoindex . '"'
. ' data-date="' . hsc(@filemtime(wikiFN($ID))) . '"'
. ' data-pageid="' . hsc($ID) . '"'
. ' data-strikethrough="' . ($this->getConf("Strikethrough") ? '1' : '0') . '"'
. ($checked ? ' checked="checked"' : '') . ' /> ';
}
// Username(s) of todouser(s)
if (!isset($data['todousers'])) $data['todousers']=array();
$todousers = array();
foreach($data['todousers'] as $user) {
if (($user = $this->_prepUsername($user,$data['username'])) != '') {
$todousers[] = $user;
}
}
$todouser=join(', ',$todousers);
if($todouser!='') {
$return .= '<span class="todouser">[' . hsc($todouser) . ']</span>';
}
if(isset($data['completeduser']) && ($checkeduser=$this->_prepUsername($data['completeduser'],$data['username']))!='') {
$return .= '<span class="todouser">[' . hsc('✓ '.$checkeduser);
if(isset($data['completeddate'])) { $return .= ', '.$data['completeddate']->format('Y-m-d'); }
$return .= ']</span>';
}
// start/due date
unset($bg);
$now = new DateTime("now");
if(!$checked && (isset($data['start']) || isset($data['due'])) && (!isset($data['start']) || $data['start']<$now) && (!isset($data['due']) || $now<$data['due'])) $bg='todostarted';
if(!$checked && isset($data['due']) && $now>=$data['due']) $bg='tododue';
// show start/due date
if($data['showdate'] == 1 && (isset($data['start']) || isset($data['due']))) {
$return .= '<span class="tododates">[';
if(isset($data['start'])) { $return .= $data['start']->format('Y-m-d'); }
$return .= ' → ';
if(isset($data['due'])) { $return .= $data['due']->format('Y-m-d'); }
$return .= ']</span>';
}
$spanclass = 'todotext';
if($this->getConf("CheckboxText") && !$this->getConf("AllowLinks") && $oldID == $ID && $data['checkbox']) {
$spanclass .= ' clickabletodo todohlght';
}
if(isset($bg)) $spanclass .= ' '.$bg;
$return .= '<span class="' . $spanclass . '">';
if($checked && $this->getConf("Strikethrough")) {
$return .= '<del>';
}
$return .= '<span class="todoinnertext">';
if($this->getConf("AllowLinks")) {
$return .= $this->_createLink($renderer, $todotitle, $todotitle);
} else {
if ($oldID != $ID) {
$return .= $renderer->internallink($id, $todotitle, null, true);
} else {
$return .= hsc($todotitle);
}
}
$return .= '</span>';
if($checked && $this->getConf("Strikethrough")) {
$return .= '</del>';
}
$return .= '</span>';
//restore page ID
$ID = $oldID;
return $return;
}
/**
* Prepare user name string.
*
* @param string $username
* @param string $displaytype - one of 'user', 'real', 'none'
* @return string
*/
private function _prepUsername($username, $displaytype) {
switch ($displaytype) {
case "real":
global $auth;
$username = $auth->getUserData($username)['name'];
break;
case "none":
$username="";
break;
case "user":
default:
break;
}
return $username;
}
/**
* Generate links from our Actions if necessary.
*
* @param Doku_Renderer_xhtml $renderer
* @param string $pagename
* @param string $name
* @return string
*/
private function _createLink($renderer, $pagename, $name = NULL) {
$id = $this->_composePageid($pagename);
return $renderer->internallink($id, $name, null, true);
}
/**
* Compose the pageid of the pages linked by a todoitem
*
* @param string $pagename
* @return string page id
*/
private function _composePageid($pagename) {
#Get the ActionNamespace and make sure it ends with a : (if not, add it)
$actionNamespace = $this->getConf("ActionNamespace");
if(strlen($actionNamespace) == 0 || substr($actionNamespace, -1) != ':') {
$actionNamespace .= ":";
}
#Replace ':' in $pagename so we don't create unnecessary namespaces
$pagename = str_replace(':', '-', $pagename);
//resolve and build link
$id = $actionNamespace . $pagename;
return $id;
}
/**
* @brief this function can be called by dokuwiki plugin searchpattern to process the todos found by searchpattern.
* use this searchpattern expression for open todos:
* ~~SEARCHPATTERN#'/<todo[^#>]*>.*?<\/todo[\W]*?>/'?? _ToDo ??~~
* use this searchpattern expression for completed todos:
* ~~SEARCHPATTERN#'/<todo[^#>]*#[^>]*>.*?<\/todo[\W]*?>/'?? _ToDo ??~~
* this handler method uses the table and layout with css classes from searchpattern plugin
*
* @param $type string type of the request from searchpattern plugin
* (wholeoutput, intable:whole, intable:prefix, intable:match, intable:count, intable:suffix)
* wholeoutput = all output is done by THIS plugin (no output will be done by search pattern)
* intable:whole = the left side of table (page name) is done by searchpattern, the right side
* of the table will be done by THIS plugin
* intable:prefix = on the right side of table - THIS plugin will output a prefix header and
* searchpattern will continue it's default output
* intable:match = if regex, right side of table - THIS plugin will format the current
* outputvalue ($value) and output it instead of searchpattern
* intable:count = if normal, right side of table - THIS plugin will format the current
* outputvalue ($value) and output it instead of searchpattern
* intable:suffix = on the right side of table - THIS plugin will output a suffix footer and
* searchpattern will continue it's default output
* @param Doku_Renderer_xhtml $renderer current rendering object (use $renderer->doc .= 'text' to output text)
* @param array $data whole data multidemensional array( array( $page => $countOfMatches ), ... )
* @param array $matches whole regex matches multidemensional array( array( 0 => '1st Match', 1 => '2nd Match', ... ), ... )
* @param string $page id of current page
* @param array $params the parameters set by searchpattern (see search pattern documentation)
* @param string $value value which should be outputted by searchpattern
* @return bool true if THIS method is responsible for the output (using $renderer->doc) OR false if searchpattern should output it's default
*/
public function _searchpatternHandler($type, $renderer, $data, $matches, $params = array(), $page = null, $value = null) {
$renderer->nocache();
$type = strtolower($type);
switch($type) {
case 'wholeoutput':
// $matches should hold an array with all <todo>matches</todo> or <todo #>matches</todo>
if(!is_array($matches)) {
return false;
}
//file_put_contents( dirname(__FILE__).'/debug.txt', print_r($matches,true), FILE_APPEND );
//file_put_contents( dirname(__FILE__).'/debug.txt', print_r($params,true), FILE_APPEND );
$renderer->doc .= '<div class="sp_main">';
$renderer->doc .= '<table class="inline sp_main_table">'; //create table
foreach($matches as $page => $allTodosPerPage) {
$renderer->doc .= '<tr class="sp_title"><th class="sp_title" colspan="2"><a href="' . wl($page) . '">' . $page . '</a></td></tr>';
//entry 0 contains all whole matches
foreach($allTodosPerPage[0] as $todoindex => $todomatch) {
$x = preg_match('%<todo([^>]*)>(.*)</[\W]*todo[\W]*>%i', $todomatch, $tododata);
if($x) {
list($checked, $todouser) = $this->parseTodoArgs($tododata[1]);
$todotitle = trim($tododata[2]);
if(empty($todotitle)) {
continue;
}
$renderer->doc .= '<tr class="sp_result"><td class="sp_page" colspan="2">';
// in case of integration with searchpattern there is no chance to find the index of an element
$renderer->doc .= $this->createTodoItem($renderer, $todotitle, $todoindex, $todouser, $checked, $page, array('checkbox'=>'yes', 'username'=>'user'));
$renderer->doc .= '</td></tr>';
}
}
}
$renderer->doc .= '</table>'; //end table
$renderer->doc .= '</div>';
// true means, that this handler method does the output (searchpattern plugin has nothing to do)
return true;
break;
case 'intable:whole':
break;
case 'intable:prefix':
//$renderer->doc .= '<b>Start on Page '.$page.'</b>';
break;
case 'intable:match':
//$renderer->doc .= 'regex match on page '.$page.': <pre>'.$value.'</pre>';
break;
case 'intable:count':
//$renderer->doc .= 'normal count on page '.$page.': <pre>'.$value.'</pre>';
break;
case 'intable:suffix':
//$renderer->doc .= '<b>End on Page '.$page.'</b>';
break;
default:
break;
}
// false means, that this handler method does not output anything. all should be done by searchpattern plugin
return false;
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :

BIN
lib/plugins/todo/todo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B