本文整理汇总了PHP中Core::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::instance方法的具体用法?PHP Core::instance怎么用?PHP Core::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Current Instance of Core
* @return Core
*/
public static function getInstance()
{
if (Core::$instance == null) {
Core::$instance = new CoreAjax();
}
return Core::$instance;
}
示例2: inst
public static function inst()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
示例3: getInstance
/**
* Возвращает ссылку на себя
* @example Core::getInstance()->parse_url();
*
* @example $core = Core::getInstance();
* @example $core->parse_url();
* @return Core
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new Core();
}
return self::$instance;
}
示例4: getInstance
/**
* Get Instance
*
* Return an instance of this class
* @return object Instance of this class
*/
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例5: singleton
/**
* Utilizamos el método singleton para acceder a los objetos
* @access public
* @return
*/
public static function singleton()
{
if (!isset(self::$instance)) {
$obj = __CLASS__;
self::$instance = new $obj();
}
return self::$instance;
}
示例6: coreInstance
public static function coreInstance()
{
if (!isset(self::$instance)) {
$object = __CLASS__;
self::$instance = new $object();
}
return self::$instance;
}
示例7: getInstance
public static function getInstance()
{
// Implement the singleton pattern
if (!isset(self::$instance)) {
$obj = __CLASS__;
self::$instance = new $obj();
}
return self::$instance;
}
示例8: 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;
}
}
示例9: _getShowCase
private function _getShowCase($genre, $page = 0, $size = 4)
{
$books = $this->_getBooksByGenre($genre, $page, $size);
$num_books = Core::instance()->getDb()->countBookyByGenre($genre);
if (count($books) == 0) {
return null;
}
$args = array('books' => $books, 'style' => 'showcase', 'text_details' => i('To the details'), 'navigation' => true, 'prev_hidden' => $num_books <= $size, 'next_hidden' => count($books) < $size, 'config' => urlencode(json_encode(array('page' => $page, 'size' => $size, 'request' => Controller::instance()->getViewUrl() . '&ajax=1&ajax_fn=nextShowcasePage&page={%page%}&size={%size%}&genre=' . $genre))));
return TemplateRenderer::instance()->extendedRender('theme/templates/snippets/showcase.html', $args);
}
示例10: prepare
public function prepare()
{
$cwd = getcwd();
chdir('..');
require_once 'config.php';
require_once 'classes/class.core.php';
// prevent chdir problems
$core = Core::instance();
chdir($cwd);
}
示例11: getInstance
/**
* Current Instance of Core
* @return Core
*/
public static function getInstance()
{
try {
if (Core::$instance == null) {
Core::$instance = new self();
}
return Core::$instance;
} catch (CoreException $exception) {
throw new CoreException('Fatal Error: Cannot Instantiate Core');
}
}
示例12: _getSearchResult
private function _getSearchResult($str, $category, $page = 0, $size = 10, $only_titles = false)
{
$category = !isset($category) || $category == null || $category == '' ? null : $category;
$books = Core::instance()->getDb()->searchBooks($str, $category, $page, $size, null, $only_titles);
if ($str != '') {
foreach ($books as $key => $book) {
$books[$key]['title'] = Utilities::highlight($book['title'], $str);
$books[$key]['author'] = trim($books[$key]['author']);
$description = Utilities::cutText($book['description'], 300);
$books[$key]['description'] = Utilities::highlight($description, $str);
}
}
$total = Core::instance()->getDb()->countSearchBooks($str, $category);
$result = array('books' => $books, 'total' => $total);
return $result;
}
示例13:
* ['name' => <i>module_name</i>]<br>
*
* admin/System/components/modules/default_module/process<br>
* ['name' => <i>module_name</i>]<br>
*
* admin/System/components/modules/db/process<br>
* ['name' => <i>module_name</i>]<br>
*
* admin/System/components/modules/storage/process<br>
* ['name' => <i>module_name</i>]
*/
namespace cs;
$Cache = Cache::instance();
$Config = Config::instance();
$Core = Core::instance();
$db = DB::instance();
$L = Language::instance();
$Page = Page::instance();
$User = User::instance();
$Permission = Permission::instance();
$a = Index::instance();
if (isset($_POST['update_modules_list'])) {
/**
* List of currently presented modules in file system
*/
$modules_list = array_fill_keys($new_modules = get_files_list(MODULES, false, 'd'), ['active' => -1, 'db' => [], 'storage' => []]);
/**
* Already known modules
*/
$modules =& $Config->components['modules'];
示例14: explode
$block_until = $user_data['block_until'];
$block_until = explode('T', $block_until);
$block_until[0] = explode('-', $block_until[0]);
$block_until[1] = explode(':', $block_until[1]);
$user_data['block_until'] = mktime($block_until[1][0], $block_until[1][1], 0, $block_until[0][1], $block_until[0][2], $block_until[0][0]);
unset($block_until);
} else {
$user_data['block_until'] = 0;
}
if ($user_data['password']) {
if (strlen($user_data['password']) < $Config->core['password_min_length']) {
$Page->warning($L->password_too_short);
} elseif (password_check($user_data['password'], $Config->core['password_min_length']) < $Config->core['password_min_strength']) {
$Page->warning($L->password_too_easy);
} else {
$user_data['password_hash'] = hash('sha512', hash('sha512', $user_data['password']) . Core::instance()->public_key);
}
}
unset($user_data['password']);
if ($user_data['login'] && $user_data['login'] != $User->get('login', $id) && (!filter_var($user_data['login'], FILTER_VALIDATE_EMAIL) && $User->get_id(hash('sha224', $user_data['login'])) === false || $user_data['login'] == $user_data['email'])) {
$user_data['login_hash'] = hash('sha224', $user_data['login']);
} else {
if ($user_data['login'] != $User->get('login', $id)) {
$Page->warning($L->login_occupied_or_is_not_valid);
}
unset($user_data['login']);
}
if ($user_data['email']) {
$user_data['email_hash'] = hash('sha224', $user_data['email']);
} else {
unset($user_data['login']);
示例15: define
define('CACHE', DIR . '/storage/cache');
/**
* Log directory for current domain
*/
define('LOGS', DIR . '/storage/logs');
/**
* Temp directory for current domain
*/
define('TEMP', DIR . '/storage/temp');
/**
* Directory with public cache (available from the outside)
*/
define('PCACHE', DIR . '/storage/pcache');
/**
* Themes dir
*/
define('THEMES', DIR . '/themes');
/**
* Including of custom user files
*/
foreach (glob(CUSTOM . '/*.php') ?: [] as $custom) {
include $custom;
}
unset($custom);
/**
* System running
*/
Core::instance();
Language::instance();
defined('CS_ERROR_HANDLER') && CS_ERROR_HANDLER && Error::instance();
Index::instance();