class Database {
var $handle;
-
- function __construct()
+ private $order = array(
+ 'ia' => 'ORDER BY entries.id',
+ 'id' => 'ORDER BY entries.id DESC',
+ 'ta' => 'ORDER BY lower(entries.title)',
+ 'td' => 'ORDER BY lower(entries.title) DESC',
+ 'default' => 'ORDER BY entries.id'
+ );
+
+ function __construct()
{
switch (STORAGE) {
case 'sqlite':
$query = $this->executeQuery($sql, $params);
}
- public function getEntriesByView($view, $user_id, $limit = '') {
- switch ($_SESSION['sort'])
- {
- case 'ia':
- $order = 'ORDER BY id';
- break;
- case 'id':
- $order = 'ORDER BY id DESC';
+ public function getEntriesByView($view, $user_id, $limit = '', $tag_id = 0) {
+ switch ($view) {
+ case 'archive':
+ $sql = "SELECT * FROM entries WHERE user_id=? AND is_read=? ";
+ $params = array($user_id, 1);
break;
- case 'ta':
- $order = 'ORDER BY lower(title)';
+ case 'fav' :
+ $sql = "SELECT * FROM entries WHERE user_id=? AND is_fav=? ";
+ $params = array($user_id, 1);
break;
- case 'td':
- $order = 'ORDER BY lower(title) DESC';
+ case 'tag' :
+ $sql = "SELECT entries.* FROM entries
+ LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id
+ WHERE entries.user_id=? AND tags_entries.tag_id = ? ";
+ $params = array($user_id, $tag_id);
break;
default:
- $order = 'ORDER BY id';
+ $sql = "SELECT * FROM entries WHERE user_id=? AND is_read=? ";
+ $params = array($user_id, 0);
break;
}
- switch ($view)
- {
+ $sql .= $this->getEntriesOrder().' ' . $limit;
+
+ $query = $this->executeQuery($sql, $params);
+ $entries = $query->fetchAll();
+
+ return $entries;
+ }
+
+ public function getEntriesByViewCount($view, $user_id, $tag_id = 0) {\r
+ switch ($view) {\r
case 'archive':
- $sql = "SELECT * FROM entries WHERE user_id=? AND is_read=? " . $order;
+ $sql = "SELECT count(*) FROM entries WHERE user_id=? AND is_read=? ";\r
$params = array($user_id, 1);
break;
case 'fav' :
- $sql = "SELECT * FROM entries WHERE user_id=? AND is_fav=? " . $order;
+ $sql = "SELECT count(*) FROM entries WHERE user_id=? AND is_fav=? ";\r
$params = array($user_id, 1);
break;
+ case 'tag' :\r
+ $sql = "SELECT count(*) FROM entries\r
+ LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id\r
+ WHERE entries.user_id=? AND tags_entries.tag_id = ? ";\r
+ $params = array($user_id, $tag_id);\r
+ break;\r
default:
- $sql = "SELECT * FROM entries WHERE user_id=? AND is_read=? " . $order;
+ $sql = "SELECT count(*) FROM entries WHERE user_id=? AND is_read=? ";\r
$params = array($user_id, 0);
break;
}
- $sql .= ' ' . $limit;
-
$query = $this->executeQuery($sql, $params);
- $entries = $query->fetchAll();
+ list($count) = $query->fetch();
- return $entries;
+ return $count;\r
}
public function updateContent($id, $content, $user_id) {
$query = $this->executeQuery($sql_action, $params_action);
return $query;
}
+
+ private function getEntriesOrder() {
+ if (isset($_SESSION['sort']) and array_key_exists($_SESSION['sort'], $this->order)) {
+ return $this->order[$_SESSION['sort']];
+ }
+ else {
+ return $this->order['default'];
+ }
+ }
+
}
$tpl_vars = array(
'entry_id' => $id,
'tags' => $tags,
- );
- break;
- case 'tag':
- $entries = $this->store->retrieveEntriesByTag($id, $this->user->getId());
- $tag = $this->store->retrieveTag($id, $this->user->getId());
- $tpl_vars = array(
- 'tag' => $tag,
- 'entries' => $entries,
+ 'entry' => $entry,
);
break;
case 'tags':
Tools::logm('error in view call : entry is null');
}
break;
- default: # home, favorites and archive views
- $entries = $this->store->getEntriesByView($view, $this->user->getId());
+ default: # home, favorites, archive and tag views
$tpl_vars = array(
'entries' => '',
'page_links' => '',
'nb_results' => '',
);
- if (count($entries) > 0) {
- $this->pagination->set_total(count($entries));
+ //if id is given - we retrive entries by tag: id is tag id
+ if ($id) {
+ $tpl_vars['tag'] = $this->store->retrieveTag($id, $this->user->getId());
+ $tpl_vars['id'] = intval($id);
+ }
+
+ $count = $this->store->getEntriesByViewCount($view, $this->user->getId(), $id);
+
+ if ($count > 0) {
+ $this->pagination->set_total($count);
$page_links = str_replace(array('previous', 'next'), array(_('previous'), _('next')),
- $this->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . '&'));
- $datas = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit());
- $tpl_vars['entries'] = $datas;
+ $this->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . (($id)?'&id='.$id:'') . '&' ));
+ $tpl_vars['entries'] = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit(), $id);
$tpl_vars['page_links'] = $page_links;
- $tpl_vars['nb_results'] = count($entries);
+ $tpl_vars['nb_results'] = $count;
}
Tools::logm('display ' . $view . ' view');
break;
{
$views = array(
'install', 'import', 'export', 'config', 'tags',
- 'edit-tags', 'view', 'login', 'error', 'tag'
+ 'edit-tags', 'view', 'login', 'error'
);
if (in_array($view, $views)) {
<li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
<li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
<li><a href="./?view=tags" {% if view == 'tags' %}class="current"{% endif %}>{% trans "tags" %}</a></li>
+ <li><a href="javascript: void(null);" id="pocheit">{% trans "save a link" %}</a></li>
<li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
<li><a class="icon icon-power" href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
- </ul>
\ No newline at end of file
+ </ul>
+
+ {% include '_pocheit-form.twig' %}
========================================================================== */
.messages {
- text-align: center;
+ text-align: left;
+ margin-top: 1em;
}
.messages > * { display: inline-block;}
#article_toolbar a {
padding: 0.3em 0.4em 0.2em;
}
-}
\ No newline at end of file
+}
{% include '_menu.twig' %}
{% endblock %}
{% block content %}
+<div id="article">
+ <h2>{{ entry.title|raw }}</21>
+</div>
{% if tags is empty %}
<div class="notags">no tags</div>
{% endif %}
{% for tag in tags %}<li>{{ tag.value }} <a href="./?action=remove_tag&tag_id={{ tag.id }}&id={{ entry_id }}">✘</a></li>{% endfor %}
</ul>
<form method="post" action="./?action=add_tag">
- <label for="value">Add tags: </label><input type="text" placeholder="interview, editorial, video" id="value" name="value" required="required" />
- <p>{% trans "You can enter multiple tags, separated by commas." %}</p>
<input type="hidden" name="entry_id" value="{{ entry_id }}" />
+ <label for="value">Add tags: </label><input type="text" placeholder="interview, editorial, video" id="value" name="value" required="required" />
<input type="submit" value="Tag" />
+ <p>{% trans "You can enter multiple tags, separated by commas." %}</p>
</form>
<a class="icon icon-reply return" href="./?view=view&id={{ entry_id }}">{% trans "return to article" %}</a>
{% endblock %}
{% include '_menu.twig' %}
{% endblock %}
{% block content %}
+ {% if tag %}
+ <h3>{% trans "Tag" %}: <b>{{ tag.value }}</b></h3>
+ {% endif %}
{% if entries is empty %}
<div class="messages warning"><p>{% trans "No articles found." %}</p></div>
{% else %}
</ul>
<p>{{ entry.content|striptags|slice(0, 300) }}...</p>
</div>
-
+
{% endfor %}
</div>
{% if view == 'home' %}{% if nb_results > 1 %}<a title="{% trans "Mark all the entries as read" %}" href="./?action=archive_all">{{ "Mark all the entries as read" }}</a>{% endif %}{% endif %}
+++ /dev/null
-{% extends "layout.twig" %}
-{% block title %}tag {% endblock %}
-{% block menu %}
-{% include '_menu.twig' %}
-{% endblock %}
-{% block content %}
- <h3>{% trans "Tag" %} {{ tag.value }}</h3>
- {% if entries is empty %}
- <div class="messages warning"><p>{% trans "No link available here!" %}</p></div>
- {% else %}
- {% block pager %}
- {% if nb_results > 1 %}
- <div class="results">
- <div class="nb-results">{{ nb_results }} {% trans "results" %}</div>
- {{ page_links | raw }}
- </div>
- {% endif %}
- {% endblock %}
- <div class="list-entries">
- {% for entry in entries %}
- <div id="entry-{{ entry.id|e }}" class="entrie">
- <h2><a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
- <ul class="tools links">
- <li><a title="{% trans "Toggle mark as read" %}" class="tool icon-check icon {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span>{% trans "Toggle mark as read" %}</span></a></li>
- <li><a title="{% trans "toggle favorite" %}" class="tool icon-star icon {% if entry.is_fav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span>{% trans "toggle favorite" %}</span></a></li>
- <li><a title="{% trans "delete" %}" class="tool delete icon-trash icon" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li>
- <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.url | e | getDomain }}</span></a></li>
- </ul>
- <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
- </div>
- {% endfor %}
- </div>
- {% endif %}
-{% endblock %}
\ No newline at end of file
{% block precontent %}
{% if entries|length > 1 %}
<ul id="sort">
- <li><a href="./?sort=ia&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by date asc" %}" title="{% trans "by date asc" %}" /></a> {% trans "by date" %} <a href="./?sort=id&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by date desc" %}" title="{% trans "by date desc" %}" /></a></li>
- <li><a href="./?sort=ta&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by title asc" %}" title="{% trans "by title asc" %}" /></a> {% trans "by title" %} <a href="./?sort=td&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by title desc" %}" title="{% trans "by title desc" %}" /></a></li>
+ <li><a href="./?sort=ia&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by date asc" %}" title="{% trans "by date asc" %}" /></a> {% trans "by date" %} <a href="./?sort=id&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by date desc" %}" title="{% trans "by date desc" %}" /></a></li>
+ <li><a href="./?sort=ta&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by title asc" %}" title="{% trans "by title asc" %}" /></a> {% trans "by title" %} <a href="./?sort=td&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by title desc" %}" title="{% trans "by title desc" %}" /></a></li>
</ul>
{% endif %}
{% endblock %}
{% include '_menu.twig' %}
{% endblock %}
{% block content %}
+
+<div id="article">
+ <header class="mbm">
+ <h1>{{ entry.title|raw }}</h1>
+ </header>
+</div>
+
{% if tags is empty %}
no tags
{% endif %}
{% for tag in tags %}<li>{{ tag.value }} <a href="./?action=remove_tag&tag_id={{ tag.id }}&id={{ entry_id }}">✘</a></li>{% endfor %}
</ul>
<form method="post" action="./?action=add_tag">
- <label for="value">Add tags: </label><input type="text" placeholder="interview, editorial, video" id="value" name="value" required="required" />
- <p>{% trans "You can enter multiple tags, separated by commas." %}</p>
<input type="hidden" name="entry_id" value="{{ entry_id }}" />
+ <label for="value">Add tags: </label>
+ <input type="text" placeholder="interview, editorial, video" id="value" name="value" required="required" />
<input type="submit" value="Tag" />
+ <p>{% trans "You can enter multiple tags, separated by commas." %}</p>
+
</form>
-<a href="./?view=view&id={{ entry_id }}">{% trans "return to article" %}</a>
+<a href="./?view=view&id={{ entry_id }}">« {% trans "return to article" %}</a>
{% endblock %}
{% block precontent %}
{% if entries|length > 1 %}
<ul id="sort">
- <li><a href="./?sort=ia&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by date asc" %}" title="{% trans "by date asc" %}" /></a> {% trans "by date" %} <a href="./?sort=id&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by date desc" %}" title="{% trans "by date desc" %}" /></a></li>
- <li><a href="./?sort=ta&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by title asc" %}" title="{% trans "by title asc" %}" /></a> {% trans "by title" %} <a href="./?sort=td&view={{ view }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by title desc" %}" title="{% trans "by title desc" %}" /></a></li>
+ <li><a href="./?sort=ia&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by date asc" %}" title="{% trans "by date asc" %}" /></a> {% trans "by date" %} <a href="./?sort=id&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by date desc" %}" title="{% trans "by date desc" %}" /></a></li>
+ <li><a href="./?sort=ta&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by title asc" %}" title="{% trans "by title asc" %}" /></a> {% trans "by title" %} <a href="./?sort=td&view={{ view }}&id={{ id }}"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by title desc" %}" title="{% trans "by title desc" %}" /></a></li>
</ul>
{% endif %}
{% endblock %}
{% block content %}
+ {% if tag %}
+ <h3>{% trans "Tag" %}: <b>{{ tag.value }}</b></h3>
+ {% endif %}
+
{% if entries is empty %}
<div class="messages warning"><p>{% trans "No articles found." %}</p></div>
{% else %}
+++ /dev/null
-{% extends "layout.twig" %}
-{% block title %}tag {% endblock %}
-{% block menu %}
-{% include '_menu.twig' %}
-{% endblock %}
-{% block content %}
- <h3>{% trans "Tag" %} {{ tag.value }}</h3>
- {% if entries is empty %}
- <div class="messages warning"><p>{% trans "No link available here!" %}</p></div>
- {% else %}
- {% block pager %}
- {% if nb_results > 1 %}
- <div class="results">
- <div class="nb-results">{{ nb_results }} {% trans "results" %}</div>
- {{ page_links | raw }}
- </div>
- {% endif %}
- {% endblock %}
- {% for entry in entries %}
- <div id="entry-{{ entry.id|e }}" class="entrie">
- <h2><a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
- <ul class="tools">
- <li><a title="{% trans "toggle mark as read" %}" class="tool {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span>{% trans "toggle mark as read" %}</span></a></li>
- <li><a title="{% trans "toggle favorite" %}" class="tool {% if entry.is_fav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span>{% trans "toggle favorite" %}</span></a></li>
- <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li>
- <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.url | e | getDomain }}</span></a></li>
- <li><a target="_blank" title="{% trans "estimated reading time:" %} {{ entry.content| getReadingTime }} min" class="reading-time"><span>{{ entry.content| getReadingTime }} min</span></a></li>
- </ul>
- <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
- </div>
- {% endfor %}
- {% endif %}
-{% endblock %}
\ No newline at end of file
<header class="mbm">
<h1>{{ entry.title|raw }}</h1>
</header>
- <aside class="tags">
- {% trans "tags:" %} {% for tag in tags %}<a href="./?view=tag&id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}<a href="./?view=edit-tags&id={{ entry.id|e }}" title="{% trans "Edit tags" %}">✎</a>
- </aside>
+ {% block tags %}
+ <aside class="tags">
+ {% trans "tags:" %} {% for tag in tags %}<a href="./?view=tag&id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}<a href="./?view=edit-tags&id={{ entry.id|e }}" title="{% trans "Edit tags" %}">✎</a>
+ </aside>
+ {% endblock %}
<article>
{{ content | raw }}
</article>
+ {{ block('tags') }}
</div>
<script src="{{ poche_url }}/themes/{{ constant('DEFAULT_THEME') }}/js/restoreScroll.js"></script>
<script type="text/javascript">
$('#article_toolbar .tool.top').parent().hide();
}
});
- </script>
+ </script>
{% endblock %}
a.bad-display span {
background-image: url('../img/solarized-dark/bad-display.png');
+}
+
+.arrow-down {
+ width: 0px;
+ height: 0px;
+ border-style: solid;
+ border-width: 10px 10px 0 10px;
+ border-color: #586E75 transparent transparent transparent;
+
+ position: absolute;
+ margin-top: 1.5em;
+ margin-left: -30px;
}
\ No newline at end of file
a.bad-display span {
background-image: url('../img/solarized/bad-display.png');
+}
+
+.arrow-down {
+ width: 0px;
+ height: 0px;
+ border-style: solid;
+ border-width: 10px 10px 0 10px;
+ border-color: #93A1A1 transparent transparent transparent;
+
+ position: absolute;
+ margin-top: 1.5em;
+ margin-left: -30px;
}
\ No newline at end of file