2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 // +----------------------------------------------------------------------+
5 // | Akelos Framework - http://www.akelos.org |
6 // +----------------------------------------------------------------------+
7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez |
8 // | Released under the GNU Lesser General Public License, see LICENSE.txt|
9 // +----------------------------------------------------------------------+
12 * @package ActiveSupport
14 * @author Bermi Ferrer <bermi a.t akelos c.om>
15 * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
19 error_reporting(defined('AK_ERROR_REPORTING_ON_SCRIPTS') ? AK_ERROR_REPORTING_ON_SCRIPTS
: 0);
20 require_once(AK_LIB_DIR
.DS
.'Ak.php');
21 require_once(AK_LIB_DIR
.DS
.'AkObject.php');
22 require_once(AK_LIB_DIR
.DS
.'AkInflector.php');
23 defined('AK_SKIP_DB_CONNECTION') && AK_SKIP_DB_CONNECTION ?
($dsn='') : Ak
::db(&$dsn);
27 require_once(AK_LIB_DIR
.DS
.'AkInstaller.php');
28 require_once(AK_LIB_DIR
.DS
.'utils'.DS
.'generators'.DS
.'AkelosGenerator.php');
30 $installer = array_shift($options);
31 $installer_class_name = AkInflector
::camelize(AkInflector
::demodulize($installer)).'Installer';
32 $command = count($options) > 0 ?
array_shift($options) : 'usage';
34 $installer = str_replace('::','/',$installer);
35 $file = AK_APP_DIR
.DS
.'installers'.DS
.rtrim(join('/',array_map(array('AkInflector','underscore'), explode('/',$installer.'/'))),'/').'_installer.php';
38 function ak_print_available_installers($files, $preffix = '')
40 foreach($files as $k => $file){
42 if(preg_match('/(.*)_installer\.php$/', $file, $match)){
43 echo ' * '.$preffix.$match[1]."\n";
46 ak_print_available_installers($file, $k.'::');
52 if($installer_class_name == 'Installer'){
53 $files = Ak
::dir(AK_APP_DIR
.DS
.'installers', array('recurse' => true));
55 echo Ak
::t("\n Could not find installers at %dir \n", array('%dir'=>AK_APP_DIR
.DS
.'installers'));
57 echo Ak
::t("\n You must supply a valid installer name like : \n");
58 echo Ak
::t("\n > ./script/migrate my_installer_name install\n\n");
59 echo Ak
::t(" Available installers are: \n\n");
60 ak_print_available_installers($files);
62 }elseif(!file_exists($file)){
63 echo Ak
::t("\n\n Could not locate the installer file %file\n\n",array('%file'=>$file));
66 if(!class_exists($installer_class_name)){
67 echo Ak
::t("\n\n Could not find load the installer. Class doesn't exists\n\n");
69 $installer = new $installer_class_name();
70 if(!method_exists($installer,$command)){
71 echo Ak
::t("\n\n Could not find the method %method for the installer %installer\n\n",
72 array('%method'=>$command,'%installer'=>$installer_class_name));
74 $installer->$command($options);