aboutsummaryrefslogtreecommitdiff
path: root/app/layout/nav_menu.phtml
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-21 16:46:36 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-21 16:55:19 +0200
commit80cffa6de51771cd80995fb1c4f1e04ee868eb45 (patch)
tree5199c6512140b804e2c456d263d40816ab79a6eb /app/layout/nav_menu.phtml
parent8a7bab3a55442f85553ab1d897084e89c10f7e05 (diff)
Views are in dedicated actions + improve Context
- Seperate normal, global and rss outputs in dedicated actions (NOT WORKING YET!) - Rewrite aside_flux and nav_menu to use Context object - Improve Context object See https://github.com/marienfressinaud/FreshRSS/issues/634
Diffstat (limited to 'app/layout/nav_menu.phtml')
-rw-r--r--app/layout/nav_menu.phtml205
1 files changed, 47 insertions, 158 deletions
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml
index 1a26422df..440e4d0b6 100644
--- a/app/layout/nav_menu.phtml
+++ b/app/layout/nav_menu.phtml
@@ -1,6 +1,5 @@
-<?php
- $actual_view = Minz_Request::param('output', 'normal');
-?>
+<?php $actual_view = Minz_Request::actionName(); ?>
+
<div class="nav_menu">
<?php if ($actual_view === 'normal') { ?>
<a class="btn toggle_aside" href="#aside_flux"><?php echo _i('category'); ?></a>
@@ -9,82 +8,24 @@
<?php if (FreshRSS_Auth::hasAccess()) { ?>
<div id="nav_menu_actions" class="stick">
<?php
- $url_state = $this->url;
-
- if ($this->state & FreshRSS_Entry::STATE_READ) {
- $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_READ;
- $checked = 'true';
- $class = 'active';
- } else {
- $url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_READ;
- $checked = 'false';
- $class = '';
- }
- ?>
- <a id="toggle-read"
- class="btn <?php echo $class; ?>"
- aria-checked="<?php echo $checked; ?>"
- href="<?php echo Minz_Url::display($url_state); ?>"
- title="<?php echo _t('show_read'); ?>">
- <?php echo _i('read'); ?>
- </a>
-
- <?php
- if ($this->state & FreshRSS_Entry::STATE_NOT_READ) {
- $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_NOT_READ;
- $checked = 'true';
- $class = 'active';
- } else {
- $url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_NOT_READ;
- $checked = 'false';
- $class = '';
- }
- ?>
- <a id="toggle-unread"
- class="btn <?php echo $class; ?>"
- aria-checked="<?php echo $checked; ?>"
- href="<?php echo Minz_Url::display($url_state); ?>"
- title="<?php echo _t('show_not_reads'); ?>">
- <?php echo _i('unread'); ?>
- </a>
-
- <?php
- if ($this->state & FreshRSS_Entry::STATE_FAVORITE || $this->get_c == 's') {
- $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_FAVORITE;
- $checked = 'true';
- $class = 'active';
- } else {
- $url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_FAVORITE;
- $checked = 'false';
- $class = '';
- }
- ?>
- <a id="toggle-favorite"
- class="btn <?php echo $class; ?>"
- aria-checked="<?php echo $checked; ?>"
- href="<?php echo Minz_Url::display($url_state); ?>"
- title="<?php echo _t('show_favorite'); ?>">
- <?php echo _i('starred'); ?>
- </a>
-
- <?php
- if ($this->state & FreshRSS_Entry::STATE_NOT_FAVORITE) {
- $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_NOT_FAVORITE;
- $checked = 'true';
- $class = 'active';
- } else {
- $url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_NOT_FAVORITE;
- $checked = 'false';
- $class = '';
- }
+ $states = array(
+ 'read' => FreshRSS_Entry::STATE_READ,
+ 'unread' => FreshRSS_Entry::STATE_NOT_READ,
+ 'starred' => FreshRSS_Entry::STATE_FAVORITE,
+ 'non-starred' => FreshRSS_Entry::STATE_NOT_FAVORITE,
+ );
+
+ foreach ($states as $state_str => $state) {
+ $state_enabled = FreshRSS_Context::isStateEnabled($state);
+ $url_state = Minz_Request::currentRequest();
+ $url_state['params']['state'] = FreshRSS_Context::getRevertState($state);
?>
- <a id="toggle-not-favorite"
- class="btn <?php echo $class; ?>"
- aria-checked="<?php echo $checked; ?>"
- href="<?php echo Minz_Url::display($url_state); ?>"
- title="<?php echo _t('show_not_favorite'); ?>">
- <?php echo _i('non-starred'); ?>
- </a>
+ <a id="toggle-<?php echo $state_str; ?>"
+ class="btn <?php echo $state_enabled ? 'active' : ''; ?>"
+ aria-checked="<?php echo $state_enabled ? 'true' : 'false'; ?>"
+ title="<?php echo _t($state_str); ?>"
+ href="<?php echo Minz_Url::display($url_state); ?>"><?php echo _i($state_str); ?></a>
+ <?php } ?>
<div class="dropdown">
<div id="dropdown-query" class="dropdown-target"></div>
@@ -109,7 +50,7 @@
<?php } ?>
<?php
- $url_query = $this->url;
+ $url_query = Minz_Request::currentRequest();;
$url_query['c'] = 'configure';
$url_query['a'] = 'addQuery';
?>
@@ -117,74 +58,26 @@
</ul>
</div>
</div>
+
<?php
- $get = false;
+ $get = FreshRSS_Context::currentGet();
+ $next_step = FreshRSS_Context::nextStep();
$string_mark = _t('mark_all_read');
- if ($this->get_f) {
- $get = 'f_' . $this->get_f;
+ if ($get[0] == 'f') {
$string_mark = _t('mark_feed_read');
- } elseif ($this->get_c && $this->get_c != 'a') {
- if ($this->get_c === 's') {
- $get = 's';
- } else {
- $get = 'c_' . $this->get_c;
- }
+ } elseif ($get[0] == 'c') {
$string_mark = _t('mark_cat_read');
}
- $nextGet = $get;
- if (FreshRSS_Context::$conf->onread_jump_next && strlen($get) > 2) {
- $anotherUnreadId = '';
- $foundCurrent = false;
- switch ($get[0]) {
- case 'c':
- foreach ($this->cat_aside as $cat) {
- if ($cat->id() == $this->get_c) {
- $foundCurrent = true;
- continue;
- }
- if ($cat->nbNotRead() <= 0) continue;
- $anotherUnreadId = $cat->id();
- if ($foundCurrent) break;
- }
- $nextGet = empty($anotherUnreadId) ? 'a' : 'c_' . $anotherUnreadId;
- break;
- case 'f':
- foreach ($this->cat_aside as $cat) {
- if ($cat->id() == $this->get_c) {
- foreach ($cat->feeds() as $feed) {
- if ($feed->id() == $this->get_f) {
- $foundCurrent = true;
- continue;
- }
- if ($feed->nbNotRead() <= 0) continue;
- $anotherUnreadId = $feed->id();
- if ($foundCurrent) break;
- }
- break;
- }
- }
- $nextGet = empty($anotherUnreadId) ? 'c_' . $this->get_c : 'f_' . $anotherUnreadId;
- break;
- }
- }
-
- $p = isset($this->entries[0]) ? $this->entries[0] : null;
- $idMax = $p === null ? (time() - 1) . '000000' : $p->id();
-
- if ($this->order === 'ASC') { //In this case we do not know but we guess idMax
- $idMax2 = (time() - 1) . '000000';
- if (strcmp($idMax2, $idMax) > 0) {
- $idMax = $idMax2;
- }
- }
- $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('get' => $get, 'nextGet' => $nextGet, 'idMax' => $idMax));
- $output = Minz_Request::param('output', '');
- if ($output != '' && FreshRSS_Context::$conf->view_mode !== $output) {
- $arUrl['params']['output'] = $output;
- }
- $markReadUrl = Minz_Url::display($arUrl);
- Minz_Session::_param('markReadUrl', $markReadUrl);
+ $mark_read_url = array(
+ 'c' => 'entry',
+ 'a' => 'read',
+ 'params' => array(
+ 'get' => $get,
+ 'nextGet' => $next_step['get'],
+ 'idMax' => $next_step['idMax']
+ )
+ );
?>
<form id="mark-read-menu" method="post" style="display: none"></form>
@@ -193,7 +86,7 @@
<?php $confirm = FreshRSS_Context::$conf->reading_confirm ? 'confirm' : ''; ?>
<button class="read_all btn <?php echo $confirm; ?>"
form="mark-read-menu"
- formaction="<?php echo $markReadUrl; ?>"
+ formaction="<?php echo Minz_Url::display($mark_read_url); ?>"
type="submit"><?php echo _t('mark_read'); ?></button>
<div class="dropdown">
@@ -206,15 +99,16 @@
<li class="item">
<button class="as-link <?php echo $confirm; ?>"
form="mark-read-menu"
- formaction="<?php echo $markReadUrl; ?>"
+ formaction="<?php echo Minz_Url::display($mark_read_url); ?>"
type="submit"><?php echo $string_mark; ?></button>
</li>
<li class="separator"></li>
<?php
- $mark_before_today = $arUrl;
- $mark_before_today['params']['idMax'] = $this->today . '000000';
- $mark_before_one_week = $arUrl;
- $mark_before_one_week['params']['idMax'] = ($this->today - 604800) . '000000';
+ $today = @strtotime('today');
+ $mark_before_today = $mark_read_url;
+ $mark_before_today['params']['idMax'] = $today . '000000';
+ $mark_before_one_week = $mark_read_url;
+ $mark_before_one_week['params']['idMax'] = ($today - 604800) . '000000';
?>
<li class="item">
<button class="as-link <?php echo $confirm; ?>"
@@ -233,25 +127,20 @@
</div>
<?php } ?>
- <?php $url_output = $this->url; ?>
+ <?php $url_output = Minz_Request::currentRequest(); ?>
<div class="stick" id="nav_menu_views">
- <?php $url_output['params']['output'] = 'normal'; ?>
+ <?php $url_output['a'] = 'normal'; ?>
<a class="view_normal btn <?php echo $actual_view == 'normal'? 'active' : ''; ?>" title="<?php echo _t('normal_view'); ?>" href="<?php echo Minz_Url::display($url_output); ?>">
<?php echo _i("view-normal"); ?>
</a>
- <?php $url_output['a'] = 'global'; unset($url_output['params']['output']); ?>
+ <?php $url_output['a'] = 'global'; ?>
<a class="view_global btn <?php echo $actual_view == 'global'? 'active' : ''; ?>" title="<?php echo _t('global_view'); ?>" href="<?php echo Minz_Url::display($url_output); ?>">
<?php echo _i("view-global"); ?>
</a>
- <?php $url_output['params']['output'] = 'reader'; ?>
- <a class="view_reader btn <?php echo $actual_view == 'reader'? 'active' : ''; ?>" title="<?php echo _t('reader_view'); ?>" href="<?php echo Minz_Url::display($url_output); ?>">
- <?php echo _i("view-reader"); ?>
- </a>
-
<?php
- $url_output['params']['output'] = 'rss';
+ $url_output['a'] = 'rss';
if (FreshRSS_Context::$conf->token) {
$url_output['params']['token'] = FreshRSS_Context::$conf->token;
}
@@ -284,7 +173,7 @@
</div>
<?php
- if ($this->order === 'DESC') {
+ if (FreshRSS_Context::$order === 'DESC') {
$order = 'ASC';
$icon = 'up';
$title = 'older_first';
@@ -293,7 +182,7 @@
$icon = 'down';
$title = 'newer_first';
}
- $url_order = $this->url;
+ $url_order = Minz_Request::currentRequest();
$url_order['params']['order'] = $order;
?>
<a id="toggle-order" class="btn" href="<?php echo Minz_Url::display($url_order); ?>" title="<?php echo _t($title); ?>">