當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Text_Diff::isEmpty方法代碼示例

本文整理匯總了PHP中Text_Diff::isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:PHP Text_Diff::isEmpty方法的具體用法?PHP Text_Diff::isEmpty怎麽用?PHP Text_Diff::isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Text_Diff的用法示例。


在下文中一共展示了Text_Diff::isEmpty方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: diffChar

function diffChar($orig, $final, $words = 0, $function = 'character')
{
    if ($words) {
        preg_match_all("/\\w+\\s+(?=\\w)|\\w+|\\W/", implode("<br />", $orig), $matches);
        $line1 = $matches[0];
        preg_match_all("/\\w+\\s+(?=\\w)|\\w+|\\W/", implode("<br />", $final), $matches);
        $line2 = $matches[0];
    } else {
        $line1 = preg_split('//', implode("<br />", $orig), -1, PREG_SPLIT_NO_EMPTY);
        $line2 = preg_split('//', implode("<br />", $final), -1, PREG_SPLIT_NO_EMPTY);
    }
    $z = new Text_Diff($line1, $line2);
    if ($z->isEmpty()) {
        return array($orig[0], $final[0]);
    }
    //echo "<pre>";print_r($z);echo "</pre>";
    require_once "renderer_{$function}.php";
    $new = "Text_Diff_Renderer_{$function}";
    $renderer = new $new(sizeof($line1));
    return $renderer->render($z);
}
開發者ID:Kraiany,項目名稱:kraiany_site_docker,代碼行數:21,代碼來源:difflib.php

示例2: diffChar

 function diffChar($orig, $final)
 {
     $line1 = preg_split('//', implode("<br />", $orig), -1, PREG_SPLIT_NO_EMPTY);
     $line2 = preg_split('//', implode("<br />", $final), -1, PREG_SPLIT_NO_EMPTY);
     $z = new Text_Diff($line1, $line2);
     if ($z->isEmpty()) {
         return array($orig[0], $final[0]);
     }
     // echo "<pre>";print_r($z);echo "</pre>";
     require_once 'character.php';
     $renderer = new Text_Diff_Renderer_character(10000);
     return $renderer->render($z);
 }
開發者ID:sdoney,項目名稱:cookbook,代碼行數:13,代碼來源:sidebyside.php

示例3: diffChar

function diffChar($orig, $final, $words = 0, $function = 'character')
{
    $glue = strpos($function, 'inline') !== false ? "<br />" : "\n";
    if ($words) {
        preg_match_all("/\\w+\\s+(?=\\w)|\\w+|\\W/u", implode($glue, $orig), $matches);
        $line1 = $matches[0];
        preg_match_all("/\\w+\\s+(?=\\w)|\\w+|\\W/u", implode($glue, $final), $matches);
        $line2 = $matches[0];
    } else {
        $line1 = preg_split('//u', implode($glue, $orig), -1, PREG_SPLIT_NO_EMPTY);
        $line2 = preg_split('//u', implode($glue, $final), -1, PREG_SPLIT_NO_EMPTY);
    }
    $z = new Text_Diff($line1, $line2);
    if ($z->isEmpty()) {
        return array($orig[0], $final[0]);
    }
    //echo "<pre>";print_r($z);echo "</pre>";
    compileRendererClass($function);
    $new = "Text_Diff_Renderer_{$function}";
    $renderer = new $new(count($line1));
    return $renderer->render($z);
}
開發者ID:rjsmelo,項目名稱:tiki,代碼行數:22,代碼來源:difflib.php

示例4: get_diff

 /**
  * Get a html diff between two versions.
  *
  * @param string latest_revision id of the latest revision
  * @param string oldest_revision id of the oldest revision
  * @return array array with the original value, the new value and a diff -u
  */
 public function get_diff($oldest_revision, $latest_revision, $renderer_style = 'inline')
 {
     if (!class_exists('Text_Diff')) {
         @(include_once 'Text/Diff.php');
         @(include_once 'Text/Diff/Renderer.php');
         @(include_once 'Text/Diff/Renderer/unified.php');
         @(include_once 'Text/Diff/Renderer/inline.php');
         if (!class_exists('Text_Diff')) {
             throw new midcom_error("Failed to load Text_Diff library.");
         }
     }
     $oldest = $this->get_revision($oldest_revision);
     $newest = $this->get_revision($latest_revision);
     $return = array();
     foreach ($oldest as $attribute => $oldest_value) {
         if (!array_key_exists($attribute, $newest)) {
             continue;
             // This isn't in the newer version, skip
         }
         if (is_array($oldest_value)) {
             continue;
             // Skip
         }
         $return[$attribute] = array('old' => $oldest_value, 'new' => $newest[$attribute]);
         if ($oldest_value != $newest[$attribute]) {
             $lines1 = explode("\n", $oldest_value);
             $lines2 = explode("\n", $newest[$attribute]);
             $diff = new Text_Diff($lines1, $lines2);
             if ($renderer_style == 'unified') {
                 $renderer = new Text_Diff_Renderer_unified();
             } else {
                 $renderer = new Text_Diff_Renderer_inline();
             }
             if (!$diff->isEmpty()) {
                 // Run the diff
                 $return[$attribute]['diff'] = $renderer->render($diff);
                 if ($renderer_style == 'inline') {
                     // Modify the output for nicer rendering
                     $return[$attribute]['diff'] = str_replace('<del>', "<span class=\"deleted\" title=\"removed in {$latest_revision}\">", $return[$attribute]['diff']);
                     $return[$attribute]['diff'] = str_replace('</del>', '</span>', $return[$attribute]['diff']);
                     $return[$attribute]['diff'] = str_replace('<ins>', "<span class=\"inserted\" title=\"added in {$latest_revision}\">", $return[$attribute]['diff']);
                     $return[$attribute]['diff'] = str_replace('</ins>', '</span>', $return[$attribute]['diff']);
                 }
             }
         }
     }
     return $return;
 }
開發者ID:nemein,項目名稱:openpsa,代碼行數:55,代碼來源:rcs.php


注:本文中的Text_Diff::isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。