mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-26 18:21:02 +00:00
more verif while installing
This commit is contained in:
parent
ca1b0a1a6f
commit
4a2912880f
4 changed files with 72 additions and 30 deletions
|
@ -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. <br />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. <br />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');
|
||||
}
|
||||
|
|
|
@ -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 <a href="http://inthepoche.com/?pages/Documentation">the documentation.</a>');
|
||||
}
|
||||
|
||||
require_once './inc/poche/User.class.php';
|
||||
require_once './inc/poche/Tools.class.php';
|
||||
require_once './inc/poche/Url.class.php';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue