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();
}
}
- private function init()
+ /**
+ * all checks before installation.
+ * @return boolean
+ */
+ private function checkBeforeInstall()
{
- Tools::initPhp();
- Session::init();
+ $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 (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) {
- $this->user = $_SESSION['poche_user'];
+ 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;
}
- else {
- # fake user, just for install & login screens
- $this->user = new User();
- $this->user->setConfig($this->getDefaultConfig());
+
+ if (!$allIsGood) {
+ echo $this->tpl->render('error.twig', array(
+ 'msg' => $msg
+ ));
}
- # l10n
- $language = $this->user->getConfigValue('language');
- putenv('LC_ALL=' . $language);
- setlocale(LC_ALL, $language);
- bindtextdomain($language, LOCALE);
- textdomain($language);
+ return $allIsGood;
+ }
+ private function initTpl()
+ {
# template engine
$loader = new Twig_Loader_Filesystem(TPL);
if (DEBUG_POCHE) {
# filter for reading time
$filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
$this->tpl->addFilter($filter);
+ }
+
+ private function init()
+ {
+ Tools::initPhp();
+ Session::init();
+
+ if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) {
+ $this->user = $_SESSION['poche_user'];
+ }
+ else {
+ # fake user, just for install & login screens
+ $this->user = new User();
+ $this->user->setConfig($this->getDefaultConfig());
+ }
+
+ # l10n
+ $language = $this->user->getConfigValue('language');
+ putenv('LC_ALL=' . $language);
+ setlocale(LC_ALL, $language);
+ bindtextdomain($language, LOCALE);
+ textdomain($language);
# Pagination
$this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
<p>
{% trans "poche is still not installed. Please fill the below form to install it. Don't hesitate to <a href='http://inthepoche.com/?pages/Documentation'>read the documentation on poche website</a>." %}
</p>
- <div class="row">
+ <p class="row">
<label class="col w150p" for="login">{% trans "Login" %}</label>
<input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus />
- </div>
- <div class="row">
+ </p>
+ <p class="row">
<label class="col w150p" for="password">{% trans "Password" %}</label>
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
- </div>
- <div class="row">
+ </p>
+ <p class="row">
<label class="col w150p" for="password_repeat">{% trans "Repeat your password" %}</label>
<input class="col" type="password" id="password_repeat" name="password_repeat" placeholder="Password" tabindex="3">
- </div>
- <div class="row mts txtcenter">
+ </p>
+ <p class="row mts txtcenter">
<button class="bouton" type="submit" tabindex="4">{% trans "Install" %}</button>
- </div>
+ </p>
</fieldset>
<input type="hidden" name="token" value="{{ token }}">
</form>