Forráskód Böngészése

Common functionalities

ahwelp 2 éve
szülő
commit
d821c32013
43 módosított fájl, 1278 hozzáadás és 0 törlés
  1. 8 0
      app/common/Routes.php
  2. 111 0
      app/common/defaults/DefaultsController.php
  3. 21 0
      app/common/defaults/Routes.php
  4. 14 0
      app/common/defaults/classes/Defaults.php
  5. 40 0
      app/common/defaults/db/Migrate.php
  6. 2 0
      app/common/defaults/lang/en.php
  7. 2 0
      app/common/defaults/lang/pt_br.php
  8. 8 0
      app/common/defaults/version.php
  9. 10 0
      app/common/defaults/views/form.mustache
  10. 4 0
      app/common/defaults/views/index.mustache
  11. 136 0
      app/common/email/EmailController.php
  12. 107 0
      app/common/email/EmailTemplateController.php
  13. 28 0
      app/common/email/Routes.php
  14. 49 0
      app/common/email/classes/Email.php
  15. 19 0
      app/common/email/classes/EmailsCongifs.php
  16. 19 0
      app/common/email/classes/EmailsTemplate.php
  17. 57 0
      app/common/email/db/Migrate.php
  18. 2 0
      app/common/email/lang/en.php
  19. 2 0
      app/common/email/lang/pt_br.php
  20. 0 0
      app/common/email/todo.md
  21. 6 0
      app/common/email/version.php
  22. 62 0
      app/common/email/views/form.mustache
  23. 2 0
      app/common/email/views/index.mustache
  24. 48 0
      app/common/email/views/templateForm.mustache
  25. 111 0
      app/common/files/FilesController.php
  26. 16 0
      app/common/files/Routes.php
  27. 21 0
      app/common/files/classes/Files.php
  28. 33 0
      app/common/files/db/Migrate.php
  29. 2 0
      app/common/files/lang/en.php
  30. 2 0
      app/common/files/lang/pt_br.php
  31. 6 0
      app/common/files/version.php
  32. 10 0
      app/common/files/views/form.mustache
  33. 4 0
      app/common/files/views/index.mustache
  34. 111 0
      app/common/glossary/GlossaryController.php
  35. 22 0
      app/common/glossary/Routes.php
  36. 49 0
      app/common/glossary/classes/Glossary.php
  37. 36 0
      app/common/glossary/db/Migrate.php
  38. 2 0
      app/common/glossary/lang/en.php
  39. 2 0
      app/common/glossary/lang/pt_br.php
  40. 0 0
      app/common/glossary/todo.md
  41. 6 0
      app/common/glossary/version.php
  42. 86 0
      app/common/glossary/views/form.mustache
  43. 2 0
      app/common/glossary/views/index.mustache

+ 8 - 0
app/common/Routes.php

@@ -0,0 +1,8 @@
+<?php
+
+use App\Core\Template\Output as Output;
+use Routes\RouteCollection as RouteCollection;
+
+RouteCollection::get('*', function() {
+    Output::addSubmenu('config', 'Configuração', icon('cogs'), ['class' => 'nav-link'], 10 );
+}, -10)->doIgnore();

+ 111 - 0
app/common/defaults/DefaultsController.php

@@ -0,0 +1,111 @@
+<?php
+
+namespace App\Common\Defaults;
+
+use \App\Core\Template\Output as Output;
+use \App\Common\Defaults\Classes\Defaults as Defaults;
+
+class DefaultsController {
+
+    /**
+    * Index
+    *   Show the main Defaults list
+    */
+    function index(){
+        Output::setView('index');
+        $list = Array();
+
+        for($i = 0; $i <= 10; $i++){
+            $obj = Array();
+            $obj['id'] = $i;
+            $obj['value'] = md5($i);
+            $obj['description'] = sha1($i);
+            $list[] = $obj;
+        }
+        Output::addValue('list', $list );
+        Output::render();
+    }
+
+    /**
+    * Create
+    *
+    * Render the main Defaults formulary
+    */
+    function create(){
+        Output::setView('form', ['id' => 0]);
+        Output::render();
+    }
+
+    /**
+    * Store
+    *
+    * Store the param on the database
+    * @param Defaults $defaults
+    */
+    function store(Defaults $defaults){
+
+    }
+
+    /**
+    * Search
+    *
+    * Store the param on the database
+    * @param Defaults $defaults
+    */
+    function search(){
+    
+    }
+
+    /**
+    * Show
+    *
+    * Render one register
+    *
+    * @param Defaults $defaults
+    */
+    function show(Defaults $defaults){
+
+    }
+
+    /**
+    * Edit
+    *
+    * Render the formular for a database Defaults
+    *
+    * @param Defaults $defaults
+    */
+    function edit(Defaults $defaults){
+        Output::setView('form', $defaults);
+        Output::render();
+    }
+
+    /**
+    * Update
+    * Store the changes of the param on the database
+    *
+    * @param Defaults $defaults
+    */
+    function update(Defaults $defaults){
+
+    }
+
+    /**
+    * Destroy
+    * If the object has soft delete.
+    *
+    * @param Defaults $defaults
+    */
+    function destroy(Defaults $defaults){
+
+    }
+
+    /**
+    * Purge
+    * Remove object even with soft delete.
+    *
+    * @param Defaults $defaults
+    */
+    function purge(Defaults $defaults){
+
+    }
+}

+ 21 - 0
app/common/defaults/Routes.php

@@ -0,0 +1,21 @@
+<?php
+
+use App\Core\Template\Output as Output;
+use Routes\RouteCollection as RouteCollection;
+
+//Menu itens
+RouteCollection::get('*', function() {
+    //Output::addMenu('/defaults', 'defaults', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
+    Output::addOnSubmenu('config', '/defaults', "Padrões", "", ['class' => 'nav-link']);
+}, -10)->doIgnore();
+
+RouteCollection::group("/defaults", function(){
+    RouteCollection::get   ("/",            "\App\Common\Defaults\DefaultsController@index");
+    RouteCollection::get   ("/form",        "\App\Common\Defaults\DefaultsController@create");
+    RouteCollection::post  ("/",            "\App\Common\Defaults\DefaultsController@store");
+    RouteCollection::post  ("/search",      "\App\Common\Defaults\DefaultsController@search");
+    RouteCollection::get   ("/[i:id]",      "\App\Common\Defaults\DefaultsController@show");
+    RouteCollection::get   ("/[i:id]/edit", "\App\Common\Defaults\DefaultsController@edit");
+    RouteCollection::put   ("/[i:id]/edit", "\App\Common\Defaults\DefaultsController@update");
+    RouteCollection::delete("/[i:id]",      "\App\Common\Defaults\DefaultsController@destroy");
+});

+ 14 - 0
app/common/defaults/classes/Defaults.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Common\Defaults\Classes;
+
+use ORM\Entity as Entity;
+
+class Defaults extends Entity {
+
+    const _tableName = "defaultss";
+    
+
+    
+
+}

+ 40 - 0
app/common/defaults/db/Migrate.php

@@ -0,0 +1,40 @@
+<?php
+
+use Schema\Wrapper as Wrapper;
+use App\Core\Sanity\MigratorController as Migrator;
+
+function common_defaults_upgrade($pluginversion) {
+    if ($pluginversion < "0.0.1") {
+        $table = Wrapper::get_table("common_system_defaults");
+        $table->addColumn("module", "string", Array("null" => true));
+        $table->addColumn("table",  "string", Array("null" => true));
+        $table->addColumn("key",    "string", Array("null" => false));
+        $table->addColumn("value",  "string", Array("null" => false));        
+        $table->create();
+
+        $table = Wrapper::get_table("common_user_defaults");
+        $table->addColumn("user_id", "integer", Array("null" => false));
+        $table->addColumn("module",  "string",  Array("null" => true));
+        $table->addColumn("table",   "string",  Array("null" => true));
+        $table->addColumn("key",     "string",  Array("null" => false));
+        $table->addColumn("value",   "string",  Array("null" => false));
+        $table->addForeignKey('user_id',   Wrapper::get_table('core_auth_user'));
+
+        Migrator::getInstance()->update_plugin_version("common_defaults", "1.0.0");
+        return;
+    }
+
+    //if ($pluginversion < "0.0.2") {
+        //$table = Wrapper::get_table("common_defaultss");
+        //Migrator::getInstance()->update_plugin_version("common_defaults", "1.0.1");
+        //return;
+    //}
+}
+
+function common_defaults_rollback($pluginversion) {
+    if($pluginversion > "0.0.1"){
+        $table = Wrapper::get_table("common_defaultss");
+        $table->drop();
+        return;
+    }
+}

+ 2 - 0
app/common/defaults/lang/en.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["defaults"]["module_name"] = "Defaults";

+ 2 - 0
app/common/defaults/lang/pt_br.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["defaults"]["module_name"] = "Defaults";

+ 8 - 0
app/common/defaults/version.php

@@ -0,0 +1,8 @@
+<?php
+
+$plugin->name = "common_defaults";
+$plugin->version = "0.0.0";
+
+$plugin->require = Array(
+    Array("name" => "core_auth", "version" => "1.0.0")
+);

+ 10 - 0
app/common/defaults/views/form.mustache

@@ -0,0 +1,10 @@
+{{@ if( {{id}} ): @}}
+<form method="POST" action="/defaults/{{id}}/edit">
+   <input type="hidden" name="id" value="{{id}}" />
+   <input type="hidden" name="_method" value="put" />
+{{@ else: @}}
+<form method="POST" action="/defaults">
+   <input type="hidden" name="id" value="" />
+{{@ endif; @}}
+
+</form>

+ 4 - 0
app/common/defaults/views/index.mustache

@@ -0,0 +1,4 @@
+<a href='/defaults/form' >Adicionar </a>
+<div class="table-responsive">
+
+</div>

+ 136 - 0
app/common/email/EmailController.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace App\Common\Email;
+
+use \App\Core\Template\Output as Output;
+use \App\Core\Email\Classes\Email as Email;
+
+use PHPMailer\PHPMailer\PHPMailer;
+use PHPMailer\PHPMailer\SMTP;
+use PHPMailer\PHPMailer\Exception;
+
+class EmailController extends \DefaultController
+{
+
+    protected $_class = Email::class;
+    protected $_baseUrl = '/email';
+
+    /**
+     * Index
+     *   Show the main Email list
+     */
+    function index()
+    {
+        Output::render('index');
+        /*
+        $mail = new PHPMailer(true);
+
+        // Server settings
+        $mail->SMTPDebug = SMTP::DEBUG_SERVER; // for detailed debug output
+        $mail->isSMTP();
+        $mail->Host = 'smtp.gmail.com';
+        $mail->SMTPAuth = true;
+        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
+        $mail->Port = 587;
+
+        $mail->Username = 'ahwelp@universo.univates.br';
+        $mail->Password = '********';
+
+        // Sender and recipient settings
+        $mail->setFrom('ahwelp@universo.univates.br', 'Sender Name');
+        $mail->addAddress('ahwelp@univates.br', 'Receiver Name');
+        $mail->addReplyTo('ahwelp@universo.univates.br', 'Sender Name');
+
+        // Setting the email content
+        $mail->IsHTML(true);
+        $mail->Subject = "Send email using Gmail SMTP and PHPMailer";
+        $mail->Body = 'HTML message body. <b>Gmail</b> SMTP email body.';
+        $mail->AltBody = 'Plain text message body for non-HTML email client. Gmail SMTP email body.';
+
+        $mail->send();
+        echo "Email message sent.";*/
+    }
+
+    /**
+     * Create
+     *
+     * Render the main Email formulary
+     */
+    function create()
+    {
+        Output::render('form', ['id' => 0]);
+    }
+
+    /**
+     * Store
+     *
+     * Store the param on the database
+     * @param Email $email
+     */
+    function store(Email $email)
+    {
+    }
+
+    /**
+     * Search
+     *
+     * Store the param on the database
+     * @param Email $email
+     */
+    function search()
+    {
+    }
+
+    /**
+     * Show
+     *
+     * Render one register
+     *
+     * @param Email $email
+     */
+    function show(Email $email)
+    {
+    }
+
+    /**
+     * Edit
+     *
+     * Render the formular for a database Email
+     *
+     * @param Email $email
+     */
+    function edit(Email $email)
+    {
+        Output::render('form', $email);
+    }
+
+    /**
+     * Update
+     * Store the changes of the param on the database
+     *
+     * @param Email $email
+     */
+    function update(Email $email)
+    {
+    }
+
+    /**
+     * Destroy
+     * If the object has soft delete.
+     *
+     * @param Email $email
+     */
+    function destroy(Email $email)
+    {
+    }
+
+    /**
+     * Purge
+     * Remove object even with soft delete.
+     *
+     * @param Email $email
+     */
+    function purge(Email $email)
+    {
+    }
+}

+ 107 - 0
app/common/email/EmailTemplateController.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace App\Common\Email;
+
+use App\Common\Email\Classes\EmailTemplate;
+use \App\Core\Template\Output as Output;
+use \App\Core\Email\Classes\Email as Email;
+
+class EmailTemplateController extends \DefaultController
+{
+
+    protected $_class   = EmailTemplate::class;
+    protected $_baseUrl = '/email';
+
+    /**
+     * Index
+     *   Show the main Email list
+     */
+    function index()
+    {
+        //Output::render('index');
+    }
+
+    /**
+     * Create
+     *
+     * Render the main Email formulary
+     */
+    function create()
+    {
+        Output::render('templateForm', ['id' => 0]);
+    }
+
+    /**
+     * Store
+     *
+     * Store the param on the database
+     * @param Email $email
+     */
+    function store(Email $email)
+    {
+        var_dump($email);
+    }
+
+    /**
+     * Search
+     *
+     * Store the param on the database
+     * @param Email $email
+     */
+    function search()
+    {
+    }
+
+    /**
+     * Show
+     *
+     * Render one register
+     *
+     * @param Email $email
+     */
+    function show(Email $email)
+    {
+    }
+
+    /**
+     * Edit
+     *
+     * Render the formular for a database Email
+     *
+     * @param Email $email
+     */
+    function edit(Email $email)
+    {
+        Output::render('form', $email);
+    }
+
+    /**
+     * Update
+     * Store the changes of the param on the database
+     *
+     * @param Email $email
+     */
+    function update(Email $email)
+    {
+    }
+
+    /**
+     * Destroy
+     * If the object has soft delete.
+     *
+     * @param Email $email
+     */
+    function destroy(Email $email)
+    {
+    }
+
+    /**
+     * Purge
+     * Remove object even with soft delete.
+     *
+     * @param Email $email
+     */
+    function purge(Email $email)
+    {
+    }
+}

+ 28 - 0
app/common/email/Routes.php

@@ -0,0 +1,28 @@
+<?php
+
+use App\Core\Template\Output as Output;
+use Routes\RouteCollection as RouteCollection;
+
+//Menu itens
+RouteCollection::get('*', function() {
+    Output::addOnSubmenu('config', '/email', "Emails", "", ['class' => 'nav-link']);
+}, -10)->doIgnore();
+
+RouteCollection::group("/email", function(){
+    RouteCollection::get   ("/",            "\App\Common\Email\EmailController@index");
+    RouteCollection::get   ("/form",        "\App\Common\Email\EmailController@create");
+    RouteCollection::post  ("/",            "\App\Common\Email\EmailController@store");
+    RouteCollection::post  ("/search",      "\App\Common\Email\EmailController@search");
+    RouteCollection::get   ("/[i:id]",      "\App\Common\Email\EmailController@show");
+    RouteCollection::get   ("/[i:id]/edit", "\App\Common\Email\EmailController@edit");
+    RouteCollection::put   ("/[i:id]/edit", "\App\Common\Email\EmailController@update");
+    RouteCollection::delete("/[i:id]",      "\App\Common\Email\EmailController@destroy");
+
+    //RouteCollection::get   ("/template", "\App\Common\Email\EmailTemplateController@index");
+    RouteCollection::get   ("/template/form", "\App\Common\Email\EmailTemplateController@create");
+    RouteCollection::post  ("/template", "\App\Common\Email\EmailTemplateController@store");
+    RouteCollection::get   ("/template/[i:id]", "\App\Common\Email\EmailTemplateController@show");
+    RouteCollection::get   ("/template/[i:id]/edit", "\App\Common\Email\EmailTemplateController@edit");
+    RouteCollection::put   ("/template/[i:id]/edit", "\App\Common\Email\EmailTemplateController@update");
+
+});

+ 49 - 0
app/common/email/classes/Email.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Common\Email\Classes;
+
+use ORM\Entity as Entity;
+
+class Email extends Entity {
+
+    //const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
+
+    const _tableName = "emails";
+
+    /*const _properties = Array(
+        "id"   => ['listable' => true,  'searcheble' => false, 'orderable' => false],
+        "name" => ['listable' => true,  'searcheble' => true]);
+    */
+
+    const _properties = Array(
+        'id',
+        'name',
+        'description'
+    );
+
+    /*protected $_ignore = Array(
+
+    );*/
+
+    const _listable = Array(
+        'id',
+        'name'
+    );
+
+    const _searchable = Array(
+        'name'
+    );
+
+    const _orderable = Array(
+
+    );
+
+    /*const _datatables = Array(
+
+    );*/
+
+    //const _timestamps = true;
+    //const _softdelete = true;
+
+    //const _connectionName = "";
+}

+ 19 - 0
app/common/email/classes/EmailsCongifs.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Common\Email\Classes;
+
+use ORM\Entity as Entity;
+
+class EmailConfigs extends Entity {
+
+    const _tableName = "common_emails_configs";
+    const _timestamps = true;
+    const _softdelete = true;
+
+    const _properties = Array(
+        'id',
+        'name',
+        'description'
+    );
+
+}

+ 19 - 0
app/common/email/classes/EmailsTemplate.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Common\Email\Classes;
+
+use ORM\Entity as Entity;
+
+class EmailTemplate extends Entity {
+
+    const _tableName = "common_emails_templates";
+    const _timestamps = true;
+    const _softdelete = true;
+
+    const _properties = Array(
+        'id',
+        'name',
+        'description'
+    );
+
+}

+ 57 - 0
app/common/email/db/Migrate.php

@@ -0,0 +1,57 @@
+<?php
+
+use Schema\Wrapper as Wrapper;
+use App\Core\Sanity\MigratorController as Migrator;
+
+//https://book.cakephp.org/phinx/0/en/migrations.html#valid-column-types
+function common_email_upgrade($pluginversion) {
+    if ($pluginversion < "0.0.1") {
+
+        $table = Wrapper::get_table("common_emails_config");
+        $table->addColumn("name", "string", Array("null" => false));
+        $table->addColumn("smtphosts", "string", Array("null" => false));
+        $table->addColumn("smtpsecure", "integer", Array("null" => false, "default" => 0));
+        $table->addColumn("smtpauthtype", "integer", Array("null" => false, "default" => 0));
+        $table->addColumn("smtpuser", "string", Array("null" => false));
+        $table->addColumn("smtppass", "string", Array("null" => false));
+        $table->addColumn("smtpmaxbulk", "integer", Array("null" => false, "default" => 1));
+        $table->addColumn("noreplyaddress", "string", Array("null" => false, "default" => ''));
+        $table->addColumn("sitemailcharset", "string", Array("null" => false, "default" => 'UTF-8'));
+        $table->addTimestamps();
+        $table->addSoftDelete();
+        $table->create();
+
+        $table = Wrapper::get_table("common_emails_templates");
+        $table->addColumn("name", "string", Array("null" => false));
+        $table->addColumn("title", "string", Array("null" => false));
+        $table->addColumn("body", "text");
+        $table->addTimestamps();
+        $table->addSoftDelete();
+        $table->create();
+
+        $table = Wrapper::get_table("common_emails");
+        $table->addColumn("name", "string", Array("null" => false));
+        $table->addColumn("template", "integer", Array());
+        $table->addColumn("title", "text");
+        $table->addColumn("body", "text");
+        $table->addColumn("timesent", "timestamp", Array());
+        $table->create();
+
+        Migrator::getInstance()->update_plugin_version("common_email", "1.0.0");
+        return;
+    }
+
+    //if ($pluginversion < "0.0.2") {
+        //$table = Wrapper::get_table("common_emails");
+        //Migrator::getInstance()->update_plugin_version("common_email", "1.0.1");
+        //return;
+    //}
+}
+
+function common_email_rollback($pluginversion) {
+    if($pluginversion > "0.0.1"){
+        $table = Wrapper::get_table("common_emails");
+        $table->drop();
+        return;
+    }
+}

+ 2 - 0
app/common/email/lang/en.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["email"]["module_name"] = "Email";

+ 2 - 0
app/common/email/lang/pt_br.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["email"]["module_name"] = "Email";

+ 0 - 0
app/common/email/todo.md


+ 6 - 0
app/common/email/version.php

@@ -0,0 +1,6 @@
+<?php
+
+$plugin->name = "common_email";
+$plugin->version = "0.0.0";
+
+//$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] );

+ 62 - 0
app/common/email/views/form.mustache

@@ -0,0 +1,62 @@
+{{#id}}
+<form method="POST" action="/email/{{id}}/edit">
+   <input type="hidden" name="id" value="{{id}}" />
+   <input type="hidden" name="_method" value="put" />
+{{/id}}
+{{^id}}
+<form method="POST" action="/email">
+   <input type="hidden" name="id" value="" />
+{{/id}}
+    <div class='row'>
+        <div class="col-md-8 col-xs-12 g-3">
+            <div class="card">
+                <div class="card-header">Header</div>
+                <div class="card-body">
+                    <div class="row g-3">
+                        <div class="col-xs-12 col-3">
+                            <label class="form-label">Código</label>
+                            <input type="text" class="form-control" name='code' value="{{code}}">
+                        </div>
+                        <div class="col-xs-12 col-9">
+                            <label class="form-label">Nome</label>
+                            <input type="text" class="form-control" name='name' value="{{name}}">
+                        </div>
+                    </div>
+
+                    <div class="row">
+                        <div class="col-xs-12 g-3">
+                            <label class="form-label">Descrição</label>
+                            <textarea class="form-control" name="descricao">{{description}}</textarea>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class='row'>
+        <div class="col-md-8 col-xs-12 g-3">
+            <div class="card">
+                <div class="card-header">Header</div>
+                <div class="card-body">
+                    <div class="row g-3">
+                        <div class="col-xs-12 col-3">
+                            <label class="form-label">Código</label>
+                            <input type="text" class="form-control" name='code' value="{{code}}">
+                        </div>
+                        <div class="col-xs-12 col-9">
+                            <label class="form-label">Nome</label>
+                            <input type="text" class="form-control" name='name' value="{{name}}">
+                        </div>
+                    </div>
+
+                    <div class="row">
+                        <div class="col-xs-12 g-3">
+                            <label class="form-label">Descrição</label>
+                            <textarea class="form-control" name="descricao">{{description}}</textarea>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</form>

+ 2 - 0
app/common/email/views/index.mustache

@@ -0,0 +1,2 @@
+<a class="btn btn-primary" href="/email/template/form"> Adicionar modelo</a>
+<a class="btn btn-primary" href="/email/config/form"> Adicionar configuração</a>

+ 48 - 0
app/common/email/views/templateForm.mustache

@@ -0,0 +1,48 @@
+<h2> {{#string}} emailTemplates,email {{/string}} </h2>
+
+{{#id}}
+<form method="POST" action="/email/template/{{id}}/edit">
+   <input type="hidden" name="id" value="{{id}}" />
+   <input type="hidden" name="_method" value="put" />
+{{/id}}
+{{^id}}
+<form method="POST" action="/email/template">
+   <input type="hidden" name="id" value="" />
+{{/id}}
+    <div class='row'>
+        <div class="col-12 g-3">
+            <div class="card">
+                <div class="card-header">Header</div>
+                <div class="card-body">
+                    <div class="row g-3">
+                        <div class="col-xs-12 col-3">
+                            <label class="form-label">{{#string}} name {{/string}}</label>
+                            <input type="text" class="form-control" name='code' value="{{code}}">
+                        </div>
+                        <div class="col-xs-12 col-9">
+                            <label class="form-label">{{#string}} title {{/string}}</label>
+                            <input type="text" class="form-control" name='name' value="{{name}}">
+                        </div>
+                    </div>
+
+                    <div class="row">
+                        <div class="col-xs-12 g-3">
+                            <label class="form-label">{{#string}} content {{/string}}</label>
+                            <textarea id="wysiwyg" name="descricao">{{description}}</textarea>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="row">
+        <div class="col-md-6 g-3"> <input class="btn btn-success btn-block" type="submit" value="Salvar">
+        </div>
+        <div class="col-md-6 g-3"> <a class="btn btn-danger btn-block" href="/people">Cancelar</a> </div>
+    </div>
+
+</form>
+
+<script>
+    $('#wysiwyg').trumbowyg();
+</script>

+ 111 - 0
app/common/files/FilesController.php

@@ -0,0 +1,111 @@
+<?php
+
+namespace App\Common\Files;
+
+use \App\Core\Template\Output as Output;
+use \App\Common\Files\Classes\Files as Files;
+
+class FilesController {
+
+    /**
+    * Index
+    *   Show the main Files list
+    */
+    function index(){
+        Output::setView('index');
+        $list = Array();
+
+        for($i = 0; $i <= 10; $i++){
+            $obj = Array();
+            $obj['id'] = $i;
+            $obj['value'] = md5($i);
+            $obj['description'] = sha1($i);
+            $list[] = $obj;
+        }
+        Output::addValue('list', $list );
+        Output::render();
+    }
+
+    /**
+    * Create
+    *
+    * Render the main Files formulary
+    */
+    function create(){
+        Output::setView('form', ['id' => 0]);
+        Output::render();
+    }
+
+    /**
+    * Store
+    *
+    * Store the param on the database
+    * @param Files $files
+    */
+    function store(Files $files){
+
+    }
+
+    /**
+    * Search
+    *
+    * Store the param on the database
+    * @param Files $files
+    */
+    function search(){
+    
+    }
+
+    /**
+    * Show
+    *
+    * Render one register
+    *
+    * @param Files $files
+    */
+    function show(Files $files){
+
+    }
+
+    /**
+    * Edit
+    *
+    * Render the formular for a database Files
+    *
+    * @param Files $files
+    */
+    function edit(Files $files){
+        Output::setView('form', $files);
+        Output::render();
+    }
+
+    /**
+    * Update
+    * Store the changes of the param on the database
+    *
+    * @param Files $files
+    */
+    function update(Files $files){
+
+    }
+
+    /**
+    * Destroy
+    * If the object has soft delete.
+    *
+    * @param Files $files
+    */
+    function destroy(Files $files){
+
+    }
+
+    /**
+    * Purge
+    * Remove object even with soft delete.
+    *
+    * @param Files $files
+    */
+    function purge(Files $files){
+
+    }
+}

+ 16 - 0
app/common/files/Routes.php

@@ -0,0 +1,16 @@
+<?php
+
+use App\Core\Template\Output as Output;
+use Routes\RouteCollection as RouteCollection;
+
+//Menu itens
+RouteCollection::get('*', function() {
+    Output::addOnSubmenu('config', '/files', "Arquivos", "", ['class' => 'nav-link']);
+}, -10)->doIgnore();
+
+RouteCollection::group("/files", function(){
+    RouteCollection::post  ("/",            "\App\Common\Files\FilesController@store");
+    RouteCollection::get   ("/[i:id]",      "\App\Common\Files\FilesController@show");
+    RouteCollection::put   ("/[i:id]/edit", "\App\Common\Files\FilesController@update");
+    RouteCollection::delete("/[i:id]",      "\App\Common\Files\FilesController@destroy");
+});

+ 21 - 0
app/common/files/classes/Files.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Common\Files\Classes;
+
+use ORM\Entity as Entity;
+
+class Files extends Entity {
+
+    //const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
+
+    const _tableName = "filess";
+    /*const _properties = Array(
+        "id"   => ['listable' => true,  'searcheble' => false, 'orderable' => false], 
+        "name" => ['listable' => true,  'searcheble' => true]);
+    */
+
+    //const _timestamps = true;
+    //const _softdelete = true;
+
+    //const _connectionName = "";
+}

+ 33 - 0
app/common/files/db/Migrate.php

@@ -0,0 +1,33 @@
+<?php
+
+use Schema\Wrapper as Wrapper;
+use App\Core\Sanity\MigratorController as Migrator;
+
+function common_files_upgrade($pluginversion) {
+    if ($pluginversion < "0.0.1") {
+        $table = Wrapper::get_table("common_filess");
+        $table->addColumn("name", "string", Array("null" => false));
+        $table->addColumn("time", "timestamp", Array("null" => true, "default"=>null));
+        $table->addColumn("areaid", "integer", Array("null" => false));
+        $table->addTimestamps();
+        $table->addSoftDelete();
+        $table->create();
+
+        Migrator::getInstance()->update_plugin_version("common_files", "1.0.0");
+        return;
+    }
+
+    //if ($pluginversion < "0.0.2") {
+        //$table = Wrapper::get_table("common_filess");
+        //Migrator::getInstance()->update_plugin_version("common_files", "1.0.1");
+        //return;
+    //}
+}
+
+function common_files_rollback($pluginversion) {
+    if($pluginversion > "0.0.1"){
+        $table = Wrapper::get_table("common_filess");
+        $table->drop();
+        return;
+    }
+}

+ 2 - 0
app/common/files/lang/en.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["files"]["module_name"] = "Files";

+ 2 - 0
app/common/files/lang/pt_br.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["files"]["module_name"] = "Files";

+ 6 - 0
app/common/files/version.php

@@ -0,0 +1,6 @@
+<?php
+
+$plugin->name = "common_files";
+$plugin->version = "0.0.0";
+
+//$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] );

+ 10 - 0
app/common/files/views/form.mustache

@@ -0,0 +1,10 @@
+{{@ if( {{id}} ): @}}
+<form method="POST" action="/files/{{id}}/edit">
+   <input type="hidden" name="id" value="{{id}}" />
+   <input type="hidden" name="_method" value="put" />
+{{@ else: @}}
+<form method="POST" action="/files">
+   <input type="hidden" name="id" value="" />
+{{@ endif; @}}
+
+</form>

+ 4 - 0
app/common/files/views/index.mustache

@@ -0,0 +1,4 @@
+<a href='/files/form' >Adicionar </a>
+<div class="table-responsive">
+
+</div>

+ 111 - 0
app/common/glossary/GlossaryController.php

@@ -0,0 +1,111 @@
+<?php
+
+namespace App\Common\Glossary;
+
+use \App\Core\Template\Output as Output;
+use \App\Common\Glossary\Classes\Glossary as Glossary;
+
+class GlossaryController extends \DefaultController{
+
+    protected $_class   = Glossary::class;
+    protected $_baseUrl = '/glossary';
+
+    /**
+    * Index
+    *   Show the main Glossary list
+    */
+    function index(){
+        $list = Array();
+
+        for($i = 0; $i <= 10; $i++){
+            $obj = Array();
+            $obj['id'] = $i;
+            $obj['value'] = md5($i);
+            $obj['description'] = sha1($i);
+            $list[] = $obj;
+        }
+
+        Output::render('index', Array('list' => $list));
+    }
+
+    /**
+    * Create
+    *
+    * Render the main Glossary formulary
+    */
+    function create(){
+        Output::render('form', ['id' => 0]);
+    }
+
+    /**
+    * Store
+    *
+    * Store the param on the database
+    * @param Glossary $glossary
+    */
+    function store(Glossary $glossary){
+
+    }
+
+    /**
+    * Search
+    *
+    * Store the param on the database
+    * @param Glossary $glossary
+    */
+    function search(){
+
+    }
+
+    /**
+    * Show
+    *
+    * Render one register
+    *
+    * @param Glossary $glossary
+    */
+    function show(Glossary $glossary){
+
+    }
+
+    /**
+    * Edit
+    *
+    * Render the formular for a database Glossary
+    *
+    * @param Glossary $glossary
+    */
+    function edit(Glossary $glossary){
+        Output::render('form', $glossary);
+    }
+
+    /**
+    * Update
+    * Store the changes of the param on the database
+    *
+    * @param Glossary $glossary
+    */
+    function update(Glossary $glossary){
+
+    }
+
+    /**
+    * Destroy
+    * If the object has soft delete.
+    *
+    * @param Glossary $glossary
+    */
+    function destroy(Glossary $glossary){
+
+    }
+
+    /**
+    * Purge
+    * Remove object even with soft delete.
+    *
+    * @param Glossary $glossary
+    */
+    function purge(Glossary $glossary){
+
+    }
+}

+ 22 - 0
app/common/glossary/Routes.php

@@ -0,0 +1,22 @@
+<?php
+
+use App\Core\Template\Output as Output;
+use Routes\RouteCollection as RouteCollection;
+
+//Menu itens
+RouteCollection::get('*', function() {
+    Output::addOnSubmenu('config', '/glossary', 'glossary', icon('cubes'), ['class' => 'nav-link']);
+}, -10)->doIgnore();
+
+RouteCollection::group("/glossary", function(){
+    RouteCollection::get   ("/",            "\App\Common\Glossary\GlossaryController@index");
+    RouteCollection::get   ("/table",       "\App\Common\Glossary\GlossaryController@table");
+    RouteCollection::post  ("/table",       "\App\Common\Glossary\GlossaryController@searchTable");
+    RouteCollection::get   ("/form",        "\App\Common\Glossary\GlossaryController@create");
+    RouteCollection::post  ("/",            "\App\Common\Glossary\GlossaryController@store");
+    RouteCollection::post  ("/search",      "\App\Common\Glossary\GlossaryController@search");
+    RouteCollection::get   ("/[i:id]",      "\App\Common\Glossary\GlossaryController@show");
+    RouteCollection::get   ("/[i:id]/edit", "\App\Common\Glossary\GlossaryController@edit");
+    RouteCollection::put   ("/[i:id]/edit", "\App\Common\Glossary\GlossaryController@update");
+    RouteCollection::delete("/[i:id]",      "\App\Common\Glossary\GlossaryController@destroy");
+});

+ 49 - 0
app/common/glossary/classes/Glossary.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Common\Glossary\Classes;
+
+use ORM\Entity as Entity;
+
+class Glossary extends Entity {
+
+    //const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
+
+    const _tableName = "glossarys";
+
+    /*const _properties = Array(
+        "id"   => ['listable' => true,  'searcheble' => false, 'orderable' => false],
+        "name" => ['listable' => true,  'searcheble' => true]);
+    */
+
+    const _properties = Array(
+        'id',
+        'name',
+        'description'
+    );
+
+    /*protected $_ignore = Array(
+
+    );*/
+
+    const _listable = Array(
+        'id',
+        'name'
+    );
+
+    const _searchable = Array(
+        'name'
+    );
+
+    const _orderable = Array(
+
+    );
+
+    /*const _datatables = Array(
+
+    );*/
+
+    //const _timestamps = true;
+    //const _softdelete = true;
+
+    //const _connectionName = "";
+}

+ 36 - 0
app/common/glossary/db/Migrate.php

@@ -0,0 +1,36 @@
+<?php
+
+use Schema\Wrapper as Wrapper;
+use App\Core\Sanity\MigratorController as Migrator;
+
+//https://book.cakephp.org/phinx/0/en/migrations.html#valid-column-types
+function common_glossary_upgrade($pluginversion) {
+    if ($pluginversion < "0.0.1") {
+        $table = Wrapper::get_table("common_glossarys");
+        $table->addColumn("area_id",     "integer", Array("null" => false));
+        $table->addColumn("name",        "string", Array("null" => false));
+        $table->addColumn("description", "text",   Array("null" => true));
+        //$table->addColumn("time", "timestamp", Array("null" => true, "default"=>null));
+
+        $table->addTimestamps();
+        $table->addSoftDelete();
+        $table->create();
+
+        Migrator::getInstance()->update_plugin_version("common_glossary", "1.0.0");
+        return;
+    }
+
+    //if ($pluginversion < "0.0.2") {
+        //$table = Wrapper::get_table("common_glossarys");
+        //Migrator::getInstance()->update_plugin_version("common_glossary", "1.0.1");
+        //return;
+    //}
+}
+
+function common_glossary_rollback($pluginversion) {
+    if($pluginversion > "0.0.1"){
+        $table = Wrapper::get_table("common_glossarys");
+        $table->drop();
+        return;
+    }
+}

+ 2 - 0
app/common/glossary/lang/en.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["glossary"]["module_name"] = "Glossary";

+ 2 - 0
app/common/glossary/lang/pt_br.php

@@ -0,0 +1,2 @@
+<?php
+    $lang["glossary"]["module_name"] = "Glossary";

+ 0 - 0
app/common/glossary/todo.md


+ 6 - 0
app/common/glossary/version.php

@@ -0,0 +1,6 @@
+<?php
+
+$plugin->name = "common_glossary";
+$plugin->version = "0.0.0";
+
+//$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] );

+ 86 - 0
app/common/glossary/views/form.mustache

@@ -0,0 +1,86 @@
+{{#id}}
+<form method="POST" action="/glossary/{{id}}/edit">
+   <input type="hidden" name="id" value="{{id}}" />
+   <input type="hidden" name="_method" value="put" />
+{{/id}}
+{{^id}}
+<form method="POST" action="/glossary">
+   <input type="hidden" name="id" value="" />
+{{/id}}
+    <div class='row'>
+        <div class="col-md-8 col-xs-12 g-3">
+            <div class="card">
+                <div class="card-header">Header</div>
+                <div class="card-body">
+                    <div class="row g-3">
+                        <div class="col-xs-12 col-3">
+                            <label class="form-label">Código</label>
+                            <input type="text" class="form-control" name='code' value="{{code}}">
+                        </div>
+                        <div class="col-xs-12 col-9">
+                            <label class="form-label">Nome</label>
+                            <input type="text" class="form-control" name='name' value="{{name}}">
+                        </div>
+                    </div>
+
+                    <div class="row">
+                        <div class="col-xs-12 g-3">
+                            <label class="form-label">Descrição</label>
+                            <textarea class="form-control" name="descricao">{{description}}</textarea>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="col-md-4 col-xs-12 g-3">
+            <div class="card">
+                <div class="card-header">Header</div>
+                <div class="card-body">
+                    <div class="row g-3">
+                        <div class="col-xs-12 col-3">
+                            <label class="form-label">Código</label>
+                            <input type="text" class="form-control" name='code' value="{{code}}">
+                        </div>
+                        <div class="col-xs-12 col-9">
+                            <label class="form-label">Nome</label>
+                            <input type="text" class="form-control" name='name' value="{{name}}">
+                        </div>
+                    </div>
+
+                    <div class="row">
+                        <div class="col-xs-12 g-3">
+                            <label class="form-label">Descrição</label>
+                            <textarea class="form-control" name="descricao">{{description}}</textarea>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class='row'>
+        <div class="col-md-8 col-xs-12 g-3">
+            <div class="card">
+                <div class="card-header">Header</div>
+                <div class="card-body">
+                    <div class="row g-3">
+                        <div class="col-xs-12 col-3">
+                            <label class="form-label">Código</label>
+                            <input type="text" class="form-control" name='code' value="{{code}}">
+                        </div>
+                        <div class="col-xs-12 col-9">
+                            <label class="form-label">Nome</label>
+                            <input type="text" class="form-control" name='name' value="{{name}}">
+                        </div>
+                    </div>
+
+                    <div class="row">
+                        <div class="col-xs-12 g-3">
+                            <label class="form-label">Descrição</label>
+                            <textarea class="form-control" name="descricao">{{description}}</textarea>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</form>

+ 2 - 0
app/common/glossary/views/index.mustache

@@ -0,0 +1,2 @@
+<a href='/glossary/form' >Adicionar </a>
+<div class="table-responsive remote-datatable" data-source="/glossary/table?selective=true"></div>