本文整理汇总了PHP中language::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP language::getInstance方法的具体用法?PHP language::getInstance怎么用?PHP language::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类language
的用法示例。
在下文中一共展示了language::getInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Default data for main page.
*/
public function init()
{
// title is globally also for 404 pages.
$serial_title = property::getInstance()->get('seo_title');
$serial_desc = property::getInstance()->get('seo_description');
$serial_keywords = property::getInstance()->get('seo_keywords');
$this->metadata['title'][] = $serial_title[language::getInstance()->getUseLanguage()];
if (router::getInstance()->isMain()) {
$this->metadata['description'][] = $serial_desc[language::getInstance()->getUseLanguage()];
$this->metadata['keywords'][] = $serial_keywords[language::getInstance()->getUseLanguage()];
}
$this->metadata['global_title'] = $serial_title[language::getInstance()->getUseLanguage()];
}
示例2: init
public function init()
{
if (is_null($this->link)) {
if (file_exists(root . '/config.php')) {
try {
$this->link = @new \PDO("mysql:host=" . property::getInstance()->get('db_host') . ";dbname=" . property::getInstance()->get('db_name') . "", property::getInstance()->get('db_user'), property::getInstance()->get('db_pass'), array(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, \PDO::ATTR_EMULATE_PREPARES => false, \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => false));
} catch (\PDOException $e) {
if (loader != 'install') {
logger::getInstance()->log(logger::LEVEL_ERR, "Database is down! Check configuration and database server uplink! Log: " . $e->getMessage());
exit(language::getInstance()->get('database_down_desc') . " " . property::getInstance()->get('mail_from'));
}
}
} else {
logger::getInstance()->log(logger::LEVEL_ERR, "Configuration file /config.php is not available - database connect FAIL!");
}
}
}
示例3: viewInstall
private function viewInstall()
{
$params = array();
if (file_exists(root . '/install/.lock')) {
$params['notify']['prepare']['lock'] = true;
}
if (file_exists(root . '/config.php') && !is_writable(root . '/config.php')) {
$params['notify']['prepare']['cfg_write'] = true;
}
if (!is_writable(root . '/install/')) {
$params['notify']['prepare']['inst_write'] = true;
}
if (!file_exists(root . '/install/sql/install.sql')) {
$params['notify']['prepare']['sql_notfound'] = true;
}
$timezone_array = timezone::getInstance()->getZoneUTC();
template::getInstance()->set(template::TYPE_SYSTEM, 'timezones', $timezone_array);
if (sizeof($params['notify']) == 0) {
if (system::getInstance()->post('submit')) {
$testCon = null;
try {
$testCon = @new \PDO("mysql:host=" . system::getInstance()->post('config:db_host') . ";dbname=" . system::getInstance()->post('config:db_name') . "", system::getInstance()->post('config:db_user'), system::getInstance()->post('config:db_pass'));
} catch (\PDOException $exception) {
$params['notify']['process']['db_conn_miss'] = true;
}
if ($testCon != null) {
$reg_login = system::getInstance()->post('admin:login');
$reg_email = system::getInstance()->post('admin:email');
$reg_pass = system::getInstance()->post('admin:pass');
$reg_repass = system::getInstance()->post('admin:repass');
if (!filter_var($reg_email, FILTER_VALIDATE_EMAIL)) {
$params['notify']['process']['reg_email_wrong'] = true;
}
if (!system::getInstance()->validPasswordLength($reg_pass)) {
$params['notify']['process']['reg_pass_wrong'] = true;
}
if (system::getInstance()->length($reg_login) < 3 || system::getInstance()->length($reg_login) > 64) {
$params['notify']['process']['reg_login_wrong'] = true;
}
if ($reg_pass != $reg_repass) {
$params['notify']['process']['reg_repass_nomatch'] = true;
}
if (sizeof($params['notify']) == 0) {
$configs_data = '<?php' . "\n";
foreach (system::getInstance()->post(null) as $var_name => $var_value) {
if (system::getInstance()->prefixEquals($var_name, 'config:')) {
$var_name = substr($var_name, strlen('config:'));
$var_name = system::getInstance()->nohtml($var_name);
if ($var_name === 'seo_title') {
foreach (language::getInstance()->getAvailable() as $clang) {
$configs_data .= '$config[\'' . $var_name . '\'][\'' . $clang . '\'] = "' . system::getInstance()->nohtml($var_value[$clang]) . '";' . "\n";
}
} else {
$configs_data .= '$config[\'' . $var_name . '\'] = "' . system::getInstance()->nohtml($var_value) . '"' . ";\n";
}
}
}
$random_password_salt = system::getInstance()->randomString(rand(12, 16));
$configs_data .= '$config[\'tpl_dir\'] = "templates";
$config[\'tpl_name\'] = "default";
$config[\'debug\'] = true;
$config[\'multi_title\'] = false;
$config[\'cache_interval\'] = "120";
$config[\'token_time\'] = "86400";
$config[\'user_friendly_url\'] = false;
$config[\'mail_from\'] = "admin@example.com";
$config[\'mail_ownername\'] = "Site Admin";
$config[\'mail_smtp_use\'] = false;
$config[\'mail_smtp_host\'] = "smtp.yandex.ru";
$config[\'mail_smtp_port\'] = "25";
$config[\'mail_smtp_auth\'] = true;
$config[\'mail_smtp_login\'] = "admin@example.com";
$config[\'mail_smtp_password\'] = "madness";
$config[\'password_salt\'] = "' . $random_password_salt . '";
';
$configs_data .= '?>';
file_put_contents(root . '/install/.lock', 'Install success');
file_put_contents(root . '/config.php', $configs_data);
$prefix = system::getInstance()->post('config:db_prefix');
if (!system::getInstance()->isLatinOrNumeric($prefix)) {
$prefix = "ffcms";
}
$query_dump = str_replace('{$db_prefix}', $prefix, file_get_contents(root . '/install/sql/install.sql'));
$testCon->exec($query_dump);
$md5_doublehash = system::getInstance()->doublemd5($reg_pass, $random_password_salt);
$stmt = $testCon->prepare("INSERT INTO " . $prefix . "_user (`login`, `email`, `nick`, `pass`, `access_level`) VALUES(?, ?, 'admin', ?, '3')");
$stmt->bindParam(1, $reg_login, \PDO::PARAM_STR);
$stmt->bindParam(2, $reg_email, \PDO::PARAM_STR);
$stmt->bindParam(3, $md5_doublehash, \PDO::PARAM_STR, 32);
$stmt->execute();
$user_id = $testCon->lastInsertId();
$stmt = null;
$stmt = $testCon->prepare("INSERT INTO " . $prefix . "_user_custom(`id`) VALUES (?)");
$stmt->bindParam(1, $user_id, \PDO::PARAM_INT);
$stmt->execute();
$stmt = null;
$testCon = null;
$params['notify']['success'] = true;
}
}
//.........这里部分代码省略.........
示例4: init
public function init()
{
$this->twigLoader();
$this->set(self::TYPE_SYSTEM, 'url', property::getInstance()->get('url'));
$this->set(self::TYPE_SYSTEM, 'protocol', property::getInstance()->get('protocol'));
$this->set(self::TYPE_SYSTEM, 'script_url', property::getInstance()->get('script_url'));
$this->set(self::TYPE_SYSTEM, 'nolang_url', system::getInstance()->nohtml(property::getInstance()->get('nolang_url')));
$this->set(self::TYPE_SYSTEM, 'uri', system::getInstance()->nohtml($this->nolang_uri()));
$this->set(self::TYPE_SYSTEM, 'theme', property::getInstance()->get('script_url') . '/' . property::getInstance()->get('tpl_dir') . '/' . $this->getIfaceTemplate());
$this->set(self::TYPE_SYSTEM, 'lang', language::getInstance()->getUseLanguage());
$this->set(self::TYPE_SYSTEM, 'languages', language::getInstance()->getAvailable());
$this->set(self::TYPE_SYSTEM, 'self_url', property::getInstance()->get('script_url') . router::getInstance()->getUriString());
$serial_title = property::getInstance()->get('seo_title');
$this->set(self::TYPE_SYSTEM, 'title', $serial_title[language::getInstance()->getUseLanguage()]);
$this->set(self::TYPE_SYSTEM, 'file_name', basename($_SERVER['PHP_SELF']));
$this->set(self::TYPE_SYSTEM, 'version', version);
$this->set(self::TYPE_SYSTEM, 'admin_tpl', property::getInstance()->get('script_url') . '/' . property::getInstance()->get('tpl_dir') . '/' . property::getInstance()->get('admin_tpl'));
// for script usage
$this->set(self::TYPE_SYSTEM, 'loader', loader);
$this->set(self::TYPE_SYSTEM, 'is_main', router::getInstance()->isMain());
$this->set(self::TYPE_SYSTEM, 'get_data', system::getInstance()->get(null));
$this->set(self::TYPE_SYSTEM, 'yandex_translate_key', property::getInstance()->get('yandex_translate_key'));
}
示例5: prepareLanguages
/**
* Prepare language info from input data.
*/
private function prepareLanguages()
{
$lang = null;
if (loader === 'front' && router::getInstance()->getPathLanguage() != null && language::getInstance()->canUse($this->getPathLanguage())) {
// did we have language in path for front iface?
$lang = router::getInstance()->getPathLanguage();
} elseif ((loader === 'api' || loader === 'install') && language::getInstance()->canUse($_COOKIE['ffcms_lang'])) {
// did language defined for API scripts?
$lang = $_COOKIE['ffcms_lang'];
} elseif ($_SERVER['HTTP_ACCEPT_LANGUAGE'] != null && language::getInstance()->canUse(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)) && loader !== 'back') {
// did we have lang mark in browser?
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
} else {
// no ? then use default language
$lang = property::getInstance()->get('lang');
}
language::getInstance()->setUseLanguage($lang);
}