From 37a1dc12655862a2f6e02b06145bd31a2f8b5489 Mon Sep 17 00:00:00 2001
From: michael <michael@content-space.de>
Date: Sun, 12 Oct 2008 22:11:22 +0200
Subject: [PATCH] Changed html_revisions() to use Doku_Form, FS#1064

html_revisions() uses Doku_Form now like html_recent(), the new event HTML_REVISIONSFORM_OUTPUT can be used to create action-plugins to customize the revisions-ouput like e.g. suggested in FS#1064.

darcs-hash:20081012201122-074e0-c965ada0cc5ff572cc905d5fc7152a94c93b2741.gz
---
 inc/html.php | 132 +++++++++++++++++++++++++++++++++------------------
 1 file changed, 86 insertions(+), 46 deletions(-)

diff --git a/inc/html.php b/inc/html.php
index f9c58c896..80cefd9b1 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -424,28 +424,48 @@ function html_revisions($first=0){
   $date = @strftime($conf['dformat'],$INFO['lastmod']);
 
   print p_locale_xhtml('revisions');
-  print '<form action="'.wl($ID).'" method="post" id="page__revisions">';
-  print '<ul>';
+
+  $form = new Doku_Form('page__revisions', wl($ID));
+  $form->addElement(form_makeOpenTag('ul'));
   if($INFO['exists'] && $first==0){
-    print (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
-    print '<div class="li">';
-    print '<input type="checkbox" name="rev2[]" value="current" /> ';
+    if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
+      $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
+    else
+      $form->addElement(form_makeOpenTag('li'));
+    $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
+    $form->addElement(form_makeTag('input', array(
+      'type' => 'checkbox',
+      'name' => 'rev2[]',
+      'value' => 'current')));
 
-    print $date;
+    $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
+    $form->addElement($date);
+    $form->addElement(form_makeCloseTag('span'));
 
-    print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> ';
+    $form->addElement(form_makeTag('img', array(
+      'src' =>  DOKU_BASE.'lib/images/blank.gif',
+      'width' => '15',
+      'height' => '11',
+      'alt'    => '')));
+
+    $form->addElement(form_makeOpenTag('a', array(
+      'class' => 'wikilink1',
+      'href'  => wl($ID))));
+    $form->addElement($ID);
+    $form->addElement(form_makeCloseTag('a'));
 
-    print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ';
+    $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
+    $form->addElement(' &ndash; ');
+    $form->addElement(htmlspecialchars($INFO['sum']));
+    $form->addElement(form_makeCloseTag('span'));
 
-    print ' &ndash; ';
-    print htmlspecialchars($INFO['sum']);
-    print ' <span class="user">';
-    print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor']);
-    print '</span> ';
+    $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
+    $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor']));
+    $form->addElement(form_makeCloseTag('span'));
 
-    print '('.$lang['current'].')';
-    print '</div>';
-    print '</li>';
+    $form->addElement('('.$lang['current'].')');
+    $form->addElement(form_makeCloseTag('div'));
+    $form->addElement(form_makeCloseTag('li'));
   }
 
   foreach($revisions as $rev){
@@ -453,49 +473,69 @@ function html_revisions($first=0){
     $info   = getRevisionInfo($ID,$rev,true);
     $exists = page_exists($ID,$rev);
 
-    print ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
-    print '<div class="li">';
+    if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
+      $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
+    else
+      $form->addElement(form_makeOpenTag('li'));
+    $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
     if($exists){
-      print '<input type="checkbox" name="rev2[]" value="'.$rev.'" /> ';
+      $form->addElement(form_makeTag('input', array(
+        'type' => 'checkbox',
+        'name' => 'rev2[]',
+        'value' => $rev)));
     }else{
-      print '<img src="'.DOKU_BASE.'lib/images/blank.gif" width="14" height="11" alt="" /> ';
+      $form->addElement(form_makeTag('img', array(
+        'src' => DOKU_BASE.'lib/images/blank.gif',
+        'width' => 14,
+        'height' => 11,
+        'alt' => '')));
     }
-    print $date;
+
+    $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
+    $form->addElement($date);
+    $form->addElement(form_makeCloseTag('span'));
 
     if($exists){
-      print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
-      $p = array();
-      $p['src']    = DOKU_BASE.'lib/images/diff.png';
-      $p['width']  = 15;
-      $p['height'] = 11;
-      $p['title']  = $lang['diff'];
-      $p['alt']    = $lang['diff'];
-      $att = buildAttributes($p);
-      print "<img $att />";
-      print '</a> ';
-
-      print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a>';
+      $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link')));
+      $form->addElement(form_makeTag('img', array(
+        'src'    => DOKU_BASE.'lib/images/diff.png',
+        'width'  => 15,
+        'height' => 11,
+        'title'  => $lang['diff'],
+        'alt'    => $lang['diff'])));
+      $form->addElement(form_makeCloseTag('a'));
+
+      $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1')));
+      $form->addElement($ID);
+      $form->addElement(form_makeCloseTag('a'));
     }else{
-      print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> ';
-      print $ID;
+      $form->addElement(form_makeTag('img', array(
+        'src' => DOKU_BASE.'lib/images/blank.gif',
+        'width' => '15',
+        'height' => '11',
+        'alt'   => '')));
+      $form->addElement($ID);
     }
 
-    print ' &ndash; ';
-    print htmlspecialchars($info['sum']);
-    print ' <span class="user">';
+    $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
+    $form->addElement(' &ndash; ');
+    $form->addElement(htmlspecialchars($info['sum']));
+    $form->addElement(form_makeCloseTag('span'));
+
+    $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
     if($info['user']){
-      print editorinfo($info['user']);
+      $form->addElement(editorinfo($info['user']));
     }else{
-      print $info['ip'];
+      $form->addElement($info['ip']);
     }
-    print '</span>';
+    $form->addElement(form_makeCloseTag('span'));
 
-    print '</div>';
-    print '</li>';
+    $form->addElement(form_makeCloseTag('div'));
+    $form->addElement(form_makeCloseTag('li'));
   }
-  print '</ul>';
-  print '<input name="do[diff]" type="submit" value="'.$lang['diff2'].'" class="button" />';
-  print '</form>';
+  $form->addElement(form_makeCloseTag('ul'));
+  $form->addElement(form_makeButton('submit', 'diff', $lang['diff2']));
+  html_form('revisions', $form);
 
   print '<div class="pagenav">';
   $last = $first + $conf['recent'];
-- 
GitLab