2024.11.27 02:21:09

This commit is contained in:
Christian Moser 2024-11-27 02:21:09 +01:00
parent 4b2918a931
commit b442dbc2e1
33 changed files with 539 additions and 218 deletions

1
PO/LINGUAS Normal file
View File

@ -0,0 +1 @@
de

4
PO/POTFILES Normal file
View File

@ -0,0 +1,4 @@
../src/Controller/MainController.php
../src/Controller/SecurityController.php
../src/Controller/SetupController.php
../src/Kernel.php

10
PO/POTFILES.webroot Normal file
View File

@ -0,0 +1,10 @@
../src/MyDevel/Webroot/Controller/WebrootController.php
../src/MyDevel/Webroot/Controller/WebrootSetupController.php
../src/MyDevel/Webroot/Entity/WebrootFile.php
../src/MyDevel/Webroot/Entity/WebrootFilePermission.php
../src/MyDevel/Webroot/Entity/WebrootRole.php
../src/MyDevel/Webroot/Entity/WebrootUser.php
../src/MyDevel/Webroot/Repository/WebrootFilePermissionRepository.php
../src/MyDevel/Webroot/Repository/WebrootFileRepository.php
../src/MyDevel/Webroot/Repository/WebrootRoleRepository.php
../src/MyDevel/Webroot/Repository/WebrootUserRepository.php

1
PO/PTOFILES Normal file
View File

@ -0,0 +1 @@

22
PO/compilemessages Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh
SELF="$(realpath "$0")"
PO_DIR="$(dirname "$SELF")"
PROJECT_ROOT="$(dirname "$PO_DIR")"
cd "$PO_DIR"
for i in `cat LINGUAS`; do
msgdir="$PROJECT_ROOT/translations/$i/LC_MESSAGES";
if [ ! -d "$msgdir" ]; then
mkdir -p "$msgdir"
fi
if [ -f $i.po ]; then
msgfmt -o "$msgdir/messages.mo" $i.po
fi
if [ -f webroot/$i.po ]; then
msgfmt -o "$msgdir/mydevel.webroot.mo" "webroot/$i.po"
fi
done

18
PO/de.po Normal file
View File

@ -0,0 +1,18 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-26 20:44+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

18
PO/messages.pot Normal file
View File

@ -0,0 +1,18 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-26 20:44+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

61
PO/mkpotfiles.sh Normal file
View File

@ -0,0 +1,61 @@
#!/bin/sh
SELF="$(realpath "$0")"
PODIR="$(dirname "$SELF")"
PROJECT_ROOT="$(dirname "$PODIR")"
cd "$PODIR"
echo "Creating POTFILES"
rm -v POTFILES
for i in $(find ../src | grep '\.php' | grep -v '\.\./src/MyDevel'); do
echo $i >> POTFILES
done
if [ -f messages.pot ]; then
JOIN="--join-existing"
else
JOIN=""
fi
echo "extracting messages"
xgettext -f POTFILES -d messages -L PHP $JOIN --force-po -o messages.pot
if [ -z "$JOIN" ]; then
sed -i s/charset=CHARSET/charset=UTF-8/g messages.pot
fi
for i in `cat LINGUAS`; do
if [ ! -f $i.po ]; then
cp messages.pot $i.po
else
msgmerge $i.po messages.pot
fi
done
echo "Creating POTFILES.webroot"
rm -v POTFILES.webroot
for i in $(find ../src/MyDevel/Webroot | grep '\.php'); do
echo $i >> POTFILES.webroot
done
if [ ! -d webroot ]; then
mkdir -v webroot
fi
if [ -f webroot/messages.pot ]; then
JOIN="--join-existing"
else
JOIN=""
fi
xgettext -d mydevel.webroot -f POTFILES.webroot -L PHP $JOIN --force-po -o webroot/messages.pot
if [ -z "$JOIN" ]; then
sed -i s/charset=CHARSET/charset=UTF-8/g webroot/messages.pot
fi
for i in `cat LINGUAS`; do
if [ ! -f webroot/$i.po ]; then
cp webroot/messages.pot webroot/$i.po
else
msgmerge webroot/$i.po webroot/messages.pot
fi
done

18
PO/webroot/de.po Normal file
View File

@ -0,0 +1,18 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-26 20:44+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

18
PO/webroot/messages.pot Normal file
View File

@ -0,0 +1,18 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-26 20:44+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

View File

@ -55,9 +55,7 @@
},
"autoload": {
"psr-4": {
"MyDevel\\": "src/MyDevel/",
"App\\": "src/"
}
},
"autoload-dev": {

View File

@ -15,18 +15,6 @@ services:
# this creates a service per class whose id is the fully-qualified class name
MyDevel\:
resource: '../src/MyDevel/'
#exclude:
#- '../src/MyDevel/Webroot/Entity/'
#MyDevel\Webroot\Controller\WebrootSetupController:
# abstract: true
# class: WebrootSetupController
# autowire: true
# arguments: ['%kernel.project_dir%']
App\:
resource: '../src/'
exclude:

View File

@ -1,43 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241126043446 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE mydevel_webroot_file');
$this->addSql('DROP TABLE mydevel_webroot_file_permission');
$this->addSql('DROP TABLE mydevel_webroot_role');
$this->addSql('DROP TABLE mydevel_webroot_user');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE mydevel_webroot_file (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, owner_id INTEGER NOT NULL, url CLOB NOT NULL COLLATE "BINARY", abspath CLOB NOT NULL COLLATE "BINARY", CONSTRAINT FK_A7B135127E3C61F9 FOREIGN KEY (owner_id) REFERENCES mydevel_webroot_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A7B135127E3C61F9 ON mydevel_webroot_file (owner_id)');
$this->addSql('CREATE TABLE mydevel_webroot_file_permission (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, role_id INTEGER NOT NULL, webroot_file_id INTEGER NOT NULL, is_readable BOOLEAN DEFAULT 1 NOT NULL, is_writeable BOOLEAN DEFAULT 0 NOT NULL, is_deleteable BOOLEAN DEFAULT 0 NOT NULL, CONSTRAINT FK_4D56CEFD60322AC FOREIGN KEY (role_id) REFERENCES mydevel_webroot_role (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_4D56CEF2800AFC9 FOREIGN KEY (webroot_file_id) REFERENCES mydevel_webroot_file (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_4D56CEF2800AFC9 ON mydevel_webroot_file_permission (webroot_file_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4D56CEFD60322AC ON mydevel_webroot_file_permission (role_id)');
$this->addSql('CREATE TABLE mydevel_webroot_role (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, role VARCHAR(255) NOT NULL COLLATE "BINARY", name VARCHAR(255) NOT NULL COLLATE "BINARY", description VARCHAR(1023) DEFAULT NULL COLLATE "BINARY")');
$this->addSql('CREATE TABLE mydevel_webroot_user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(180) NOT NULL COLLATE "BINARY", roles CLOB NOT NULL COLLATE "BINARY" --(DC2Type:json)
, password VARCHAR(255) NOT NULL COLLATE "BINARY", email VARCHAR(255) NOT NULL COLLATE "BINARY")');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME ON mydevel_webroot_user (username)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A6BDD54BE7927C74 ON mydevel_webroot_user (email)');
}
}

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241126013626 extends AbstractMigration
final class Version20241126213642 extends AbstractMigration
{
public function getDescription(): string
{
@ -25,6 +25,7 @@ final class Version20241126013626 extends AbstractMigration
owner_id INTEGER NOT NULL,
url CLOB NOT NULL,
abspath CLOB NOT NULL,
description CLOB DEFAULT NULL,
CONSTRAINT FK_A7B135127E3C61F9 FOREIGN KEY (owner_id) REFERENCES mydevel_webroot_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A7B135127E3C61F9 ON mydevel_webroot_file (owner_id)');
@ -52,7 +53,8 @@ final class Version20241126013626 extends AbstractMigration
roles CLOB NOT NULL --(DC2Type:json)
,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL
email VARCHAR(255) NOT NULL,
is_admin BOOLEAN DEFAULT 0 NOT NULL
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A6BDD54BE7927C74 ON mydevel_webroot_user (email)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME ON mydevel_webroot_user (username)');

View File

@ -15,8 +15,10 @@ class MainController extends AbstractController //WebrootMainController
{
$project_root = $kernel->getProjectDir();
if (!file_exists(join(DIRECTORY_SEPARATOR,[$project_root,'.env.local']))) {
return $this->redirect('/setup');
$dotenvlocal_file = join(DIRECTORY_SEPARATOR,[$project_root,'.env.local']);
if (!file_exists($dotenvlocal_file)) {
return $this->redirectToRoute('webroot.setup');
}
return $this->render('main/index.html.twig', [

View File

@ -4,15 +4,200 @@ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Form\Extension\Core\Type as FormType;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Doctrine\ORM\EntityManagerInterface;
use MyDevel\Webroot\Controller\WebrootSetupController;
use App\Controller\WebrootSetupController;
use App\Entity\WebrootUser;
use App\Entity\WebrootRole;
class SetupController extends WebrootSetupController
{
#[Route('/setup',name:'webroot.setup.initial')]
public function initialSetup(Request $request,
EntityManagerInterface $em,
UserPasswordHasherInterface $passwd_hasher): Response
{
$dotenv_file = join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),".env"]);
$dotenvlocal_file = join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),".env.local"]);
$errors = array();
if (!file_exists($dotenv_file)) {
$file = fopen($dotenv_file, "w", false);
fclose($file);
}
$form = $this->createFormBuilder()
->add('language',FormType\TextType::class,)
->add('site_name',FormType\TextType::class,[
"mapped"=>false,
"label" => "Site name"])
->add('site_rootdir',FormType\TextType::class,[
"mapped"=>false,
"label" => "Site Root Directory"])
->add('site_email',FormType\EmailType::class,[
"mapped"=>false,
"label" => "Contact email"])
->add('user_username',FormType\TextType::class,[
"mapped"=>false,
"label"=>"Username"])
->add('user_email',FormType\EmailType::class,[
"mapped"=>false,
"label"=> "Email address"])
->add("user_password0", FormType\PasswordType::class,[
"mapped"=>false,
"label"=>"Password"])
->add("user_password1",FormType\PasswordType::class,[
"mapped"=>false,
"label"=>"Confirm Password"])
->add('db_backend',FormType\ChoiceType::class,[
"mapped" => false,
"label" => "Database Backend",
"choices" => [
"sqlite" => "SQLite3",
"mysql" => "MySQL/MariaDB",
"postgresql" => "PostgreSQL",
]])
->add('db_database',FormType\TextType::class,[
"mapped"=>false,
"label"=>"Database"])
->add('db_host', FormType\TextType::class,[
"mapped"=>false,
"label"=>"Host"])
->add('db_port', FormType\IntegerType::class,[
"mapped"=>false,
"label"=>"Port"])
->add('db_user',FormType\TextType::class,[
"mapped"=>false,
"label"=>"User"])
->add('db_password',FormType\TextType::class,[
"mapped"=>false,
"label"=>"Password"])
->add('email_backend', FormType\ChoiceType::class, [
"mapped"=>false,
"label" => "Email Backend",
"choices"=> [
"none", "None",
"smtp", "SMTP",
"sendmail","Sendmail",
"native","Naitve",
]])
->add('email_path',FormType\TextType::class,[
"mapped"=>false,
"label"=>"Email Path"])
->add('email_user',FormType\TextType::class,[
"mapped"=>false,
"label"=>"User"])
->add('email_password', FormType\PasswordType::class,[
"mapped"=>false,
"label"=> "Password"])
->add('email_host',FormType\TextType::class,[
"mapped"=>false,
"label"=>"SMTP Host"])
->add('email_port',FormType\TextType::class,[
"mapped"=>false,
"label"=>"SMTP Port"])
->add('email_address', FormType\EmailType::class,[
"mapped"=>false,
"label"=>"Sender address"])
->add('submit', FormType\SubmitType::class)
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$password0 = $form.get('user_password0')->getData();
$password1 = $form.get('user_password1')->get_data();
$errors[] = "Passwords dont match";
//if passwords don't match rerender form.
return $this->render("setup/initial-setup.html.twig",[
"error" => $errors,
"form" => $form]);
$dotevnlocal = join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),'.env.local']);
$file = fopen($dotevnlocal,"w");
$language=$form->get('language')->getNormData();
if ($language || strlen($language) > 1) {
fwrite($file,"LANG=\"" . $language . "\"\n");
}
fwrite($file,"SITE_NAME=\"" . $form->get("site_name")->getNormData() . "\"\n");
fwrite($file,"SITE_EMAIL=\"". $form->get('site_email')->getNormData() . "\"\n");
$db_backend=$form->get('db_backend')->getNormData();
if ($db_backend === "sqlite") {
fwrite("DATABASE_URL=\"sqlite://" . $form.get('db_database') . "\"\n");
} elseif ($db_backend === "mysql") {
fwrite("DATABASE_URL=\"msysql://"
. urlencode($form.get('db_user')->getNormData())
. ":" . urlencode($form.get('db_password')->getNormData())
. "@" . urlencode($form.get('db_host')->getNormData())
. ":" . $form.get('db_port')->getNormData()
. "/" . urlencode($form.get('db_database')->getNormData())
. "?charset=utf8mb4\"\n");
} elseif ($db_backend === "postgresql") {
fwrite("DATABASE_URL=\"postgresql://"
. urlencode($form->get('db_user')->getNormData())
. ":" . urlencode($form->get('db_password')->getNormData())
. "@" . urlencode($form->get('db_host')->getNormData())
. ":" . $form->get('db_port')->getNormData()
. "/" . urlencode($form.get('db_database')->getNormData())
. "?charset=utf8");
}
fclose($file);
(new Dotenv())->loadEnv(join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),".env"]));
try {
$migration_message = $this->runMakeMigration();
$migrate_message = $this->runMigrate();
$user = new WebrootUser();
$user->setAdmin(true);
$user->setUsername($form->get('user_username')->getNormData());
$user->setRoles(["ROLE_SUPERADMIN","ROLE_ADMIN","ROLE_USER"]);
$user->setEmail($form->get("user_email")->getNormData());
$user->set_password($passwd_hasher->hashPassword($user, $password0));
$em->persist($user);
foreach($this->getInitialRoles() as $roledata) {
$role = new WebrootRole();
$role->setRole($roledata["role"]);
$role->setName($roledata["name"]);
$role->setDescription($roledata["description"]);
$em->persist($role);
}
return redirectToRoute("app_login");
} catch (\Exception $ex) {
unlink($dotevnlocal);
$errors[] = $ex->getMessage();
} finally {
}
}
return $this->render('setup/initial-setup.html.twig', [
"form" => $form,
"errors" => $errors
]);
}
#[Route('/setup', name: 'webroot.setup')]
public function index(): Response
{
if (!$this->isInstalled()) {
return redirectToRoute('webroot.setup.initial');
}
if (!$this->userIsLoggedInAsAdmin()) {
return redirectToRoute("app_login");
}
return $this->render('setup/controller.html.twig', [
'controller_name' => "WebrootController",
'function' => __FUNCTION__,

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Controller;
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Controller;
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@ -55,66 +55,18 @@ abstract class WebrootSetupController extends AbstractController
return $repos->hasAdministrator();
}
/**
* @brief Check if there is a *.setupkey*-file in the project root.
*
* @note This file will be deleted after the initial setup!
*
* @return bool `true` if there is a *.setupkey* file int the project
* root directory.
*/
protected function hasSetupKey(): bool
{
return file_exists(join(DIRECTORY_SEPARATOR,[$this->project_dir,".setupkey"]));
}
/**
* @Brief Get the actual setup key from file.
* @return string|null Returns `null` when there is no `.setupkey` file
* located in prject root else the first line of the file.
*/
protected function getSetupKey(): ?string
{
if (!$this->hasSetupKey()) {
return null;
}
$file = fopen($this->project_dir,".setupkey");
$str = fread($file, 4096);
fclose($file);
$pos = strpos($str,"\r\n",0);
if (!$pos) {
$pos = strpos($str,"\n",0);
}
if ($pos) {
$key=substr(string,0,pos);
} else {
$key=$str;
}
return key;
}
/**
* @brief Check if user is logged in for setup.
* @return bool Returns `true` if user is logged in and is allowed to view
* the setup pages.
*/
public function isLoggedIn(): bool
public function userIsLoggedInAsAdmin(): bool
{
$user = $this->getUser();
if ($user && $user->isAdmin()) {
return true;
}
$has_setup_key = $this->hasSetupKey();
$has_administrator = $this->hasAdministrator();
if (!$has_administrator && !$has_setup_key) {
return true;
}
if ($has_setup_key && isset($_COOKIE["mydevel_webroot_sk"])) {
return (filter_input(INPUT_COOKIE, "mydevel_webroot_sk") === $this->getSetupKey());
}
return false;
}
@ -132,33 +84,6 @@ abstract class WebrootSetupController extends AbstractController
&& file_exists(join(DIRECTORY_SEPARATOR,[$this->project_dir,".env.local"])));
}
/**
* @brief Check if the key marches the one from file.
*
* @param string $key The key to check.
*
* @return bool|null Returns `null` if there is no *.setupkey* file present,
* `true` on match and false if the key does not match.
*/
protected function checkSetupKey(string $key): ?bool
{
if (!$this->hasSetupKey()) {
return null;
}
$file_key = $this->getSetupKey();
if ($key === $file_key) {
$cookie_domain = getenv("WEBROOT_HOST");
if (!$cookie_domain || !strlen("WEBROOT_HOST")) {
$request = $this->getRequest();
$cookie_domain = $request->getHost();
setcookie("mydevel_webroot_sk",$file_key,0,"/",$cookie_domain,1,0);
return true;
}
}
return false;
}
/**
*
* @return string
@ -175,10 +100,15 @@ abstract class WebrootSetupController extends AbstractController
]);
$output = new BufferedOutput();
$application->run($input,$output);
$errc =$application->run($input,$output);
$content=$output->fetch();
if ($errc) {
throw new \Exception("make:migration failed!");
}
return $content;
}
@ -196,10 +126,23 @@ abstract class WebrootSetupController extends AbstractController
"--no-interaction" => true,
]);
$output = new BufferedOutput();
$application->run($input,$output);
$ercode = $application->run($input,$output);
if ($errcode) {
throw new \Excpetion("runMigrate failed!");
}
$content = $output->fetch();
return $content;
}
public function getInitialRoles(): array
{
return [
["role"=>"ROLE_SUPERADMIN","name"=>"Super Administrator","description"=>"Super Administrator with all rights, always!"],
["role"=>"ROLE_ADMIN","name"=>"Administrator","description"=>"Role with administrative rights."],
["role"=>"ROLE_USER","name"=>"Common User","description"=>"Common user rights."],
["role"=>"ROLE_PUBLIC","name"=>"Public Access","description"=>"Role for public access."],
];
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Entity;
namespace App\Entity;
use App\Repository\WebrootFileRepository;
use Doctrine\Common\Collections\ArrayCollection;
@ -22,6 +22,8 @@ class WebrootFile
#[ORM\Column(length: 65535,nullable:false)]
private ?string $abspath = null;
#[ORM\Column(length: 4095,nullable:true)]
private ?string $description = null;
/**
* @var Collection<int, WebrootPermission>
@ -33,6 +35,7 @@ class WebrootFile
#[ORM\JoinColumn(nullable: false)]
private ?WebrootUser $owner = null;
public function __construct()
{
$this->permissions = new ArrayCollection();
@ -67,6 +70,18 @@ class WebrootFile
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, WebrootPermission>
*/

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Entity;
namespace App\Entity;
use App\Repository\WebrootPermissionRepository;
use Doctrine\ORM\Mapping as ORM;

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Entity;
namespace App\Entity;
use App\Repository\WebrootRoleRepository;
use Doctrine\ORM\Mapping as ORM;

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Entity;
namespace App\Entity;
use App\Repository\WebrootUserRepository;
use Doctrine\ORM\Mapping as ORM;

View File

@ -1,16 +0,0 @@
<?php
function i18n_initialize(string $packge,string $localedir,?string $locale) {
if (function_exists("gettext")) {
if (!$locale) {
$locale="";
}
setlocale(LC_ALL, $locale);
bindtextdomain($package, $localedir);
if (function_exists("bind_textdomain_codeset")) {
bind_textdomain_codeset($package,"UTF-8");
}
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace MyDevel\Utility\i18n;
function i18n_initialize(string $packge, string $localedir, ?string $locale)
{
if (function_exists("gettext")) {
if (!$locale) {
$locale=getenv(LANG);
}
setlocale(LC_ALL, $locale);
bindtextdomain($package,$loclaedir);
if (function_exists("bind_textdomain_codeset")) {
bind_textdomain_codeset(package, "UTF-8");
}
texdomain(package);
}
}
if (function_exists("gettext")) {
function _(string $msgid): string
{
return gettext(msgid);
}
} else {
function _(string $msgid): string
{
return msgid;
}
}
function N_(string $msgid): string
{
return msgid;
}
if (function_exists("ngettext")) {
function X_(string $singular,string $plural,int $count): string
{
return ngettext($singular, $plural, $count);
}
} else {
function X_(string $singular,string $plural,int $count): string
{
if ($count == 1) {
return $singular;
}
return $plural;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Repository;
namespace App\Repository;
use App\Entity\WebrootPermission;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Repository;
namespace App\Repository;
use App\Entity\WebrootFile;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Repository;
namespace App\Repository;
use App\Entity\WebrootRole;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;

View File

@ -1,6 +1,6 @@
<?php
namespace MyDevel\Webroot\Repository;
namespace App\Repository;
use App\Entity\WebrootUser;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;

View File

@ -0,0 +1,9 @@
{% extends 'base.html.twig' %}
{% block body %}
<div class="form-box full width">
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
<div>
{% endblock %}

View File

@ -0,0 +1,59 @@
{% extends 'base.html.twig' %}
{% block body %}
<h3>Index für <em>{{ url_path }}</em></h3>
<div class="toolbar">
{% if create_dir %}
<span class="toolbar-item">
<a class="coolbar-button" href="{{ create_dir }}">
<img />
</a>
</span>
{% endif %}
{% if upload_file %}
<span class="toolbar-item">
<a class="toolbar-button" href="{{ upload_file }}">
<img />
</a>
</span>
{% endif %}
</div>
<table><!-- Directory Index -->
<tr>
<th class="td-color"><a href="{{ sort_standard_href }}"><img class="list-icon" alt="[icon]" width="32" height="32" src="/static/icons/empty.svg" /></a></th>
<th class="td-color"><a href="{{ sort_name_href }}">Name</a></th>
<th class="td-color"><a href="{{ sort_size_href }}">Größe</a></th>
<th class="td-color"><a href="{{ sort_time_href }}">Zuletzt geändert</a></th>
<th class="td-color">Beschreibung</th>
<th class="td-color"></th>
</tr>
<tr><td colspan="6"><strong><hr></strong></td></tr>
{% if parent_url %}
<tr>
<td><img class="list-icom" width="24" height="24" alt="[icon]" src="/static/icons/back.svg" /></td>
<td><a href="{{ parent_url }}">Zurück</a></td>
<td>-</td>
<td>-</td>
<td>-</td>
<td><img class="list-icon" alt="icon" width="24" height="24" src="/static/icons/empty.svg" /></td>
</tr>
{% endif %}
{% for entry in dir_entries %}
<tr>
<td>{% if entry.icon %}<img class="list-icon" alt="{{ entry.icon_alt }}" src="{{ entry.icon }}" width="24" height="24" />{% endif %}</td>
<td><a href="{{ entry.href }}">{{ entry.name }}</a></td>
<td>{{ entry.display_size }}</td>
<td>{{ entry.last_modified }}</td>
<td>{{ entry.description }}</td>
<td>
{% if entry.delete %}
<a href="{{ entry.delete }}"<img class="list-icon" alt="[delete]" width="24" height="24" src="/static/icons/delete.svg" /></a>
{% else %}
<img class="list-icon" alt="" width="24" height="24" src="/static/icons/empty.svg">
{% endif %}
</td>
</tr>
{% endfor %}
<tr><td colspan="6"><strong><hr></strong></td></tr>
</table>
{% endblock %}

View File

@ -0,0 +1,59 @@
{% extends 'base.html.twig' %}
{% block body %}
<h3>Index for <em>{{ url_path }}</em></h3>
<div class="toolbar">
{% if create_dir %}
<span class="toolbar-item">
<a class="coolbar-button" href="{{ create_dir }}">
<img />
</a>
</span>
{% endif %}
{% if upload_file %}
<span class="toolbar-item">
<a class="toolbar-button" href="{{ upload_file }}">
<img />
</a>
</span>
{% endif %}
</div>
<table><!-- Directory Index -->
<tr>
<th class="td-color"><a href="{{ sort_standard_href }}"><img class="list-icon" alt="[icon]" width="32" height="32" src="/static/icons/empty.svg" /></a></th>
<th class="td-color"><a href="{{ sort_name_href }}">Size</a></th>
<th class="td-color"><a href="{{ sort_time_href }}">Last changed</a></th>
<th class="td-color">Description</th>
<th class="td-color"></th>
</tr>
<tr><td colspan="6"><strong><hr></strong></td></tr>
{% if parent_url %}
<tr>
<td><img class="list-icom" width="24" height="24" alt="[icon]" src="/static/icons/back.svg" /></td>
<td><a href="{{ parent_url }}">Zurück</a></td>
<td>-</td>
<td>-</td>
<td>-</td>
<td><img class="list-icon" alt="icon" width="24" height="24" src="/static/icons/empty.svg" /></td>
</tr>
{% endif %}
{% for entry in dir_entries %}
<tr>
<td>{% if entry.icon %}<img class="list-icon" alt="{{ entry.icon_alt }}" src="{{ entry.icon }}" width="24" height="24" />{% endif %}</td>
<td><a href="{{ entry.href }}">{{ entry.name }}</a></td>
<td>{{ entry.display_size }}</td>
<td>{{ entry.last_modified }}</td>
<td>{{ entry.description }}</td>
<td>
{% if entry.delete %}
<a href="{{ entry.delete }}"<img class="list-icon" alt="[delete]" width="24" height="24" src="/static/icons/delete.svg" /></a>
{% else %}
<img class="list-icon" alt="" width="24" height="24" src="/static/icons/empty.svg">
{% endif %}
</td>
</tr>
{% endfor %}
<tr><td colspan="6"><strong><hr></strong></td></tr>
</table>
{% endblock %}

Binary file not shown.

Binary file not shown.