Rev 348 | Rev 386 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 348 | Rev 360 | ||
---|---|---|---|
Line 83... | Line 83... | ||
83 | if (!is_null($slang)) { |
83 | if (!is_null($slang)) { |
84 | return $slang->natOrder($fieldname, $order); |
84 | return $slang->natOrder($fieldname, $order); |
85 | } else { |
85 | } else { |
86 | $order = strtolower($order); |
86 | $order = strtolower($order); |
87 | if (($order != 'asc') && ($order != 'desc')) { |
87 | if (($order != 'asc') && ($order != 'desc')) { |
88 | throw new OIDplusException("Invalid order '$order' (needs to be 'asc' or 'desc')"); |
88 | throw new OIDplusException(_L('Invalid order "%1" (needs to be "asc" or "desc")',$order)); |
89 | } |
89 | } |
90 | 90 | ||
91 | // For (yet) unsupported DBMS, we do not offer natural sort |
91 | // For (yet) unsupported DBMS, we do not offer natural sort |
92 | return "$fieldname $order"; |
92 | return "$fieldname $order"; |
93 | } |
93 | } |
Line 111... | Line 111... | ||
111 | // Note: The config setting "database_version" is inserted in setup/sql/...sql, not in the OIDplus core init |
111 | // Note: The config setting "database_version" is inserted in setup/sql/...sql, not in the OIDplus core init |
112 | 112 | ||
113 | $res = $this->query("SELECT value FROM ###config WHERE name = 'database_version'"); |
113 | $res = $this->query("SELECT value FROM ###config WHERE name = 'database_version'"); |
114 | $row = $res->fetch_array(); |
114 | $row = $res->fetch_array(); |
115 | if ($row == null) { |
115 | if ($row == null) { |
116 | throw new OIDplusConfigInitializationException('Cannot determine database version (the entry "database_version" inside the table "###config" is probably missing)'); |
116 | throw new OIDplusConfigInitializationException(_L('Cannot determine database version (the entry "database_version" inside the table "###config" is probably missing)')); |
117 | } |
117 | } |
118 | $version = $row['value']; |
118 | $version = $row['value']; |
119 | if (!is_numeric($version) || ($version < 200) || ($version > 999)) { |
119 | if (!is_numeric($version) || ($version < 200) || ($version > 999)) { |
120 | throw new OIDplusConfigInitializationException('Entry "database_version" inside the table "###config" seems to be wrong (expect number between 200 and 999)'); |
120 | throw new OIDplusConfigInitializationException(_L('Entry "database_version" inside the table "###config" seems to be wrong (expect number between 200 and 999)')); |
121 | } |
121 | } |
122 | 122 | ||
123 | while (file_exists($file = OIDplus::basePath().'/includes/db_updates/update'.$version.'.inc.php')) { |
123 | while (file_exists($file = OIDplus::basePath().'/includes/db_updates/update'.$version.'.inc.php')) { |
124 | $prev_version = $version; |
124 | $prev_version = $version; |
125 | include $file; // run update-script |
125 | include $file; // run update-script |
126 | if ($version != $prev_version+1) { |
126 | if ($version != $prev_version+1) { |
127 | // This should usually not happen, since the update-file should increase the version |
127 | // This should usually not happen, since the update-file should increase the version |
128 | // or throw an Exception by itself |
128 | // or throw an Exception by itself |
129 | throw new OIDplusException("Database update $prev_version -> ".($prev_version+1)." failed (script reports new version to be $version)"); |
129 | throw new OIDplusException(_L('Database update %1 -> %2 failed (script reports new version to be %3)',$prev_version,$prev_version+1,$version)); |
130 | } |
130 | } |
131 | } |
131 | } |
132 | 132 | ||
133 | // Now that our database is up-to-date, we check if database tables are existing |
133 | // Now that our database is up-to-date, we check if database tables are existing |
134 | // without config table, because it was checked above |
134 | // without config table, because it was checked above |
Line 145... | Line 145... | ||
145 | private function initRequireTables($tableNames)/*: void*/ { |
145 | private function initRequireTables($tableNames)/*: void*/ { |
146 | $msgs = array(); |
146 | $msgs = array(); |
147 | foreach ($tableNames as $tableName) { |
147 | foreach ($tableNames as $tableName) { |
148 | $prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX', ''); |
148 | $prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX', ''); |
149 | if (!$this->tableExists($prefix.$tableName)) { |
149 | if (!$this->tableExists($prefix.$tableName)) { |
150 | $msgs[] = 'Table '.$prefix.$tableName.' is missing!'; |
150 | $msgs[] = _L('Table %1 is missing!',$prefix.$tableName); |
151 | } |
151 | } |
152 | } |
152 | } |
153 | if (count($msgs) > 0) { |
153 | if (count($msgs) > 0) { |
154 | throw new OIDplusConfigInitializationException(implode("\n\n",$msgs)); |
154 | throw new OIDplusConfigInitializationException(implode("\n\n",$msgs)); |
155 | } |
155 | } |
Line 188... | Line 188... | ||
188 | if (is_null($slangCache)) { |
188 | if (is_null($slangCache)) { |
189 | if (OIDplus::baseConfig()->exists('FORCE_DBMS_SLANG')) { |
189 | if (OIDplus::baseConfig()->exists('FORCE_DBMS_SLANG')) { |
190 | $name = OIDplus::baseConfig()->getValue('FORCE_DBMS_SLANG', ''); |
190 | $name = OIDplus::baseConfig()->getValue('FORCE_DBMS_SLANG', ''); |
191 | $slangCache = OIDplus::getSqlSlangPlugin($name); |
191 | $slangCache = OIDplus::getSqlSlangPlugin($name); |
192 | if ($mustExist && is_null($slangCache)) { |
192 | if ($mustExist && is_null($slangCache)) { |
193 | throw new OIDplusConfigInitializationException("Enforced SQL slang (via setting FORCE_DBMS_SLANG) '$name' does not exist."); |
193 | throw new OIDplusConfigInitializationException(_L('Enforced SQL slang (via setting FORCE_DBMS_SLANG) "%1" does not exist.',$name)); |
194 | } |
194 | } |
195 | } else { |
195 | } else { |
196 | foreach (OIDplus::getSqlSlangPlugins() as $plugin) { |
196 | foreach (OIDplus::getSqlSlangPlugins() as $plugin) { |
197 | if ($plugin->detect($this)) { |
197 | if ($plugin->detect($this)) { |
198 | $slangCache = $plugin; |
198 | $slangCache = $plugin; |
199 | break; |
199 | break; |
200 | } |
200 | } |
201 | } |
201 | } |
202 | if ($mustExist && is_null($slangCache)) { |
202 | if ($mustExist && is_null($slangCache)) { |
203 | throw new OIDplusException("Cannot determine the SQL slang of your DBMS. Your DBMS is probably not supported."); |
203 | throw new OIDplusException(_L('Cannot determine the SQL slang of your DBMS. Your DBMS is probably not supported.')); |
204 | } |
204 | } |
205 | } |
205 | } |
206 | } |
206 | } |
207 | 207 | ||
208 | return $slangCache; |
208 | return $slangCache; |
209 | } |
209 | } |
210 | } |
210 | } |
211 | - |