diff --git a/mind3rd/API/classes/Mind.php b/mind3rd/API/classes/Mind.php index bf15c74..985a83b 100755 --- a/mind3rd/API/classes/Mind.php +++ b/mind3rd/API/classes/Mind.php @@ -1,4 +1,9 @@ + * @license licenses/mind3rd.license /** * This is the main class * It provides a bunch of static methods to deal with the console diff --git a/mind3rd/API/classes/MindCommand.php b/mind3rd/API/classes/MindCommand.php index 0f825a8..e43d660 100755 --- a/mind3rd/API/classes/MindCommand.php +++ b/mind3rd/API/classes/MindCommand.php @@ -1,11 +1,17 @@ + * @license licenses/mind3rd.license + */ +use Symfony\Component\Console\Input\InputArgument, + Symfony\Component\Console\Input\InputOption, + Symfony\Component\Console; /** - * This class extends the Command class from Symfony - * All the program should extend it + * This class extends the class Command, from Symfony. + * All programs should extend it * * @author felipe Nascimento de Moura */ @@ -21,12 +27,20 @@ class MindCommand extends Symfony\Component\Console\Command\Command public $answers = Array(); public $commandAvailableOptions = Array(); + /** + * A required call, to set your program to work. + * This method initiates the program registering it to the application's core. + */ public function init() { parent::__construct(); } - public function configure() + /** + * This method configures your program to the application. + * You don't need to call it. + */ + final public function configure() { $this->setDefinition(Array()); $this->setName($this->commandName); @@ -54,6 +68,21 @@ class MindCommand extends Symfony\Component\Console\Command\Command $this->setDefinition($definition); } + /** + * This is a quite useful method for you to deal with user interaction. + * + * You can use this method to get information already sent by the user trhough POST + * or asking the user via console. + * It deals with the environment and sets the answered values to the $this->answers properties. + * + * Example: $myCommand->prompt('name', 'what is your name?'); + * echo $myCommand->answers['name']; + * + * @param string $name + * @param string $question + * @param boolean $mode Set it to true, if it is a password(then, it will be represented by * in the console + * @return mixed the answer + */ public function prompt($name, $question, $mode=false) { GLOBAL $_REQ; @@ -126,6 +155,18 @@ class MindCommand extends Symfony\Component\Console\Command\Command return $this->answers[$name]; } + /** + * Adds a required argument to your command. + * + * That means that, the given parameter MUST be passed to the command to execute. + * Example: auth felipenmoura + * in this case, 'auth' is the command and 'felipenmoura' is the required argument + * + * @param string $argName + * @param string $description + * @param Array $availableOptions A list of available options + * @return MindCommand + */ public function addRequiredArgument($argName, $description='', $availableOptions=null) @@ -138,6 +179,18 @@ class MindCommand extends Symfony\Component\Console\Command\Command $this->commandAvailableOptions[$argName]= $availableOptions; return $this; } + + /** + * Adds an optional argument to the command. + * An optional argument is that argument which may be ommited when the command is called. + * Example: auth admin 1234 + * Where 'auth' is the command, 'admin' is the required argument and '1234' is the password, an optional argument. + * + * @param string $argName + * @param string $description + * @param Array $availableOptions A list of available options to the argument + * @return MindCommand + */ public function addOptionalArgument($argName, $description='', $availableOptions=null) @@ -150,6 +203,20 @@ class MindCommand extends Symfony\Component\Console\Command\Command $this->commandAvailableOptions[$argName]= $availableOptions; return $this; } + + /** + * Adds a required option. + * An option is that argument which receives a value. + * Example: create project demo + * Where 'project' is the option and 'demo' is its value. + * + * @param string $argName + * @param string $shortCut + * @param string $description + * @param mixed $default + * @param Array $availableOptions A list of available options + * @return MindCommand + */ public function addRequiredOption($argName, $shortCut=null, $description='', @@ -166,6 +233,18 @@ class MindCommand extends Symfony\Component\Console\Command\Command $this->commandAvailableOptions[$argName]= $availableOptions; return $this; } + + /** + * Adds an optional option to the command. + * This is an option which, IF passed, receives a value. + * + * @param string $argName + * @param string $shortCut + * @param string $description + * @param mixed $default + * @param Array $availableOptions A list of available options. + * @return MindCommand + */ public function addOptionalOption($argName, $shortCut=null, $description='', @@ -183,6 +262,18 @@ class MindCommand extends Symfony\Component\Console\Command\Command return $this; } + /** + * Adds a flag to the command. + * A flag is just a boolean which defines an specific data. + * Example: show users -d + * Here, '-d' is the flag which defines the command to show detailed data about users. + * + * @param string $argName + * @param string $shortCut + * @param string $description + * @param Array $availableOptions A list of available options. + * @return MindCommand + */ public function addFlag($argName, $shortCut=null, $description='', @@ -198,24 +289,46 @@ class MindCommand extends Symfony\Component\Console\Command\Command return $this; } + /** + * Sets the command's name. + * @param string $commandName + * @return MindCommand + */ public function setCommandName($commandName) { $this->commandName= $commandName; return $this; } + /** + * Sets the command's description. + * @param string $description + * @return MindCommand + */ public function description($description) { $this->description= $description; return $this; } + /** + * Sets the command's help message. + * @param string $helpContent + * @return MindCommand + */ public function help($helpContent) { $this->helpContent= $helpContent; return $this; } + /** + * This method sets the action the command will call. + * You can pass an annonymous function to it or the name of a method INSIDE the command's class. + * + * @param string|function $action + * @return MindCommand + */ public function setAction($action) { $this->commandAction= $action; diff --git a/mind3rd/API/classes/MindDB.php b/mind3rd/API/classes/MindDB.php index 59592fa..b6bb693 100755 --- a/mind3rd/API/classes/MindDB.php +++ b/mind3rd/API/classes/MindDB.php @@ -1,9 +1,10 @@ + * @license licenses/mind3rd.license */ - /** * Basic abstraction of the SQLite layer * diff --git a/mind3rd/API/classes/MindDBAL.php b/mind3rd/API/classes/MindDBAL.php index 3bc1f24..a5da37c 100755 --- a/mind3rd/API/classes/MindDBAL.php +++ b/mind3rd/API/classes/MindDBAL.php @@ -1,12 +1,12 @@ + * @license licenses/mind3rd.license + */ +/** + * Connects and executes queries and commands into the SQLite server. * * @author felipe */ diff --git a/mind3rd/API/classes/MindDir.php b/mind3rd/API/classes/MindDir.php index 48cc5b0..d2b4277 100755 --- a/mind3rd/API/classes/MindDir.php +++ b/mind3rd/API/classes/MindDir.php @@ -1,6 +1,15 @@ + * @license licenses/mind3rd.license + */ /** - * Description of MindDir + * The class which will deal with Directories and files. + * This is not the most complete fileManager and will be used by the + * application's core. To deal in a more advanced way with files, or to + * interact easily with files within a project, use the FileManager class. * * @author felipe */ diff --git a/mind3rd/API/classes/MindEntity.php b/mind3rd/API/classes/MindEntity.php index 7809523..92eae77 100755 --- a/mind3rd/API/classes/MindEntity.php +++ b/mind3rd/API/classes/MindEntity.php @@ -1,7 +1,13 @@ + * @license licenses/mind3rd.license + */ /** * A facade to deal with attributes/properties and methods - * related to an entity + * related to an entity. * * @author felipe */ diff --git a/mind3rd/API/classes/MindException.php b/mind3rd/API/classes/MindException.php index 23ae713..aa3030a 100755 --- a/mind3rd/API/classes/MindException.php +++ b/mind3rd/API/classes/MindException.php @@ -1,14 +1,15 @@ + * @license licenses/mind3rd.license + */ + /** + * The Generic Exception manager. + * + * @author felipe + */ + class MindException extends Exception{ + // TODO: build the MindException class... + } \ No newline at end of file diff --git a/mind3rd/API/classes/MindPlugin.php b/mind3rd/API/classes/MindPlugin.php index 4a98011..6b1dd41 100755 --- a/mind3rd/API/classes/MindPlugin.php +++ b/mind3rd/API/classes/MindPlugin.php @@ -1,6 +1,13 @@ + * @license licenses/mind3rd.license + */ /** - * Description of MindPlugin + * The abstract class with generic methods Plugins may use. + * Also, offers methods to the application itself, allowing it to deal with plugins. * * @author felipe */ @@ -13,6 +20,12 @@ public $description; public $links= Array(); + /** + * Gets a list of all installed plugins. + * + * @param boolean $echoes If the list should or not be sent to the output. + * @return Array The list of plugins + */ public static function listPlugins($echoes=true) { if($echoes) @@ -47,11 +60,23 @@ return Mind::$pluginList; } + /** + * Informs which program/command will trigger the current plugin. + * + * @param string $trg The name of the command which will trigger the plugin + * @return MindPlugin + */ public function setTrigger($trg) { $this->trigger= $trg; return $this; } + /** + * Sets WHEN the plugin will be run. + * + * @param string $evt 'before' or 'after' the trigger command be executed. + * @return MindPlugin + */ public function setEvent($evt) { $this->event= $evt=='before'? 'before':'after'; @@ -66,16 +91,9 @@ */ static function addPlugin(&$plugin) { - //echo $plugin->name." - ".$plugin->trigger."\n\n"; - - //print_r(Mind::$triggers); - //if(in_array($plugin->trigger, Mind::$triggers)) - //{ - if(!isset(Mind::$pluginList[$plugin->trigger])) - Mind::$pluginList[$plugin->trigger]= Array( 'before'=>Array(), - 'after'=>Array()); - Mind::$pluginList[$plugin->trigger][$plugin->event][]= $plugin; - //} - //print_r(Mind::$pluginList); + if(!isset(Mind::$pluginList[$plugin->trigger])) + Mind::$pluginList[$plugin->trigger]= Array( 'before'=>Array(), + 'after'=>Array()); + Mind::$pluginList[$plugin->trigger][$plugin->event][]= $plugin; } } diff --git a/mind3rd/API/classes/MindProject.php b/mind3rd/API/classes/MindProject.php index 8a36029..a1c7f20 100755 --- a/mind3rd/API/classes/MindProject.php +++ b/mind3rd/API/classes/MindProject.php @@ -1,8 +1,14 @@ + * @license licenses/mind3rd.license + */ +/** + * Will keep and deal with the current opened project. + * + * @author Felipe Nascimento de Moura */ class MindProject extends VersionManager{ @@ -46,6 +52,11 @@ class MindProject extends VersionManager{ return $qrs; } + /** + * Returns the list of registered and active projects. + * + * @return Array + */ public static function listProjects() { $db= new MindDB(); diff --git a/mind3rd/API/classes/MindProperty.php b/mind3rd/API/classes/MindProperty.php index 6653ebc..09bb7de 100755 --- a/mind3rd/API/classes/MindProperty.php +++ b/mind3rd/API/classes/MindProperty.php @@ -1,8 +1,14 @@ + * @license licenses/mind3rd.license + */ /** - * Represents the property of an entity(MindEntity::properties) + * Represents the property of an entity(MindEntity::properties). * - * @author felipe + * @author Felipe Nascimento de Moura */ class MindProperty { diff --git a/mind3rd/API/classes/MindRelation.php b/mind3rd/API/classes/MindRelation.php index 3cb103f..14f6a9d 100755 --- a/mind3rd/API/classes/MindRelation.php +++ b/mind3rd/API/classes/MindRelation.php @@ -1,8 +1,14 @@ + * @license licenses/mind3rd.license + */ /** * Represents a relation between two Entities * - * @author felipe + * @author Felipe Nascimento de Moura */ class MindRelation { diff --git a/mind3rd/API/classes/MindSpeaker.php b/mind3rd/API/classes/MindSpeaker.php index b8129fb..fc0b9e6 100755 --- a/mind3rd/API/classes/MindSpeaker.php +++ b/mind3rd/API/classes/MindSpeaker.php @@ -1,4 +1,13 @@ + * @license licenses/mind3rd.license + */ +/** + * This class will write out messages to the user as the application is used. + */ class MindSpeaker { /** diff --git a/mind3rd/API/classes/MindTimer.php b/mind3rd/API/classes/MindTimer.php index 60997eb..e7a710d 100755 --- a/mind3rd/API/classes/MindTimer.php +++ b/mind3rd/API/classes/MindTimer.php @@ -1,6 +1,12 @@ + * @license licenses/mind3rd.license + */ +/** + * This is a time controller, to deal with processes time. * * @author felipe * diff --git a/mind3rd/API/classes/MindUser.php b/mind3rd/API/classes/MindUser.php index 6e89a18..e83340d 100644 --- a/mind3rd/API/classes/MindUser.php +++ b/mind3rd/API/classes/MindUser.php @@ -1,14 +1,14 @@ + * @license licenses/mind3rd.license + */ +/** + * Class to deal with User's structure. * - * @author felipe + * @author Felipe Nascimento de Moura */ class MindUser { diff --git a/mind3rd/API/classes/VersionManager.php b/mind3rd/API/classes/VersionManager.php index ffb70d1..a8a2763 100755 --- a/mind3rd/API/classes/VersionManager.php +++ b/mind3rd/API/classes/VersionManager.php @@ -1,10 +1,19 @@ + * @license licenses/mind3rd.license /** * This class takes care of the version control methods * * @author felipe */ class VersionManager { + + /** + * Commits the current project status. + */ public static function commit() { $project= new DAO\ProjectFactory(Mind::$currentProject); @@ -13,10 +22,16 @@ Mind::$currentProject['version']= $project->data['version']; } + /** + * Sets the Version settings up. + */ public static function setUp() { } + /** + * Clears any data that may interfere with future version maintainces. + */ public static function cleanUp() { $path= Mind::$currentProject['path']."/temp/"; diff --git a/mind3rd/API/classes/theos/ProjectFileManager.php b/mind3rd/API/classes/theos/ProjectFileManager.php index 80812de..57ceef5 100755 --- a/mind3rd/API/classes/theos/ProjectFileManager.php +++ b/mind3rd/API/classes/theos/ProjectFileManager.php @@ -33,6 +33,12 @@ class ProjectFileManager { return $tmpURI; } + /** + * Creates the given directorey. + * Note that you can pass nested directories. + * Example: 'new_dir/another_new_dir/the_final_new_dir/' + * @param string $uri + */ public static function createDir($uri) { $uri= self::setInnerURI($uri); @@ -51,6 +57,15 @@ class ProjectFileManager { chmod($uri, 0777); } + /** + * Appends a string into a given file. + * If the file does not exists, it creates it for you. + * Again, it may be a nested uri. + * + * @param string $file + * @param string $data + * @return boolean True in case of success, false otherwise. + */ public static function appendDataToFile($file, $data) { $file= self::setInnerURI($file); @@ -64,6 +79,16 @@ class ProjectFileManager { return \Mind::$currentProject['path']."/".$uri; } + /** + * Writes the given string in the file. + * Note that this method will replace the old file's content. + * If the file does not exist, it will be created. + * Nested uris are allowed. + * + * @param string $file + * @param string $data + * @return type + */ public static function writeToFile($file, $data) { $file= self::setInnerURI($file); @@ -72,6 +97,14 @@ class ProjectFileManager { return false; } + /** + * Creates a file. + * Nested URIs are allowed(any unexistent folder will be created, then). + * + * @param string $uri + * @param string $type Accepts null, 'general' or 'xml' + * @return mixed the file handler or the SimpleXML from the created file. + */ public static function createFile($uri, $type='general') { $uri= self::setInnerURI($uri); @@ -84,6 +117,13 @@ class ProjectFileManager { } } + /** + * Creates an XML file. + * Nested URIs are allowed. + * + * @param string $uri + * @return SimpleXML + */ public static function createXMLFile($uri) { if(file_exists($uri))