toTable() public static method

$diff - the diff array $indentation - indentation to add to every line of the generated HTML; this optional parameter defaults to '' $separator - the separator between lines; this optional parameter defaults to '
'
public static toTable ( $diff, $indentation = '', $separator = '<br>' )
Beispiel #1
0
    }
}
?>
        </div>
        <?php 
if (!empty($oracle_says)) {
    ?>
        <div class="row">
          <div class="col-md-8 col-md-offset-2">
          <span><h3 style="text-align:center">YOU vs. ORACLE</h3></span>
          <div style="display:table;text-align:left;margin-left:auto;margin-right:auto">
            <?php 
    // include the Diff class
    require_once 'class.Diff.php';
    // output the result of comparing two files as a table
    echo Diff::toTable(Diff::compare(preg_replace('~\\R~u', "\n", empty($expected) ? '' : $expected), $oracle_says));
    ?>
          </div>
          </div>
        </div>
        <?php 
}
?>
        <div class="jumbotron" style="height:75%;position:relative;">
        <?php 
if (empty($error)) {
    ?>
        <form role="form" id="login-form" action="" method="POST" class="row">
        <div class="form-group col-md-6">
            <div class="input-group input-group-lg">
              <span class="input-group-addon">@</span>
 public function getDiff()
 {
     $fileNew = realpath($this->getFile());
     $fileOld = dirname(__DIR__) . '/../addons/files/local/' . $this->aid . '.zip';
     if (!is_file($fileOld)) {
         $path = realpath(dirname(__DIR__) . '/../addons/files/local/');
         $fh = fopen($path . '/' . $this->aid . '.zip', 'w');
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, "http://" . AWSFileManager::getBucket() . "/addons/" . $this->aid . "_1");
         curl_setopt($ch, CURLOPT_FILE, $fh);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         // this will follow redirects
         curl_exec($ch);
         curl_close($ch);
         fclose($fh);
     }
     $fileOld = realpath(dirname(__DIR__) . '/../addons/files/local/' . $this->aid . '.zip');
     $zipNew = new ZipArchive();
     $zipOld = new ZipArchive();
     $resNew = $zipNew->open($fileNew);
     $resOld = $zipOld->open($fileOld);
     if ($resNew === TRUE && $resOld === TRUE) {
         $newFiles = array();
         for ($i = 0; $i < $zipNew->numFiles; $i++) {
             $newFiles[] = $zipNew->getNameIndex($i);
         }
         $oldFiles = [];
         for ($i = 0; $i < $zipOld->numFiles; $i++) {
             $oldFiles[] = $zipOld->getNameIndex($i);
         }
         $added = array_diff($newFiles, $oldFiles);
         $removed = array_diff($oldFiles, $newFiles, ["glass.json", "version.json"]);
         $commonFiles = array_intersect($newFiles, $oldFiles);
         $commonFiles = array_diff($commonFiles, ["glass.json", "version.json"]);
         $diff = [];
         foreach ($commonFiles as $fi) {
             if (strpos($fi, ".cs") == strlen($fi) - 3) {
                 $newStr = $zipNew->getFromName($fi);
                 $oldStr = $zipOld->getFromName($fi);
                 if (trim($newStr) != trim($oldStr)) {
                     $diff[$fi] = Diff::toTable(Diff::compare($oldStr, $newStr));
                 }
             }
         }
         $ret = ["added" => $added, "removed" => $removed, "changes" => $diff];
         return $ret;
     } else {
         return false;
     }
 }
		<?php 
$input_array = array('id' => $args['content']->id);
$before = build_field_content_blockquote($input_array);
$input_array = array('id' => $args['content']->parent);
$after = build_field_content_blockquote($input_array);
foreach ($before as $key => $val) {
    ?>
		
		<blockquote class="content_field_blockquote">
			<div class="content_field">
				<label><?php 
    echo $val['field_name'];
    ?>
</label>
				<div class="content_field_value">
					<?php 
    $before_val = $val['field_val'];
    $after_val = $after[$key]['field_val'];
    echo Diff::toTable(Diff::compare($before_val, $after_val));
    ?>
				</div>
			</div>
		</blockquote>
		
		<?php 
}
?>

	</div>

</div>
Beispiel #4
0
function wiki_compare_page($arr)
{
    $pageUrlName = array_key_exists('pageUrlName', $arr) ? $arr['pageUrlName'] : '';
    $resource_id = array_key_exists('resource_id', $arr) ? $arr['resource_id'] : '';
    $currentCommit = array_key_exists('currentCommit', $arr) ? $arr['currentCommit'] : 'HEAD';
    $compareCommit = array_key_exists('compareCommit', $arr) ? $arr['compareCommit'] : null;
    if (!$compareCommit) {
        return array('message' => 'No compare commit was provided', 'success' => false);
    }
    $w = wiki_get_wiki($resource_id);
    if (!$w['path']) {
        return array('message' => 'Error reading wiki', 'success' => false);
    }
    $page_path = $w['path'] . '/' . $pageUrlName . '.md';
    if (is_readable($page_path) === true) {
        $reponame = array_key_exists('title', $w['wiki']) ? urlencode($w['wiki']['title']) : 'repo';
        if ($reponame === '') {
            $reponame = 'repo';
        }
        $git = new GitRepo('', null, false, $w['wiki']['title'], $w['path']);
        $compareContent = $currentContent = '';
        try {
            foreach ($git->git->tree($currentCommit) as $object) {
                if ($object['type'] == 'blob' && $object['file'] === $pageUrlName . '.md') {
                    $currentContent = $git->git->cat->blob($object['hash']);
                }
            }
            foreach ($git->git->tree($compareCommit) as $object) {
                if ($object['type'] == 'blob' && $object['file'] === $pageUrlName . '.md') {
                    $compareContent = $git->git->cat->blob($object['hash']);
                }
            }
            require_once 'library/class.Diff.php';
            $diff = Diff::toTable(Diff::compare($currentContent, $compareContent));
        } catch (\PHPGit\Exception\GitException $e) {
            return array('message' => 'GitRepo error thrown', 'success' => false);
        }
        return array('diff' => $diff, 'message' => '', 'success' => true);
    } else {
        return array('message' => 'Page file not writable', 'success' => false);
    }
}
<?php

$email = $website_url = $handle = fopen("/opt/lampp/htdocs/{$email}/{$website_url}/change.txt", "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        $pieces = explode(" ", $line);
        $variable1 = $pieces[0];
        if ($variable1 == "Files") {
            $variable2 = $pieces[1];
            $variable3 = $pieces[3];
            ob_start();
            require_once '/opt/lampp/htdocs/project/class.Diff2.php';
            $d = Diff::toTable(Diff::compareFiles("{$variable2}", "{$variable3}"));
            echo "<iframe src='http://localhost/left.html' width='49%' height='100%'></iframe>";
            echo "<iframe src='http://localhost/right.html' width='49%' height='100%'></iframe>";
            require_once '/opt/lampp/htdocs/project/class.Diff.php';
            $d = Diff1::toTable(Diff1::compareFiles("{$variable2}", "{$variable3}"));
            echo $d;
            $content = ob_get_contents();
            ob_end_clean();
            $variable2 = str_replace("/", ".", $variable2);
            $variable3 = str_replace("/", ".", $variable3);
            $search = ".opt.lampp.htdocs.{$email}.{$website_url}.";
            $variable2 = str_replace($search, '', $variable2);
            $variable3 = str_replace($search, '', $variable3);
            file_put_contents("/opt/lampp/htdocs/{$email}/{$website_url}/diff/{$variable2}.{$variable3}.html", $content);
        } else {
            $variable1 = $pieces[2];
            $variable2 = $pieces[3];
            $variable1 = str_replace(":", "/", $variable1);
            $output1 = "cp {$variable1}{$variable2} /opt/lampp/htdocs/{$email}/{$website_url}/diff/";
Beispiel #6
0
 public function diff($snapshotId1, $snapshotId2)
 {
     $x = Snapshot::find($snapshotId1)->readNoTags();
     $y = Snapshot::find($snapshotId2)->readNoTags();
     $html = "<style>\n    \t\t.diffInserted{\n    \t\t\tborder: 1px solid rgb(192,255,192);\n    \t\t\tbackground: rgb(224,255,224);\n    \t\t}\n    \t\t.diffDeleted{\n    \t\t\tborder: 1px solid rgb(255,192,192);\n    \t\t\tbackground: rgb(255,224,224);\n    \t\t}\n    \t</style>";
     return $html . Diff::toTable(Diff::compare($x, $y));
 }