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


PHP Diff::stringDiff方法代码示例

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


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

示例1: saveTextRevision

 public function saveTextRevision($moduleId, $moduleContentTypeId, $moduleContentId, $oldText, $newText, $textfieldIndex = 0, $revision = 0)
 {
     global $dbi, $login, $settings;
     if (!$settings->enableRevisioning) {
         return;
     }
     // Get latest revision number and increment
     $maxRevision = 0;
     if (empty($revision)) {
         $result = $dbi->query("SELECT MAX(revision) FROM " . revisionTableName . " WHERE moduleId=" . $dbi->quote($moduleId) . " AND moduleContentTypeId=" . $dbi->quote($moduleContentTypeId) . " AND moduleContentId=" . $dbi->quote($moduleContentId));
         if ($result->rows()) {
             list($maxRevision) = $result->fetchrow_array();
             $maxRevision++;
         }
     } else {
         $maxRevision = $revision;
     }
     // Parse text strings
     $newText = parseString($newText);
     $oldText = parseString($oldText);
     // Calculate diff
     $diff = new Diff();
     $result = $diff->stringDiff($newText, $oldText, " ");
     $changes = $diff->sequentialChanges($result);
     if (sizeof($changes) > 0) {
         $serializedChanges = serialize($changes);
         // Insert diff
         $dbi->query("INSERT INTO " . revisionTableName . "(moduleId,moduleContentTypeId,moduleContentId,textfieldIndex,diff,revision,userId,timestamp) VALUES(" . $dbi->quote($moduleId) . "," . $dbi->quote($moduleContentTypeId) . "," . $dbi->quote($moduleContentId) . "," . $dbi->quote($textfieldIndex) . "," . $dbi->quote($serializedChanges) . "," . $dbi->quote($maxRevision) . "," . $dbi->quote($login->id) . ",NOW())");
     }
     return $maxRevision;
 }
开发者ID:gkathir15,项目名称:catmis,代码行数:31,代码来源:Revision.class.php

示例2: array

    $first_retweet[$text] = array_search(array_search($short_text, $retweets_short), $tweets);
}
$first_retweet_ids = array_values($first_retweet);
sort($first_retweet_ids);
$first_tweet = $tweets[$first_retweet_ids[0]];
$first_tweet_short = $retweets_short[$first_tweet];
// calculate levenshtein and diff for first occurences of modified text of retweet
$levenshtein = $diffs = array();
foreach ($first_retweet as $text => $id) {
    if (empty($levenshtein)) {
        $levenshtein[$first_tweet_short] = 0;
        $diffs[$retweets_short[$text]] = $retweets_short[$text];
    } else {
        $levenshtein[$retweets_short[$text]] = levenshtein($first_tweet_short, $retweets_short[$text]);
        $diffClass = new Diff();
        $diffs[$retweets_short[$text]] = $diffClass->renderDiff($diffClass->stringDiff($first_tweet_short, $retweets_short[$text]));
    }
}
echo "<Br>Zoom: <span id='zoomin' class='zoom'>in</span> / <span id='zoomout' class='zoom'>out</span><Br>";
echo '<fieldset class="if_parameters">';
echo '<legend>Retweet URLs</legend>';
print "<div id='content'>";
//$palette = array("108cbf", "f62221", "008027", "97c932", "fad40d", "f8962b", "c99997", "7e7e7e", "cbcbcb", "44bdec", "ff6364", "42c168", "bced5e"); // issue crawler
//$palette = array_reverse($palette);
$palette = array("#90C4A7", "#EDA391", "#DEE287", "#DAC0D8", "#E0B97B", "#D6D0AA", "#A9DFDE", "#A2D093", "#D4D5CC", "#BABD7B", "#D6B4A2", "#E8ABBC", "#B0C1D0", "#D9EFAC", "#B6EECA");
asort($first_retweet);
$distinct_retweets = count($indentation);
print "<table cellspacing='0' cellpadding='0'>";
// header row
print "<tr><td>date</td><td>user</td><td>source</td><td class='seperator'>tweet</td>";
foreach ($first_retweet_ids as $id) {
开发者ID:jlorberkasunic,项目名称:dmi-tcat,代码行数:31,代码来源:mod.retweet_urls.php


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