本文整理汇总了PHP中Text_Diff_Renderer_inline类的典型用法代码示例。如果您正苦于以下问题:PHP Text_Diff_Renderer_inline类的具体用法?PHP Text_Diff_Renderer_inline怎么用?PHP Text_Diff_Renderer_inline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Text_Diff_Renderer_inline类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: inline_diff
function inline_diff($text1, $text2, $nl)
{
// create the hacked lines for each file
$htext1 = chunk_split($text1, 1, "\n");
$htext2 = chunk_split($text2, 1, "\n");
// convert the hacked texts to arrays
// if you have PHP5, you can use str_split:
/*
$hlines1 = str_split(htext1, 2);
$hlines2 = str_split(htext2, 2);
*/
// otherwise, use this code
$len1 = strlen($text1);
$len2 = strlen($text2);
for ($i = 0; $i < $len1; $i++) {
$hlines1[$i] = substr($htext1, $i * 2, 2);
}
for ($i = 0; $i < $len2; $i++) {
$hlines2[$i] = substr($htext2, $i * 2, 2);
}
/*
$text1 = str_replace("\n",$nl,$text1);
$text2 = str_replace("\n",$nl,$text2);
*/
$text1 = str_replace("\n", " \n", $text1);
$text2 = str_replace("\n", " \n", $text2);
$hlines1 = explode(" ", $text1);
$hlines2 = explode(" ", $text2);
// create the diff object
$diff = new Text_Diff($hlines1, $hlines2);
// get the diff in unified format
// you can add 4 other parameters, which will be the ins/del prefix/suffix tags
$renderer = new Text_Diff_Renderer_inline(50000);
return $renderer->render($diff);
}
开发者ID:yaoboqin,项目名称:fis3,代码行数:35,代码来源:inline_function.php
示例2: dodiff
function dodiff($cur, $prev)
{
$cur = str_replace("\r", '', $cur);
$prev = str_replace("\r", '', $prev);
$diff = new Text_Diff('native', array(explode("\n", $prev), explode("\n", $cur)));
$renderer = new Text_Diff_Renderer_inline();
$stuff = nl2br($renderer->render($diff));
return '<div style="font-family:\'Consolas\',\'Courier New\',monospace; border:1px dashed #ccc; padding: 1em;">' . $stuff . '</div>';
}
开发者ID:RoadrunnerWMC,项目名称:ABXD-plugins,代码行数:9,代码来源:page_wikidiff.php
示例3: execute
function execute($request)
{
parent::execute($request);
$cat_data = $this->currentCategoryObj->getData();
$breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
// get $history_profile from the id
$older_profile = pico_get_content_history_profile($this->mydirname, $request['older_history_id']);
if (empty($request['newer_history_id'])) {
$newer_profile = pico_get_content_history_profile($this->mydirname, 0, intval($older_profile[1]));
} else {
$newer_profile = pico_get_content_history_profile($this->mydirname, $request['newer_history_id']);
}
// check each content_ids
if ($older_profile[1] != $newer_profile[1]) {
die('Differenct content_ids each other');
}
$this->contentObj = new PicoContent($this->mydirname, $request['content_id'], $this->currentCategoryObj);
// add breadcrumbs if the content exists
if (!$this->contentObj->isError()) {
$content_data = $this->contentObj->getData();
$this->assign['content'] = $this->contentObj->getData4html();
$breadcrumbsObj->appendPath(XOOPS_URL . '/modules/' . $this->mydirname . '/' . $this->assign['content']['link'], $this->assign['content']['subject']);
$breadcrumbsObj->appendPath(XOOPS_URL . '/modules/' . $this->mydirname . '/index.php?page=contentmanager&content_id=' . $content_data['id'], _MD_PICO_CONTENTMANAGER);
}
// permission check by 'can_edit'
if (empty($cat_data['can_edit'])) {
redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_EDITCONTENT);
exit;
}
// get diff
$diff_from_file4disp = '';
$original_error_level = error_reporting();
error_reporting($original_error_level & ~E_NOTICE & ~E_WARNING);
$diff = new Text_Diff(explode("\n", $older_profile[2]), explode("\n", $newer_profile[2]));
//$renderer = new Text_Diff_Renderer_unified();
//$diff_str = htmlspecialchars( $renderer->render( $diff ) , ENT_QUOTES ) ;
$renderer = new Text_Diff_Renderer_inline();
$this->assign['diff_str'] = $renderer->render($diff);
error_reporting($original_error_level);
// breadcrumbs
$breadcrumbsObj->appendPath('', 'DIFF');
$this->assign['xoops_breadcrumbs'] = $breadcrumbsObj->getXoopsbreadcrumbs();
$this->assign['xoops_pagetitle'] = _MD_PICO_HISTORY;
// view
$this->view = $request['view'];
switch ($this->view) {
case 'diffhistories':
$this->template_name = $this->mydirname . '_main_diffhistories.html';
$this->is_need_header_footer = true;
break;
default:
$this->is_need_header_footer = false;
break;
}
}
开发者ID:nouphet,项目名称:rata,代码行数:55,代码来源:PicoControllerDiffHistories.class.php
示例4: render_diff
/**
* Render diffence between strings
*
* @param string $string_1
* @param string $string_2
* @return string
*/
function render_diff($string_1, $string_2)
{
require_once DIFF_LIB_PATH . '/Diff.php';
require_once DIFF_LIB_PATH . '/Diff/Renderer.php';
require_once DIFF_LIB_PATH . '/Diff/Renderer/inline.php';
$lines_1 = strpos($string_1, "\n") ? explode("\n", $string_1) : array($string_1);
$lines_2 = strpos($string_2, "\n") ? explode("\n", $string_2) : array($string_2);
$diff = new Text_Diff('auto', array($lines_1, $lines_2));
$renderer = new Text_Diff_Renderer_inline();
return $renderer->render($diff);
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:18,代码来源:init.php
示例5: compare
public static function compare($lines1, $lines2)
{
if (is_string($lines1)) {
$lines1 = explode("\n", $lines1);
}
if (is_string($lines2)) {
$lines2 = explode("\n", $lines2);
}
$diff = new Text_Diff('auto', array($lines1, $lines2));
$renderer = new Text_Diff_Renderer_inline();
return $renderer->render($diff);
}
开发者ID:noxt,项目名称:business-keeper,代码行数:12,代码来源:TextDiff.php
示例6: render_diff_text
function render_diff_text($new, $old)
{
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer/inline.php';
$diff = new Text_Diff('auto', array(split("\n", $old), split("\n", $new)));
$diff_renderer = new Text_Diff_Renderer_inline();
$diff_value = $diff_renderer->render($diff);
$form_renderer = AMP_get_renderer();
if (!$diff_value) {
$diff_value = htmlentities($new);
}
if (!$diff_value) {
return false;
}
return $form_renderer->div($form_renderer->tag('pre', $diff_value), array('class' => 'diff'));
}
开发者ID:radicalsuz,项目名称:amp,代码行数:16,代码来源:Form.php
示例7: createDiff
private function createDiff(&$old_article, &$new_article, &$result)
{
$old = "";
$new = "";
foreach ($old_article as $key => $value) {
if (isset($new_article[$key])) {
$v1 = preg_split("[\n\r]", $value);
$v2 = preg_split("[\n\r]", $new_article[$key]);
/* Create the Diff object. */
$diff = new Text_Diff($v1, $v2);
/* Output the diff in unified format.*/
$renderer = new Text_Diff_Renderer_inline();
$result[] = $renderer->render($diff);
}
}
}
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:16,代码来源:ActionArticleCreateDiff.php
示例8: textDiff
public function textDiff($lines1, $lines2)
{
require_once APP_PATH . 'core' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'Text' . DIRECTORY_SEPARATOR . 'Diff.php';
// require_once(APP_PATH.'core'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'Text'.DIRECTORY_SEPARATOR.'Diff'.DIRECTORY_SEPARATOR.'Renderer.php');
require_once APP_PATH . 'core' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'Text' . DIRECTORY_SEPARATOR . 'Diff' . DIRECTORY_SEPARATOR . 'Renderer' . DIRECTORY_SEPARATOR . 'unified.php';
require_once APP_PATH . 'core' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'Text' . DIRECTORY_SEPARATOR . 'Diff' . DIRECTORY_SEPARATOR . 'Renderer' . DIRECTORY_SEPARATOR . 'context.php';
require_once APP_PATH . 'core' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'Text' . DIRECTORY_SEPARATOR . 'Diff' . DIRECTORY_SEPARATOR . 'Renderer' . DIRECTORY_SEPARATOR . 'inline.php';
if (is_string($lines1)) {
$lines1 = explode("\n", $lines1);
}
if (is_string($lines2)) {
$lines2 = explode("\n", $lines2);
}
$diff = new \Text_Diff('auto', array($lines1, $lines2));
$renderer = new \Text_Diff_Renderer_inline();
return $renderer->render($diff);
}
开发者ID:seaice,项目名称:li,代码行数:17,代码来源:Generate.php
示例9: diff
function diff($f1, $f2)
{
require_once 'InlineDiff/diff.php';
require_once 'InlineDiff/renderer.php';
require_once 'InlineDiff/inline.php';
// Load the lines of each file.
$c1 = @file_get_contents($f1);
$c2 = @file_get_contents($f2);
$lines1 = empty($c1) ? array() : explode("\n", $c1);
$lines2 = empty($c2) ? array() : explode("\n", $c2);
$lines1 = $this->mapNewline($lines1);
$lines2 = $this->mapNewline($lines2);
// Create the Diff object.
$diff = new Text_Diff($lines1, $lines2);
$renderer = new Text_Diff_Renderer_inline();
global $plugin_ret_diff;
$plugin_ret_diff = "<pre id=\"diff\">" . $renderer->render($diff) . "</pre>";
return true;
}
开发者ID:pastak,项目名称:jichikai_web,代码行数:19,代码来源:wkp_InlineDiff.php
示例10: getTextDiff
function getTextDiff($method, $diff1, $diff2)
{
switch ($method) {
case 'unified':
require_once '/data/project/xtools/textdiff/textdiff/Diff/Renderer/unified.php';
$diff = new Text_Diff('auto', array(explode("\n", $diff1), explode("\n", $diff2)));
$renderer = new Text_Diff_Renderer_unified();
$diff = $renderer->render($diff);
break;
case 'inline':
require_once '/data/project/xtools/textdiff/textdiff/Diff/Renderer/inline.php';
$diff = new Text_Diff('auto', array(explode("\n", $diff1), explode("\n", $diff2)));
$renderer = new Text_Diff_Renderer_inline();
$diff = $renderer->render($diff);
break;
}
unset($renderer);
return $diff;
}
开发者ID:JackPotte,项目名称:xtools,代码行数:19,代码来源:textdiff.php
示例11: getDiffObject
public function getDiffObject($original)
{
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer/inline.php';
$diffObject = new SxCms_Page_Revision();
$renderer = new Text_Diff_Renderer_inline();
$titleDiff = new Text_Diff('auto', array(array($original->getTitle()), array($this->getTitle())));
$titleDiff = $renderer->render($titleDiff) ? $renderer->render($titleDiff) : array_pop($titleDiff->getOriginal());
$summaryDiff = new Text_Diff('auto', array(array($original->getSummary()), array($this->getSummary())));
$summaryDiff = $renderer->render($summaryDiff) ? $renderer->render($summaryDiff) : array_pop($summaryDiff->getOriginal());
$summaryDiff = html_entity_decode($summaryDiff);
$contentDiff = new Text_Diff('auto', array(array($original->getContent()), array($this->getContent())));
$contentDiff = $renderer->render($contentDiff) ? $renderer->render($contentDiff) : array_pop($contentDiff->getOriginal());
$contentDiff = html_entity_decode($contentDiff);
$sourceDiff = new Text_Diff('auto', array(array($original->getSource()), array($this->getSource())));
$sourceDiff = $renderer->render($sourceDiff) ? $renderer->render($sourceDiff) : array_pop($sourceDiff->getOriginal());
$linkDiff = new Text_Diff('auto', array(array($original->getLink()), array($this->getLink())));
$linkDiff = $renderer->render($linkDiff) ? $renderer->render($linkDiff) : array_pop($linkDiff->getOriginal());
$diffObject->setLanguage($this->getLanguage())->setTitle($titleDiff)->setSummary($summaryDiff)->setContent($contentDiff)->setSource($sourceDiff)->setLink($linkDiff)->setApproved($this->isApproved());
return $diffObject;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:21,代码来源:Revision.php
示例12: show_only_difference
public function show_only_difference()
{
$renderer = new Text_Diff_Renderer_inline();
$result = $renderer->render($this->text_diff);
$lignes = explode("\n", $result);
$del_continue = false;
$ins_continue = false;
$first_trois_points = true;
$next_points = "";
$buffer = array();
foreach ($lignes as $l) {
$l_inti = $l;
$return = "";
if ($del_continue) {
$return .= "<span class='diff_del'>";
}
if ($ins_continue) {
$return .= "<span class='diff_ins'>";
}
if (substr_count($l, '<del>') - substr_count($l, '</del>') > 0) {
$del_continue = true;
}
if (substr_count($l, '<del>') - substr_count($l, '</del>') < 0) {
$del_continue = false;
}
if (substr_count($l, '<ins>') - substr_count($l, '</ins>') > 0) {
$ins_continue = true;
}
if (substr_count($l, '<ins>') - substr_count($l, '</ins>') < 0) {
$ins_continue = false;
}
$l = str_replace("<del>", "<span class='diff_del'>", $l);
$l = str_replace("<ins>", "<span class='diff_ins'>", $l);
$l = str_replace("</ins>", "</span>", $l);
$l = str_replace("</del>", "</span>", $l);
$return .= $l;
if ($del_continue) {
$return .= "</span>";
}
if ($ins_continue) {
$return .= "</span>";
}
if ($l_inti != $return) {
$buffer[] = array(true, $return);
} else {
$buffer[] = array(false, $return);
}
}
$return = "<div class='diff_result'><ol class='numbering'>\n";
$troispoint = false;
for ($i = 0; $i < count($buffer); $i++) {
// If there is a modified line 3 before or 3 after this lines we print it ... other wise we print one sigle "..."
$n1 = max(0, $i - 1);
$n2 = max(0, $i - 2);
$n3 = max(0, $i - 3);
$n4 = $i;
$n5 = min(count($buffer) - 1, $i + 1);
$n6 = min(count($buffer) - 1, $i + 2);
$n7 = min(count($buffer) - 1, $i + 3);
if ($buffer[$n1][0] || $buffer[$n2][0] || $buffer[$n3][0] || $buffer[$n4][0] || $buffer[$n5][0] || $buffer[$n6][0] || $buffer[$n7][0]) {
$return .= $next_points;
$next_points = "";
$return .= "<li class='numbering_li' value='" . ($i + 1) . "'><pre> " . $buffer[$i][1] . "</pre></li>\n";
$troispoint = false;
} else {
if (!$troispoint) {
if ($first_trois_points) {
$return .= "</ol><pre> ...</pre>\n";
$next_points .= "<ol class='numbering'>\n";
$troispoint = true;
$first_trois_points = false;
} else {
$return .= "</ol><pre> ...</pre>\n";
$next_points .= "<hr class='diff_hr'/>\n";
$next_points .= "<pre> ...</pre>";
$next_points .= "<ol class='numbering'>\n";
$troispoint = true;
}
}
}
}
if ($next_points == "") {
$return .= "</ol></div>\n";
} else {
$return .= "</div>\n";
}
return $return;
}
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:88,代码来源:text_diff.class.php
示例13: explode
$from_lines = explode("\n", $from_page["data"][0]["data"]);
if (isset($_REQUEST["diff_to"]) && $_REQUEST["diff_to"] != $gContent->mInfo["version"]) {
$to_version = $_REQUEST["diff_to"];
$to_page = $gContent->getHistory($to_version);
$to_lines = explode("\n", $to_page["data"][0]["data"]);
} else {
$to_version = $gContent->mInfo["version"];
$to_lines = explode("\n", $gContent->mInfo["data"]);
}
/**
* run 'pear install Text_Diff' to install the library,
*/
if ($gBitSystem->isFeatureActive('liberty_inline_diff') && @(include_once 'Text/Diff.php')) {
include_once 'Text/Diff/Renderer/inline.php';
$diff = new Text_Diff($from_lines, $to_lines);
$renderer = new Text_Diff_Renderer_inline();
$html = $renderer->render($diff);
} else {
include_once UTIL_PKG_PATH . 'diff.php';
$diffx = new WikiDiff($from_lines, $to_lines);
$fmt = new WikiUnifiedDiffFormatter();
$html = $fmt->format($diffx, $from_lines);
}
$gBitSmarty->assign('diffdata', $html);
$gBitSmarty->assign('diff2', 'y');
$gBitSmarty->assign('version_from', $from_version);
$gBitSmarty->assign('version_to', $to_version);
} elseif (@BitBase::verifyId($_REQUEST["compare"])) {
$from_version = $_REQUEST["compare"];
$from_page = $gContent->getHistory($from_version);
$from_page['data'][0]['no_cache'] = TRUE;
开发者ID:kailIII,项目名称:liberty,代码行数:31,代码来源:content_history_inc.php
示例14: process
public static function process($url, $history_call = false, $refresh = false)
{
if (MODULE_TIMES) {
$time = microtime(true);
}
$url = str_replace('&', '&', $url);
//do we need this if we set arg_separator.output to &?
if ($url) {
$_POST = array();
parse_str($url, $_POST);
if (get_magic_quotes_gpc()) {
$_POST = undoMagicQuotes($_POST);
}
$_GET = $_REQUEST =& $_POST;
}
ModuleManager::load_modules();
self::check_firstrun();
if ($history_call === '0') {
History::clear();
} elseif ($history_call) {
History::set_id($history_call);
}
//on init call methods...
$ret = on_init(null, null, null, true);
foreach ($ret as $k) {
call_user_func_array($k['func'], $k['args']);
}
$root =& ModuleManager::create_root();
self::go($root);
//go somewhere else?
$loc = location(null, true);
//on exit call methods...
$ret = on_exit(null, null, null, true, $loc === false);
foreach ($ret as $k) {
call_user_func_array($k['func'], $k['args']);
}
if ($loc !== false) {
if (isset($_REQUEST['__action_module__'])) {
$loc['__action_module__'] = $_REQUEST['__action_module__'];
}
//clean up
foreach (self::$content as $k => $v) {
unset(self::$content[$k]);
}
foreach (self::$jses as $k => $v) {
if ($v[1]) {
unset(self::$jses[$k]);
}
}
//go
$loc['__location'] = microtime(true);
return self::process(http_build_query($loc), false, true);
}
$debug = '';
if (DEBUG && ($debug_diff = @(include_once 'tools/Diff.php'))) {
require_once 'tools/Text/Diff/Renderer/inline.php';
$diff_renderer = new Text_Diff_Renderer_inline();
}
//clean up old modules
if (isset($_SESSION['client']['__module_content__'])) {
$to_cleanup = array_keys($_SESSION['client']['__module_content__']);
foreach ($to_cleanup as $k) {
$mod = ModuleManager::get_instance($k);
if ($mod === null) {
$xx = explode('/', $k);
$yy = explode('|', $xx[count($xx) - 1]);
$mod = $yy[0];
if (is_callable(array($mod . 'Common', 'destroy'))) {
call_user_func(array($mod . 'Common', 'destroy'), $k, isset($_SESSION['client']['__module_vars__'][$k]) ? $_SESSION['client']['__module_vars__'][$k] : null);
}
if (DEBUG) {
$debug .= 'Clearing mod vars & module content ' . $k . '<br>';
}
unset($_SESSION['client']['__module_vars__'][$k]);
unset($_SESSION['client']['__module_content__'][$k]);
}
}
}
$reloaded = array();
foreach (self::$content as $k => $v) {
$reload = $v['module']->get_reload();
$parent = $v['module']->get_parent_path();
if (DEBUG && REDUCING_TRANSFER) {
$debug .= '<hr style="height: 3px; background-color:black">';
$debug .= '<b> Checking ' . $k . ', parent=' . $v['module']->get_parent_path() . '</b><ul>' . '<li>Force - ' . (isset($reload) ? print_r($reload, true) : 'not set') . '</li>' . '<li>First display - ' . (isset($_SESSION['client']['__module_content__'][$k]) ? 'no</li>' . '<li>Content changed - ' . ($_SESSION['client']['__module_content__'][$k]['value'] !== $v['value'] ? 'yes' : 'no') . '</li>' . '<li>JS changed - ' . ($_SESSION['client']['__module_content__'][$k]['js'] !== $v['js'] ? 'yes' : 'no') : 'yes') . '</li>' . '<li>Parent reloaded - ' . (isset($reloaded[$parent]) ? 'yes' : 'no') . '</li>' . '<li>History call - ' . ($history_call ? 'yes' : 'no') . '</li>' . '</ul>';
}
if (!REDUCING_TRANSFER || (!isset($reload) && (!isset($_SESSION['client']['__module_content__'][$k]) || $_SESSION['client']['__module_content__'][$k]['value'] !== $v['value'] || $_SESSION['client']['__module_content__'][$k]['js'] !== $v['js']) || $history_call || $reload == true || isset($reloaded[$parent]))) {
//force reload or parent reloaded
if (DEBUG && isset($_SESSION['client']['__module_content__'])) {
$debug .= '<b>Reloading: ' . (isset($v['span']) ? '; span=' . $v['span'] . ',' : '') . ' triggered=' . ($reload == true ? 'force' : 'auto') . ', </b><hr><b>New value:</b><br><pre>' . htmlspecialchars($v['value']) . '</pre>' . (isset($_SESSION['client']['__module_content__'][$k]['value']) ? '<hr><b>Old value:</b><br><pre>' . htmlspecialchars($_SESSION['client']['__module_content__'][$k]['value']) . '</pre>' : '');
if ($debug_diff && isset($_SESSION['client']['__module_content__'][$k]['value'])) {
$xxx = new Text_Diff(explode("\n", $_SESSION['client']['__module_content__'][$k]['value']), explode("\n", $v['value']));
$debug .= '<hr><b>Diff:</b><br><pre>' . $diff_renderer->render($xxx) . '</pre>';
}
$debug .= '<hr style="height: 5px; background-color:black">';
}
if (isset($v['span'])) {
self::text($v['value'], $v['span']);
}
if ($v['js']) {
//.........这里部分代码省略.........
开发者ID:cretzu89,项目名称:EPESI,代码行数:101,代码来源:epesi.php
示例15: log_diff
function log_diff($fromvalue,$tovalue)
{
# Forumlate descriptive text to describe the change made to a metadata field.
# Remove any database escaping
$fromvalue=str_replace("\\","",$fromvalue);
$tovalue=str_replace("\\","",$tovalue);
if (substr($fromvalue,0,1)==",")
{
# Work a different way for checkbox lists.
$fromvalue=explode(",",i18n_get_translated($fromvalue));
$tovalue=explode(",",i18n_get_translated($tovalue));
# Get diffs
$inserts=array_diff($tovalue,$fromvalue);
$deletes=array_diff($fromvalue,$tovalue);
# Process array diffs into meaningful strings.
$return="";
if (count($deletes)>0)
{
$return.="- " . join("\n- " , $deletes);
}
if (count($inserts)>0)
{
if ($return!="") {$return.="\n";}
$return.="+ " . join("\n+ ", $inserts);
}
#debug($return);
return $return;
}
# For standard strings, use Text_Diff
require_once dirname(__FILE__).'/../lib/Text_Diff/Diff.php';
require_once dirname(__FILE__).'/../lib/Text_Diff/Diff/Renderer/inline.php';
$lines1 = explode("\n",$fromvalue);
$lines2 = explode("\n",$tovalue);
$diff = new Text_Diff('native', array($lines1, $lines2));
$renderer = new Text_Diff_Renderer_inline();
$diff=$renderer->render($diff);
$return="";
# The inline diff syntax places inserts within <ins></ins> tags and deletes within <del></del> tags.
# Handle deletes
if (strpos($diff,"<del>")!==false)
{
$s=explode("<del>",$diff);
for ($n=1;$n<count($s);$n++)
{
$t=explode("</del>",$s[$n]);
if ($return!="") {$return.="\n";}
$return.="- " . trim(i18n_get_translated($t[0]));
}
}
# Handle inserts
if (strpos($diff,"<ins>")!==false)
{
$s=explode("<ins>",$diff);
for ($n=1;$n<count($s);$n++)
{
$t=explode("</ins>",$s[$n]);
if ($return!="") {$return.="\n";}
$return.="+ " . trim(i18n_get_translated($t[0]));
}
}
#debug ($return);
return $return;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:77,代码来源:resource_functions.php
示例16: fn_text_diff
function fn_text_diff($source, $dest, $side_by_side = false)
{
$diff = new Text_Diff('auto', array(explode("\n", $source), explode("\n", $dest)));
$renderer = new Text_Diff_Renderer_inline();
if ($side_by_side == false) {
$renderer->_split_level = 'words';
}
$res = $renderer->render($diff);
if ($side_by_side == true) {
$res = $renderer->sideBySide($res);
}
return $res;
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:13,代码来源:fn.common.php
示例17: getDiffs
/**
* Gets an HTML diff output between the records at $id1 and $id2
* respectively, where $id1 and $id2 are history ids from the history__id
* column of the history table.
* @param string $tablename The name of the base table.
* @param integer $id1 The id number of the first record (from the history__id column)
* @param integer $id2 The id of the second record (from the history__id column)
* @param string $fieldname Optional name of a field to return.
* @returns mixed Either the value of the specified field name if $fieldname is specified,
* or a Dataface_Record object whose field values are formatted diffs.
*/
function getDiffs($tablename, $id1, $id2 = null, $fieldname = null)
{
import('Text/Diff.php');
import('Text/Diff/Renderer/inline.php');
$htablename = $tablename . '__history';
if (!Dataface_Table::tableExists($htablename)) {
return PEAR::raiseError(df_translate('scripts.Dataface.HistoryTool.getDiffs.ERROR_HISTORY_TABLE_DOES_NOT_EXIST', "History table for '{$tablename}' does not exist, so we cannot obtain changes for records of that table.", array('tablename' => $tablename)), DATAFACE_E_ERROR);
}
$rec1 = df_get_record($htablename, array('history__id' => $id1));
if (!isset($id2)) {
// The 2nd id wasn't provided so we assume we want to know the diffs
// against the current state of the record.
$table =& Dataface_Table::loadTable($tablename);
$query = $rec1->strvals(array_keys($table->keys()));
$io = new Dataface_IO($tablename);
$io->lang = $rec1->val('history__language');
$rec2 = new Dataface_Record($tablename, array());
$io->read($query, $rec2);
} else {
$rec2 = df_get_record($htablename, array('history__id' => $id2));
}
$vals1 = $rec1->strvals();
$vals2 = $rec2->strvals();
$vals_diff = array();
$renderer = new Text_Diff_Renderer_inline();
foreach ($vals2 as $key => $val) {
$diff = new Text_Diff(explode("\n", @$vals1[$key]), explode("\n", $val));
$vals_diff[$key] = $renderer->render($diff);
}
$diff_rec = new Dataface_Record($htablename, $vals_diff);
if (isset($fieldname)) {
return $diff_rec->val($fieldname);
}
return $diff_rec;
}
开发者ID:minger11,项目名称:Pipeline,代码行数:46,代码来源:HistoryTool.php
示例18: compare
public function compare()
{
require_once APP_PATH . '/../Text/Diff.php';
require_once APP_PATH . '/../Text/Diff/Renderer.php';
require_once APP_PATH . '/../Text/Diff/Renderer/inline.php';
$page_id = I("page_id");
$history_id = I("page_history_id");
$diff_type = I("diff_type");
$page = D("Page")->where(" page_id = '{$page_id}' ")->find();
$history = D("PageHistory")->where(" page_history_id = '{$history_id}' ")->find();
$lines1 = htmlspecialchars_decode($page['page_content']);
$lines2 = htmlspecialchars_decode($history['page_content']);
is_string($lines1) && ($lines1 = explode("\n", $lines1));
is_string($lines2) && ($lines2 = explode("\n", $lines2));
$diff = new \Text_Diff('auto', array($lines2, $lines1));
$renderer = new \Text_Diff_Renderer_inline();
$diffResutl = $renderer->render($diff);
$this->assign("diffResutl", $diffResutl);
$this->assign("page_id", $page_id);
$this->assign("page_history_id", $history_id);
$this->assign("item_id", $page['item_id']);
$this->display();
}
开发者ID:fx408,项目名称:showdoc,代码行数:23,代码来源:PageController.class.php
示例19: executeDiff
public function executeDiff()
{
$this->setPage();
// $this->revision is revision2
$this->forward403Unless($this->canView);
$this->forward404If($this->page->isNew());
$this->forward404If($this->revision->isNew());
// Source revision
$c = new Criteria();
$c->add(nahoWikiRevisionPeer::PAGE_ID, $this->page->getId());
$c->add(nahoWikiRevisionPeer::REVISION, $this->getRequestParameter('oldRevision'));
$this->revision1 = nahoWikiRevisionPeer::doSelectOne($c);
$this->forward404Unless($this->revision1);
// Dest revision
$this->revision2 = $this->revision;
// Make diff
$lines1 = explode("\n", $this->revision1->getContent());
$lines2 = explode("\n", $this->revision2->getContent());
$diff = new Text_Diff('auto', array($lines1, $lines2));
switch ($this->getRequestParameter('mode', 'inline')) {
case 'unified':
$renderer = new Text_Diff_Renderer_unified();
break;
case 'context':
$renderer = new Text_Diff_Renderer_context();
break;
case 'inline':
default:
$renderer = new Text_Diff_Renderer_inline();
break;
}
$this->diff = $renderer->render($diff);
// Direct download
if ($this->getRequestParameter('raw')) {
$this->getResponse()->setContentType('text/plain');
$this->renderText($this->diff);
return sfView::NONE;
}
return sfView::SUCCESS;
}
开发者ID:sgrove,项目名称:cothinker,代码行数:40,代码来源:BasenahoWikiActions.class.php
示例20: getHistory
//.........这里部分代码省略.........
echo '<input name="new" value="' . $row['id'] . '" type="radio" ' . $newstyle . ' ' . $newchecked . '/> ';
echo '<a href="' . api_get_self() . '?action=showpage&title=' . api_htmlentities(urlencode($page)) . '&view=' . $row['id'] . '">';
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=showpage&title=' . api_htmlentities(urlencode($page)) . '&view=' . $row['id'] . '">';
echo api_get_local_time($row['dtime'], null, date_default_timezone_get());
echo '</a>';
echo ' (' . get_lang('Version') . ' ' . $row['version'] . ')';
echo ' ' . get_lang('By') . ' ';
if ($row['user_id'] != 0) {
echo UserManager::getUserProfileLink($userinfo);
} else {
echo get_lang('Anonymous') . ' (' . api_htmlentities($row['user_ip']) . ')';
}
echo ' ( ' . get_lang('Progress') . ': ' . api_htmlentities($row['progress']) . '%, ';
$comment = $row['comment'];
if (!empty($comment)) {
echo get_lang('Comments') . ': ' . api_htmlentities(api_substr($row['comment'], 0, 100));
if (api_strlen($row['comment']) > 100) {
echo '... ';
}
} else {
echo get_lang('Comments') . ': ---';
}
echo ' ) </li>';
$counter++;
}
//end while
echo '<br/>';
echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">' . get_lang('ShowDifferences') . ' ' . get_lang('LinesDiff') . '</button>';
echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">' . get_lang('ShowDifferences') . ' ' . get_lang('WordsDiff') . '</button>';
echo '</ul></form>';
} else {
// We show the differences between two versions
$version_old = array();
if (isset($_POST['old'])) {
$sql_old = "SELECT * FROM {$tbl_wiki}\n WHERE c_id = {$course_id} AND id='" . Database::escape_string($_POST['old']) . "'";
$result_old = Database::query($sql_old);
$version_old = Database::fetch_array($result_old);
}
$sql_new = "SELECT * FROM {$tbl_wiki}\n WHERE c_id = {$course_id} AND id='" . Database::escape_string($_POST['new']) . "'";
$result_new = Database::query($sql_new);
$version_new = Database::fetch_array($result_new);
$oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null;
$oldContent = isset($version_old['content']) ? $version_old['content'] : null;
if (isset($_POST['HistoryDifferences'])) {
include 'diff.inc.php';
//title
echo '<div id="wikititle">' . api_htmlentities($version_new['title']) . '
<font size="-2"><i>(' . get_lang('DifferencesNew') . '</i>
<font style="background-color:#aaaaaa">' . $version_new['dtime'] . '</font>
<i>' . get_lang('DifferencesOld') . '</i>
<font style="background-color:#aaaaaa">' . $oldTime . '</font>
) ' . get_lang('Legend') . ': <span class="diffAdded" >' . get_lang('WikiDiffAddedLine') . '</span>
<span class="diffDeleted" >' . get_lang('WikiDiffDeletedLine') . '</span> <span class="diffMoved">' . get_lang('WikiDiffMovedLine') . '</span></font>
</div>';
}
if (isset($_POST['HistoryDifferences2'])) {
//title
echo '<div id="wikititle">' . api_htmlentities($version_new['title']) . '
<font size="-2"><i>(' . get_lang('DifferencesNew') . '</i> <font style="background-color:#aaaaaa">' . $version_new['dtime'] . '</font>
<i>' . get_lang('DifferencesOld') . '</i> <font style="background-color:#aaaaaa">' . $oldTime . '</font>)
' . get_lang('Legend') . ': <span class="diffAddedTex" >' . get_lang('WikiDiffAddedTex') . '</span>
<span class="diffDeletedTex" >' . get_lang('WikiDiffDeletedTex') . '</span></font></div>';
}
if (isset($_POST['HistoryDifferences'])) {
echo '<table>' . diff($oldContent, $version_new['content'], true, 'format_table_line') . '</table>';
// format_line mode is better for words
echo '<br />';
echo '<strong>' . get_lang('Legend') . '</strong><div class="diff">' . "\n";
echo '<table><tr>';
echo '&
|
请发表评论