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


PHP application::get_instance方法代码示例

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


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

示例1: get_url_valid

 function get_url_valid()
 {
     if ($this->url) {
         return $this->url;
     }
     $route = $this->route ? $this->route : 'default';
     $p = array('controller' => $this->controller, 'action' => $this->action);
     if ($this->param) {
         if (is_string($this->param)) {
             $param = explode(',', $this->param);
             $map = is_string($this->map) ? explode(',', $this->map) : array();
             if ($map) {
                 foreach ($map as $n => $el) {
                     $el = trim($el);
                     if ($el) {
                         $p[$el] = trim(@$param[$n]);
                     }
                 }
             }
         } else {
             $pp = clone $this->param;
             if ($pp instanceof data) {
                 $pp = $pp->to_array();
             }
             $p = array_merge($p, $pp);
         }
     }
     $view = application::get_instance()->controller->view;
     $href = $view->url($p, $route);
     return $href;
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:31,代码来源:menu.php

示例2: __get

 function __get($k)
 {
     if ($k == 'view') {
         return $this->view;
     }
     // Смысл класса сущности - в создании виртуальных переменных класса, не связанных с данными сущности. Виртуальная переменная транслируется в метод get_имя_паременной класса сущности, который должен вернуть ее значение
     $method = 'get_' . $k;
     $k_replaced = preg_replace('/\\_(valid|control|lang)$/i', '', $k);
     if (method_exists($this, $method)) {
         $ret = $this->{$method}();
     } else {
         $ret = $this->get($k);
         if ($ret === null && $k != $k_replaced) {
             $ret = $this->get($k_replaced);
         }
     }
     if ($k != $k_replaced) {
         $reg = application::get_instance()->controller->view->lang(true);
         if ($reg && array_key_exists('ml_' . $k_replaced . '_' . $reg->id, $this->_data)) {
             $ret_lang = $this->get('ml_' . $k_replaced . '_' . $reg->id);
             if (strlen($ret_lang) == 0) {
                 if (array_key_exists('ml_' . $k_replaced . '_' . application::get_instance()->controller->view->lang()->default->id, $this->_data)) {
                     $ret_lang = $this->get('ml_' . $k_replaced . '_' . application::get_instance()->controller->view->lang()->default->id);
                     if (strlen($ret_lang) > 0) {
                         $ret = $ret_lang;
                     }
                 }
             } else {
                 $ret = $ret_lang;
             }
         }
     }
     return $ret;
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:34,代码来源:entity.php

示例3: init

 public function init()
 {
     if ($this->_inited) {
         return;
     }
     $this->_inited = true;
     $config = application::get_instance()->config->user;
     $config->model = array();
     $config->model->user = isset($config->model->user) ? $config->model->user : $this->default_model_user;
     $this->model_user = 'model_' . $config->model->user;
     if (class_exists($this->model_user)) {
         $this->model_user = new $this->model_user();
         $this->_key = 'user_' . $this->model_user->name;
     }
     $this->model_usersoc = 'model_' . (isset($config->model->usersoc) ? $config->model->usersoc : $this->default_model_usersoc);
     $this->model_usersoc = class_exists($this->model_usersoc) ? new $this->model_usersoc() : null;
     if ($config->acl) {
         $this->model_role = 'model_' . (isset($config->model->role) ? $config->model->role : $this->default_model_role);
         $this->model_role = class_exists($this->model_role) ? new $this->model_role() : null;
         $this->model_rule = 'model_' . (isset($config->model->rule) ? $config->model->rule : $this->default_model_rule);
         $this->model_rule = class_exists($this->model_rule) ? new $this->model_rule() : null;
         $this->model_resource = 'model_' . (isset($config->model->resource) ? $config->model->resource : $this->default_model_resource);
         $this->model_resource = class_exists($this->model_resource) ? new $this->model_resource() : null;
         $this->model_role2role = 'model_' . (isset($config->model->role2role) ? $config->model->role2role : $this->default_model_role2role);
         $this->model_role2role = class_exists($this->model_role2role) ? new $this->model_role2role() : null;
         $this->model_rule2role = 'model_' . (isset($config->model->rule2role) ? $config->model->rule2role : $this->default_model_rule2role);
         $this->model_rule2role = class_exists($this->model_rule2role) ? new $this->model_rule2role() : null;
         $this->model_rule2resource = 'model_' . (isset($config->model->rule2resource) ? $config->model->rule2resource : $this->default_model_rule2resource);
         $this->model_rule2resource = class_exists($this->model_rule2resource) ? new $this->model_rule2resource() : null;
         $this->init_acl();
     }
     $this->salt = $config->salt;
     $this->login_auto();
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:34,代码来源:user.php

示例4: init

 public function init()
 {
     if ($this->data) {
         return;
     }
     $lang = application::get_instance()->config->translate->lang;
     if (file_exists(PATH_ROOT . '/' . DIR_LIBRARY . '/translate/' . $lang . '.php')) {
         $data = (include PATH_ROOT . '/' . DIR_LIBRARY . '/translate/' . $lang . '.php');
         if ($data) {
             $this->data = array_merge($this->data, $data);
         }
     }
     if (file_exists(PATH_ROOT . '/' . DIR_APPLICATION . '/translate/' . $lang . '.php')) {
         $data = (include PATH_ROOT . '/' . DIR_APPLICATION . '/translate/' . $lang . '.php');
         if ($data) {
             $this->data = array_merge($this->data, $data);
         }
     }
     if (class_exists('model_translate')) {
         $m = new model_translate();
         $data_db = $m->fetch_all();
         if ($data_db) {
             $data_array = array();
             foreach ($data_db as $el) {
                 $data_array[$el->key] = $el->value_lang;
             }
             $this->data = array_merge($this->data, $data_array);
         }
     }
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:30,代码来源:translate.php

示例5: call

 public static function call($message = 'Application Error', $code = 500)
 {
     $_SERVER['REQUEST_URI'] = '/error';
     header('HTTP/1.1 ' . $code . ' ' . $message);
     application::$instance = new application();
     application::get_instance()->bootstrap()->run();
     exit;
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:8,代码来源:error.php

示例6: url

 public function url($data = null, $route = 'default')
 {
     if ($data === null) {
         return $this;
     }
     $router = application::get_instance()->router;
     $request = application::get_instance()->request;
     return isset($router->route[$route]) ? $router->route[$route]->assemble($data, $request, $this->default) : '';
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:9,代码来源:url.php

示例7: set

 public function set($lang)
 {
     if (application::get_instance()->config->resource->lang->type != 'session') {
         return false;
     }
     if ($lang) {
         session::set('lang', $lang);
     } else {
         session::remove('lang');
     }
     setcookie($this->_key, $lang, time() + 86400 * 30, '/');
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:12,代码来源:lang.php

示例8: __construct

 public function __construct($name, $param = array())
 {
     $this->name = $name;
     if (isset($param['id'])) {
         $this->id = $param['id'];
     }
     if (isset($param['class'])) {
         $this->class = $param['class'];
     }
     if (isset($param['view_script'])) {
         $this->view_script = $param['view_script'];
     }
     if (isset($param['frame_view_script'])) {
         $this->frame_view_script = $param['frame_view_script'];
     }
     if (isset($param['class_error'])) {
         $this->class_error = $param['class_error'];
     }
     if (isset($param['class_frame'])) {
         $this->class_frame = $param['class_frame'];
     }
     if (isset($param['class_control'])) {
         $this->class_control = $param['class_control'];
     }
     if (isset($param['class_label'])) {
         $this->class_label = $param['class_label'];
     }
     if (isset($param['label'])) {
         $this->label = $param['label'];
     }
     if (isset($param['attr'])) {
         $this->attr = $param['attr'];
     }
     if (isset($param['validator'])) {
         $this->validator = $param['validator'];
     }
     if (isset($param['description'])) {
         $this->description = $param['description'];
     }
     if (isset($param['required'])) {
         $this->required = $param['required'];
     }
     if (isset($param['value'])) {
         $this->value = $param['value'];
     }
     if (isset($param['attribute'])) {
         $this->attribute = new data($param['attribute']);
     }
     if (isset($param['item'])) {
         $this->item = new data($param['item']);
     }
     $this->view = application::get_instance()->controller->view;
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:53,代码来源:element.php

示例9: send

 public function send()
 {
     if ($this->body) {
         $res = implode('', $this->body);
         $config = application::get_instance()->config->html;
         if ($config->compress && ob_start("ob_gzhandler")) {
             ini_set('zlib.output_compression_level', 6);
         } else {
             ob_start();
         }
         echo $res;
     }
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:13,代码来源:response.php

示例10: url

 function url($url = '')
 {
     $url = $url ? $url : application::get_instance()->request->url;
     if (application::get_instance()->config->resource->lang) {
         $m = new model_lang();
         $langs = $m->fetch_col('stitle', array('show_it' => 1));
         $url = preg_replace('/^\\/(' . implode('|', $langs) . ')\\//si', '/', $url);
     }
     $m = new model_meta();
     $data = $m->fetch_by_url($url);
     if ($data) {
         $this->auto($data, false);
     }
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:14,代码来源:collector.php

示例11: forward

 public function forward($action, $controller = null, $param = null)
 {
     $app = $this->layout = application::get_instance();
     $app->request->controller = $controller;
     if (!$app->request->controller) {
         $app->request->controller = str_replace('controller_', '', get_class($app->controller));
     }
     $app->request->action = $action;
     if ($param) {
         $app->request->param = new data($param);
     }
     $app->run_controller();
     exit;
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:14,代码来源:controller.php

示例12: iqsms

 function iqsms($message, $phones, $config)
 {
     $y = application::get_instance()->config->sms->iqsms;
     $ok = 0;
     foreach ($phones as $phone) {
         $ch = curl_init('http://gate.iqsms.ru/send/?phone=' . rawurlencode($phone) . '&text=' . rawurlencode($message) . (@$config['sender'] ? '&sender=' . rawurlencode($config['sender']) : ''));
         curl_setopt($ch, CURLOPT_USERPWD, $y['login'] . ':' . $y['password']);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $res = curl_exec($ch);
         $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if ($status_code == 200 && stripos($res, 'accepted') !== false) {
             $ok++;
         }
     }
     return $ok;
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:16,代码来源:sms.php

示例13: __construct

 function __construct($config)
 {
     if ($config->type != 'session') {
         if (preg_match('/^\\/x\\//i', @$_SERVER['REQUEST_URI'])) {
             return;
         }
         $route = new data();
         if (count(application::get_instance()->config->route)) {
             $ml = new model_lang();
             $default = $ml->fetch_one('stitle', array('is_default' => 1));
             foreach (application::get_instance()->config->route as $k => $v) {
                 $route->{$k} = array('type' => 'chain', 'param' => array('part' => array(array('type' => 'rewrite', 'param' => array('url' => '([^\\/]+)', 'map' => 'lang', 'default' => $default)), clone $v), 'controller' => $v->param ? $v->param->controller : null, 'action' => $v->param ? $v->param->action : null, 'inner' => $v->inner, 'title' => $v->title));
             }
         }
         application::get_instance()->router = new router($route);
     }
     application::get_instance()->config->plugin[] = 'lang';
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:18,代码来源:lang.php

示例14: init

 function init()
 {
     $this->config = application::get_instance()->config->pay ? clone application::get_instance()->config->pay : new data();
     $mt = new model_translate();
     $config_db = $mt->fetch_col('key', '(SUBSTRING(`key`, 1, 4) = "pay_")');
     if ($config_db) {
         foreach ($config_db as $v) {
             $p = explode('_', $v);
             array_shift($p);
             $p0 = array_shift($p);
             if ($p0 && $p) {
                 $p = implode('_', $p);
                 $this->config[$p0] = isset($this->config[$p0]) ? $this->config[$p0] : array();
                 $this->config[$p0][$p] = $this->view->translate($v);
             }
         }
     }
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:18,代码来源:pay.php

示例15: controller_before

 public function controller_before()
 {
     $ml = new model_lang();
     $ids = $ml->fetch_col('stitle', array('show_it' => 1));
     if (@application::get_instance()->config->resource->lang->type == 'session') {
         if ($ids) {
             $lang_session = session::get('lang');
             $lang_cookie = @$_COOKIE['lang'];
             if ($lang_session && !in_array($lang_session, $ids)) {
                 session::remove('lang');
                 $lang_session = null;
             }
             if ($lang_cookie && !in_array($lang_cookie, $ids) || $lang_cookie && $lang_session && $lang_session != $lang_cookie) {
                 setcookie('lang', null, time() + 86400 * 30, '/');
             }
             if ($lang_cookie && !$lang_session) {
                 session::set('lang', $lang_cookie);
                 $lang_session = $lang_cookie;
             }
             if (application::get_instance()->config->resource->lang->detect && !$lang_session) {
                 $lang_detected = $this->prefered_language($ids, @$_SERVER['HTTP_ACCEPT_LANGUAGE']);
                 if ($lang_detected) {
                     session::set('lang', $lang_detected);
                 }
             }
         }
     } else {
         if ($ids && !in_array(application::get_instance()->controller->request->param->lang, $ids)) {
             unset(application::get_instance()->controller->request->param->lang);
         }
         if (!application::get_instance()->controller->request->param->lang) {
             application::get_instance()->controller->request->param->lang = application::get_instance()->controller->view->lang()->default->stitle;
         }
         if (application::get_instance()->request->url == '/control') {
             header('Location: /' . application::get_instance()->controller->view->lang()->default->stitle . '/control');
             exit;
         } else {
             if (application::get_instance()->request->url == '/error') {
                 header('Location: /' . application::get_instance()->controller->view->lang('stitle') . '/error');
                 exit;
             }
         }
     }
 }
开发者ID:s-kalaus,项目名称:ekernel,代码行数:44,代码来源:lang.php


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