Handle errors raised by plugins in template. fixes #370
This commit is contained in:
parent
89dfc37b0a
commit
056107ab4e
4 changed files with 48 additions and 22 deletions
|
@ -1126,3 +1126,8 @@ div.dailyNoEntry {
|
||||||
.center {
|
.center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.errors {
|
||||||
|
color: red;
|
||||||
|
float: left;
|
||||||
|
}
|
30
index.php
30
index.php
|
@ -55,8 +55,7 @@
|
||||||
$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode');
|
$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode');
|
||||||
|
|
||||||
// Default plugins, default config - will be overriden by config.php and then plugin's config.php file.
|
// Default plugins, default config - will be overriden by config.php and then plugin's config.php file.
|
||||||
$GLOBALS['plugins']['READITYOUSELF_URL'] = 'http://someurl.com';
|
//$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/';
|
||||||
$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/';
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------
|
||||||
define('shaarli_version', '0.5.4');
|
define('shaarli_version', '0.5.4');
|
||||||
// http://server.com/x/shaarli --> /shaarli/
|
// http://server.com/x/shaarli --> /shaarli/
|
||||||
|
@ -583,25 +582,40 @@ function __construct()
|
||||||
$this->tpl = false;
|
$this->tpl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize all default tpl tags.
|
||||||
|
*/
|
||||||
private function initialize()
|
private function initialize()
|
||||||
{
|
{
|
||||||
$this->tpl = new RainTPL;
|
$this->tpl = new RainTPL;
|
||||||
$this->tpl->assign('newversion', escape(checkUpdate()));
|
$this->tpl->assign('newversion', escape(checkUpdate()));
|
||||||
$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'])) $searchcrits.='&searchtags='.urlencode($_GET['searchtags']);
|
if (!empty($_GET['searchtags'])) {
|
||||||
elseif (!empty($_GET['searchterm'])) $searchcrits.='&searchterm='.urlencode($_GET['searchterm']);
|
$searchcrits .= '&searchtags=' . urlencode($_GET['searchtags']);
|
||||||
|
}
|
||||||
|
elseif (!empty($_GET['searchterm'])) {
|
||||||
|
$searchcrits .= '&searchterm=' . urlencode($_GET['searchterm']);
|
||||||
|
}
|
||||||
$this->tpl->assign('searchcrits', $searchcrits);
|
$this->tpl->assign('searchcrits', $searchcrits);
|
||||||
$this->tpl->assign('source', index_url($_SERVER));
|
$this->tpl->assign('source', index_url($_SERVER));
|
||||||
$this->tpl->assign('version', shaarli_version);
|
$this->tpl->assign('version', shaarli_version);
|
||||||
$this->tpl->assign('scripturl', index_url($_SERVER));
|
$this->tpl->assign('scripturl', index_url($_SERVER));
|
||||||
$this->tpl->assign('pagetitle', 'Shaarli');
|
$this->tpl->assign('pagetitle', 'Shaarli');
|
||||||
$this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links?
|
$this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links?
|
||||||
if (!empty($GLOBALS['title'])) $this->tpl->assign('pagetitle',$GLOBALS['title']);
|
if (!empty($GLOBALS['title'])) {
|
||||||
if (!empty($GLOBALS['titleLink'])) $this->tpl->assign('titleLink',$GLOBALS['titleLink']);
|
$this->tpl->assign('pagetitle', $GLOBALS['title']);
|
||||||
if (!empty($GLOBALS['pagetitle'])) $this->tpl->assign('pagetitle',$GLOBALS['pagetitle']);
|
}
|
||||||
|
if (!empty($GLOBALS['titleLink'])) {
|
||||||
|
$this->tpl->assign('titleLink', $GLOBALS['titleLink']);
|
||||||
|
}
|
||||||
|
if (!empty($GLOBALS['pagetitle'])) {
|
||||||
|
$this->tpl->assign('pagetitle', $GLOBALS['pagetitle']);
|
||||||
|
}
|
||||||
$this->tpl->assign('shaarlititle', empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title']);
|
$this->tpl->assign('shaarlititle', empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title']);
|
||||||
return;
|
if (!empty($GLOBALS['plugins']['errors'])) {
|
||||||
|
$this->tpl->assign('plugin_errors', $GLOBALS['plugins']['errors']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following assign() method is basically the same as RainTPL (except that it's lazy)
|
// The following assign() method is basically the same as RainTPL (except that it's lazy)
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) {
|
if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) {
|
||||||
$GLOBALS['plugins']['errors'][] = 'Wallabag plugin error: '.
|
$GLOBALS['plugins']['errors'][] = 'Readityourself plugin error: '.
|
||||||
'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '.
|
'Please define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" '.
|
||||||
'in "plugins/wallabag/config.php" or in your Shaarli config.php file.';
|
'in "plugins/readityourself/config.php" or in your Shaarli config.php file.';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,6 +40,13 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{if="!empty($plugin_errors) && isLoggedIn()"}
|
||||||
|
<ul class="errors">
|
||||||
|
{loop="plugin_errors"}
|
||||||
|
<li>{$value}</li>
|
||||||
|
{/loop}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue