[Home]WikiPatches/SaveAndEditButton

UseModWiki | WikiPatches | RecentChanges | Preferences

With this option appears a button in edit mode in order to permit save and continue editing, See in action on PmWiki, for example.

The Patch

Sub DoEdit {
...
   my ($id, $isConflict, $oldTime, $newText, $preview) = @_;
   my ($header, $editRows, $editCols, $userName, $revision, $oldText);
   my ($summary, $isEdit, $pageTime);
+  my ($saveEdit);
+  
+  $saveEdit = &GetParam("saveEdit", "");
   if ($FreeLinks) {
     $id = &FreeToNormal($id);  # Take care of users like Markus Lude :-)
   }
...
     print T($EditNote) . '<br>';  # Allow translation
   }
   print $q->submit(-name=>'Save', -value=>T('Save')), "\n";
+  print ''.$q->submit(-name=>'saveEdit', -value=>T('SaveEdit')), "\n";
   $userName = &GetParam("username", "");
   if ($userName ne "") {
     print ' (', T('Your user name is'), ' ',
...
           &GetTextArea('newtext', $newText, $editRows, $editCols),
           "<p>\n";
   }
-  if ($preview) {
+  if ($preview && !$saveEdit ) {
     print '<div class=wikipreview>';
     print "<hr class=wikilinepreview>\n";
     print "<h2>", T('Preview:'), "</h2>\n";
    if ($isConflict) {
      print "<b>",
            T('NOTE: This preview shows the revision of the other author.'),
            "</b><hr>\n";
    }
+  }
+  if ($preview && !$saveEdit ) {
     $MainPage = $id;
     $MainPage =~ s|/.*||;  # Only the main page name (remove subpage)
     print &WikiToHTML($oldText) . "<hr class=wikilinepreview>\n";
     print "<h2>", T('Preview only, not yet saved'), "</h2>\n";
     print '</div>';
   }
   print $q->endform;
   if (!&GetParam('embed', $EmbedWiki)) {
     print '<div class=wikifooter>';

sub DoPost {
...
   my $summary = &GetParam("summary", "");
   my $oldtime = &GetParam("oldtime", "");
   my $oldconflict = &GetParam("oldconflict", "");
+  my $saveEdit = &GetParam("saveEdit", "");
   my $isEdit = 0;
   my $editTime = $Now;
   my $authorAddr = $ENV{REMOTE_ADDR};
...
   $pgtime = $Section{'ts'};
   $preview = 0;
   $preview = 1  if (&GetParam("Preview", "") ne "");
-  if (!$preview && ($old eq $string)) {  # No changes (ok for preview)
+  if (!$preview && ($old eq $string) && (!$saveEdit)) {  # No changes (ok for preview)
     &ReleaseLock();
     &ReBrowsePage($id, "", 1);
+    return;
+  }
+  if (!$preview && ($old eq $string) && ($saveEdit) ) {
+    &ReleaseLock();  
+    &DoEdit($id, 0, $pgtime, $string, 1);
     return;
   }
   if (($UserID > 399) || ($Section{'id'} > 399))  {
...
     unlink($IndexFile);  # Regenerate index on next request
   }
   &ReleaseLock();
-  &ReBrowsePage($id, "", 1);
+  if ($saveEdit) {
+    &SavePage();
+    &DoEdit($id, 0, $pgtime, $string, 1);
+    return;
+  } else {
+    &ReBrowsePage($id, "", 1);
+  }
 }

--JuanmaMP


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited August 7, 2009 9:40 pm by JuanmaMP (diff)
Search: