diff --git a/README.md b/README.md index 90cddee..671484f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # doodle +DokuWiki Extensions : https://www.dokuwiki.org/plugin:doodle + +This plugin can help your team to schedule meetings or making other decisions in a team. + diff --git a/lang/ca/lang.php b/lang/ca/lang.php new file mode 100644 index 0000000..16e132d --- /dev/null +++ b/lang/ca/lang.php @@ -0,0 +1,9 @@ + + */ + +$lang['btn_submit'] = 'Envia'; + +//Setup VIM: ex: et ts=4 enc=utf-8 : +?> diff --git a/lang/de/lang.php b/lang/de/lang.php new file mode 100644 index 0000000..887efa1 --- /dev/null +++ b/lang/de/lang.php @@ -0,0 +1,6 @@ + diff --git a/lang/en/lang.php b/lang/en/lang.php new file mode 100644 index 0000000..8e97789 --- /dev/null +++ b/lang/en/lang.php @@ -0,0 +1,6 @@ + diff --git a/lang/es/lang.php b/lang/es/lang.php new file mode 100644 index 0000000..c1d98d4 --- /dev/null +++ b/lang/es/lang.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/lang/fr/lang.php b/lang/fr/lang.php new file mode 100644 index 0000000..3a75cf0 --- /dev/null +++ b/lang/fr/lang.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/lang/hu/lang.php b/lang/hu/lang.php new file mode 100644 index 0000000..9e5d1ab --- /dev/null +++ b/lang/hu/lang.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/lang/it/lang.php b/lang/it/lang.php new file mode 100644 index 0000000..cac4330 --- /dev/null +++ b/lang/it/lang.php @@ -0,0 +1,5 @@ + diff --git a/lang/nl/lang.php b/lang/nl/lang.php new file mode 100644 index 0000000..92269a2 --- /dev/null +++ b/lang/nl/lang.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/lang/sv/lang.php b/lang/sv/lang.php new file mode 100644 index 0000000..7b54d2b --- /dev/null +++ b/lang/sv/lang.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/lang/zh-cn/lang.php b/lang/zh-cn/lang.php new file mode 100644 index 0000000..f1ccf22 --- /dev/null +++ b/lang/zh-cn/lang.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/lang/zh-tw/lang.php b/lang/zh-tw/lang.php new file mode 100644 index 0000000..414f111 --- /dev/null +++ b/lang/zh-tw/lang.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/manager.dat b/manager.dat new file mode 100644 index 0000000..2e99026 --- /dev/null +++ b/manager.dat @@ -0,0 +1,2 @@ +downloadurl=http://admin.parlenet.org/files/plugins/doodle.tgz +installed=Tue, 31 May 2022 15:24:36 +0000 diff --git a/plugin.info.txt b/plugin.info.txt new file mode 100644 index 0000000..8f67878 --- /dev/null +++ b/plugin.info.txt @@ -0,0 +1,7 @@ +base doodle +author Francois Merciol +email dokuplugin@merciol.fr +date 2021-03-21 +name Doodle Plugin +desc helps to schedule meetings +url http://www.dokuwiki.org/plugin:doodle diff --git a/style.css b/style.css new file mode 100644 index 0000000..7aee3f7 --- /dev/null +++ b/style.css @@ -0,0 +1,9 @@ +div.dokuwiki table.inline td.okay { + background-color: #afa; + text-align: center; +} + +div.dokuwiki table.inline td.notokay { + background-color: #fcc; + text-align: center; +} diff --git a/syntax.php b/syntax.php new file mode 100644 index 0000000..66b1d0b --- /dev/null +++ b/syntax.php @@ -0,0 +1,272 @@ + + * @previsou author Esther Brunner + */ + +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +require_once(DOKU_PLUGIN.'syntax.php'); + +/** + * All DokuWiki plugins to extend the parser/rendering mechanism + * need to inherit from this class + */ +class syntax_plugin_doodle extends DokuWiki_Syntax_Plugin { + /** + * return some info + */ + function getInfo(){ + return array( + 'author' => 'Jonathan Tsai', + 'email' => 'tryweb@ichiayi.com', + 'date' => '2009/08/10', + 'name' => 'Doodle Plugin', + 'desc' => 'helps to schedule meetings', + 'url' => 'http://wiki.splitbrain.org/plugin:doodle', + ); + } + + function getType(){ return 'substition';} + function getPType(){ return 'block';} + function getSort(){ return 168; } + + /** + * Connect pattern to lexer + */ + function connectTo($mode){ + $this->Lexer->addSpecialPattern('.+?', $mode, 'plugin_doodle'); + } + + /** + * Handle the match + */ + function handle($match, $state, $pos, Doku_Handler $handler){ + $match = substr($match, 8, -9); // strip markup + list($title, $options) = preg_split('/>/u', $match, 2); + list($leftstr, $rightstr) = explode ('\|', $title); + if ($rightstr == "") { + $title = $leftstr; + $disable = ""; + $single = ""; + $login = ""; + } + else { + $title = $rightstr; + $disable = strpos($leftstr, "disable"); + $single = strpos($leftstr, "single"); + $login = strpos($leftstr, "login"); + } + if (!$options){ + $options = $title; + $title = NULL; + } + $options = explode('^', $match); + + $c = count($options); + for ($i = 0; $i < $c; $i++){ + $options[$i] = trim($options[$i]); + } + + return array(trim($title), $options, $disable, $single, $login); + } + + /** + * Create output + */ + function render($mode, Doku_Renderer $renderer, $data) { + if ($mode == 'xhtml'){ + global $lang; + + $options = $data[1]; + $c = count($options)-1; + $title = $renderer->_xmlEntities($data[0]); + $disable = $renderer->_xmlEntities($data[2]); + $single = $renderer->_xmlEntities($data[3]); + $login = $renderer->_xmlEntities($data[4]); + $dID = md5($title); + + // prevent caching to ensure the poll results are fresh + $renderer->info['cache'] = false; + + // get doodle file contents + $dfile = metaFN($dID, '.doodle'); + $old_dfile = metaFN(md5(cleanID($title)), '.doodle'); + // rename old meta File + if (file_exists($old_dfile)) { + rename($old_dfile, $dfile); + } + $doodle = unserialize(@file_get_contents($dfile)); + + if ($c == 0){ + // no options given: reset the doodle + $doodle = NULL; + } + + // output the doodle + $renderer->table_open(); + if ($title){ + $renderer->tablerow_open(); + $renderer->tableheader_open($c); + $renderer->doc .= $title; + $renderer->tableheader_close(); + $renderer->tablerow_close(); + } + $renderer->tablerow_open(); + $renderer->tableheader_open(); + $renderer->doc .= $lang['fullname']; + $renderer->tableheader_close(); + for ($i = 1; $i < $c; $i++){ + $renderer->tableheader_open(); + $renderer->doc .= $renderer->_xmlEntities($options[$i]); + $renderer->tableheader_close(); + } + $renderer->tablerow_close(); + + if ($submit = $_REQUEST[$dID.'-submit']){ + // user has just voted -> update results + $user = trim($_REQUEST['fullname']); + $user = str_replace('<', '<', $user); + $user = str_replace('>', '>', $user); + if (!empty($user)){ + for ($i = 1; $i < $c; $i++){ + $opt = md5($options[$i]); + $opt_old = $renderer->_xmlEntities($options[$i]); + if (isset($doodle[$user][$opt_old])) { + $doodle[$user][$opt_old] = false; + } + if ($_REQUEST[$dID.'-option'.$i]){ + $doodle[$user][$opt] = true; + } else { + $doodle[$user][$opt] = false; + } + } + $doodle[$user]['time']=time(); + } + $fh = fopen($dfile, 'w'); + fwrite($fh, serialize($doodle)); + fclose($fh); + } + + // display results + if (is_array($doodle)) $renderer->doc .= $this->_doodleResults($doodle, $options); + // display entry form + if ($disable=="") { + $renderer->doc .= $this->_doodleForm($c, $dID, $doodle, $options, $login, $single); + } + $renderer->table_close(); + return true; + } + + return false; + } + + function _doodleResults($doodle, $options){ + $cuser = count($doodle); + if ($cuser < 1) return ''; + $copt = count($options)-1; + $users = array_keys($doodle); + $ret = ''; + $count = array(); + + // table okay / not okay + for ($i = 0; $i < $cuser; $i++){ + $isChecked = 0; + $user = $users[$i]; + $updTime = isset($doodle[$user]['time'])?date('Y-m-d H:i:s', $doodle[$user]['time']):'Okey'; + $retTmp = ''.$user.''; + for ($j = 1; $j < $copt; $j++){ + $option = md5($options[$j]); + $option_old = $options[$j]; + if ($doodle[$user][$option] || $doodle[$user][$option_old]){ + $class = 'okay'; + $title = ''.$updTime.''; + $count[$option] += 1; + $isChecked = 1; + } elseif (!isset($doodle[$user][$option]) && !isset($doodle[$user][$option_old])){ + $class = 'centeralign'; + $title = ' '; + } else { + $class = 'notokay'; + $title = ' '; + } + $retTmp .= ''.$title.''; + } + $retTmp .= ''; + $ret .= ($isChecked==1)?$retTmp:""; + } + + // total count + $ret .= ' '; + for ($j = 1; $j < $copt; $j++){ + $option = md5($options[$j]); + $ret .= ''.$count[$option].''; + } + $ret .= ''; + + return $ret; + } + + function _doodleForm($n, $dID, $doodle, $options, $login, $single){ + global $lang; + global $ID; + global $INFO; + + $user = ($_SERVER['REMOTE_USER'] ? $INFO['userinfo']['name'] : ''); + $count = array(); + + $ret = '
'. + ''. + ''; + if ($login=="") { + $ret .= ''; + } + else { + if ($user=="") { + return ""; + } + $ret .= ''.''.$user.''; + } + $i = 1; + while ($i < $n){ + if (is_array($doodle)){ + $option = md5($options[$i]); + $option_old = $options[$j]; + if ($doodle[$user][$option] || $doodle[$user][$option_old]){ + $checked = 'checked="checked" '; + } else { + $checked = ' '; + } + } else { + $checked = ' '; + } + $onclickstr = ""; + if ($single!="") { + $onclickstr = 'onclick="javascript:'; + for ($j=1;$j<$n;$j++) { + if ($j!=$i) { + $onclickstr .= 'form[\''.$dID.'-option'.$j.'\'].checked=false;'; + } + } + $onclickstr .= '"'; + } + $ret.= ''; + $i++; + } + $ret .= ''. + ''. + '
'; + + return $ret; + } +} + +?>