$this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false));
$this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false));
$this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
- if (!empty($GLOBALS['plugin_errors'])) {
- $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']);
- }
$this->tpl->assign('token', getToken($this->conf));
// To be removed with a proper theme configuration.
$this->tpl->assign('conf', $this->conf);
*/
protected $conf;
+ /**
+ * @var array List of plugin errors.
+ */
+ protected $errors;
+
/**
* Plugins subdirectory.
* @var string $PLUGINS_PATH
public function __construct(&$conf)
{
$this->conf = $conf;
+ $this->errors = array();
}
/**
/**
* Load a single plugin from its files.
+ * Call the init function if it exists, and collect errors.
* Add them in $loadedPlugins if successful.
*
* @param string $dir plugin's directory.
$conf = $this->conf;
include_once $pluginFilePath;
+ $initFunction = $pluginName . '_init';
+ if (function_exists($initFunction)) {
+ $errors = call_user_func($initFunction, $this->conf);
+ if (!empty($errors)) {
+ $this->errors = array_merge($this->errors, $errors);
+ }
+ }
+
$this->loadedPlugins[] = $pluginName;
}
return $metaData;
}
+
+ /**
+ * Return the list of encountered errors.
+ *
+ * @return array List of errors (empty array if none exists).
+ */
+ public function getErrors()
+ {
+ return $this->errors;
+ }
}
/**
$PAGE = new PageBuilder($conf);
$PAGE->assign('linkcount', count($LINKSDB));
$PAGE->assign('privateLinkcount', count_private($LINKSDB));
+ $PAGE->assign('plugin_errors', $pluginManager->getErrors());
// Determine which page will be rendered.
$query = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : '';
* and check user status with _LOGGEDIN_.
*/
+/**
+ * Initialization function.
+ * It will be called when the plugin is loaded.
+ * This function can be used to return a list of initialization errors.
+ *
+ * @param $conf ConfigManager instance.
+ *
+ * @return array List of errors (optional).
+ */
+function demo_plugin_init($conf)
+{
+ $conf->get('toto', 'nope');
+
+ $errors[] = 'This a demo init error.';
+ return $errors;
+}
+
/**
* Hook render_header.
* Executed on every page redering.
// it seems kinda dead.
// Not tested.
-$riyUrl = $conf->get('plugins.READITYOUSELF_URL');
-if (empty($riyUrl)) {
- $GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '.
- 'Please define the "READITYOUSELF_URL" setting in the plugin administration page.';
+/**
+ * Init function, return an error if the server is not set.
+ *
+ * @param $conf ConfigManager instance.
+ *
+ * @return array Eventual error.
+ */
+function readityourself_init($conf)
+{
+ $riyUrl = $conf->get('plugins.READITYOUSELF_URL');
+ if (empty($riyUrl)) {
+ $error = 'Readityourself plugin error: '.
+ 'Please define the "READITYOUSELF_URL" setting in the plugin administration page.';
+ return array($error);
+ }
}
/**
require_once 'WallabagInstance.php';
-$wallabagUrl = $conf->get('plugins.WALLABAG_URL');
-if (empty($wallabagUrl)) {
- $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '.
- 'Please define the "WALLABAG_URL" setting in the plugin administration page.';
+/**
+ * Init function, return an error if the server is not set.
+ *
+ * @param $conf ConfigManager instance.
+ *
+ * @return array Eventual error.
+ */
+function wallabag_init($conf)
+{
+ $wallabagUrl = $conf->get('plugins.WALLABAG_URL');
+ if (empty($wallabagUrl)) {
+ $error = 'Wallabag plugin error: '.
+ 'Please define the "WALLABAG_URL" setting in the plugin administration page.';
+ return array($error);
+ }
}
/**
* PluginReadityourselfTest.php.php
*/
-// FIXME! add an init method.
-$conf = new ConfigManager('');
require_once 'plugins/readityourself/readityourself.php';
/**
PluginManager::$PLUGINS_PATH = 'plugins';
}
+ /**
+ * Test Readityourself init without errors.
+ */
+ function testReadityourselfInitNoError()
+ {
+ $conf = new ConfigManager('');
+ $conf->set('plugins.READITYOUSELF_URL', 'value');
+ $errors = readityourself_init($conf);
+ $this->assertEmpty($errors);
+ }
+
+ /**
+ * Test Readityourself init with errors.
+ */
+ function testReadityourselfInitError()
+ {
+ $conf = new ConfigManager('');
+ $errors = readityourself_init($conf);
+ $this->assertNotEmpty($errors);
+ }
+
/**
* Test render_linklist hook.
*/
* PluginWallabagTest.php.php
*/
-// FIXME! add an init method.
-$conf = new ConfigManager('');
require_once 'plugins/wallabag/wallabag.php';
/**
PluginManager::$PLUGINS_PATH = 'plugins';
}
+ /**
+ * Test wallabag init without errors.
+ */
+ function testWallabagInitNoError()
+ {
+ $conf = new ConfigManager('');
+ $conf->set('plugins.WALLABAG_URL', 'value');
+ $errors = wallabag_init($conf);
+ $this->assertEmpty($errors);
+ }
+
+ /**
+ * Test wallabag init with errors.
+ */
+ function testWallabagInitError()
+ {
+ $conf = new ConfigManager('');
+ $errors = wallabag_init($conf);
+ $this->assertNotEmpty($errors);
+ }
+
/**
* Test render_linklist hook.
*/
<div class="clear"></div>
{if="$linksToDisplay"}
- {loop="cols"}
+ {loop="$cols"}
{if="isset($value[0])"}
<div id="daily_col{$counter+1}">
- {loop="value"}
+ {loop="$value"}
{$link=$value}
<div class="dailyEntry">
<div class="dailyEntryPermalink">
{/if}
{if="$link.tags"}
<div class="dailyEntryTags">
- {loop="link.taglist"}
+ {loop="$link.taglist"}
{$value} -
{/loop}
</div>
<link>{$absurl}</link>
<pubDate>{$rssdate}</pubDate>
<description><![CDATA[
- {loop="links"}
+ {loop="$links"}
<h3><a href="{$value.url}">{$value.title}</a></h3>
<small>{if="!$hide_timestamps"}{function="strftime('%c', $value.timestamp)"} - {/if}{if="$value.tags"}{$value.tags}{/if}<br>
{$value.url}</small><br>
Do Not Edit! -->{ignore}The RainTPL loop is formatted to avoid generating extra newlines{/ignore}
<TITLE>{$pagetitle}</TITLE>
<H1>Shaarli export of {$selection} bookmarks on {$date}</H1>
-<DL><p>{loop="links"}
+<DL><p>{loop="$links"}
<DT><A HREF="{$value.url}" ADD_DATE="{$value.timestamp}" PRIVATE="{$value.private}" TAGS="{$value.taglist}">{$value.title}</A>{if="$value.description"}{$eol}<DD>{$value.description}{/if}{/loop}
</DL><p>
</author>
<id>{$index_url}</id>
<generator>Shaarli</generator>
- {loop="links"}
+ {loop="$links"}
<entry>
<title>{$value.title}</title>
{if="$usepermalinks"}
<!-- PubSubHubbub Discovery -->
<atom:link rel="hub" href="{$pubsubhub_url}" />
{/if}
- {loop="links"}
+ {loop="$links"}
<item>
<title>{$value.title}</title>
<guid isPermaLink="{if="$usepermalinks"}true{else}false{/if}">{$value.guid}</guid>
</div>
{/if}
<ul>
- {loop="links"}
+ {loop="$links"}
<li{if="$value.class"} class="{$value.class}"{/if}>
<a id="{$value.shorturl}"></a>
<div class="thumbnail">{$value.url|thumbnail}</div>
<a href="{$value.real_url}"><span class="linkurl" title="Short link">{$value.url}</span></a><br>
{if="$value.tags"}
<div class="linktaglist">
- {loop="value.taglist"}<span class="linktag" title="Add tag"><a href="?addtag={$value|urlencode}">{$value}</a></span> {/loop}
+ {loop="$value.taglist"}<span class="linktag" title="Add tag"><a href="?addtag={$value|urlencode}">{$value}</a></span> {/loop}
</div>
{/if}
{if="!empty($plugin_errors) && isLoggedIn()"}
<ul class="errors">
- {loop="plugin_errors"}
+ {loop="$plugin_errors"}
<li>{$value}</li>
{/loop}
</ul>
<div class="center">
<div id="picwall_container">
- {loop="linksToDisplay"}
+ {loop="$linksToDisplay"}
<div class="picwall_pictureframe">
{$value.thumbnail}<a href="{$value.real_url}"><span class="info">{$value.title}</span></a>
{loop="$value.picwall_plugin"}
</div>
<div id="cloudtag">
- {loop="tags"}
+ {loop="$tags"}
<span class="count">{$value.count}</span><a
href="?searchtags={$key|urlencode}" style="font-size:{$value.size}em;">{$key}</a>
{loop="$value.tag_plugin"}