12
12
13
13
/** Demo management Componenet */
14
14
class DemoComponent extends AppComponent
15
- {
15
+ {
16
16
/** reset database (only works with mysql)*/
17
17
public function reset ()
18
18
{
19
19
if (Zend_Registry::get ('configGlobal ' )->demomode != 1 )
20
20
{
21
21
throw new Zend_Exception ("Please enable demo mode " );
22
22
}
23
-
24
- $ db = Zend_Registry::get ('dbAdapter ' );
23
+
24
+ $ db = Zend_Registry::get ('dbAdapter ' );
25
25
$ dbname = Zend_Registry::get ('configDatabase ' )->database ->params ->dbname ;
26
-
27
- $ stmt = $ db ->query ("SELECT * FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = ' " .$ dbname ."' " );
26
+
27
+ $ stmt = $ db ->query ("SELECT * FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = ' " .$ dbname ."' " );
28
28
while ($ row = $ stmt ->fetch ())
29
29
{
30
- $ db ->query ("DELETE FROM ` " .$ row ['TABLE_NAME ' ]."` " );
30
+ $ db ->query ("DELETE FROM ` " .$ row ['TABLE_NAME ' ]."` " );
31
31
}
32
32
33
33
$ path = BASE_PATH .'/data/assetstore ' ;
34
34
$ dir = opendir ($ path );
35
- while ($ entry = readdir ($ dir ))
36
- {
35
+ while ($ entry = readdir ($ dir ))
36
+ {
37
37
if (is_dir ($ path .'/ ' .$ entry ) && !in_array ($ entry , array ('. ' , '.. ' )))
38
38
{
39
39
$ this ->_rrmdir ($ path .'/ ' .$ entry );
40
40
}
41
41
}
42
-
42
+
43
43
$ path = BASE_PATH .'/data/thumbnail ' ;
44
44
$ dir = opendir ($ path );
45
- while ($ entry = readdir ($ dir ))
46
- {
45
+ while ($ entry = readdir ($ dir ))
46
+ {
47
47
if (is_dir ($ path .'/ ' .$ entry ) && !in_array ($ entry , array ('. ' , '.. ' )))
48
48
{
49
49
$ this ->_rrmdir ($ path .'/ ' .$ entry );
50
50
}
51
51
}
52
-
52
+
53
53
if (file_exists (BASE_PATH .'/core/configs/ldap.local.ini ' ))
54
54
{
55
55
unlink (BASE_PATH .'/core/configs/ldap.local.ini ' );
56
56
}
57
-
57
+
58
58
$ modelLoad = new MIDAS_ModelLoader ();
59
59
$ userModel = $ modelLoad ->loadModel ('User ' );
60
60
$ communityModel = $ modelLoad ->loadModel ('Community ' );
61
61
$ assetstoreModel = $ modelLoad ->loadModel ('Assetstore ' );
62
62
$ admin = $ userModel ->createUser ('admin@kitware.com ' , 'admin ' , 'Demo ' , 'Administrator ' , 1 );
63
63
$ user = $ userModel ->createUser ('user@kitware.com ' , 'user ' , 'Demo ' , 'User ' , 0 );
64
-
64
+
65
65
$ communityDao = $ communityModel ->createCommunity ('Demo ' , "This is a Demo Community " , MIDAS_COMMUNITY_PUBLIC , $ admin , MIDAS_COMMUNITY_CAN_JOIN );
66
-
66
+
67
67
$ assetstoreDao = new AssetstoreDao ();
68
68
$ assetstoreDao ->setName ('Default ' );
69
69
$ assetstoreDao ->setPath (BASE_PATH .'/data/assetstore ' );
70
70
$ assetstoreDao ->setType (MIDAS_ASSETSTORE_LOCAL );
71
- $ assetstoreModel ->save ($ assetstoreDao );
72
-
71
+ $ assetstoreModel ->save ($ assetstoreDao );
72
+
73
73
$ applicationConfig = parse_ini_file (BASE_PATH .'/core/configs/application.ini ' , true );
74
- $ applicationConfig ['global ' ]['defaultassetstore.id ' ] = $ assetstoreDao ->getKey ();
75
- $ applicationConfig ['global ' ]['demomode ' ] = true ;
76
- $ applicationConfig ['global ' ]['environment ' ] = 'development ' ;
77
- $ applicationConfig ['global ' ]['application.name ' ] = 'MIDAS - Demo ' ;
78
- $ applicationConfig ['global ' ]['application.description ' ] = 'MIDAS integrates multimedia server technology with Kitware?s open-source data analysis and visualization clients. The server follows open standards for data storage, access and harvesting ' ;
79
- $ applicationConfig ['global ' ]['application.keywords ' ] = 'demonstration, data management, visualization ' ;
80
-
74
+ $ applicationConfig ['global ' ]['defaultassetstore.id ' ] = $ assetstoreDao ->getKey ();
75
+ $ applicationConfig ['global ' ]['demomode ' ] = true ;
76
+ $ applicationConfig ['global ' ]['environment ' ] = 'development ' ;
77
+ $ applicationConfig ['global ' ]['application.name ' ] = 'MIDAS - Demo ' ;
78
+ $ applicationConfig ['global ' ]['application.description ' ] = 'MIDAS integrates multimedia server technology with Kitware?s open-source data analysis and visualization clients. The server follows open standards for data storage, access and harvesting ' ;
79
+ $ applicationConfig ['global ' ]['application.keywords ' ] = 'demonstration, data management, visualization ' ;
80
+
81
81
$ enabledModules = array ('visualize ' , 'oai ' , 'metadataextractor ' , 'api ' , 'scheduler ' , 'thumbnailcreator ' , 'statistics ' );
82
-
82
+
83
83
foreach ($ enabledModules as $ module )
84
84
{
85
85
if (file_exists (BASE_PATH .'/core/configs/ ' .$ module .'.demo.local.ini ' ))
86
86
{
87
87
copy (BASE_PATH .'/core/configs/ ' .$ module .'.demo.local.ini ' , BASE_PATH .'/core/configs/ ' .$ module .'.local.ini ' );
88
- $ applicationConfig ['module ' ][$ module ] = true ;
88
+ $ applicationConfig ['module ' ][$ module ] = true ;
89
89
}
90
90
else
91
91
{
92
92
unlink (BASE_PATH .'/core/configs/ ' .$ module .'.local.ini ' );
93
93
}
94
94
}
95
-
95
+
96
96
require_once BASE_PATH .'/core/controllers/components/UtilityComponent.php ' ;
97
97
$ utilityComponent = new UtilityComponent ();
98
98
$ utilityComponent ->createInitFile (BASE_PATH .'/core/configs/application.local.ini ' , $ applicationConfig );
99
-
99
+
100
100
$ configGlobal = new Zend_Config_Ini (APPLICATION_CONFIG , 'global ' , true );
101
101
Zend_Registry::set ('configGlobal ' , $ configGlobal );
102
-
102
+
103
103
require_once BASE_PATH .'/core/controllers/components/UploadComponent.php ' ;
104
104
$ uploadCompoenent = new UploadComponent ();
105
105
$ item = $ uploadCompoenent ->createUploadedItem ($ admin , 'midasLogo.gif ' , BASE_PATH .'/core/public/images/midasLogo.gif ' , $ communityDao ->getPublicFolder ());
106
106
$ item = $ uploadCompoenent ->createUploadedItem ($ admin , 'cow.vtp ' , BASE_PATH .'/core/public/demo/cow.vtp ' , $ communityDao ->getPublicFolder ());
107
107
}
108
-
108
+
109
109
/** recursively delete a folder*/
110
- private function _rrmdir ($ dir )
111
- {
110
+ private function _rrmdir ($ dir )
111
+ {
112
112
if (!file_exists ($ dir ))
113
113
{
114
114
return ;
115
115
}
116
- if (is_dir ($ dir ))
117
- {
118
- $ objects = scandir ($ dir );
116
+ if (is_dir ($ dir ))
117
+ {
118
+ $ objects = scandir ($ dir );
119
119
}
120
120
121
- foreach ($ objects as $ object )
122
- {
123
- if ($ object != ". " && $ object != ".. " )
124
- {
121
+ foreach ($ objects as $ object )
122
+ {
123
+ if ($ object != ". " && $ object != ".. " )
124
+ {
125
125
if (filetype ($ dir ."/ " .$ object ) == "dir " )
126
126
{
127
127
$ this ->_rrmdir ($ dir ."/ " .$ object );
128
128
}
129
- else
129
+ else
130
130
{
131
- unlink ($ dir ."/ " .$ object );
131
+ unlink ($ dir ."/ " .$ object );
132
132
}
133
- }
134
- }
135
- reset ($ objects );
136
- rmdir ($ dir );
133
+ }
134
+ }
135
+ reset ($ objects );
136
+ rmdir ($ dir );
137
137
}
138
138
} // end class
0 commit comments