<p class="muted">Type determined from filename</p>
</div>
</div>
+ {% if not file or file.isText %}
<textarea name="files[{{fileid}}][content]" id="content_{{fileid}}" cols="80" rows="15" class="content">{{file.getContent}}</textarea>
+ {% else %}
+ <p style="text-align: center">
+ Binary files cannot be edited.
+ </p>
+ {% endif %}
<div class="row-fluid">
<div class="span9">
<label for="upload_{{fileid}}" class="inline">Replace with upload:</label>
$tm = new Tool_Manager();
return $tm->getSuitable($this);
}
+
+ /**
+ * Tells if the file contains textual content and is editable.
+ *
+ * @return boolean
+ */
+ public function isText()
+ {
+ $ext = $this->getExt();
+ if (!isset($GLOBALS['phorkie']['languages'][$ext]['mime'])) {
+ return false;
+ }
+
+ $type = $GLOBALS['phorkie']['languages'][$ext]['mime'];
+ return substr($type, 0, 5) === 'text/';
+ }
}
?>
\ No newline at end of file
->addArgument($file->getFilename())
->execute();
$bChanged = true;
- } else if ($bNew || $file->getContent() != $arFile['content']) {
+ } else if ($bNew || (isset($arFile['content']) && $file->getContent() != $arFile['content'])) {
file_put_contents($file->getPath(), $arFile['content']);
$command = $vc->getCommand('add')
->addArgument($file->getFilename())