Permalink
Browse files

Completed linkage from prints to scans

  • Loading branch information...
1 parent a6c14de commit a53499f9909abea587823a658e52998679be3b1f Michal Migurski committed Mar 19, 2012
Showing with 93 additions and 88 deletions.
  1. +11 −0 site/lib/lib.scans.php
  2. +65 −80 site/templates/print.htmlf.tpl
  3. +17 −8 site/www/print.php
View
@@ -96,6 +96,11 @@ function get_scans(&$dbh, $args, $page, $include_private=false)
$where_clauses[] = sprintf('(user_id = %s)', $dbh->quoteSmart($args['user']));
}
+ if(isset($args['print']))
+ {
+ $where_clauses[] = sprintf('(print_id = %s)', $dbh->quoteSmart($args['print']));
+ }
+
$q = sprintf("SELECT place_name, place_woeid,
region_name, region_woeid,
country_name, country_woeid,
@@ -279,6 +284,12 @@ function get_scan_notes(&$dbh, $args, $page)
$where_clauses = array('1');
+ if(is_array($args['scans']))
+ {
+ $scan_ids = array_map(array(&$dbh, 'quoteSmart'), $args['scans']);
+ $where_clauses[] = sprintf('(scan_id IN (%s))', join(',', $scan_ids));
+ }
+
if(isset($args['scan']))
{
$where_clauses[] = sprintf('(scan_id = %s)', $dbh->quoteSmart($args['scan']));
@@ -183,97 +183,82 @@
{/literal}
</script>
- {if $print.selected_page}
- <div class="overview_print" id="overview_map"></div>
- <h1>
- Untitled {$pages.west}
- </h1>
- <p>
- <b>
- {if $print.place_woeid}
- <a href="{$base_dir}/atlases.php?place={$print.place_woeid}">{$print.place_name|nice_placename}</a>,
- {/if}
- {if $print.country_woeid}
- <a href="{$base_dir}/atlases.php?place={$print.country_woeid}">{$print.country_name|nice_placename}</a>
- {/if}
- </b><br>
-
- Created by <a href='{$base_dir}/atlases.php?user={$print.user_id}'>{$user_name}</a>,
- <a href="{$base_dir}/atlases.php?month={"Y-m"|@date:$print.created}">{$print.age|nice_relativetime|escape}</a>
- </p>
- <ul><li><a href="{$print.pdf_url}"><b>Download PDF</b></a></li></ul>
-
- <div class="print" id="map">
- <div id="canvas"></div>
- </div>
-
- <div class="clearfloat"></div>
- <br clear="all">
-
- <h2>
- Page {$print.selected_page.page_number}
- </h2>
+ <div class="overview_print" id="overview_map"></div>
+ <h1>
+ Untitled
+ </h1>
+ <p>
+ <b>
+ {if $print.place_woeid}
+ <a href="{$base_dir}/atlases.php?place={$print.place_woeid}">{$print.place_name|nice_placename}</a>,
+ {/if}
+ {if $print.country_woeid}
+ <a href="{$base_dir}/atlases.php?place={$print.country_woeid}">{$print.country_name|nice_placename}</a>
+ {/if}
+ </b><br>
+ Created by <a href='{$base_dir}/atlases.php?user={$print.user_id}'>{$user.name}</a>,
+ <a href="{$base_dir}/atlases.php?month={"Y-m"|@date:$print.created}">{$print.age|nice_relativetime|escape}</a>
+ <br>
+ {$pages|@count}
+ {if $pages|@count == 1}
+ page
+ {else}
+ pages
+ {/if}
+ </p>
+ <ul><li><a href="{$print.pdf_url}"><b>Download PDF</b></a></li></ul>
+
+ <div class="print" id="map">
+ <div id="canvas"></div>
+ </div>
+
+ <div class="clearfloat"></div>
+
+ <h2>Scans</h2>
+
+ <ul>
+ {foreach from=$scans item="scan"}
+ <li>
+ <a href="scan.php?id={$scan.id|escape}">Scan {$scan.id|escape}</a>, {$scan.age|nice_relativetime|escape}
+ </li>
+ {/foreach}
+ </ul>
+
+ <h2>Notes</h2>
+
+ <ul>
+ {foreach from=$notes item="note"}
+ <li>
+ <i>{$note.note|escape}</i> on <a href="scan.php?id={$note.scan_id|escape}">scan {$note.scan_id|escape}</a>
+ </li>
+ {/foreach}
+ </ul>
+
+ {if $print.selected_page}
+ <h2>Page {$print.selected_page.page_number}</h2>
+
<div class="atlasPage">
<img src="{$print.selected_page.preview_url}" alt="printed page" name="atlasPage" id="atlasPage">
<br>
<span class="atlasPageNumber">{$print.selected_page.page_number}</span>
</div>
+
{else}
- <div class="overview_print" id="overview_map"></div>
- <h1>
- Untitled
- </h1>
- <p>
- <b>
- {if $print.place_woeid}
- <a href="{$base_dir}/atlases.php?place={$print.place_woeid}">{$print.place_name|nice_placename}</a>,
- {/if}
- {if $print.country_woeid}
- <a href="{$base_dir}/atlases.php?place={$print.country_woeid}">{$print.country_name|nice_placename}</a>
- {/if}
- </b><br>
-
- Created by <a href='{$base_dir}/atlases.php?user={$print.user_id}'>{$user_name}</a>,
- <a href="{$base_dir}/atlases.php?month={"Y-m"|@date:$print.created}">{$print.age|nice_relativetime|escape}</a>
- <br>
- {$pages|@count}
- {if $pages|@count == 1}
- page
- {else}
- pages
- {/if}
- </p>
- <ul><li><a href="{$print.pdf_url}"><b>Download PDF</b></a></li></ul>
-
- <div class="print" id="map">
- <div id="canvas"></div>
- </div>
-
- <div class="clearfloat"></div>
+ <h2 class="pageCount">{$pages|@count} page{if $pages|@count > 1}s{/if}</h2>
- <h2 class="pageCount">
- {$pages|@count}
- {if $pages|@count == 1}
- page
- {else}
- pages
- {/if}
- </h2>
-
- {foreach from=$pages item="page"}
- <div class="atlasPage">
- <a href="{$base_dir}/print.php?id={$print.id}/{$page.page_number}">
- <img src="{$page.preview_url}" alt="printed page" name="atlasPage" id="atlasPage">
- </a>
- <br>
- <span class="atlasPageNumber">{$page.page_number}</span>
- </div>
- {/foreach}
+ {foreach from=$pages item="page"}
+ <div class="atlasPage">
+ <a href="{$base_dir}/print.php?id={$print.id}/{$page.page_number}">
+ <img src="{$page.preview_url}" alt="printed page" name="atlasPage" id="atlasPage">
+ </a>
+ <br>
+ <span class="atlasPageNumber">{$page.page_number}</span>
+ </div>
+ {/foreach}
{/if}
{else}
-
<div class="smallContainer">
<p>Preparing your atlas... ({$print.progress*100|string_format:"%d"}% complete)</p>
<div class="progressBarCase">
View
@@ -14,22 +14,31 @@
$context->sm->assign('print', $print);
-
- if ($print['selected_page'])
- {
+ if($print['selected_page']) {
$pages = array($print['selected_page']);
+
} else {
$pages = get_print_pages($context->db, $print_id);
}
$context->sm->assign('pages', $pages);
- $user = get_user($context->db, $print['user_id']);
- if ($user['name'])
+ if($user = get_user($context->db, $print['user_id']))
{
- $context->sm->assign('user_name', $user['name']);
- } else {
- $context->sm->assign('user_name', 'Anonymous');
+ $context->sm->assign('user', $user);
+ }
+
+ if($scans = get_scans($context->db, array('print' => $print['id'])))
+ {
+ $note_args = array('scans' => array());
+
+ foreach($scans as $scan)
+ $note_args['scans'][] = $scan['id'];
+
+ $notes = get_scan_notes($context->db, $note_args);
+
+ $context->sm->assign('scans', $scans);
+ $context->sm->assign('notes', $notes);
}
if($context->type == 'text/html') {

0 comments on commit a53499f

Please sign in to comment.