1<?php
2  /**
3   * This is the HTML template for the doodle table.
4   *
5   * I am utilizing the PHP parser as a templating engine:
6   * doodle_tempalte.php is simply included and evaled from syntax.php
7   * The variable  $template   will be inherited from syntax.php and can be used here.
8   */
9  global $ID;
10
11  $template = $this->template;
12  $c = count($template['choices']);
13  $c1 = count($template['doodleData']);
14?>
15
16<!-- Doodle Plugin -->
17<div class="doodle4_scrollcontainer">
18<form action="<?php echo wl() ?>" method="post" name="doodle__form" id="<?php echo $template['formId'] ?>" accept-charset="utf-8" >
19
20<input type="hidden" name="sectok" value="<?php echo getSecurityToken() ?>" />
21<input type="hidden" name="do" value="show" >
22<input type="hidden" name="id" value="<?php echo $ID ?>" >
23<input type="hidden" name="formId" value="<?php echo $template['formId'] ?>" >
24<input type="hidden" name="edit__entry"   value="">
25<input type="hidden" name="delete__entry" value="">
26
27<?php
28//check UserList vertical or horizontal
29if ($template['userlist'] == 'vertical'){
30//vertical
31?>
32
33 <table class="inline">
34   <tbody>
35     <tr class="row0">
36       <th class="centeralign" colspan="<?php echo ($c+1) ?>">
37         <?php echo $template['title'] ?>
38       </th>
39     </tr>
40     <tr class="row1">
41         <th class="col0"><?php echo $lang['fullname'] ?></th>
42<?php foreach ($template['choices'] as $choice) {  ?>
43         <td class="centeralign" style="width:<?php echo $template['fieldwidth'] ?>"><?php echo $choice ?></td>
44<?php } ?>
45     </tr>
46
47<?php foreach ($template['doodleData'] as $fullname => $userData) { ?>
48     <tr>
49         <td class="rightalign">
50           <?php
51		if ($template['printName'] == 'both'){
52			echo $userData['editLinks'].$fullname.' ('.$userData['username'].')';
53		} elseif ($template['printName'] == 'fullname'){
54			 echo $userData['editLinks'].$fullname;
55		}elseif ($template['printName'] == 'username'){
56			echo $userData['editLinks'].$userData['username'];
57		}
58	?>
59         </td>
60         <?php for ($col = 0; $col < $c; $col++) {
61             echo $userData['choice'][$col];
62         } ?>
63     </tr>
64<?php } ?>
65
66<!-- Results / sum per column -->
67	 <?php
68		if ($template['showSum']){
69				echo ' <th class="rightalign"><b>';
70				echo $template['result'];
71				echo '</b></th>';
72				for ($col = 0; $col < $c; $col++) {
73					echo '<th class="centeralign"><b>';
74					echo $template['count'][$col];
75					echo '</b></th>';
76				}
77		}
78	 ?>
79
80<?php
81     /* Input fields, if allowed. */
82 	echo $template['inputTR']
83?>
84
85<?php if (!empty($template['msg'])) { ?>
86     <tr>
87       <td colspan="<?php echo $c+1 ?>">
88         <?php echo $template['msg'] ?>
89       </td>
90     </tr>
91<?php } ?>
92
93   </tbody>
94 </table>
95
96<?php
97}
98else
99{
100
101//horizontal
102/* Input fields, if allowed. */
103$trArray = preg_split('[<tr>]', $template['inputTR']);
104foreach ($trArray as $tr){
105	$trA = $trA . $tr;
106}
107$trArray = preg_split('[</td>]', $trA);
108$i1 = 0;
109$trArrayUser = array();
110foreach ($trArray as $tr){
111	$trArrayUser[$i1] = $tr . '</td>';;
112	$i1 = $i1 + 1;;
113}
114$trArray = preg_split('[</TD>]', $trArrayUser[1]);
115$i1 = 0;
116$trArrayCheck = array();
117foreach ($trArray as $tr){
118	$trArrayCheck[$i1] = $tr . '</td>';
119	$i1 = $i1 + 1;
120}
121 ?>
122 <table class="inline">
123   <tbody>
124     <tr class="row0">
125       <th class="centeralign" colspan="<?php echo ($c1+3) ?>">
126         <?php echo $template['title'] ?>
127       </th>
128     </tr>
129
130     <tr class="row1">
131	 <!--edit lang for first column-->
132         <th class="col0"><?php echo '' ?>
133		 </th>
134          <?php $durchlauf = 1; $userZahl = 0; $checkbox = 0;
135          foreach ($template['choices'] as $choice) {
136	         if($durchlauf == 1){
137                foreach ($template['doodleData'] as $fullname => $userData) { ?>
138                 <td class="centeralign" style="width:<?php echo $template['fieldwidth'] ?>">
139
140
141                 <?php
142		if ($template['printName'] == 'both'){
143			echo $userData['editLinks'].$fullname.' ('.$userData['username'].')';
144		} elseif ($template['printName'] == 'fullname'){
145			 echo $userData['editLinks'].$fullname;
146		}elseif ($template['printName'] == 'username'){
147			echo $userData['editLinks'].$userData['username'];
148		}
149		?>
150
151
152
153
154
155	     </td>
156 <?php
157		            for ($col = 0; $col < $c; $col++) {
158                     $userAuswahl[$userZahl][$col] = $userData['choice'][$col];
159                    }
160		        $userZahl++;
161		        }
162	            $userZahl = 0;
163				//Username for Vote
164	            echo $trArrayUser[0];
165               // Results
166		        if ($template['showSum']){
167				  echo ' <th class="rightalign"><b>';
168				  echo $template['result'];
169				  echo '</b></th>';
170		       }
171		   }
172 ?>
173	 </tr>
174        <?php
175        $durchlauf = 2;
176	    if($durchlauf > 1){?>
177	<tr>
178	    <td class="rightalign" ><?php echo $choice ?>
179		</td>
180	  <?php for ($col = 0; $col < $c1 ; $col++) {
181			 //Userchoices
182             echo $userAuswahl[$col][$userZahl];
183            }
184		    //User Input if allowed
185		    echo $trArrayCheck[$checkbox];
186		    // Results / sum per row -->
187		    if ($template['showSum']){
188
189					echo '<th class="centeralign"><b>';
190					echo $template['count'][$checkbox];
191					echo '</b></th>';
192		    }
193		    $checkbox = $checkbox + 1;
194		      ?>
195    </tr>
196 <?php  }
197        $userZahl++;
198      }?>
199<?php
200     /* Input fields, if allowed. */
201 //	Vote Button
202 echo $trArrayCheck[count($trArrayCheck) -1];
203?>
204<?php if (!empty($template['msg'])) { ?>
205     <tr>
206       <td colspan="<?php echo $c+1 ?>">
207         <?php echo $template['msg'] ?>
208       </td>
209     </tr>
210<?php } ?>
211   </tbody>
212 </table>
213
214<?php
215}
216?>
217
218</form>
219</div>
220