Merge branch 'master' of github.com:felipenmoura/theWebMind

Esse commit está contido em:
Felipe Nascimento de Moura
2011-05-07 12:27:15 -03:00
20 arquivos alterados com 287 adições e 141 exclusões
Arquivo normal → Arquivo executável
Ver Arquivo
Arquivo normal → Arquivo executável
Ver Arquivo

Antes

Largura:  |  Altura:  |  Tamanho: 5.9 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 5.9 KiB

Arquivo executável → Arquivo normal
Ver Arquivo
Arquivo normal → Arquivo executável
Ver Arquivo
+1
Ver Arquivo
@@ -57,6 +57,7 @@ class En implements l10n{
$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['mustBeAdmin'] = Mind::message("API: You must be the admin to perform this action", '[Fail]', false);
$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";;
+1
Ver Arquivo
@@ -65,6 +65,7 @@ class pt implements l10n{
$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['mustBeAdmin'] = Mind::message("API: Você precisa ser o administrador para executar esta instrução", '[Fail]', false);
$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";
+10 -6
Ver Arquivo
@@ -1,15 +1,19 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
/**
* This file is part of TheWebMind 3rd generation.
*
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
namespace Lobe;
/**
* Description of Neuron
* A Neuron.
*
* @author felipe
* @package Lobe
*/
abstract class Neuron {
+12 -5
Ver Arquivo
@@ -1,14 +1,21 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
/**
* This file is part of TheWebMind 3rd generation.
*
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
namespace Lobe\db;
/**
* Description of DBGen
* Database Generator.
* Generates/manages the database according to the current project's configuration.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @package Lobe
* @subpackage db
*/
class db extends \Lobe\Neuron implements \neuron{
+12 -5
Ver Arquivo
@@ -1,14 +1,21 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
/**
* This file is part of TheWebMind 3rd generation.
*
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
namespace Lobe\db\resources;
/**
* Description of DBDealer
* DBDealer.
*
* @author felipe
* @package Lobe
* @subpackage db
* @subpackage resources
*/
class DBDealer {
+13 -13
Ver Arquivo
@@ -1,26 +1,26 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
/**
* This file is part of TheWebMind 3rd generation.
*
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
namespace Lobe\sql;
/**
* Description of sql
* SQL file generator.
* Generates the .sql file into docs directory of the project.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @package Lobe
* @subpackage sql
*/
class sql extends \Lobe\Neuron implements \neuron{
public function __construct(Array $data)
{
$projectData= \Mind::$currentProject;
\DQB\QueryFactory::$showHeader= true;
\DQB\QueryFactory::setUp(\Mind::$currentProject['database_drive']);
\DQB\QueryFactory::buildQuery('*');
$qrs= \DQB\QueryFactory::getCompleteQuery(false, true, 'string');
$file= \theos\ProjectFileManager::createFile('docs/create.sql');
return \fwrite($file, $qrs) !== false;
return \API\FileManager::writeToFile('docs/create.sql', \API\Get::DDL());
}
}
Arquivo normal → Arquivo executável
+1
Ver Arquivo
@@ -47,5 +47,6 @@ class testFacade extends \Lobe\Neuron implements \neuron{
echo " openProject(\$projectName);\n";
echo " projectExists(\$projectName);\n";
echo " source();\n";
}
}
+7 -1
Ver Arquivo
@@ -25,7 +25,13 @@ class QueryFactory extends TableSort{
public static function getCompleteQuery($decorated=true, $raw= false, $format='string')
{
$closingQueries= Array();
if(sizeof(self::$queries) == 0)
{
self::buildQuery();
//echo "No queries to show...have you commited your project?\n";
//return false;
}
$closingQueries= Array();
$outpt= ($format=='string')? "": Array();
if(self::$showHeader)
{
Arquivo normal → Arquivo executável
+46 -4
Ver Arquivo
@@ -12,13 +12,55 @@
*/
class MindUser
{
static protected $dbConn = false;
static protected $validAttrs = Array('name', 'email', 'pwd');
static protected $adminValidAttrs = Array('status', 'type');
protected static function hash($pwd)
{
return sha1($pwd);
}
public static function set($attr, $value, $user=false)
{
if(\in_array($attr, self::$adminValidAttrs) || $user)
{
if($_SESSION['pk_user'] != 1)
{
\Mind::write('mustBeAdmin');
return false;
}
}elseif(!\in_array($attr, self::$validAttrs))
return false;
if($attr == 'pwd')
$value= self::hash($value);
$value= (is_string($value))? "'".$value."'": $value;
$db= self::getDBConn();
$user= $user? $user: $_SESSION['pk_user'];
$qr= "UPDATE user set ".$attr."= ".$value.
"WHERE pk_user=".$user;
$db->execute($qr);
if($attr == 'pwd')
echo "\n";
}
protected static function getDBConn()
{
if(!self::$dbConn)
self::$dbConn= new \MindDB();
return self::$dbConn;
}
public static function listUsers($detailed=false)
{
$db= new \MindDB();
$db= self::getDBConn();
if($detailed)
$projs= $db->query('SELECT * from user');
$usrs= $db->query('SELECT * from user');
else
$projs= $db->query('SELECT login from user');
return $projs;
$usrs= $db->query('SELECT login from user');
return $usrs;
}
}
@@ -94,9 +94,9 @@ class ProjectFileManager {
public static function writeToFile($file, $data)
{
$file= self::setInnerURI($file);
if(file_exists($file))
return \file_put_contents ($file, $data);
return false;
if(!file_exists($file))
self::createFile($file);
return \file_put_contents($file, $data);
}
/**
Arquivo normal → Arquivo executável
Ver Arquivo
Arquivo normal → Arquivo executável
+101 -101
Ver Arquivo
@@ -1,108 +1,108 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @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.
* This file is part of TheWebMind 3rd generation.
*
* @param boolean $echoes If the plugins list should be sent to the output
* @return Array
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
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');
}
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.
*
* 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
* @author felipe
*/
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();
}
}
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();
}
}
Arquivo normal → Arquivo executável
Ver Arquivo
Arquivo normal → Arquivo executável
+4 -2
Ver Arquivo
@@ -30,10 +30,12 @@ class User{
{
return \MindProject::projectsList();
}
/*
public static function ()
public static function set($attr, $value, $user=false)
{
\MindUser::set($attr, $value, $user);
}
/*
public static function ()
{
}*/
+76
Ver Arquivo
@@ -0,0 +1,76 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
/**
* This class represents a model for programs
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
*/
class Set extends MindCommand implements program
{
public $whose = '';
public $attribute= '';
public $value = '';
public $extra = '';
private function setUserData()
{
if($this->attribute=='pwd')
$this->value= $this->prompt('pwd', 'The new password, please', true);
if($this->extra && $this->value=='as')
{
}else
\API\User::set($this->attribute, $this->value);
}
private function setProjectData()
{
echo "Project's data\n";
}
public function executableFunction()
{
if($this->whose == 'user')
{
$this->setUserData();
}else{
$this->setProjectData();
}
}
public function __construct()
{
$this->setCommandName('set')
->setDescription("Sets user's or project's data ")
->setRestrict(true)
->setHelp("You can set information about the current user or a project's data.
if you are the admin, you can use the following line:
set user :username: as :status:
or
set user :username: as :type:
Where status may be 'A' or 'I', and type may be 'A' or 'N'")
->setAction('executableFunction');
$this->addRequiredArgument('whose',
'Who will suffer the update',
Array('user', 'project'));
$this->addRequiredArgument('attribute',
'The attribute you will change');
$this->addOptionalArgument('value',
'The value for that attribute(optional only for pwd');
$this->addOptionalArgument('extra',
'An extra data about the defined attribute(the status or type for users or projects)');
$this->init();
}
}
-1
Ver Arquivo
@@ -75,7 +75,6 @@ EOT
$this->query= 'update';
break;
}
$qrs= \MindProject::showSQL(($this->table=='*'), $this->table, $this->query);
echo $qrs;
return $this;