diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/docs/Diagrams/Classes/mind3rd.jpg b/docs/Diagrams/Classes/mind3rd.jpg old mode 100644 new mode 100755 diff --git a/docs/Diagrams/Classes/mind3rd.vpp b/docs/Diagrams/Classes/mind3rd.vpp old mode 100644 new mode 100755 diff --git a/docs/Diagrams/Classes/parts/1.png b/docs/Diagrams/Classes/parts/1.png old mode 100644 new mode 100755 diff --git a/docs/Diagrams/Classes/parts/2.png b/docs/Diagrams/Classes/parts/2.png old mode 100644 new mode 100755 diff --git a/docs/Diagrams/Classes/parts/3.png b/docs/Diagrams/Classes/parts/3.png old mode 100644 new mode 100755 diff --git a/docs/Diagrams/Classes/parts/4.png b/docs/Diagrams/Classes/parts/4.png old mode 100644 new mode 100755 diff --git a/docs/Diagrams/ER/InnerSQLite-Database.jpg b/docs/Diagrams/ER/InnerSQLite-Database.jpg old mode 100644 new mode 100755 diff --git a/docs/Diagrams/UseCase-Activity/Entity Relationship Inner SQLite Database.jpg b/docs/Diagrams/UseCase-Activity/Entity Relationship Inner SQLite Database.jpg old mode 100644 new mode 100755 diff --git a/docs/Diagrams/UseCase-Activity/command-execution.jpg b/docs/Diagrams/UseCase-Activity/command-execution.jpg old mode 100644 new mode 100755 diff --git a/docs/Diagrams/tests/phpUnit-176-tests.png b/docs/Diagrams/tests/phpUnit-176-tests.png old mode 100644 new mode 100755 diff --git a/docs/en/discrete programming language definition.odt b/docs/en/discrete programming language definition.odt old mode 100644 new mode 100755 diff --git a/docs/ide/images/f.png b/docs/ide/images/f.png old mode 100644 new mode 100755 diff --git a/docs/ide/images/loading_animation.gif b/docs/ide/images/loading_animation.gif old mode 100644 new mode 100755 diff --git a/docs/ide/images/o.png b/docs/ide/images/o.png old mode 100644 new mode 100755 diff --git a/docs/ide/images/w.png b/docs/ide/images/w.png old mode 100644 new mode 100755 diff --git a/docs/ide/index.php b/docs/ide/index.php index f69d60c..4c8e905 100755 --- a/docs/ide/index.php +++ b/docs/ide/index.php @@ -80,8 +80,7 @@ type:'POST', url:'../../', data:{ - program:'test', - unit: true + program:'test' }, success: function(ret){ document.getElementById('result').innerHTML= ret @@ -146,7 +145,7 @@ data:{ program:'use', what:'project', - name:'demo_en' + projectName:'demo_en' }, success: function(ret){ $.ajax({ @@ -240,7 +239,7 @@ url:'../../', data:{ program:'generate', - what: 'db' + lobe: 'db' }, success: function(retQ){ document.getElementById('result').innerHTML= retQ; diff --git a/docs/pt/Relatorio parcial - TCC-2.pdf b/docs/pt/Relatorio parcial - TCC-2.pdf old mode 100644 new mode 100755 diff --git a/docs/pt/TODO~ b/docs/pt/TODO~ deleted file mode 100644 index 8a6966d..0000000 --- a/docs/pt/TODO~ +++ /dev/null @@ -1,3 +0,0 @@ -adicionar ao relatório, a definição detalhada da API, seus -métodos e parâmetros(ja tentando facilitar para a criação -da documentação para os usuarios/contribuidores). diff --git a/docs/pt/eap.pod b/docs/pt/eap.pod old mode 100644 new mode 100755 diff --git a/mind3rd/API/DBMS/mysql.php b/mind3rd/API/DBMS/mysql.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/DBMS/pgsql.php b/mind3rd/API/DBMS/pgsql.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/DBMS/sqlite.php b/mind3rd/API/DBMS/sqlite.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/Facade.php b/mind3rd/API/Facade.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/L10N/en.php b/mind3rd/API/L10N/en.php index 8e33230..394e421 100755 --- a/mind3rd/API/L10N/en.php +++ b/mind3rd/API/L10N/en.php @@ -53,6 +53,13 @@ class En implements l10n{ $this->messages['theosDBQrFailAbort'] = Mind::message("Theos: All the queries will be aborted", '[Fail]', false); $this->messages['theosDBQrOk'] = Mind::message("Theos: Database created successfuly", '[Ok]', false); $this->messages['dbDriverNotFound'] = Mind::message("Theos: Database Driver not found", '[Fail]', false); + $this->messages['missingParameter'] = Mind::message("API: Missing argument: %s", '[Fail]', false); + $this->messages['done'] = Mind::message("API: Done\n", '[Ok]', false); + $this->messages['invalidOptionValue'] = Mind::message("API: %s is not a valid option for %s", '[Fail]', false); + $this->messages['runnintPHPUnit'] = "Please wait...running PHPUnit...\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". + "changing the phpunit-src ini property\n";; $this->messages['http_invalid_requisition'] = <<messages['theosDBQrOk'] = Mind::message("Theos: Base de dados gerada com sucesso", '[Ok]', false); $this->messages['theosDBQrOk'] = Mind::message("Theos: Base de dados gerada com sucesso", '[Ok]', false); $this->messages['dbDriverNotFound'] = Mind::message("Theos: Database Driver não encontrado", '[Fail]', false); + $this->messages['missingParameter'] = Mind::message("API: Argumento faltando: %s", '[Fail]', false); + $this->messages['done'] = Mind::message("API: Pronto\n", '[Ok]', false); + $this->messages['invalidOptionValue'] = Mind::message("API: %s não é uma opção válida para %s", '[Fail]', false); + $this->messages['runnintPHPUnit'] = "Aguarde...executando testes unitários...\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". + "alterando a propriedade phpunit-src\n"; $this->messages['http_invalid_requisition'] = <<$qrObject) { - //foreach($qrType as $qr) - //{ - //print_r($qr); - if(!$dealer->createTable($qrObject)) - { - return false; - } - - //} + if(!$dealer->createTable($qrObject)) + { + return false; + } } $this->dbal->commit(); \Mind::write('theosDBQrOk'); diff --git a/mind3rd/API/Lobe/db/resources/DBDealer.php b/mind3rd/API/Lobe/db/resources/DBDealer.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/Lobe/sql/sql.php b/mind3rd/API/Lobe/sql/sql.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/DQB/Query.php b/mind3rd/API/classes/DQB/Query.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/DQB/QueryFactory.php b/mind3rd/API/classes/DQB/QueryFactory.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/DQB/TableSort.php b/mind3rd/API/classes/DQB/TableSort.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/MindCommand.php b/mind3rd/API/classes/MindCommand.php index c93aa26..eda738a 100755 --- a/mind3rd/API/classes/MindCommand.php +++ b/mind3rd/API/classes/MindCommand.php @@ -18,15 +18,16 @@ class MindCommand extends Symfony\Component\Console\Command\Command private $requiredOptions = Array(); private $optionalOptions = Array(); private $commandFlags = Array(); - + public $answers = Array(); + public function init() { - //$this->configure(); parent::__construct(); } public function configure() { + $this->setDefinition(Array()); $this->setName($this->commandName); $definition= Array(); @@ -39,6 +40,78 @@ class MindCommand extends Symfony\Component\Console\Command\Command $this->setDefinition($definition); } + public function prompt($name, $question, $mode=false) + { + GLOBAL $_REQ; + $secret= false; + $options= false; + + if($mode) + { + if(is_array($mode)) + { + $options= $mode; + }else + $secret= true; + } + + $answer= null; + if($_REQ['env'] !='http') + { + do + { + echo $question."\n"; + if($options) + { + echo "("; + $optionLegend= Array(); + foreach($options as $optVal=>$optLabel) + { + $optionLegend[]= $optVal."=".$optLabel; + } + echo trim(implode(" |", $optionLegend)); + echo ")\n"; + } + if(!$secret) + { + $fp = fopen('php://stdin', 'r'); + $answer = trim(fgets($fp, 1024)); + + if($options && + !in_array(strtolower($answer), + array_map('strtolower', array_keys($options)))) + { + Mind::write('invalidOptionValue', true, $answer, $name); + $answer= false; + } + + }else{ + $answer= $this->readPassword('*'); + } + }while(!$answer); + }else{ + if(isset($_POST[$name])) + { + $answer= $_POST[$name]; + + if($options && + !in_array(strtolower($answer), + array_map('strtolower', $options))) + { + Mind::write('invalidOptionValue', true, $answer, $name); + $answer= false; + } + } + if(!$answer) + { + Mind::write('missingParameter', true, $name); + exit; + } + } + $this->answers[$name]= trim($answer); + return $this->answers[$name]; + } + public function addRequiredArgument($argName, $agDescription='') { $this->requiredArguments[]= new InputArgument($argName, @@ -75,9 +148,9 @@ class MindCommand extends Symfony\Component\Console\Command\Command public function addFlag($name, $shortCut=null, $description='') { $this->commandFlags[]= new InputOption($name, - $shortCut, - InputOption::PARAMETER_NONE, - $description); + $shortCut, + InputOption::PARAMETER_NONE, + $description); return $this; } @@ -204,6 +277,10 @@ class MindCommand extends Symfony\Component\Console\Command\Command { $this->$k= $arg; } + foreach($input->getOptions() as $k=>$opt) + { + $this->$k= $opt; + } $this->runAction(); } diff --git a/mind3rd/API/classes/MindDBAL.php b/mind3rd/API/classes/MindDBAL.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/MindException.php b/mind3rd/API/classes/MindException.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/scientia/Darwin.php b/mind3rd/API/classes/scientia/Darwin.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/theos/DBGen.php b/mind3rd/API/classes/theos/DBGen.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/theos/Gosh.php b/mind3rd/API/classes/theos/Gosh.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/classes/theos/ProjectFileManager.php b/mind3rd/API/classes/theos/ProjectFileManager.php old mode 100644 new mode 100755 index f408c0b..b356390 --- a/mind3rd/API/classes/theos/ProjectFileManager.php +++ b/mind3rd/API/classes/theos/ProjectFileManager.php @@ -12,6 +12,11 @@ namespace theos; */ final class ProjectFileManager { + public static function getLobesDir() + { + return _MINDSRC_."/mind3rd/API/Lobe/"; + } + private static function filterURI($uri, $allowSlashes=true) { $uri= \urlencode(\utf8_encode($uri)); diff --git a/mind3rd/API/interfaces/DBMS.php b/mind3rd/API/interfaces/DBMS.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/interfaces/l10n.php b/mind3rd/API/interfaces/l10n.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/interfaces/neuron.php b/mind3rd/API/interfaces/neuron.php old mode 100644 new mode 100755 diff --git a/mind3rd/API/programs/Analyze.php b/mind3rd/API/programs/Analyze.php index d41a229..f776c4b 100755 --- a/mind3rd/API/programs/Analyze.php +++ b/mind3rd/API/programs/Analyze.php @@ -15,48 +15,25 @@ private $nameSpace= false; public $autoCommit= false; - public function configure() + public function __construct() { - $this->setName('analyze') + $this->setCommandName('analyze') ->setDescription('Analyze the the code for your application') ->setRestrict(true) - ->setDefinition(Array( - new InputArgument('namespace', InputArgument::OPTIONAL, 'Analyze an specific namespace'), - new InputOption('commit', false, InputOption::PARAMETER_NONE, "Commit the result after analisys") - )) + ->setAction('action') ->setHelp(<<nameSpace= $input->getArgument('namespace'); - $this->autoCommit= $input->getOption('commit'); - Mind::write('thinking'); - $this->runAction(); + ); + $this->addOptionalArgument('namespace', 'Analyze an specific namespace'); + $this->addFlag('commit', false, "Commit the result after analisys"); + + $this->init(); } - public function HTTPExecute() - { - GLOBAL $_REQ; - if(!parent::HTTPExecute()) - return false; - if(isset($_REQ['data']['namespace'])) - $this->nameSpace= $_REQ['data']['namespace']; - if(isset($_REQ['data']['commit'])) - { - $this->autoCommit= $_REQ['data']['commit']; - } - $this->runAction(); - } - - private function action() + public function action() { if(!isset($_SESSION['currentProject'])) { @@ -64,14 +41,10 @@ EOT Mind::write('currentProjectRequiredTip'); return false; } + Mind::write('thinking'); MindProject::analyze($this->autoCommit? true: false); + //Mind::write('done'); return $this; } - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } diff --git a/mind3rd/API/programs/Auth.php b/mind3rd/API/programs/Auth.php index 9c09377..8917069 100755 --- a/mind3rd/API/programs/Auth.php +++ b/mind3rd/API/programs/Auth.php @@ -12,75 +12,27 @@ */ class Auth extends MindCommand implements program { - public function configure() - { - $this->setName('auth') - ->setDescription('Autenticate a user') - ->setRestrict(false) - ->setDefinition(Array( - new InputArgument('login', InputArgument::REQUIRED, 'Login to access'), - new InputArgument('pwd', InputArgument::OPTIONAL, 'The user password') - )) - ->setHelp(<<getArgument('pwd')) - { - Mind::write('passwordRequired', true); - $pw= Mind::readPassword(true); - } - - $this->login= $input->getArgument('login'); - $this->pwd= $pw; - if($this->runAction()) - Mind::write('autenticated', true, $input->getArgument('login')); - } - - public function HTTPExecute() - { - if(!parent::HTTPExecute()) - return false; - GLOBAL $_REQ; - if(!isset($_REQ['data'])) - { - Mind::write('loginRequired'); - return false; - }elseif(!isset($_REQ['data']['pwd']) || !isset($_REQ['data']['login'])) - { - Mind::write('loginRequired'); - return false; - } - $this->pwd= $_REQ['data']['pwd']; - $this->login= $_REQ['data']['pwd']; - - if($this->runAction()) - Mind::write('autenticated', true, $_REQ['data']['login']); - } - - private function action() + public $login= null; + public $pwd= null; + + public function action() { + if(!$this->pwd) + $this->pwd= $this->prompt('pwd', + Mind::write('passwordRequired', false), + true); + if($db = new SQLite3(_MINDSRC_.'/mind3rd/SQLite/mind')) { $result= $db->query("SELECT * FROM user where login='".$this->login. "' AND pwd='".sha1($this->pwd)."' AND status= 'A'"); $row= $result->fetchArray(); - /*while() - { - $row = $result->current();*/ - $_SESSION['auth']= JSON_encode($row); - $_SESSION['pk_user']= $row['pk_user']; - $_SESSION['status']= $row['status']; - $_SESSION['login']= $row['login']; - /*break; - }*/ + + $_SESSION['auth']= JSON_encode($row); + $_SESSION['pk_user']= $row['pk_user']; + $_SESSION['status']= $row['status']; + $_SESSION['login']= $row['login']; + if(!$row) { Mind::write('auth_fail', true); @@ -89,13 +41,25 @@ EOT }else{ die('Database not found!'); } + Mind::write('autenticated', true, $this->login); return $this; } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } + + public function __construct() + { + + $this->setCommandName('auth') + ->setDescription('Autenticate a user') + ->setRestrict(false) + ->setAction('action') + ->setHelp(<<addRequiredArgument('login', 'Login to access'); + $this->addOptionalArgument('pwd', 'The password may optionaly be passed'); + + $this->init(); + } } diff --git a/mind3rd/API/programs/Clear.php b/mind3rd/API/programs/Clear.php index 546def2..72f78e9 100755 --- a/mind3rd/API/programs/Clear.php +++ b/mind3rd/API/programs/Clear.php @@ -5,34 +5,20 @@ class Clear extends MindCommand implements program { - public function configure() + public function __construct() { - $this->setName('clear') + $this->setCommandName('clear') ->setDescription('Clears the console') - ->setDefinition(array()) + ->setRestrict(false) + ->setAction('action') ->setHelp(<<init(); } - public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + public function action() { system('clear'); } - - public function HTTPExecute() - { - } - - private function action() - { - return $this; - } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } diff --git a/mind3rd/API/programs/Commit.php b/mind3rd/API/programs/Commit.php index 9797859..198ce4f 100755 --- a/mind3rd/API/programs/Commit.php +++ b/mind3rd/API/programs/Commit.php @@ -15,35 +15,20 @@ private $nameSpace= false; public $autoCommit= false; - public function configure() + public function __construct() { - $this->setName('commit') + $this->setCommandName('commit') ->setDescription('Commits the analyzed content to a new version') ->setRestrict(true) + ->setAction('action') ->setHelp(<<runAction(); + $this->init(); } - public function HTTPExecute() - { - GLOBAL $_REQ; - if(!parent::HTTPExecute()) - return false; - $this->runAction(); - } - - private function action() + public function action() { if(!isset($_SESSION['currentProject'])) { @@ -54,11 +39,4 @@ EOT MindProject::analyze(true, false); return $this; } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } diff --git a/mind3rd/API/programs/Create.php b/mind3rd/API/programs/Create.php index b059379..7647fed 100755 --- a/mind3rd/API/programs/Create.php +++ b/mind3rd/API/programs/Create.php @@ -18,81 +18,31 @@ class Create extends MindCommand implements program { public $what= null; - public $argname= false; + public $argName= false; public $info= ""; private $userType= null; - public function configure() + public function __construct() { - $this->setName('create') + $this->setCommandName('create') ->setDescription('Create structures, such as project or user') ->setRestrict(true) - ->setDefinition(Array( - new InputArgument('what', InputArgument::REQUIRED, 'What to create'), - new InputArgument('name', InputArgument::REQUIRED, 'The refered name'), - new InputOption('info', '-i', InputOption::PARAMETER_OPTIONAL, 'Add extra information about the project') - )) + ->setAction('action') ->setHelp(<<addRequiredArgument('what', 'What to create'); + $this->addRequiredArgument('argName', 'The refered name'); + $this->addOptionalOption('into', '-i', 'Add extra information about what is being created'); + + $this->init(); } - public function execute(Console\Input\InputInterface $input, - Console\Output\OutputInterface $output) - { - if(!parent::execute($input, $output)) - return false; - $this->what= $input->getArgument('what'); - $this->argName= $input->getArgument('name'); - - if($this->what == 'user') - { - $this->info= $input->getOption('info'); - echo "login: "; - $this->login= trim(fgets(fopen("php://stdin", "r"))); - echo "pwd: "; - $this->pwd= Mind::readPassword(true); - echo "\n"; - while($this->userType!='N' && $this->userType!='A') - { - echo "Type (use A for admin, or N for normal): "; - $this->userType= strtoupper(trim(fgets(fopen("php://stdin", "r")))); - } - } - $this->runAction(); - } - - public function HTTPExecute() - { - if(!parent::HTTPExecute()) - { - return false; - } - $this->what= $_REQ['data']['what']; - $this->argName= $_REQ['data']['name']; - if(isset($_REQ['data']['info'])) - $this->info= $_REQ['data']['info']; - if($this->what == 'user') - { - if(!isset($_REQ['data']['login']) - || - !isset($_REQ['data']['pwd']) - || - !isset($_REQ['data']['userType'])) - { - return false; - } - $this->login= $_REQ['data']['login']; - $this->pwd= $_REQ['data']['pwd']; - $this->userType= $_REQ['data']['userType']; - } - $this->runAction(); - } - - private function action() + public function action() { GLOBAL $_MIND; switch($this->what) @@ -115,10 +65,6 @@ EOT return false; } - Mind::copyDir(Mind::$modelsDir.'mind/', $this->projectfile); - - chmod($this->projectfile, 0777); - $db= new MindDB(); $qr_newProj= "INSERT into project ( @@ -147,7 +93,6 @@ EOT )"; $db->execute($qr_userProj); - //Mind::$currentProject['']; $iniSource= Mind::$projectsDir.$this->argName.'/mind.ini'; $cP= $_MIND->defaults; @@ -179,6 +124,9 @@ EOT $db->execute($qr_vsProj); $db->execute("COMMIT"); + Mind::copyDir(Mind::$modelsDir.'mind/', $this->projectfile); + chmod($this->projectfile, 0777); + Mind::write('projectCreated', true, $this->argName); $ini= file_get_contents($iniSource); @@ -195,14 +143,19 @@ EOT $this->argName. '/mind.ini', $ini); - + Mind::openProject(Array('pk_project'=>$key, 'name'=>$this->argName)); - - echo "\n"; break; case 'user': $db= new MindDB(); + $this->prompt('name', "What is the new user's name?"); + $this->prompt('pwd', "What will be the password?", true); + $this->prompt('type', + "\nWill this user be an administrator?", + Array('Y'=>'Yes', + 'N'=>'No')); + $qr_newUser= "INSERT into user ( name, @@ -213,11 +166,14 @@ EOT ) values ( + '".$this->answers['name']."', '".addslashes($this->argName)."', - '".$this->login."', - '".sha1($this->pwd)."', + '".sha1($this->answers['pwd'])."', 'A', - '".$this->userType."' + '".(strtoupper( + substr($this->answers['type'], + 0, + 1))=='Y'? 'A': 'N')."' )"; $db->execute($qr_newUser); Mind::write('userCreated', true, $this->argName); @@ -229,11 +185,4 @@ EOT break; } } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } \ No newline at end of file diff --git a/mind3rd/API/programs/Generate.php b/mind3rd/API/programs/Generate.php old mode 100644 new mode 100755 index f6e4879..0841f70 --- a/mind3rd/API/programs/Generate.php +++ b/mind3rd/API/programs/Generate.php @@ -12,58 +12,46 @@ */ class Generate extends MindCommand implements program { - public $what; + public $lobe; public $param; public $detail; public $optional; public $extra; - public function configure() + public function __construct() { - $this->setName('generate') - ->setDescription('Commits the analyzed content to a new version') + $dir= \theos\ProjectFileManager::getLobesDir(); + $d = dir($dir); + $options= Array(); + while (false !== ($entry = $d->read())) { + if(is_dir($dir.$entry) && substr($entry, 0, 1) != '.') + $options[]= " >".$entry."\n"; + } + $d->close(); + + $help= <<setCommandName('generate') + ->setDescription('Generates different outputs') ->setRestrict(true) - ->setHelp(<<setDefinition(Array( - new InputArgument('what', InputArgument::REQUIRED, 'What to create'), - new InputArgument('param', InputArgument::OPTIONAL, 'A param for that command'), - new InputArgument('detail', InputArgument::OPTIONAL, 'A detail for that command'), - new InputArgument('optional', InputArgument::OPTIONAL, 'An optional argument'), - new InputArgument('extra', InputArgument::OPTIONAL, 'Extra data to pass'), - )); - } - - public function execute(Console\Input\InputInterface $input, - Console\Output\OutputInterface $output) - { - if(!parent::execute($input, $output)) - return false; - $this->what= $input->getArgument('what'); - $this->param= $input->getArgument('param'); - $this->detail= $input->getArgument('detail'); - $this->optional= $input->getArgument('optional'); - $this->extra= $input->getArgument('extra'); - Mind::write('thinking'); - $this->runAction(); + ->setAction('action') + ->setHelp($help); + + $this->addRequiredArgument('lobe', 'Lobe to be used'); + $this->addOptionalArgument('param', 'A param for that command'); + $this->addOptionalArgument('detail', 'A detail for that command'); + $this->addOptionalArgument('optional', 'An optional argument'); + $this->addOptionalArgument('extra', 'Extra data to be passed'); + + $this->init(); } - public function HTTPExecute() - { - GLOBAL $_REQ; - if(!parent::HTTPExecute()) - return false; - $this->what = $_REQ['data']['what']; - $this->param = (isset($_REQ['data']['param']))? $_REQ['data']['param']: false; - $this->detail = (isset($_REQ['data']['detail']))? $_REQ['data']['detail']: false; - $this->optional= (isset($_REQ['data']['optional']))? $_REQ['data']['optional']: false; - $this->extra = (isset($_REQ['data']['extra']))? $_REQ['data']['extra']: false; - $this->runAction(); - } - - private function action() + public function action() { if(!isset($_SESSION['currentProject'])) { @@ -71,8 +59,9 @@ EOT Mind::write('currentProjectRequiredTip'); return false; } + Mind::write('thinking'); if($exec= Mind::$gosh->generate(Array( - $this->what, + $this->lobe, $this->param, $this->detail, $this->optional, @@ -81,11 +70,4 @@ EOT return false; return $this; } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } diff --git a/mind3rd/API/programs/Info.php b/mind3rd/API/programs/Info.php index 069ea0d..acb1f20 100755 --- a/mind3rd/API/programs/Info.php +++ b/mind3rd/API/programs/Info.php @@ -10,43 +10,24 @@ */ class Info extends MindCommand implements program { - public function configure() + public function __construct() { $this - ->setName('info') + ->setCommandName('info') ->setDescription('Performs some tests on theWebMind') ->setRestrict(true) - ->setDefinition(array()) + ->setAction('action') ->setHelp(<<runAction(); + $this->init(); } - public function HTTPExecute() - { - $this->runAction(); - } - - private function action() + public function action() { GLOBAL $_MIND; - if(!parent::verifyCredentials()) - return false; print_r($_MIND->about); return $this; } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } \ No newline at end of file diff --git a/mind3rd/API/programs/Quit.php b/mind3rd/API/programs/Quit.php index e1f4b55..15fd435 100755 --- a/mind3rd/API/programs/Quit.php +++ b/mind3rd/API/programs/Quit.php @@ -5,38 +5,24 @@ class Quit extends MindCommand implements program { - public function configure() + public function __construct() { - $this->setName('exit') + $this->setCommandName('exit') ->setDescription('Finishes the application') - ->setDefinition(Array()) + ->setAction('action') + ->setRestrict(false) ->setFileName('Quit') ->setHelp(<<runAction(); - exit; + $this->init(); } - public function HTTPExecute() + public function action() { - $this->runAction(); - } - - private function action() - { - session_destroy(); + @session_destroy(); Mind::write('bye'); - return $this; - } - - public function runAction() - { - $ret= $this->action(); - return $ret; + exit; } } diff --git a/mind3rd/API/programs/RunTest.php b/mind3rd/API/programs/RunTest.php index ed12b90..c7c68ff 100755 --- a/mind3rd/API/programs/RunTest.php +++ b/mind3rd/API/programs/RunTest.php @@ -8,94 +8,48 @@ class RunTest extends MindCommand implements program { - public function configure() + public $unit=false; + + public function __construct() { - $this - ->setName('test') - ->setDescription('Performs some tests on theWebMind') - ->setRestrict(false) - ->setDefinition(Array( - new InputOption('unit', '-u', InputOption::PARAMETER_NONE, 'Execute unit tests, also') - )) - ->setFileName('RunTest') - ->setHelp(<<setCommandName('test') + ->setDescription('Performs some tests on theWebMind') + ->setRestrict(false) + ->setAction('action') + ->setFileName('RunTest') + ->setHelp(<<addFlag('unit', '-u', 'Also execute unit tests'); + + $this->init(); } - private function action() + public function action() { GLOBAL $_MIND; + ob_start(); $this->runStep1(); + ob_flush(); $this->runStep2(); + ob_flush(); $this->runStep3(); - if($this->unitTestsAlso) + ob_flush(); + + if($this->unit) { - if(file_exists(_MINDSRC_."/Tests/bundle.list")) - { - if(!isset($_MIND->conf['phpunit-src'])) - { - // TODO: put it into speaker classes, to use l10n messages - echo " You must specify where to find phpUnit classes\n"; - echo " You can configure it on mind3rd/env/mind.ini ini file\n"; - echo " changing the phpunit-src ini property\n"; - return false; - } - // TODO: it doesn't work yet - /* - $unitTestsFolder= _MINDSRC_."/Tests/"; - $unitTestsList= file_get_contents($unitTestsFolder."bundle.list"); - $unitTestsList= explode("\n", $unitTestsList); - - foreach($unitTestsList as $unitTests) - { - $unitTests= explode(' ', $unitTests); - echo "Applying Unit tests to ".$unitTests[1]."\n"; - //include_once $unitTestsFolder.$unitTests[0]; - echo shell_exec("phpunit ".$unitTestsFolder.$unitTests[0]); - break; - } - */ - }else - { - // TODO: send it to the speaker - echo "[Error] Unit Tests not fount in [root]/Tests\n"; - return false; - } + if(!isset($_MIND->conf['phpunit-src'])) + { + \Mind::write('phpunitNotFound'); + return false; + } + \Mind::write('runnintPHPUnit'); + ob_flush(); + echo shell_exec($_MIND->conf['phpunit-src']." "._MINDSRC_."/Tests/"); } } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } - - public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) - { - if(!parent::execute($input, $output)) - return false; - - $this->unitTestsAlso= $input->getOption('unit')? true: false; - - return $this->runAction(); - } - - public function HTTPExecute() - { - GLOBAL $_REQ; - if(!parent::HTTPExecute()) - return false; - - $this->unitTestsAlso= (isset($_REQ['data']) - && - isset($_REQ['data']['unit']))? - true: false; - - return $this->runAction(); - } private function runStep1() { @@ -122,8 +76,4 @@ EOT $stat= '[OK]'; Mind::message('Read & Write permissions', $stat); } - - public function __construct($name = null) { - parent::__construct($name); - } } diff --git a/mind3rd/API/programs/SetUse.php b/mind3rd/API/programs/SetUse.php index 98a9b36..268ded6 100755 --- a/mind3rd/API/programs/SetUse.php +++ b/mind3rd/API/programs/SetUse.php @@ -12,64 +12,30 @@ */ class SetUse extends MindCommand implements program { - private $argName= false; - private $what= false; + public $projectName= false; - public function configure() + public function __construct() { - $this->setName('use') + $this->setCommandName('use') ->setDescription('Opens the project, or specifies any personal option') ->setRestrict(true) + ->setaction('action') ->setFileName('SetUse') - ->setDefinition(Array( - new InputArgument('what', InputArgument::REQUIRED, 'What to use, from now on'), - new InputArgument('name', InputArgument::REQUIRED, 'specify what you want to use/open') - )) ->setHelp(<<addRequiredArgument('projectName', 'Specify the project name, you want to use/open'); + + $this->init(); } - public function execute(Console\Input\InputInterface $input, - Console\Output\OutputInterface $output) + + public function action() { - if(!parent::execute($input, $output)) - return false; - $this->what= $input->getArgument('what'); - $this->argName= $input->getArgument('name'); - $this->runAction(); - } - - public function HTTPExecute() - { - GLOBAL $_REQ; - if(!parent::HTTPExecute()) - return false; - if(isset($_REQ['data']['what']) && isset($_REQ['data']['name'])) - { - $this->argName= $_REQ['data']['name']; - $this->what= $_REQ['data']['what']; - } - $this->runAction(); - } - - private function action() - { - switch($this->what) - { - case 'project': - if(!$projectData= Mind::hasProject($this->argName)) - return false; - Mind::openProject($projectData); - break; - } + if(!$projectData= Mind::hasProject($this->projectName)) + return false; + Mind::openProject($projectData); return $this; } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } diff --git a/mind3rd/API/programs/Show.php b/mind3rd/API/programs/Show.php index 5e6a140..15b3ec5 100755 --- a/mind3rd/API/programs/Show.php +++ b/mind3rd/API/programs/Show.php @@ -5,56 +5,32 @@ class Show extends MindCommand implements program { - private $whatToShow= null; + public $what= null; + public $detailed= false; + public $extra= ''; - public function configure() + public function __construct() { - $this->setName('show') + $this->setCommandName('show') ->setDescription('Show many different kind of data') - ->setDefinition(array( - new InputArgument('what', InputArgument::REQUIRED, 'What to show'), - new InputOption('detailed', '-d', InputOption::PARAMETER_NONE, 'Show detailed data'), - new InputArgument('extra', InputArgument::OPTIONAL, 'Extra information to be used'), - )) + ->setAction('action') ->setHelp(<<whatToShow= $input->getArgument('what'); - //echo $input->getOption('detailed')."\n"; - $this->detailed= $input->getOption('detailed'); - $this->extra= $input->getArgument('extra'); - $this->runAction(); + + $this->addRequiredArgument('what', 'What to how'); + $this->addOptionalArgument('extra', 'Extra information to be used'); + $this->addFlag('detailed', '-d', 'Show detailed data'); + + $this->init(); } - public function HTTPExecute() - { - if(!parent::HTTPExecute()) - return false; - GLOBAL $_REQ; - $this->whatToShow= $_REQ['data']['what']; - if(isset($_REQ['data']['detailed']) && $_REQ['data']['detailed']) - $this->detailed= 1; - else - $this->detailed= false; - if(isset($_REQ['data']['extra'])) - $this->extra= $_REQ['data']['extra']; - else - $this->extra= false; - $this->runAction(); - } - - private function action() + public function action() { GLOBAL $_REQ; GLOBAL $_MIND; - switch($this->whatToShow) + switch($this->what) { case 'projects': $projs= $this->loadProjectList(); @@ -153,20 +129,12 @@ EOT } break; default: - Mind::write('invalidOption', true, $this->whatToShow); + Mind::write('invalidOption', true, $this->what); return false; break; } return $this; } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } - private function loadProjectList() { $db= new MindDB(); @@ -222,4 +190,4 @@ EOT echo "\n"; } } - } + } \ No newline at end of file diff --git a/mind3rd/API/programs/commandExample.php b/mind3rd/API/programs/commandExample.php deleted file mode 100755 index 1e9a479..0000000 --- a/mind3rd/API/programs/commandExample.php +++ /dev/null @@ -1,53 +0,0 @@ -setName('Mind:commandName') - ->setDescription('CommandDescription') - ->setDefinition(array( - new InputArgument('arg1', InputArgument::REQUIRED, 'ArgDescription.'), - new InputOption( - 'Option', null, InputOption::PARAMETER_REQUIRED, - 'Description of the option', - 'object' - ), - new InputOption('detailed', '-d', InputOption::PARAMETER_NONE, ''), - new InputOption( - 'first-result', null, InputOption::PARAMETER_REQUIRED, - 'The first result in the result set.' - ) - )) - ->setHelp(<<runAction(); - } - - public function HTTPExecute() - { - $this->runAction(); - } - - private function action() - { - return $this; - } - - public function runAction() - { - $ret= $this->action(); - // this is used to run the plugins set to be executed - // AFTER the execution of the current program - parent::runAction(); - return $ret; - } - } diff --git a/mind3rd/API/programs/dqb.php b/mind3rd/API/programs/dqb.php old mode 100644 new mode 100755 index 1eeaaa3..12b24b6 --- a/mind3rd/API/programs/dqb.php +++ b/mind3rd/API/programs/dqb.php @@ -10,54 +10,38 @@ */ class DQB extends MindCommand implements program { - public function configure() + public $query=null; + public $table=null; + + public function __construct() { $this - ->setName('dqb') + ->setCommandName('dqb') ->setDescription('Performs some tests on theWebMind') ->setRestrict(true) - ->setDefinition(array( - new InputArgument('query', - InputArgument::REQUIRED, - 'Options: create, drop, alter, insert, delete, select and update'), - new InputArgument('table', - InputArgument::REQUIRED, - "Which table will have its query built. Use * to see them all."), - )) + ->setAction('action') ->setHelp(<<query= $input->getArgument('query'); - $this->table= $input->getArgument('table'); - $this->runAction(); + + //$this->addRequiredArgument('query', 'Options: create, drop, alter, insert, delete, select and update'); + $this->addRequiredArgument('table', 'Which table will have its query built. Use * to see them all.'); + + $this->init(); } - public function HTTPExecute() - { - GLOBAL $_REQ; - if(!parent::HTTPExecute()) - return false; - if(isset($_REQ['data']['query']) && isset($_REQ['data']['table'])) - { - $this->query= $_REQ['data']['query']; - $this->table= $_REQ['data']['table']; - } - $this->runAction(); - } - - private function action() + public function action() { GLOBAL $_MIND, $_REQ; if(!parent::verifyCredentials()) return false; + // for now, only the create has been developed + // even if the following options are already described there are not + // plans to build them so soon. + $this->query= 'c'; switch($this->query) { case 'create': @@ -90,11 +74,4 @@ EOT echo $qrs; return $this; } - - public function runAction() - { - $ret= $this->action(); - parent::runAction(); - return $ret; - } } \ No newline at end of file diff --git a/mind3rd/API/programs/modeloTeste.php b/mind3rd/API/programs/modeloTeste.php old mode 100644 new mode 100755 index da417ef..b788f8f --- a/mind3rd/API/programs/modeloTeste.php +++ b/mind3rd/API/programs/modeloTeste.php @@ -23,6 +23,13 @@ // in this example, we will simply show a message using one argument echo " This command has just been executed!\n"; echo " With argument: ".$this->firstArgument."\n\n"; + $this->prompt('name', "What's your name?"); + echo "Hello ".$this->answers['name']."\n"; + $this->prompt('pwd', 'Say a magic word!', true); + $this->prompt('genre', "\nwhat is your genre?", + Array('F'=>'Female', + 'M'=>'Male')); + echo "\nOW, ok :)\n\n"; } public function __construct() @@ -45,7 +52,7 @@ ->setDescription("This is a model command, only") ->setRestrict(false) ->setHelp("A longer text, explaining the command") - ->setAction('executableFunction'); + ->setAction('executableFunction'); // in this case, the method MUST be public */ /** diff --git a/setup.php b/setup.php old mode 100644 new mode 100755