Login: update PageBuilder and default/vintage templates
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
parent
8474208474
commit
89ccc83ba4
12 changed files with 38 additions and 30 deletions
|
@ -25,6 +25,9 @@ class PageBuilder
|
||||||
* @var LinkDB $linkDB instance.
|
* @var LinkDB $linkDB instance.
|
||||||
*/
|
*/
|
||||||
protected $linkDB;
|
protected $linkDB;
|
||||||
|
|
||||||
|
/** @var bool $isLoggedIn Whether the user is logged in **/
|
||||||
|
protected $isLoggedIn = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PageBuilder constructor.
|
* PageBuilder constructor.
|
||||||
|
@ -34,12 +37,13 @@ class PageBuilder
|
||||||
* @param LinkDB $linkDB instance.
|
* @param LinkDB $linkDB instance.
|
||||||
* @param string $token Session token
|
* @param string $token Session token
|
||||||
*/
|
*/
|
||||||
public function __construct(&$conf, $linkDB = null, $token = null)
|
public function __construct(&$conf, $linkDB = null, $token = null, $isLoggedIn = false)
|
||||||
{
|
{
|
||||||
$this->tpl = false;
|
$this->tpl = false;
|
||||||
$this->conf = $conf;
|
$this->conf = $conf;
|
||||||
$this->linkDB = $linkDB;
|
$this->linkDB = $linkDB;
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
|
$this->isLoggedIn = $isLoggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +59,7 @@ private function initialize()
|
||||||
$this->conf->get('resource.update_check'),
|
$this->conf->get('resource.update_check'),
|
||||||
$this->conf->get('updates.check_updates_interval'),
|
$this->conf->get('updates.check_updates_interval'),
|
||||||
$this->conf->get('updates.check_updates'),
|
$this->conf->get('updates.check_updates'),
|
||||||
isLoggedIn(),
|
$this->isLoggedIn,
|
||||||
$this->conf->get('updates.check_updates_branch')
|
$this->conf->get('updates.check_updates_branch')
|
||||||
);
|
);
|
||||||
$this->tpl->assign('newVersion', escape($version));
|
$this->tpl->assign('newVersion', escape($version));
|
||||||
|
@ -67,6 +71,7 @@ private function initialize()
|
||||||
$this->tpl->assign('versionError', escape($exc->getMessage()));
|
$this->tpl->assign('versionError', escape($exc->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->tpl->assign('is_logged_in', $this->isLoggedIn);
|
||||||
$this->tpl->assign('feedurl', escape(index_url($_SERVER)));
|
$this->tpl->assign('feedurl', escape(index_url($_SERVER)));
|
||||||
$searchcrits = ''; // Search criteria
|
$searchcrits = ''; // Search criteria
|
||||||
if (!empty($_GET['searchtags'])) {
|
if (!empty($_GET['searchtags'])) {
|
||||||
|
|
15
index.php
15
index.php
|
@ -182,9 +182,11 @@
|
||||||
$loginManager->checkLoginState($_SESSION, $_COOKIE, WEB_PATH, $clientIpId, STAY_SIGNED_IN_TOKEN);
|
$loginManager->checkLoginState($_SESSION, $_COOKIE, WEB_PATH, $clientIpId, STAY_SIGNED_IN_TOKEN);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter function for PageBuilder
|
* Adapter function to ensure compatibility with third-party templates
|
||||||
*
|
*
|
||||||
* TODO: update PageBuilder and tests
|
* @see https://github.com/shaarli/Shaarli/pull/1086
|
||||||
|
*
|
||||||
|
* @return bool true when the user is logged in, false otherwise
|
||||||
*/
|
*/
|
||||||
function isLoggedIn()
|
function isLoggedIn()
|
||||||
{
|
{
|
||||||
|
@ -383,9 +385,10 @@ function showDailyRSS($conf, $loginManager) {
|
||||||
* @param PageBuilder $pageBuilder Template engine wrapper.
|
* @param PageBuilder $pageBuilder Template engine wrapper.
|
||||||
* @param LinkDB $LINKSDB LinkDB instance.
|
* @param LinkDB $LINKSDB LinkDB instance.
|
||||||
* @param ConfigManager $conf Configuration Manager instance.
|
* @param ConfigManager $conf Configuration Manager instance.
|
||||||
* @param PluginManager $pluginManager Plugin Manager instane.
|
* @param PluginManager $pluginManager Plugin Manager instance.
|
||||||
|
* @param LoginManager $loginManager Login Manager instance
|
||||||
*/
|
*/
|
||||||
function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager)
|
function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager, $loginManager)
|
||||||
{
|
{
|
||||||
$day = date('Ymd', strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
|
$day = date('Ymd', strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
|
||||||
if (isset($_GET['day'])) {
|
if (isset($_GET['day'])) {
|
||||||
|
@ -523,7 +526,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
||||||
die($e->getMessage());
|
die($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$PAGE = new PageBuilder($conf, $LINKSDB, $sessionManager->generateToken());
|
$PAGE = new PageBuilder($conf, $LINKSDB, $sessionManager->generateToken(), $loginManager->isLoggedIn());
|
||||||
$PAGE->assign('linkcount', count($LINKSDB));
|
$PAGE->assign('linkcount', count($LINKSDB));
|
||||||
$PAGE->assign('privateLinkcount', count_private($LINKSDB));
|
$PAGE->assign('privateLinkcount', count_private($LINKSDB));
|
||||||
$PAGE->assign('plugin_errors', $pluginManager->getErrors());
|
$PAGE->assign('plugin_errors', $pluginManager->getErrors());
|
||||||
|
@ -708,7 +711,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
||||||
|
|
||||||
// Daily page.
|
// Daily page.
|
||||||
if ($targetPage == Router::$PAGE_DAILY) {
|
if ($targetPage == Router::$PAGE_DAILY) {
|
||||||
showDaily($PAGE, $LINKSDB, $conf, $pluginManager);
|
showDaily($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ATOM and RSS feed.
|
// ATOM and RSS feed.
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
<div class="linklist-item-thumbnail">{$thumb}</div>
|
<div class="linklist-item-thumbnail">{$thumb}</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<div class="linklist-item-editbuttons">
|
<div class="linklist-item-editbuttons">
|
||||||
{if="$value.private"}
|
{if="$value.private"}
|
||||||
<span class="label label-private">{$strPrivate}</span>
|
<span class="label label-private">{$strPrivate}</span>
|
||||||
|
@ -179,7 +179,7 @@ <h2>
|
||||||
|
|
||||||
<div class="linklist-item-infos-date-url-block pure-g">
|
<div class="linklist-item-infos-date-url-block pure-g">
|
||||||
<div class="linklist-item-infos-dateblock pure-u-lg-7-12 pure-u-1">
|
<div class="linklist-item-infos-dateblock pure-u-lg-7-12 pure-u-1">
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<div class="linklist-item-infos-controls-group pure-u-0 pure-u-lg-visible">
|
<div class="linklist-item-infos-controls-group pure-u-0 pure-u-lg-visible">
|
||||||
<span class="linklist-item-infos-controls-item ctrl-checkbox">
|
<span class="linklist-item-infos-controls-item ctrl-checkbox">
|
||||||
<input type="checkbox" class="delete-checkbox" value="{$value.id}">
|
<input type="checkbox" class="delete-checkbox" value="{$value.id}">
|
||||||
|
@ -196,7 +196,7 @@ <h2>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<a href="?{$value.shorturl}" title="{$strPermalink}">
|
<a href="?{$value.shorturl}" title="{$strPermalink}">
|
||||||
{if="!$hide_timestamps || isLoggedIn()"}
|
{if="!$hide_timestamps || $is_logged_in"}
|
||||||
{$updated=$value.updated_timestamp ? $strEdited. format_date($value.updated) : $strPermalink}
|
{$updated=$value.updated_timestamp ? $strEdited. format_date($value.updated) : $strPermalink}
|
||||||
<span class="linkdate" title="{$updated}">
|
<span class="linkdate" title="{$updated}">
|
||||||
<i class="fa fa-clock-o"></i>
|
<i class="fa fa-clock-o"></i>
|
||||||
|
@ -236,7 +236,7 @@ <h2>
|
||||||
{if="$link_plugin_counter - 1 != $counter"}·{/if}
|
{if="$link_plugin_counter - 1 != $counter"}·{/if}
|
||||||
{/loop}
|
{/loop}
|
||||||
{/if}
|
{/if}
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
·
|
·
|
||||||
<a href="?delete_link&lf_linkdate={$value.id}&token={$token}"
|
<a href="?delete_link&lf_linkdate={$value.id}&token={$token}"
|
||||||
title="{$strDelete}" class="delete-link confirm-delete">
|
title="{$strDelete}" class="delete-link confirm-delete">
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<div class="linklist-paging">
|
<div class="linklist-paging">
|
||||||
<div class="paging pure-g">
|
<div class="paging pure-g">
|
||||||
<div class="linklist-filters pure-u-1-3">
|
<div class="linklist-filters pure-u-1-3">
|
||||||
{if="isLoggedIn() or !empty($action_plugin)"}
|
{if="$is_logged_in or !empty($action_plugin)"}
|
||||||
<span class="linklist-filters-text pure-u-0 pure-u-lg-visible">
|
<span class="linklist-filters-text pure-u-0 pure-u-lg-visible">
|
||||||
{'Filters'|t}
|
{'Filters'|t}
|
||||||
</span>
|
</span>
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<a href="?visibility=private" title="{'Only display private links'|t}"
|
<a href="?visibility=private" title="{'Only display private links'|t}"
|
||||||
class="{if="$visibility==='private'"}filter-on{else}filter-off{/if}"
|
class="{if="$visibility==='private'"}filter-on{else}filter-off{/if}"
|
||||||
><i class="fa fa-user-secret"></i></a>
|
><i class="fa fa-user-secret"></i></a>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="pure-u-2-24"></div>
|
<div class="pure-u-2-24"></div>
|
||||||
<div id="footer" class="pure-u-20-24 footer-container">
|
<div id="footer" class="pure-u-20-24 footer-container">
|
||||||
<strong><a href="https://github.com/shaarli/Shaarli">Shaarli</a></strong>
|
<strong><a href="https://github.com/shaarli/Shaarli">Shaarli</a></strong>
|
||||||
{if="isLoggedIn()===true"}
|
{if="$is_logged_in===true"}
|
||||||
{$version}
|
{$version}
|
||||||
{/if}
|
{/if}
|
||||||
·
|
·
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
{$shaarlititle}
|
{$shaarlititle}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{if="isLoggedIn() || $openshaarli"}
|
{if="$is_logged_in || $openshaarli"}
|
||||||
<li class="pure-menu-item">
|
<li class="pure-menu-item">
|
||||||
<a href="?do=addlink" class="pure-menu-link" id="shaarli-menu-shaare">
|
<a href="?do=addlink" class="pure-menu-link" id="shaarli-menu-shaare">
|
||||||
<i class="fa fa-plus" ></i> {'Shaare'|t}
|
<i class="fa fa-plus" ></i> {'Shaare'|t}
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-rss">
|
<li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-rss">
|
||||||
<a href="?do={$feed_type}{$searchcrits}" class="pure-menu-link">{'RSS Feed'|t}</a>
|
<a href="?do={$feed_type}{$searchcrits}" class="pure-menu-link">{'RSS Feed'|t}</a>
|
||||||
</li>
|
</li>
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-logout">
|
<li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-logout">
|
||||||
<a href="?do=logout" class="pure-menu-link">{'Logout'|t}</a>
|
<a href="?do=logout" class="pure-menu-link">{'Logout'|t}</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
<i class="fa fa-rss"></i>
|
<i class="fa fa-rss"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{if="!isLoggedIn()"}
|
{if="!$is_logged_in"}
|
||||||
<li class="pure-menu-item" id="shaarli-menu-desktop-login">
|
<li class="pure-menu-item" id="shaarli-menu-desktop-login">
|
||||||
<a href="?do=login" class="pure-menu-link"
|
<a href="?do=login" class="pure-menu-link"
|
||||||
data-open-id="header-login-form"
|
data-open-id="header-login-form"
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{if="!isLoggedIn()"}
|
{if="!$is_logged_in"}
|
||||||
<form method="post" name="loginform">
|
<form method="post" name="loginform">
|
||||||
<div class="subheader-form header-login-form" id="header-login-form">
|
<div class="subheader-form header-login-form" id="header-login-form">
|
||||||
<input type="text" name="login" placeholder="{'Username'|t}" tabindex="3">
|
<input type="text" name="login" placeholder="{'Username'|t}" tabindex="3">
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if="!empty($plugin_errors) && isLoggedIn()"}
|
{if="!empty($plugin_errors) && $is_logged_in"}
|
||||||
<div class="pure-g new-version-message pure-alert pure-alert-error pure-alert-closable" id="shaarli-errors-alert">
|
<div class="pure-g new-version-message pure-alert pure-alert-error pure-alert-closable" id="shaarli-errors-alert">
|
||||||
<div class="pure-u-2-24"></div>
|
<div class="pure-u-2-24"></div>
|
||||||
<div class="pure-u-20-24">
|
<div class="pure-u-20-24">
|
||||||
|
|
|
@ -49,7 +49,7 @@ <h2 class="window-title">{'Tag list'|t} - {$countTags} {'tags'|t}</h2>
|
||||||
{loop="tags"}
|
{loop="tags"}
|
||||||
<div class="tag-list-item pure-g" data-tag="{$key}">
|
<div class="tag-list-item pure-g" data-tag="{$key}">
|
||||||
<div class="pure-u-1">
|
<div class="pure-u-1">
|
||||||
{if="isLoggedIn()===true"}
|
{if="$is_logged_in===true"}
|
||||||
<a href="#" class="delete-tag"><i class="fa fa-trash"></i></a>
|
<a href="#" class="delete-tag"><i class="fa fa-trash"></i></a>
|
||||||
<a href="?do=changetag&fromtag={$key|urlencode}" class="rename-tag">
|
<a href="?do=changetag&fromtag={$key|urlencode}" class="rename-tag">
|
||||||
<i class="fa fa-pencil-square-o {$key}"></i>
|
<i class="fa fa-pencil-square-o {$key}"></i>
|
||||||
|
@ -63,7 +63,7 @@ <h2 class="window-title">{'Tag list'|t} - {$countTags} {'tags'|t}</h2>
|
||||||
{$value}
|
{$value}
|
||||||
{/loop}
|
{/loop}
|
||||||
</div>
|
</div>
|
||||||
{if="isLoggedIn()===true"}
|
{if="$is_logged_in===true"}
|
||||||
<div class="rename-tag-form pure-u-1">
|
<div class="rename-tag-form pure-u-1">
|
||||||
<input type="text" name="{$key}" value="{$key}" class="rename-tag-input" />
|
<input type="text" name="{$key}" value="{$key}" class="rename-tag-input" />
|
||||||
<a href="#" class="validate-rename-tag"><i class="fa fa-check"></i></a>
|
<a href="#" class="validate-rename-tag"><i class="fa fa-check"></i></a>
|
||||||
|
@ -81,7 +81,7 @@ <h2 class="window-title">{'Tag list'|t} - {$countTags} {'tags'|t}</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{if="isLoggedIn()===true"}
|
{if="$is_logged_in===true"}
|
||||||
<input type="hidden" name="taglist" value="{loop="$tags"}{$key} {/loop}"
|
<input type="hidden" name="taglist" value="{loop="$tags"}{$key} {/loop}"
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
<img src="img/squiggle.png" width="25" height="26" title="permalink" alt="permalink">
|
<img src="img/squiggle.png" width="25" height="26" title="permalink" alt="permalink">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{if="!$hide_timestamps || isLoggedIn()"}
|
{if="!$hide_timestamps || $is_logged_in"}
|
||||||
<div class="dailyEntryLinkdate">
|
<div class="dailyEntryLinkdate">
|
||||||
<a href="?{$value.shorturl}">{function="strftime('%c', $link.timestamp)"}</a>
|
<a href="?{$value.shorturl}">{function="strftime('%c', $link.timestamp)"}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
<a id="{$value.shorturl}"></a>
|
<a id="{$value.shorturl}"></a>
|
||||||
<div class="thumbnail">{$value.url|thumbnail}</div>
|
<div class="thumbnail">{$value.url|thumbnail}</div>
|
||||||
<div class="linkcontainer">
|
<div class="linkcontainer">
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<div class="linkeditbuttons">
|
<div class="linkeditbuttons">
|
||||||
<form method="GET" class="buttoneditform">
|
<form method="GET" class="buttoneditform">
|
||||||
<input type="hidden" name="edit_link" value="{$value.id}">
|
<input type="hidden" name="edit_link" value="{$value.id}">
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
{if="$value.description"}<div class="linkdescription">{$value.description}</div>{/if}
|
{if="$value.description"}<div class="linkdescription">{$value.description}</div>{/if}
|
||||||
{if="!$hide_timestamps || isLoggedIn()"}
|
{if="!$hide_timestamps || $is_logged_in"}
|
||||||
{$updated=$value.updated_timestamp ? 'Edited: '. format_date($value.updated) : 'Permalink'}
|
{$updated=$value.updated_timestamp ? 'Edited: '. format_date($value.updated) : 'Permalink'}
|
||||||
<span class="linkdate" title="Permalink">
|
<span class="linkdate" title="Permalink">
|
||||||
<a href="?{$value.shorturl}">
|
<a href="?{$value.shorturl}">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="paging">
|
<div class="paging">
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<div class="paging_privatelinks">
|
<div class="paging_privatelinks">
|
||||||
<a href="?visibility=private">
|
<a href="?visibility=private">
|
||||||
{if="$visibility=='private'"}
|
{if="$visibility=='private'"}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
<script src="js/shaarli.min.js"></script>
|
<script src="js/shaarli.min.js"></script>
|
||||||
|
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<script>function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script>
|
<script>function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
{ignore} When called as a popup from bookmarklet, do not display menu. {/ignore}
|
{ignore} When called as a popup from bookmarklet, do not display menu. {/ignore}
|
||||||
{else}
|
{else}
|
||||||
<li><a href="{$titleLink}" class="nomobile">Home</a></li>
|
<li><a href="{$titleLink}" class="nomobile">Home</a></li>
|
||||||
{if="isLoggedIn()"}
|
{if="$is_logged_in"}
|
||||||
<li><a href="?do=logout">Logout</a></li>
|
<li><a href="?do=logout">Logout</a></li>
|
||||||
<li><a href="?do=tools">Tools</a></li>
|
<li><a href="?do=tools">Tools</a></li>
|
||||||
<li><a href="?do=addlink">Add link</a></li>
|
<li><a href="?do=addlink">Add link</a></li>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{if="!empty($plugin_errors) && isLoggedIn()"}
|
{if="!empty($plugin_errors) && $is_logged_in"}
|
||||||
<ul class="errors">
|
<ul class="errors">
|
||||||
{loop="$plugin_errors"}
|
{loop="$plugin_errors"}
|
||||||
<li>{$value}</li>
|
<li>{$value}</li>
|
||||||
|
|
Loading…
Reference in a new issue