public function preview()
{
if (($pos = strrpos($this->path, '.')) !== false) {
$type = substr($this->path, $pos + 1);
} else {
$type = 'unknown';
}
if ($type === 'php') {
return highlight_string($this->content, true);
} elseif (!in_array($type, ['jpg', 'gif', 'png', 'exe'])) {
return nl2br(Html::encode($this->content));
} else {
return false;
}
}