Benutzer-Werkzeuge

Webseiten-Werkzeuge

doodle:start

Doodle Plugin for DokuWiki

I've extended the Doodle-Pluging (http://www.dokuwiki.org/plugin:doodle) for Dokuwiki (http://www.dokuwiki.org).

Here is another patched version of the original Doodle-Plugin: http://www.dokuwiki.org/plugin:doodle2

Changes

  • German text: „Speichern“ („Save“) instead of „Abschicken“.
  • re-edit an existing entry just by clicking the name (it's a link know): the name and all previous saved options are copied in the edit-form

Screenshots / Demo

Download

Zip-File

Version: 21.7.2010: doodle-edit-20100721.zip

Diff

Version: 21.7.2010

diff -r -u ../doodle.ORIG/lang/de/lang.php doodle/lang/de/lang.php
--- ../doodle.ORIG/lang/de/lang.php     2008-08-26 21:06:32.000000000 +0200
+++ doodle/lang/de/lang.php     2010-07-21 14:18:41.000000000 +0200
@@ -1,6 +1,6 @@
 <?php
 
-$lang['btn_submit'] = 'Abschicken';
+$lang['btn_submit'] = 'Speichern';
 
 //Setup VIM: ex: et ts=4 enc=utf-8 :
 ?>
--- ../doodle.ORIG/syntax.php   2009-08-10 17:21:22.000000000 +0200
+++ doodle/syntax.php   2010-07-21 14:33:46.000000000 +0200
@@ -23,8 +23,8 @@
        return array(
                'author' => 'Jonathan Tsai',
                'email'  => 'tryweb@ichiayi.com',
-               'date'   => '2009/08/10',
-               'name'   => 'Doodle Plugin',
+               'date'   => '2010/07/21',
+               'name'   => 'Doodle Plugin, extended by http://strukturpunkt.de/doodle/start',
                'desc'   => 'helps to schedule meetings',
                'url'   => 'http://wiki.splitbrain.org/plugin:doodle',
        );
@@ -106,6 +106,19 @@
                        $doodle = NULL;
                }
                
+               // output the javascript functions
+               $renderer->doc .= '
+<script type="text/javascript">
+function setFullname(neu, magicnr, options) {
+  // (c) http://strukturpunkt.de/doodle/start
+  for (var i=0; i < options.length; i++) {
+    j=i+1;
+    document.getElementsByName(magicnr+"-option"+j)[0].checked=options[i];
+  }
+  document.getElementsByName("fullname")[0].value=neu;
+}
+</script>
+               ';
                // output the doodle
                $renderer->table_open();
                if ($title){
@@ -152,7 +165,7 @@
                }
 
                // display results
-               if (is_array($doodle)) $renderer->doc .= $this->_doodleResults($doodle, $options);
+               if (is_array($doodle)) $renderer->doc .= $this->_doodleResults($doodle, $options, $dID);
                        // display entry form
                        if ($disable=="") {
                                $renderer->doc .= $this->_doodleForm($c, $dID, $doodle, $options, $login, $single);
@@ -164,7 +177,7 @@
                return false;
        }
   
-  function _doodleResults($doodle, $options){
+  function _doodleResults($doodle, $options, $dID){
        $cuser = count($doodle);
        if ($cuser < 1) return '';
        $copt  = count($options)-1;
@@ -177,7 +190,20 @@
                $isChecked = 0;
                $user = $users[$i];
                $updTime = isset($doodle[$user]['time'])?date('Y-m-d H:i:s', $doodle[$user]['time']):'Okey';
-               $retTmp = '<tr><td class="rightalign">'.$user.'</td>';
+               // store old values and give it the javascript function as argument
+               $optarr = "[";
+               for ($j = 1; $j < $copt; $j++){
+                       $option = md5($options[$j]);
+                       $option_old = $options[$j];
+                       if ($doodle[$user][$option] || $doodle[$user][$option_old]){
+                               $optarr .= "1,";
+                       } else {
+                               $optarr .= "0,";
+                       }
+               }
+               $optarr = substr($optarr, 0, strlen($optarr)-1); // remove last ','
+               $optarr .= "]";
+               $retTmp = '<tr><td class="rightalign">'.'<a href="#" onclick="javascript:setFullname(\''.$user.'\',\''. $dID . '\', ' . $optarr . '); return false">'.$user.'</a>'.'</td>';
                for ($j = 1; $j < $copt; $j++){
                        $option = md5($options[$j]);
                        $option_old = $options[$j];

2. Diff (erlaube mehrere Doodles auf einer Seite, fullname eindeutig)

var/www/perlmongers.strukturpunkt.de/lib/plugins/doodle/syntax.php syntax.php  / 
--- /var/www/perlmongers.strukturpunkt.de/lib/plugins/doodle/syntax.php	2010-07-21 14:33:46.000000000 +0200
+++ syntax.php	2010-07-22 14:56:53.000000000 +0200
@@ -115,7 +115,7 @@
     j=i+1;
     document.getElementsByName(magicnr+"-option"+j)[0].checked=options[i];
   }
-  document.getElementsByName("fullname")[0].value=neu;
+  document.getElementsByName(magicnr+"-fullname")[0].value=neu;
 }
 </script>
 		';
@@ -141,7 +141,7 @@
 					
 		if ($submit = $_REQUEST[$dID.'-submit']){
 			// user has just voted -> update results
-			$user = trim($_REQUEST['fullname']);
+			$user = trim($_REQUEST[$dID.'-fullname']);
 			$user = str_replace('<', '&lt;', $user);
 			$user = str_replace('>', '&gt;', $user);
 			if (!empty($user)){
@@ -251,13 +251,13 @@
 		'<input type="hidden" name="do" value="show" />'.
 		'<input type="hidden" name="id" value="'.$ID.'" />';
 	if ($login=="") {
-		$ret .= '<td class="rightalign"><input type="text" name="fullname" '.'value="'.$user.'" /></td>';
+		$ret .= '<td class="rightalign"><input type="text" name="'.$dID.'-fullname" '.'value="'.$user.'" /></td>';
 	}
 	else {
 		if ($user=="") {
 			return "";
 		}
-		$ret .= '<input type="hidden" name="fullname" value="'.$user.'" />'.'<td class="rightalign">'.$user.'</td>';
+		$ret .= '<input type="hidden" name="'.$dID.'-fullname" value="'.$user.'" />'.'<td class="rightalign">'.$user.'</td>';
 	}
 	$i = 1;
 	while ($i < $n){
Permalink doodle/start.txt · Zuletzt geändert: 18.05.2011 07:47 von kfr

oeffentlich