Fixed #13 - tri par date / tri par titre

This commit is contained in:
nicosomb 2013-04-16 12:58:03 +02:00
parent 139769aa24
commit 9fee2e7266
9 changed files with 42 additions and 13 deletions

View File

@ -32,6 +32,21 @@ header {
color: #F1F1F1;
}
#main ul#sort {
padding: 0;
list-style-type: none;
text-align: center;
}
#main ul#sort li {
display: inline;
font-size: 0.9em;
}
#main ul#sort img:hover {
cursor: pointer;
}
#main, #article {
margin: 0 auto;
}

BIN
img/down.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

BIN
img/up.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

View File

@ -35,8 +35,8 @@ if (!isset($_SESSION['token_poche'])) {
}
# Traitement des paramètres et déclenchement des actions
$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'index';
$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
$_SESSION['view'] = (isset ($_GET['view'])) ? htmlentities($_GET['view']) : 'index';
$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
$url = (isset ($_GET['url'])) ? $_GET['url'] : '';

View File

@ -182,7 +182,7 @@ function action_to_do($action, $id, $url, $token)
/**
* Détermine quels liens afficher : home, fav ou archives
*/
function display_view()
function display_view($view)
{
global $db;
@ -205,7 +205,7 @@ function display_view()
break;
}
switch ($_SESSION['view'])
switch ($view)
{
case 'archive':
$sql = "SELECT * FROM entries WHERE is_read=? " . $order;

View File

@ -10,10 +10,10 @@
include dirname(__FILE__).'/inc/config.php';
$entries = display_view();
$entries = display_view($view);
$tpl->assign('title', 'poche, a read it later open source system');
$tpl->assign('view', $_SESSION['view']);
$tpl->assign('view', $view);
$tpl->assign('poche_url', get_poche_url());
$tpl->assign('entries', $entries);
$tpl->assign('load_all_js', 1);

View File

@ -22,6 +22,6 @@ function toggle_archive(element, id, token, view_article) {
}
}
function sort_links(sort, token) {
$('#content').load('process.php', { sort: sort, token: token } );
function sort_links(view, sort, token) {
$('#content').load('process.php', { view: view, sort: sort, token: token } );
}

16
process.php Normal file
View File

@ -0,0 +1,16 @@
<?php
/**
* poche, a read it later open source system
*
* @category poche
* @author Nicolas Lœuillet <support@inthepoche.com>
* @copyright 2013
* @license http://www.wtfpl.net/ see COPYING file
*/
include dirname(__FILE__).'/inc/config.php';
$entries = display_view($view);
$tpl->assign('token', $_SESSION['token_poche']);
$tpl->assign('entries', $entries);
$tpl->draw('entries');

View File

@ -9,10 +9,8 @@
<li><a href="?view=archive" {if="$view == 'archive'"}class="current"{/if}>archive</a></li>
<li><a style="cursor: move" 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></li>
</ul>
<!-- <ul>
<li onclick="sort_links('ia', '{$token}');">tri par id asc</li>
<li onclick="sort_links('id', '{$token}');">tri par id desc</li>
<li onclick="sort_links('ta', '{$token}');">tri par title asc</li>
<li onclick="sort_links('td', '{$token}');">tri par title desc</li>
</ul> -->
<ul id="sort">
<li><img src="img/up.png" onclick="sort_links('{$view}', 'ia', '{$token}');" title="by date asc" /> by date <img src="img/down.png" onclick="sort_links('{$view}', 'id', '{$token}');" title="by date desc" /></li>
<li><img src="img/up.png" onclick="sort_links('{$view}', 'ta', '{$token}');" title="by title asc" /> by title <img src="img/down.png" onclick="sort_links('{$view}', 'td', '{$token}');" title="by title desc" /></li>
</ul>
<div id="content">