Permalink
Browse files

Added drop-down list of existing forms to atlas composition flow

  • Loading branch information...
1 parent 6b09825 commit 55f084e3e524707ed65be3fd54945181db1048b0 Michal Migurski committed Mar 10, 2012
View
@@ -287,8 +287,8 @@ function compose_from_postvars(&$dbh, $post, $user_id)
{
$print['form_id'] = $form['id'];
- if($post['parsed']) {
- $message['fields'] = get_form_fields($dbh, $form['id']);
+ if($form['parsed']) {
+ $message['form_fields'] = get_form_fields($dbh, $form['id']);
} else {
// The form hasn't been parsed yet, probably because
View
@@ -66,17 +66,22 @@ function add_form_id_to_print(&$dbh, $form_id, $print_id)
}
}
- function get_forms(&$dbh, $page)
+ function get_forms(&$dbh, $user_id, $page)
{
list($count, $offset, $perpage, $page) = get_pagination($page);
- $q = sprintf("SELECT id, title, http_method, action_url,
+ $where_user_clause = empty($user_id)
+ ? '1'
+ : sprintf('(user_id = %s)', $dbh->quoteSmart($user_id));
+
+ $q = sprintf("SELECT id, form_url, title, http_method, action_url,
UNIX_TIMESTAMP(created) AS created,
UNIX_TIMESTAMP(parsed) AS parsed,
UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(created) AS age,
user_id
FROM forms
WHERE parsed
+ AND {$where_user_clause}
ORDER BY created DESC
LIMIT %d OFFSET %d",
$count, $offset);
View
@@ -19,7 +19,7 @@ function get_smarty_instance()
$s->assign('base_dir', get_base_dir());
$s->assign('base_href', get_base_href());
$s->assign('constants', get_defined_constants());
- $s->assign('request', array('get' => $_GET, 'uri' => $_SERVER['REQUEST_URI'], 'session' => $_SESSION));
+ $s->assign('request', array('get' => $_GET, 'post' => $_POST, 'uri' => $_SERVER['REQUEST_URI'], 'session' => $_SESSION));
$s->assign('providers', get_map_providers());
$s->register_modifier('nice_relativetime', 'nice_relativetime');
@@ -52,7 +52,8 @@
<div class="container" style="margin-top: 50px;">
<form action="{$base_dir}/make-layout.php" method="POST">
<p style="margin-bottom: 60px;">
- <span style="font-size: 22px;">Give Your Atlas a Name</span><br />
+ <label for="atlas_title" style="font-size: 22px;">Give Your Atlas a Name</label>
+ <br />
<input style="margin-top: 10px; color: grey;" type="text" id='title_input' name="atlas_title" size="60"
placeholder="Untitled"/>
</p>
@@ -64,16 +65,26 @@
enter the URL to your Google form, and we'll do the rest.
</p>
<p>
- <span style="font-size: 16px"><b>Google Form URL</b> (<i>This is Optional.</i>)</span><br />
+ <label for="form_input" style="font-size: 16px"><b>Google Form URL</b> (<i>This is Optional.</i>)</label>
+ <br />
<input style="margin-top: 10px; color: grey;" type="text" id='form_input' name="form_url" size="60"
placeholder="http://"/>
</p>
+ <p>
+ Your recent forms:
+ <select name="form_id">
+ {foreach from=$forms item="form"}
+ {assign var="domain" value=$form.form_url|regex_replace:"#^https?://([^/]+)/.+$#":"(\\1)"}
+ <option value="{$form.id|escape}" label="{$form.title|escape} {$domain|escape}">{$form.title|escape} {$domain|escape}</option>
+ {/foreach}
+ </select>
+ </p>
- <input type="hidden" name="action" value="{$atlas_data.action}">
<input type="hidden" id="page_zoom" name="page_zoom" value="{$atlas_data.page_zoom}">
<input type="hidden" id="paper_size" name="paper_size" value="{$atlas_data.paper_size}">
<input type="hidden" id="orientation" name="orientation" value="{$atlas_data.orientation}">
<input type="hidden" id="provider" name="provider" value="{$atlas_data.provider}">
+
{foreach from=$atlas_data.pages item="page" key="index"}
<input type="hidden" name="pages[{$index}]" value="{$page}">
{/foreach}
@@ -80,17 +80,24 @@
</div>
<div class="clearfloat"></div>
<div style="float: right; margin-top: 60px;">
- <input type="hidden" name="atlas_title" value="{$atlas_data.atlas_title}">
- <input type="hidden" name="form_url" value="{$atlas_data.form_url}">
- <input type="hidden" name="action" value="{$atlas_data.action}">
- <input type="hidden" id="page_zoom" name="page_zoom" value="{$atlas_data.page_zoom}">
- <input type="hidden" id="paper_size" name="paper_size" value="{$atlas_data.paper_size}">
- <input type="hidden" id="orientation" name="orientation" value="{$atlas_data.orientation}">
- <input type="hidden" id="provider" name="provider" value="{$atlas_data.provider}">
- {foreach from=$atlas_data.pages item="page" key="index"}
+ <input type="hidden" name="atlas_title" value="{$request.post.atlas_title}">
+ <input type="hidden" id="page_zoom" name="page_zoom" value="{$request.post.page_zoom}">
+ <input type="hidden" id="paper_size" name="paper_size" value="{$request.post.paper_size}">
+ <input type="hidden" id="orientation" name="orientation" value="{$request.post.orientation}">
+ <input type="hidden" id="provider" name="provider" value="{$request.post.provider}">
+
+ {if $request.post.form_url}
+ <input type="hidden" name="form_url" value="{$request.post.form_url}">
+ {elseif $request.post.form_id}
+ <input type="hidden" name="form_id" value="{$request.post.form_id}">
+ {/if}
+
+ {foreach from=$request.post.pages item="page" key="index"}
<input type="hidden" name="pages[{$index}]" value="{$page}">
{/foreach}
+
<input type="submit" value="Finished!" />
+ <input type="hidden" name="action" value="compose">
</div>
</form>
</div>
View
@@ -15,7 +15,7 @@
$pagination = array('page' => $_GET['page'], 'perpage' => $_GET['perpage']);
- $forms = get_forms($dbh, $pagination);
+ $forms = get_forms($dbh, null, $pagination);
foreach ($forms as $i => $form)
{
View
@@ -8,13 +8,19 @@
$dbh =& get_db_connection();
remember_user($dbh);
+ $forms = array();
+
+ if($user = cookied_user($dbh))
+ $forms = get_forms($dbh, $user['id'], get_pagination(8));
+
/**** ... ****/
$user = cookied_user($dbh);
$user_id = $user['id'];
$sm = get_smarty_instance();
$sm->assign('atlas_data', $_POST);
+ $sm->assign('forms', $forms);
$type = $_GET['type'] ? $_GET['type'] : $_SERVER['HTTP_ACCEPT'];
$type = get_preferred_type($type);
View
@@ -11,7 +11,6 @@
/**** ... ****/
$sm = get_smarty_instance();
- $sm->assign('atlas_data', $_POST);
$type = $_GET['type'] ? $_GET['type'] : $_SERVER['HTTP_ACCEPT'];
$type = get_preferred_type($type);

0 comments on commit 55f084e

Please sign in to comment.