From d780d738d8c7dfbef6108088b919141a265d3ac9 Mon Sep 17 00:00:00 2001 From: "Felipe N. Moura" Date: Sun, 26 Aug 2012 01:50:41 -0300 Subject: [PATCH] appllying changes to the new IDE --- ide/index.php | 25 ++++++++- index.php | 1 + mind3rd/API/facade/Set.php | 108 ++++++++++++++++++++++++++++++++++++ mind3rd/API/http.php | 16 ++++-- mind3rd/API/utils/utils.php | 4 +- mind3rd/env/defaults.ini | 4 +- 6 files changed, 150 insertions(+), 8 deletions(-) create mode 100644 mind3rd/API/facade/Set.php diff --git a/ide/index.php b/ide/index.php index 663ad39..97d278a 100755 --- a/ide/index.php +++ b/ide/index.php @@ -1,2 +1,25 @@ + + + Mind3rd IDE + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.php b/index.php index be3e2fa..2438609 100755 --- a/index.php +++ b/index.php @@ -22,4 +22,5 @@ default : $_REQ['data']= null; } + include('mind3rd/API/utils/utils.php'); \ No newline at end of file diff --git a/mind3rd/API/facade/Set.php b/mind3rd/API/facade/Set.php new file mode 100644 index 0000000..c68c3d8 --- /dev/null +++ b/mind3rd/API/facade/Set.php @@ -0,0 +1,108 @@ + + * @license licenses/mind3rd.license + */ + namespace API; + /** + * This is a facade to help you getting generic data. + * This class offers you a bunch of "shortcuts" to many different data or results. + * + * @author felipe + */ + class Get{ + + /** + * Gets a list of installed plugins. + * + * @param boolean $echoes If the plugins list should be sent to the output + * @return Array + */ + public static function plugins($echoes=false) + { + return \MindPlugin::listPlugins($echoes); + } + + /** + * Gets an array with all the installed lobes. + * @return Array + */ + public static function lobes() + { + return \Lobe\Neuron::listLobes(); + } + + /** + * Gets all the information about the current project. + * @return string + */ + public static function projectData() + { + $dt= \Mind::$currentProject; + return $dt; + } + + /** + * Returns a list of identified tables for the current project. + * @return Array + */ + public static function tables() + { + return \Analyst::getUniverse(); + } + + /** + * Returns an array with all the DDL codes for the current project. + * @return Array + */ + public static function DDL() + { + $dbDriver= \Mind::$currentProject['database_drive']; + \DQB\QueryFactory::setUp($dbDriver); + return \DQB\QueryFactory::getCompleteQuery(false, true, 'array'); + } + + /** + * + * Returns an array with all the DDL codes for the current project. + * This method returns each DDL comand as a decorated command, containing HTML tags. + * @return Array + */ + public static function DecoratedDDL() + { + $dbDriver= \Mind::$currentProject['database_drive']; + \DQB\QueryFactory::setUp($dbDriver); + return \DQB\QueryFactory::getCompleteQuery(true, false, 'array'); + } + + /** + * Gets the currently opened project or false if none. + * + * @return \MindProject|false + */ + public static function currentProject() + { + return \Mind::$project? \Mind::$project: + false; + } + + /** + * Gets an array with all the source code, for the current project. + * @return Array + */ + public static function source() + { + return \API\Project::source(); + } + + /** + * Gets the list of currently instaled idioms. + * @return Array + */ + public static function idioms() + { + return \Mind::getIdiomsList(); + } + } \ No newline at end of file diff --git a/mind3rd/API/http.php b/mind3rd/API/http.php index 5620859..1f3d327 100755 --- a/mind3rd/API/http.php +++ b/mind3rd/API/http.php @@ -20,26 +20,32 @@ } if(!isset($_REQ['data'])) $_REQ['data']= Array(); - + foreach($_POST as $k=>$value) { $_REQ['data'][$k]= preg_replace("/['\"\\\.\/]/", '', $value); } - if(isset($_SESSION['currentProject'])) + if(isset($_SESSION['currentProject']) && $_SESSION['currentProject']) { $p= Array(); $p['pk_project']= $_SESSION['currentProject']; $p['name']= $_SESSION['currentProjectName']; Mind::openProject($p); } - + if(isset($app)) { if(!isset($_REQ['data']) || !isset($_REQ['data']['program'])) { - Mind::write('programRequired'); - return false; + if($_MIND->defaults['use_default_ide'] != false){ + header('Location: '.$_MIND->defaults['use_default_ide']); + exit; + }else{ + Mind::write('programRequired'); + return false; + } + } $program= $app->findCommand($_REQ['data']['program']); $program= $program->getFileName(); diff --git a/mind3rd/API/utils/utils.php b/mind3rd/API/utils/utils.php index c4cdc5e..272ed8e 100755 --- a/mind3rd/API/utils/utils.php +++ b/mind3rd/API/utils/utils.php @@ -46,11 +46,12 @@ } $d->close(); } + // building the application define('SYSTEM_NAME', 'mind'); $app= new Symfony\Component\Console\Application(SYSTEM_NAME); - + // defining the programs/commands to be used $programs= Array(); $d = dir(_MINDSRC_.'/mind3rd/API/programs'); @@ -66,6 +67,7 @@ $d->close(); $app->addCommands($programs); \MIND::$programs= $programs; + // starting the application if($_REQ['env']=='shell'){ include(_MINDSRC_.'/mind3rd/API/shell.php'); diff --git a/mind3rd/env/defaults.ini b/mind3rd/env/defaults.ini index cef6a49..4ef55d5 100755 --- a/mind3rd/env/defaults.ini +++ b/mind3rd/env/defaults.ini @@ -43,4 +43,6 @@ fk_prefix="fk_" counter_col="counter" ; Varchar and Char properties should have mandatorily a size, if none is passed, ; the following value will be used as size -default_character_length=255 \ No newline at end of file +default_character_length=255 +; should it open an IDE when HTTP requests come with no program param? +use_default_ide=ide/ \ No newline at end of file