protected function _changed($orig, $final) { /* If we've already split on characters, just display. */ if ($this->_split_level == 'characters') { return $this->_deleted($orig) . $this->_added($final); } /* If we've already split on words, just display. */ if ($this->_split_level == 'words') { $prefix = ''; while ($orig[0] !== false && $final[0] !== false && substr($orig[0], 0, 1) == ' ' && substr($final[0], 0, 1) == ' ') { $prefix .= substr($orig[0], 0, 1); $orig[0] = substr($orig[0], 1); $final[0] = substr($final[0], 1); } return $prefix . $this->_deleted($orig) . $this->_added($final); } $text1 = implode("\n", $orig); $text2 = implode("\n", $final); /* Non-printing newline marker. */ $nl = ""; if ($this->_split_characters) { $diff = new Horde_Text_Diff('native', array(preg_split('//', $text1), preg_split('//', $text2))); } else { /* We want to split on word boundaries, but we need to preserve * whitespace as well. Therefore we split on words, but include * all blocks of whitespace in the wordlist. */ $diff = new Horde_Text_Diff('native', array($this->_splitOnWords($text1, $nl), $this->_splitOnWords($text2, $nl))); } /* Get the diff in inline format. */ $renderer = new Horde_Text_Diff_Renderer_inline(array_merge($this->getParams(), array('split_level' => $this->_split_characters ? 'characters' : 'words'))); /* Run the diff and get the output. */ return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; }
$article_edits = $db->fetch_array($edit_query); } if ($db->num_rows($query) == 0) { error($lang->invalid_article); } $article = $db->fetch_array($query); $wiki = $article; // this is for backwards compatibility if (isset($article_edits)) { $article['original'] = $article_edits['revision']; } require_once MYBB_ROOT . "inc/3rdparty/diff/Diff.php"; require_once MYBB_ROOT . "inc/3rdparty/diff/Diff/Renderer.php"; require_once MYBB_ROOT . "inc/3rdparty/diff/Diff/Renderer/Inline.php"; $diff = new Horde_Text_Diff('auto', array(array($article['original']), array($article['content']))); $renderer = new Horde_Text_Diff_Renderer_inline(); $diff_report = $renderer->render($diff); if ($article['original'] == $article['content']) { $diff_report = $lang->identical; } add_breadcrumb($lang->wiki_revisions, "wiki.php"); add_breadcrumb($article['title'], "wiki.php?action=diff&aid={$aid}"); eval("\$page = \"" . $templates->get("wiki_revision_article") . "\";"); output_page($page); } elseif ($mybb->input['action'] == 'contributors') { // Save resources... rather than possibly query the db in get_user, we grab all users, assign them // to an array,and go through that when we need to. Slightly inefficient for huge numbers of members // but when a new method comes about I will use that, $query = $db->write_query(sprintf("SELECT * FROM `%susers`", TABLE_PREFIX)); $users = array(); while ($row = $db->fetch_array($query)) {