Beispiel #1
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $fromRevisionId = $pl->getParameterValue("from_revision_id");
     $toRevisionId = $pl->getParameterValue("to_revision_id");
     if ($fromRevisionId == $toRevisionId) {
         throw new ProcessException(_("What is the point in comparing the revision with itself? Please choose different revisions of the page."), "same_revision");
     }
     $fromRevision = DB_PageRevisionPeer::instance()->selectByPrimaryKey($fromRevisionId);
     $toRevision = DB_PageRevisionPeer::instance()->selectByPrimaryKey($toRevisionId);
     if ($fromRevision == null || $toRevision == null) {
         throw new ProcessException(_("Error selecting revisions to compare"), "no_revisions");
     }
     $fromMetadata = $fromRevision->getMetadata();
     $toMetadata = $toRevision->getMetadata();
     $changed = array();
     // compare titles and other things
     if ($fromMetadata->getTitle() !== $toMetadata->getTitle()) {
         $changed['title'] = true;
     }
     if ($fromMetadata->getUnixName() !== $toMetadata->getUnixName()) {
         $changed['unix_name'] = true;
     }
     if ($fromMetadata->getParentPageId() !== $toMetadata->getParentPageId()) {
         $changed['parent'] = true;
         if ($fromMetadata->getParentPageId()) {
             $fromParent = DB_PagePeer::instance()->selectByPrimaryKey($fromMetadata->getParentPageId())->getUnixName();
             $runData->contextAdd("fromParent", $fromParent);
         }
         if ($toMetadata->getParentPageId()) {
             $toParent = DB_PagePeer::instance()->selectByPrimaryKey($toMetadata->getParentPageId())->getUnixName();
             $runData->contextAdd("toParent", $toParent);
         }
     }
     //compare source now
     $fromPageSource = $fromRevision->getSourceText();
     $toPageSource = $toRevision->getSourceText();
     if ($fromPageSource !== $toPageSource) {
         $changed['source'] = true;
         // create page diff... wooo...
         $t1 = $fromPageSource;
         $t2 = $toPageSource;
         $inlineDiff = Wikidot_Util_Diff::generateInlineStringDiff($t1, $t2);
         $runData->contextAdd("inlineDiff", $inlineDiff);
     }
     $runData->contextAdd("fromPageSource", $fromPageSource);
     $runData->contextAdd("toPageSource", $toPageSource);
     $runData->contextAdd("fromRevision", $fromRevision);
     $runData->contextAdd("toRevision", $toRevision);
     $runData->contextAdd("fromMetadata", $fromMetadata);
     $runData->contextAdd("toMetadata", $toMetadata);
     $runData->contextAdd("changed", $changed);
 }
Beispiel #2
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $toPageSource = $pl->getParameterValue("source");
     $mode = $pl->getParameterValue("mode");
     $revisionId = $pl->getParameterValue("revision_id");
     $revision = DB_PageRevisionPeer::instance()->selectByPrimaryKey($revisionId);
     $fromPageSource = $revision->getSourceText();
     if ($mode == "section") {
         // compare only a fragment...
         $rangeStart = $pl->getParameterValue("range_start");
         $rangeEnd = $pl->getParameterValue("range_end");
         $s2 = explode("\n", $fromPageSource);
         $fromPageSource = implode("\n", array_slice($s2, $rangeStart, $rangeEnd - $rangeStart + 1));
     }
     // create page diff... wooo...
     $t1 = $fromPageSource;
     $t2 = $toPageSource;
     $inlineDiff = Wikidot_Util_Diff::generateInlineStringDiff($t1, $t2);
     $runData->contextAdd("diff", $inlineDiff);
 }