public function languagesExportToFile() { global $ARGS, $baseDir; $setting = Models\Language::loadOne($ARGS['id']); if ($setting) { $language = $setting->c['language']; $filename = $baseDir . $setting->c['location']; $csv = "# " . date("Y-m-d H:i:s") . "\n"; foreach (Models\Translation::getAll() as $id) { $translation = Models\Translation::loadOne($id); $trans = $translation->c[$language]; if (!$trans || $trans == "") { $trans = ""; //$translation->c["name"]; } if (!preg_match('/[^a-z_\\-0-9]/i', $translation->c['name'])) { $csv .= $translation->c['name'] . " = \"" . str_replace('"', '\\"', $trans) . "\"\n"; } } $res = file_put_contents($filename, $csv); if ($res) { $setting->c['published'] = date("Y-m-d H:i:s"); Models\Language::updateOne($setting); return array("status" => 1, "msg" => "Language file created"); } } return array("status" => 0, "msg" => "Language file creation failed"); }
public function translated($req = array(), $opt = array()) { $search = Translation::search(array_merge($req, array($this->c['language'] => new Atabase\QueryPredicate\InPredicate(array("", null), true))), $opt); return $search['count']; }
$baseDir = __DIR__ . '/..'; require_once $baseDir . '/vendor/autoload.php'; $kernel = Atabase\Bootstrapper::KERNEL_DEV; $bootstrapper = new Atabase\Bootstrapper($kernel, $baseDir); $bootstrapper->init(); global $CONFIG; $CONFIG->setValue("general", "baseDir", $baseDir); } catch (PDOException $e) { $logger = new Monolog\Logger('database'); $logger->pushHandler(new Monolog\Handler\StreamHandler($baseDir . '/tmp/database.log', Monolog\Logger::DEBUG)); $logger->addCritical($e->getMessage()); header(Atabase\Exceptions\HTTPStatusLookup::httpHeaderFor(500)); echo Atabase\Exceptions\HTTPStatusLookup::getMessageForCode(500) . ' - Database Connection Error'; exit; } catch (HTTPErrorException $e) { $logger = new Monolog\Logger('kernel'); $logger->pushHandler(new Monolog\Handler\StreamHandler($baseDir . '/tmp/kernel.log', Monolog\Logger::DEBUG)); $logger->addCritical($e->getMessage()); $e->terminate(" - Kernel Loading Failed"); } /***************************************/ /* LANGUAGES TEST */ /***************************************/ echo "<h1>Languages test</h1>"; global $TEMPLATE, $ARGS, $CONFIG; $translation = Models\Translation::loadOne('1'); $languageCategory = Models\LanguageCategory::loadOne('1'); $language = MOdels\Language::loadOne('1'); echo "<p>" . $translation . "</p>"; echo "<p>" . $languageCategory . "</p>"; echo "<p>" . $language . "</p>";
public static function returnObject($key) { return Translation::autocompleteOne("name", $key); }