Fixed #55 - export des données au format json

This commit is contained in:
nicosomb 2013-04-21 18:09:25 +02:00
parent 016989b79a
commit 44e77bfa24
5 changed files with 22 additions and 1 deletions

View file

@ -232,6 +232,12 @@ function display_view($view, $id = 0, $full_head = 'yes')
switch ($view)
{
case 'export':
$entries = $store->retrieveAll();
$tpl->assign('export', json_encode($entries));
$tpl->draw('export');
logm('export view');
break;
case 'config':
$tpl->assign('load_all_js', 0);
$tpl->draw('head');
@ -240,7 +246,7 @@ function display_view($view, $id = 0, $full_head = 'yes')
$tpl->draw('js');
$tpl->draw('footer');
logm('config view');
break;
break;
case 'view':
$entry = $store->retrieveOneById($id);

View file

@ -38,6 +38,14 @@ class Sqlite extends Store {
}
}
public function retrieveAll() {
$sql = "SELECT * FROM entries ORDER BY id";
$query = $this->executeQuery($sql, array());
$entries = $query->fetchAll();
return $entries;
}
public function retrieveOneById($id) {
parent::__construct();

View file

@ -17,6 +17,10 @@ class Store {
}
public function retrieveAll() {
}
public function retrieveOneById($id) {
}

View file

@ -3,4 +3,6 @@
<p>Thanks to the bookmarklet, you will be able to easily add a link to your poche. If you don't know how use a bookmarklet, <a href="http://support.mozilla.org/en-US/kb/bookmarklets-perform-common-web-page-tasks">have a look here</a>.</p>
<p>Drag & drop this link to your bookmarks bar and have fun with poche.</p>
<p><a style="cursor: move; border: 1px dashed grey; background: white;" title="i am a bookmarklet, use me !" href="javascript:(function(){var%20url%20=%20location.href%20||%20url;window.open('{$poche_url}?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></p>
<h2>Export</h2>
<p><a href="?view=export" target="_blank">Click here</a> to export your poche datas.</p>
</div>

1
tpl/export.html Normal file
View file

@ -0,0 +1 @@
export {$export}