diff --git a/index.php b/index.php index 95b287f..d49bda9 100644 --- a/index.php +++ b/index.php @@ -52,7 +52,16 @@ "; }else{ - echo "
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+ |
+
';
diff --git a/restrict/framework/components/new_project.php b/restrict/framework/components/new_project.php
index f74a42e..9620c0a 100755
--- a/restrict/framework/components/new_project.php
+++ b/restrict/framework/components/new_project.php
@@ -10,7 +10,8 @@
echo $_MIND['fw']->decrypt($e);
exit;*/
- //echo "";
+ $_POST['name']= $_MIND['fw']->fixName(strtolower($_POST['name']));
+
if(Project::projectExists($_POST['name']))
{
echo "Mind.Dialog.ShowError(".JSON_encode($_MIND['fw']->errorOutput(4)).")";
@@ -329,4 +330,4 @@
$("#newProjectForm .tabs").tabs();
//setTimeout(function(){document.getElementById('new_project_name').focus();}, 1000);
});
-
\ No newline at end of file
+
diff --git a/restrict/framework/mind-2.0.php b/restrict/framework/mind-2.0.php
index 2c02a31..06409d1 100755
--- a/restrict/framework/mind-2.0.php
+++ b/restrict/framework/mind-2.0.php
@@ -1,5 +1,5 @@
mkXML('my_xml.xml');
+ * $myXML->addChild('my_tag');
+ * @author Felipe Nascimento
+ * @name mkXML
+ * @param String $fileURL
+ * @return SimpleXMLObject $obj
+ */
+ function mkXML($fileURL)
{
- $f = fopen($file,"w+");
+ $f = fopen($fileURL,"w+");
fwrite($f,' ');
fclose($f);
- return simplexml_load_file($file);
+ return simplexml_load_file($fileURL);
}
- function saveXML($c, $file)
+
+ /**
+ * This method saves the current situation of a SimpleXMLObject to a file
+ * as XML. If the file doesn't exist, it will be created
+ * @author Felipe Nascimento
+ * @name saveXML
+ * @param SimpleXMLObject $xml
+ * @param String $fileURL
+ * @return boolean
+ */
+ function saveXML($xml, $fileURL)
{
- $f = fopen($file, "w+");
- fwrite($f, $c->asXML());
- fclose($f);
+ $f = fopen($fileURL, "w+");
+ fwrite($f, $xml->asXML());
+ if(fclose($f))
+ return true;
+ else
+ return false;
}
- function getEncodedPwd($n)
+
+ /**
+ * This method can be used to encode the pwd. If this algorithm should change, we can simply change this method
+ * @author Felipe Nascimento
+ * @name getEncodedPwd
+ * @param String $pwd
+ * @return MD5_String
+ */
+ function getEncodedPwd($pwd)
{
- return md5($n);
+ return md5($pwd);
}
+
+ /**
+ * You can use this method to filter some special chars. Any new future special char can be added here
+ * It also replaces any numbers to "_"
+ * @author Felipe Nascimento
+ * @name getEncoded
+ * @param String $n
+ * @return String
+ */
function getEncoded($n)
{
$n= utf8_decode($n);
- $n= addslashes(strip_tags(preg_replace('/[\!\@\#\$\%\�\&\*\(\)\\_\-\=\+\^\~\,\.\{\[\]\}\?\"\']\;\/\:/', '', $n)));
- $n= preg_replace('/[����]/i', 'a', $n);
- $n= preg_replace('/[����]/i', 'e', $n);
- $n= preg_replace('/[����]/i', 'i', $n);
- $n= preg_replace('/[�����]/i', 'o', $n);
- $n= preg_replace('/[����]/i', 'u', $n);
- $n= preg_replace('/�/i', 'c', $n);
- $n= preg_replace('/�/i', 'n', $n);
- $n= preg_replace('/^[0-9]/', '_', $n);
+ $n= addslashes(strip_tags(preg_replace('/[\!\@\#\$\%\&\*\(\)\\_\-\=\+\^\~\,\.\{\[\]\}\?\"\']\;\/\:/', '', $n)));
+ $n= preg_replace('/[áàâã]/i', 'a', $n);
+ $n= preg_replace('/[éèêẽ]/i', 'e', $n);
+ $n= preg_replace('/[íìîĩï]/i', 'i', $n);
+ $n= preg_replace('/[óòôõö]/i', 'o', $n);
+ $n= preg_replace('/[úùûũü]/i', 'u', $n);
+ $n= preg_replace('/ç/i', 'c', $n);
+ $n= preg_replace('/ñ/i', 'n', $n);
+ //$n= preg_replace('/^[0-9]/', '_', $n);
return $n;
}
+
+ /**
+ * This method is responsable to replace the special tags and prepare all the client interface applying the theme and template
+ * The resulted output is set to $this->output property;
+ * @author Felipe Nascimento
+ * @name mountIde
+ * @return void
+ */
function mountIde()
{
GLOBAL $_MIND;
@@ -111,22 +204,46 @@
$ide= str_replace('{?$_MIND_MENUS}', $menus, $ide);
$this->output.= $ide.'
';
}
+
+ /**
+ * It echoes and returns the prepared output for interface
+ * @author Felipe Nascimento
+ * @name output
+ * @return String
+ */
function output()
{
echo $this->output;
return $this->output;
}
+
+ /**
+ * Ouputs a patternized message of error, to be treated by the javascript framework running on the client side
+ * @author Felipe Nascimento
+ * @name errorOutput
+ * @param Integer $erCod
+ * @return ErrorObject
+ */
function errorOutput($erCod)
{
GLOBAL $_MIND;
include($_MIND['rootDir'].'/'.$_MIND['errorMessagesFile']);
return new Error($erCod);
}
+
+ /**
+ * This method also transmits the error to the client side, but calling a specific method from the js MindFramework
+ * to treat the error
+ * @author Felipe Nascimento
+ * @name ouputPane
+ * @param String/ErrorObject $m
+ * @param boolean $flag -- indicates a fatal message, to end the script
+ * @return numeric Array
+ */
function outputPane($m, $flag= false)
{
GLOBAL $_MIND;
$this->output.= $m.'
';
- //echo "";
if(is_string($m))
echo "Mind.Dialog.ShowMessage('".$m."'); ";
else
@@ -134,6 +251,13 @@
if(!$flag)
exit;
}
+
+ /**
+ * Here, we will load all the extra configuration files indicated into our conf file
+ * @author Felipe Nascimento
+ * @name loadExternal
+ * @return boolean
+ */
function loadExternal()
{
GLOBAL $_MIND;
@@ -141,18 +265,45 @@
while($m= current($_MIND['load']))
{
if(!include($_MIND['load'][key($_MIND['load'])]))
+ {
$this->outputPane("Error when trying to load the config file ".key($_MIND['load'])."");
+ return false;
+ }
next($_MIND['load']);
}
+ return true;
}
+
+ /**
+ * Constructor
+ * @author Felipe Nascimento
+ * @name _construct
+ * @return void
+ */
public function _construct()
{
$this->output= '';
}
+
+ /**
+ * Another different option to apply filters to our received data
+ * This method add slashes the our quots and clears all the tags
+ * @author Felipe Nascimento
+ * @name filter
+ * @param String $str
+ * @return String
+ */
public function filter($str)
{
return addslashes(strip_tags($str));
}
+
+ /**
+ * Gets the list of possible idioms
+ * @author Felipe Nascimento
+ * @name getLanguages
+ * @return Array
+ */
function getLanguages()
{
$c=0;
@@ -171,11 +322,23 @@
return $ar;
}
+ /**
+ * Get the list of avaliable Users
+ * @author Felipe Nascimento
+ * @name getUsers
+ * @return UserObject Collection
+ */
function getUsers()
{
return User::getUsers();
}
+ /**
+ * Lists the registered DBMSs
+ * @author Felipe Nascimento
+ * @name getDBMS
+ * @return Array
+ */
function getDBMSs()
{
$c=0;
@@ -193,6 +356,15 @@
$d->close();
return $ar;
}
+
+ /**
+ * Used to copy whole directories. Special use to update your project related to the teamwork
+ * @author Felipe Nascimento
+ * @name updateCopy
+ * @param String $source
+ * @param String $dest
+ * @return boolean
+ */
function updateCopy($source, $dest)
{
if (is_file($source))
@@ -228,6 +400,16 @@
return true;
}
+ /**
+ * This method will copy the whole directory, recursively
+ * but it is focused to the "generate project" tool
+ * @author Felipe Nascimento
+ * @name copyDir
+ * @param String $source
+ * @param String $dest
+ * @param [String $flag]
+ * @return boolean
+ */
function copyDir($source, $dest, $flag= false)
{
// Simple copy for a file
@@ -269,6 +451,14 @@
return true;
}
+ /**
+ * Removes recusrively a directory
+ * @author thiago
+ * @name deleteDirectory
+ * @param String $dir
+ * @return boolean
+ * [EDITOR NOTE: "Credits to erkethan at free dot fr." - thiago]
+ */
function deleteDirectory($dir)
{
if(!file_exists($dir))
@@ -290,32 +480,73 @@
// [EDITOR NOTE: "Credits to erkethan at free dot fr." - thiago]
}
+ /**
+ * Add here, some rules to filter specific information of the pushed info from client
+ * @author Felipe Nascimento
+ * @name treatClientInfo
+ * @param String $clientInfo
+ * @return String
+ */
function treatClientInfo($clientInfo)
{
- // validate here, the needed verifications on client Info pushed
- //$clientInfo= addslashes($clientInfo);
return $clientInfo;
}
+ /**
+ * A method to decrypt data. For now, it does nothing, but you can add specification here
+ * @author Felipe Nascimento
+ * @name decrypt
+ * @param String $text
+ * @return String
+ */
function decrypt($text)
{
return $text;//base64_decode(convert_uudecode($text));
}
+
+ /**
+ * A method to encrypt data. For now, it does nothing, but you can add specification here
+ * @author Felipe Nascimento
+ * @name encrypt
+ * @param String $text
+ * @return String
+ */
function encrypt($text)
{
return $text;//convert_uuencode(base64_encode($text));
}
+
+ /**
+ * Transletes an Object into an Array
+ * It is basicaly an alias to get_object_vars
+ * @author Felipe Nascimento
+ * @name objectToArray
+ * @param Object $obj
+ * @return Array
+ */
function objectToArray($obj)
{
return get_object_vars($obj);
}
+
+ /**
+ * Parses a SimpleXML object into an Array
+ * @author Felipe Nascimento
+ * @name decrypt
+ * @param String $text
+ * @return String
+ */
function xmlObjectToArray($obj)
{
- $ar= Array();
return get_object_vars($obj);
- return $ar;
}
+ /**
+ * Loads the list of users
+ * @author Felipe Nascimento
+ * @name getUserList
+ * @return Array
+ */
function getUsersList($x='')
{
GLOBAL $_MIND;
@@ -332,6 +563,12 @@
return $users;
}
+ /**
+ * Loads the list of avaliable Modules
+ * @author Felipe Nascimento
+ * @name getModulesList
+ * @return Array
+ */
function getModulesList($x='')
{
GLOBAL $_MIND;
@@ -348,17 +585,52 @@
return $modules;
}
+ /**
+ * Loads a specific module
+ * @author Felipe Nascimento
+ * @name getModule
+ * @param String $mName
+ * @return ModuleObject
+ */
function getModule($mName)
{
$m= new Module($mName);
return $m;
}
- public function fixName($str)
+ /**
+ * an alternative to the default output, to help when deugging
+ * @author Felipe Nascimento
+ * @name printR
+ * @param mixed $var
+ * @return void
+ */
+ function printR($var)
{
- return preg_replace("[^a-zA-Z0-9_]", "", strtr($str, "áàâãéêíóôõüçáàâãéêÍÓÔÕÜÇ- ", "aaaaeeiooouucAAAAEEIOOOUUC__"));
+ echo "";
+ print_r($var);
+ echo "
";
}
+ /**
+ * Fixes names to be used into the database or to name files
+ * @author Felipe Nascimento
+ * @name fixName
+ * @param String $str
+ * @return String
+ */
+ public function fixName($str)
+ {
+ return preg_replace("/[^a-zA-Z0-9_]/", "", strtr(utf8_decode($str), "áàâãéêíóôõüçáàâãéêÍÓÔÕÜÇ- ", "aaaaeeioooucAAAAEEIOOOUC__"));
+ }
+
+ /**
+ * Loads the list of past saved ER Diagrams
+ * @author Felipe Nascimento
+ * @name getSavedERDList
+ * @param String $projectName
+ * @return Array
+ */
function getSavedERDList($p)
{
GLOBAL $_MIND;
@@ -374,12 +646,28 @@
}
return $der;
}
+
+ /**
+ * Loads the data from a specific saved ER Diagram
+ * @author Felipe Nascimento
+ * @name getSavedERDItem
+ * @param String $projectName
+ * @param String $diagramName
+ * @return JSon
+ */
function getSavedERDItem($p, $d)
{
GLOBAL $_MIND;
$d= file_get_contents($_MIND['rootDir'].$_MIND['userDir'].'/'.$_SESSION['user']['login'].'/temp/'.$p.'/mind/er/'.$d.'.json');
return $d;
}
+
+ /**
+ * Loads the list of registered plugins
+ * @author Felipe Nascimento
+ * @name getPlugins
+ * @return Array
+ */
function getPlugins()
{
GLOBAL $_MIND;
@@ -398,6 +686,14 @@
}
return $pList;
}
+
+ /**
+ * Gets the current version of the current project
+ * @author Felipe Nascimento
+ * @name currentVersion
+ * @param &ProjectObject $p
+ * @return Array
+ */
function currentVersion(&$p)
{
GLOBAL $_MIND;
@@ -407,18 +703,22 @@
if($p->hasProject($p->name))
{
$conf= simplexml_load_file($dir);
- $ar= Array();
- $ar['version']= (integer)$conf->version['value'];
- $ar['subVersion']= (integer)$conf->subVersion['value'];
- $ar['update']= (integer)$conf->update['value'];
+ $ar = Array();
+ $ar['version'] = (integer)$conf->version['value'];
+ $ar['subVersion'] = (integer)$conf->subVersion['value'];
+ $ar['update'] = (integer)$conf->update['value'];
}
$ar['date']= $conf->date['value'];
return $ar;
- /* $log= $dir.'/logs';
- if(!file_exists($log))
- mkdir($log); */
-
}
+
+ /**
+ * Save any changes made to the options
+ * @author Felipe Nascimento
+ * @name saveOptions
+ * @param Array $ar
+ * @return void
+ */
public function saveOptions($ar)
{
GLOBAL $_MIND;
@@ -468,6 +768,13 @@
$_MIND['fw']->saveXML($xml, $opXML);
}
+
+ /**
+ * Loads the currently set options
+ * @author Felipe Nascimento
+ * @name loadOptions
+ * @return Assoc Array
+ */
public function loadOptions()
{
GLOBAL $_MIND;
@@ -479,7 +786,6 @@
$opts['actionWithNewVersion'] = (string)$op->actionWithNewVersion['value'];
$opts['actionWithNewSubVersion']= (string)$op->actionWithNewSubVersion['value'];
$opts['actionWithNewUpdates'] = (string)$op->actionWithNewUpdates['value'];
-
$opts['useGlobalSynDic'] = (string)$op->useGlobalSynDic;
$opts['useLocalSynDic'] = (string)$op->useLocalSynDic;
$opts['addAutomatically'] = (string)$op->addAutomatically;
@@ -491,6 +797,13 @@
return $opts;
}
+
+ /**
+ * Lists all the currently registered themes
+ * @author Felipe Nascimento
+ * @name getThemes
+ * @return Array
+ */
public function getThemes()
{
$c=0;
@@ -509,7 +822,18 @@
return $ar;
}
}
- function errorHandle($errno=499, $errstr="Internal Mind Error", $errfile=false, $errline=0)
+
+ /**
+ * Function created to deal with possible errors
+ * @author Felipe Nascimento
+ * @name errorHandler
+ * @param Integer $errno
+ * @param String $errstr
+ * @param String $errfile
+ * @param Integer $errline
+ * @return void
+ */
+ function errorHandler($errno=499, $errstr="Internal Mind Error", $errfile=false, $errline=0)
{
switch($errno)
{
@@ -538,8 +862,10 @@
}
}
+ // instantiates the Framework itself and loas any extra required data
$_MIND['fw']= new Mind();
$_MIND['fw']->loadExternal();
- set_error_handler('errorHandle');
-?>
\ No newline at end of file
+ // specifies who is the error handler for this application
+ set_error_handler('errorHandler');
+?>
diff --git a/restrict/framework/styles/default.css b/restrict/framework/styles/default.css
index 24cae24..b35e25e 100755
--- a/restrict/framework/styles/default.css
+++ b/restrict/framework/styles/default.css
@@ -33,6 +33,11 @@ FORM
margin:0px;
padding:0px;
}
+input[type=text]
+{
+ height:26px;
+ background-color:#fff;
+}
pre
{
margin:0px;
@@ -500,4 +505,4 @@ pre
width:300px;
border:none;
border-bottom:solid 1px #aaa;
-}
\ No newline at end of file
+}