当前位置: 首页>>代码示例>>PHP>>正文


PHP core::get_instance方法代码示例

本文整理汇总了PHP中core::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP core::get_instance方法的具体用法?PHP core::get_instance怎么用?PHP core::get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core的用法示例。


在下文中一共展示了core::get_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_api_editor_menu

 /**
  * Editor nav menu
  */
 function action_api_editor_menu()
 {
     /** @var tf_editor $ed */
     $ed = core::lib('editor');
     $menu = array();
     // dies on get_editor_actions
     $menu['core'] = core::get_instance()->get_editor_actions();
     foreach (core::modules() as $module) {
         $menu[$module->get_name()] = $module->get_editor_actions();
     }
     $menuNormalized = array();
     foreach ($menu as $key => $actions) {
         $submenuNormalized = array();
         if (!empty($actions)) {
             foreach ($actions as $subKey => $subMenu) {
                 if (!empty($subMenu['url'])) {
                     $subMenu['url'] = $ed->make_url($subMenu['url'], 1);
                 }
                 $submenuNormalized[] = !$subMenu ? array() : array_merge(array('id' => $subKey), $subMenu);
             }
             $menuNormalized[] = array('id' => $key, 'title' => i18n::T(array($key, '_name')), 'actions' => $submenuNormalized);
         }
     }
     $this->renderer->set_ajax_answer($menuNormalized)->ajax_flush();
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:28,代码来源:controller.php

示例2: __construct

 /**
  * Create auth lib
  * @param users_collection users handle
  * @param bool disable auth
  */
 function __construct(tf_users $musers, $null_auth = false)
 {
     $this->_cookie_domain = '.' . core::get_instance()->get_main_domain();
     $this->mod_users = $musers;
     $this->users = $musers->get_users_handle();
     $this->sessions = $musers->get_sessions_handle();
     $this->_null_auth = $null_auth;
     $this->onload();
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:14,代码来源:auth.php

示例3: __construct

 /**
  * Creator 
  */
 protected function __construct()
 {
     //  $this->storage = new logger_storage_null();
     //  return;
     $this->storage = core::get_instance()->class_register('logs', array('no_preload' => true), true);
     // cant create storage, try file-mock!
     if (!$this->storage) {
         $this->storage = new logger_storage_null();
     }
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:13,代码来源:logger.php

示例4: __construct

 /**
  * Pissdrunk construct
  */
 function __construct()
 {
     $this->cache = core::lib('cache')->get_engine($this->_cache_engine);
     $this->handle = core::get_instance()->class_register('page_cache', array('no_preload' => true));
     $this->_enabled = !core::get_instance()->get_cfg_var('disable_page_cache', false);
     if (!empty($this->_cache_threshold) && $this->_cache_threshold != 1) {
         foreach ($this->_threshold_table as $k => $v) {
             $this->_threshold_table[$k]['cache'] = $v['cache'] * $this->_cache_threshold;
         }
     }
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:14,代码来源:page_cacher.php

示例5: set_current

 /**
  * Doamin matched in initial_route
  */
 function set_current()
 {
     $this->_current = true;
     if (0 != $this->template) {
         $core = core::get_instance();
         $templates = $core->get_cfg_var('templates');
         if (isset($templates[$this->template])) {
             core::dprint(array('SITE_LAYOUT : %s', $templates[$this->template]), core::E_DEBUG1);
             core::lib('renderer')->set_layout($templates[$this->template]);
         }
     }
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:15,代码来源:item.php

示例6: run

 function run()
 {
     $q = trim(urldecode($this->request->get('q')));
     $q = core::lib('db')->escape($q);
     if (strings::strlen($q) < 2) {
         $this->renderer->set_ajax_result(false)->set_ajax_message('Короткое сообщение')->ajax_flush(false);
         return;
     }
     $pmod = $this->_controller->get_context();
     $ph = $pmod->get_search_handle()->set_working_fields('keyword')->set_limit(10);
     if (!empty($q)) {
         $ph->set_where("keyword like '%{$q}%' AND c_count > 0");
     }
     $sugg = $ph->load()->render();
     core::get_instance()->ajax_answer($sugg);
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:16,代码来源:suggest.php

示例7: make_search

 /**
  * Make search
  */
 public function make_search($key)
 {
     $id = false;
     $psearchs = $this->_controller->get_context()->get_search_handle();
     $psearch_results = $this->_controller->get_context()->get_search_result_handle();
     $core = core::get_instance();
     $site_id = $this->_controller->get_context()->get_current_site_id();
     // check key exists
     if ($search_item = $psearchs->get_by_key($key, $site_id)) {
         $id = $search_item->id;
         $this->_found = $search_item->c_count;
     }
     // if too old, clean search results, make it new
     if ($search_item) {
         if ($search_item->time + $this->_expire_time < time()) {
             // clear
             $search_item->remove();
             $search_item = null;
         }
     }
     if (!$search_item) {
         $this->_found = 0;
         $cdata = core::module('sat')->get_node_handle();
         $orig_key = $key;
         # remove this for non test
         # $key = strings::convert_from($key);
         $key = core::lib('db')->escape(strings::strtolower($key));
         $cdata->set_where("site_id = {$site_id} AND active AND LCASE(title) LIKE '%{$key}%'")->load();
         $result = array();
         $ctype = $core->get_ctype('sat.node')->get_id();
         $this->_found = $cdata->count();
         if (!$cdata->is_empty()) {
             foreach ($cdata as $item) {
                 $result[] = array('title' => $item->title, 'description' => strip_tags($item->description), 'time' => $item->updated_at, 'url' => $item->get_url(), 'ctype' => $ctype, 'post_id' => $item->id);
             }
         }
         // create search history item
         $id = $psearchs->create(array('uid' => $this->_controller->get_user()->id, 'keyword' => $key, 'c_count' => $this->_found, 'site_id' => $site_id));
         // fill results
         foreach ($result as $v) {
             $v['pid'] = $id;
             $psearch_results->create($v);
         }
     }
     return $id;
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:49,代码来源:query.php

示例8: smarty_function_block

/**
 * Block entry point
 * 
 * @param array
 *     module                  // module tag
 *     action                  // block action
 *     cache                   // seconds, cache data
 *     other params
 */
function smarty_function_block($params, &$smarty)
{
    $core = core::get_instance();
    foreach ($params as $k => $v) {
        if (!isset(${$k})) {
            ${$k} = $v;
        }
    }
    $cache_this = false;
    // $core->time_check('c1', true, true);
    if (isset($cache)) {
        $cacher_factory = core::lib('cache');
        if ($cacher_factory->has_memory()) {
            $cacher = $cacher_factory->get_memory_handle();
            $cache_time = $cache;
            unset($params['cache']);
            $cache_id = 'block_' . md5(serialize($params));
            $result = $cacher->get($cache_id, false);
            if (false !== $result) {
                core::dprint('cache hit : ' . $params['action'] . ' - ' . $core->time_check('c1', true));
                return $result;
            }
            $cache_this = true;
        }
    }
    try {
        if (empty($module)) {
            $module = 'core';
        }
        if ($pmod = $core->module($module)) {
            unset($params['action'], $params['module']);
            $result = $pmod->run_block($action, $params);
            if ($cache_this) {
                $cacher->set($cache_id, $result, $cache_time);
            }
            // core::var_dump('no cache : ' . $cache_id, $core->time_check('c1', true));
            return $result;
        }
    } catch (modules_exception $e) {
        return '[block] ' . $e->getMessage();
    }
    return false;
}
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:52,代码来源:function.block.php

示例9: factory

 /**
  * Create handle
  * @param array params
  */
 public static function factory($parms = 'smarty')
 {
     $smarty = false;
     // $test = loader::$root_path . loader::DIR_MODULES . 'core/tplparser/smarty/Smarty.class.php';
     $test = loader::get_root() . loader::DIR_EXT . 'smarty/Smarty.class.php';
     if (fs::file_exists($test)) {
         require $test;
         $smarty = new Smarty();
         $smarty->compile_check = true;
         $smarty->force_compile = false;
         // true;
         $template = core::get_instance()->get_cfg_var('template');
         $smarty->caching = false;
         //TRUE;
         //$smarty->cache_lifetime = 3600;
         $smarty->debugging = core::get_instance()->get_cfg_var('debug_templates');
     } else {
         $smarty = new tplparser_mock();
         core::dprint('[tplparser] using mock');
     }
     self::$parser = $smarty;
     self::set_template($template);
     return $smarty;
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:28,代码来源:tplparser.php

示例10: core

 /**
  * Get kernel
  * @return core
  */
 static function core()
 {
     return self::$_core ? self::$_core : (self::$_core = core::get_instance(self::_option(self::OPTION_CORE_PARAMS)));
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:8,代码来源:loader.php

示例11: class_register

 /**
  * Create or retrieve object bu class
  * 
  * module name prefixed with {@see loader::CLASS_PREFIX}
  * 
  * @param string  module_name
  * @param array   config ( order_sql , where_sql, limit_sql )
  *                tpl_table - template name block
  * @param boolean standalone (регистрировать в системе или нет)
  * 
  * @return object (&by ref)
  * 
  * @throws core_exception
  */
 function class_register($module, $config = array(), $standalone = false)
 {
     $tmp = false;
     /*   check modules path
               if yes, make namespace for it
          */
     $path_prefix = $this->root_dir;
     /* standalone class support
           without register in $core->classes db
           
           class naming:
           /classes/module/
                 +- collection (module_collection)
                 +- item (module_item)
        */
     $m_class = $module . '_collection';
     // chroot support
     // [tf]obsolete: auto chroot to module
     $f_class_path = $path_prefix . 'classes/' . $module . '/';
     $f_class = array($f_class_path . 'collection' . loader::DOT_PHP, $f_class_path . 'item' . loader::DOT_PHP);
     if (!class_exists($m_class)) {
         if (!fs::file_exists($f_class[0]) || !fs::file_exists($f_class[1])) {
             core::dprint("[color=red][ERROR CLASS_REGISTER] file not found; [/color] {$module} ({$f_class_path})");
             core::dprint($f_class);
             throw new core_exception("Class register failed : {$module} in " . $path_prefix, core::E_ERROR);
             return $tmp;
             // false;
         }
         require_once $f_class[0];
         require_once $f_class[1];
     }
     if (!$standalone && isset($this->classes[$module])) {
         return $this->classes[$module];
     }
     /*   use prefix
               render to {$tpl_table}
               sql from  {$table}
          */
     $table_ = $module;
     $config['prefix'] = core::get_instance()->get_cfg_var(array('database', 'prefix'));
     $table_ = $config['prefix'] . $table_;
     // if not passed, set to module tag
     if (!isset($config['tpl_table'])) {
         $config['tpl_table'] = $module;
     }
     // new one
     $config_ = array('load' => true, 'table' => $table_, 'root' => $f_class_path);
     if ($config !== false) {
         $config_ = array_merge($config_, $config);
     }
     // preload fix
     if (isset($config['no_preload'])) {
         unset($config_['load']);
     }
     // In editor, check for class with 'editor_' prefix
     if (core::in_editor()) {
         $editor_class = 'editor_' . $m_class;
         if (class_exists($editor_class)) {
             $m_class = $editor_class;
         }
         $config_['in_editor'] = true;
     }
     $tmp = new $m_class($config_);
     if ($standalone) {
         return $tmp;
     }
     $this->classes[$module] = $tmp;
     return $this->classes[$module];
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:83,代码来源:core_factory.php

示例12: normalize_url

 /**
  * Make url with context    
  */
 function normalize_url(&$url)
 {
     $core = core::get_instance();
     $base = $core->get_base_url();
     $url = $base . $url;
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:9,代码来源:module_router.php

示例13: translate

 /**
  * Translate
  * @param mixed $id
  */
 public function translate($id)
 {
     $mod = $this->tag;
     $ret = core::get_instance()->get_langword($id, $mod);
     if (!$ret) {
         core::dprint('[core::translate] undefined : ' . $id . ($mod ? " in {$mod}" : ''));
     }
     return $ret;
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:13,代码来源:module.php

示例14: sql_query

 /**
  * SQL query
  *
  * @param mixed $query
  * @param mixed $transaction
  */
 function sql_query($query, $options = null)
 {
     if (empty($query)) {
         core::dprint('Empty sql_query call');
         return false;
     }
     if (is_array($query)) {
         $query = vsprintf($query[0], array_slice($query, 1));
     }
     $starttime = microtime(true);
     ++$this->_counter;
     $tm_ = core::get_instance()->time_check('mysql', 1, 1);
     unset($this->query_result);
     $this->num_queries++;
     $this->_connect();
     if (!$this->_connect_id && class_exists('core', 0)) {
         core::dprint(array('[SQL_ERROR] no connect %s', $query), core::E_SQL);
     }
     if (!empty($options['mysql_unbuffered'])) {
         $this->query_result = mysql_unbuffered_query($query, $this->_connect_id);
     } else {
         $this->query_result = mysql_query($query, $this->_connect_id);
     }
     $this->_last_query = $query;
     if ($this->query_result) {
         $endtime = microtime(true);
         $this->sql_time += $endtime - $starttime;
         if (core::get_instance()->cfg('debug_sql') >= 100) {
             core::dprint('<b>' . $this->_counter . ' ' . $this->num_queries . ')  ' . htmlspecialchars($query) . ' [' . round($this->sql_time, 4) . 'ms]</b>');
             // debug code idea by jovani (phpbbguru.net/community/profile.php?mode=viewprofile&u=12)
             if (strtoupper(substr($query, 0, 6)) == "SELECT") {
                 $x = mysql_query("EXPLAIN {$query}", $this->_connect_id);
                 $z = array();
                 while ($y = mysql_fetch_array($x, MYSQL_ASSOC)) {
                     core::dprint("&nbsp;&nbsp;&raquo; tbl = " . $y['table'] . " type = " . $y['type'] . " possible = " . $y['possible_keys'] . " used = " . $y['key'] . " len = " . $y['key_len'] . " ref = " . $y['ref'] . " rows = " . $y['rows'] . " extra = " . $y['Extra']);
                 }
                 mysql_free_result($x);
             }
         }
         // replace password in query for log
         $query = preg_replace("#password = '.*'#U", "password = '*******'", $query);
         if (core::get_instance()->get_cfg_var('debug_sql')) {
             $tm_ = core::get_instance()->time_check('mysql', 1);
             core::dprint($this->_counter . '. ' . $query . ' --[time : ' . $tm_ . ' s]', core::E_SQL);
             if (0 && ($console = core::lib('console'))) {
                 $dbg_trace = $console->debug_backtrace_smart();
                 if (isset($dbg_trace[2]) && !isset($dbg_trace[2]['class'])) {
                     $dbg_trace[2]['class'] = '';
                 }
                 $dbg_info = $dbg_trace[1]['file'] . ' in ' . $dbg_trace[1]['line'] . (!isset($dbg_trace[2]) ? '' : " ({$dbg_trace[2]['class']}::{$dbg_trace[2]['function']}) ");
                 core::dprint(' -- in ' . $dbg_info);
             }
         }
     } else {
         $endtime = microtime(true);
         $this->sql_time += $endtime - $starttime;
         if (core::get_instance()->get_cfg_var('debug_sql')) {
             $tm_ = core::get_instance()->time_check('mysql', 1);
             $err = $this->sql_error();
             core::dprint('[* SQL FAIL] ' . $query, core::E_SQL);
             core::dprint('[* SQL FAIL] ' . $err['message'] . ' : ' . $err['code'] . ' --[time : ' . $tm_ . ' s]', core::E_SQL);
         }
     }
     return $this->query_result;
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:71,代码来源:mysql.php

示例15:

            return;
            break;
        default:
            $this->set_action_name($subsection . '_edit');
            $attachs->prepare2edt($edit_id);
            break;
    }
}
/**
* New
*/
if ($operation == 'new') {
    $this->set_action_name($subsection . '_new');
}
/**
* Post modify submit
*/
if (isset($post['attach_submit'])) {
    $id = core::get_params('id');
    $bulk = core::lib('request')->get_bulk();
    $post_item->modify_attach($bulk, $id);
    // $attachs->modify($bulk, $id);
    if ($post_type == 'videos' && !empty($bulk['file']['size']) && !preg_match('#\\.flv$#', $bulk['file']['name'])) {
        core::get_instance()->set_message(array('content', 'videos_flv_pending'));
    }
}
// render
if (!$edit_id && $operation != 'new') {
    $attachs->set_tpl_table('attach');
    $attachs->render2edt();
}
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:31,代码来源:post_edit_attach.php


注:本文中的core::get_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。