Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 98b3d10

Browse files
author
Charles Marion
committed
Enh: Improved testing framework
1 parent 68e28a3 commit 98b3d10

File tree

264 files changed

+30179
-47307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+30179
-47307
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ cmake_minimum_required( VERSION 2.8 )
88
# Set Midas version information
99
set( Midas_VERSION_MAJOR "3" )
1010
set( Midas_VERSION_MINOR "0" )
11-
include( CMake/kwsysDateStamp.cmake )
11+
include( library/CMake/kwsysDateStamp.cmake )
1212
set( Midas_VERSION_BUILD
1313
${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY} )
1414
set( Midas_VERSION
1515
"${Midas_VERSION_MAJOR}.${Midas_VERSION_MINOR}.${Midas_VERSION_BUILD}" )
1616

1717

18-
set( PHP_UNIT CACHE STRING
19-
"Phpunit executable.")
18+
set( PHP CACHE STRING
19+
"Php executable.")
2020

2121
#-----------------------------------------------------------------------------
2222
# This should be at the top level for warning suppression

core/AppComponent.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ class AppComponent extends MIDAS_GlobalComponent
88
{
99

1010

11-
}
12-
13-
?>
11+
}

core/AppController.php

Lines changed: 134 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -16,164 +16,208 @@ public function preDispatch()
1616
parent::preDispatch();
1717
$this->view->setEncoding('iso-8859-1');
1818

19-
$fc=Zend_Controller_Front::getInstance();
20-
$module=$fc->getRequest()->getModuleName();
21-
if($module=='default')
19+
$fc = Zend_Controller_Front::getInstance();
20+
$module = $fc->getRequest()->getModuleName();
21+
if($module == 'default')
2222
{
23-
$module='core';
23+
$module = 'core';
2424
}
25-
$this->getLogger()->setEventItem('module',$module);
26-
$this->view->webroot=$fc->getBaseUrl();
27-
$this->coreWebroot=$this->view->webroot.'/core';
28-
$this->view->coreWebroot=$this->coreWebroot;
25+
$this->getLogger()->setEventItem('module', $module);
26+
$this->view->webroot = $fc->getBaseUrl();
27+
$this->coreWebroot = $this->view->webroot.'/core';
28+
$this->view->coreWebroot = $this->coreWebroot;
2929

30-
$this->view->title=Zend_Registry::get('configGlobal')->application->name;
30+
$this->view->title = Zend_Registry::get('configGlobal')->application->name;
3131

3232
// Set the version
33-
$this->view->version='3.0.0';
33+
$this->view->version = '3.0.0';
3434
if(isset(Zend_Registry::get('configDatabase')->version))
3535
{
36-
$this->view->version=Zend_Registry::get('configDatabase')->version;
36+
$this->view->version = Zend_Registry::get('configDatabase')->version;
3737
}
38-
38+
3939
require_once BASE_PATH . '/core/models/dao/UserDao.php';
4040
require_once BASE_PATH . '/core/models/dao/ItemDao.php';
4141
//Init Session
42-
if($fc->getRequest()->getActionName()!='login'||$fc->getRequest()->getControllerName()!='user')
42+
if($fc->getRequest()->getActionName() != 'login' || $fc->getRequest()->getControllerName() != 'user')
4343
{
44-
45-
46-
if (isset($_POST['sid']))
44+
if(isset($_POST['sid']))
4745
{
4846
Zend_Session::setId($_POST['sid']);
4947
}
5048
Zend_Session::start();
51-
$user=new Zend_Session_Namespace('Auth_User');
52-
$user->setExpirationSeconds(60*Zend_Registry::get('configGlobal')->session->lifetime);
53-
$this->userSession=$user;
54-
$this->view->recentItems=array();
55-
if ($user->Dao!=null)
49+
$user = new Zend_Session_Namespace('Auth_User');
50+
$user->setExpirationSeconds(60 * Zend_Registry::get('configGlobal')->session->lifetime);
51+
$this->userSession = $user;
52+
$this->view->recentItems = array();
53+
if($user->Dao != null)
5654
{
57-
$this->logged=true;
58-
$this->view->logged=true;
59-
$user->Dao->lastAction=date('c');
60-
$this->view->userDao=$user->Dao;
61-
$cookieData = $this->getRequest()->getCookie('recentItems'.$this->userSession->Dao->user_id);
62-
$this->view->recentItems=array();
55+
if($fc->getRequest()->getControllerName() != 'install' && $fc->getRequest()->getControllerName() != 'error' && $user->Dao->isAdmin() && $this->isUpgradeNeeded())
56+
{
57+
$this->view->needUpgrade = true;
58+
}
59+
else
60+
{
61+
$this->view->needUpgrade = false;
62+
}
63+
$this->logged = true;
64+
$this->view->logged = true;
65+
$user->Dao->lastAction = date('c');
66+
$this->view->userDao = $user->Dao;
67+
$cookieData = $this->getRequest()->getCookie('recentItems'.$this->userSession->Dao->user_id);
68+
$this->view->recentItems = array();
6369
if(isset($cookieData))
6470
{
65-
$this->view->recentItems= unserialize($cookieData);
66-
$check=$this->_getParam('checkRecentItem');
71+
$this->view->recentItems = unserialize($cookieData);
72+
$check = $this->_getParam('checkRecentItem');
6773
// check if recent items exit (every 10 minutes)
68-
if(isset($check)||strtotime($user->Dao->lastAction)<strtotime("-1 minute"))
74+
if(isset($check) || strtotime($user->Dao->lastAction) < strtotime("-1 minute"))
6975
{
7076
$modelLoad = new MIDAS_ModelLoader();
7177
$itemModel = $modelLoad->loadModel('Item');
72-
foreach ($this->view->recentItems as $key => $t)
78+
foreach($this->view->recentItems as $key => $t)
7379
{
7480
if(!is_array($t))
7581
{
7682
unset($this->view->recentItems[$key]);
7783
continue;
7884
}
79-
$item=$itemModel->load($t['item_id']);
80-
if($item==false)
85+
$item = $itemModel->load($t['item_id']);
86+
if($item == false)
8187
{
8288
unset($this->view->recentItems[$key]);
8389
}
8490
}
85-
setcookie('recentItems'.$this->userSession->Dao->getKey(), serialize($this->view->recentItems), time()+60*60*24*30,'/'); //30 days
91+
setcookie('recentItems'.$this->userSession->Dao->getKey(), serialize($this->view->recentItems), time() + 60 * 60 * 24 * 30, '/'); //30 days
8692
}
8793
}
8894
}
8995
else
9096
{
91-
$this->view->logged=false;
92-
$this->logged=false;
97+
$this->view->logged = false;
98+
$this->logged = false;
9399
}
94100
}
95101
else
96102
{
97-
$this->userSession=null;
98-
$this->view->logged=false;
99-
$this->logged=false;
103+
$this->userSession = null;
104+
$this->view->logged = false;
105+
$this->logged = false;
100106
}
101107

102-
$this->view->lang=Zend_Registry::get('configGlobal')->application->lang;
108+
$this->view->lang = Zend_Registry::get('configGlobal')->application->lang;
103109
//create a global javascript json array
104-
$jsonGlobal=array(
105-
"webroot"=>$this->view->webroot,
106-
"coreWebroot"=>$this->view->coreWebroot,
107-
"logged"=>$this->logged,
108-
"needToLog"=>false,
109-
"currentUri"=>$this->getRequest()->REQUEST_URI,
110-
"lang"=>Zend_Registry::get('configGlobal')->application->lang,
111-
"Yes"=>$this->t('Yes'),
112-
"No"=>$this->t('No')
113-
);
110+
$jsonGlobal = array(
111+
"webroot" => $this->view->webroot,
112+
"coreWebroot" => $this->view->coreWebroot,
113+
"logged" => $this->logged,
114+
"needToLog" => false,
115+
"currentUri" => $this->getRequest()->REQUEST_URI,
116+
"lang" => Zend_Registry::get('configGlobal')->application->lang,
117+
"Yes" => $this->t('Yes'),
118+
"No" => $this->t('No'));
114119

115120

116-
$login=array(
117-
"titleUploadLogin"=>$this->t('Please log in'),
118-
"contentUploadLogin"=>$this->t('You need to be logged in to be able to upload files.')
119-
);
121+
$login = array(
122+
"titleUploadLogin" => $this->t('Please log in'),
123+
"contentUploadLogin" => $this->t('You need to be logged in to be able to upload files.'));
120124

121-
$browse=array(
122-
'view'=>$this->t('View'),
123-
'uploadIn'=>$this->t('Upload here'),
124-
'createFolder'=>$this->t('Create a new Folder'),
125-
'preview'=>$this->t('Preview'),
126-
'download'=>$this->t('Download'),
127-
'downloadLastest'=>$this->t('Download lastest revision'),
128-
'manage'=>$this->t('Manage'),
129-
'edit'=>$this->t('Edit'),
130-
'delete'=>$this->t('Delete'),
131-
'removeItem'=>$this->t('Remove Item from Folder'),
132-
'deleteMessage'=>$this->t('Do you really want to delete the folder'),
133-
'removeMessage'=>$this->t('Do you really want to remove the item'),
134-
'share'=>$this->t('Sharing settings'),
135-
'rename'=>$this->t('Rename'),
136-
'move'=>$this->t('Move'),
137-
'copy'=>$this->t('Copy'),
138-
'element'=>$this->t('element'),
125+
$browse = array(
126+
'view' => $this->t('View'),
127+
'uploadIn' => $this->t('Upload here'),
128+
'createFolder' => $this->t('Create a new Folder'),
129+
'preview' => $this->t('Preview'),
130+
'download' => $this->t('Download'),
131+
'downloadLastest' => $this->t('Download lastest revision'),
132+
'manage' => $this->t('Manage'),
133+
'edit' => $this->t('Edit'),
134+
'delete' => $this->t('Delete'),
135+
'removeItem' => $this->t('Remove Item from Folder'),
136+
'deleteMessage' => $this->t('Do you really want to delete the folder'),
137+
'removeMessage' => $this->t('Do you really want to remove the item'),
138+
'share' => $this->t('Sharing settings'),
139+
'rename' => $this->t('Rename'),
140+
'move' => $this->t('Move'),
141+
'copy' => $this->t('Copy'),
142+
'element' => $this->t('element'),
139143
'community' => array(
140-
'invit'=>$this->t('Invite collaborators'),
141-
'advanced'=>$this->t('Advanced properties'),
142-
)
143-
);
144+
'invit' => $this->t('Invite collaborators'),
145+
'advanced' => $this->t('Advanced properties')));
144146

145-
$feed=array(
146-
"deleteFeed"=>$this->t('Do you really want to delete the feed')
147-
);
147+
$feed = array(
148+
"deleteFeed" => $this->t('Do you really want to delete the feed'));
148149

149-
$this->view->json=array(
150-
"global"=>$jsonGlobal,"login"=>$login,'feed'=>$feed,"browse"=>$browse
151-
);
152-
Zend_Loader::loadClass("JsonComponent",BASE_PATH.'/core/controllers/components');
150+
$this->view->json = array(
151+
"global" => $jsonGlobal, "login" => $login, 'feed' => $feed, "browse" => $browse);
152+
Zend_Loader::loadClass("JsonComponent", BASE_PATH.'/core/controllers/components');
153153
} // end preDispatch()
154154

155+
/** get server's url */
156+
function getServerURL()
157+
{
158+
$currentPort = "";
159+
$prefix = "http://";
160+
161+
if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
162+
{
163+
$currentPort = ":".$_SERVER['SERVER_PORT'];
164+
}
165+
if($_SERVER['SERVER_PORT'] == 443 || (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS'])))
166+
{
167+
$prefix = "https://";
168+
}
169+
return $prefix.$_SERVER['SERVER_NAME'].$currentPort;
170+
}
171+
172+
/** check if midas needs to be upgraded */
173+
public function isUpgradeNeeded()
174+
{
175+
require_once BASE_PATH.'/core/controllers/components/UpgradeComponent.php';
176+
$upgradeComponent = new UpgradeComponent();
177+
$db = Zend_Registry::get('dbAdapter');
178+
$dbtype = Zend_Registry::get('configDatabase')->database->adapter;
179+
180+
$upgradeComponent->initUpgrade('core', $db, $dbtype);
181+
if($upgradeComponent->getNewestVersion() != $upgradeComponent->transformVersionToNumeric(Zend_Registry::get('configDatabase')->version))
182+
{
183+
return true;
184+
}
185+
$modules = array();
186+
$modulesConfig = Zend_Registry::get('configsModules');
187+
foreach($modulesConfig as $key => $module)
188+
{
189+
$upgradeComponent->initUpgrade($key, $db, $dbtype);
190+
if($upgradeComponent->getNewestVersion() != 0 && $upgradeComponent->getNewestVersion() != $upgradeComponent->transformVersionToNumeric($module->version))
191+
{
192+
return true;
193+
}
194+
}
195+
return false;
196+
}
155197

198+
/** zend post dispatch*/
156199
public function postDispatch()
157200
{
158201
parent::postDispatch();
159-
$this->view->json=JsonComponent::encode($this->view->json);
160-
$this->view->generatedTimer= round((microtime(true) - START_TIME),3);
161-
if (Zend_Registry::get('config')->mode->test!=1)
202+
$this->view->json = JsonComponent::encode($this->view->json);
203+
$this->view->generatedTimer = round((microtime(true) - START_TIME), 3);
204+
if(Zend_Registry::get('config')->mode->test != 1)
162205
{
163206
header('Content-Type: text/html; charset=ISO-8859-1');
164207
}
165208
}
166209

210+
/** trigger logging (javascript) */
167211
public function haveToBeLogged()
168212
{
169-
$this->view->header=$this->t("You should be logged to access this page");
170-
$this->view->json['global']['needToLog']=true;
213+
$this->view->header = $this->t("You should be logged to access this page");
214+
$this->view->json['global']['needToLog'] = true;
171215
$this->_helper->viewRenderer->setNoRender();
172216
}
173217
/** translation */
174218
protected function t($text)
175219
{
176-
Zend_Loader::loadClass("InternationalizationComponent",BASE_PATH.'/core/controllers/components');
220+
Zend_Loader::loadClass("InternationalizationComponent", BASE_PATH.'/core/controllers/components');
177221
return InternationalizationComponent::translate($text);
178222
} //end method t
179223

@@ -265,7 +309,4 @@ protected function t($text)
265309
var $User;
266310

267311
/**end completion eclipse */
268-
}
269-
270-
//end class
271-
?>
312+
}//end class

core/AppFilters.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ class AppFilters extends MIDAS_GlobalFilter
88
{
99

1010

11-
}
12-
13-
?>
11+
}

core/AppForm.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
<?php
2+
/** Common Form Class*/
23
class AppForm
34
{
45
/** constructor*/
56
public function __construct()
67
{
78
$fc = Zend_Controller_Front::getInstance();
8-
$this->webroot = $fc->getBaseUrl() ;
9+
$this->webroot = $fc->getBaseUrl();
910
}//end construct
1011

1112

1213
/** translation */
1314
protected function t($text)
1415
{
15-
Zend_Loader::loadClass("InternationalizationComponent",BASE_PATH.'/core/controllers/components');
16+
Zend_Loader::loadClass("InternationalizationComponent", BASE_PATH.'/core/controllers/components');
1617
return InternationalizationComponent::translate($text);
1718
}//en method t
1819
}//end class
19-
20-
?>

0 commit comments

Comments
 (0)