Common functionalities

This commit is contained in:
ahwelp
2023-01-24 20:35:43 +00:00
parent 1012e09995
commit d821c32013
43 changed files with 1278 additions and 0 deletions
+111
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -0,0 +1,2 @@
<?php
$lang["files"]["module_name"] = "Files";
+2
View File
@@ -0,0 +1,2 @@
<?php
$lang["files"]["module_name"] = "Files";
+6
View File
@@ -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
View File
@@ -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
View File
@@ -0,0 +1,4 @@
<a href='/files/form' >Adicionar </a>
<div class="table-responsive">
</div>