/** * Exports the content of a file to be saved * * @return string */ public function export() { $file = ''; foreach ($this->fileTagNameToFunction as $tag => $function) { $function = str_replace('FromString', '', $function); $tag = strtoupper($tag); $function = 'get' . $function; if (method_exists($this->song, $function)) { $value = $this->song->{$function}(); $file .= "#{$tag}:{$value};\n"; } else { Output::log('No Method', $function); } } foreach ($this->song->notes as $key => $value) { $file .= "\n//---------------{$value->getType()} - {$value->getDifficulty()} ----------------\n" . "#NOTES:\n" . " {$value->getType()}:\n" . " {$value->getDescription()}:\n" . " {$value->getDifficulty()}:\n" . " {$value->getMeter()}:\n" . " {$value->getGrooveString()}:\n" . "{$value->getSteps()};\n"; } return $file; }
public function handler($e) { if ($e instanceof \Exception) { $type = 'Internal-Exception'; $message = sprintf($type . ': "%s" thrown at %s(%d)', $e->getMessage(), $e->getFile(), $e->getLine()); } else { $type = 'PHP-Exception'; $message = sprintf($type . '"%s" thrown at %s(%d)', $e->getMessage(), $e->getFile(), $e->getLine()); } Output::$indent = 0; Output::log(''); Output::error($message); Output::log(''); Output::$indent++; $handle = @fopen($e->getFile(), "r"); if ($handle) { $code = array(); $line = 1; while (($buffer = fgets($handle)) !== false) { if ($line > $e->getLine() - 5 && $line < $e->getLine() + 5) { $code[] = array('line' => $line, 'code' => $buffer); } if ($line > $e->getLine() + 5) { break; } $line++; } fclose($handle); Output::log(Console::BOLD . 'File Preview:', $e->getFile() . '(' . $e->getLine() . ')'); foreach ($code as $c) { $line = str_replace("\n", '', $c['line'] . ': ' . $c['code']); if ($c['line'] == $e->getLine()) { $line = Console::bgRGB('#9c7a04') . Console::fgRGB('#FFFFFF', true) . $line; } Output::log($line); } } $this->MakePrettyException($e->getTrace()); Output::log(); }