Skip to content

Commit e2ae2e0

Browse files
authored
Merge pull request #1 from OliveCMS/v2
see change logs
2 parents a728551 + 125fe98 commit e2ae2e0

File tree

22 files changed

+1026
-652
lines changed

22 files changed

+1026
-652
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ test.php
55
composer.phar
66
composer.lock
77
vendor/
8+
debugc/
89
database*/

.travis.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ php:
55
- 5.6
66
- 7.0
77
- 7.1
8-
- 7.2
98

109
services:
1110
- mysql
@@ -16,9 +15,5 @@ before_script:
1615
- composer install
1716

1817
script:
19-
- chmod +x ./test/bash.sh
20-
- chmod +x ./test/src/bexe.sh
21-
- chmod +x ./test/src/lexe.sh
22-
- export IS_TRAVIS_CI=dev
23-
- cd test
24-
- ./bash.sh -y
18+
- chmod +x ./test/run
19+
- ./test/run -y

CHANGELOG.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
11
# Changelog
22

3-
# v1.0
3+
## v2.0
4+
5+
UDSM now have D2T (Database 2 Table) mode! this option is a solution for when Addon can not auto create database! with this mode, app can create auto database.
6+
7+
### Core changes:
8+
9+
* Core class
10+
1. review and rewrite all UDMS namespace classes
11+
2. rename AppDataModel to AppModel
12+
3. add `getAppModel`, `getAppModelData`, `setAppModelData`, `resetAppModel`, `setD2TMod`, `desD2TMode`, `getD2T` and `setD2T` methods
13+
4. rewrite `listDatabases`, `existsDatabase`, `createDatabase`, `renameDatabase` and `dropDatabase` for match with **D2TMode**
14+
5. rewrite `setAppModel` and `render` method
15+
6. review and rewrite optimize for `AppModel`, `AppModelData`, `DatabaseModel` and `DatabaseModelData` methods
16+
7. fix dropDatabase $keep bug
17+
8. fix type (core class -> Core class)
18+
9. fix valid name check bug
19+
10. add errors code for Exception method
20+
11. update Documentation and Readme page
21+
12. add D2TMode Documentation
22+
13. add Errors Documentation
23+
* Common class
24+
1. move path, `DatabaseModel`, `DatabaseModelData` and `addLog` methods to Core class
25+
2. add `getCore` to reserved name
26+
* Database class:
27+
1. add `getName` method
28+
2. rewrite `listTable`, `createTable`, `existsTable`, `dropTable`, `renameTable` and `cleanTable` for match with **D2TMode**
29+
* Table class:
30+
1. rewrite some line for match with **D2TMode**
31+
2. add columns list to DatabaseModelData
32+
3. set default value column type and lenght when null
33+
34+
### Addons changes:
35+
36+
* Json
37+
1. review and rewrite optimize for db and dbc functions
38+
2. rewrite point core methods
39+
* MongoDB
40+
1. fix listTable function problem
41+
2. review and rewrite optimize for db and dbc functions
42+
3. rewrite point core methods
43+
* MySQL
44+
1. fix get relation column type and lenght
45+
2. fix set null column type and lenght
46+
3. rewrite point core methods
47+
48+
### Test case changes:
49+
50+
1. rewrite with ColorConsole
51+
2. fix rmDir use with new Olive\\Tools
52+
3. add `D2TMode` case
53+
4. add addon cases and full test time
54+
55+
## v1.0
456

557
release fast project.
658

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,29 @@ $udms->school->student->find(
5050
- [Usage Instructions](doc/01-usage.md)
5151
- [Utility Classes](doc/02-utilities.md)
5252
- [Addons Connect Instructions](doc/03-addons.md)
53+
- [D2TMode Instructions](doc/04-d2tmode.md)
54+
- [UDMS Errors](doc/05-error.md)
5355

5456
## Requirements
5557

56-
- udms 2.x works with PHP 5.5+.
58+
- UDMS 2.x works with PHP 5.5+.
5759
- PDO mysql
5860
- php mongodb module
5961

62+
# Versioning
63+
64+
UDMS will be maintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered with the following format:
65+
66+
`<major>.<minor>.<patch>`
67+
68+
And constructed with the following guidelines:
69+
70+
major -> Breaking backward compatibility bumps the major
71+
minor -> New additions
72+
patch -> Bug fixes
73+
74+
For more information on SemVer, please visit http://semver.org.
75+
6076
## License
6177

62-
UDMS is licensed under the [MIT license](http://opensource.org/licenses/MIT).
78+
olive-cms/udms is licensed under the [MIT license](http://opensource.org/licenses/MIT).

addons/Json/Point.php

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<?php
22
namespace Olive\UDMS\Addon\Json;
33

4+
use Olive\Tools;
45
use Olive\UDMS\Common as Common;
56
use Olive\UDMS\Model\Addon as Addon;
6-
use Olive\Tools;
77
class Point implements Addon
88
{
99
use Common;
1010

11+
private $cacheDB;
12+
13+
private $cacheDBC;
14+
1115
public function createDatabase($name, $options)
1216
{
13-
$dir = $this->getUCPath($name . '/json/');
17+
$dir = $this->getCore->getUCPath($name . '/json/');
1418
if (! is_dir($dir)) {
1519
mkdir($dir);
1620
}
@@ -20,12 +24,12 @@ public function createDatabase($name, $options)
2024

2125
public function dropDatabase($name)
2226
{
23-
Tools::rmDir($this->getUCPath($name . '/json/'));
27+
Tools::rmDir($this->getCore->getUCPath($name . '/json/'));
2428
}
2529

2630
public function existsDatabase($name)
2731
{
28-
if (file_exists($this->getUCPath($name . '/json/db.json'))) {
32+
if (file_exists($this->getCore->getUCPath($name . '/json/db.json'))) {
2933
return true;
3034
} else {
3135
return false;
@@ -35,9 +39,9 @@ public function existsDatabase($name)
3539
public function listDatabases()
3640
{
3741
$return = [];
38-
$dbdirs = Tools::getDirList($this->getUCPath());
42+
$dbdirs = Tools::getDirList($this->getCore->getUCPath());
3943
foreach ($dbdirs as $db) {
40-
if (file_exists($this->getUCPath($db . '/json/db.json'))) {
44+
if (file_exists($this->getCore->getUCPath($db . '/json/db.json'))) {
4145
$return[] = $db;
4246
}
4347
}
@@ -51,32 +55,32 @@ public function renameDatabase($name, $to)
5155

5256
private function get_db($name)
5357
{
54-
if (! isset($GLOBALS['__udms_global']['addon']['json']['db'][$name])) {
55-
$GLOBALS['__udms_global']['addon']['json']['db'][$name] = Tools::getJsonFile($this->getUCPath($name . '/json/db.json'));
58+
if (is_null($this->cacheDB)) {
59+
$this->cacheDB = Tools::getJsonFile($this->getCore->getUCPath($name . '/json/db.json'));
5660
}
5761

58-
return $GLOBALS['__udms_global']['addon']['json']['db'][$name];
62+
return $this->cacheDB;
5963
}
6064

6165
private function update_db($name, $data = [])
6266
{
63-
Tools::file($this->getUCPath($name . '/json/db.json'), Tools::jsonEncode($data));
64-
$GLOBALS['__udms_global']['addon']['json']['db'][$name] = $data;
67+
Tools::file($this->getCore->getUCPath($name . '/json/db.json'), Tools::jsonEncode($data));
68+
$this->cacheDB = $data;
6569
}
6670

6771
private function get_dbc($name)
6872
{
69-
if (! isset($GLOBALS['__udms_global']['addon']['json']['config'][$name])) {
70-
$GLOBALS['__udms_global']['addon']['json']['config'][$name] = Tools::getJsonFile($this->getUCPath($name . '/json/config.json'));
73+
if (is_null($this->cacheDBC)) {
74+
$this->cacheDBC = Tools::getJsonFile($this->getCore->getUCPath($name . '/json/config.json'));
7175
}
7276

73-
return $GLOBALS['__udms_global']['addon']['json']['config'][$name];
77+
return $this->cacheDBC;
7478
}
7579

7680
private function update_dbc($name, $data = [])
7781
{
78-
Tools::file($this->getUCPath($name . '/json/config.json'), Tools::jsonEncode($data));
79-
$GLOBALS['__udms_global']['addon']['json']['config'][$name] = $data;
82+
Tools::file($this->getCore->getUCPath($name . '/json/config.json'), Tools::jsonEncode($data));
83+
$this->cacheDBC = $data;
8084
}
8185

8286
public function createTable($db, $name, $options)
@@ -221,9 +225,8 @@ public function get($db, $table)
221225
}
222226
}
223227

224-
public function __construct($path, $udmsCacheDir, $option = [])
228+
public function __construct($point, $option = [])
225229
{
226-
$this->setPath($path);
227-
$this->setUCPath($udmsCacheDir);
230+
$this->getCore = $point;
228231
}
229232
}

addons/MongoDB/Point.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
namespace Olive\UDMS\Addon\MongoDB;
33

44
use MongoDB as MDB;
5+
use Olive\Tools;
56
use Olive\UDMS\Common as Common;
67
use Olive\UDMS\Exception\Custom as UException;
78
use Olive\UDMS\Model\Addon as Addon;
8-
use Olive\Tools;
99
class Point implements Addon
1010
{
1111
use Common;
@@ -22,6 +22,8 @@ class Point implements Addon
2222

2323
private $dse;
2424

25+
private $cacheDBC;
26+
2527
public function createDatabase($name, $options)
2628
{
2729
$create = $this->service->$name->__udms_table;
@@ -30,7 +32,7 @@ public function createDatabase($name, $options)
3032
'__udms_id' => '0'
3133
]
3234
);
33-
$dir = $this->getUCPath($name . '/mongodb/');
35+
$dir = $this->getCore->getUCPath($name . '/mongodb/');
3436
if (! is_dir($dir)) {
3537
mkdir($dir);
3638
}
@@ -126,7 +128,7 @@ public function listTables($db)
126128
$return[] = $ti['name'];
127129
}
128130

129-
return $return;
131+
return array_diff($return, ['__udms_table']);
130132
}
131133

132134
public function renameTable($db, $name, $to)
@@ -142,17 +144,17 @@ public function renameTable($db, $name, $to)
142144

143145
private function get_dbc($name)
144146
{
145-
if (! isset($GLOBALS['__udms_global']['addon']['mongodb']['config'][$name])) {
146-
$GLOBALS['__udms_global']['addon']['mongodb']['config'][$name] = Tools::getJsonFile($this->getUCPath($name . '/mongodb/config.json'));
147+
if (is_null($this->cacheDBC)) {
148+
$this->cacheDBC = Tools::getJsonFile($this->getCore->getUCPath($name . '/mongodb/config.json'));
147149
}
148150

149-
return $GLOBALS['__udms_global']['addon']['mongodb']['config'][$name];
151+
return $this->cacheDBC;
150152
}
151153

152154
private function update_dbc($name, $data = [])
153155
{
154-
Tools::file($this->getUCPath($name . '/mongodb/config.json'), Tools::jsonEncode($data));
155-
$GLOBALS['__udms_global']['addon']['mongodb']['config'][$name] = $data;
156+
Tools::file($this->getCore->getUCPath($name . '/mongodb/config.json'), Tools::jsonEncode($data));
157+
$this->cacheDBC = $data;
156158
}
157159

158160
public function createColumn($db, $table, $name, $options)
@@ -254,10 +256,9 @@ public function get($db, $table)
254256
}
255257
}
256258

257-
public function __construct($path, $udmsCacheDir, $option = [])
259+
public function __construct($point, $option = [])
258260
{
259-
$this->setPath($path);
260-
$this->setUCPath($udmsCacheDir);
261+
$this->getCore = $point;
261262
$this->option = $option;
262263
if (isset($option['login'])) {
263264
$login = $option['login'];
@@ -269,7 +270,7 @@ public function __construct($path, $udmsCacheDir, $option = [])
269270
try {
270271
$db = new MDB\Client($option['type'] . '://' . $option['host'], $login);
271272
} catch (Excepstion $e) {
272-
throw new UException($this->getUCPath(), 'Can not connect to MongoDB.');
273+
throw new UException($this->getCore->getUCPath(), 'Can not connect to MongoDB.', 200);
273274
}
274275
$this->service = $db;
275276
}

0 commit comments

Comments
 (0)