• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP TableDiffFormatter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了TableDiffFormatter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: showDiffs

function showDiffs($a, $b)
{
    $ota = explode("\n", str_replace("\r\n", "\n", $a));
    $nta = explode("\n", str_replace("\r\n", "\n", $b));
    $diffs = new Diff($ota, $nta);
    $formatter = new TableDiffFormatter();
    $funky = $formatter->format($diffs);
    preg_match_all('/<span class="diffchange">(.*?)<\\/span>/', $funky, $matches);
    foreach ($matches[1] as $bit) {
        $hex = bin2hex($bit);
        echo "\t{$hex}\n";
    }
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:13,代码来源:RandomTest.php


示例2: test_white_between_words

    function test_white_between_words()
    {
        // From FS#2161
        global $lang;
        $df = new Diff(explode("\n", "example"), explode("\n", "example example2"));
        $idf = new InlineDiffFormatter();
        $tdf = new TableDiffFormatter();
        $this->assertEqual($idf->format($df), '<tr><td colspan="4" class="diff-blockheader">@@ ' . $lang['line'] . ' -1 +1 @@&nbsp;<span class="diff-deletedline"><del>' . $lang['deleted'] . '</del></span>&nbsp;<span class="diff-addedline">' . $lang['created'] . '</span></td></tr>

<tr><td colspan="4">example&nbsp;<span class="diff-addedline">example2</span></td></tr>
');
        $this->assertEqual($tdf->format($df), '<tr><td class="diff-blockheader" colspan="2">' . $lang['line'] . ' 1:</td>
<td class="diff-blockheader" colspan="2">' . $lang['line'] . ' 1:</td>
</tr>
<tr><td>-</td><td class="diff-deletedline">example</td><td>+</td><td class="diff-addedline">example&nbsp;<strong>example2</strong></td></tr>
');
    }
开发者ID:hlxlplxl,项目名称:dokuwiki,代码行数:17,代码来源:DifferenceEngine.test.php


示例3: show_texts_diff

function show_texts_diff($text1, $text2, $display_line_numbers = false)
{
    if (is_null($text1)) {
        $text1 = '';
    }
    if (is_null($text2)) {
        $text2 = '';
    }
    if ($text1 == $text2 || !is_scalar($text1) || !is_scalar($text2)) {
        // arguments are not scalars or are identical => do nothing
        return '';
    }
    $lines1 = explode("\n", $text1);
    $lines2 = explode("\n", $text2);
    $diffs = new Diff($lines1, $lines2);
    $formatter = new TableDiffFormatter($display_line_numbers);
    return $formatter->format($diffs);
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:18,代码来源:DiffHelper.php


示例4: html_diff


//.........这里部分代码省略.........
            $l_rev = $rev1;
        } else {
            // no revision was given, compare previous to current
            $r_rev = '';
            $revs = getRevisions($ID, 0, 1);
            $l_rev = $revs[0];
        }
        // when both revisions are empty then the page was created just now
        if (!$l_rev && !$r_rev) {
            $l_text = '';
        } else {
            $l_text = rawWiki($ID, $l_rev);
        }
        $r_text = rawWiki($ID, $r_rev);
        if (!$l_rev) {
            $l_head = '&mdash;';
        } else {
            $l_info = getRevisionInfo($ID, $l_rev, true);
            if ($l_info['user']) {
                $l_user = editorinfo($l_info['user']);
                if (auth_ismanager()) {
                    $l_user .= ' (' . $l_info['ip'] . ')';
                }
            } else {
                $l_user = $l_info['ip'];
            }
            $l_user = '<span class="user">' . $l_user . '</span>';
            $l_sum = $l_info['sum'] ? '<span class="sum">' . hsc($l_info['sum']) . '</span>' : '';
            if ($l_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
                $l_minor = 'class="minor"';
            }
            $l_head = '<a class="wikilink1" href="' . wl($ID, "rev={$l_rev}") . '">' . $ID . ' [' . strftime($conf['dformat'], $l_rev) . ']</a>' . '<br />' . $l_user . ' ' . $l_sum;
        }
        if ($r_rev) {
            $r_info = getRevisionInfo($ID, $r_rev, true);
            if ($r_info['user']) {
                $r_user = editorinfo($r_info['user']);
                if (auth_ismanager()) {
                    $r_user .= ' (' . $r_info['ip'] . ')';
                }
            } else {
                $r_user = $r_info['ip'];
            }
            $r_user = '<span class="user">' . $r_user . '</span>';
            $r_sum = $r_info['sum'] ? '<span class="sum">' . hsc($r_info['sum']) . '</span>' : '';
            if ($r_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
                $r_minor = 'class="minor"';
            }
            $r_head = '<a class="wikilink1" href="' . wl($ID, "rev={$r_rev}") . '">' . $ID . ' [' . strftime($conf['dformat'], $r_rev) . ']</a>' . '<br />' . $r_user . ' ' . $r_sum;
        } elseif ($_rev = @filemtime(wikiFN($ID))) {
            $_info = getRevisionInfo($ID, $_rev, true);
            if ($_info['user']) {
                $_user = editorinfo($_info['user']);
                if (auth_ismanager()) {
                    $_user .= ' (' . $_info['ip'] . ')';
                }
            } else {
                $_user = $_info['ip'];
            }
            $_user = '<span class="user">' . $_user . '</span>';
            $_sum = $_info['sum'] ? '<span class="sum">' . hsc($_info['sum']) . '</span>' : '';
            if ($_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
                $r_minor = 'class="minor"';
            }
            $r_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' [' . strftime($conf['dformat'], $_rev) . ']</a> ' . '(' . $lang['current'] . ')' . '<br />' . $_user . ' ' . $_sum;
        } else {
            $r_head = '&mdash; (' . $lang['current'] . ')';
        }
    }
    $df = new Diff(explode("\n", htmlspecialchars($l_text)), explode("\n", htmlspecialchars($r_text)));
    $tdf = new TableDiffFormatter();
    if ($intro) {
        print p_locale_xhtml('diff');
    }
    ?>
    <table class="diff">
      <tr>
        <th colspan="2" <?php 
    echo $l_minor;
    ?>
>
          <?php 
    echo $l_head;
    ?>
        </th>
        <th colspan="2" <?php 
    echo $r_minor;
    ?>
>
          <?php 
    echo $r_head;
    ?>
        </th>
      </tr>
      <?php 
    echo $tdf->format($df);
    ?>
    </table>
  <?php 
}
开发者ID:jalemanyf,项目名称:wsnlocalizationscala,代码行数:101,代码来源:html.php


示例5: html_diff

/**
 * show diff
 *
 * @author Andreas Gohr <[email protected]>
 * Modified by Brandon Zehm, pulled from dokuwiki.
 * Requires DifferenceEngine.php from dokuwiki.
 *
 * Input: two strings
 * Output: html
 */
function html_diff($old, $new, $oldname = '', $newname = '', $stdout = 1)
{
    global $conf;
    $html = '';
    if (!($old and $new)) {
        return 'ERROR => Insufficient parameters passed to html_diff()!';
    }
    // Load diff code
    require_once $conf['inc_diff'];
    $df = new Diff(explode("\n", htmlspecialchars($old)), explode("\n", htmlspecialchars($new)));
    $tdf = new TableDiffFormatter();
    $html .= <<<EOL

    <table class="diff" width="100%">
        <tr>
          <td colspan="2" width="50%" class="diff-header">
            {$oldname}
          </td>
          <td colspan="2" width="50%" class="diff-header">
            {$newname}
          </td>
        </tr>
EOL;
    $html .= $tdf->format($df) . "</table>";
    if ($stdout) {
        echo $html;
    } else {
        return $html;
    }
}
开发者ID:edt82,项目名称:ona,代码行数:40,代码来源:functions_general.inc.php


示例6: format_differences

 /**
  * Return an HTML table allowing to display differences between two texts, the same way MediaWiki does
  *
  * @param string $value1
  * @param string $value2
  * @param array $table_options attributes to add on the <table> tag
  */
 function format_differences($value1, $value2, $table_options = array())
 {
     if (!is_array($value1)) {
         $value1 = explode("\r\n", $value1);
     }
     if (!is_array($value2)) {
         $value2 = explode("\r\n", $value2);
     }
     require_once App::pluginPath('alaxos') . '/lib/DifferenceEngine.php';
     $formatter = new TableDiffFormatter();
     $formatter->line_name = __d('alaxos', 'line', true);
     $table_rows = $formatter->format(new Diff($value1, $value2));
     if (!empty($table_rows)) {
         return $this->Html->tag('table', $table_rows, $table_options);
     } else {
         return null;
     }
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:25,代码来源:alaxos_html.php


示例7: textDiff

 /**
  * Generates diff, to be wrapped internally in a logging/instrumentation
  *
  * @param string $otext Old text, must be already segmented
  * @param string $ntext New text, must be already segmented
  * @return bool|string
  */
 protected function textDiff($otext, $ntext)
 {
     global $wgExternalDiffEngine, $wgContLang;
     $otext = str_replace("\r\n", "\n", $otext);
     $ntext = str_replace("\r\n", "\n", $ntext);
     if ($wgExternalDiffEngine == 'wikidiff' || $wgExternalDiffEngine == 'wikidiff3') {
         wfDeprecated("\$wgExternalDiffEngine = '{$wgExternalDiffEngine}'", '1.27');
         $wgExternalDiffEngine = false;
     }
     if ($wgExternalDiffEngine == 'wikidiff2') {
         if (function_exists('wikidiff2_do_diff')) {
             # Better external diff engine, the 2 may some day be dropped
             # This one does the escaping and segmenting itself
             $text = wikidiff2_do_diff($otext, $ntext, 2);
             $text .= $this->debug('wikidiff2');
             return $text;
         }
     } elseif ($wgExternalDiffEngine !== false) {
         # Diff via the shell
         $tmpDir = wfTempDir();
         $tempName1 = tempnam($tmpDir, 'diff_');
         $tempName2 = tempnam($tmpDir, 'diff_');
         $tempFile1 = fopen($tempName1, "w");
         if (!$tempFile1) {
             return false;
         }
         $tempFile2 = fopen($tempName2, "w");
         if (!$tempFile2) {
             return false;
         }
         fwrite($tempFile1, $otext);
         fwrite($tempFile2, $ntext);
         fclose($tempFile1);
         fclose($tempFile2);
         $cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
         $difftext = wfShellExec($cmd);
         $difftext .= $this->debug("external {$wgExternalDiffEngine}");
         unlink($tempName1);
         unlink($tempName2);
         return $difftext;
     }
     # Native PHP diff
     $ota = explode("\n", $wgContLang->segmentForDiff($otext));
     $nta = explode("\n", $wgContLang->segmentForDiff($ntext));
     $diffs = new Diff($ota, $nta);
     $formatter = new TableDiffFormatter();
     $difftext = $wgContLang->unsegmentForDiff($formatter->format($diffs));
     return $difftext;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:56,代码来源:DifferenceEngine.php


示例8: compareTask

 /**
  * Compare two versions of a wiki page
  *
  * @return     void
  */
 public function compareTask()
 {
     include_once dirname(dirname(__DIR__)) . DS . 'helpers' . DS . 'differenceengine.php';
     $this->view->page = $this->page;
     $this->view->config = $this->config;
     $this->view->base_path = $this->_base_path;
     $this->view->sub = $this->_sub;
     // Incoming
     $oldid = Request::getInt('oldid', 0);
     $diff = Request::getInt('diff', 0);
     // Do some error checking
     if (!$diff) {
         $this->setError(Lang::txt('COM_WIKI_ERROR_MISSING_VERSION'));
         $this->displayTask();
         return;
     }
     if ($diff == $oldid) {
         $this->setError(Lang::txt('COM_WIKI_ERROR_SAME_VERSIONS'));
         $this->displayTask();
         return;
     }
     // If no initial page is given, compare to the current revision
     $this->view->revision = $this->page->revision('current');
     $this->view->or = $this->page->revision($oldid);
     $this->view->dr = $this->page->revision($diff);
     // Diff the two versions
     $ota = explode("\n", $this->view->or->get('pagetext'));
     $nta = explode("\n", $this->view->dr->get('pagetext'));
     //$diffs = new Diff($ota, $nta);
     $formatter = new \TableDiffFormatter();
     $this->view->content = $formatter->format(new \Diff($ota, $nta));
     // Prep the pagename for display
     // e.g. "MainPage" becomes "Main Page"
     $this->view->title = $this->page->get('title');
     // Set the page's <title> tag
     Document::setTitle(Lang::txt(strtoupper($this->_option)) . ': ' . $this->view->title . ': ' . Lang::txt(strtoupper($this->_option . '_' . $this->_task)));
     // Set the pathway
     if (Pathway::count() <= 0) {
         Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option);
     }
     Pathway::append($this->view->title, $this->page->link());
     Pathway::append(Lang::txt(strtoupper($this->_option . '_' . $this->_task)), $this->page->link() . '&' . ($this->_sub ? 'action' : 'task') . '=' . $this->_task);
     $this->view->sub = $this->_sub;
     $this->view->message = $this->_message;
     $this->view->name = Lang::txt(strtoupper($this->_option));
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->display();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:55,代码来源:history.php


示例9: html_diff

/**
 * show diff
 *
 * @author Andreas Gohr <[email protected]>
 * @param  string $text - compare with this text with most current version
 * @param  bool   $intr - display the intro text
 */
function html_diff($text = '', $intro = true, $type = null)
{
    global $ID;
    global $REV;
    global $lang;
    global $conf;
    if (!$type) {
        $type = $_REQUEST['difftype'];
    }
    if ($type != 'inline') {
        $type = 'sidebyside';
    }
    // we're trying to be clever here, revisions to compare can be either
    // given as rev and rev2 parameters, with rev2 being optional. Or in an
    // array in rev2.
    $rev1 = $REV;
    if (is_array($_REQUEST['rev2'])) {
        $rev1 = (int) $_REQUEST['rev2'][0];
        $rev2 = (int) $_REQUEST['rev2'][1];
        if (!$rev1) {
            $rev1 = $rev2;
            unset($rev2);
        }
    } else {
        $rev2 = (int) $_REQUEST['rev2'];
    }
    $r_minor = '';
    $l_minor = '';
    if ($text) {
        // compare text to the most current revision
        $l_rev = '';
        $l_text = rawWiki($ID, '');
        $l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . dformat((int) @filemtime(wikiFN($ID))) . '</a> ' . $lang['current'];
        $r_rev = '';
        $r_text = cleanText($text);
        $r_head = $lang['yours'];
    } else {
        if ($rev1 && $rev2) {
            // two specific revisions wanted
            // make sure order is correct (older on the left)
            if ($rev1 < $rev2) {
                $l_rev = $rev1;
                $r_rev = $rev2;
            } else {
                $l_rev = $rev2;
                $r_rev = $rev1;
            }
        } elseif ($rev1) {
            // single revision given, compare to current
            $r_rev = '';
            $l_rev = $rev1;
        } else {
            // no revision was given, compare previous to current
            $r_rev = '';
            $revs = getRevisions($ID, 0, 1);
            $l_rev = $revs[0];
            $REV = $l_rev;
            // store revision back in $REV
        }
        // when both revisions are empty then the page was created just now
        if (!$l_rev && !$r_rev) {
            $l_text = '';
        } else {
            $l_text = rawWiki($ID, $l_rev);
        }
        $r_text = rawWiki($ID, $r_rev);
        list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev);
    }
    $df = new Diff(explode("\n", htmlspecialchars($l_text)), explode("\n", htmlspecialchars($r_text)));
    if ($type == 'inline') {
        $tdf = new InlineDiffFormatter();
    } else {
        $tdf = new TableDiffFormatter();
    }
    if ($intro) {
        print p_locale_xhtml('diff');
    }
    if (!$text) {
        ptln('<div class="diffoptions">');
        $form = new Doku_Form(array('action' => wl()));
        $form->addHidden('id', $ID);
        $form->addHidden('rev2[0]', $l_rev);
        $form->addHidden('rev2[1]', $r_rev);
        $form->addHidden('do', 'diff');
        $form->addElement(form_makeListboxField('difftype', array('sidebyside' => $lang['diff_side'], 'inline' => $lang['diff_inline']), $type, $lang['diff_type'], '', '', array('class' => 'quickselect')));
        $form->addElement(form_makeButton('submit', 'diff', 'Go'));
        $form->printForm();
        $diffurl = wl($ID, array('do' => 'diff', 'rev2[0]' => $l_rev, 'rev2[1]' => $r_rev, 'difftype' => $type));
        ptln('<p><a class="wikilink1" href="' . $diffurl . '">' . $lang['difflink'] . '</a></p>');
        ptln('</div>');
    }
    ?>
    <table class="diff diff_<?php 
//.........这里部分代码省略.........
开发者ID:nefercheprure,项目名称:dokuwiki,代码行数:101,代码来源:html.php


示例10: generateDiffBody

 /**
  * Generate a diff, no caching
  * $otext and $ntext must be already segmented
  */
 function generateDiffBody($otext, $ntext)
 {
     global $wgExternalDiffEngine, $wgContLang;
     $fname = 'DifferenceEngine::generateDiffBody';
     $otext = str_replace("\r\n", "\n", $otext);
     $ntext = str_replace("\r\n", "\n", $ntext);
     if ($wgExternalDiffEngine == 'wikidiff') {
         # For historical reasons, external diff engine expects
         # input text to be HTML-escaped already
         $otext = htmlspecialchars($wgContLang->segmentForDiff($otext));
         $ntext = htmlspecialchars($wgContLang->segmentForDiff($ntext));
         if (!function_exists('wikidiff_do_diff')) {
             dl('php_wikidiff.so');
         }
         return $wgContLang->unsegementForDiff(wikidiff_do_diff($otext, $ntext, 2));
     }
     if ($wgExternalDiffEngine == 'wikidiff2') {
         # Better external diff engine, the 2 may some day be dropped
         # This one does the escaping and segmenting itself
         if (!function_exists('wikidiff2_do_diff')) {
             //wfProfileIn( "$fname-dl" );
             @dl('php_wikidiff2.so');
             //wfProfileOut( "$fname-dl" );
         }
         if (function_exists('wikidiff2_do_diff')) {
             //wfProfileIn( 'wikidiff2_do_diff' );
             $text = wikidiff2_do_diff($otext, $ntext, 2);
             //wfProfileOut( 'wikidiff2_do_diff' );
             return $text;
         }
     }
     if ($wgExternalDiffEngine !== false) {
         # Diff via the shell
         global $wgTmpDirectory;
         $tempName1 = tempnam($wgTmpDirectory, 'diff_');
         $tempName2 = tempnam($wgTmpDirectory, 'diff_');
         $tempFile1 = fopen($tempName1, "w");
         if (!$tempFile1) {
             //wfProfileOut( $fname );
             return false;
         }
         $tempFile2 = fopen($tempName2, "w");
         if (!$tempFile2) {
             //wfProfileOut( $fname );
             return false;
         }
         fwrite($tempFile1, $otext);
         fwrite($tempFile2, $ntext);
         fclose($tempFile1);
         fclose($tempFile2);
         $cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
         //wfProfileIn( "$fname-shellexec" );
         $difftext = wfShellExec($cmd);
         //wfProfileOut( "$fname-shellexec" );
         unlink($tempName1);
         unlink($tempName2);
         return $difftext;
     }
     # Native PHP diff
     $ota = explode("\n", $wgContLang->segmentForDiff($otext));
     $nta = explode("\n", $wgContLang->segmentForDiff($ntext));
     $diffs = new Diff($ota, $nta);
     $formatter = new TableDiffFormatter();
     return $wgContLang->unsegmentForDiff($formatter->format($diffs));
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:69,代码来源:class.WordLevelDiff.php


示例11: rss_buildItems

/**
 * Add recent changed pages to a feed object
 *
 * @author Andreas Gohr <[email protected]>
 * @param  object $rss - the FeedCreator Object
 * @param  array $data - the items to add
 * @param  array $opt  - the feed options
 */
function rss_buildItems(&$rss, &$data, $opt)
{
    global $conf;
    global $lang;
    global $auth;
    $eventData = array('rss' => &$rss, 'data' => &$data, 'opt' => &$opt);
    $event = new Doku_Event('FEED_DATA_PROCESS', $eventData);
    if ($event->advise_before(false)) {
        foreach ($data as $ditem) {
            if (!is_array($ditem)) {
                // not an array? then only a list of IDs was given
                $ditem = array('id' => $ditem);
            }
            $item = new FeedItem();
            $id = $ditem['id'];
            $meta = p_get_metadata($id);
            // add date
            if ($ditem['date']) {
                $date = $ditem['date'];
            } elseif ($meta['date']['modified']) {
                $date = $meta['date']['modified'];
            } else {
                $date = @filemtime(wikiFN($id));
            }
            if ($date) {
                $item->date = date('r', $date);
            }
            // add title
            if ($conf['useheading'] && $meta['title']) {
                $item->title = $meta['title'];
            } else {
                $item->title = $ditem['id'];
            }
            if ($conf['rss_show_summary'] && !empty($ditem['sum'])) {
                $item->title .= ' - ' . strip_tags($ditem['sum']);
            }
            // add item link
            switch ($opt['link_to']) {
                case 'page':
                    $item->link = wl($id, 'rev=' . $date, true, '&');
                    break;
                case 'rev':
                    $item->link = wl($id, 'do=revisions&rev=' . $date, true, '&');
                    break;
                case 'current':
                    $item->link = wl($id, '', true, '&');
                    break;
                case 'diff':
                default:
                    $item->link = wl($id, 'rev=' . $date . '&do=diff', true, '&');
            }
            // add item content
            switch ($opt['item_content']) {
                case 'diff':
                case 'htmldiff':
                    require_once DOKU_INC . 'inc/DifferenceEngine.php';
                    $revs = getRevisions($id, 0, 1);
                    $rev = $revs[0];
                    if ($rev) {
                        $df = new Diff(explode("\n", htmlspecialchars(rawWiki($id, $rev))), explode("\n", htmlspecialchars(rawWiki($id, ''))));
                    } else {
                        $df = new Diff(array(''), explode("\n", htmlspecialchars(rawWiki($id, ''))));
                    }
                    if ($opt['item_content'] == 'htmldiff') {
                        $tdf = new TableDiffFormatter();
                        $content = '<table>';
                        $content .= '<tr><th colspan="2" width="50%">' . $rev . '</th>';
                        $content .= '<th colspan="2" width="50%">' . $lang['current'] . '</th></tr>';
                        $content .= $tdf->format($df);
                        $content .= '</table>';
                    } else {
                        $udf = new UnifiedDiffFormatter();
                        $content = "<pre>\n" . $udf->format($df) . "\n</pre>";
                    }
                    break;
                case 'html':
                    $content = p_wiki_xhtml($id, $date, false);
                    // no TOC in feeds
                    $content = preg_replace('/(<!-- TOC START -->).*(<!-- TOC END -->)/s', '', $content);
                    // make URLs work when canonical is not set, regexp instead of rerendering!
                    if (!$conf['canonical']) {
                        $base = preg_quote(DOKU_REL, '/');
                        $content = preg_replace('/(<a href|<img src)="(' . $base . ')/s', '$1="' . DOKU_URL, $content);
                    }
                    break;
                case 'abstract':
                default:
                    $content = $meta['description']['abstract'];
            }
            $item->description = $content;
            //FIXME a plugin hook here could be senseful
            // add user
//.........这里部分代码省略.........
开发者ID:Harvie,项目名称:dokuwiki,代码行数:101,代码来源:feed.php


示例12: html_diff


//.........这里部分代码省略.........
            $l_rev = $rev1;
        } else {
            // no revision was given, compare previous to current
            $r_rev = '';
            $revs = $pagelog->getRevisions(0, 1);
            $l_rev = $revs[0];
            $REV = $l_rev;
            // store revision back in $REV
        }
        // when both revisions are empty then the page was created just now
        if (!$l_rev && !$r_rev) {
            $l_text = '';
        } else {
            $l_text = rawWiki($ID, $l_rev);
        }
        $r_text = rawWiki($ID, $r_rev);
        list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline');
    }
    /*
     * Build navigation
     */
    $l_nav = '';
    $r_nav = '';
    if (!$text) {
        list($l_nav, $r_nav) = html_diff_navigation($pagelog, $type, $l_rev, $r_rev);
    }
    /*
     * Create diff object and the formatter
     */
    $diff = new Diff(explode("\n", $l_text), explode("\n", $r_text));
    if ($type == 'inline') {
        $diffformatter = new InlineDiffFormatter();
    } else {
        $diffformatter = new TableDiffFormatter();
    }
    /*
     * Display intro
     */
    if ($intro) {
        print p_locale_xhtml('diff');
    }
    /*
     * Display type and exact reference
     */
    if (!$text) {
        ptln('<div class="diffoptions group">');
        $form = new Doku_Form(array('action' => wl()));
        $form->addHidden('id', $ID);
        $form->addHidden('rev2[0]', $l_rev);
        $form->addHidden('rev2[1]', $r_rev);
        $form->addHidden('do', 'diff');
        $form->addElement(form_makeListboxField('difftype', array('sidebyside' => $lang['diff_side'], 'inline' => $lang['diff_inline']), $type, $lang['diff_type'], '', '', array('class' => 'quickselect')));
        $form->addElement(form_makeButton('submit', 'diff', 'Go'));
        $form->printForm();
        ptln('<p>');
        // link to exactly this view FS#2835
        echo html_diff_navigationlink($type, 'difflink', $l_rev, $r_rev ? $r_rev : $INFO['currentrev']);
        ptln('</p>');
        ptln('</div>');
        // .diffoptions
    }
    /*
     * Display diff view table
     */
    ?>
    <div class="table">
开发者ID:evacomaroski,项目名称:dokuwiki,代码行数:67,代码来源:html.php


示例13: compare_diff

    function compare_diff($old, $cur, $titles = array())
    {
        $this->add_tag_head('compare_diff.css');
        include_once $this->root->mytrustdirpath . '/include/DifferenceEngine.php';
        $this->compare_diff_pre($old);
        $this->compare_diff_pre($cur);
        $df = new Diff($old, $cur);
        $tdf = new TableDiffFormatter();
        $html = $tdf->format($df);
        if ($titles) {
            $title = <<<EOD
<tr>
<th colspan="2">{$titles[0]}</th>
<th colspan="2">{$titles[1]}</th>
</tr>
EOD;
        } else {
            $title = '';
        }
        return <<<EOD
<table class="diff">
{$title}
{$html}
</table>
EOD;
    }
开发者ID:nouphet,项目名称:rata,代码行数:26,代码来源:xpwiki_func.php


示例14: param

     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('item');
     // Check permission:
     $current_User->check_perm('item_post!CURSTATUS', 'edit', true, $edited_Item);
     param('r1', 'integer', 0);
     $r2 = (int) param('r2', 'string', 0);
     $Revision_1 = $edited_Item->get_revision($r1);
     $Revision_2 = $edited_Item->get_revision($r2);
     load_class('_core/model/_diff.class.php', 'Diff');
     // Compare the titles of two revisions
     $revisions_difference_title = new Diff(explode("\n", $Revision_1->iver_title), explode("\n", $Revision_2->iver_title));
     $format = new TitleDiffFormatter();
     $revisions_difference_title = $format->format($revisions_difference_title);
     // Compare the contents of two revisions
     $revisions_difference_content = new Diff(explode("\n", $Revision_1->iver_content), explode("\n", $Revision_2->iver_content));
     $format = new TableDiffFormatter();
     $revisions_difference_content = $format->format($revisions_difference_content);
     break;
 case 'history_restore':
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('item');
     // Check permission:
     $current_User->check_perm('item_post!CURSTATUS', 'edit', true, $edited_Item);
     param('r', 'integer', 0);
     if ($r > 0) {
         // Update item only from revisions ($r == 0 for current version)
         $Revision = $edited_Item->get_revision($r);
         $edited_Item->set('status', $Revision->iver_status);
         $edited_Item->set('title', $Revision->iver_title);
         $edited_Item->set('content', $Revision->iver_content);
         if ($edited_Item->dbupdate()) {
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:31,代码来源:items.ctrl.php


示例15: textDiff

 /**
  * Generates diff, to be wrapped internally in a logging/instrumentation
  *
  * @param string $otext Old text, must be already segmented
  * @param string $ntext New text, must be already segmented
  * @return bool|string
  */
 protected function textDiff($otext, $ntext)
 {
     global $wgExternalDiffEngine, $wgContLang;
     $otext = str_replace("\r\n", "\n", $otext);
     $ntext = str_replace("\r\n", "\n", $ntext);
     if ($wgExternalDiffEngine == 'wikidiff' || $wgExternalDiffEngine == 'wikidiff3') {
         wfDeprecated("\$wgExternalDiffEngine = '{$wgExternalDiffEngine}'", '1.27');
         $wgExternalDiffEngine = false;
     } elseif ($wgExternalDiffEngine == 'wikidiff2') {
         // Same as above, but with no deprecation warnings
         $wgExternalDiffEngine = false;
     } elseif (!is_string($wgExternalDiffEngine) && $wgExternalDiffEngine !== false) {
         // And prevent people from shooting themselves in the foot...
         wfWarn('$wgExternalDiffEngine is set to a non-string value, forcing it to false');
         $wgExternalDiffEngine = false;
     }
     if (function_exists('wikidiff2_do_diff') && $wgExternalDiffEngine === false) {
         # Better external diff engine, the 2 may some day be dropped
         # This one does the escaping and segmenting itself
         $text = wikidiff2_do_diff($otext, $ntext, 2);
         $text .= $this->debug('wikidiff2');
         return $text;
     } elseif ($wgExternalDiffEngine !== false && is_executable($wgExternalDiffEngine)) {
         # Diff via the shell
         $tmpDir = wfTempDir();
         $tempName1 = tempnam($tmpDir, 'diff_');
         $tempName2 = tempnam($tmpDir, 'diff_');
         $tempFile1 = fopen($tempName1, "w");
         if (!$tempFile1) {
             return false;
         }
         $tempFile2 = fopen($tempName2, "w");
         if (!$tempFile2) {
             return false;
         }
         fwrite($tempFile1, $otext);
         fwrite($tempFile2, $ntext);
         fclose($tempFile1);
         fclose($tempFile2);
         $cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
         $difftext = wfShellExec($cmd);
         $difftext .= $this->debug("external {$wgExternalDiffEngine}");
         unlink($tempName1);
         unlink($tempName2);
         return $difftext;
     }
     # Native PHP diff
     $ota = explode("\n", $wgContLang->segmentForDiff($otext));
     $nta = explode("\n", $wgContLang->segmentForDiff($ntext));
     $diffs = new Diff($ota, $nta);
     $formatter = new TableDiffFormatter();
     $difftext = $wgContLang->unsegmentForDiff($formatter->format($diffs));
     return $difftext;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:61,代码来源:DifferenceEngine.php


示例16: getDiffTable

 /**
  * Get a diff table.
  *
  * @param string $origCode Original code
  * @param string $newCode New code
  * @param boolean $showAll Set true to show all lines | false to show only changed lines
  *
  * @return return_type
  */
 public function getDiffTable($origCode, $newCode, $showAll = true)
 {
     $codeOrig = explode("\n", htmlentities($origCode));
     $codeNew = explode("\n", htmlentities($newCode));
     ecrLoadHelper('DifferenceEngine');
     //--we are adding a blank line to the end.. this is somewhat 'required' by PHPdiff
     if ($codeOrig[count($codeOrig) - 1] != '') {
         $codeOrig[] = '';
     }
     if ($codeNew[count($codeNew) - 1] != '') {
         $codeNew[] = '';
     }
     $dwDiff = new Diff($codeOrig, $codeNew);
     $dwFormatter = new TableDiffFormatter();
     //-- Small hack to display the whole file - :|
     if ($showAll) {
         $dwFormatter->leading_context_lines = 99999;
         $dwFormatter->trailing_context_lines = 99999;
     }
     return $dwFormatter->format($dwDiff);
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:30,代码来源:languageconverter.php


示例17: processDiffSetting

 /**
  * Process a diff for one setting
  *
  * @param $name String: setting name
  * @patam $old Mixed: old value
  * @param $new Mixed: new value
  * @param $type String: setting type
  * @return String: XHTML
  */
 function processDiffSetting($name, $old, $new, $type)
 {
     $msg = $this->msg('configure-setting-' . $name);
     $rawVal = Xml::element('tt', null, "\${$name}");
     if ($msg->exists()) {
         $msgVal = $msg->parse() . " ({$rawVal})";
     } else {
         $msgVal = $rawVal;
     }
     $oldSet = $this->getSettingAsArray(WebConfiguration::filterVar($old), $name, $type);
     $newSet = $this->getSettingAsArray(WebConfiguration::filterVar($new), $name, $type);
     $diffs = new Diff($oldSet, $newSet);
     $formatter = new TableDiffFormatter();
     return "<tr><td class=\"diff-lineno configure-setting\" colspan=\"4\">{$msgVal}</td></tr>\n" . $formatter->format($diffs);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:24,代码来源:Configure.diff.php


示例18: outputDiffHtml

 private function outputDiffHtml($localXMLArray, $remoteXMLArray)
 {
     $diffObj = new Diff($localXMLArray, $remoteXMLArray);
     $dft = new TableDiffFormatter();
     return $dft->format($diffObj);
 }
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:6,代码来源:class_Monitor.php


示例19: explode

    $current = explode("\n", $pageVersion->content('raw'));
    $previousVersion = $pageVersion->get('version') - 1;
    if ($previousVersion == 0) {
        $previous = array();
    } else {
        $previous = $this->page->version($previousVersion);
        // make view OK with the LIMIT
        if (!empty($previous)) {
            $previous = explode("\n", $previous->content('raw'));
        }
    }
    // define function to format context's
    // basically make sure lines that are not different
    // are outputted as code not rendered html
    $contextFormatter = function ($context) {
        return htmlentities($context);
    };
    // out formatted diff table
    $formatter = new TableDiffFormatter();
    $diff = $formatter->format(new Diff($previous, $current), $contextFormatter);
    echo $diff;
    ?>
						</div>
					</div>
				<?php 
}
?>
			</div>
		</div>
	</div>
</section>
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:versions.php


示例20: _diff

 /**
  * show diff between the local and remote versions of the page
  */
 function _diff($id)
 {
     if (!$this->_connect()) {
         return false;
     }
     $no = $this->profno;
     $ok = $this->client->query('wiki.getPage', $id);
     if (!$ok) {
         echo $this->getLang('pullfail') . ' ' . hsc($id) . ' ';
         echo hsc($this->client->getErrorMessage());
         die;
     }
     $remote = $this->client->getResponse();
     $local = rawWiki($id);
     $df = new Diff(explode("\n", htmlspecialchars($local)), explode("\n", htmlspecialchars($remote)));
     $tdf = new TableDiffFormatter();
     echo '<table class="diff" 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP TablePress类代码示例发布时间:2022-05-23
下一篇:
PHP TableDataset类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap