aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/poche/Poche.class.php85
1 files changed, 44 insertions, 41 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 1ba8e7c1..899d7356 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