<div class="row-fluid" style="margin-top: 5ex">
- <div class="span12">
+ <div class="span4"></div>
+ <div class="span4" style="text-align: center">
+ <a class="btn" href="{{repo.getLink('edit', 'newfile')}}" id="add-button">
+ <i class="icon-plus"></i>
+ Add file
+ </a>
+ </div>
+ <div class="span4">
<a class="btn pull-right" href="{{repo.getLink('delete')}}">
<i class="icon-trash"></i> Delete paste
</a>
{% block content %}
<div class="content-padding-fix"></div>
-<form method="post" action="{{repo.getLink('edit', singlefile.getFilename)}}" enctype="multipart/form-data" class="form-horizontal">
+<form method="post" action="{{formaction}}" enctype="multipart/form-data" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="description">Description</label>
<div class="controls">
{% endif %}
{% endfor %}
+ {% if singlefile == "newfile" %}
+ {% include 'edit-file.htm' with {'file': null, 'fileid': 'newfile', 'newfile': true} %}
+ {% endif %}
+
{% include 'edit-add.htm' %}
<div class="row-fluid formbuttons">
{
public $repo;
+ /**
+ * When a new file is created during processing, its name
+ * is stored here for later use.
+ *
+ * @var string
+ */
+ public $newfileName;
+
+
+
public function __construct(Repository $repo = null)
{
$this->repo = $repo;
//automatically append file extension if none is there
$name .= '.' . $arFile['type'];
}
+ $this->newfileName = $name;
} else if (!$this->repo->hasFile($orignalName)) {
//unknown file
//FIXME: Show error message
$file = null;
if (isset($_GET['file'])) {
- $file = $repo->getFileByName($_GET['file']);
+ if ($_GET['file'] == 'newfile') {
+ $file = 'newfile';
+ } else {
+ $file = $repo->getFileByName($_GET['file']);
+ }
}
$repopo = new Repository_Post($repo);
if ($repopo->process($_POST, $_SESSION)) {
$anchor = '';
- if ($file !== null) {
+ if ($file instanceof File) {
$anchor = '#' . $file->getAnchorName();
+ } else if ($file === 'newfile' && $repopo->newfileName) {
+ $anchor = '#' . $repo->getFileByName($repopo->newfileName)->getAnchorName();
}
redirect($repo->getLink('display', null, true) . $anchor);
}
+$actionFile = null;
+if ($file instanceof File) {
+ $actionFile = $file->getFilename();
+} else if ($file === 'newfile') {
+ $actionFile = 'newfile';
+}
+
render(
'edit',
array(
'singlefile' => $file,
'dh' => new \Date_HumanDiff(),
'htmlhelper' => new HtmlHelper(),
+ 'formaction' => $repo->getLink('edit', $actionFile)
)
);
?>