Added a few more annotations
Esse commit está contido em:
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
/**
|
||||
* This is the main class
|
||||
* It provides a bunch of static methods to deal with the console
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
/**
|
||||
* 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 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 <felipenmoura@gmail.com>
|
||||
*/
|
||||
@@ -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;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
|
||||
/**
|
||||
* Basic abstraction of the SQLite layer
|
||||
*
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of MindDBAL
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* Connects and executes queries and commands into the SQLite server.
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @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
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* A facade to deal with attributes/properties and methods
|
||||
* related to an entity
|
||||
* related to an entity.
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of MindException
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class MindException extends Exception{
|
||||
}
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* The Generic Exception manager.
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class MindException extends Exception{
|
||||
// TODO: build the MindException class...
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Will keep and deal with the current opened project
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author felipe
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* Will keep and deal with the current opened project.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
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();
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @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 <felipenmoura@gmail.com>
|
||||
*/
|
||||
class MindProperty {
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* Represents a relation between two Entities
|
||||
*
|
||||
* @author felipe
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
class MindRelation {
|
||||
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* This class will write out messages to the user as the application is used.
|
||||
*/
|
||||
class MindSpeaker
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Description of MindTimer
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* This is a time controller, to deal with processes time.
|
||||
*
|
||||
* @author felipe
|
||||
*
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of MindUser
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author felipe
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
/**
|
||||
* Class to deal with User's structure.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
class MindUser
|
||||
{
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @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/";
|
||||
|
||||
@@ -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))
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário