aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
authorJean-Christophe Saad-Dupuy <saad.dupuy@gmail.com>2013-10-07 14:25:24 +0200
committerJean-Christophe Saad-Dupuy <saad.dupuy@gmail.com>2013-10-07 14:25:24 +0200
commit5e07dc8b51f9612de5f5a00bbac399c777e82fa4 (patch)
tree66454b9a6dd4e8cd045dd8451a268cf914e583b8 /inc
parent2916d24b209e1e36cf22cb902d7e6dc34113c7e5 (diff)
parent894c36ea32d38d425e27dae43a29dcd9e669040e (diff)
downloadwallabag-5e07dc8b51f9612de5f5a00bbac399c777e82fa4.tar.gz
wallabag-5e07dc8b51f9612de5f5a00bbac399c777e82fa4.tar.zst
wallabag-5e07dc8b51f9612de5f5a00bbac399c777e82fa4.zip
Merge remote branch 'upstream/dev' into dev
Conflicts: themes/default/_head.twig
Diffstat (limited to 'inc')
-rw-r--r--inc/poche/Poche.class.php89
-rwxr-xr-xinc/poche/config.inc.php.new2
2 files changed, 46 insertions, 45 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 1ba8e7c1..245f6a13 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -20,7 +20,7 @@ class Poche
20 public $pagination; 20 public $pagination;
21 21
22 private $currentTheme = ''; 22 private $currentTheme = '';
23 private $notInstalledMessage = ''; 23 private $notInstalledMessage = array();
24 24
25 # @todo make this dynamic (actually install themes and save them in the database including author information et cetera) 25 # @todo make this dynamic (actually install themes and save them in the database including author information et cetera)
26 private $installedThemes = array( 26 private $installedThemes = array(
@@ -33,28 +33,21 @@ class Poche
33 33
34 public function __construct() 34 public function __construct()
35 { 35 {
36 if (! $this->configFileIsAvailable()) { 36 if ($this->configFileIsAvailable()) {
37 return; 37 $this->init();
38 } 38 }
39 39
40 $this->init(); 40 if ($this->themeIsInstalled()) {
41 41 $this->initTpl();
42 if (! $this->themeIsInstalled()) {
43 return;
44 } 42 }
45 43
46 $this->initTpl(); 44 if ($this->systemIsInstalled()) {
47 45 $this->store = new Database();
48 if (! $this->systemIsInstalled()) { 46 $this->messages = new Messages();
49 return; 47 # installation
50 } 48 if (! $this->store->isInstalled()) {
51 49 $this->install();
52 $this->store = new Database(); 50 }
53 $this->messages = new Messages();
54
55 # installation
56 if (! $this->store->isInstalled()) {
57 $this->install();
58 } 51 }
59 } 52 }
60 53
@@ -94,7 +87,7 @@ class Poche
94 87
95 public function configFileIsAvailable() { 88 public function configFileIsAvailable() {
96 if (! self::$configFileAvailable) { 89 if (! self::$configFileAvailable) {
97 $this->notInstalledMessage = 'You have to rename <strong>inc/poche/config.inc.php.new</strong> to <strong>inc/poche/config.inc.php</strong>.'; 90 $this->notInstalledMessage[] = 'You have to rename inc/poche/config.inc.php.new to inc/poche/config.inc.php.';
98 91
99 return false; 92 return false;
100 } 93 }
@@ -103,39 +96,44 @@ class Poche
103 } 96 }
104 97
105 public function themeIsInstalled() { 98 public function themeIsInstalled() {
99 $passTheme = TRUE;
106 # Twig is an absolute requirement for Poche to function. Abort immediately if the Composer installer hasn't been run yet 100 # Twig is an absolute requirement for Poche to function. Abort immediately if the Composer installer hasn't been run yet
107 if (! self::$canRenderTemplates) { 101 if (! self::$canRenderTemplates) {
108 $this->notInstalledMessage = 'Twig does not seem to be installed. Please initialize the Composer installation to automatically fetch dependencies. Have a look at <a href="http://doc.inthepoche.com/doku.php?id=users:begin:install">the documentation.</a>'; 102 $this->notInstalledMessage[] = 'Twig does not seem to be installed. Please initialize the Composer installation to automatically fetch dependencies. Have a look at <a href="http://doc.inthepoche.com/doku.php?id=users:begin:install">the documentation.</a>';
109 103 $passTheme = FALSE;
110 return false;
111 } 104 }
112 105
113 if (! is_writable(CACHE)) { 106 if (! is_writable(CACHE)) {
114 $this->notInstalledMessage = '<h1>error</h1><p>You don\'t have write access on cache directory.</p>'; 107 $this->notInstalledMessage[] = 'You don\'t have write access on cache directory.';
115 108
116 self::$canRenderTemplates = false; 109 self::$canRenderTemplates = false;
117 110
118 return false; 111 $passTheme = FALSE;
119 } 112 }
120 113
121 # Check if the selected theme and its requirements are present 114 # Check if the selected theme and its requirements are present
122 if (! is_dir(THEME . '/' . $this->getTheme())) { 115 if ($this->getTheme() != '' && ! is_dir(THEME . '/' . $this->getTheme())) {
123 $this->notInstalledMessage = 'The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $this->getTheme() . ')'; 116 $this->notInstalledMessage[] = 'The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $this->getTheme() . ')';
124 117
125 self::$canRenderTemplates = false; 118 self::$canRenderTemplates = false;
126 119
127 return false; 120 $passTheme = FALSE;
128 } 121 }
129 122
130 foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) { 123 foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) {
131 if (! is_dir(THEME . '/' . $requiredTheme)) { 124 if (! is_dir(THEME . '/' . $requiredTheme)) {
132 $this->notInstalledMessage = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')'; 125 $this->notInstalledMessage[] = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')';
133 126
134 self::$canRenderTemplates = false; 127 self::$canRenderTemplates = false;
135 128
136 return false; 129 $passTheme = FALSE;
137 } 130 }
138 } 131 }
132
133 if (!$passTheme) {
134 return FALSE;
135 }
136
139 137
140 return true; 138 return true;
141 } 139 }
@@ -147,25 +145,30 @@ class Poche
147 */ 145 */
148 public function systemIsInstalled() 146 public function systemIsInstalled()
149 { 147 {
150 $msg = ''; 148 $msg = TRUE;
151 149
152 $configSalt = defined('SALT') ? constant('SALT') : ''; 150 $configSalt = defined('SALT') ? constant('SALT') : '';
153 151
154 if (empty($configSalt)) { 152 if (empty($configSalt)) {
155 $msg = '<h1>error</h1><p>You have not yet filled in the SALT value in the config.inc.php file.</p>'; 153 $this->notInstalledMessage[] = 'You have not yet filled in the SALT value in the config.inc.php file.';
156 } else if (STORAGE == 'sqlite' && ! file_exists(STORAGE_SQLITE)) { 154 $msg = FALSE;
155 }
156 if (STORAGE == 'sqlite' && ! file_exists(STORAGE_SQLITE)) {
157 Tools::logm('sqlite file doesn\'t exist'); 157 Tools::logm('sqlite file doesn\'t exist');
158 $msg = '<h1>error</h1><p>sqlite file doesn\'t exist, you can find it in install folder. Copy it in /db folder.</p>'; 158 $this->notInstalledMessage[] = 'sqlite file doesn\'t exist, you can find it in install folder. Copy it in /db folder.';
159 } else if (is_dir(ROOT . '/install') && ! DEBUG_POCHE) { 159 $msg = FALSE;
160 $msg = '<h1>install folder</h1><p>you have to delete the /install folder before using poche.</p>'; 160 }
161 } else if (STORAGE == 'sqlite' && ! is_writable(STORAGE_SQLITE)) { 161 if (is_dir(ROOT . '/install') && ! DEBUG_POCHE) {
162 $this->notInstalledMessage[] = 'you have to delete the /install folder before using poche.';
163 $msg = FALSE;
164 }
165 if (STORAGE == 'sqlite' && ! is_writable(STORAGE_SQLITE)) {
162 Tools::logm('you don\'t have write access on sqlite file'); 166 Tools::logm('you don\'t have write access on sqlite file');
163 $msg = '<h1>error</h1><p>You don\'t have write access on sqlite file.</p>'; 167 $this->notInstalledMessage[] = 'You don\'t have write access on sqlite file.';
168 $msg = FALSE;
164 } 169 }
165 170
166 if (! empty($msg)) { 171 if (! $msg) {
167 $this->notInstalledMessage = $msg;
168
169 return false; 172 return false;
170 } 173 }
171 174
@@ -363,8 +366,8 @@ class Poche
363 case 'config': 366 case 'config':
364 $dev = $this->getPocheVersion('dev'); 367 $dev = $this->getPocheVersion('dev');
365 $prod = $this->getPocheVersion('prod'); 368 $prod = $this->getPocheVersion('prod');
366 $compare_dev = version_compare(POCHE_VERSION, $dev); 369 $compare_dev = version_compare(POCHE, $dev);
367 $compare_prod = version_compare(POCHE_VERSION, $prod); 370 $compare_prod = version_compare(POCHE, $prod);
368 $themes = $this->getInstalledThemes(); 371 $themes = $this->getInstalledThemes();
369 $tpl_vars = array( 372 $tpl_vars = array(
370 'themes' => $themes, 373 'themes' => $themes,
diff --git a/inc/poche/config.inc.php.new b/inc/poche/config.inc.php.new
index 902509e3..c60d4f80 100755
--- a/inc/poche/config.inc.php.new
+++ b/inc/poche/config.inc.php.new
@@ -52,8 +52,6 @@ define ('CACHE', ROOT . '/cache');
52 52
53define ('PAGINATION', '10'); 53define ('PAGINATION', '10');
54 54
55define ('POCHE_VERSION', '1.0.0');
56
57define ('POCKET_FILE', '/ril_export.html'); 55define ('POCKET_FILE', '/ril_export.html');
58define ('READABILITY_FILE', '/readability'); 56define ('READABILITY_FILE', '/readability');
59define ('INSTAPAPER_FILE', '/instapaper-export.html'); 57define ('INSTAPAPER_FILE', '/instapaper-export.html');