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

Commit

Permalink
ENH: Added module support
Browse files Browse the repository at this point in the history
Added helloword module
Added task module
  • Loading branch information
Charles Marion committed Mar 18, 2011
1 parent 31dbc9c commit 80deed2
Show file tree
Hide file tree
Showing 70 changed files with 1,081 additions and 273 deletions.
38 changes: 13 additions & 25 deletions core/AppController.php
Expand Up @@ -36,9 +36,18 @@ public function preDispatch()
Zend_Translate::setCache($cache);
}
$translate=new Zend_Translate('csv',BASE_PATH.'/translation/fr-main.csv','en');

Zend_Registry::set('translater',$translate);


$translaters=array();
$configs=array();
$modulesEnable= Zend_Registry::get('modulesEnable');
foreach($modulesEnable as $module)
{
$translaters[$module]=new Zend_Translate('csv',BASE_PATH."/modules/$module/translation/fr-main.csv","en");
$configs[$module]= new Zend_Config_Ini(BASE_PATH."/modules/$module/configs/module.ini", 'global');
}
Zend_Registry::set('translatersModules',$translaters);
Zend_Registry::set('configsModules',$configs);
//Init Session
$user=new Zend_Session_Namespace('Auth_User');
if (!isset($user->initialized))
Expand Down Expand Up @@ -123,24 +132,8 @@ public function postDispatch()
/** translation */
protected function t($text)
{
if (Zend_Registry::get('configGlobal')->application->lang=='fr')
{
$translate=Zend_Registry::get('translater');
$new_text=$translate->_($text);
if ($new_text==$text&&Zend_Registry::get('config')->mode->debug==1)
{
$content=@file_get_contents(BASE_PATH."/tmp/report/translation-fr.csv");
if (strpos($content,$text.";")==false)
{
$translationFile=BASE_PATH."/tmp/report/translation-fr.csv";
$fh=fopen($translationFile,'a');
fwrite($fh,"\n$text;");
fclose($fh);
}
}
return $new_text;
}
return $text;
Zend_Loader::loadClass("InternationalizationComponent",BASE_PATH.'/core/controllers/components');
return InternationalizationComponent::translate($text);
} //end method t

/**completion eclipse*/
Expand Down Expand Up @@ -219,11 +212,6 @@ protected function t($text)
* @var ItemRevisionModel
*/
var $ItemRevision;
/**
* Task Model
* @var TaskModel
*/
var $Task;
/**
* User Model
* @var UserModel
Expand Down
20 changes: 2 additions & 18 deletions core/AppForm.php
Expand Up @@ -12,24 +12,8 @@ public function __construct()
/** translation */
protected function t($text)
{
if(Zend_Registry::get('configGlobal')->application->lang=='fr')
{
$translate=Zend_Registry::get('translater');
$new_text=$translate->_($text);
if($new_text==$text&&Zend_Registry::get('config')->mode->debug == 1)
{
$content=@file_get_contents(BASE_PATH."/tmp/report/translation-fr.csv");
if(strpos($content,$text.";")==false)
{
$translationFile = BASE_PATH."/tmp/report/translation-fr.csv";
$fh = fopen($translationFile, 'a');
fwrite($fh, "\n$text;");
fclose($fh);
}
}
return $new_text;
}
return $text;
Zend_Loader::loadClass("InternationalizationComponent",BASE_PATH.'/core/controllers/components');
return InternationalizationComponent::translate($text);
}//en method t
}//end class

Expand Down
29 changes: 17 additions & 12 deletions core/Bootstrap.php
Expand Up @@ -69,6 +69,7 @@ protected function _initConfig()
'username' => $configDatabase->database->params->username,
'password' => $configDatabase->database->params->password,
'dbname' => $configDatabase->database->params->dbname,
'port' =>$configDatabase->database->params->port,
'driver_options' => $pdoParams
);
if($configGlobal->environment=="production")
Expand Down Expand Up @@ -166,20 +167,23 @@ protected function _initRouter()
);
$router->addRoute('webdav', $route1);

//Init Modules

$frontController = Zend_Controller_Front::getInstance();

//Init Modules
$frontController = Zend_Controller_Front::getInstance();
$frontController->addControllerDirectory(BASE_PATH . '/core/controllers');

$modules = new Zend_Config_Ini(APPLICATION_CONFIG, 'module');
// routes modules
$listeModule = array(
array('task')
);

$listeModule = array();
foreach($modules as $key=>$module)
{
if($module==1&& file_exists(BASE_PATH.'/modules/'.$key))
{
$listeModule[]=$key;
}
}
foreach ($listeModule as $m) {
$route = implode('/', $m);
$nameModule = implode('_', $m);
$route = $m;
$nameModule = $m;
$router->addRoute("$nameModule-1",
new Zend_Controller_Router_Route("$route/:controller/:action/*",
array(
Expand All @@ -204,9 +208,10 @@ protected function _initRouter()
)
)
);
$frontController->addControllerDirectory(BASE_PATH . "/modules/$route/constrollers", $nameModule);
$frontController->addControllerDirectory(BASE_PATH . "/modules/$route/controllers", $nameModule);
require_once BASE_PATH . "/modules/$route/AppController.php";
}

Zend_Registry::set('modulesEnable',$listeModule);
return $router;
}
}
Expand Down
3 changes: 3 additions & 0 deletions core/configs/application.ini
Expand Up @@ -26,6 +26,9 @@ default.timezone=America/New_York
;Processing onthefly or cron
processing=onthefly

[module]
task=true

[production]
;Activate error reporting using Zend
mode.debug=0
Expand Down
39 changes: 39 additions & 0 deletions core/configs/application.local.ini
@@ -0,0 +1,39 @@
[global]
environment=development
application.name=MIDAS - Digital Archiving System
application.lang=fr
smartoptimizer=1
session.lifetime=20
alert.email=charles.marion@kitware.com
alert.enable=1
webdav.path=midaswebdav
md5sum.path=
password.prefix=b#ube8#y
defaultassetstore.id=10
default.timezone=America/New_York
processing=cron


[module]
helloworld=true
task=true


[production]
mode.debug=0
mode.test=0
error.php=0


[development]
mode.debug=1
mode.test=0
error.php=1


[testing]
mode.debug=1
mode.test=1
error.php=1


2 changes: 2 additions & 0 deletions core/configs/core.ini
Expand Up @@ -6,8 +6,10 @@ appnamespace = "Midas"
resources.frontController.controllerDirectory = "./core/controllers"
resources.layout.layoutPath ="./core/layouts/"
resources.view.scriptPath = "./core/views/"
resources.frontController.moduleDirectory = "./modules"

[testing]
resources.frontController.controllerDirectory = "./../core/controllers"
resources.frontController.moduleDirectory = "./../modules"
resources.layout.layoutPath ="./../core/layouts/"
resources.view.scriptPath = "./../core/views/";
5 changes: 4 additions & 1 deletion core/configs/database.ini
Expand Up @@ -6,6 +6,7 @@ database.params.host = localhost
database.params.username = root
database.params.password = 123
database.params.dbname = midas3
database.params.port = 3306


[development]
Expand All @@ -16,12 +17,14 @@ database.params.host = localhost
database.params.username = root
database.params.password = 123
database.params.dbname = midas3
database.params.port = 3306

[testing]
database.type=pdo
database.profiler=1
database.adapter = PDO_MYSQL
database.params.host = localhost
database.params.username = root
database.params.password =
database.params.password = 123
database.params.dbname = midas3_test
database.params.port = 3306
33 changes: 33 additions & 0 deletions core/configs/database.local.ini
@@ -0,0 +1,33 @@
[production]
database.type=pdo
database.profiler=0
database.adapter=PDO_MYSQL
database.params.host=localhost
database.params.username=root
database.params.password=
database.params.dbname=midas
database.params.port=3306


[development]
database.type=pdo
database.profiler=1
database.adapter=PDO_MYSQL
database.params.host=localhost
database.params.username=root
database.params.password=
database.params.dbname=midas
database.params.port=3306


[testing]
database.type=pdo
database.profiler=1
database.adapter=PDO_MYSQL
database.params.host=localhost
database.params.username=root
database.params.password=123
database.params.dbname=midas3_test
database.params.port=3306


2 changes: 2 additions & 0 deletions core/controllers/ErrorController.php
Expand Up @@ -34,6 +34,7 @@ public function init()
$this->_error = $error;

$this->_environment = $environment;
$this->view->setScriptPath(BASE_PATH."/core/views");
}

public function errorAction()
Expand Down Expand Up @@ -73,6 +74,7 @@ public function errorAction()
{
$this->getLogger()->crit($this->view->message);
}

}

private function _applicationError()
Expand Down

0 comments on commit 80deed2

Please sign in to comment.