First Commit
This commit is contained in:
Executable
+9
@@ -0,0 +1,9 @@
|
||||
SysCMS Commercial License
|
||||
|
||||
Copyright (c) 2026 Marco Costa. All rights reserved.
|
||||
|
||||
This software is licensed, not sold. Permission is granted to use this software subject to the terms of the SysCMS Commercial License.
|
||||
|
||||
Redistribution, sublicensing, resale, or disclosure of this software, in whole or in part, is strictly prohibited without prior written permission from the author.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
# Modelo Module for SysCMS
|
||||
|
||||
Template and model management module.
|
||||
|
||||
## Features
|
||||
- Template creation and editing
|
||||
- Model-based content generation
|
||||
- Layout management
|
||||
- Custom fields
|
||||
- Preview system
|
||||
|
||||
## Installation
|
||||
1. Upload the `modelo.zip` file through the module manager or extract it to the `modules/` directory.
|
||||
2. Run the migrations to register the module.
|
||||
3. Configure template settings in the admin panel.
|
||||
|
||||
## Routes
|
||||
- Web routes: `routes/web.php`
|
||||
|
||||
## License
|
||||
Copyright (c) 2026 Marco Costa. All rights reserved.
|
||||
Licensed under the SysCMS Commercial License.
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Modelo\Controllers;
|
||||
|
||||
use App\Controllers\BaseAdminController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Modules\Modelo\Models\Modelo;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ModeloController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* List all Modelos for the current company
|
||||
*/
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
if (!$user || !$user->hasPermission('modelo.view')) {
|
||||
return new Response($this->view->render('components/alerts.twig', [
|
||||
'type' => 'danger',
|
||||
'message' => 'Access denied.'
|
||||
]), 403);
|
||||
}
|
||||
|
||||
$modelos = Modelo::orderBy('modelos_order', 'asc')->get();
|
||||
|
||||
return $this->renderAdminView('@modelo/admin/index.twig', [
|
||||
'page_title' => 'Gerenciamento de Modelo',
|
||||
'modelos' => $modelos
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show create form
|
||||
*/
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
if (!$user || !$user->hasPermission('modelo.manage')) {
|
||||
return new Response('Access denied', 403);
|
||||
}
|
||||
|
||||
return $this->renderAdminView('@modelo/admin/form.twig', [
|
||||
'page_title' => 'Novo Modelo',
|
||||
'action' => 'create'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new Modelo
|
||||
*/
|
||||
public function store(Request $request): Response
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
if (!$user || !$user->hasPermission('modelo.manage')) {
|
||||
return new Response('Access denied', 403);
|
||||
}
|
||||
|
||||
$data = $request->request->all();
|
||||
|
||||
$modelo = new Modelo();
|
||||
// Handle potential null bus_id for Super Admins
|
||||
$busId = $user->users_bus_id;
|
||||
if (empty($busId)) {
|
||||
$busId = $_SESSION['current_company_id'] ?? 1;
|
||||
}
|
||||
$modelo->modelos_bus_id = $busId;
|
||||
$modelo->modelos_title = $data['title'];
|
||||
$modelo->modelos_slug = !empty($data['slug']) ? Str::slug($data['slug']) : Str::slug($data['title']);
|
||||
$modelo->modelos_content = $data['content'];
|
||||
$modelo->modelos_order = (int) ($data['order'] ?? 0);
|
||||
$modelo->modelos_active = isset($data['active']);
|
||||
$modelo->modelos_visibility = $data['visibility'] ?? 'public';
|
||||
|
||||
$modelo->save();
|
||||
|
||||
return new RedirectResponse(url('admin/modelo?success=created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show edit form
|
||||
*/
|
||||
public function edit(Request $request, $id): Response
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
if (!$user || !$user->hasPermission('modelo.manage')) {
|
||||
return new Response('Access denied', 403);
|
||||
}
|
||||
|
||||
$modelo = Modelo::find($id);
|
||||
if (!$modelo) {
|
||||
return new Response('Modelo not found', 404);
|
||||
}
|
||||
|
||||
return $this->renderAdminView('@modelo/admin/form.twig', [
|
||||
'page_title' => 'Editar Modelo',
|
||||
'modelo' => $modelo,
|
||||
'action' => 'edit'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Modelo
|
||||
*/
|
||||
public function update(Request $request, $id): Response
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
if (!$user || !$user->hasPermission('modelo.manage')) {
|
||||
return new Response('Access denied', 403);
|
||||
}
|
||||
|
||||
$modelo = Modelo::find($id);
|
||||
if (!$modelo) {
|
||||
return new Response('Modelo not found', 404);
|
||||
}
|
||||
|
||||
$data = $request->request->all();
|
||||
|
||||
$modelo->modelos_title = $data['title'];
|
||||
$modelo->modelos_slug = !empty($data['slug']) ? Str::slug($data['slug']) : Str::slug($data['title']);
|
||||
$modelo->modelos_content = $data['content'];
|
||||
$modelo->modelos_order = (int) ($data['order'] ?? 0);
|
||||
$modelo->modelos_active = isset($data['active']);
|
||||
$modelo->modelos_visibility = $data['visibility'] ?? 'public';
|
||||
|
||||
$modelo->save();
|
||||
|
||||
return new RedirectResponse(url('admin/modelo?success=updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Modelo
|
||||
*/
|
||||
public function delete(Request $request, $id): Response
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
if (!$user || !$user->hasPermission('modelo.manage')) {
|
||||
return new Response('Access denied', 403);
|
||||
}
|
||||
|
||||
$modelo = Modelo::find($id);
|
||||
if ($modelo) {
|
||||
$modelo->delete();
|
||||
}
|
||||
|
||||
return new RedirectResponse(url('admin/modelo?success=deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* User Manual
|
||||
*/
|
||||
public function manual(Request $request): Response
|
||||
{
|
||||
return $this->renderAdminView('@modelo/admin/manual.twig', [
|
||||
'title' => 'Manual do Usuário - Módulo Modelo'
|
||||
]);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Modelo\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\Modelo\Models\Modelo;
|
||||
|
||||
class PublicController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Show public Modelos for Company 1
|
||||
*/
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
// Define a constant to bypass the company scope if needed
|
||||
if (!defined('PUBLIC_MODELO_ACCESS')) {
|
||||
define('PUBLIC_MODELO_ACCESS', true);
|
||||
}
|
||||
|
||||
$query = Modelo::where('modelos_active', true);
|
||||
|
||||
// Check visibility logic
|
||||
$canViewPrivate = false;
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$canViewPrivate = true;
|
||||
}
|
||||
|
||||
if (!$canViewPrivate) {
|
||||
$query->where('modelos_visibility', 'public');
|
||||
}
|
||||
|
||||
$modelos = $query->orderBy('modelos_order', 'asc')->get();
|
||||
|
||||
return $this->renderView('@modelo/public/index.twig', [
|
||||
'page_title' => 'Nossos Modelos',
|
||||
'modelos' => $modelos
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a single Modelo by slug
|
||||
*/
|
||||
public function show(Request $request, string $slug): Response
|
||||
{
|
||||
if (!defined('PUBLIC_MODELO_ACCESS')) {
|
||||
define('PUBLIC_MODELO_ACCESS', true);
|
||||
}
|
||||
|
||||
$modelo = Modelo::where('modelos_slug', $slug)
|
||||
->where('modelos_active', true)
|
||||
->first();
|
||||
|
||||
if (!$modelo) {
|
||||
return new Response('Modelo não encontrado', 404);
|
||||
}
|
||||
|
||||
// Replace placeholders
|
||||
$content = $modelo->modelos_content;
|
||||
$content = str_replace('[site_name]', $_SESSION['bus_name'] ?? 'SysCMS', $content);
|
||||
$content = str_replace('[current_date]', date('d/m/Y'), $content);
|
||||
$content = str_replace('[contact_email]', $_SESSION['bus_email'] ?? 'contato@syscms.com', $content);
|
||||
|
||||
return $this->renderView('@modelo/public/show.twig', [
|
||||
'page_title' => $modelo->modelos_title,
|
||||
'modelo' => $modelo,
|
||||
'content' => $content
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Modelo\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Modules\Company\Models\Company;
|
||||
|
||||
class Modelo extends Model
|
||||
{
|
||||
protected $table = 'modelos';
|
||||
protected $primaryKey = 'modelos_id';
|
||||
|
||||
protected $fillable = [
|
||||
'modelos_bus_id',
|
||||
'modelos_title',
|
||||
'modelos_slug',
|
||||
'modelos_content',
|
||||
'modelos_order',
|
||||
'modelos_active',
|
||||
'modelos_visibility'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'modelos_active' => 'boolean',
|
||||
'modelos_order' => 'integer'
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::addGlobalScope('company', function (Builder $builder) {
|
||||
if (isset($_SESSION['user_idbus']) && !defined('PUBLIC_MODELO_ACCESS')) {
|
||||
$builder->where('modelos_bus_id', $_SESSION['user_idbus']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class, 'modelos_bus_id', 'bus_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Modelo\Providers;
|
||||
|
||||
use Kernel\Application;
|
||||
|
||||
class ModeloServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
$app = Application::getInstance();
|
||||
$app->addPublicPath('/modelo*');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateModelosTable
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (!Capsule::schema()->hasTable('modelos')) {
|
||||
Capsule::schema()->create('modelos', function (Blueprint $table) {
|
||||
$table->increments('modelos_id');
|
||||
$table->integer('modelos_bus_id')->default(0)->index();
|
||||
$table->string('modelos_title', 255);
|
||||
$table->text('modelos_content');
|
||||
$table->integer('modelos_order')->default(0);
|
||||
$table->boolean('modelos_active')->default(true);
|
||||
$table->string('modelos_visibility')->default('public');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Capsule::schema()->dropIfExists('modelos');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use App\Models\Module;
|
||||
|
||||
class InsertModeloModule
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$moduleData = [
|
||||
'modules_name' => 'modelo',
|
||||
'modules_display_name' => 'Modelo (Template)',
|
||||
'modules_description' => 'Módulo modelo para criação de novos módulos',
|
||||
'modules_version' => '1.0.0',
|
||||
'modules_author' => 'SysCMS Team',
|
||||
'modules_ative' => true,
|
||||
'modules_public' => true,
|
||||
'modules_blocked' => false,
|
||||
'modules_dependencies' => [],
|
||||
'modules_permissions' => [
|
||||
"modelo.view",
|
||||
"modelo.manage"
|
||||
],
|
||||
'modules_settings' => [
|
||||
"menu" => [
|
||||
"dashboard" => [
|
||||
"icon" => "bi bi-box",
|
||||
"label" => "Modelo",
|
||||
"route" => "admin/modelo",
|
||||
"order" => 99,
|
||||
"permission" => "modelo.view"
|
||||
]
|
||||
]
|
||||
],
|
||||
'modules_path' => 'modules/modelo',
|
||||
'modules_namespace' => 'Modules\\Modelo',
|
||||
'modules_icon' => 'bi bi-box',
|
||||
'menu_side_bar' => true,
|
||||
'menu_nav_bar' => false,
|
||||
'modules_order' => 99,
|
||||
'modules_install_date' => date('Y-m-d H:i:s'),
|
||||
'modules_update_date' => date('Y-m-d H:i:s')
|
||||
];
|
||||
|
||||
$existingModule = Module::where('modules_name', 'modelo')->first();
|
||||
|
||||
if (!$existingModule) {
|
||||
$module = Module::create($moduleData);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$module = Module::where('modules_name', 'modelo')->first();
|
||||
if ($module) {
|
||||
Capsule::table('bus_modules')->where('bus_modules_module_id', $module->modules_id)->delete();
|
||||
$module->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AddSlugToModelosTable
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (Capsule::schema()->hasTable('modelos')) {
|
||||
if (!Capsule::schema()->hasColumn('modelos', 'modelos_slug')) {
|
||||
Capsule::schema()->table('modelos', function (Blueprint $table) {
|
||||
$table->string('modelos_slug', 255)->nullable()->after('modelos_title');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if (Capsule::schema()->hasTable('modelos')) {
|
||||
if (Capsule::schema()->hasColumn('modelos', 'modelos_slug')) {
|
||||
Capsule::schema()->table('modelos', function (Blueprint $table) {
|
||||
$table->dropColumn('modelos_slug');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"menu": {
|
||||
"dashboard": "Modell"
|
||||
},
|
||||
"title": "Modell",
|
||||
"management": "Modellverwaltung",
|
||||
"new_modelo": "Neues Modell",
|
||||
"edit_modelo": "Modell bearbeiten",
|
||||
"item_title": "Titel",
|
||||
"item_content": "Inhalt",
|
||||
"order": "Reihenfolge",
|
||||
"active": "Aktiv",
|
||||
"save": "Speichern",
|
||||
"cancel": "Abbrechen",
|
||||
"delete": "Löschen",
|
||||
"confirm_delete": "Sind Sie sicher, dass Sie löschen möchten?",
|
||||
"visibility": "Sichtbarkeit",
|
||||
"public": "Öffentlich",
|
||||
"private": "Privat",
|
||||
"status": "Status",
|
||||
"inactive": "Inaktiv",
|
||||
"actions": "Aktionen",
|
||||
"operation_success": "Vorgang erfolgreich.",
|
||||
"no_items": "Keine Elemente gefunden."
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"menu": {
|
||||
"dashboard": "Model"
|
||||
},
|
||||
"title": "Model",
|
||||
"management": "Model Management",
|
||||
"new_modelo": "New Model",
|
||||
"edit_modelo": "Edit Model",
|
||||
"item_title": "Title",
|
||||
"item_content": "Content",
|
||||
"order": "Order",
|
||||
"active": "Active",
|
||||
"save": "Save",
|
||||
"cancel": "Cancel",
|
||||
"delete": "Delete",
|
||||
"confirm_delete": "Are you sure you want to delete?",
|
||||
"visibility": "Visibility",
|
||||
"public": "Public",
|
||||
"private": "Private",
|
||||
"status": "Status",
|
||||
"inactive": "Inactive",
|
||||
"actions": "Actions",
|
||||
"operation_success": "Operation successful.",
|
||||
"no_items": "No items found."
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"menu": {
|
||||
"dashboard": "Modelo"
|
||||
},
|
||||
"title": "Modelo",
|
||||
"management": "Gestión de Modelo",
|
||||
"new_modelo": "Nuevo Modelo",
|
||||
"edit_modelo": "Editar Modelo",
|
||||
"item_title": "Título",
|
||||
"item_content": "Contenido",
|
||||
"order": "Orden",
|
||||
"active": "Activo",
|
||||
"save": "Guardar",
|
||||
"cancel": "Cancelar",
|
||||
"delete": "Eliminar",
|
||||
"confirm_delete": "¿Está seguro de que desea eliminar?",
|
||||
"visibility": "Visibilidad",
|
||||
"public": "Público",
|
||||
"private": "Privado",
|
||||
"status": "Estado",
|
||||
"inactive": "Inactivo",
|
||||
"actions": "Acciones",
|
||||
"operation_success": "Operación exitosa.",
|
||||
"no_items": "No se encontraron elementos."
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"menu": {
|
||||
"dashboard": "Modèle"
|
||||
},
|
||||
"title": "Modèle",
|
||||
"management": "Gestion de Modèle",
|
||||
"new_modelo": "Nouveau Modèle",
|
||||
"edit_modelo": "Modifier le Modèle",
|
||||
"item_title": "Titre",
|
||||
"item_content": "Contenu",
|
||||
"order": "Ordre",
|
||||
"active": "Actif",
|
||||
"save": "Enregistrer",
|
||||
"cancel": "Annuler",
|
||||
"delete": "Supprimer",
|
||||
"confirm_delete": "Êtes-vous sûr de vouloir supprimer ?",
|
||||
"visibility": "Visibilité",
|
||||
"public": "Public",
|
||||
"private": "Privé",
|
||||
"status": "Statut",
|
||||
"inactive": "Inactif",
|
||||
"actions": "Actions",
|
||||
"operation_success": "Opération réussie.",
|
||||
"no_items": "Aucun élément trouvé."
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"menu": {
|
||||
"dashboard": "Modelo"
|
||||
},
|
||||
"title": "Modelo",
|
||||
"management": "Gerenciamento de Modelo",
|
||||
"new_modelo": "Novo Modelo",
|
||||
"edit_modelo": "Editar Modelo",
|
||||
"item_title": "Título",
|
||||
"item_content": "Conteúdo",
|
||||
"order": "Ordem",
|
||||
"active": "Ativo",
|
||||
"save": "Salvar",
|
||||
"cancel": "Cancelar",
|
||||
"delete": "Excluir",
|
||||
"confirm_delete": "Tem certeza que deseja excluir?",
|
||||
"visibility": "Visibilidade",
|
||||
"public": "Público",
|
||||
"private": "Privado",
|
||||
"status": "Status",
|
||||
"inactive": "Inativo",
|
||||
"actions": "Ações",
|
||||
"operation_success": "Operação realizada com sucesso.",
|
||||
"no_items": "Nenhum item encontrado."
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
Executable
+39
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "modelo",
|
||||
"display_name": "Modelo (Template)",
|
||||
"description": "Módulo modelo para criação de novos módulos",
|
||||
"version": "1.0.0",
|
||||
"author": "SysCMS Team",
|
||||
"dependencies": [],
|
||||
"permissions": [
|
||||
"modelo.view",
|
||||
"modelo.manage"
|
||||
],
|
||||
"settings": [],
|
||||
"menu": {
|
||||
"dashboard": {
|
||||
"icon": "bi bi-box",
|
||||
"label": "modelo.menu.dashboard",
|
||||
"route": "admin/modelo",
|
||||
"order": 99,
|
||||
"permission": "modelo.view"
|
||||
}
|
||||
},
|
||||
"providers": [
|
||||
"Modules\\Modelo\\Providers\\ModeloServiceProvider"
|
||||
],
|
||||
"routes": {
|
||||
"web": "routes/web.php"
|
||||
},
|
||||
"views": "views",
|
||||
"locales": "locales",
|
||||
"module_ative": true,
|
||||
"module_public": true,
|
||||
"module_blocked": false,
|
||||
"menu_side_bar": true,
|
||||
"menu_nav_bar": false,
|
||||
"ready": true,
|
||||
"tables": [
|
||||
"modelos"
|
||||
]
|
||||
}
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use Kernel\Application;
|
||||
|
||||
return function (Application $app) {
|
||||
// Admin Routes
|
||||
$app->addRoute('GET', '/admin/modelo', [\Modules\Modelo\Controllers\ModeloController::class, 'index']);
|
||||
$app->addRoute('GET', '/admin/modelo/create', [\Modules\Modelo\Controllers\ModeloController::class, 'create']);
|
||||
$app->addRoute('POST', '/admin/modelo/store', [\Modules\Modelo\Controllers\ModeloController::class, 'store']);
|
||||
$app->addRoute('GET', '/admin/modelo/edit/{id}', [\Modules\Modelo\Controllers\ModeloController::class, 'edit']);
|
||||
$app->addRoute('POST', '/admin/modelo/update/{id}', [\Modules\Modelo\Controllers\ModeloController::class, 'update']);
|
||||
$app->addRoute('GET', '/admin/modelo/delete/{id}', [\Modules\Modelo\Controllers\ModeloController::class, 'delete']);
|
||||
$app->addRoute('GET', '/admin/modelo/manual', [\Modules\Modelo\Controllers\ModeloController::class, 'manual']);
|
||||
|
||||
// Public Routes
|
||||
$app->addRoute('GET', '/modelo', [\Modules\Modelo\Controllers\PublicController::class, 'index']);
|
||||
$app->addRoute('GET', '/modelo/{slug}', [\Modules\Modelo\Controllers\PublicController::class, 'show']);
|
||||
|
||||
// Install/Migrate Route (Temporary)
|
||||
$app->addRoute('GET', '/admin/modelo/install', function () {
|
||||
try {
|
||||
// Create Table
|
||||
if (!\Illuminate\Database\Capsule\Manager::schema()->hasTable('modelos')) {
|
||||
\Illuminate\Database\Capsule\Manager::schema()->create('modelos', function ($table) {
|
||||
$table->increments('modelos_id');
|
||||
$table->integer('modelos_bus_id')->default(0)->index();
|
||||
$table->string('modelos_title', 255);
|
||||
$table->text('modelos_content');
|
||||
$table->integer('modelos_order')->default(0);
|
||||
$table->boolean('modelos_active')->default(true);
|
||||
$table->string('modelos_visibility')->default('public');
|
||||
$table->timestamps();
|
||||
});
|
||||
echo "Table 'modelos' created.<br>";
|
||||
} else {
|
||||
echo "Table 'modelos' already exists.<br>";
|
||||
}
|
||||
|
||||
// Register Module
|
||||
$module = \App\Models\Module::where('modules_name', 'modelo')->first();
|
||||
if (!$module) {
|
||||
$newModule = \App\Models\Module::create([
|
||||
'modules_name' => 'modelo',
|
||||
'modules_display_name' => 'Modelo (Template)',
|
||||
'modules_description' => 'Módulo modelo para criação de novos módulos',
|
||||
'modules_version' => '1.0.0',
|
||||
'modules_author' => 'SysCMS Team',
|
||||
'modules_ative' => true,
|
||||
'modules_public' => true,
|
||||
'modules_blocked' => false,
|
||||
'modules_dependencies' => [],
|
||||
'modules_permissions' => ["modelo.view", "modelo.manage"],
|
||||
'modules_settings' => [
|
||||
"menu" => [
|
||||
"dashboard" => [
|
||||
"icon" => "bi bi-box",
|
||||
"label" => "Modelo",
|
||||
"route" => "admin/modelo",
|
||||
"order" => 99,
|
||||
"permission" => "modelo.view"
|
||||
]
|
||||
]
|
||||
],
|
||||
'modules_path' => 'modules/modelo',
|
||||
'modules_namespace' => 'Modules\\Modelo',
|
||||
'modules_icon' => 'bi bi-box',
|
||||
'menu_side_bar' => true,
|
||||
'menu_nav_bar' => false,
|
||||
'modules_order' => 99
|
||||
]);
|
||||
|
||||
// Add to companies
|
||||
if (\Illuminate\Database\Capsule\Manager::schema()->hasTable('bus')) {
|
||||
$companies = \Modules\Company\Models\Company::all();
|
||||
foreach ($companies as $company) {
|
||||
\Illuminate\Database\Capsule\Manager::table('bus_modules')->insert([
|
||||
'bus_modules_bus_id' => $company->bus_id,
|
||||
'bus_modules_module_id' => $newModule->modules_id,
|
||||
'bus_modules_is_enabled' => true,
|
||||
'bus_modules_settings' => json_encode([]),
|
||||
'bus_modules_enabled_by' => 1,
|
||||
'bus_modules_enabled_at' => date('Y-m-d H:i:s'),
|
||||
'bus_modules_show_public_nav' => true,
|
||||
'bus_modules_show_dashboard_nav' => true,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
echo "Module 'modelo' registered.<br>";
|
||||
} else {
|
||||
echo "Module 'modelo' already registered.<br>";
|
||||
}
|
||||
|
||||
echo "Installation completed. <a href='/admin/dashboard'>Go to Dashboard</a>";
|
||||
} catch (\Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . " <a href='/admin/dashboard'>Go to Dashboard</a>";
|
||||
}
|
||||
});
|
||||
};
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
{% extends "layouts/dashboard.twig" %}
|
||||
|
||||
{% block title %}{{ page_title }} - {{ platformName }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">{{ page_title }}</h1>
|
||||
<ol class="breadcrumb mb-4">
|
||||
<li class="breadcrumb-item"><a href="{{ url('admin/dashboard') }}">{{ __('dashboard.title') }}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ url('admin/modelo') }}">{{ __('modelo.management') }}</a></li>
|
||||
<li class="breadcrumb-item active">{{ page_title }}</li>
|
||||
</ol>
|
||||
|
||||
{% include '@modelo/admin/nav.twig' ignore missing %}
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<i class="bi bi-pencil-square me-1"></i>
|
||||
{{ page_title }}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ action == 'create' ? url('admin/modelo/store') : url('admin/modelo/update/' ~ modelo.modelos_id) }}" method="POST">
|
||||
{{ csrf_field()|raw }}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="title" class="form-label">{{ __('modelo.item_title') }}</label>
|
||||
<input type="text" class="form-control" id="title" name="title" value="{{ modelo.modelos_title }}" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="slug" class="form-label">URL Amigável (Slug)</label>
|
||||
<input type="text" class="form-control" id="slug" name="slug" value="{{ modelo.modelos_slug }}" placeholder="deixe em branco para gerar automaticamente">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">{{ __('modelo.item_content') }}</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="10" required>{{ modelo.modelos_content }}</textarea>
|
||||
<div class="form-text">Dica: Use <code>[site_name]</code>, <code>[current_date]</code> ou <code>[contact_email]</code> como variáveis dinâmicas.</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="order" class="form-label">{{ __('modelo.order') }}</label>
|
||||
<input type="number" class="form-control" id="order" name="order" value="{{ modelo.modelos_order ?? 0 }}">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="visibility" class="form-label">{{ __('modelo.visibility') }}</label>
|
||||
<select class="form-select" id="visibility" name="visibility">
|
||||
<option value="public" {{ (modelo.modelos_visibility == 'public') ? 'selected' : '' }}>{{ __('modelo.public') }}</option>
|
||||
<option value="private" {{ (modelo.modelos_visibility == 'private') ? 'selected' : '' }}>{{ __('modelo.private') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">{{ __('modelo.status') }}</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="active" name="active" value="1" {{ (action == 'create' or modelo.modelos_active) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="active">
|
||||
{{ __('modelo.active') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">{{ __('modelo.save') }}</button>
|
||||
<a href="{{ url('admin/modelo') }}" class="btn btn-secondary">{{ __('modelo.cancel') }}</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
{% extends "layouts/dashboard.twig" %}
|
||||
|
||||
{% block title %}{{ page_title }} - {{ platformName }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">{{ page_title }}</h1>
|
||||
<ol class="breadcrumb mb-4">
|
||||
<li class="breadcrumb-item"><a href="{{ url('admin/modelo') }}">{{ __('modelo.management') }}</a></li>
|
||||
<li class="breadcrumb-item active">{{ page_title }}</li>
|
||||
</ol>
|
||||
|
||||
{% include '@modelo/admin/nav.twig' ignore missing %}
|
||||
|
||||
{% if request.get('success') %}
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ __('modelo.operation_success') }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<i class="bi bi-box me-1"></i>
|
||||
{{ __('modelo.title') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('modelo.order') }}</th>
|
||||
<th>{{ __('modelo.item_title') }}</th>
|
||||
<th>{{ __('modelo.visibility') }}</th>
|
||||
<th>{{ __('modelo.status') }}</th>
|
||||
<th>{{ __('modelo.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in modelos %}
|
||||
<tr>
|
||||
<td>{{ item.modelos_order }}</td>
|
||||
<td>{{ item.modelos_title }}</td>
|
||||
<td>
|
||||
{% if item.modelos_visibility == 'public' %}
|
||||
<span class="badge bg-primary">{{ __('modelo.public') }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-dark">{{ __('modelo.private') }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if item.modelos_active %}
|
||||
<span class="badge bg-success">{{ __('modelo.active') }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">{{ __('modelo.inactive') }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ url('admin/modelo/edit/' ~ item.modelos_id) }}" class="btn btn-sm btn-info text-white"><i class="bi bi-pencil"></i></a>
|
||||
<a href="{{ url('admin/modelo/delete/' ~ item.modelos_id) }}" class="btn btn-sm btn-danger" onclick="return confirm('{{ __('modelo.confirm_delete') }}')"><i class="bi bi-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">{{ __('modelo.no_items') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
{% extends "layouts/dashboard.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">{{ title }}</h1>
|
||||
<ol class="breadcrumb mb-4">
|
||||
<li class="breadcrumb-item"><a href="{{ url('admin/dashboard') }}">{{ __('dashboard.title') }}</a></li>
|
||||
<li class="breadcrumb-item active">Módulo Modelo</li>
|
||||
</ol>
|
||||
|
||||
{% include '@modelo/admin/nav.twig' ignore missing %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3 d-none d-lg-block">
|
||||
<div class="list-group sticky-top" style="top: 100px; z-index: 1;">
|
||||
<a href="#visao-geral" class="list-group-item list-group-item-action">Visão Geral</a>
|
||||
<a href="#templates" class="list-group-item list-group-item-action">Gerenciar Templates</a>
|
||||
<a href="#placeholders" class="list-group-item list-group-item-action">Placeholders Dinâmicos</a>
|
||||
<a href="#visibilidade" class="list-group-item list-group-item-action">Visibilidade e Ordem</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-9">
|
||||
<!-- Visão Geral -->
|
||||
<div class="card shadow mb-4" id="visao-geral">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">1. Visão Geral</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>O módulo <strong>Modelo</strong> é uma ferramenta de prototipagem e padronização de conteúdo. Ele permite criar estruturas pré-definidas (templates) que podem ser reutilizadas em todo o sistema, garantindo consistência visual e agilidade na criação de novas páginas.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Templates -->
|
||||
<div class="card shadow mb-4" id="templates">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">2. Gerenciar Templates</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Ao criar um novo modelo, você define o título e o conteúdo base. Esse conteúdo pode incluir HTML rico, estilos e referências que servirão de base para outros módulos ou páginas estáticas.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Placeholders -->
|
||||
<div class="card shadow mb-4" id="placeholders">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">3. Placeholders Dinâmicos</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Você pode usar variáveis nos seus modelos que serão substituídas por dados reais do sistema:</p>
|
||||
<ul>
|
||||
<li><code>[site_name]</code> - Nome da empresa/unidade.</li>
|
||||
<li><code>[current_date]</code> - Data atual formatada.</li>
|
||||
<li><code>[contact_email]</code> - E-mail de contato principal.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Visibilidade -->
|
||||
<div class="card shadow mb-4" id="visibilidade">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">4. Visibilidade e Ordem</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul>
|
||||
<li><strong>Ordem:</strong> Define a sequência de exibição dos modelos em listas de seleção.</li>
|
||||
<li><strong>Público/Privado:</strong> Define se o modelo pode ser acessado por qualquer pessoa ou apenas internamente pela equipe administrativa.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<div class="mb-4 d-print-none">
|
||||
<div class="btn-group" role="group" aria-label="Navegação Modelo">
|
||||
<a href="/admin/modelo" class="btn btn-outline-primary {% if request_path == '/admin/modelo' %}active{% endif %}">
|
||||
<i class="bi bi-grid"></i> Todos os Modelos
|
||||
</a>
|
||||
<a href="/admin/modelo/create" class="btn btn-outline-primary {% if request_path == '/admin/modelo/create' %}active{% endif %}">
|
||||
<i class="bi bi-plus-circle"></i> Novo Modelo
|
||||
</a>
|
||||
<a href="/admin/modelo/manual" class="btn btn-outline-info {% if request_path == '/admin/modelo/manual' %}active{% endif %}">
|
||||
<i class="bi bi-book"></i> Manual
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
{% extends "layouts/main.twig" %}
|
||||
|
||||
{% block title %}{{ page_title }} - {{ platformName }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-10">
|
||||
<h1 class="text-center display-4 mb-5">{{ page_title }}</h1>
|
||||
|
||||
<div class="row g-4">
|
||||
{% for item in modelos %}
|
||||
<div class="col-md-6">
|
||||
<div class="card h-100 shadow-sm border-0 transition-hover">
|
||||
<div class="card-body p-4">
|
||||
<h5 class="card-title fw-bold text-primary mb-3">{{ item.modelos_title }}</h5>
|
||||
<p class="card-text text-muted mb-4">
|
||||
{{ item.modelos_content|striptags|slice(0, 150) }}...
|
||||
</p>
|
||||
<a href="{{ url('/modelo/' ~ item.modelos_slug) }}" class="btn btn-primary w-100">
|
||||
Ver Detalhes <i class="bi bi-arrow-right ms-2"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info text-center py-5">
|
||||
<i class="bi bi-info-circle display-4 d-block mb-3"></i>
|
||||
{{ __('modelo.no_items') }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.transition-hover:hover {
|
||||
transform: translateY(-5px);
|
||||
transition: transform 0.3s ease;
|
||||
box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
{% extends "layouts/main.twig" %}
|
||||
|
||||
{% block title %}{{ page_title }} - {{ platformName }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-10">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{ url('/') }}">Início</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ url('/modelo') }}">Modelos</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ page_title }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<article class="card shadow-sm border-0 mt-4">
|
||||
<div class="card-body p-5">
|
||||
<h1 class="display-4 mb-4">{{ page_title }}</h1>
|
||||
<hr class="my-4">
|
||||
<div class="modelo-content">
|
||||
{{ content|raw }}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<div class="mt-4 text-center">
|
||||
<a href="{{ url('/modelo') }}" class="btn btn-outline-primary">
|
||||
<i class="bi bi-arrow-left"></i> Voltar para a lista
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.modelo-content {
|
||||
line-height: 1.8;
|
||||
font-size: 1.1rem;
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user