Common functionalities
This commit is contained in:
@@ -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){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
});
|
||||
@@ -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 = "";
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["glossary"]["module_name"] = "Glossary";
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["glossary"]["module_name"] = "Glossary";
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$plugin->name = "common_glossary";
|
||||
$plugin->version = "0.0.0";
|
||||
|
||||
//$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] );
|
||||
@@ -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>
|
||||
@@ -0,0 +1,2 @@
|
||||
<a href='/glossary/form' >Adicionar </a>
|
||||
<div class="table-responsive remote-datatable" data-source="/glossary/table?selective=true"></div>
|
||||
Reference in New Issue
Block a user