Added friendly message for extra parameter error

Added redirect to setup page when accessing the index before installing it
Esse commit está contido em:
Felipe N. Moura
2012-03-28 18:56:48 -03:00
commit 5057551be7
6 arquivos alterados com 94 adições e 70 exclusões
+1
Ver Arquivo
@@ -64,6 +64,7 @@ class En implements l10n{
$this->messages['runnintPHPUnit'] = "Please wait...running PHPUnit...\n"; $this->messages['runnintPHPUnit'] = "Please wait...running PHPUnit...\n";
$this->messages['mustBeAdmin'] = Mind::message("API: You must be the admin to perform this action", '[Fail]', false); $this->messages['mustBeAdmin'] = Mind::message("API: You must be the admin to perform this action", '[Fail]', false);
$this->messages['cannotInstall'] = Mind::message("API: To install a component, you need to change the 'allow_installation' property into mind.ini file, setting it as true", '[Fail]', false); $this->messages['cannotInstall'] = Mind::message("API: To install a component, you need to change the 'allow_installation' property into mind.ini file, setting it as true", '[Fail]', false);
$this->messages['wrongParam'] = Mind::message("\nMain: The parameter '%s', whose value is '%s', is not valid!", '[Fail]', false);
$this->messages['phpunitNotFound'] = "You must specify where to find phpUnit classes\n". $this->messages['phpunitNotFound'] = "You must specify where to find phpUnit classes\n".
"You can configure it on mind3rd/env/mind.ini ini file\n". "You can configure it on mind3rd/env/mind.ini ini file\n".
"changing the phpunit-src ini property\n";; "changing the phpunit-src ini property\n";;
+1
Ver Arquivo
@@ -72,6 +72,7 @@ class pt implements l10n{
$this->messages['runnintPHPUnit'] = "Aguarde...executando testes unitários...\n"; $this->messages['runnintPHPUnit'] = "Aguarde...executando testes unitários...\n";
$this->messages['mustBeAdmin'] = Mind::message("API: Você precisa ser o administrador para executar esta instrução", '[Fail]', false); $this->messages['mustBeAdmin'] = Mind::message("API: Você precisa ser o administrador para executar esta instrução", '[Fail]', false);
$this->messages['cannotInstall'] = Mind::message("API: Para instalar um componente, será preciso alterar a propriedade 'allow_installation' no arquivo mind.ini para true", '[Fail]', false); $this->messages['cannotInstall'] = Mind::message("API: Para instalar um componente, será preciso alterar a propriedade 'allow_installation' no arquivo mind.ini para true", '[Fail]', false);
$this->messages['wrongParam'] = Mind::message("\nMain: O parâmetro '%s', com valor '%s' é inválido!", '[Fail]', false);
$this->messages['phpunitNotFound'] = "Especifique onde encontram-se as classes do PHPUnit\n". $this->messages['phpunitNotFound'] = "Especifique onde encontram-se as classes do PHPUnit\n".
"Você pode configurar isto em mind3rd/env/mind.ini ini file\n". "Você pode configurar isto em mind3rd/env/mind.ini ini file\n".
"alterando a propriedade phpunit-src\n"; "alterando a propriedade phpunit-src\n";
+7 -1
Ver Arquivo
@@ -160,7 +160,13 @@
echo self::getHelp($programName); echo self::getHelp($programName);
return; return;
} }
$program->$realArgs[$k]= $arg;
if(!key_exists($k, $realArgs)){
\Mind::write('wrongParam', true, $k, $arg);
exit;
}else{
$program->$realArgs[$k]= $arg;
}
} }
if(is_string($program->commandAction)) if(is_string($program->commandAction))
+17 -5
Ver Arquivo
@@ -11,8 +11,20 @@
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com> * @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license * @license licenses/mind3rd.license
*/ */
require(_MINDSRC_.'/mind3rd/API/utils/header.php'); require(_MINDSRC_.'/mind3rd/API/utils/header.php');
if(!Mind::isInstalled()){
if($_REQ['env']=='shell'){
echo "You have to install the application!\nTo install it, please run: sudo php mind install";
}else{
header('location:setup.php');
}
exit;
}
include(_MINDSRC_.'/mind3rd/API/utils/constants.php'); include(_MINDSRC_.'/mind3rd/API/utils/constants.php');
require(_MINDSRC_.'/mind3rd/env/setup/Setup.php');
/** /**
* @global Mind $_MIND This variable contains many information about the proect, the system and also have some methods an attributes to deal with such data * @global Mind $_MIND This variable contains many information about the proect, the system and also have some methods an attributes to deal with such data
@@ -54,9 +66,9 @@
$d->close(); $d->close();
$app->addCommands($programs); $app->addCommands($programs);
\MIND::$programs= $programs; \MIND::$programs= $programs;
// starting the application // starting the application
if($_REQ['env']=='shell') if($_REQ['env']=='shell'){
include('shell.php'); include('shell.php');
else }else{
include('http.php'); include('http.php');
}
+64 -64
Ver Arquivo
@@ -9,77 +9,77 @@
define('_CONSOLE_LINE_LENGTH_', 80); define('_CONSOLE_LINE_LENGTH_', 80);
require(_MINDSRC_.'/mind3rd/API/classes/Mind.php'); require(_MINDSRC_.'/mind3rd/API/classes/Mind.php');
if(!Mind::isInstalled()) if(Mind::isInstalled())
{ {
//include(_MINDSRC_.'/wizard/installation-1.php'); Mind::autoloadRegisterPath(Array(
exit; _MINDSRC_.'/mind3rd/API/external/',
} _MINDSRC_.'/mind3rd/API/interfaces/',
_MINDSRC_.'/mind3rd/API/programs/',
_MINDSRC_.'/mind3rd/API/L10N/',
_MINDSRC_.'/mind3rd/API/classes/',
_MINDSRC_.'/mind3rd/API/cortex/Lexer/',
_MINDSRC_.'/mind3rd/API/cortex/tokenizer/',
_MINDSRC_.'/mind3rd/API/cortex/canonic/',
_MINDSRC_.'/mind3rd/API/cortex/syntaxer/',
_MINDSRC_.'/mind3rd/API/cortex/analyst/',
_MINDSRC_.'/mind3rd/API/languages/',
_MINDSRC_.'/mind3rd/API/DBMS/',
_MINDSRC_.'/mind3rd/API/Lobe/',
_MINDSRC_.'/mind3rd/API/'
));
Mind::autoloadRegisterPath(Array( function __autoload($what)
_MINDSRC_.'/mind3rd/API/external/',
_MINDSRC_.'/mind3rd/API/interfaces/',
_MINDSRC_.'/mind3rd/API/programs/',
_MINDSRC_.'/mind3rd/API/L10N/',
_MINDSRC_.'/mind3rd/API/classes/',
_MINDSRC_.'/mind3rd/API/cortex/Lexer/',
_MINDSRC_.'/mind3rd/API/cortex/tokenizer/',
_MINDSRC_.'/mind3rd/API/cortex/canonic/',
_MINDSRC_.'/mind3rd/API/cortex/syntaxer/',
_MINDSRC_.'/mind3rd/API/cortex/analyst/',
_MINDSRC_.'/mind3rd/API/languages/',
_MINDSRC_.'/mind3rd/API/DBMS/',
_MINDSRC_.'/mind3rd/API/Lobe/',
_MINDSRC_.'/mind3rd/API/'
));
function __autoload($what)
{
GLOBAL $_MIND;
$what= preg_replace("/[ '\"\.\/]/", '', $what);
$what= str_replace('\\', '/', $what);
$what= str_replace('.', '', $what);
if(file_exists(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php'))
{ {
include(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php'); GLOBAL $_MIND;
return true; $what= preg_replace("/[ '\"\.\/]/", '', $what);
} $what= str_replace('\\', '/', $what);
$what= str_replace('.', '', $what);
// checking if the class is not a facad from the API
if(strpos($what, 'API/')!==false)
{
$what= explode('/', $what);
$classFile= array_pop($what);
$what= str_replace('/', '\\', $what);
$file= _MINDSRC_.'/mind3rd/API/facade/'.$classFile.".php";
if(file_exists($file))
{
include($file);
return true;
}
}
// checking if the class is inside any of the autoload paths
$dirs= Mind::$autoloadPaths;
for($i=0; $i<sizeof($dirs); $i++) if(file_exists(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php'))
{
if(file_exists($dirs[$i].$what.'.php'))
{ {
require_once($dirs[$i].$what.'.php'); include(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php');
return true; return true;
} }
}
// let's check if it is a language // checking if the class is not a facad from the API
$langPath= _MINDSRC_.'/mind3rd/API/languages/'.$_MIND->defaults['default_human_languageName'].'/'.$what.'.php'; if(strpos($what, 'API/')!==false)
if(file_exists($langPath)) {
{ $what= explode('/', $what);
require_once($langPath); $classFile= array_pop($what);
return true; $what= str_replace('/', '\\', $what);
} $file= _MINDSRC_.'/mind3rd/API/facade/'.$classFile.".php";
if(file_exists($file))
{
include($file);
return true;
}
}
// ok, if it's reached here...it didn't go well! // checking if the class is inside any of the autoload paths
echo " [ERROR] Class not found: ".$what."\n"; $dirs= Mind::$autoloadPaths;
return false;
for($i=0; $i<sizeof($dirs); $i++)
{
if(file_exists($dirs[$i].$what.'.php'))
{
require_once($dirs[$i].$what.'.php');
return true;
}
}
// let's check if it is a language
$langPath= _MINDSRC_.'/mind3rd/API/languages/'.
$_MIND->defaults['default_human_languageName'].'/'.
$what.'.php';
if(file_exists($langPath))
{
require_once($langPath);
return true;
}
// ok, if it's reached here...it didn't go well!
echo " [ERROR] Class not found: ".$what."\n";
return false;
}
} }
+4
Ver Arquivo
@@ -135,6 +135,10 @@ abstract class Setup {
return self::$installationOk= $phpVsOk && $sqliteOk && $projectsDir && $sqliteDir && $apiDir; return self::$installationOk= $phpVsOk && $sqliteOk && $projectsDir && $sqliteDir && $apiDir;
} }
public static function isInstalled(){
return file_exists('mind3rd/SQLite/mind');
}
/** /**
* Creates the SQLite DataBase. * Creates the SQLite DataBase.
* *