当前位置: 首页>>代码示例>>PHP>>正文


PHP Text_Diff_Renderer_inline类代码示例

本文整理汇总了PHP中Text_Diff_Renderer_inline的典型用法代码示例。如果您正苦于以下问题:PHP Text_Diff_Renderer_inline类的具体用法?PHP Text_Diff_Renderer_inline怎么用?PHP Text_Diff_Renderer_inline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Text_Diff_Renderer_inline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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&amp;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('&amp;', '&', $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 . ', &nbsp;&nbsp;&nbsp; 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']) ? ';&nbsp;&nbsp;&nbsp;&nbsp;span=' . $v['span'] . ',' : '') . '&nbsp;&nbsp;&nbsp;&nbsp;triggered=' . ($reload == true ? 'force' : 'auto') . ',&nbsp;&nbsp;</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


注:本文中的Text_Diff_Renderer_inline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。