Esempio n. 1
0
 public function input_element($type, $params = false)
 {
     if (!self::$inputer) {
         if (vmc::is_online()) {
             self::$inputer = vmc::servicelist('html_input');
         } else {
             self::$inputer = array('base_view_input' => new base_view_input());
         }
     }
     if ($params === false) {
         foreach (self::$inputer as $inputer) {
             $inputer->app = $this->app;
             if (method_exists($inputer, 'input_' . $type)) {
                 return true;
             }
         }
     } else {
         foreach (self::$inputer as $inputer) {
             $inputer->app = $this->app;
             if (method_exists($inputer, 'input_' . $type)) {
                 $html = $inputer->{'input_' . $type}($params);
             }
         }
         return $html;
     }
     return false;
 }
Esempio n. 2
0
 public function has_conflict_apps($apps, &$conflict_apps)
 {
     if (!vmc::is_online() || app::get('base')->status() == 'uninstalled') {
         return false;
     }
     if (is_string($apps)) {
         $apps = array($apps);
     }
     $queue = array();
     $installed_queue = array();
     $install_apps = array();
     $installed_apps = array();
     foreach ($apps as $app_id) {
         $install_apps[$app_id] = array();
         $this->check_conflicts_install($app_id, $queue);
     }
     $rows = vmc::database()->select('select app_id from vmc_base_apps where status != "uninstalled"');
     foreach ($rows as $row) {
         $installed_apps[$row['app_id']] = array();
         $this->check_conflicts_install($row['app_id'], $installed_queue);
     }
     $conflict_one = array_intersect_key($queue, $installed_apps);
     $conflict_two = array_intersect_key($installed_queue, $install_apps);
     $conflict_apps = array_merge($conflict_one, $conflict_two);
     return count($conflict_apps) ? true : false;
 }
Esempio n. 3
0
 function &load($check_lastmodified = true)
 {
     $real_table_name = $this->real_table_name();
     if ($this->_define[$real_table_name]) {
         return $this->_define[$real_table_name];
     }
     if (vmc::is_online() && !($this->target_app->app_id == 'base' && $this->key() == 'kvstore')) {
         if (defined('EXTENDS_DIR') && file_exists(EXTENDS_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php')) {
             $define_lastmodified = $check_lastmodified ? filemtime(EXTENDS_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php') : null;
         } else {
             $define_lastmodified = $check_lastmodified ? filemtime($this->target_app->app_dir . '/dbschema/' . $this->key . '.php') : null;
         }
         $define_flag = base_kvstore::instance('tbdefine')->fetch($this->target_app->app_id . $this->key, $define, $define_lastmodified);
     } else {
         $define_flag = false;
     }
     if ($define_flag === false) {
         if (defined('EXTENDS_DIR') && file_exists(EXTENDS_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php')) {
             require EXTENDS_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php';
         } else {
             require $this->target_app->app_dir . '/dbschema/' . $this->key . '.php';
         }
         $define =& $db[$this->key()];
         $this->_define[$real_table_name] =& $define;
         foreach ($define['columns'] as $k => $v) {
             if ($v['pkey']) {
                 $define['idColumn'][$k] = $k;
             }
             // 虚拟主键,用于没有主键的表需要用到系统通用的需要主键的方法,如果detail_func($id)这种finder列表需要的地方
             if ($v['virtual_pkey']) {
                 $define['virtual_pkey'][$k] = $k;
             }
             if ($v['is_title']) {
                 $define['textColumn'][$k] = $k;
             }
             if ($v['in_list']) {
                 $define['in_list'][] = $k;
                 if ($v['default_in_list']) {
                     $define['default_in_list'][] = $k;
                 }
             }
             $define['columns'][$k] = $this->_prepare_column($k, $v);
             if (isset($v['pkey']) && $v['pkey']) {
                 $define['pkeys'][$k] = $k;
             }
         }
         if (!$define['idColumn']) {
             if ($define['virtual_pkey'] && count($define['virtual_pkey']) == 1) {
                 $define['idColumn'] = current($define['virtual_pkey']);
             } else {
                 $define['idColumn'] = key($define['columns']);
             }
         } elseif (count($define['idColumn']) == 1) {
             $define['idColumn'] = current($define['idColumn']);
         }
         if (!$define['textColumn']) {
             $keys = array_keys($define['columns']);
             $define['textColumn'] = $keys[1];
         } elseif (count($define['idColumn']) == 1) {
             $define['textColumn'] = current($define['textColumn']);
         }
         if (vmc::is_online() && !($this->target_app->app_id == 'base' && $this->key() == 'kvstore')) {
             base_kvstore::instance('tbdefine')->store($this->target_app->app_id . $this->key, $define);
         }
     }
     return $define;
 }
Esempio n. 4
0
 public function status()
 {
     if (vmc::is_online()) {
         if (!vmc::database()->select('SHOW TABLES LIKE "' . vmc::database()->prefix . 'base_apps"')) {
             return 'uninstalled';
         } else {
             $row = @vmc::database()->selectrow('select status from vmc_base_apps where app_id="' . $this->app_id . '"');
         }
         return $row ? $row['status'] : 'uninstalled';
     } else {
         return 'uninstalled';
     }
 }
Esempio n. 5
0
 public function store($key, $value, $ttl = 0, $persistent = true)
 {
     self::$__store_count++;
     if ($persistent && (defined('KV_PERSISTENT') && constant('KV_PERSISTENT')) && self::$__persistent && get_class($this->get_controller()) != 'base_kvstore_mysql' && vmc::is_online()) {
         $this->persistent($key, $value, $ttl);
     }
     logger::debug('kvstore:' . self::$__fetch_count . '.' . ' instance:' . $this->get_prefix() . ' store key:' . $key);
     return $this->get_controller()->store($key, $value, $ttl);
 }