Added 'set project.sourceadd' command;

Added support for the 'set conf.param' command;
Added a quantifier to portuguese(varios);
Esse commit está contido em:
Felipe N. Moura
2012-07-02 01:31:37 -03:00
commit 230a4c9cf4
7 arquivos alterados com 80 adições e 24 exclusões
+38
Ver Arquivo
@@ -33,6 +33,7 @@
public static $content = "";
public static $originalContent = "";
public static $curLang = 'en';
public static $availableSetAttrs= Array();
public static function &getInstance()
{
@@ -214,6 +215,39 @@
Mind::$autoloadPaths[]= $p;
}
public static function set($property, $value){
if(!\MindUser::isAdmin()){
\Mind::write('mustBeAdmin');
return false;
}
$iniSource= _MINDSRC_.MIND_CONF;
if(!file_exists($iniSource)){
echo "[Main] Failed retrieving the configuration file!!!\nTry to reinstall mind!\n";
return false;
}
try{
$iniContent= file_get_contents($iniSource);
}catch(Exception $e){
\MindSpeaker::write('permissionDenied', true, $proj);
return false;
}
$attr= trim($property);
if(!\in_array($attr, self::$availableSetAttrs)){
\MindSpeaker::write('invalidCreateParams');
echo "Available list: ".implode(', ', self::$availableSetAttrs)."\n";
return false;
}
$iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=\"". addslashes($value)."\"\n", $iniContent);
try{
file_put_contents($iniSource, $iniContent);
}catch(Excepption $e){
\MindSpeaker::write('permissionDenied', true, $proj);
return false;
}
\Mind::write('done');
return true;
}
/**
* The Constructor
*/
@@ -222,12 +256,14 @@
{
return $GLOBALS['_MIND'];
}*/
$path= _MINDSRC_;
Mind::$projectsDir= $path.PROJECTS_DIR;
Mind::$modelsDir= $path.MODELS_DIR;
$this->about= parse_ini_file($path.ABOUT_INI);
$this->defaults= parse_ini_file($path.DEFAULTS_INI);
$this->conf= parse_ini_file($path.MIND_CONF);
self::$availableSetAttrs= array_keys($this->conf);
require_once($path.L10N_DIR.$this->defaults['default_human_language'].'.php');
Mind::$curLang= $this->defaults['default_human_languageName'];
Mind::$l10n= new $this->defaults['default_human_language']();
@@ -239,5 +275,7 @@
Mind::$gosh= new theos\Gosh();
Mind::$darwin= new scientia\Darwin();
}
}
+11 -4
Ver Arquivo
@@ -24,6 +24,7 @@ class MindProject extends VersionManager{
'database_port',
'database_user',
'database_pwd',
'sourceadd', 'sourceAdd',
'source');
/**
@@ -148,25 +149,31 @@ class MindProject extends VersionManager{
return false;
}
$attr= trim($attr);
$attr= strtolower(trim($attr));
if(!\in_array($attr, self::$availableAttrs)){
\MindSpeaker::write('invalidCreateParams');
echo "Available list: ".implode(', ', self::$availableAttrs)."\n";
return false;
}
if($attr == 'source'){
if($attr == 'source' || $attr == 'sourceadd'){
$srcs= Mind::$currentProject['sources'];
$source= func_get_arg(2);
if(!$source)
$source= 'main';
//echo "\n\n".$srcs.'/'.addslashes($source).'.mnd'."\n\n";
if(file_put_contents($srcs.'/'.addslashes($source).'.mnd', $value))
if(
file_put_contents(
$srcs.'/'.addslashes($source).'.mnd',
(($attr == 'sourceadd')? "\n": '').$value,
($attr == 'sourceadd')? FILE_APPEND: false
)
)
return true;
Mind::write('permissionDenied');
return false;
}else{
$iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=".str_replace('"', '', $value)."\n", $iniContent);
$iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=\"".addslashes($value)."\"\n", $iniContent);
try{
file_put_contents($iniSource, $iniContent);
\MindProject::reload();
@@ -89,7 +89,7 @@ class Application
//new InputOption('--quiet', '-q', InputOption::PARAMETER_NONE, 'Do not output any message.'),
//new InputOption('--verbose', '-v', InputOption::PARAMETER_NONE, 'Increase verbosity of messages.'),
//new InputOption('--version', '-V', InputOption::PARAMETER_NONE, 'Display this program version.'),
new InputOption('--color', '-c', InputOption::PARAMETER_NONE, 'Force ANSI color output.'),
//new InputOption('--color', '-c', InputOption::PARAMETER_NONE, 'Force ANSI color output.'),
//new InputOption('--no-interaction', '-n', InputOption::PARAMETER_NONE, 'Do not ask any interactive question.'),
));
}
+1 -1
Ver Arquivo
@@ -9,6 +9,6 @@
<root>
<none>nada,nenhum,zero,0,nenhuma</none>
<one>um,uma,1,algum,alguma,único,única,unico,unica</one>
<many>uns,alguns,umas,algumas,muito,muita,muitos,vários,muitas,várias,diversos,diversas,n,m,x</many>
<many>uns,alguns,umas,algumas,muito,muita,muitos,vários,varios,muitas,várias,diversos,diversas,n,m,x</many>
<or>ou,até,/</or>
</root>
+28 -16
Ver Arquivo
@@ -39,6 +39,8 @@
*/
public function executableFunction()
{
GLOBAL $_MIND;
$property= explode('.', $this->property);
if(sizeof($property) <= 1){
\MindSpeaker::write('wrongParam', true, "property", $this->property);
@@ -46,23 +48,33 @@
}
$entity= $property[0];
$property= $property[1];
if($entity == 'user'){
if($property == 'pwd' && !$this->extra){
$this->prompt('pwd', "What will be the password?", true);
if($this->value)
$this->extra= $this->value;
$this->value= $this->answers['pwd'];
}
if($this->extra){
if(\MindUser::set($property, $this->value, $this->extra))
switch($entity){
case 'user':
if($property == 'pwd' && !$this->extra){
$this->prompt('pwd', "What will be the password?", true);
if($this->value)
$this->extra= $this->value;
$this->value= $this->answers['pwd'];
}
if($this->extra){
if(\MindUser::set($property, $this->value, $this->extra))
\MindSpeaker::write('done');
}else{
if(\MindUser::set($property, $this->value))
\MindSpeaker::write('done');
}
break;
case 'project':
if(\MindProject::set($property, $this->value, $this->extra))
\MindSpeaker::write('done');
}else{
if(\MindUser::set($property, $this->value))
\MindSpeaker::write('done');
}
}else{
if(\MindProject::set($property, $this->value, $this->extra))
\MindSpeaker::write('done');
break;
case 'conf':
\Mind::set($property, $this->value);
break;
default:
\Mind.write('invalidOption', true, $entity);
return false;
break;
}
}
-1
Ver Arquivo
@@ -84,7 +84,6 @@ EOT
case 'conf':
case 'props':
case 'properties':
//var_dump($_MIND);
$p= \Mind::$currentProject;
if($p){
//$p['users']= Array();
+1 -1
Ver Arquivo
@@ -8,7 +8,7 @@
;
;
; specify where theWebMind will find the phpunit classes
phpunit-src= "/usr/bin/phpunit"
phpunit-src=/usr/bin/phpunit
; what is the minimun size of a field, that may identify it as a big
; field or not
big_fields_size= 255