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 $content = "";
public static $originalContent = ""; public static $originalContent = "";
public static $curLang = 'en'; public static $curLang = 'en';
public static $availableSetAttrs= Array();
public static function &getInstance() public static function &getInstance()
{ {
@@ -214,6 +215,39 @@
Mind::$autoloadPaths[]= $p; 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 * The Constructor
*/ */
@@ -222,12 +256,14 @@
{ {
return $GLOBALS['_MIND']; return $GLOBALS['_MIND'];
}*/ }*/
$path= _MINDSRC_; $path= _MINDSRC_;
Mind::$projectsDir= $path.PROJECTS_DIR; Mind::$projectsDir= $path.PROJECTS_DIR;
Mind::$modelsDir= $path.MODELS_DIR; Mind::$modelsDir= $path.MODELS_DIR;
$this->about= parse_ini_file($path.ABOUT_INI); $this->about= parse_ini_file($path.ABOUT_INI);
$this->defaults= parse_ini_file($path.DEFAULTS_INI); $this->defaults= parse_ini_file($path.DEFAULTS_INI);
$this->conf= parse_ini_file($path.MIND_CONF); $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'); require_once($path.L10N_DIR.$this->defaults['default_human_language'].'.php');
Mind::$curLang= $this->defaults['default_human_languageName']; Mind::$curLang= $this->defaults['default_human_languageName'];
Mind::$l10n= new $this->defaults['default_human_language'](); Mind::$l10n= new $this->defaults['default_human_language']();
@@ -239,5 +275,7 @@
Mind::$gosh= new theos\Gosh(); Mind::$gosh= new theos\Gosh();
Mind::$darwin= new scientia\Darwin(); Mind::$darwin= new scientia\Darwin();
} }
} }
+11 -4
Ver Arquivo
@@ -24,6 +24,7 @@ class MindProject extends VersionManager{
'database_port', 'database_port',
'database_user', 'database_user',
'database_pwd', 'database_pwd',
'sourceadd', 'sourceAdd',
'source'); 'source');
/** /**
@@ -148,25 +149,31 @@ class MindProject extends VersionManager{
return false; return false;
} }
$attr= trim($attr); $attr= strtolower(trim($attr));
if(!\in_array($attr, self::$availableAttrs)){ if(!\in_array($attr, self::$availableAttrs)){
\MindSpeaker::write('invalidCreateParams'); \MindSpeaker::write('invalidCreateParams');
echo "Available list: ".implode(', ', self::$availableAttrs)."\n"; echo "Available list: ".implode(', ', self::$availableAttrs)."\n";
return false; return false;
} }
if($attr == 'source'){ if($attr == 'source' || $attr == 'sourceadd'){
$srcs= Mind::$currentProject['sources']; $srcs= Mind::$currentProject['sources'];
$source= func_get_arg(2); $source= func_get_arg(2);
if(!$source) if(!$source)
$source= 'main'; $source= 'main';
//echo "\n\n".$srcs.'/'.addslashes($source).'.mnd'."\n\n"; //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; return true;
Mind::write('permissionDenied'); Mind::write('permissionDenied');
return false; return false;
}else{ }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{ try{
file_put_contents($iniSource, $iniContent); file_put_contents($iniSource, $iniContent);
\MindProject::reload(); \MindProject::reload();
@@ -89,7 +89,7 @@ class Application
//new InputOption('--quiet', '-q', InputOption::PARAMETER_NONE, 'Do not output any message.'), //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('--verbose', '-v', InputOption::PARAMETER_NONE, 'Increase verbosity of messages.'),
//new InputOption('--version', '-V', InputOption::PARAMETER_NONE, 'Display this program version.'), //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.'), //new InputOption('--no-interaction', '-n', InputOption::PARAMETER_NONE, 'Do not ask any interactive question.'),
)); ));
} }
+1 -1
Ver Arquivo
@@ -9,6 +9,6 @@
<root> <root>
<none>nada,nenhum,zero,0,nenhuma</none> <none>nada,nenhum,zero,0,nenhuma</none>
<one>um,uma,1,algum,alguma,único,única,unico,unica</one> <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> <or>ou,até,/</or>
</root> </root>
+28 -16
Ver Arquivo
@@ -39,6 +39,8 @@
*/ */
public function executableFunction() public function executableFunction()
{ {
GLOBAL $_MIND;
$property= explode('.', $this->property); $property= explode('.', $this->property);
if(sizeof($property) <= 1){ if(sizeof($property) <= 1){
\MindSpeaker::write('wrongParam', true, "property", $this->property); \MindSpeaker::write('wrongParam', true, "property", $this->property);
@@ -46,23 +48,33 @@
} }
$entity= $property[0]; $entity= $property[0];
$property= $property[1]; $property= $property[1];
if($entity == 'user'){ switch($entity){
if($property == 'pwd' && !$this->extra){ case 'user':
$this->prompt('pwd', "What will be the password?", true); if($property == 'pwd' && !$this->extra){
if($this->value) $this->prompt('pwd', "What will be the password?", true);
$this->extra= $this->value; if($this->value)
$this->value= $this->answers['pwd']; $this->extra= $this->value;
} $this->value= $this->answers['pwd'];
if($this->extra){ }
if(\MindUser::set($property, $this->value, $this->extra)) 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'); \MindSpeaker::write('done');
}else{ break;
if(\MindUser::set($property, $this->value)) case 'conf':
\MindSpeaker::write('done'); \Mind::set($property, $this->value);
} break;
}else{ default:
if(\MindProject::set($property, $this->value, $this->extra)) \Mind.write('invalidOption', true, $entity);
\MindSpeaker::write('done'); return false;
break;
} }
} }
-1
Ver Arquivo
@@ -84,7 +84,6 @@ EOT
case 'conf': case 'conf':
case 'props': case 'props':
case 'properties': case 'properties':
//var_dump($_MIND);
$p= \Mind::$currentProject; $p= \Mind::$currentProject;
if($p){ if($p){
//$p['users']= Array(); //$p['users']= Array();
+1 -1
Ver Arquivo
@@ -8,7 +8,7 @@
; ;
; ;
; specify where theWebMind will find the phpunit classes ; 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 ; what is the minimun size of a field, that may identify it as a big
; field or not ; field or not
big_fields_size= 255 big_fields_size= 255