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

Esse commit está contido em:
Felipe Nascimento de Moura
2011-06-01 21:00:07 -03:00
15 arquivos alterados com 244 adições e 10 exclusões
+1
Ver Arquivo
@@ -58,6 +58,7 @@ class En implements l10n{
$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['cannotInstall'] = Mind::message("API: To install a component, you need to change the 'allow_installation' property into mind.ini file, setting it as true", '[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
@@ -66,6 +66,7 @@ class pt implements l10n{
$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['cannotInstall'] = Mind::message("API: Para instalar um componente, será preciso alterar a propriedade 'allow_installation' no arquivo mind.ini para true", '[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";
+12 -2
Ver Arquivo
@@ -34,6 +34,14 @@
public static $originalContent = "";
public static $curLang = 'en';
public static function &getInstance()
{
GLOBAL $_MIND;
if(!$_MIND)
$_MIND= new Mind();
return $_MIND;
}
/**
* @var Lexer An instance of the Lexer class
*/
@@ -171,13 +179,11 @@
* false, otherwise
* Alias for MindProject::hasProject
*
* @global Mind $_MIND
* @param String $project
* @return boolean
*/
static function hasProject($project)
{
GLOBAL $_MIND;
return MindProject::hasProject($project);
}
@@ -211,6 +217,10 @@
* Constructor
*/
public function Mind(){
if(isset($GLOBALS['_MIND']))
{
return $GLOBALS['_MIND'];
}
$path= _MINDSRC_;
Mind::$projectsDir= $path.PROJECTS_DIR;
Mind::$modelsDir= $path.MODELS_DIR;
+16 -2
Ver Arquivo
@@ -24,6 +24,7 @@ class MindCommand extends Symfony\Component\Console\Command\Command
private $requiredOptions = Array();
private $optionalOptions = Array();
private $commandFlags = Array();
private $adminOnly = false;
public $answers = Array();
public $commandAction = null;
public $commandAvailableOptions = Array();
@@ -301,6 +302,12 @@ class MindCommand extends Symfony\Component\Console\Command\Command
return $this;
}
public function setAdminAccess()
{
$this->adminOnly= true;
return $this;
}
/**
* Sets the command's description.
* @param string $description
@@ -388,12 +395,19 @@ class MindCommand extends Symfony\Component\Console\Command\Command
public function verifyCredentials()
{
if($this->restrict)
if(!isset($_SESSION['auth']))
if(!MindUser::isIn())
{
Mind::write('not_allowed');
Mind::write('not_allowed_tip');
return false;
}
if($this->adminOnly && !MindUser::isAdmin())
{
Mind::write('mustBeAdmin');
return false;
}
return true;
}
@@ -529,7 +543,7 @@ class MindCommand extends Symfony\Component\Console\Command\Command
}
}
// yea, I know it looks a bit crazy!
// yeah, I know it looks a bit crazy!
if(is_string($this->commandAction))
$this->{$this->commandAction}();
else
+23
Ver Arquivo
@@ -47,6 +47,24 @@ class MindUser
echo "\n";
}
/**
* Verifies if there is a user autenticated.
* @return boolean
*/
public static function isIn()
{
return isset($_SESSION['pk_user']);
}
/**
* Retrieves if the currently logged user is an administrator.
* @return boolean
*/
public static function isAdmin()
{
return isset($_SESSION['pk_user']) && $_SESSION['type'] == 'A';
}
protected static function getDBConn()
{
if(!self::$dbConn)
@@ -54,6 +72,11 @@ class MindUser
return self::$dbConn;
}
/**
* Retrieves the list of users.
* @param boolean $detailed
* @return mixed
*/
public static function listUsers($detailed=false)
{
$db= self::getDBConn();
+31 -2
Ver Arquivo
@@ -9,10 +9,39 @@
/**
*
* @author felipe
* @package scientia
*/
class Darwin {
public static function addDoubt($context, $type)
protected $tips = Array();
protected $decisions = Array();
protected $doubts = Array();
public static function getTips()
{
return self::$tips;
}
public static function getDecisions()
{
return self::$decisions;
}
public static function getDoubts()
{
return self::$doubts;
}
public static function addTip($tipMessage, $context=false)
{
self::$tips[]= new Tip($tipMessage, $context);
}
public static function addDecision($decisionMessage, $context=false)
{
self::$decisions[]= new Decision($decisionMessage, $context);
}
public static function addDoubt($doubtMessage, $context)
{
echo "DUVIDAAAA";
self::$doubts[]= new Doubt($doubtMessage, $context);
}
}
+23
Ver Arquivo
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
namespace scientia;
/**
*
* @author felipe
* @package scientia
*/
class Decision {
public $context = false;
public $doubtMessage= "";
public function __construct($doubtMessage, $context)
{
}
}
+23
Ver Arquivo
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
namespace scientia;
/**
*
* @author felipe
* @package scientia
*/
class Doubt {
public $context = false;
public $doubtMessage= "";
public function __construct($doubtMessage, $context)
{
}
}
+23
Ver Arquivo
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
namespace scientia;
/**
*
* @author felipe
* @package scientia
*/
class Tip {
public $context = false;
public $doubtMessage= "";
public function __construct($doubtMessage, $context)
{
}
}
+1
Ver Arquivo
@@ -38,6 +38,7 @@
$_SESSION['pk_user']= $row['pk_user'];
$_SESSION['status']= $row['status'];
$_SESSION['login']= $row['login'];
$_SESSION['type']= $row['type'];
if(!$row)
{
+77
Ver Arquivo
@@ -0,0 +1,77 @@
<?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 program will be able to install components to the application.
* These components may be a new L10N idiom, a new language to be interpreted, a new program, a new DBMS, a new Plugin or a new Lobe.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
*/
class Install extends MindCommand implements program
{
/*
* The properties you will use as argument MUST be declared, and public
*/
public $firstArgument= '';
protected function installIt()
{
$list= explode("\n",
file_get_contents(_MINDSRC_.
'/mind3rd/env/trusted-sources.list'));
foreach($list as $source)
{
$src= $source.$this->what."/".$this->which_one.".xml";
echo $src."\n";
if(file_exists($src))
{
echo file_get_contents($src);
return true;
}
}
echo "Thing not found!";
return false;
}
public function executableFunction()
{
if(Mind::getInstance()->conf['allow_installation'])
{
return $this->installIt();
}
return Mind::write('cannotInstall');
}
public function __construct()
{
$this->setCommandName('install')
->setDescription("This program will be able to install components to the application.")
//->setFileName('modeloTeste') // use this if your class has NOT the same name as its file
->setRestrict(true)
->setAdminAccess()
->setHelp("This program will be able to install components to the application.\nThese components may be a new L10N idiom, a new language to be interpreted, a new program, a new DBMS, a new Plugin or a new Lobe.")
->setAction('executableFunction');
$this->addRequiredArgument('what',
'what will be installed',
Array('l10n', 'language', 'dbms', 'plugin', 'lobe'));
$this->addRequiredArgument('which_one',
'What is te one of it you choosed, you will install?');
//$this->addOptionalArgument('secondArgument', 'This is the second and optional argument');
//$this->addRequiredOption('user', '-u', 'The user who will be passed for any reason', 'root');
//$this->addOptionalOption('detailed', '-d', 'Should perform its action detailed?', null);
//$this->addFlag('silent', '-s', 'Executes the command quietly');
$this->init();
}
}
+1 -1
Ver Arquivo
@@ -76,4 +76,4 @@
// after all the definition, you MUST initiate your program.
$this->init();
}
}
}
+7 -2
Ver Arquivo
@@ -18,15 +18,20 @@ version=3.0.0.1
; the last date it has been changed
date= Jul 6th, 2010
; here, a list of the authors
; name<e-mail>,
; name<e-mail>,name<e-mail>...
authors= Felipe Nascimento de Moura<felipenmoura@gmail.com>
; some technologies it uses
; PHP
; SQLite
; SQLite3
; RegExp
; INI files
; shell commands
; HTTP Headers/Rest
; Bootstrap
; MVC
; Factories
; PHPUnit
; XML
; readline(php extension)
+3 -1
Ver Arquivo
@@ -21,4 +21,6 @@ relations_length= 4
; should use the entity's name as prefix on merged entities
use_prefix_on_merged_entities= true
; how many points should consider an entity worth of mergin or not
merging_amount_pts=2
merging_amount_pts=2
; should admin users be able to install components to the structure?
allow_installation=true
+2
Ver Arquivo
@@ -0,0 +1,2 @@
http://localhost/theWebMind/extra/
http://extra.thewebmind.org/