rename Phorkie to phorkie (lowercase)
[phorkie.git] / www / index.php
index f821c840d1e6c3cfd7cee4ecd3c21d41eb542949..d926a1dff8b73045e0dc17ae7bdc95fe09acb412 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-namespace Phorkie;
+namespace phorkie;
 /**
  * Show paste creation form
  *
@@ -12,40 +12,20 @@ namespace Phorkie;
  */
 require_once 'www-header.php';
 
-if (isset($_POST['files'])) {
-    //save
-    $rs = new Repositories();
-    $repo = $rs->createNew();
-    $vc = $repo->getVc();
-    $vc->initRepository();
-    foreach (glob($repo->repoDir . '/.git/hooks/*') as $hookfile) {
-        unlink($hookfile);
-    }
-    file_put_contents($repo->repoDir . '.git/description', $_POST['description']);
-
-    foreach ($_POST['files'] as $num => $arFile) {
-        if ($arFile['name'] != '') {
-            $fname = $arFile['name'];
-        } else {
-            $fname = 'phork' . $num . '.' . $arFile['type'];
-        }
-        $fpath = $repo->repoDir . $fname;
-        file_put_contents($fpath, $arFile['content']);
-        //fixme: let the class do that when it is able to
-        $command = $vc->getCommand('add')
-            ->addArgument($fname)
-            ->execute();
-    }
-    $command = $vc->getCommand('commit')
-        ->setOption('message', 'initial paste')
-        ->setOption('author', 'Anonymous <anonymous@phorkie>')
-        ->execute();
-    //redirect to phork
-    redirect($repo->getLink('display'));
+$repopo = new Repository_Post();
+if ($repopo->process($_POST)) {
+    redirect($repopo->repo->getLink('display'));
 }
 
 $phork = array(
     '1' => new File(null, null)
 );
-render('index', array('files' => $phork, 'description' => ''));
-?>
\ No newline at end of file
+render(
+    'index',
+    array(
+        'files' => $phork,
+        'description' => '',
+        'htmlhelper' => new HtmlHelper(),
+    )
+);
+?>