function _changed($orig, $closing)
 {
     wfProfileIn(__METHOD__);
     $diff = new WordLevelDiff($orig, $closing);
     $del = $diff->orig();
     $add = $diff->closing();
     # Notice that WordLevelDiff returns HTML-escaped output.
     # Hence, we will be calling addedLine/deletedLine without HTML-escaping.
     while ($line = array_shift($del)) {
         $aline = array_shift($add);
         echo '<tr>' . $this->deletedLine($line) . $this->addedLine($aline) . "</tr>\n";
     }
     foreach ($add as $line) {
         # If any leftovers
         echo '<tr>' . $this->emptyLine() . $this->addedLine($line) . "</tr>\n";
     }
     wfProfileOut(__METHOD__);
 }
Beispiel #2
0
 /**
  * Compares to revisions of the page
  *
  * @param	int		$a_left		Nr of first revision
  * @param	int		$a_right	Nr of second revision
  */
 function compareVersion($a_left, $a_right)
 {
     // get page objects
     include_once "./Services/COPage/classes/class.ilPageObjectFactory.php";
     $l_page = ilPageObjectFactory::getInstance($this->getParentType(), $this->getId(), $a_left);
     $r_page = ilPageObjectFactory::getInstance($this->getParentType(), $this->getId(), $a_right);
     $l_hashes = $l_page->getPageContentsHashes();
     $r_hashes = $r_page->getPageContentsHashes();
     // determine all deleted and changed page elements
     foreach ($l_hashes as $pc_id => $h) {
         if (!isset($r_hashes[$pc_id])) {
             $l_hashes[$pc_id]["change"] = "Deleted";
         } else {
             if ($l_hashes[$pc_id]["hash"] != $r_hashes[$pc_id]["hash"]) {
                 $l_hashes[$pc_id]["change"] = "Modified";
                 $r_hashes[$pc_id]["change"] = "Modified";
                 include_once "./Services/COPage/mediawikidiff/class.WordLevelDiff.php";
                 // if modified element is a paragraph, highlight changes
                 if ($l_hashes[$pc_id]["content"] != "" && $r_hashes[$pc_id]["content"] != "") {
                     $new_left = str_replace("\n", "<br />", $l_hashes[$pc_id]["content"]);
                     $new_right = str_replace("\n", "<br />", $r_hashes[$pc_id]["content"]);
                     $wldiff = new WordLevelDiff(array($new_left), array($new_right));
                     $new_left = $wldiff->orig();
                     $new_right = $wldiff->closing();
                     $l_page->setParagraphContent($l_hashes[$pc_id]["hier_id"], $new_left[0]);
                     $r_page->setParagraphContent($l_hashes[$pc_id]["hier_id"], $new_right[0]);
                 }
             }
         }
     }
     // determine all new paragraphs
     foreach ($r_hashes as $pc_id => $h) {
         if (!isset($l_hashes[$pc_id])) {
             $r_hashes[$pc_id]["change"] = "New";
         }
     }
     $l_page->addChangeDivClasses($l_hashes);
     $r_page->addChangeDivClasses($r_hashes);
     return array("l_page" => $l_page, "r_page" => $r_page, "l_changes" => $l_hashes, "r_changes" => $r_hashes);
 }
 public function _changed($orig, $closing)
 {
     $diff = new WordLevelDiff($orig, $closing);
     $del = $diff->orig();
     $add = $diff->closing();
     while ($line = array_shift($del)) {
         $aline = array_shift($add);
         print '<tr>' . $this->deletedLine($line) . $this->addedLine($aline) . "</tr>\n";
     }
     $this->_added($add);
     # If any leftovers
 }
Beispiel #4
0
 function _changed($orig, $closing)
 {
     $diff = new WordLevelDiff($orig, $closing);
     $del = $diff->orig();
     $add = $diff->closing();
     // Notice that WordLevelDiff returns HTML-escaped output.
     // Hence, we will be calling addedLine/deletedLine without HTML-escaping.
     while ($line = array_shift($del)) {
         $aline = array_shift($add);
         $this->rows[] = array_merge($this->deletedLine($line), isset($aline) ? $this->addedLine($aline) : $this->emptyLine());
     }
     foreach ($add as $line) {
         // If any leftovers
         $this->rows[] = array_merge($this->emptyLine(), $this->addedLine($line));
     }
 }
 /**
  * Writes the two sets of lines to the output buffer, each enclosed in <tr>.
  *
  * @param string[] $orig
  * @param string[] $closing
  */
 protected function changed($orig, $closing)
 {
     $diff = new WordLevelDiff($orig, $closing);
     $del = $diff->orig();
     $add = $diff->closing();
     # Notice that WordLevelDiff returns HTML-escaped output.
     # Hence, we will be calling addedLine/deletedLine without HTML-escaping.
     $ndel = count($del);
     $nadd = count($add);
     $n = max($ndel, $nadd);
     for ($i = 0; $i < $n; $i++) {
         $delLine = $i < $ndel ? $this->deletedLine($del[$i]) : $this->emptyLine();
         $addLine = $i < $nadd ? $this->addedLine($add[$i]) : $this->emptyLine();
         $this->writeOutput("<tr>{$delLine}{$addLine}</tr>\n");
     }
 }
Beispiel #6
0
 /**
  * Writes the two sets of lines to the output buffer, each enclosed in <tr>.
  *
  * @param string[] $orig
  * @param string[] $closing
  */
 protected function changed($orig, $closing)
 {
     $diff = new WordLevelDiff($orig, $closing);
     $del = $diff->orig();
     $add = $diff->closing();
     # Notice that WordLevelDiff returns HTML-escaped output.
     # Hence, we will be calling addedLine/deletedLine without HTML-escaping.
     $line = array_shift($del);
     while ($line) {
         $aline = array_shift($add);
         $this->writeOutput('<tr>' . $this->deletedLine($line) . $this->addedLine($aline) . "</tr>\n");
         $line = array_shift($del);
     }
     foreach ($add as $line) {
         # If any leftovers
         $this->writeOutput('<tr>' . $this->emptyLine() . $this->addedLine($line) . "</tr>\n");
     }
 }