aboutsummaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-30 01:03:32 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-30 01:03:32 +0100
commit92efd68a3a13e49fe7bbfb8441611c0dcd639415 (patch)
treee6228848744b9369ad4e4e52c541075f5c723b6d /app/views
parent220341b40642771f9b5db97296edfb1913182464 (diff)
Début de mode multi-utilisateur avec http_auth
+ Légère optimisation de Minz_View. + Encore plus de tests de bibliothèques dans install.php Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126 et https://github.com/marienfressinaud/FreshRSS/issues/303
Diffstat (limited to 'app/views')
-rw-r--r--app/views/configure/users.phtml51
-rw-r--r--app/views/helpers/javascript_vars.phtml2
-rw-r--r--app/views/helpers/view/normal_view.phtml60
-rw-r--r--app/views/index/index.phtml45
4 files changed, 90 insertions, 68 deletions
diff --git a/app/views/configure/users.phtml b/app/views/configure/users.phtml
index 7e8edf9af..db57448f6 100644
--- a/app/views/configure/users.phtml
+++ b/app/views/configure/users.phtml
@@ -22,20 +22,11 @@
<label class="group-name" for="mail_login"><?php echo Minz_Translate::t('persona_connection_email'); ?></label>
<?php $mail = $this->conf->mail_login; ?>
<div class="group-controls">
- <input type="email" id="mail_login" name="mail_login" value="<?php echo $mail ? $mail : ''; ?>" placeholder="<?php echo Minz_Translate::t('blank_to_disable'); ?>" />
+ <input type="email" id="mail_login" name="mail_login" value="<?php echo $mail ? $mail : ''; ?>" placeholder="alice@example.net" />
<noscript><b><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></b></noscript>
</div>
</div>
- <div class="form-group">
- <label class="group-name" for="token"><?php echo Minz_Translate::t('auth_token'); ?></label>
- <?php $token = $this->conf->token; ?>
- <div class="group-controls">
- <input type="text" id="token" name="token" value="<?php echo $token; ?>" placeholder="<?php echo Minz_Translate::t('blank_to_disable'); ?>"/>
- <?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('explain_token', Minz_Url::display(null, 'html', true), $token); ?>
- </div>
- </div>
-
<div class="form-group form-actions">
<div class="group-controls">
<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t('save'); ?></button>
@@ -48,20 +39,11 @@
<legend><?php echo Minz_Translate::t('users'); ?></legend>
<div class="form-group">
- <div class="group-controls">
- <label class="checkbox" for="anon_access">
- <input type="checkbox" name="anon_access" id="anon_access" value="1"<?php echo Minz_Configuration::allowAnonymous() ? ' checked="checked"' : ''; ?> />
- <?php echo Minz_Translate::t('allow_anonymous', Minz_Configuration::defaultUser()); ?>
- </label>
- </div>
- </div>
-
- <div class="form-group">
<label class="group-name" for="auth_type"><?php echo Minz_Translate::t('auth_type'); ?></label>
<div class="group-controls">
<select id="auth_type" name="auth_type">
- <option value="none"<?php echo Minz_Configuration::authType() === 'none' ? ' selected="selected"' : ''; ?>>None (dangerous)</option>
- <option value="http_auth"<?php echo Minz_Configuration::authType() === 'http_auth' ? ' selected="selected"' : ''; ?>>HTTP Auth</option>
+ <option value="none"<?php echo Minz_Configuration::authType() === 'none' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t('auth_none'); ?></option>
+ <option value="http_auth"<?php echo Minz_Configuration::authType() === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>>HTTP Auth</option>
<option value="persona"<?php echo Minz_Configuration::authType() === 'persona' ? ' selected="selected"' : ''; ?>>Mozilla Persona</option>
</select>
</div>
@@ -75,7 +57,32 @@
echo '<option>', $user, '</option>';
}
?></select>
- (not implemented yet)
+ </div>
+ </div>
+
+ <div class="form-group form-actions">
+ <div class="group-controls">
+ <button type="submit" class="btn btn-important"><?php echo Minz_Translate::t('save'); ?></button>
+ <button type="reset" class="btn"><?php echo Minz_Translate::t('cancel'); ?></button>
+ </div>
+ </div>
+
+ <legend>Mozilla Persona</legend>
+ <div class="form-group">
+ <div class="group-controls">
+ <label class="checkbox" for="anon_access">
+ <input type="checkbox" name="anon_access" id="anon_access" value="1"<?php echo Minz_Configuration::allowAnonymous() ? ' checked="checked"' : ''; ?> />
+ <?php echo Minz_Translate::t('allow_anonymous', Minz_Configuration::defaultUser()); ?>
+ </label>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="group-name" for="token"><?php echo Minz_Translate::t('auth_token'); ?></label>
+ <?php $token = $this->conf->token; ?>
+ <div class="group-controls">
+ <input type="text" id="token" name="token" value="<?php echo $token; ?>" placeholder="<?php echo Minz_Translate::t('blank_to_disable'); ?>"/>
+ <?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('explain_token', Minz_Url::display(null, 'html', true), $token); ?>
</div>
</div>
diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml
index 8f508487c..8419b9391 100644
--- a/app/views/helpers/javascript_vars.phtml
+++ b/app/views/helpers/javascript_vars.phtml
@@ -29,7 +29,7 @@
if ($mail != 'null') {
$mail = '"' . $mail . '"';
}
- echo 'use_persona=', login_is_conf ($this->conf) ? 'true' : 'false',
+ echo 'use_persona=', Minz_Configuration::authType() === 'persona' ? 'true' : 'false',
',url_freshrss="', _url ('index', 'index'), '",',
'url_login="', _url ('index', 'login'), '",',
'url_logout="', _url ('index', 'logout'), '",',
diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml
index f59cae2b8..1b4388796 100644
--- a/app/views/helpers/view/normal_view.phtml
+++ b/app/views/helpers/view/normal_view.phtml
@@ -7,39 +7,48 @@ if (!empty($this->entries)) {
$display_today = true;
$display_yesterday = true;
$display_others = true;
-
- $logged = !login_is_conf ($this->conf) || is_logged ();
- $shaarli = $this->conf->sharing ('shaarli');
- $poche = $this->conf->sharing ('poche');
- $diaspora = $this->conf->sharing ('diaspora');
+ $shaarli = $this->loginOk && $this->conf->sharing ('shaarli');
+ $poche = $this->loginOk && $this->conf->sharing ('poche');
+ $diaspora = $this->loginOk && $this->conf->sharing ('diaspora');
$twitter = $this->conf->sharing ('twitter');
$google_plus = $this->conf->sharing ('g+');
$facebook = $this->conf->sharing ('facebook');
$email = $this->conf->sharing ('email');
$print = $this->conf->sharing ('print');
- $today = $this->today;
$hidePosts = !$this->conf->display_posts;
$lazyload = $this->conf->lazyload;
+ $topline_read = $this->conf->topline_read;
+ $topline_favorite = $this->conf->topline_favorite;
+ $topline_date = $this->conf->topline_date;
+ $topline_link = $this->conf->topline_link;
+ $bottomline_read = $this->conf->bottomline_read;
+ $bottomline_favorite = $this->conf->bottomline_favorite;
+ $bottomline_sharing = $this->conf->bottomline_sharing && (
+ $shaarli || $poche || $diaspora || $twitter ||
+ $google_plus || $facebook || $email);
+ $bottomline_tags = $this->conf->bottomline_tags;
+ $bottomline_date = $this->conf->bottomline_date;
+ $bottomline_link = $this->conf->bottomline_link;
?>
<div id="stream" class="normal<?php echo $hidePosts ? ' hide_posts' : ''; ?>">
<?php foreach ($this->entries as $item) { ?>
- <?php if ($display_today && $item->isDay (FreshRSS_Days::TODAY, $today)) { ?>
+ <?php if ($display_today && $item->isDay (FreshRSS_Days::TODAY, $this->today)) { ?>
<div class="day" id="day_today">
<?php echo Minz_Translate::t ('today'); ?>
<span class="date"> - <?php echo timestamptodate (time (), false); ?></span>
<span class="name"><?php echo $this->currentName; ?></span>
</div>
<?php $display_today = false; } ?>
- <?php if ($display_yesterday && $item->isDay (FreshRSS_Days::YESTERDAY, $today)) { ?>
+ <?php if ($display_yesterday && $item->isDay (FreshRSS_Days::YESTERDAY, $this->today)) { ?>
<div class="day" id="day_yesterday">
<?php echo Minz_Translate::t ('yesterday'); ?>
<span class="date"> - <?php echo timestamptodate (time () - 86400, false); ?></span>
<span class="name"><?php echo $this->currentName; ?></span>
</div>
<?php $display_yesterday = false; } ?>
- <?php if ($display_others && $item->isDay (FreshRSS_Days::BEFORE_YESTERDAY, $today)) { ?>
+ <?php if ($display_others && $item->isDay (FreshRSS_Days::BEFORE_YESTERDAY, $this->today)) { ?>
<div class="day" id="day_before_yesterday">
<?php echo Minz_Translate::t ('before_yesterday'); ?>
<span class="name"><?php echo $this->currentName; ?></span>
@@ -48,14 +57,14 @@ if (!empty($this->entries)) {
<div class="flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>">
<ul class="horizontal-list flux_header"><?php
- if ($logged) {
- if ($this->conf->topline_read) {
+ if ($this->loginOk) {
+ if ($topline_read) {
?><li class="item manage"><?php
?><a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', $item->isRead () ? 0 : 1); ?>"><?php
echo FreshRSS_Themes::icon($item->isRead () ? 'read' : 'unread'); ?></a><?php
?></li><?php
}
- if ($this->conf->topline_favorite) {
+ if ($topline_favorite) {
?><li class="item manage"><?php
?><a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', $item->isFavorite () ? 0 : 1); ?>"><?php
echo FreshRSS_Themes::icon($item->isFavorite () ? 'starred' : 'non-starred'); ?></a><?php
@@ -67,8 +76,8 @@ if (!empty($this->entries)) {
?>
<li class="item website"><a href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>"><img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="✇" /> <span><?php echo $feed->name(); ?></span></a></li>
<li class="item title"><a target="_blank" href="<?php echo $item->link (); ?>"><?php echo $item->title (); ?></a></li>
- <?php if ($this->conf->topline_date) { ?><li class="item date"><?php echo $item->date (); ?> </li><?php } ?>
- <?php if ($this->conf->topline_link) { ?><li class="item link"><a target="_blank" href="<?php echo $item->link (); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a></li><?php } ?>
+ <?php if ($topline_date) { ?><li class="item date"><?php echo $item->date (); ?> </li><?php } ?>
+ <?php if ($topline_link) { ?><li class="item link"><a target="_blank" href="<?php echo $item->link (); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a></li><?php } ?>
</ul>
<div class="flux_content">
@@ -85,14 +94,14 @@ if (!empty($this->entries)) {
?>
</div>
<ul class="horizontal-list bottom"><?php
- if ($logged) {
- if ($this->conf->bottomline_read) {
+ if ($this->loginOk) {
+ if ($bottomline_read) {
?><li class="item manage"><?php
?><a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', $item->isRead () ? 0 : 1); ?>"><?php
echo FreshRSS_Themes::icon($item->isRead () ? 'read' : 'unread'); ?></a><?php
?></li><?php
}
- if ($this->conf->bottomline_favorite) {
+ if ($bottomline_favorite) {
?><li class="item manage"><?php
?><a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', $item->isFavorite () ? 0 : 1); ?>"><?php
echo FreshRSS_Themes::icon($item->isFavorite () ? 'starred' : 'non-starred'); ?></a><?php
@@ -101,10 +110,7 @@ if (!empty($this->entries)) {
} ?>
<li class="item">
<?php
- if ($this->conf->bottomline_sharing && (
- $shaarli || $poche || $diaspora || $twitter ||
- $google_plus || $facebook || $email
- )) {
+ if ($bottomline_sharing) {
$link = urlencode ($item->link ());
$title = urlencode ($item->title () . ' - ' . $feed->name ());
?>
@@ -117,19 +123,19 @@ if (!empty($this->entries)) {
<ul class="dropdown-menu">
<li class="dropdown-close"><a href="#close">❌</a></li>
- <?php if ($logged && $shaarli) { ?>
+ <?php if ($shaarli) { ?>
<li class="item">
<a target="_blank" href="<?php echo $shaarli . '?post=' . $link . '&amp;title=' . $title . '&amp;source=FreshRSS'; ?>">
<?php echo Minz_Translate::t ('shaarli'); ?>
</a>
</li>
- <?php } if ($logged && $poche) { ?>
+ <?php } if ($poche) { ?>
<li class="item">
<a target="_blank" href="<?php echo $poche . '?action=add&amp;url=' . base64_encode (urldecode($link)); ?>">
<?php echo Minz_Translate::t ('poche'); ?>
</a>
</li>
- <?php } if ($logged && $diaspora) { ?>
+ <?php } if ($diaspora) { ?>
<li class="item">
<a target="_blank" href="<?php echo $diaspora . '/bookmarklet?url=' . $link . '&amp;title=' . $title; ?>">
<?php echo Minz_Translate::t ('diaspora'); ?>
@@ -171,7 +177,7 @@ if (!empty($this->entries)) {
<?php } ?>
</li>
<?php
- $tags = $this->conf->bottomline_tags ? $item->tags() : null;
+ $tags = $bottomline_tags ? $item->tags() : null;
if (!empty($tags)) {
?>
<li class="item">
@@ -190,8 +196,8 @@ if (!empty($this->entries)) {
</div>
</li>
<?php } ?>
- <?php if ($this->conf->bottomline_date) { ?><li class="item date"><?php echo $item->date (); ?> </li><?php } ?>
- <?php if ($this->conf->bottomline_link) { ?><li class="item link"><a target="_blank" href="<?php echo $item->link (); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a></li><?php } ?>
+ <?php if ($bottomline_date) { ?><li class="item date"><?php echo $item->date (); ?> </li><?php } ?>
+ <?php if ($bottomline_link) { ?><li class="item link"><a target="_blank" href="<?php echo $item->link (); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a></li><?php } ?>
</ul>
</div>
</div>
diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml
index 4db53e2a5..549d0b61e 100644
--- a/app/views/index/index.phtml
+++ b/app/views/index/index.phtml
@@ -1,29 +1,38 @@
<?php
+function showForbidden() {
+?><div class="post content">
+ <h1><?php echo Minz_Translate::t ('forbidden_access'); ?></h1>
+ <p><?php echo Minz_Configuration::canLogIn() ?
+ Minz_Translate::t ('forbidden_access_description') :
+ Minz_Translate::t ('forbidden_access') . ' (' . Minz_Configuration::authType() . ')'; ?></p>
+ <p><a href="<?php echo _url ('index', 'about'); ?>"><?php echo Minz_Translate::t ('about_freshrss'); ?></a></p>
+</div><?php
+}
+
$output = Minz_Request::param ('output', 'normal');
-$token = $this->conf->token;
-$token_param = Minz_Request::param ('token', '');
-$token_is_ok = ($token != '' && $token == $token_param);
-if(!login_is_conf ($this->conf) ||
- is_logged() ||
- Minz_Configuration::allowAnonymous() ||
- ($output == 'rss' && $token_is_ok)) {
- if($output == 'rss') {
+if ($this->loginOk || Minz_Configuration::allowAnonymous()) {
+ if ($output === 'normal') {
+ $this->renderHelper ('view/normal_view');
+ } elseif ($output === 'rss') {
$this->renderHelper ('view/rss_view');
- } elseif($output == 'reader') {
+ } elseif ($output === 'reader') {
$this->renderHelper ('view/reader_view');
- } elseif($output == 'global') {
+ } elseif ($output === 'global') {
$this->renderHelper ('view/global_view');
} else {
$this->renderHelper ('view/normal_view');
}
+} elseif ($output === 'rss') {
+ $token = $this->conf->token;
+ $token_param = Minz_Request::param ('token', '');
+ $token_is_ok = ($token != '' && $token == $token_param);
+ if ($token_is_ok) {
+ $this->renderHelper ('view/rss_view');
+ } else {
+ showForbidden();
+ }
} else {
-?>
-<div class="post content">
- <h1><?php echo Minz_Translate::t ('forbidden_access'); ?></h1>
- <p><?php echo Minz_Translate::t ('forbidden_access_description'); ?></p>
- <p><a href="<?php echo _url ('index', 'about'); ?>"><?php echo Minz_Translate::t ('about_freshrss'); ?></a></p>
-</div>
-<?php
-} \ No newline at end of file
+ showForbidden();
+}