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


PHP core::modules方法代码示例

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


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

 function get_anket_result()
 {
     if (!isset($this->_anket_result) && core::modules()->is_registered('anket')) {
         $this->_anket_result = core::module('anket')->get_managed_item('anket_result', $this->result_id, array('with_module_prefix' => 1));
     }
     return $this->_anket_result;
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:7,代码来源:item.php

示例3: run

 /**
  * Remember!
  * Assign current item in controller for comment linking!
  */
 function run()
 {
     if (loader::in_ajax() !== true) {
         throw new controller_exception('Cant touch this ' . __METHOD__);
         return false;
     }
     core::dprint('run comment modify');
     $pctl = core::modules()->get_router()->get_controller();
     $user = core::lib('auth')->get_user();
     /**
      * Parent item, must be assigned thru @see module_controller::set_current_item()
      * @var abs_collection_item
      */
     $post = $pctl->get_current_item();
     // var_dump(get_class($post), core::get_modules()->get_router()->get_name());
     if (!$post) {
         throw new controller_exception('No item assigned');
     }
     if (!$post->has_behavior('sat.commentable')) {
         throw new controller_exception('Not commentable');
     }
     $comments = $post->behavior('sat.commentable')->get_attach_model();
     //get_comments();
     $request = core::lib('request');
     $renderer = core::lib('renderer');
     $user_id = core::lib('auth')->get_user()->id;
     $pid = (int) $request->post('pid', 0);
     $limit = core::selfie()->cfg('comment_interval', 60);
     $auth = core::lib('auth');
     /** @var aregistry $sd */
     $sd = $auth->get_current_session()->get_storage();
     $time = $sd->comments_last_time;
     //$time = $comments->get_last_time($pid, $user_id);
     // disallow by interval
     if ($time && $time + $limit > time()) {
         $pctl->set_null_template();
         $renderer->set_ajax_answer(array('status' => false, 'id' => 0, 'message' => vsprintf(i18n::T('sat\\comment_interval_restriction'), $time + $limit - time())))->ajax_flush();
         // else core::get_instance()->set_message(array('content', 'comment_interval_restriction'));
         return;
         // exit
     }
     $sd->comments_last_time = time();
     $username = functions::request_var('username', '');
     $text = functions::request_var('text', '');
     $api = functions::request_var('api');
     $id = $comments->modify(array('user_ip' => core::lib('auth')->get_user_ip(true), 'user_id' => $user_id, 'ctype_id' => $post->get_ctype_id(), 'username' => $username, 'pid' => $pid, 'text' => $text, 'type' => functions::request_var('type', 0), 'tpid' => functions::request_var('tpid', 0), 'api' => $api));
     $comment = $comments->get_item_by_id($id);
     if (!$comment) {
         throw new controller_exception('[ajax] Comment create failed');
     }
     $comment->load_secondary();
     $renderer->set_data('comment', $comment->render())->set_ajax_answer(array('status' => true, 'id' => $id))->set_ajax_message(i18n::T('sat\\comment_posted'));
     //->set_main_template('content/comment/view');
     $renderer->ajax_flush('shared/comments/comment');
     // alright, update counter
     return $id;
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:61,代码来源:modify.php

示例4: init0

 /**
  * INIT0 - call right after create an instance of core
  * create basic stuff
  * @throws core_exception
  */
 public function init0()
 {
     if ($this->initialized) {
         throw new core_exception('Already initialized');
     }
     $this->initialized = self::IS_LOADING;
     self::dprint(array("core::init0 %s", loader::with_composer() ? '+composer' : ''), self::E_DEBUG2);
     // templates setup
     self::register_lib('tpl_parser', function () {
         return tpl_loader::factory(core::selfie()->cfg('lib_tpl_parser'));
     });
     // renderer
     self::register_lib('renderer', function () {
         return 0 ? new \SatCMS\Modules\Core\Base\ObjectMock() : new tf_renderer(core::selfie()->cfg('template'), core::lib('tpl_parser'));
     });
     // database setup (database-`mysql`)
     $this->configure_database($this->cfg('database'));
     // set default timezone
     $tz = $this->cfg('default_timezone');
     date_default_timezone_set($tz ? $tz : 'Europe/Moscow');
     // load core config
     $this->dyn_config = $this->model('config', array('render_by_key' => true))->load()->merge_with($this->config);
     // content-types
     $ctype_config = loader::get_docs() . 'ctypes.cfg';
     $ctype_array = fs::file_exists($ctype_config) ? parse_ini_file($ctype_config, true) : array();
     $this->_ctypes = $this->get_ctype_handle();
     $this->_ctypes->from_array($ctype_array);
     // add libs
     self::register_lib('logger', function () {
         return tf_logger::get_instance()->enable(!core::get_instance()->cfg('disable_logs', false));
     });
     self::register_lib('manager', new tf_manager());
     self::register_lib('request', new tf_request());
     $modules_config = array();
     if ('file' == $this->cfg('modules_config', '') && ($modules_config_file = loader::get_docs() . 'modules.cfg') && fs::file_exists($modules_config_file)) {
         $modules_config = parse_ini_file($modules_config_file, true);
     } else {
         try {
             $modules_config = $this->module('modules', array('key' => 'tag'))->as_array();
         } catch (module_exception $e) {
             // misconfigured modules, some of modules not exists
             throw new core_exception($e->getMessage(), tf_exception::CRITICAL);
         }
     }
     // site init %domain%
     // config/%domain%/init.php
     $site_config = array();
     $site_config_path = $this->cfg('site_config');
     if (!empty($site_config_path)) {
         $host = @$_SERVER['HTTP_HOST'];
         if ('%domain%' == $site_config_path) {
             $site_config_path = strpos($host, 'www.') === 0 ? substr($host, 4) : $host;
         }
         $mod_config_file = loader::get_docs() . $site_config_path . '/init.php';
         if ($site_config_path && file_exists($mod_config_file)) {
             $site_config = (include $mod_config_file);
         }
     }
     // import module config `mod_{module}`
     // allow overrides modules.cfg
     foreach ($this->config as $cfg_key => $cfg) {
         if (strpos($cfg_key, 'mod_') === 0) {
             $cfg_key = substr($cfg_key, 4);
             $modules_config[$cfg_key] = @$modules_config[$cfg_key] ?: array();
             $modules_config[$cfg_key] = functions::array_merge_recursive_distinct($modules_config[$cfg_key], $cfg);
         }
     }
     // module manager
     self::$modules = new core_modules($modules_config, $site_config);
     // finish core init0 proccess
     parent::init0();
     // check bans
     if (!$this->cfg('no_bans_check') && isset($_SERVER['REQUEST_URI']) && ($_uri = $_SERVER['REQUEST_URI']) && !empty($_uri)) {
         if ($this->get_bans_handle()->check_spam($_uri)) {
             throw new core_exception(i18n::T('you_are_banned'), tf_exception::CRITICAL);
         }
     }
     self::register_lib('auth', new tf_auth(loader::in_shell()))->start_session();
     if (self::in_editor()) {
         // editor kickstart
         $this->lib('editor');
     }
     register_shutdown_function(array($this, 'halt'));
     $this->initialized = true;
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:90,代码来源:core.php

示例5: init0

 /**
  * INIT0 - call right after create an instance of core    
  * create basic stuff
  * @throws core_exception
  */
 public function init0()
 {
     // templates setup
     self::register_lib('tpl_parser', tpl_loader::factory());
     // renderer
     self::register_lib('renderer', new tf_renderer($this->get_cfg_var('site_url') . loader::DIR_TEMPLATES . $this->get_cfg_var('template') . '/', self::lib('tpl_parser')));
     // database setup
     self::register_lib('db', $db_test = db_loader::get($this->get_cfg_var('database')));
     if (!$db_test && !defined('TF_TEST_INFECTED')) {
         throw new core_exception('Database connection problem', tf_exception::CRITICAL);
     }
     // set default timezone
     $tz = $this->get_cfg_var('default_timezone');
     date_default_timezone_set($tz ? $tz : 'Europe/Moscow');
     // load core config
     $this->dyn_config = $this->class_register('config', array('render_by_key' => true));
     $this->dyn_config->merge_with($this->config);
     // add libs
     self::register_lib('logger', tf_logger::get_instance());
     //     ->enable(!$this->get_cfg_var('disable_logger', false));
     if (!defined('TF_TEST_INFECTED')) {
         set_error_handler(create_function('$x, $y', 'if (0 != ini_get("error_reporting")) throw new system_exception($y, $x);'), E_ALL & ~E_NOTICE);
     }
     self::register_lib('manager', new tf_manager());
     self::register_lib('validator', new tf_validator());
     self::register_lib('request', new tf_request());
     $modules_array = array();
     if ('file' == $this->get_cfg_var('modules_config', '') && ($modules_config = loader::get_docs() . 'modules.cfg') && fs::file_exists($modules_config)) {
         $modules_array = parse_ini_file($modules_config, true);
     } else {
         try {
             $modules_array = $this->class_register('modules', array('key' => 'tag'))->as_array();
         } catch (modules_exception $e) {
             // probably misconfigured modules table, some of modules not exists
             throw new core_exception($e->getMessage(), tf_exception::CRITICAL);
         }
     }
     // modules manager
     self::$modules = new modules_factory($modules_array);
     // finish core init0 proccess
     parent::init0();
     // check bans
     if (!$this->get_cfg_var('no_bans_check') && isset($_SERVER['REQUEST_URI']) && ($_uri = $_SERVER['REQUEST_URI']) && !empty($_uri)) {
         if ($this->get_bans_handle()->check_spam($_uri)) {
             throw new core_exception($this->get_langword('you_are_banned'), tf_exception::CRITICAL);
         }
     }
     /* content type in autoload
           so convert it to object an destroy it
        */
     if (self::in_editor()) {
         self::register_lib('editor', new tf_editor());
     }
     // register auth
     if ($musers = $this->module('users')) {
         self::register_lib('auth', new tf_auth($musers, loader::in_shell()));
     }
     $this->initialized = true;
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:64,代码来源:core.php

示例6: load_objects

 /**
  * Load access objects
  * @todo customize?
  */
 function load_objects()
 {
     core::dprint('[W:] load auth entries');
     $this->_objects = array();
     /*
       'core' =>
         array (size=3)
           'config' =>
             array (size=3)
      'url' => string '?m=core&c=config' (length=16)
      'title' => string 'Переменные' (length=20)
      'default' => boolean true
           'logs' =>
             array (size=2)
      'url' => string '?m=core&c=logs' (length=14)
      'title' => string 'Логи' (length=8)
           'mail_tpl' =>
             array (size=2)
      'url' => string '?m=core&c=mail_tpl' (length=18)
      'title' => string 'Шаблоны писем' (length=25)
     */
     $actions = array();
     $actions['core'] = $this->core->get_editor_actions();
     foreach (core::modules() as $module) {
         $actions[$module->get_name()] = $module->get_editor_actions();
     }
     foreach ($actions as $name => $operations) {
         $object = array('title' => i18n::T(array($name, '_name')), 'name' => $name, 'items' => array(array('id' => 0, 'title' => '*')));
         if (!empty($operations)) {
             foreach ($operations as $opID => $op) {
                 $object['items'][] = array('id' => $opID, 'title' => $op['title']);
             }
         }
         $this->_objects[] = $object;
     }
     return;
     /*
     $pr = core::module('sestat')->get_project_handle()->load();
     
     $this->_objects[] = array(
           'title'   => 'Статистика'
         , 'name'    => 'mod_sestat'
         , 'items'   => array(array('id' => 0, 'title' => '*'))            
     );
     
     $this->_objects[] = array(
           'title'   => 'Пользователи'
         , 'name'    => 'mod_users'
         , 'items'   => array(array('id' => 0, 'title' => '*'))            
     );  
     
     $this->_objects[] = array(
           'title'   => 'Настройки'
         , 'name'    => 'mod_core'
         , 'items'   => array(array('id' => 0, 'title' => '*'))            
     );  
     
     $this->_objects[] = array(
           'title'   => 'Проекты'
         , 'name'    => 'projects'    // section name
         , 'items'   => array(array('id' => 0, 'title' => '*'))            
     );
     
     foreach ($pr as $p) {
         $c = count($this->_objects) - 1;
         $this->_objects[$c]['items']
             []= array('id' => $p->id, 'title' => $p->title);
     }
     */
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:74,代码来源:collection.php

示例7: output_begin

 /**
  * Pre out    
  */
 private function output_begin($ext_config = array())
 {
     // query current module for info
     $core = core::selfie();
     $module = core::modules()->get_router();
     $controller = $module->get_controller();
     // lang constants {$lang._module.value}
     // @deprecated, use smarty i18n modifier
     $this->set_data('lang', $core->get_langwords());
     foreach ($this->import_cfg as $key) {
         if (false !== ($test = $core->cfg($key))) {
             $cfg[$key] = $test;
         }
     }
     $cfg['template_url'] = $this->template_url;
     $cfg['url'] = $_SERVER['REQUEST_URI'];
     $cfg['title'] = $this->get_page_title();
     $cfg['domain_url'] = $module->get_router()->get_protocol() . $_SERVER['HTTP_HOST'];
     $cfg['static_url'] = $core->get_static_url();
     $cfg['debug'] = core::is_debug();
     $cfg['version'] = core::$version;
     $cfg['in_ajax'] = loader::in_ajax();
     $cfg['token'] = $core->auth->token();
     if ($rc = $core->get_renderable_config()) {
         $cfg = array_merge($cfg, $rc);
     }
     // set default title if empty
     if (empty($cfg['title'])) {
         $cfg['title'] = '';
     }
     $cfg['module'] = $module->get_name();
     $cfg['section'] = $controller->get_section_name();
     $cfg['action'] = $controller->get_action_name();
     // ridiculous translate stuff @todo rethink
     $cfg['action_title'] = $controller->get_title();
     // mix configs
     if (!empty($ext_config)) {
         $cfg = array_merge($cfg, $ext_config);
     }
     if (core::in_editor()) {
         $cfg['editor'] = $core->cfg('editor', array());
     }
     // user
     $this->render_user();
     // render modules
     $this->render_modules();
     // this go to template
     $this->set_data('req', core::get_params()->as_array())->set_data('return', $this->return)->set_data('current', $this->current)->set_data('config', $cfg);
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:52,代码来源:renderer.php


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