Beispiel #1
0
$all_linenotes = $hashb_mine ? $Info->commit_info("linenotes") : array();
$lnorder = new LinenotesOrder($all_linenotes, $Info->can_see_grades);
$lnorder->set_diff($diff);
// print line notes
$notelinks = array();
foreach ($lnorder->seq() as $fl) {
    $f = str_starts_with($fl[0], $Pset->directory_slash) ? substr($fl[0], strlen($Pset->directory_slash)) : $fl[0];
    $notelinks[] = '<a href="#L' . $fl[1] . '_' . html_id_encode($fl[0]) . '" onclick="return gotoline61(this)" class="noteref61' . (!$fl[2] && !$Info->user_can_see_grades ? " hiddennote61" : "") . '">' . htmlspecialchars($f) . ':' . substr($fl[1], 1) . '</a>';
}
if (count($notelinks)) {
    ContactView::echo_group("notes", join(", ", $notelinks));
}
// check for any linenotes
$has_any_linenotes = false;
foreach ($diff as $file => $dinfo) {
    if ($lnorder->file($file)) {
        $has_any_linenotes = true;
        break;
    }
}
// line notes
foreach ($diff as $file => $dinfo) {
    $linenotes = $lnorder->file($file);
    $open = $linenotes || !$dinfo->boring || !$hasha_mine && !$hashb_mine;
    $Info->echo_file_diff($file, $dinfo, $lnorder, $open);
}
Ht::stash_script('jQuery(".diffnoteentry61").autogrow();jQuery(window).on("beforeunload",beforeunload61)');
echo "<table id=\"diff61linenotetemplate\" style=\"display:none\"><tbody>";
$Info->echo_linenote_entry_prototype();
echo "</tbody></table>";
echo "<div class='clear'></div>\n";
Beispiel #2
0
 function echo_file_diff($file, DiffInfo $dinfo, LinenotesOrder $lnorder, $open)
 {
     $fileid = html_id_encode($file);
     $tabid = "file61_" . $fileid;
     $linenotes = $lnorder->file($file);
     echo '<h3><a class="fold61" href="#" onclick="return fold61(', "'#{$tabid}'", ',this)"><span class="foldarrow">', $open ? "&#x25BC;" : "&#x25B6;", "</span>&nbsp;", htmlspecialchars($file), "</a>";
     if (!$dinfo->removed) {
         $rawfile = $file;
         if ($this->repo->truncated_psetdir($this->pset) && str_starts_with($rawfile, $this->pset->directory_slash)) {
             $rawfile = substr($rawfile, strlen($this->pset->directory_slash));
         }
         echo '<a style="display:inline-block;margin-left:2em;font-weight:normal" href="', $this->hoturl("raw", ["file" => $rawfile]), '">[Raw]</a>';
     }
     echo '</h3>';
     echo '<table id="', $tabid, '" class="code61 diff61 filediff61';
     if ($this->pc_view) {
         echo " live";
     }
     if (!$this->user_can_see_grades) {
         echo " hidegrade61";
     }
     if (!$open) {
         echo '" style="display:none';
     }
     echo '" data-pa-file="', htmlspecialchars($file), '" data-pa-fileid="', $fileid, "\"><tbody>\n";
     if ($this->pc_view) {
         Ht::stash_script("jQuery('#{$tabid}').mousedown(linenote61).mouseup(linenote61)");
     }
     foreach ($dinfo->diff as $l) {
         if ($l[0] == "@") {
             $x = array(" gx", "difflctx61", "", "", $l[3]);
         } else {
             if ($l[0] == " ") {
                 $x = array(" gc", "difflc61", $l[1], $l[2], $l[3]);
             } else {
                 if ($l[0] == "-") {
                     $x = array(" gd", "difflc61", $l[1], "", $l[3]);
                 } else {
                     $x = array(" gi", "difflc61", "", $l[2], $l[3]);
                 }
             }
         }
         $aln = $x[2] ? "a" . $x[2] : "";
         $bln = $x[3] ? "b" . $x[3] : "";
         $ak = $bk = "";
         if ($linenotes && $aln && isset($linenotes->{$aln})) {
             $ak = ' id="L' . $aln . '_' . $fileid . '"';
         }
         if ($bln) {
             $bk = ' id="L' . $bln . '_' . $fileid . '"';
         }
         if (!$x[2] && !$x[3]) {
             $x[2] = $x[3] = "...";
         }
         echo '<tr class="diffl61', $x[0], '">', '<td class="difflna61"', $ak, '>', $x[2], '</td>', '<td class="difflnb61"', $bk, '>', $x[3], '</td>', '<td class="', $x[1], '">', diff_line_code($x[4]), "</td></tr>\n";
         if ($linenotes && $bln && isset($linenotes->{$bln})) {
             $this->echo_linenote($file, $bln, $linenotes->{$bln}, $lnorder);
         }
         if ($linenotes && $aln && isset($linenotes->{$aln})) {
             $this->echo_linenote($file, $aln, $linenotes->{$aln}, $lnorder);
         }
     }
     echo "</tbody></table>\n";
 }