evoluções na ferramenta para gerar a partir do módulo

- barra de loading funcional
- criação de diretorios e arquivos apontados pela estrutura do módulo selecionado
Esse commit está contido em:
felipenmoura
2009-09-14 01:55:16 +00:00
commit 5e93141b28
16 arquivos alterados com 13628 adições e 110 exclusões
+7 -2
Ver Arquivo
@@ -11,6 +11,11 @@ celular tem um funcionario
o correto seria transformar celular em um atributo em cada tabela
*****************/
/*****************
TODA tabela DEVE estar ligada a alguma outra tabela, caso contrario, ela não existira
No linux, verificar permissoes no diretorio de usuarios, no diretorio projects, dbms, languages, modules e plugins, dando permissão ao php para criar, alterar e excluir arquivos.
No linux, verificar permissoes no diretorio de usuarios, no diretorio projects, dbms, languages, modules e plugins, dando permissão ao php para criar, alterar e excluir arquivos.
*****************/
/*****************
Número limite de tabelas suportado pelo gerador, para processar a movimentação da barra, é de 9 mil tabelas.
*****************/
+38 -2
Ver Arquivo
@@ -294,5 +294,41 @@ HELP ACTIONS
/********************************************/
armazenar cookie dos tamanhos dos paineis (e se estao abertos ou fechados)
em open_project, preparar a parte de importação (tal qual o menu importar)
Generating
copiar diretorio atual para o de backup
renomear diretorio principal dos arquivos
criar diretorio para os novos arquivos
+incrementa a barra
(Mind -> modulo)
-> solicita estrutura de diretorios
<- retorna estrutura de diretorios (array associativa)
criar estrutura
+incrementa a barra
-> arquivos a copiar
<- retorna matriz de diretorios a copiar e diretorios destino
+incrementa a barra
varrer tabelas
[
-> solicita o crud de cada tabela específica
<- retorna ok, ou solicita criação de arquivos e diretorios
+incrementa a barra
]
+incrementa a barra
-> extra
<- finalizado
+incrementa a barra
deletar diretorio renomeado
/********************************************/
em open_project, preparar a parte de importação (tal qual o menu importar)
+24 -2
Ver Arquivo
@@ -121,13 +121,13 @@
return file_exists($_MIND['rootDir'].$_MIND['moduleDir'].'/'.$m.'/conf.xml');
}
public function loadModule()
public function loadModule($k)
{
GLOBAL $_MIND;
$mDir= $_MIND['rootDir'].$_MIND['moduleDir'].'/';
include($mDir.'module_interface.php');
include($mDir.strtolower($this->name).'/'.$this->name.'.php');
$this->module= new $this->name();
$this->module= new $this->name($k);
}
public function __construct($module= false)
@@ -141,5 +141,27 @@
$this->load($module);
}
}
/***********************/
public function structure($m, $p)
{
GLOBAL $_MIND;
$x= $this->module->structure();
if(!file_exists($_MIND['rootDir'].$p.$x))
mkdir($_MIND['rootDir'].$p.$x, 0777);
$m= $_MIND['rootDir'].$m.$x;
$p= $_MIND['rootDir'].$p.$x;
if(!$_MIND['fw']->copyDir($m, $p, true))
return false;
}
public function neededFiles($d)
{
$m= $this->module->neededFiles();
}
}
?>
+51 -51
Ver Arquivo
@@ -26,6 +26,7 @@
</div>
</body>
<?php
$errMsg= "<span style='color:red;font-weight:bold'>ERROR: </span>An error ocurred while trying to generate the project.";
function showLoadStatus($s, $c= false)
{
@@ -36,11 +37,17 @@
}
?><script><?php
if($c)
$_SESSION['currentPerc']= $c;
else
$_SESSION['currentPerc']+= $_SESSION['perc'];
echo " parent.$('#generatingLoadBar').progressbar('value', ".$_SESSION['currentPerc']."); "
?>document.getElementById('here').innerHTML= "<div><?php echo $s; ?></div>"+document.getElementById('here').innerHTML;parent.document.getElementById('generatingCurrentStatus').innerHTML= "<?php echo $s; ?>";</script><?php
{
if($c<$_SESSION['currentPerc'])
{
$_SESSION['currentPerc']= $c;
echo " parent.\$('#generatingLoadBar').progressbar('value', ".$c."); ";
}
}else{
$_SESSION['currentPerc']+= $_SESSION['perc'];
echo " parent.\$('#generatingLoadBar').progressbar('value', ".$_SESSION['currentPerc']."); ";
}
?>document.getElementById('here').innerHTML+="<div><?php echo $s; ?></div>";parent.document.getElementById('generatingCurrentStatus').innerHTML="<?php echo $s; ?>";window.scrollBy(0,20);</script><?php
$_MIND['fw']->forceFlush();
}
@@ -60,57 +67,50 @@
showLoadStatus("Negotiating with module", 4);
$numberOfSteps+= sizeof($p->knowledge->tables);
}else{
// retornar ERRO aqui
showLoadStatus($errMsg);
exit;
}
$_SESSION['perc']= number_format((96 / sizeof($numberOfSteps)), 2, '.', '');
$_SESSION['perc']= number_format((96 / $numberOfSteps), 2, '.', '');
$m= new Module($_POST['module']);
$m->loadModule();
$m->loadModule($p->knowledge);
// preparing bkps and directories structure
showLoadStatus("Creating a backup");
$pDir= $_MIND['rootDir'].$_MIND['userDir'].'/'.$_SESSION['user']['login'].'/temp/'.$p->name.'/root/';
$pDirForFW= $_MIND['userDir'].'/'.$_SESSION['user']['login'].'/temp/'.$p->name.'/root/';
$mDir= $_MIND['rootDir'].$_MIND['moduleDir'].'/'.strtolower($m->name).'/data/';
$mDirForFW= $_MIND['moduleDir'].'/'.strtolower($m->name).'/data/';
$tmpDir= $_MIND['rootDir'].$_MIND['userDir'].'/'.$_SESSION['user']['login'].'/temp/'.$p->name.'/tmp_root';
showLoadStatus("Creating directories structure");
if(file_exists($tmpDir))
$_MIND['fw']->deleteDirectory($tmpDir);
rename($pDir, $tmpDir);
chmod($tmpDir, 0777);
mkdir($pDir, 0777);
showLoadStatus("Copying files");
$m->structure($mDirForFW, $pDirForFW);
showLoadStatus("Copies done");
$t= $p->knowledge->tables;
reset($t);
showLoadStatus("Starting CRUD");
while($tb= current($t))
{
showLoadStatus('..'.$tb->name.' files');
next($t);
}
$_MIND['fw']->deleteDirectory($tmpDir);
showLoadStatus("Cleaning the mess...removing temp files");
//$m->;
/*
$_MIND['loadingMessage']= Array('aaaaaaa',
'bbbbbbb',
'ccccccc',
'ddddddd',
'eeeeeee',
'fffffff',
'ggggggg',
'hhhhhhh',
'iiiiiii',
'jjjjjjj',
'kkkkkkk');
sleep(1);
$_SESSION['perc']= 96 / sizeof($_MIND['loadingMessage'])+5;
showLoadStatus($_MIND['loadingMessage'][0]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][1]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][2]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][3]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][4]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][5]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][6]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][7]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][8]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][9]); // passar a mensagem para o load, aqui
sleep(1);
showLoadStatus($_MIND['loadingMessage'][10]); // passar a mensagem para o load, aqui
*/
showLoadStatus("<b>Finished</b>, the project's been generated <a href='address_here.php' target='_quot'>here</a>", 100);
//$_MIND['fw']->deleteDirectory($tmpDir);
}
?>
+37 -11
Ver Arquivo
@@ -28,7 +28,7 @@
* @see Test()
* @return The test results
*/
function deleteDirectory($dir) {
/*function deleteDirectory($dir) {
if (!file_exists($dir)) return true;
if (!is_dir($dir) || is_link($dir)) return unlink($dir);
foreach (scandir($dir) as $item) {
@@ -40,6 +40,7 @@
}
return rmdir($dir);
}
*/
function forceFlush()
{
ob_start();
@@ -210,9 +211,14 @@
$d->close();
return $ar;
}
function copyDir($source, $dest)
function copyDir($source, $dest, $flag= false)
{
// Simple copy for a file
if($flag)
{
$s= '...'.substr($source, -30);
showLoadStatus("Copying ".$s, $_SESSION['currentPerc']);
}
if (is_file($source))
{
$c = copy($source, $dest);
@@ -220,17 +226,15 @@
return $c;
}
// Make destination directory
if (!is_dir($dest))
if(!is_dir($dest))
{
$oldumask = umask(0);
mkdir($dest, 0777);
umask($oldumask);
}else{
return false;
}
$oldumask = umask(0);
mkdir($dest, 0777);
umask($oldumask);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read())
while(false !== $entry = $dir->read())
{
// Skip pointers
if ($entry == "." || $entry == "..")
@@ -240,13 +244,35 @@
// Deep copy directories
if ($dest !== "$source/$entry")
{
$this->copyDir("$source/$entry", "$dest/$entry");
$this->copyDir("$source/$entry", "$dest/$entry", $flag);
}
}
// Clean up
$dir->close();
return true;
}
function deleteDirectory($dir)
{
if(!file_exists($dir))
return true;
if(!is_dir($dir) || is_link($dir))
return unlink($dir);
foreach(scandir($dir) as $item)
{
if ($item == '.' || $item == '..')
continue;
if(!$this->deleteDirectory($dir . "/" . $item))
{
chmod($dir . "/" . $item, 0777);
if(!$this->deleteDirectory($dir . "/" . $item))
return false;
};
}
return rmdir($dir);
// [EDITOR NOTE: "Credits to erkethan at free dot fr." - thiago]
}
function treatClientInfo($clientInfo)
{
// validate here, the needed verifications on client Info pushed
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
<?php
interface module_interface
{
public function structure();
}
?>
-12
Ver Arquivo
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<scripts>
<js src="meu_js.js" />
<js src="meu_js2.js" />
</scripts>
<styles>
<css src="meu_style.js" />
<css src="meu_js2.js" />
</styles>
<config src="page.php" />
</root>
-1
Ver Arquivo
@@ -1 +0,0 @@
sdfxcvvbnhjkyuiyuifdsdfwerewrtdfx
-1
Ver Arquivo
@@ -1 +0,0 @@
asdasdasd
-21
Ver Arquivo
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<name value="Modulo1" />
<fullName value="Meu modulinho 1"/>
<language value="C#" />
<details>
<detail name="Pattern" value="DAO" />
<detail name="Pattern" value="MVC" />
<detail name="Technology" value="Ajax" />
</details>
<version value="1.0" />
<authors>
<author value="João" email='joao@mail.com'/>
<author value="Maria" email='maria@mail.com'/>
</authors>
<description>Descrição do módulo</description>
<date value="15/08/2009" />
<thumb value="print.jpg" />
<license value="license.txt" />
</root>
-6
Ver Arquivo
@@ -1,6 +0,0 @@
<?php
class modulo1
{
}
?>
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff

Antes

Largura:  |  Altura:  |  Tamanho: 849 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 849 KiB

+20
Ver Arquivo
@@ -1,6 +1,26 @@
<?php
class Modulo2 implements module_interface
{
private $knowledge;
private $structure;
public function structure()
{
return $this->structure;
}
public function neededFiles($d)
{
/*$ar= Array();
$ar[]= Array('js/jquery.js', 'restrict/scripts');
$ar[]= Array('js/jquery.ui.all.js', '');
return $this->neededFiles= $ar;*/
}
public function __construct($knowledge)
{
$this->structure= 'structure';
$this->knowledge= $knowledge;
}
}
?>