/**
  * Format a html output of an code fragment (seven lines before and after) around the give line of the given source file
  *
  * @version 1.0
  * @author greg <*****@*****.**>
  *
  * @param string $filepath path to the source file
  * @param integer $lineno line number of the interesting line
  * @return string html formated string
  */
 public static function fetchCodeFragment($filepath, $lineno)
 {
     if (!empty($filepath) && file_exists($filepath)) {
         $filecontent = file($filepath);
         $start = max($lineno - 7, 0);
         $end = min($lineno + 7, count($filecontent));
         $line = '';
         $fragment = '';
         for ($loop = $start; $loop < $end; $loop++) {
             if (!empty($filecontent[$loop])) {
                 $line = $filecontent[$loop];
                 $line = preg_replace('#\\n$#', '', $line);
                 $line = PHPDS_backtrace::highlightString($line, $loop + 1);
             }
             if ($loop == $lineno - 1) {
                 $line = '<span class="highlight-error">' . $line . '</span>';
             }
             $fragment .= $line . "\n";
         }
         return $fragment;
     } else {
         return null;
     }
 }
Example #2
0
        echo "<dt>Basepath</dt>";
        echo "<dd><code>" . BASEPATH . "</code></dd>";
        echo "<dt>Working directory</dt>";
        echo "<dd><code>" . getcwd() . "</code></dd>";
        ?>
                    </dl>
                </div>
                <div>
                    <h3>Variable Registry</h3>
                    <pre><?php 
        echo PU_dumpArray($this->classFactory->PluginClasses);
        ?>
</pre>
                </div>
                <?php 
        echo PHPDS_backtrace::phpInfo();
        ?>
                <?php 
    }
    ?>
                <div class="alert alert-success">
                    <strong>End of Report</strong><br>
                    PHP <?php 
    echo phpversion();
    ?>
                </div>
            <?php 
} else {
    ?>
                    <p class="lead">
                        An error has occurred while trying to provide you with the requested resource. The site administrator has been informed and will take the appropriate action.</p>
 /**
  * Format a html output of an code fragment (seven lines before and after) around the give line of the given source file
  *
  * @version 1.0
  * @author greg <*****@*****.**>
  *
  * @param string $filepath path to the source file
  * @param integer $lineno line number of the interesting line
  * @return string html formated string
  */
 public static function fetchCodeFragment($filepath, $lineno)
 {
     if (!empty($filepath) && file_exists($filepath)) {
         $filecontent = file($filepath);
         $start = max($lineno - 7, 0);
         $end = min($lineno + 7, count($filecontent));
         $line = '';
         $fragment = '<div class="ui-state-default ui-corner-all"></div><div class="toggle">';
         for ($loop = $start; $loop < $end; $loop++) {
             if (!empty($filecontent[$loop])) {
                 $line = $filecontent[$loop];
                 $line = preg_replace('#\\n$#', '', $line);
                 $line = PHPDS_backtrace::highlightString($line, $loop + 1);
             }
             if ($loop == $lineno - 1) {
                 $line = '<span class="ui-state-highlight ui-corner-all">' . $line . '</span>';
             }
             $fragment .= $line . '<br />' . "\n";
         }
         $fragment .= '</div>';
         return $fragment;
     } else {
         return '<p>Missing file...</p>';
     }
 }