diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 1ba8e7c14..245f6a138 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -20,7 +20,7 @@ class Poche public $pagination; private $currentTheme = ''; - private $notInstalledMessage = ''; + private $notInstalledMessage = array(); # @todo make this dynamic (actually install themes and save them in the database including author information et cetera) private $installedThemes = array( @@ -33,28 +33,21 @@ class Poche public function __construct() { - if (! $this->configFileIsAvailable()) { - return; + if ($this->configFileIsAvailable()) { + $this->init(); } - $this->init(); - - if (! $this->themeIsInstalled()) { - return; + if ($this->themeIsInstalled()) { + $this->initTpl(); } - $this->initTpl(); - - if (! $this->systemIsInstalled()) { - return; - } - - $this->store = new Database(); - $this->messages = new Messages(); - - # installation - if (! $this->store->isInstalled()) { - $this->install(); + if ($this->systemIsInstalled()) { + $this->store = new Database(); + $this->messages = new Messages(); + # installation + if (! $this->store->isInstalled()) { + $this->install(); + } } } @@ -94,7 +87,7 @@ class Poche public function configFileIsAvailable() { if (! self::$configFileAvailable) { - $this->notInstalledMessage = 'You have to rename inc/poche/config.inc.php.new to inc/poche/config.inc.php.'; + $this->notInstalledMessage[] = 'You have to rename inc/poche/config.inc.php.new to inc/poche/config.inc.php.'; return false; } @@ -103,39 +96,44 @@ class Poche } public function themeIsInstalled() { + $passTheme = TRUE; # Twig is an absolute requirement for Poche to function. Abort immediately if the Composer installer hasn't been run yet if (! self::$canRenderTemplates) { - $this->notInstalledMessage = 'Twig does not seem to be installed. Please initialize the Composer installation to automatically fetch dependencies. Have a look at the documentation.'; - - return false; + $this->notInstalledMessage[] = 'Twig does not seem to be installed. Please initialize the Composer installation to automatically fetch dependencies. Have a look at the documentation.'; + $passTheme = FALSE; } if (! is_writable(CACHE)) { - $this->notInstalledMessage = '

error

You don\'t have write access on cache directory.

'; + $this->notInstalledMessage[] = 'You don\'t have write access on cache directory.'; self::$canRenderTemplates = false; - return false; + $passTheme = FALSE; } # Check if the selected theme and its requirements are present - if (! is_dir(THEME . '/' . $this->getTheme())) { - $this->notInstalledMessage = 'The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $this->getTheme() . ')'; + if ($this->getTheme() != '' && ! is_dir(THEME . '/' . $this->getTheme())) { + $this->notInstalledMessage[] = 'The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $this->getTheme() . ')'; self::$canRenderTemplates = false; - return false; + $passTheme = FALSE; } foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) { if (! is_dir(THEME . '/' . $requiredTheme)) { - $this->notInstalledMessage = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')'; + $this->notInstalledMessage[] = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')'; self::$canRenderTemplates = false; - return false; + $passTheme = FALSE; } } + + if (!$passTheme) { + return FALSE; + } + return true; } @@ -147,25 +145,30 @@ class Poche */ public function systemIsInstalled() { - $msg = ''; + $msg = TRUE; $configSalt = defined('SALT') ? constant('SALT') : ''; if (empty($configSalt)) { - $msg = '

error

You have not yet filled in the SALT value in the config.inc.php file.

'; - } else if (STORAGE == 'sqlite' && ! file_exists(STORAGE_SQLITE)) { + $this->notInstalledMessage[] = 'You have not yet filled in the SALT value in the config.inc.php file.'; + $msg = FALSE; + } + if (STORAGE == 'sqlite' && ! file_exists(STORAGE_SQLITE)) { Tools::logm('sqlite file doesn\'t exist'); - $msg = '

error

sqlite file doesn\'t exist, you can find it in install folder. Copy it in /db folder.

'; - } else if (is_dir(ROOT . '/install') && ! DEBUG_POCHE) { - $msg = '

install folder

you have to delete the /install folder before using poche.

'; - } else if (STORAGE == 'sqlite' && ! is_writable(STORAGE_SQLITE)) { + $this->notInstalledMessage[] = 'sqlite file doesn\'t exist, you can find it in install folder. Copy it in /db folder.'; + $msg = FALSE; + } + if (is_dir(ROOT . '/install') && ! DEBUG_POCHE) { + $this->notInstalledMessage[] = 'you have to delete the /install folder before using poche.'; + $msg = FALSE; + } + if (STORAGE == 'sqlite' && ! is_writable(STORAGE_SQLITE)) { Tools::logm('you don\'t have write access on sqlite file'); - $msg = '

error

You don\'t have write access on sqlite file.

'; + $this->notInstalledMessage[] = 'You don\'t have write access on sqlite file.'; + $msg = FALSE; } - if (! empty($msg)) { - $this->notInstalledMessage = $msg; - + if (! $msg) { return false; } @@ -363,8 +366,8 @@ class Poche case 'config': $dev = $this->getPocheVersion('dev'); $prod = $this->getPocheVersion('prod'); - $compare_dev = version_compare(POCHE_VERSION, $dev); - $compare_prod = version_compare(POCHE_VERSION, $prod); + $compare_dev = version_compare(POCHE, $dev); + $compare_prod = version_compare(POCHE, $prod); $themes = $this->getInstalledThemes(); $tpl_vars = array( 'themes' => $themes, diff --git a/inc/poche/config.inc.php.new b/inc/poche/config.inc.php.new index 902509e3d..c60d4f800 100755 --- a/inc/poche/config.inc.php.new +++ b/inc/poche/config.inc.php.new @@ -52,8 +52,6 @@ define ('CACHE', ROOT . '/cache'); define ('PAGINATION', '10'); -define ('POCHE_VERSION', '1.0.0'); - define ('POCKET_FILE', '/ril_export.html'); define ('READABILITY_FILE', '/readability'); define ('INSTAPAPER_FILE', '/instapaper-export.html'); diff --git a/index.php b/index.php index 4aebfe10a..22696c6fd 100644 --- a/index.php +++ b/index.php @@ -8,6 +8,7 @@ * @license http://www.wtfpl.net/ see COPYING file */ +define ('POCHE', '1.0.0'); require_once 'inc/poche/global.inc.php'; # Start Poche @@ -35,7 +36,12 @@ $tpl_vars = array( if (! empty($notInstalledMessage)) { if (! Poche::$canRenderTemplates || ! Poche::$configFileAvailable) { # We cannot use Twig to display the error message - die($notInstalledMessage); + echo '

Errors

    '; + foreach ($notInstalledMessage as $message) { + echo '
  1. ' . $message . '
  2. '; + } + echo '
'; + die(); } else { # Twig is installed, put the error message in the template $tpl_file = Tools::getTplFile('error'); diff --git a/install/update_sqlite_from_0_to_1.php b/install/update_sqlite_from_0_to_1.php deleted file mode 100644 index 299abf48d..000000000 --- a/install/update_sqlite_from_0_to_1.php +++ /dev/null @@ -1,72 +0,0 @@ -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - -# Requêtes à exécuter pour mettre à jour poche.sqlite en 1.x - -# ajout d'un champ user_id sur la table entries -$sql = 'ALTER TABLE entries RENAME TO tempEntries;'; -$query = $handle->prepare($sql); -$query->execute(); - -$sql = 'CREATE TABLE entries (id INTEGER PRIMARY KEY, title TEXT, url TEXT, is_read NUMERIC DEFAULT 0, is_fav NUMERIC DEFAULT 0, content BLOB, user_id NUMERIC);'; -$query = $handle->prepare($sql); -$query->execute(); - -$sql = 'INSERT INTO entries (id, title, url, is_read, is_fav, content) SELECT id, title, url, is_read, is_fav, content FROM tempEntries;'; -$query = $handle->prepare($sql); -$query->execute(); - -# Update tout pour mettre user_id = 1 -$sql = 'UPDATE entries SET user_id = 1;'; -$query = $handle->prepare($sql); -$query->execute(); - -# Changement des flags pour les lus / favoris -$sql = 'UPDATE entries SET is_read = 1 WHERE is_read = -1;'; -$query = $handle->prepare($sql); -$query->execute(); - -$sql = 'UPDATE entries SET is_fav = 1 WHERE is_fav = -1;'; -$query = $handle->prepare($sql); -$query->execute(); - -# Création de la table users -$sql = 'CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT, password TEXT, name TEXT, email TEXT);'; -$query = $handle->prepare($sql); -$query->execute(); - -$sql = 'INSERT INTO users (username) SELECT value FROM config WHERE name = "login";'; -$query = $handle->prepare($sql); -$query->execute(); - -$sql = "UPDATE users SET password = (SELECT value FROM config WHERE name = 'password')"; -$query = $handle->prepare($sql); -$query->execute(); - -# Création de la table users_config -$sql = 'CREATE TABLE users_config (id INTEGER PRIMARY KEY, user_id NUMERIC, name TEXT, value TEXT);'; -$query = $handle->prepare($sql); -$query->execute(); - -$sql = 'INSERT INTO users_config (user_id, name, value) VALUES (1, "pager", "10");'; -$query = $handle->prepare($sql); -$query->execute(); - -$sql = 'INSERT INTO users_config (user_id, name, value) VALUES (1, "language", "en_EN.UTF8");'; -$query = $handle->prepare($sql); -$query->execute(); - -# Suppression de la table temporaire -$sql = 'DROP TABLE tempEntries;'; -$query = $handle->prepare($sql); -$query->execute(); - -# Vidage de la table de config -$sql = 'DELETE FROM config;'; -$query = $handle->prepare($sql); -$query->execute(); - -echo 'welcome to poche 1.0 !'; \ No newline at end of file diff --git a/install/update_to_1beta3.php b/install/update_to_1beta3.php deleted file mode 100644 index e0da1590d..000000000 --- a/install/update_to_1beta3.php +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - updating poche - - -

update poche to 1.0-beta3

- -

Changelog

-

-

-

-

To update your poche, please fill the following fields.

-

-

-
-
-
-
-

-login($_POST['login'], sha1($_POST['password'] . $_POST['login'] . $old_salt)); - if ($user != array()) { - $new_salt = md5(time() . $_SERVER['SCRIPT_FILENAME'] . rand()); - $myconfig_file = '../inc/poche/myconfig.inc.php'; - if (!is_writable('../inc/poche/')) { - die('You don\'t have write access to create ./inc/poche/myconfig.inc.php.'); - } - - if (!file_exists($myconfig_file)) - { - $fp = fopen($myconfig_file, 'w'); - - fwrite($fp, 'updatePassword($user['id'], sha1($_POST['password'] . $_POST['login'] . $new_salt)); -?> -

your poche is up to date!

-

don't forget to delete ./install/ folder after the update.

-

go back to your poche

- - - \ No newline at end of file diff --git a/themes/default/_footer.twig b/themes/default/_footer.twig index 2b8958549..06148a57c 100644 --- a/themes/default/_footer.twig +++ b/themes/default/_footer.twig @@ -1,4 +1,4 @@ \ No newline at end of file diff --git a/themes/default/_head.twig b/themes/default/_head.twig index 9745459c4..247b929eb 100644 --- a/themes/default/_head.twig +++ b/themes/default/_head.twig @@ -8,4 +8,4 @@ - + diff --git a/themes/default/config.twig b/themes/default/config.twig index 0f1aea80b..13bdaafd9 100644 --- a/themes/default/config.twig +++ b/themes/default/config.twig @@ -23,7 +23,7 @@

{% trans "Updating poche" %}

@@ -77,4 +77,4 @@

{% trans "Export your poche datas" %}

{% trans "Click here" %} {% trans "to export your poche datas." %}

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/themes/default/css/style.css b/themes/default/css/style.css index eb04f0c48..3ef9c8236 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -188,7 +188,7 @@ a:visited { bottom: 0; left: 0; width: 100%; - height: 50px; + min-height: 50px; padding-top: 17px; text-align: center; color: #fff; diff --git a/themes/default/error.twig b/themes/default/error.twig index c829d12bb..99eb1ed65 100644 --- a/themes/default/error.twig +++ b/themes/default/error.twig @@ -1,6 +1,11 @@ {% extends "layout.twig" %} {% block title %}{% trans "plop" %}{% endblock %} {% block content %} - {{ msg|raw }} -

Don't forget the documentation.

+

Errors

+
    + {% for message in msg %} +
  1. {{message}}
  2. + {% endfor %} +
+

Don't forget the documentation.

{% endblock %} \ No newline at end of file