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

Commit 140ba53

Browse files
author
Charles Marion
committed
ENH: improved module management
ENH: Create non proliferation module
1 parent bf1484a commit 140ba53

File tree

32 files changed

+833
-37
lines changed

32 files changed

+833
-37
lines changed

core/AppController.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,6 @@ public function preDispatch()
2222

2323
// Set the version
2424
$this->view->version='3.0 beta';
25-
// Init the translater
26-
if (!$this->isDebug())
27-
{
28-
$frontendOptions=array(
29-
'lifetime'=>86400,'automatic_serialization'=>true
30-
);
31-
32-
$backendOptions=array(
33-
'cache_dir'=>BASE_PATH.'/tmp/cache/translation'
34-
);
35-
$cache=Zend_Cache::factory('Core','File',$frontendOptions,$backendOptions);
36-
Zend_Translate::setCache($cache);
37-
}
38-
$translate=new Zend_Translate('csv',BASE_PATH.'/translation/fr-main.csv','en');
39-
Zend_Registry::set('translater',$translate);
40-
41-
$translaters=array();
42-
$configs=array();
43-
$modulesEnable= Zend_Registry::get('modulesEnable');
44-
foreach($modulesEnable as $module)
45-
{
46-
$translaters[$module]=new Zend_Translate('csv',BASE_PATH."/modules/$module/translation/fr-main.csv","en");
47-
$configs[$module]= new Zend_Config_Ini(BASE_PATH."/modules/$module/configs/module.ini", 'global');
48-
}
49-
Zend_Registry::set('translatersModules',$translaters);
50-
Zend_Registry::set('configsModules',$configs);
5125
//Init Session
5226
$user=new Zend_Session_Namespace('Auth_User');
5327
if (!isset($user->initialized))

core/controllers/ErrorController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ErrorController extends AppController
1111
public function init()
1212
{
1313
parent::init();
14+
1415
$error = $this->_getParam('error_handler');
1516
if(!isset($error)||empty($error))
1617
{

core/controllers/FeedController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FeedController extends AppController
1111

1212
/** Init Controller */
1313
function init()
14-
{
14+
{
1515
$this->view->activemenu = 'feed'; // set the active menu
1616
} // end init()
1717

core/models/pdo/BitstreamModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BitstreamModel extends AppModelPdo
2929
/** do not use, use method addBitstream in ItemRevision Model*/
3030
public function save($dao)
3131
{
32-
$stack=debug_backtrace();
32+
$stack=debug_backtrace(false);
3333
if($stack[1]['class']=="ItemRevisionModel"&&$stack[1]['function']=='addBitstream')
3434
{
3535
return parent::save($dao);

core/views/community/index.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
}
2424
?>
2525
</div>
26+
27+
<?php
28+
if(empty($this->userCommunities))
29+
{
30+
echo "<h4>{$this->t("No communty available")}.<a class='createCommunity' >{$this->t("Create your own community")}!</a> </h4>";
31+
}
32+
?>
2633
</div>
2734
<div class="viewSideBar">
2835
<div class="sideElementFirst viewAction">

core/views/user/settings.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2-
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/user/user.settings.js"></script>';
2+
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/user/user.settings.js?'.time().'"></script>';
33
?>
4-
<link type="text/css" rel="stylesheet" href="<?php echo $this->webroot?>/public/css/user/user.settings.css" />
4+
<link type="text/css" rel="stylesheet" href="<?php echo $this->webroot?>/public/css/user/user.settings.css?<?php echo time(); ?>" />
55

66
<div id="tabsSettings">
77
<ul>

library/MIDAS/controller/GlobalController.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,55 @@ public function __construct(Zend_Controller_Request_Abstract $request, Zend_Cont
2727
*/
2828
public function preDispatch()
2929
{
30+
// Init the translater
31+
if (!$this->isDebug())
32+
{
33+
$frontendOptions=array(
34+
'lifetime'=>86400,'automatic_serialization'=>true
35+
);
36+
37+
$backendOptions=array(
38+
'cache_dir'=>BASE_PATH.'/tmp/cache/translation'
39+
);
40+
$cache=Zend_Cache::factory('Core','File',$frontendOptions,$backendOptions);
41+
Zend_Translate::setCache($cache);
42+
}
43+
$translate=new Zend_Translate('csv',BASE_PATH.'/translation/fr-main.csv','en');
44+
Zend_Registry::set('translater',$translate);
45+
46+
$translaters=array();
47+
$configs=array();
48+
$modulesEnable= Zend_Registry::get('modulesEnable');
49+
foreach($modulesEnable as $module)
50+
{
51+
$translaters[$module]=new Zend_Translate('csv',BASE_PATH."/modules/$module/translation/fr-main.csv","en");
52+
$configs[$module]= new Zend_Config_Ini(BASE_PATH."/modules/$module/configs/module.ini", 'global');
53+
}
54+
Zend_Registry::set('translatersModules',$translaters);
55+
Zend_Registry::set('configsModules',$configs);
56+
57+
$forward=$this->_getParam("forwardModule");
58+
$request = $this->getRequest();
59+
$response = $this->getResponse();
60+
if(!isset($forward))
61+
{
62+
foreach($configs as $key => $config)
63+
{
64+
if($config->system==1)
65+
{
66+
if(file_exists(BASE_PATH.'/modules/'.$key.'/controllers/'. ucfirst($request->getControllerName()).'CoreController.php'))
67+
{
68+
include_once BASE_PATH.'/modules/'.$key.'/controllers/'. ucfirst($request->getControllerName()).'CoreController.php';
69+
$name=ucfirst($key).'_'.ucfirst($request->getControllerName()).'CoreController';
70+
$controller=new $name($request,$response);
71+
if(method_exists($controller, $request->getActionName().'Action'))
72+
{
73+
$this->_forward($request->getActionName(), $request->getControllerName().'Core', $key,array('forwardModule'=>true));
74+
}
75+
}
76+
}
77+
}
78+
}
3079
parent::preDispatch();
3180
if (!$this->isDebug())
3281
{

library/MIDAS/modules/GlobalModule.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@ public function __construct(Zend_Controller_Request_Abstract $request, Zend_Cont
1313
{
1414

1515
parent::__construct($request, $response, $invokeArgs);
16+
if(!isset($this->moduleName))
17+
{
18+
throw new Zend_Exception("Please set the module name in AppController");
19+
}
1620
$this->loadModuleElements();
21+
$fc=Zend_Controller_Front::getInstance();
22+
$this->view->moduleWebroot=$fc->getBaseUrl().'/modules/'.$this->moduleName;
23+
24+
$stack=debug_backtrace();
25+
$forward=$this->_getParam('forwardModule');
26+
if(!isset($forward)&&strpos(get_class($stack[0]['object']),'CoreController')==false)
27+
{
28+
throw new Zend_Exception('You cannot access a core controller directly');
29+
}
1730
}
1831

1932

@@ -80,5 +93,31 @@ public function loadModuleElements()
8093
}
8194
}
8295

96+
public function callCoreAction()
97+
{
98+
$request = $this->getRequest();
99+
$response = $this->getResponse();
100+
$controllerName=ucfirst(str_replace('Core', '', $request->getControllerName()));
101+
if(file_exists(BASE_PATH.'/core/controllers/'. $controllerName.'Controller.php'))
102+
{
103+
include_once BASE_PATH.'/core/controllers/'. $controllerName.'Controller.php';
104+
$name=$controllerName.'Controller';
105+
$controller=new $name($request,$response);
106+
if(method_exists($controller, $request->getActionName().'Action'))
107+
{
108+
$controller->userSession=$this->userSession;
109+
$controller->{$request->getActionName().'Action'}();
110+
return true;
111+
}
112+
else
113+
{
114+
return false;
115+
}
116+
}
117+
else
118+
{
119+
return false;
120+
}
121+
}
83122
} // end class
84123
?>

library/Zend/Controller/Action.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ public function dispatch($action)
504504
if (null === $this->_classMethods) {
505505
$this->_classMethods = get_class_methods($this);
506506
}
507-
508507
// preDispatch() didn't change the action, so we can continue
509508
if ($this->getInvokeArg('useCaseSensitiveActions') || in_array($action, $this->_classMethods)) {
510509
if ($this->getInvokeArg('useCaseSensitiveActions')) {

modules/.htaccess

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
2-
Order Allow,Deny
3-
Deny from all
1+
<FilesMatch "\.(ini|sql|php|phtml|csv)$">
2+
Order allow,deny
3+
Deny from All
4+
</FilesMatch>

0 commit comments

Comments
 (0)