This is the snapshot the production landing site (nibiru-framework.com) is deployed from. Brings together the recent splash + docs migration to the v4 "Cosmos" design system, the new in-framework AI module, and the framework groundwork that backs the framework-reference extraction. What lands: - docs/: Astro + Starlight site with the v4 dark cosmic palette, GalaxyHero canvas constellation, Mission Control chat (wired to /api/oracle → api.neuronetz.ai via providers.mjs Ollama), 5-panel MMVC stage (Model · AI · Module · Controller · View), translated EN/DE/JA/ES/FR content, PWA + sitemap + llms.txt + Umami analytics. - docs/design-system/: canonical mockup bundle (source/index-v2.html for splash, source/docs-system.html + preview/ for docs, SPEC.md, tokens). - docs/scripts/extraction/framework-reference-v2.md: deep framework reference (~1.6k lines, file:line citations, every public factory and idiom — basis for the LoRA training corpus. - application/module/ai/: AI module with chat / embed / RAG / agent plugins, plus pdoQuery / httpGet / fileRead tools and Modelfile + smoke-test in training/. - application/module/users/: user / ACL / form-factory traits used as the reference plugin pattern for the framework docs. - application/settings/config/database/: schema + seed migrations including the AI module tables (200–203). - Form factory + autogenerator changes the framework-reference-v2 covers. Production secrets stay out: docs/.env, settings.production.ini and ai.production.ini are all gitignored (.example files are in tree). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
359 lines
10 KiB
PHP
Executable File
359 lines
10 KiB
PHP
Executable File
<?php
|
|
namespace Nibiru\Module\Users\Traits;
|
|
/**
|
|
* Trait UserForm
|
|
* @project src
|
|
* @desc This is a PHP trait file, please specify the use
|
|
* @author stephan - Maschinen Stockert Großhandels GmbH
|
|
* @date 19.04.23
|
|
* @time 15:10
|
|
* @package ${PACKAGE}
|
|
*/
|
|
use Nibiru\Factory\Form;
|
|
use Nibiru\Module\Users\Plugins\Acl;
|
|
trait UserForm
|
|
{
|
|
public static function userForm(string $action = '', array $user = [])
|
|
{
|
|
$acl = new Acl();
|
|
Form::create();
|
|
self::openHalfWidthElement('Benutzer Informationen');
|
|
self::openInnerHalfWithElement();
|
|
foreach(self::FORM_CREATE_USER as $entry)
|
|
{
|
|
if(sizeof($user) > 0)
|
|
{
|
|
self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon'], $user[$entry['valueName']]);
|
|
}
|
|
else
|
|
{
|
|
self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon']);
|
|
}
|
|
}
|
|
foreach(self::FORM_CREATE_PASSWORD as $entry)
|
|
{
|
|
if(sizeof($user) > 0)
|
|
{
|
|
self::addPasswordElement($entry['visibleName'], $entry['valueName'], $entry['icon'], $user['user_pass']);
|
|
}
|
|
else
|
|
{
|
|
self::addPasswordElement($entry['visibleName'], $entry['valueName'], $entry['icon']);
|
|
}
|
|
}
|
|
self::closeHalfWidthElement();
|
|
self::closeHalfWidthElement();
|
|
self::openHalfWidthElement('Konto Informationen');
|
|
self::openInnerHalfWithElement();
|
|
foreach(self::FORM_CREATE_ACCOUNT as $entry)
|
|
{
|
|
if(sizeof($user) > 0)
|
|
{
|
|
self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon'], $user[$entry['valueName']]);
|
|
}
|
|
else
|
|
{
|
|
self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon']);
|
|
}
|
|
}
|
|
|
|
if(sizeof($user) > 0)
|
|
{
|
|
self::addSelectDropdown($acl->loadAclRoles(), 'lock', $user['user_role_id']);
|
|
self::addActiveCheckbox('Konto aktivieren', $user['user_account_active']);
|
|
}
|
|
else
|
|
{
|
|
self::addSelectDropdown($acl->loadAclRoles(), 'lock');
|
|
self::addActiveCheckbox('Konto aktivieren', true);
|
|
}
|
|
self::closeHalfWidthElement();
|
|
if(sizeof($user) > 0)
|
|
{
|
|
self::addHiddenElementEditUser($user);
|
|
self::addSubmitFormButton('Speichern', 'save-alt');
|
|
}
|
|
else
|
|
{
|
|
self::addHiddenElementNewUser();
|
|
self::addSubmitFormButton('Erstellen', 'save-alt');
|
|
}
|
|
|
|
self::closeHalfWidthElement();
|
|
return Form::addForm([
|
|
'name' => 'userForm',
|
|
'action' => $action,
|
|
'class' => 'row',
|
|
'method' => 'post',
|
|
'target' => '_self'
|
|
]);
|
|
}
|
|
private static function addHiddenElementNewUser()
|
|
{
|
|
Form::addTypeHidden([
|
|
'name' => 'user_new',
|
|
'value' => 1
|
|
]);
|
|
Form::addTypeHidden([
|
|
'name' => 'user_active',
|
|
'value' => 1
|
|
]);
|
|
}
|
|
private static function addHiddenElementEditUser(array $user = [])
|
|
{
|
|
Form::addTypeHidden([
|
|
'name' => 'user_edit',
|
|
'value' => 1
|
|
]);
|
|
Form::addTypeHidden([
|
|
'name' => 'user_active',
|
|
'value' => $user['user_account_active']
|
|
]);
|
|
Form::addTypeHidden([
|
|
'name' => 'user_id',
|
|
'value' => $user['uid']
|
|
]);
|
|
}
|
|
private static function addSubmitFormButton(string $buttonText = '', string $icon = '')
|
|
{
|
|
Form::addOpenDiv([
|
|
'class' => 'box-footer text-end',
|
|
'value' => ''
|
|
]);
|
|
Form::addTypeButton([
|
|
'class' => 'btn btn-primary',
|
|
'type' => 'submit',
|
|
'value' => '<i class="ti-'.$icon.'"></i> '.$buttonText
|
|
]);
|
|
Form::addCloseDiv();
|
|
}
|
|
/**
|
|
* @desc will add a text element to the form
|
|
* @param string $visibleName
|
|
* @param string $valueName
|
|
* @param string $icon
|
|
* @return void
|
|
*/
|
|
private static function addTextElement(string $visibleName = '', string $valueName = '', string $icon = '', string $value = '')
|
|
{
|
|
Form::addTypeLabel([
|
|
'class' => 'form-label',
|
|
'for' => $valueName,
|
|
'value' => $visibleName
|
|
]);
|
|
Form::addOpenDiv([
|
|
'class' => 'input-group mb-3',
|
|
'value' => ''
|
|
]);
|
|
Form::addOpenAny([
|
|
'any' => 'span',
|
|
'class' => 'input-group-text',
|
|
'value' => '<i class="ti-'.$icon.'"></i>'
|
|
]);
|
|
Form::addCloseAny([
|
|
'any' => 'span'
|
|
]);
|
|
if($value!="")
|
|
{
|
|
Form::addInputTypeText([
|
|
'class' => 'form-control',
|
|
'name' => $valueName,
|
|
'placeholder' => $visibleName,
|
|
'value' => $value
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
Form::addInputTypeText([
|
|
'class' => 'form-control',
|
|
'name' => $valueName,
|
|
'placeholder' => $visibleName
|
|
]);
|
|
}
|
|
|
|
Form::addCloseDiv();
|
|
}
|
|
|
|
/**
|
|
* @desc will add a select dropdown to the form
|
|
* @param array $options
|
|
* @param string $icon
|
|
* @return void
|
|
*/
|
|
private static function addSelectDropdown( array $options = [], string $icon = '', int $selected = 0 )
|
|
{
|
|
Form::addTypeLabel([
|
|
'for' => 'source-api',
|
|
'class' => 'form-label',
|
|
'value' => 'Rolle auswählen:'
|
|
]);
|
|
Form::addOpenDiv([
|
|
'class' => 'input-group mb-3',
|
|
'value' => ''
|
|
]);
|
|
Form::addOpenAny([
|
|
'any' => 'span',
|
|
'class' => 'input-group-text',
|
|
'value' => '<i class="ti-'.$icon.'"></i>'
|
|
]);
|
|
Form::addCloseAny([
|
|
'any' => 'span'
|
|
]);
|
|
foreach($options as $option)
|
|
{
|
|
if($selected == $option['acl_id'])
|
|
{
|
|
Form::addSelectOption([
|
|
'context' => $option['acl_role'],
|
|
'value' => $option['acl_id'],
|
|
'selected' => 'selected'
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
Form::addSelectOption([
|
|
'context' => $option['acl_role'],
|
|
'value' => $option['acl_id']
|
|
]);
|
|
}
|
|
}
|
|
Form::addSelect([
|
|
'name' => 'user_acl_id',
|
|
'class' => 'form-control select2'
|
|
]);
|
|
Form::addCloseDiv();
|
|
}
|
|
|
|
/**
|
|
* @desc will add a password element to the form
|
|
* @param string $visibleName
|
|
* @param string $valueName
|
|
* @param string $icon
|
|
* @return void
|
|
*/
|
|
private static function addPasswordElement(string $visibleName = '', string $valueName = '', string $icon = '', string $value = '')
|
|
{
|
|
Form::addTypeLabel([
|
|
'class' => 'form-label',
|
|
'for' => $valueName,
|
|
'value' => $visibleName
|
|
]);
|
|
Form::addOpenDiv([
|
|
'class' => 'input-group mb-3',
|
|
'value' => ''
|
|
]);
|
|
Form::addOpenAny([
|
|
'any' => 'span',
|
|
'class' => 'input-group-text',
|
|
'value' => '<i class="ti-'.$icon.'"></i>'
|
|
]);
|
|
Form::addCloseAny([
|
|
'any' => 'span'
|
|
]);
|
|
if($value!="")
|
|
{
|
|
Form::addInputTypePassword([
|
|
'class' => 'form-control',
|
|
'name' => $valueName,
|
|
'placeholder' => $visibleName,
|
|
'value' => $value
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
Form::addInputTypePassword([
|
|
'class' => 'form-control',
|
|
'name' => $valueName,
|
|
'placeholder' => $visibleName
|
|
]);
|
|
}
|
|
Form::addCloseDiv();
|
|
}
|
|
|
|
/**
|
|
* @desc will open a half width element for form fields
|
|
* @param string $title
|
|
* @return void
|
|
*/
|
|
private static function openHalfWidthElement(string $title = '')
|
|
{
|
|
Form::addOpenDiv([
|
|
'class' => 'col-lg-6 col-13',
|
|
'value' => ''
|
|
]);
|
|
Form::addOpenDiv([
|
|
'class' => 'box',
|
|
'value' => ''
|
|
]);
|
|
Form::addOpenDiv([
|
|
'class' => 'box-header with-border',
|
|
'value' => '<h4 class="box-title">'.$title.'</h4>'
|
|
]);
|
|
Form::addCloseDiv();
|
|
}
|
|
|
|
/**
|
|
* @desc will add the inner half width distance frame element for form fields
|
|
* @return void
|
|
*/
|
|
private static function openInnerHalfWithElement()
|
|
{
|
|
Form::addOpenDiv([
|
|
'class' => 'form-group',
|
|
'value' => ''
|
|
]);
|
|
Form::addOpenDiv([
|
|
'class' => 'box-body',
|
|
'value' => ''
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @desc will add a checkbox for the active user account state
|
|
* @param string $visibleTitle
|
|
* @param bool $active
|
|
* @return void
|
|
*/
|
|
private static function addActiveCheckbox(string $visibleTitle = '', int $active = 0)
|
|
{
|
|
Form::addOpenDiv([
|
|
'class' => 'form-group', 'value' => ''
|
|
]);
|
|
Form::addOpenDiv([
|
|
'class' => 'checkbox checkbox-success',
|
|
'value' => ''
|
|
]);
|
|
if($active)
|
|
{
|
|
Form::addInputTypeCheckbox([
|
|
'id' => 'checkbox',
|
|
'name' => 'user_account_active',
|
|
'checked' => true
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
Form::addInputTypeCheckbox([
|
|
'id' => 'checkbox',
|
|
'name' => 'account_active'
|
|
]);
|
|
}
|
|
Form::addTypeLabel([
|
|
'for' => 'checkbox',
|
|
'value' => $visibleTitle
|
|
]);
|
|
Form::addCloseDiv();
|
|
Form::addCloseDiv();
|
|
}
|
|
|
|
/**
|
|
* @desc will close the inner half width distance frame element, and the half width element for form fields
|
|
* @return void
|
|
*/
|
|
private static function closeHalfWidthElement()
|
|
{
|
|
Form::addCloseDiv();
|
|
Form::addCloseDiv();
|
|
}
|
|
|
|
} |