本文整理汇总了PHP中Diff::sequentialChanges方法的典型用法代码示例。如果您正苦于以下问题:PHP Diff::sequentialChanges方法的具体用法?PHP Diff::sequentialChanges怎么用?PHP Diff::sequentialChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diff
的用法示例。
在下文中一共展示了Diff::sequentialChanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}