summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-21 18:17:16 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-21 18:17:16 -0400
commitfe0ff30a11bb54bd8f3db15a89d16a735a24c83c (patch)
treef3378e435e555ffb3a0dcdd953c24968f9e05e90 /frontend
parentUpdated todo (diff)
downloadingenue-fe0ff30a11bb54bd8f3db15a89d16a735a24c83c.tar.gz
ingenue-fe0ff30a11bb54bd8f3db15a89d16a735a24c83c.tar.bz2
ingenue-fe0ff30a11bb54bd8f3db15a89d16a735a24c83c.zip
Started restructuring frontend wizard for modularity
Diffstat (limited to 'frontend')
-rw-r--r--frontend/pages/wizard.php91
l---------frontend/pages/wizard/step0.php1
-rw-r--r--frontend/wizard/step1.php (renamed from frontend/pages/wizard/step1.php)0
3 files changed, 51 insertions, 41 deletions
diff --git a/frontend/pages/wizard.php b/frontend/pages/wizard.php
index e9af804..57e9d45 100644
--- a/frontend/pages/wizard.php
+++ b/frontend/pages/wizard.php
@@ -4,54 +4,69 @@ function init_wizard() {
if (!isset($S['user'])) {
return 'login';
}
- if (isset($request['step']) && is_array($request['step']) && count($request['step']) == 1) {
- $keys=array_keys($request['step']);
- if (is_numeric($keys[0]) && is_file(FRONTEND.'/pages/wizard/step'.$keys[0].'.php')) {
- $step=$keys[0];
- $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `owner`='.$S['user']->id.' AND `status`="config/step'.$step.'"');
- if ($r->rowCount() == 0) {
- debug('wizard', 'Build not found!');
- // Build
- unset($request['step']);
- return 'wizard';
+ // TODO only create a table entry after you submit a name
+ // Move profile to step1, that's distro-dependent
+ // Make it so you can just pop over to config build=x and it will go to the right step
+ if (isset($request['build']) && preg_match('/^[a-zA-Z0-9]{6}$/', $request['build'])) {
+ $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `owner`='.$S['user']->id.' AND `id`="'.$request['build'].'"');
+ if ($r->rowCount()) {
+ $build=new sql_build($r->fetch(PDO::FETCH_ASSOC));
+ $S['wizard.build']=&$build;
+ if (!preg_match('#^config/step([0-9]+)$#', $build->status, $match)) {
+ debug('wizard', 'build not in config stage - PANIC!');
+ throw new Exception('We haven\'t implemented this yet.');
}
- $S['build']=new sql_build($r->fetch(PDO::FETCH_ASSOC));
- require_once(FRONTEND.'/pages/wizard/step'.$step.'.php');
- $proc='process_wizard_step'.$step;
- if (function_exists($proc)) {
- $proc();
- } else {
- debug('wizard', 'No processing function for step '.$step);
+ $step=$match[1];
+ $S['wizard.step']=&$step;
+ if (isset($request['step'.$step.'submit'])) {
+ require_once(FRONTEND."/wizard/step$step.php");
+ $proc='wizard_process_step'.$step;
+ if (function_exists($proc)) {
+ $proc();
+ } else {
+ debug('wizard', 'No processing function for step '.$step);
+ }
+ $build->status='config/step'.++$step.'.php';
+ $build->write();
}
- $step++;
- if (is_file(FRONTEND.'/pages/wizard/step'.$step.'.php')) {
- $S['build']->status='config/step'.$step;
- $S['build']->write();
+ if (is_file(FRONTEND."/wizard/step$step.php")) {
+ require_once(FRONTEND.'/wizard/step'.$step.'.php');
$S['title']='Create - Step '.$step;
- return 'wizard/step'.$step;
+ $proc='wizard_init_step'.$step;
+ if (function_exists($proc)) {
+ return $proc();
+ } else {
+ debug('wizard', 'No init function for step '.$step);
+ return;
+ }
} else {
- $S['build']->status='build/ready';
- $S['build']->ctime=time();
- $S['build']->write();
- return array('title' => 'Create - Finished');
+ throw new Exception("Step $step doesn't exist");
}
} else {
- debug('wizard', 'step[0] not numeric, or step '.htmlentities($step).' not existant');
+ throw new Exception('Build not found');
}
- } else {
+/* } else {
$r=$S['pdo']->query('SELECT * FROM `builds` WHERE `owner`='.$S['user']->id.' AND `status` LIKE "config/step0"');
if ($r->rowCount()) {
- $S['build']=new sql_build($r->fetch(PDO::FETCH_ASSOC));
+ $S['wizard.build']=new sql_build($r->fetch(PDO::FETCH_ASSOC));
} else {
- $S['build']=new sql_build();
- $S['build']->init();
- }
+ $S['wizard.build']=new sql_build();
+ $S['wizard.build']->init();
+ }*/
}
return array('title' => 'Create');
}
function body_wizard() {
global $S;
- if ($S['build']->status == 'config/step0') {
+ if (isset($S['wizard.build'])) {
+ $build=&$S['wizard.build'];
+ $step=&$S['wizard.step'];
+ echo '<form action="'.url('create/'.$build->id).'" method="post">';
+ require_once(FRONTEND."/wizard/step$step.php");
+ $proc='wizard_body_step'.$step;
+ $proc();
+ echo '<input type="submit" name="step'.$S['wizard.step'].'submit" /></form>';
+ } else {
echo '<form action="'.url('create').'" method="post"><h3>Request an image built</h3>Name of your build (optional): <input name="name" /><br/>Profile: <select name="pkgdir">';
$r=$S['pdo']->query('SELECT * FROM `profiles` WHERE `flags` NOT LIKE "%d%"'); // d for disabled
while ($profile=$r->fetch(PDO::FETCH_ASSOC)) {
@@ -60,11 +75,11 @@ function body_wizard() {
echo '<option value="'.htmlentities($profile->pkgdir).'">'.htmlentities($display).'</option>';
}
echo '</select><br/><input type="submit" name="step[0]" value="Start" /></form>';
- } else {
- echo '<h3>Config finished!</h3><p>Check your build\'s status <a href="'.url('logs/build'.$S['build']->id).'">here</a></p>';
+// } else {
+// echo '<h3>Config finished!</h3><p>Check your build\'s status <a href="'.url('logs/build'.$S['build']->id).'">here</a></p>';
}
}
-function process_wizard_step0() {
+function wizard_init() {
global $S, $request;
$S['build']->name=$request['name'];
$profile=new sql_profile($request['pkgdir']);
@@ -72,8 +87,4 @@ function process_wizard_step0() {
$profileopt->write();
$S['build']->write();
}
-// One day this is going to be necessary
-function body_wizard_step0() {
- body_wizard();
-}
?>
diff --git a/frontend/pages/wizard/step0.php b/frontend/pages/wizard/step0.php
deleted file mode 120000
index cfe4a1c..0000000
--- a/frontend/pages/wizard/step0.php
+++ /dev/null
@@ -1 +0,0 @@
-../wizard.php \ No newline at end of file
diff --git a/frontend/pages/wizard/step1.php b/frontend/wizard/step1.php
index baef871..baef871 100644
--- a/frontend/pages/wizard/step1.php
+++ b/frontend/wizard/step1.php