private function __construct()
 {
     /*{{{*/
     $file = BaseConfig::getConf("log_file");
     $file = str_replace("%DATE", date("Ymd"), $file);
     $this->_file = fopen($file, "a");
     $this->_level = strtolower(BaseConfig::getConf("log_level"));
 }
Exemple #2
0
 public function assign_public_tpl_vars()
 {
     $media_url = ini('base/MEDIA_URL');
     if (substr($media_url, 0, 4) != 'http') {
         $media_url = ini('base/BASE_URL') . $media_url;
         BaseConfig::set('base/MEDIA_URL', $media_url);
     }
     $this->assign('BASE_URL', ini('base/BASE_URL'));
     $this->assign('MEDIA_URL', $media_url);
 }
Exemple #3
0
 public function __construct($code = '', $message = '', $previous = '')
 {
     BaseConfig::load(Package::get_file('system/config/exception.yml'));
     $this->exception_messages = ini('exception/messages');
     if ($this->exception_messages[$code]) {
         $message = '(' . $code . ') ' . sprintf(_($this->exception_messages[$code]), $message);
     }
     $this->message = $message;
     $this->code = $code;
 }
 function update($data)
 {
     foreach ($this->findAll() as $row) {
         $newValue = $data[$row->name];
         $tmp = explode('_', $row->name);
         if ($tmp[0] == 'pick') {
             $newValue = $newValue == 'on' ? 1 : 0;
         }
         parent::update(array('configId' => $row->configId, 'value' => $newValue));
     }
 }
 public static function getConf($var)
 {
     /*{{{*/
     if (empty(self::$conf_arr)) {
         $a = get_class_vars('BaseConfig');
         $b = get_class_vars('AppConfig');
         self::$conf_arr = array_merge($a, $b);
         return self::$conf_arr[$var];
     } else {
         return self::$conf_arr[$var];
     }
 }
Exemple #6
0
 /**
  * Collects the application-specific autoload settings and merges
  * them with the framework's required settings.
  *
  * NOTE: If you use an identical key in $psr4 or $classmap, then
  * the values in this file will overwrite the framework's values.
  */
 public function __construct()
 {
     parent::__construct();
     /*
      * -------------------------------------------------------------------
      * Namespaces
      * -------------------------------------------------------------------
      * This maps the locations of any namespaces in your application
      * to their location on the file system. These are used by the
      * Autoloader to locate files the first time they have been instantiated.
      *
      * The '/application' and '/system' directories are already mapped for
      * you. You may change the name of the 'Registry' namespace if you wish,
      * but this should be done prior to creating any namespaced classes,
      * else you will need to modify all of those classes for this to work.
      *
      * DO NOT change the name of the CodeIgniter namespace or your application
      * WILL break. *
      * Prototype:
      *
      *   $Config['psr4'] = [
      *       'CodeIgniter' => SYSPATH
      *   `];
      */
     $psr4 = ['App\\Migrations' => APPPATH . 'migrations', 'app\\models' => APPPATH . 'models', 'Eddmash\\PowerOrm' => POWERORM_SRCPATH, 'Eddmash\\PowerOrmFaker' => APPPATH . 'libraries' . DIRECTORY_SEPARATOR . 'powerormfaker' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR];
     /*
      * -------------------------------------------------------------------
      * Class Map
      * -------------------------------------------------------------------
      * The class map provides a map of class names and their exact
      * location on the drive. Classes loaded in this manner will have
      * slightly faster performance because they will not have to be
      * searched for within one or more directories as they would if they
      * were being autoloaded through a namespace.
      *
      * Prototype:
      *
      *   $Config['classmap'] = [
      *       'MyClass'   => '/path/to/class/file.php'
      *   ];
      */
     $classmap = ['PModel' => POWERORM_BASEPATH . 'PModel.php', 'CI_Model' => BASEPATH . '/core/Model.php', 'CI_DB_forge' => BASEPATH . '/database/DB_forge.php', 'CI_DB_driver' => BASEPATH . '/database/DB_driver.php', 'CI_DB_query_builder' => BASEPATH . '/database/DB_query_builder.php'];
     //--------------------------------------------------------------------
     // Do Not Edit Below This Line
     //--------------------------------------------------------------------
     $this->psr4 = array_merge($this->psr4, $psr4);
     $this->classmap = array_merge($this->classmap, $classmap);
     unset($psr4, $classmap);
 }
Exemple #7
0
 public static function init()
 {
     if (self::$inited == true) {
         return true;
     }
     import('system/bin/yaml');
     import('system/bin/cache');
     $cache_instance = CacheBackend::get_instance(array('use' => 'xcache'));
     $cache_id = '__BASE__CONFIG__';
     if ($cache_instance->is_cached($cache_id) && RUN_MODE == 'deploy') {
         self::$config['base'] = $cache_instance->get($cache_id);
     } else {
         self::$config['base'] = YamlBackend::load('etc/common.yml', false);
         $cache_instance->set($cache_id, self::$config['base']);
     }
     self::$inited = true;
 }
Exemple #8
0
 public static function init($dsn = null, $init_connect = true)
 {
     BaseConfig::load(Package::get_file('etc/conf.d/database.yml'));
     self::$dsn = sprintf('%s://%s:%s@%s:%s/%s', ini('database/' . RUN_MODE . '/adapter'), ini('database/' . RUN_MODE . '/user'), ini('database/' . RUN_MODE . '/passwd'), ini('database/' . RUN_MODE . '/host'), ini('database/' . RUN_MODE . '/port'), ini('database/' . RUN_MODE . '/name'));
     if (self::$inited !== true) {
         import('system/vendors/Doctrine/Doctrine');
         spl_autoload_register(array('Doctrine', 'autoload'));
         self::$inited = true;
     }
     if ($dsn) {
         self::$dsn = $dsn;
     }
     if ($init_connect) {
         self::create_connection(null, self::$dsn, ini('database/' . RUN_MODE . '/charset'));
     }
     spl_autoload_register(array('Doctrine_Core', 'modelsAutoload'));
 }
Exemple #9
0
 public static function load_plugins($_application = null, $_plugin_name = null, $_position = null)
 {
     /*
      * the global plugins
      */
     $plugins = YamlBackend::load('etc/conf.d/plugins.yml');
     if ($plugins) {
         foreach ((array) $plugins as $hook_name => $plugin) {
             if (!$plugin) {
                 continue;
             }
             foreach ((array) $plugin as $plugin_name => $plugin_action) {
                 self::register($hook_name, $plugin_name, $plugin_action);
             }
         }
     }
     /*
      * load the single application's plugins
      */
     if ($_application) {
         $installed_apps = array($_application);
     } else {
         $installed_apps = ini('base/INSTALLED_APPS');
     }
     $installed_apps_config = BaseConfig::get_apps_config($installed_apps);
     foreach ((array) $installed_apps_config as $app_config) {
         foreach ((array) $app_config['plugins'] as $hook_name => $ps) {
             if (!$ps) {
                 continue;
             }
             /*
              * load the decided plugin
              */
             if ($_plugin_name && $ps[$_plugin_name]) {
                 self::register($hook_name, $_plugin_name, $ps[$_plugin_name]);
                 return;
             }
             foreach ((array) $ps as $name => $plugin) {
                 self::register($hook_name, $name, $plugin);
             }
         }
     }
 }
Exemple #10
0
 public static function poweron()
 {
     if (function_exists('ob_gzhandler')) {
         ob_start('ob_gzhandler');
     } else {
         ob_start();
     }
     import('system/share/exception/BaseException');
     import('system/share/exception/DoesNotExistsException');
     //set_exception_handler(array('BaseException', 'handler'));
     import('system/share/config/base');
     BaseConfig::init();
     self::BuildEnvironment();
     import('system/share/pluggable/base');
     import('system/share/network/request');
     Request::init();
     //echo "123";
     self::runApplication();
     self::output();
 }
Exemple #11
0
 function ini($path = null)
 {
     return BaseConfig::get($path);
 }
Exemple #12
0
 protected function __load__mongo_model__($model)
 {
     import('system/bin/mongo');
     list($model_path, $model_name) = explode('.', $model);
     import('applications/' . $model_path . '/mongo_models/' . $model_name);
     BaseConfig::load(Package::get_file('etc/conf.d/database.yml'));
     $dbinfo = ini('database/mongo_' . RUN_MODE);
     call_user_func(array($model_name, 'setup'), $dbinfo);
     //        $model_name::setup($dbinfo);
 }
Exemple #13
0
 /**
  * Initializes internal state of Config object.
  * @see        parent::__construct()
  */
 public function __construct()
 {
     // Make sure that parent constructor is always invoked, since that
     // is where any default values for this object are set.
     parent::__construct();
 }
Exemple #14
0
 /**
  * @return resource a MySQL link identifier on success, or display error on failure.
  */
 public static function getConection()
 {
     //if(!self::$DB_LINK){
     try {
         if (!self::$DB_LINK) {
             //echo Debug::li(" {".Config::DATA_BASE_SERVER."}, {".Config::DATA_BASE_USER."}, {".Config::DATA_BASE_PASSWORD."} ");
             self::$DB_LINK = mysql_connect(Config::DATA_BASE_SERVER, Config::DATA_BASE_USER, Config::DATA_BASE_PASSWORD);
             if (!mysql_errno()) {
                 $temp_connect = mysql_select_db(Config::DATA_BASE_NAME, self::$DB_LINK);
                 if (mysql_errno()) {
                     echo "erro ao selecionar database:" . mysql_error();
                     exit;
                 }
             }
         }
         return self::$DB_LINK;
     } catch (Exception $e) {
         $ReturnResultVO->sucess = FALSE;
         $ReturnResultVO->addMessage($e);
         echo "erro de conexao com o banco";
         exit;
     }
     // end try{
     //}
 }
Exemple #15
0
 /**
  * @param InputConfig $InputConfig
  */
 public function __construct(InputConfig $InputConfig)
 {
     $this->input_config = $InputConfig;
     parent::__construct();
 }
Exemple #16
0
 public static function dispatch($app, $view_action, array $params = null)
 {
     $view_action = $view_action ? $view_action : 'index';
     import('system/bin/application');
     import('system/bin/cache');
     /*
      * application's url pattern mapping
      */
     $app_map_array = YamlBackend::load('etc/conf.d/urls.yml');
     if ($app_map_array['map'][$app]) {
         $app = $app_map_array['map'][$app];
     } else {
         if (array_keys($app_map_array['map'], $app)) {
             throw new DispatchException(1011, $app . '/' . $view_action);
         }
     }
     /*
      * Cache all INSTALLED APPS urls pattern
      */
     $cache_id = 'URLS_MAP';
     $url_name_map_cache_id = 'URL_NAME_MAP';
     $app_map_array_flip_cache_id = 'URL_APP_MAP_ARRAY_FLIP';
     $cache_instance = CacheBackend::get_instance();
     if ($cache_instance->is_cached($cache_id) && RUN_MODE == 'deploy' && false) {
         self::$url_patterns = $cache_instance->get($cache_id);
         self::$url_name_map = $cache_instance->get($url_name_map_cache_id);
         $app_map_array_flip = $cache_instance->get($app_map_array_flip_cache_id);
     } else {
         $installed_apps = ini('base/INSTALLED_APPS');
         $app_map_array_flip = array_flip($app_map_array['map']);
         foreach ($installed_apps as $installed_app) {
             $urlpattern = YamlBackend::load(sprintf('applications/%s/urls.yml', $installed_app));
             if ($app_map_array_flip[$installed_app]) {
                 $installed_app = $app_map_array_flip[$installed_app];
             }
             /*
              * The url-name map to view action
              * like: url name='auth_login' => auth.AuthController.login
              */
             if ($urlpattern) {
                 foreach ($urlpattern as $key => $value) {
                     if ($value['name']) {
                         self::$url_name_map[$value['name']] = $installed_app . '/' . $key;
                     }
                 }
             }
             self::$url_patterns[$installed_app] = $urlpattern;
         }
         $cache_instance->set($cache_id, self::$url_patterns);
         if (self::$url_name_map) {
             $cache_instance->set($url_name_map_cache_id, self::$url_name_map);
         }
         $cache_instance->set($app_map_array_flip_cache_id, $app_map_array_flip);
     }
     $app_map_name = array_key_exists($app, $app_map_array_flip) ? $app_map_array_flip[$app] : $app;
     $urlpattern = self::$url_patterns[$app_map_name];
     try {
         /*
          * does not set the action key
          */
         if (!$urlpattern[$view_action]['action']) {
             $_c = ucfirst($app) . 'Controller';
             try {
                 import(Package::get_file(sprintf('applications/%s/%s', $app, $_c)));
                 $urlpattern[$view_action]['action'] = $_c . '.' . $view_action;
             } catch (DoesNotExistsException $e) {
                 throw new DispatchException(1011, $app . '/' . $view_action);
             }
         }
         list($controller, $method) = explode('.', $urlpattern[$view_action]['action']);
         import(sprintf('applications/%s/%s', $app, $controller));
         if (!is_callable(array($controller, $method))) {
             throw new DispatchException(1011, $app . '/' . $view_action);
         }
         /*
          * Set current application and action
          */
         RuntimeConfig::set('runtime/application', $app);
         RuntimeConfig::set('runtime/action', $view_action);
         RuntimeConfig::set('runtime/view_action', $app . '/' . $view_action);
         BaseConfig::load_application_config($app);
         try {
             $controller = new $controller($params);
             RuntimeConfig::set('runtime/application_instance', $controller);
             /*
              * Re-init the plugins with the application implements
              */
             Pluggable::init($controller);
             /*
              * Trigger the plugins in before_application_run
              */
             Pluggable::trigger('before_application_run');
             /*
              * Call the view-action method
              */
             call_user_func_array(array($controller, $method), (array) $params);
             /*
              * Dependence exception
              */
         } catch (DependenceException $e) {
             //pass
         }
         /*
          * When the DispatchException catched
          * Return the 404
          */
     } catch (DispatchException $e) {
         $app = new BaseApplication();
         Pluggable::init($app);
         Pluggable::trigger('before_application_run');
         $app->load('smarty')->display('404');
     }
 }
Exemple #17
0
 public function __construct()
 {
     parent::__construct('ser_categories.php');
 }
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     ConfigPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new ConfigPeer();
     }
     return self::$peer;
 }
 public function getDbName($logic_column_value)
 {
     if (parent::getIsSingleDb()) {
         return parent::getSingleDbName();
     }
     if (parent::getIsDateDb()) {
         return parent::get_date_db_name();
     }
     if (parent::getDbLogicColumnType() && parent::getDbLogicColumnType() == 'string' && !is_numeric($logic_column_value)) {
         $logic_column_value = cls_dbroute::strToInt($logic_column_value);
     }
     return $this->hash->lookup($logic_column_value);
 }