Пример #1
0
 /**
  * Constructor.
  *
  * Computes diff between sequences of strings.
  *
  * This can be used to compute things like
  * case-insensitve diffs, or diffs which ignore
  * changes in white-space.
  *
  * @param $from_lines array An array of strings.
  *	(Typically these are lines from a file.)
  *
  * @param $to_lines array An array of strings.
  *
  * @param $mapped_from_lines array This array should
  *	have the same size number of elements as $from_lines.
  *	The elements in $mapped_from_lines and
  *	$mapped_to_lines are what is actually compared
  *	when computing the diff.
  *
  * @param $mapped_to_lines array This array should
  *	have the same number of elements as $to_lines.
  */
 public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines)
 {
     assert(sizeof($from_lines) == sizeof($mapped_from_lines));
     assert(sizeof($to_lines) == sizeof($mapped_to_lines));
     parent::__construct($mapped_from_lines, $mapped_to_lines);
     $xi = $yi = 0;
     for ($i = 0; $i < sizeof($this->edits); $i++) {
         $orig =& $this->edits[$i]->orig;
         if (is_array($orig)) {
             $orig = array_slice($from_lines, $xi, sizeof($orig));
             $xi += sizeof($orig);
         }
         $closing =& $this->edits[$i]->closing;
         if (is_array($closing)) {
             $closing = array_slice($to_lines, $yi, sizeof($closing));
             $yi += sizeof($closing);
         }
     }
 }
Пример #2
0
    $aText = $aLang == "en" ? "Archived page:" : "Page archivée :";
    $html .= "<dl><dt>{$aText}</dt>";
    if (is_array($archive)) {
        $html .= "\n<dd>";
        $html .= sprintf(gettext("Version %s"), $archive['version']);
        $html .= "\n</dd><dd>";
        $aText = $aLang == "en" ? "Last modified on %s" : "Dernière modification : %s";
        $html .= sprintf($aText, date($datetimeformat, $archive['lastmodified']));
        $html .= "\n</dd><dd>";
        $aText = $aLang == "en" ? "By %s" : "Par %s";
        $html .= sprintf($aText, $archive['author']);
        $html .= "</dd>";
    } else {
        $html .= "<dd><em>";
        $html .= $aLang == "en" ? "None" : "Aucune";
        $html .= "</em></dd>";
    }
    $html .= "</dl></div>\n";
    if (is_array($wiki) && is_array($archive)) {
        $diff = new WikiDiff($archive['content'], $wiki['content']);
        if ($diff->isEmpty()) {
            $aText = $aLang == "en" ? "Versions are identical" : "Les versions sont identiques";
            $html .= '<hr>[' . $aText . ']';
        } else {
            //$fmt = new WikiDiffFormatter;
            $fmt = new WikiUnifiedDiffFormatter();
            $html .= $fmt->format($diff, $archive['content']);
        }
    }
    GeneratePage('MESSAGE2', $html, sprintf("Diff %s", htmlspecialchars($pagename)), 0);
}
Пример #3
0
function diff2($page1, $page2)
{
    $page1 = split("\n", $page1);
    $page2 = split("\n", $page2);
    $z = new WikiDiff($page1, $page2);
    if ($z->isEmpty()) {
        $html = '<hr><br />[' . tra("Versions are identical") . ']<br /><br />';
    } else {
        //$fmt = new WikiDiffFormatter;
        $fmt = new WikiUnifiedDiffFormatter();
        $html = $fmt->format($z, $page1);
    }
    return $html;
}
Пример #4
0
 function action()
 {
     switch ($_REQUEST['page_op']) {
         case 'edit':
             $template['TITLE'] = dgettext('wiki', 'Edit') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->edit();
             break;
         case 'save':
             $template['TITLE'] = dgettext('wiki', 'Edit') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->post();
             break;
         case 'delete':
             $template['TITLE'] = dgettext('wiki', 'Delete') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->kill();
             break;
         case 'raw':
             Header('Content-type: text/plain');
             echo $this->getPagetext(FALSE);
             exit;
             break;
         case 'print':
             Layout::nakedDisplay($this->view());
             break;
         case 'history':
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $this->history();
             break;
         case 'viewold':
             PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
             $oldpage = new OldWikiPage($_REQUEST['id']);
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $oldpage->view();
             break;
         case 'restore':
             PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
             $oldpage = new OldWikiPage($_REQUEST['id']);
             $oldpage->restore($this->hits);
             /* Does not return */
             break;
         case 'removeold':
             PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
             $oldpage = new OldWikiPage($_REQUEST['id']);
             $oldpage->remove();
             /* Does not return */
             break;
         case 'compare':
             PHPWS_Core::initModClass('wiki', 'WikiDiff.php');
             $wikiDiff = new WikiDiff(PHPWS_Settings::get('wiki', 'diff_type'));
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $wikiDiff->diff($_REQUEST['oVer'], $_REQUEST['nVer']);
             break;
         case 'whatlinkshere':
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $this->whatLinksHere();
             break;
         case 'move':
             $template['TITLE'] = dgettext('wiki', 'Move') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->move();
             break;
         case 'do_move':
             /* Function never returns: user will be redirected to new page. */
             $this->doMove();
             break;
         case 'discussion':
             $template['TITLE'] = $this->getTitle() . ' ' . dgettext('wiki', 'Discussion');
             $template['CONTENT'] = $this->discussion();
             break;
         case 'togglelock':
             $this->toggleLock();
             PHPWS_Core::goBack();
             break;
         default:
             $this->incHits();
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $this->view();
             $template['CATEGORIES'] = $this->getCategories();
     }
     Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
 }