当前位置: 首页>>代码示例>>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;未经允许,请勿转载。