Пример #1
0
 static function show($filename1, $data1, $HTMLheader1, $filename2, $data2, $HTMLheader2)
 {
     //Get file lines
     $nl = vpl_detect_newline($data1);
     $lines1 = explode($nl, $data1);
     $nl = vpl_detect_newline($data2);
     $lines2 = explode($nl, $data2);
     //Get dif as an array of info
     $diff = self::calculateDiff($lines1, $lines2);
     if ($diff === false) {
         return;
     }
     $separator = array('<' => ' <<< ', '>' => ' >>> ', '=' => ' === ', '#' => ' ### ');
     $emptyline = "&nbsp;\n";
     $data1 = '';
     $data2 = '';
     $datal1 = '';
     $datal2 = '';
     $diffl = '';
     $lines1[-1] = '';
     $lines2[-1] = '';
     foreach ($diff as $line) {
         $diffl .= $separator[$line->type] . "\n";
         if ($line->ln1) {
             $datal1 .= $line->ln1 . " \n";
             $data1 .= $lines1[$line->ln1 - 1] . "\n";
         } else {
             $data1 .= " \n";
             $datal1 .= $emptyline;
         }
         if ($line->ln2) {
             $datal2 .= $line->ln2 . " \n";
             $data2 .= $lines2[$line->ln2 - 1] . "\n";
         } else {
             $data2 .= " \n";
             $datal2 .= $emptyline;
         }
     }
     echo '<div style="width: 100%;min-width: 950px; overflow: auto">';
     //Header
     echo '<div style="float:left; width: 445px">';
     echo $HTMLheader1;
     echo '</div>';
     echo '<div style="float:left; width: 445px">';
     echo $HTMLheader2;
     echo '</div>';
     echo '<div style="clear:both;"></div>';
     //Files
     echo '<div style="float:left; text-align: right">';
     echo '<pre class="' . vpl_sh_base::c_general . '">';
     echo $datal1;
     echo '</pre>';
     echo '</div>';
     echo '<div style="float:left; width: 390px; overflow:auto">';
     $shower = vpl_sh_factory::get_sh($filename1);
     $shower->print_file($filename1, $data1, false);
     echo '</div>';
     echo '<div style="float:left">';
     echo '<pre class="' . vpl_sh_base::c_general . '">';
     echo $diffl;
     echo '</pre>';
     echo '</div>';
     echo '<div style="float:left; text-align: right;">';
     echo '<pre class="' . vpl_sh_base::c_general . '">';
     echo $datal2;
     echo '</pre>';
     echo '</div>';
     echo '<div style="float:left; width: 390px; overflow:auto">';
     $shower = vpl_sh_factory::get_sh($filename2);
     $shower->print_file($filename2, $data2, false);
     echo '</div>';
     echo '</div>';
     echo '<div style="clear:both;"></div>';
 }
Пример #2
0
 /**
  * Print file group
  **/
 function print_files($if_no_exist = true)
 {
     global $OUTPUT;
     $filenames = $this->getFileList();
     foreach ($filenames as $name) {
         if (file_exists($this->dir . self::encodeFileName($name))) {
             echo '<h3>' . s($name) . '</h3>';
             $printer = vpl_sh_factory::get_sh($name);
             echo $OUTPUT->box_start();
             $data = $this->getFileData($name);
             $printer->print_file($name, $data);
             echo $OUTPUT->box_end();
         } elseif ($if_no_exist) {
             echo '<h3>' . s($name) . '</h3>';
         }
     }
 }