本文整理汇总了PHP中Language::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::instance方法的具体用法?PHP Language::instance怎么用?PHP Language::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::instance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
示例2: getInstance
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
示例3: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new Language();
}
return self::$instance;
}
示例4: findThis
public static function findThis()
{
if (self::$instance) {
return self::$instance;
}
self::$instance = Finder::factory('language')->findByUrl($_SERVER["HTTP_HOST"]);
return self::$instance;
}
示例5: connecting
/**
* Processing of all storage requests
*
* @param int $connection
*
* @return Storage\_Abstract|False_class
*/
protected function connecting($connection)
{
/**
* If connection found in list of failed connections - return instance of False_class
*/
if (isset($this->failed_connections[$connection])) {
return False_class::instance();
}
/**
* If connection already exists - return reference on the instance of Storage engine object
*/
if (isset($this->connections[$connection])) {
return $this->connections[$connection];
}
$Config = Config::instance();
/**
* If connection to the local storage
*/
if ($connection == 0) {
$Core = Core::instance();
$storage['connection'] = $Core->storage_type;
$storage['url'] = $Core->storage_url;
$storage['host'] = $Core->storage_host;
$storage['user'] = $Core->storage_user;
$storage['password'] = $Core->storage_password;
} elseif (isset($Config->storage[$connection])) {
$storage =& $Config->storage[$connection];
} else {
return False_class::instance();
}
/**
* Create new Storage connection
*/
$engine_class = '\\cs\\Storage\\' . $storage['connection'];
$this->connections[$connection] = new $engine_class($storage['url'], $storage['host'], $storage['user'], $storage['password']);
/**
* If successfully - add connection to the list of success connections and return instance of DB engine object
*/
if (is_object($this->connections[$connection]) && $this->connections[$connection]->connected()) {
$this->successful_connections[] = $connection . '/' . $storage['host'] . '/' . $storage['connection'];
unset($storage);
$this->{$connection} = $this->connections[$connection];
return $this->connections[$connection];
/**
* If failed - add connection to the list of failed connections and display connection error
*/
} else {
unset($this->{$connection});
$this->failed_connections[$connection] = $connection . '/' . $storage['host'] . '/' . $storage['connection'];
unset($storage);
trigger_error(Language::instance()->error_storage . ' ' . $this->failed_connections[$connection], E_USER_WARNING);
$return = False_class::instance();
$return->error = 'Connection failed';
return $return;
}
}
示例6: sleep
<?php
/**
* @package CleverStyle CMS
* @subpackage System module
* @category modules
* @author Nazar Mokrynskyi <nazar@mokrynskyi.com>
* @copyright Copyright (c) 2011-2014, Nazar Mokrynskyi
* @license MIT License, see license.txt
*/
namespace cs;
$Config = Config::instance();
$L = Language::instance();
$Page = Page::instance();
$User = User::instance();
/**
* If AJAX request from local referer, user is registered - change password, otherwise - show error
*/
if (!$Config->server['referer']['local'] || !$Config->server['ajax'] || !isset($_POST['verify_hash'], $_POST['new_password']) || !$User->user()) {
sleep(1);
error_code(403);
return;
} elseif (!$_POST['new_password']) {
error_code(400);
$Page->error($L->please_type_new_password);
return;
} elseif (hash('sha224', $User->password_hash . $User->get_session()) != $_POST['verify_hash']) {
error_code(400);
$Page->error($L->wrong_current_password);
return;
示例7: switch
<?php
/**
* @package Package
* @category modules
* @author Nazar Mokrynskyi <nazar@mokrynskyi.com>
* @copyright Copyright (c) 2014, Nazar Mokrynskyi
* @license MIT License, see license.txt
*/
namespace cs;
$rc = Config::instance()->route;
if (!isset($rc[0])) {
return;
}
switch ($rc[0]) {
case 'profile':
case path(Language::instance()->profile):
error_code(404);
}
示例8: __construct
/**
* Initialize Hotaru with the essentials
*/
public function __construct()
{
// session to be used by CSRF, etc.
if (!isset($_SESSION['HotaruCMS'])) {
@session_start();
$_SESSION['HotaruCMS'] = time();
}
// these items can be defined in settings but if not here are the defaults
if (!defined("DB_ENGINE")) {
define("DB_ENGINE", 'InnoDB');
}
if (!defined("MEMCACHED_HOST")) {
define("MEMCACHED_HOST", '127.0.0.1');
}
if (!defined("MEMCACHED_PORT")) {
define("MEMCACHED_PORT", 11211);
}
// passwordhash < 5.4
require_once EXTENSIONS . 'passwordHash/password.php';
$this->getFunctionFiles();
// The order here is important!
$this->setDefaultTimezone();
$this->setTableConstants();
$this->MakeCacheFolders();
$this->loadFiles();
$this->cage = $this->initInspektCage();
$this->db = $this->initDatabase();
//$this->mdb = $this->initDatabase('mdb');
//$this->initEloquent();
$this->memCache = $this->setMemCache(MEMCACHED_HOST, MEMCACHED_PORT);
$this->errorReporting();
//$this->loadMiscData();
$this->loadSystemJobs();
$this->loadCategories();
$this->readSettings();
$this->readAllPluginSettings();
$this->getPluginActiveTypesAndFolders();
$this->setUpDatabaseCache();
$this->isDebug = $this->checkDebug();
$this->setUpJsConstants();
// TODO
// get Widget blocks ? - speed test it first
// include "main" language pack
$lang = Language::instance();
$this->lang = $lang->includeLanguagePack($this->lang, 'main');
$lang->writeLanguageCache($this);
return true;
}
示例9: includeThemeLanguage
/**
* Include a language file for a theme
*
* @param string $filename optional filename without '_language.php' file extension
*
* Note: the language file should be in a plugin folder named 'languages'.
* '_language.php' is appended automatically to the folder of file name.
*/
public function includeThemeLanguage($filename = 'main')
{
$language = Language::instance();
$language->includeThemeLanguage($this, $filename);
}
示例10: connecting
/**
* Processing of all DB request
*
* @param int $connection Database id
* @param array|bool $mirror
*
* @return DB\_Abstract|False_class
*/
protected function connecting($connection, $mirror = true)
{
/**
* If connection found in list of failed connections - return instance of False_class
*/
if (isset($this->failed_connections[$connection])) {
return False_class::instance();
}
/**
* If we want to get data and connection with DB mirror already exists - return reference on the instance of DB engine object
*/
if ($mirror === true && isset($this->mirrors[$connection])) {
return $this->mirrors[$connection];
}
/**
* If connection already exists - return reference on the instance of DB engine object
*/
if (isset($this->connections[$connection])) {
return $this->connections[$connection];
}
$Config = Config::instance();
$Core = Core::instance();
$L = Language::instance();
/**
* If connection to the core DB and it is not connection to the mirror
*/
if ($connection == 0 && !is_array($mirror)) {
$db['type'] = $Core->db_type;
$db['name'] = $Core->db_name;
$db['user'] = $Core->db_user;
$db['password'] = $Core->db_password;
$db['host'] = $Core->db_host;
$db['charset'] = $Core->db_charset;
$db['prefix'] = $Core->db_prefix;
} else {
/**
* If it is connection to the DB mirror
*/
if (is_array($mirror)) {
$db =& $mirror;
} else {
if (!isset($Config->db[$connection]) || !is_array($Config->db[$connection])) {
return False_class::instance();
}
$db =& $Config->db[$connection];
}
}
/**
* Create new DB connection
*/
$engine_class = '\\cs\\DB\\' . $db['type'];
$this->connections[$connection] = new $engine_class($db['name'], $db['user'], $db['password'], $db['host'], $db['charset'], $db['prefix']);
unset($engine_class);
/**
* If successfully - add connection to the list of success connections and return instance of DB engine object
*/
if (is_object($this->connections[$connection]) && $this->connections[$connection]->connected()) {
$this->successful_connections[] = ($connection == 0 ? $L->core_db . '(' . $Core->db_type . ')' : $connection) . '/' . $db['host'] . '/' . $db['type'];
unset($db);
$this->{$connection} = $this->connections[$connection];
return $this->connections[$connection];
/**
* If failed - add connection to the list of failed connections and try to connect to the DB mirror if it is allowed
*/
} else {
unset($this->{$connection});
$this->failed_connections[$connection] = ($connection == 0 ? $L->core_db . '(' . $Core->db_type . ')' : $connection) . '/' . $db['host'] . '/' . $db['type'];
unset($db);
if ($mirror === true && ($connection == 0 && isset($Config->db[0]['mirrors']) && is_array($Config->db[0]['mirrors']) && count($Config->db[0]['mirrors']) || isset($Config->db[$connection]['mirrors']) && is_array($Config->db[$connection]['mirrors']) && count($Config->db[$connection]['mirrors']))) {
$dbx = $connection == 0 ? $Config->db[0]['mirrors'] : $Config->db[$connection]['mirrors'];
foreach ($dbx as $i => &$mirror_data) {
$mirror_connection = $this->connecting($connection . ' (' . $mirror_data['name'] . ')', $mirror_data);
if (is_object($mirror_connection) && $mirror_connection->connected()) {
$this->mirrors[$connection] = $mirror_connection;
$this->{$connection} = $this->connections[$connection];
return $this->mirrors[$connection];
}
}
unset($dbx, $i, $mirror_data, $mirror_connection);
}
/**
* If mirror connection is not allowed - display connection error
*/
$return = False_class::instance();
if (!is_array($mirror)) {
code_header(500);
if ($connection == 0) {
trigger_error($L->error_core_db, E_USER_ERROR);
} else {
trigger_error($L->error_db . ' ' . $this->failed_connections[$connection], E_USER_ERROR);
}
$return->error = 'Connection failed';
//.........这里部分代码省略.........
示例11: del
/**
* Deletes text on all languages
*
* @param int $database
* @param string $group
* @param string $label
*
* @return bool
*/
function del($database, $group, $label)
{
$Cache = Cache::instance();
$db = DB::instance();
$id = $db->{$database}()->qfs(["SELECT `id`\n\t\t\tFROM `[prefix]texts`\n\t\t\tWHERE\n\t\t\t\t`group`\t= '%s' AND\n\t\t\t\t`label`\t= '%s'\n\t\t\tLIMIT 1", $group, $label]);
if ($id) {
$L = Language::instance();
unset($Cache->{"texts/{$database}/{$id}_{$L->clang}"}, $Cache->{"texts/{$database}/" . md5($group) . md5($label) . "_{$L->clang}"});
return $db->{$database}()->q(["DELETE FROM `[prefix]texts`\n\t\t\t\t\tWHERE `id` = '%s'", "DELETE FROM `[prefix]texts_data`\n\t\t\t\t\tWHERE `id` = '%s'"], $id);
} else {
return true;
}
}
示例12:
<?php
/**
* @package Elections
* @category modules
* @author Nazar Mokrynskyi <nazar@mokrynskyi.com>
* @copyright Copyright (c) 2014, Nazar Mokrynskyi
* @license MIT License, see license.txt
*/
namespace cs;
Page::instance()->post_Body .= "<script src=\"//api-maps.yandex.ru/2.1/?load=package.full&lang=" . Language::instance()->clang . "_UA\"></script>\n" . "<script type=\"text/javascript\" src=\"//yandex.st/share/share.js\"></script>\n";