public function onLoad() { // select language to use (this must be listed in server's locale -a) $this->language = config::get('locale.language', 'en_US.utf8'); $this->domain = config::get('locale.domain', TXF_APPLICATION); putenv('LANGUAGE=' . $this->language); putenv('LANG=' . $this->language); putenv('LC_ALL=' . $this->language); if (!setlocale(LC_ALL, $this->language)) { log::error('could not select locale %s', $this->language); } if (\extension_loaded('gettext')) { // bind configured domain to configured path containing l10n files $path = config::get('locale.path', path::glue(TXF_APPLICATION_PATH, 'locale')); bindtextdomain($this->domain, $path); textdomain($this->domain); bind_textdomain_codeset($this->domain, 'UTF-8'); if ($this->domain !== 'txf') { // bind domain "txf" to l10n path included with current extension $path = path::glue(dirname(__DIR__), 'locale'); bindtextdomain('txf', $path); bind_textdomain_codeset('txf', 'UTF-8'); } } self::$collectionMode = config::get('locale.collect.mode', ''); self::$collectionFile = config::get('locale.collect.file'); }
/** * Tries to query database. * * Provide bound parameters in additional arguments or as single array of * parameters. * * "Trying" and "test" don't indicate that datasource isn't actually queried * or modified by some proper query. This method is available in addition to * cell() etc. to return true or false instead of a resultset. It's also * different from other methods in that's capturing any datasource-related * exceptions returning actually false on a failed query. * * @throws \BadMethodCallException * @param string,... $query query on datasource, followed by one or more parameters to bind on query * @return boolean true on successfully querying, false on failure */ public function test($query) { $arguments = func_get_args(); try { return $this->__fastQuery(null, $arguments); } catch (datasource_exception $e) { txf\log::debug(sprintf('PDO exception on testing: %s', $e->getMessage())); return false; } }