Fixed bug when trying to create a poject which name had some special charactere;

Changes to some CSS details;
Changes to the "generating" method, due to treat better when some error happenes;
Methods added to the framework.
Esse commit está contido em:
felipenmoura
2010-05-06 01:59:09 +00:00
commit 3ed3a4c6d8
5 arquivos alterados com 442 adições e 67 exclusões
+51 -6
Ver Arquivo
@@ -52,7 +52,16 @@
</tr>
</table>";
}else{
echo "<table style='width:100%;
echo "<body style='margin:0px;'>
<style type='text/css'>
BODY, TD
{
font-family: Tahoma;
color: #555;
font-size: 12px;
}
</style>
<table style='width:100%;
color:#444;
background-color:#eec;
border-bottom:solid 2px #669;
@@ -89,7 +98,7 @@
</tr>
<tr>
<td colspan='2'>
Due to keep theWebMind up to date, we advise you to set these permissions to all this directory
Due to keep theWebMind up to date, we advise you to set these permission to its whole directory
</td>
</tr>
</table>";
@@ -198,6 +207,7 @@
#mind_login_message
{
color:red;
height:22px;
}
.title
{
@@ -235,7 +245,7 @@
}
.footer
{
margin-top:90px;
margin-top:25px;
*margin-top:110px; /* IE Sucks*/
margin-left:7px;
padding-top:7px;
@@ -268,6 +278,16 @@
{
color:#f00;
}
.extra-links a
{
}
.extra-links img
{
margin-top:10px;
border:none;
width:26px;
height:26px;
}
</style>
</head>
<body scroll='no' onload="" leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0'>
@@ -361,8 +381,34 @@
&nbsp;<br>
</span>
</form>
<span onclick="this.parentNode.innerHTML= c" style='cursor: default;'>
</span>
<table class='extra-links'>
<tr>
<td>
<a href='http://docs.thewebmind.org'
target='_quot'>
<img src='http://www.thewebmind.org/img/ddl.png' title='Documentation' alt='Documentation' />
</a>
</td>
<td>
<a href='http://groups.google.com.br/group/thewebmind'
target='_quot'>
<img src='http://www.thewebmind.org/img/group.png' title='Discussion Group' alt='Discussion Group' />
</a>
</td>
<td>
<a href='http://thewebmind.org/contribute'
target='_quot'>
<img src='http://www.thewebmind.org/img/contribute.png' title='Contribute' alt='Contribute' />
</a>
</td>
<td>
<a href='http://code.google.com/p/webmind/'
target='_quot'>
<img src='http://www.thewebmind.org/img/codes.png' title='Soure (at google code)' alt='Source (at google code)' />
</a>
</td>
</tr>
</table>
</div>
<div style='text-align:left;'>
<div class='footer'>
@@ -407,7 +453,6 @@
</td>
</tr>
</table>
<!--<iframe src="http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=37151c9c105cff94@apps.messenger.live.com&mkt=en-US&useTheme=true&themeName=gray&foreColor=676769&backColor=DBDBDB&linkColor=444444&borderColor=8D8D8D&buttonForeColor=99CC33&buttonBackColor=676769&buttonBorderColor=99CC33&buttonDisabledColor=F1F1F1&headerForeColor=729527&headerBackColor=B2B2B2&menuForeColor=676769&menuBackColor=BBBBBB&chatForeColor=99CC33&chatBackColor=EAEAEA&chatDisabledColor=B2B2B2&chatErrorColor=760502&chatLabelColor=6E6C6C" width="300" height="300" style="border: solid 1px black; width: 300px; height: 300px;" frameborder="0"></iframe>-->
<iframe name="hidden_frame" style="display:none;"></iframe>
<?php
if(isset($info))
+10 -12
Ver Arquivo
@@ -169,21 +169,19 @@
/* generating database, if required */
if($_POST['database_pref'] != 'no')
{
showLoadStatus("Connecting to ".$_POST['database_pref'] ." database .......");
$p->generateQueries();
try
{
if($_POST['database_pref'] == 'only_database'){
$_POST['database_pref'] = $_POST['only_database'];
}
$con= @$p->dbmsObj->connectTo($p->environment[$_POST['database_pref']]);
}catch(Exception $e)
{
showLoadStatus("<b>ERROR: </b>Failed to connect to DataBase ... aborting (files have already been created)");
exit;
if($_POST['database_pref'] == 'only_database'){
$_POST['database_pref'] = $_POST['only_database'];
}
if($con= @$p->dbmsObj->connectTo($p->environment[$_POST['database_pref']]))
{
showLoadStatus("Connecting to ".$_POST['database_pref'] ." database .......");
}else{
showLoadStatus("<b>ERROR: </b>Failed to connect to DataBase ... aborting (files have already been created)<br/><br/>");
exit;
}
$t= $p->knowledge->tables;
reset($t);
echo '<pre>';
+2 -1
Ver Arquivo
@@ -10,7 +10,8 @@
echo $_MIND['fw']->decrypt($e);
exit;*/
//echo "<pre>";
$_POST['name']= $_MIND['fw']->fixName(strtolower($_POST['name']));
if(Project::projectExists($_POST['name']))
{
echo "Mind.Dialog.ShowError(".JSON_encode($_MIND['fw']->errorOutput(4)).")";
+370 -44
Ver Arquivo
@@ -1,5 +1,5 @@
<?php
/*{*/
// here, we'll simply prepare the url to find the root directory wherever we are
$slashes= '';
if(!is_dir('restrict'))
{
@@ -12,16 +12,27 @@
}
}
$_MIND['rootDir']= $slashes;
/*}*/
// this function does nothing. It's called when you want some error to be neutralized
function _MINDNeutralizeError($errno, $errstr, $errfile, $errline)
{
}
{}
/**
* CLass: Mind
* this is the framework itself
* @package framework
* @author Felipe Nascimento
*/
class Mind
{
private $output;
/**
* this method is used to force the utput to the client
* @author Felipe Nascimento
* @name forceFlush
* @return void
*/
function forceFlush()
{
ob_start();
@@ -31,6 +42,14 @@
ob_end_flush();
restore_error_handler();
}
/**
* this mathod will remove directories, even if they are not empty. It works recursively
* @author Felipe Nascimento
* @name removeDir
* @param String $dir
* @return void
*/
function removeDir($dir)
{
$dir .= "/";
@@ -46,6 +65,13 @@
rmdir($dir);
}
/**
* this method is called to build the main client structure, replaceing specific tags applying values to the template
* @author Felipe Nascimento
* @name apply
* @param String $str
* @return String $str
*/
function apply($str)
{
GLOBAL $_MIND;
@@ -59,49 +85,116 @@
}
return $str;
}
/**
* this method does not really include the file, but loads its results.
* instead of running the included file where it was included, it loads only the output of that script
* @author Felipe Nascimento
* @name import
* @param String $url
* @return String $scriptOutput
*/
function import($url)
{
ob_start();
include($url);
$x= ob_get_contents();
$scriptOutput= ob_get_contents();
ob_end_clean();
return $x;
return $scriptOutput;
}
function loadXML($file)
/**
* small alias for simplexml_load_file
* @author Felipe Nascimento
* @name loadXML
* @param String $fileURL
* @return SimpleXMLObject $obj
*/
function loadXML($fileURL)
{
return simplexml_load_file($file);
return simplexml_load_file($fileURL);
}
function mkXML($file)
/**
* with this function you can create a new XML file already with the required patterns applied
* This method returns a SimpleXML Object. If the file doesn't exist, it will be created
* E.g.: $myXML= $_Mind['fw']->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,'<?xml version="1.0" encoding="UTF-8" ?><root></root>');
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.'<br>';
}
/**
* 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.'<br>';
//echo "<script>outputPane['error']= '".$m."'</script>";
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 <b>".key($_MIND['load'])."</b>");
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 <erkethan@free.fr>
* @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 "<pre>";
print_r($var);
echo "</pre>";
}
/**
* 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');
// specifies who is the error handler for this application
set_error_handler('errorHandler');
?>
+5
Ver Arquivo
@@ -33,6 +33,11 @@ FORM
margin:0px;
padding:0px;
}
input[type=text]
{
height:26px;
background-color:#fff;
}
pre
{
margin:0px;