aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-11-08 13:22:44 +0100
committerArthurHoaro <arthur@hoa.ro>2015-11-08 13:22:44 +0100
commit056107ab4eae0a4867cf8d55de77d31f8868b899 (patch)
tree2d92c7afc59721584f62cd2a07052e1f5a27c7f4
parent89dfc37b0aeb865bc7298836b615e2ac5b6406ce (diff)
downloadShaarli-056107ab4eae0a4867cf8d55de77d31f8868b899.tar.gz
Shaarli-056107ab4eae0a4867cf8d55de77d31f8868b899.tar.zst
Shaarli-056107ab4eae0a4867cf8d55de77d31f8868b899.zip
Handle errors raised by plugins in template. fixes #370
-rw-r--r--inc/shaarli.css5
-rwxr-xr-xindex.php52
-rw-r--r--plugins/readityourself/readityourself.php6
-rw-r--r--tpl/page.header.html7
4 files changed, 48 insertions, 22 deletions
diff --git a/inc/shaarli.css b/inc/shaarli.css
index d1193488..5578610d 100644
--- a/inc/shaarli.css
+++ b/inc/shaarli.css
@@ -1126,3 +1126,8 @@ div.dailyNoEntry {
1126.center { 1126.center {
1127 text-align: center; 1127 text-align: center;
1128} 1128}
1129
1130ul.errors {
1131 color: red;
1132 float: left;
1133} \ No newline at end of file
diff --git a/index.php b/index.php
index c82735ca..ea7bf4d1 100755
--- a/index.php
+++ b/index.php
@@ -55,8 +55,7 @@ $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false;
55$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode'); 55$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode');
56 56
57// Default plugins, default config - will be overriden by config.php and then plugin's config.php file. 57// Default plugins, default config - will be overriden by config.php and then plugin's config.php file.
58$GLOBALS['plugins']['READITYOUSELF_URL'] = 'http://someurl.com'; 58//$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/';
59$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/';
60// ----------------------------------------------------------------------------------------------- 59// -----------------------------------------------------------------------------------------------
61define('shaarli_version', '0.5.4'); 60define('shaarli_version', '0.5.4');
62// http://server.com/x/shaarli --> /shaarli/ 61// http://server.com/x/shaarli --> /shaarli/
@@ -580,28 +579,43 @@ class pageBuilder
580 579
581 function __construct() 580 function __construct()
582 { 581 {
583 $this->tpl=false; 582 $this->tpl = false;
584 } 583 }
585 584
585 /**
586 * Initialize all default tpl tags.
587 */
586 private function initialize() 588 private function initialize()
587 { 589 {
588 $this->tpl = new RainTPL; 590 $this->tpl = new RainTPL;
589 $this->tpl->assign('newversion',escape(checkUpdate())); 591 $this->tpl->assign('newversion', escape(checkUpdate()));
590 $this->tpl->assign('feedurl',escape(index_url($_SERVER))); 592 $this->tpl->assign('feedurl', escape(index_url($_SERVER)));
591 $searchcrits=''; // Search criteria 593 $searchcrits = ''; // Search criteria
592 if (!empty($_GET['searchtags'])) $searchcrits.='&searchtags='.urlencode($_GET['searchtags']); 594 if (!empty($_GET['searchtags'])) {
593 elseif (!empty($_GET['searchterm'])) $searchcrits.='&searchterm='.urlencode($_GET['searchterm']); 595 $searchcrits .= '&searchtags=' . urlencode($_GET['searchtags']);
594 $this->tpl->assign('searchcrits',$searchcrits); 596 }
595 $this->tpl->assign('source',index_url($_SERVER)); 597 elseif (!empty($_GET['searchterm'])) {
596 $this->tpl->assign('version',shaarli_version); 598 $searchcrits .= '&searchterm=' . urlencode($_GET['searchterm']);
597 $this->tpl->assign('scripturl',index_url($_SERVER)); 599 }
598 $this->tpl->assign('pagetitle','Shaarli'); 600 $this->tpl->assign('searchcrits', $searchcrits);
599 $this->tpl->assign('privateonly',!empty($_SESSION['privateonly'])); // Show only private links? 601 $this->tpl->assign('source', index_url($_SERVER));
600 if (!empty($GLOBALS['title'])) $this->tpl->assign('pagetitle',$GLOBALS['title']); 602 $this->tpl->assign('version', shaarli_version);
601 if (!empty($GLOBALS['titleLink'])) $this->tpl->assign('titleLink',$GLOBALS['titleLink']); 603 $this->tpl->assign('scripturl', index_url($_SERVER));
602 if (!empty($GLOBALS['pagetitle'])) $this->tpl->assign('pagetitle',$GLOBALS['pagetitle']); 604 $this->tpl->assign('pagetitle', 'Shaarli');
603 $this->tpl->assign('shaarlititle',empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title'] ); 605 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links?
604 return; 606 if (!empty($GLOBALS['title'])) {
607 $this->tpl->assign('pagetitle', $GLOBALS['title']);
608 }
609 if (!empty($GLOBALS['titleLink'])) {
610 $this->tpl->assign('titleLink', $GLOBALS['titleLink']);
611 }
612 if (!empty($GLOBALS['pagetitle'])) {
613 $this->tpl->assign('pagetitle', $GLOBALS['pagetitle']);
614 }
615 $this->tpl->assign('shaarlititle', empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title']);
616 if (!empty($GLOBALS['plugins']['errors'])) {
617 $this->tpl->assign('plugin_errors', $GLOBALS['plugins']['errors']);
618 }
605 } 619 }
606 620
607 // The following assign() method is basically the same as RainTPL (except that it's lazy) 621 // The following assign() method is basically the same as RainTPL (except that it's lazy)
diff --git a/plugins/readityourself/readityourself.php b/plugins/readityourself/readityourself.php
index ee7579c0..68efc543 100644
--- a/plugins/readityourself/readityourself.php
+++ b/plugins/readityourself/readityourself.php
@@ -14,9 +14,9 @@ if (is_file(PluginManager::$PLUGINS_PATH . '/readityourself/config.php')) {
14} 14}
15 15
16if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) { 16if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) {
17 $GLOBALS['plugins']['errors'][] = 'Wallabag plugin error: '. 17 $GLOBALS['plugins']['errors'][] = 'Readityourself plugin error: '.
18 'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '. 18 'Please define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" '.
19 'in "plugins/wallabag/config.php" or in your Shaarli config.php file.'; 19 'in "plugins/readityourself/config.php" or in your Shaarli config.php file.';
20} 20}
21 21
22/** 22/**
diff --git a/tpl/page.header.html b/tpl/page.header.html
index 1d46d80c..52429f23 100644
--- a/tpl/page.header.html
+++ b/tpl/page.header.html
@@ -40,6 +40,13 @@
40 </ul> 40 </ul>
41</div> 41</div>
42 42
43{if="!empty($plugin_errors) && isLoggedIn()"}
44 <ul class="errors">
45 {loop="plugin_errors"}
46 <li>{$value}</li>
47 {/loop}
48 </ul>
49{/if}
43 50
44<div class="clear"></div> 51<div class="clear"></div>
45 52