diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 82f0228e8..1d8aaca2c 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -18,11 +18,10 @@ class Poche
function __construct()
{
- if (file_exists('./install') && !DEBUG_POCHE) {
- Tools::logm('folder /install exists');
- die('If you want to update your poche, you just have to delete /install folder.
To install your poche with sqlite, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.');
+ $this->initTpl();
+ if (!$this->checkBeforeInstall()) {
+ exit;
}
-
$this->store = new Database();
$this->init();
$this->messages = new Messages();
@@ -34,6 +33,56 @@ class Poche
}
}
+ /**
+ * all checks before installation.
+ * @return boolean
+ */
+ private function checkBeforeInstall()
+ {
+ $msg = '';
+ $allIsGood = TRUE;
+ if (file_exists('./install') && !DEBUG_POCHE) {
+ Tools::logm('folder /install exists');
+ $msg = 'If you want to update your poche, you just have to delete /install folder.
To install your poche with sqlite, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.';
+ $allIsGood = FALSE;
+ }
+
+ if (STORAGE == 'sqlite' && !is_writable(STORAGE_SQLITE)) {
+ Tools::logm('you don\'t have write access on db file');
+ $msg = 'You don\'t have write access on ' . STORAGE_SQLITE . ' file.';
+ $allIsGood = FALSE;
+ }
+
+ if (!$allIsGood) {
+ echo $this->tpl->render('error.twig', array(
+ 'msg' => $msg
+ ));
+ }
+
+ return $allIsGood;
+ }
+
+ private function initTpl()
+ {
+ # template engine
+ $loader = new Twig_Loader_Filesystem(TPL);
+ if (DEBUG_POCHE) {
+ $twig_params = array();
+ }
+ else {
+ $twig_params = array('cache' => CACHE);
+ }
+ $this->tpl = new Twig_Environment($loader, $twig_params);
+ $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
+ # filter to display domain name of an url
+ $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
+ $this->tpl->addFilter($filter);
+
+ # filter for reading time
+ $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
+ $this->tpl->addFilter($filter);
+ }
+
private function init()
{
Tools::initPhp();
@@ -55,24 +104,6 @@ class Poche
bindtextdomain($language, LOCALE);
textdomain($language);
- # template engine
- $loader = new Twig_Loader_Filesystem(TPL);
- if (DEBUG_POCHE) {
- $twig_params = array();
- }
- else {
- $twig_params = array('cache' => CACHE);
- }
- $this->tpl = new Twig_Environment($loader, $twig_params);
- $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
- # filter to display domain name of an url
- $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
- $this->tpl->addFilter($filter);
-
- # filter for reading time
- $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
- $this->tpl->addFilter($filter);
-
# Pagination
$this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
}
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php
index ba8a9fa06..ecbf1ce68 100644
--- a/inc/poche/config.inc.php
+++ b/inc/poche/config.inc.php
@@ -34,6 +34,10 @@ define ('PAGINATION', '10');
define ('THEME', 'light');
# /!\ Be careful if you change the lines below /!\
+if (!file_exists('./vendor/autoload.php')) {
+ die('Twig does not seem installed. Have a look at the documentation.');
+}
+
require_once './inc/poche/User.class.php';
require_once './inc/poche/Tools.class.php';
require_once './inc/poche/Url.class.php';
diff --git a/tpl/error.twig b/tpl/error.twig
new file mode 100644
index 000000000..84c3bc1c2
--- /dev/null
+++ b/tpl/error.twig
@@ -0,0 +1,7 @@
+{% extends "layout.twig" %}
+{% block title %}{% trans "error" %}{% endblock %}
+{% block content %}
+
{{ msg|raw }}
+Don't forget the documentation.
+{% endblock %} \ No newline at end of file diff --git a/tpl/install.twig b/tpl/install.twig index 8bcede0df..afb5b0f6b 100644 --- a/tpl/install.twig +++ b/tpl/install.twig @@ -7,21 +7,21 @@{% trans "poche is still not installed. Please fill the below form to install it. Don't hesitate to read the documentation on poche website." %}
--
-
-
-