ghost
1 year ago
5 changed files with 328 additions and 118 deletions
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
<?php |
||||
|
||||
namespace App\Service; |
||||
|
||||
use App\Entity\Page; |
||||
use App\Repository\PageRepository; |
||||
use Doctrine\ORM\EntityManagerInterface; |
||||
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
||||
|
||||
class PageService |
||||
{ |
||||
private EntityManagerInterface $entityManager; |
||||
private PageRepository $pageRepository; |
||||
private ParameterBagInterface $parameterBagInterface; |
||||
|
||||
public function __construct( |
||||
EntityManagerInterface $entityManager, |
||||
ParameterBagInterface $parameterBagInterface |
||||
) |
||||
{ |
||||
$this->entityManager = $entityManager; |
||||
$this->pageRepository = $entityManager->getRepository(Page::class); |
||||
$this->parameterBagInterface = $parameterBagInterface; |
||||
} |
||||
|
||||
public function new(): ?Page |
||||
{ |
||||
return new Page(); |
||||
} |
||||
|
||||
public function save(Page $page) : void |
||||
{ |
||||
$this->entityManager->persist($page); |
||||
$this->entityManager->flush(); |
||||
} |
||||
} |
@ -1,129 +1,115 @@
@@ -1,129 +1,115 @@
|
||||
{% extends 'default/layout.html.twig' %} |
||||
{% block title %}{{'Submit'|trans }} - {{ name }}{% endblock %} |
||||
|
||||
{% block main_content %} |
||||
<div class="margin-b-24-px padding-b-16-px border-bottom-default"> |
||||
<div class="padding-24-px margin-y-8-px border-radius-3-px background-color-night"> |
||||
<div class="margin-b-24-px padding-b-16-px border-bottom-default"> |
||||
<h1>{{'Submit'|trans }}</h1> |
||||
</div> |
||||
<form class="margin-t-8-px" name="submit" method="post" enctype="multipart/form-data" action="submit"> |
||||
<input type="hidden" name="pageId" value="<?php echo $form->pageId->attribute->value ?>" /> |
||||
<div class="margin-b-16"> |
||||
<label for="locale"> |
||||
{{'Content language'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.locale.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
<select class="width-100 margin-t-8" type="text" name="locale" id="locale"> |
||||
{% for locale in form.locale.options %} |
||||
{% if locale.active %} |
||||
<option value="{{ locale.code }}" selected="selected"> |
||||
{{ locale.value }} |
||||
</option> |
||||
{% else %} |
||||
<option value="{{ locale.code }}"> |
||||
{{ locale.value }} |
||||
</option> |
||||
{% endif %} |
||||
{% endfor %} |
||||
</select> |
||||
</div> |
||||
<div class="margin-b-16"> |
||||
<label for="title"> |
||||
{{'Title'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.title.attribute.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
{% for errors in form.title.error %} |
||||
{% for error in errors %} |
||||
<form name="submit" method="post" enctype="multipart/form-data" action="{{ path('page_submit') }}"> |
||||
<div class="margin-b-16-px"> |
||||
<label for="locale"> |
||||
{{'Content language'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.locale.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
<select class="width-100 margin-t-8-px" type="text" name="locale" id="locale"> |
||||
{% for locale in locales %} |
||||
{% if locale == form.locale.value %} |
||||
<option value="{{ locale }}" selected="selected"> |
||||
{{ locale|locale_name(locale)|u.title }} |
||||
</option> |
||||
{% else %} |
||||
<option value="{{ locale }}"> |
||||
{{ locale|locale_name(locale)|u.title }} |
||||
</option> |
||||
{% endif %} |
||||
{% endfor %} |
||||
</select> |
||||
</div> |
||||
<div class="margin-b-16-px"> |
||||
<label for="title"> |
||||
{{'Title'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.title.attribute.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
{% for error in form.title.error %} |
||||
<div class="text-color-red margin-y-8-px"> |
||||
{{ error }} |
||||
</div> |
||||
{% endfor %} |
||||
{% endfor %} |
||||
<input class="width-100 margin-t-8-px" |
||||
type="text" |
||||
name="title" |
||||
id="title" |
||||
{% if form.title.attribute.required %}required="required"{% endif %} |
||||
value="{{ form.title.attribute.value }}" |
||||
placeholder="{{ form.title.attribute.placeholder }}" |
||||
minlength="{{ form.title.attribute.minlength }}" |
||||
maxlength="{{ form.title.attribute.maxlength }}" /> |
||||
</div> |
||||
<div class="margin-y-8-px padding-t-4-px"> |
||||
<label for="description"> |
||||
{{'Description'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.description.attribute.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
{% for errors in form.description.error %} |
||||
{% for error in errors %} |
||||
<input class="width-100 margin-t-8-px" |
||||
type="text" |
||||
name="title" |
||||
id="title" |
||||
{% if form.title.attribute.minlength %}required="required"{% endif %} |
||||
value="{{ form.title.attribute.value }}" |
||||
placeholder="{{ form.title.attribute.placeholder }}" |
||||
minlength="{{ form.title.attribute.minlength }}" |
||||
maxlength="{{ form.title.attribute.maxlength }}" /> |
||||
</div> |
||||
<div class="margin-y-8-px"> |
||||
<label for="description"> |
||||
{{'Description'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.description.attribute.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
{% for error in form.description.error %} |
||||
<div class="text-color-red margin-y-8-px"> |
||||
{{ error }} |
||||
</div> |
||||
{% endfor %} |
||||
{% endfor %} |
||||
<textarea class="width-100 margin-t-8-px" |
||||
name="description" |
||||
id="description" |
||||
{% if form.description.attribute.required %}required="required"{% endif %} |
||||
value="{{ form.description.attribute.value }}" |
||||
placeholder="{{ form.description.attribute.placeholder }}" |
||||
minlength="{{ form.description.attribute.minlength }}" |
||||
maxlength="{{ form.description.attribute.maxlength }}">{{ form.description.attribute.value }}</textarea> |
||||
</div> |
||||
<div class="margin-y-8 padding-t-4"> |
||||
<label for="keywords"> |
||||
{{'Keywords'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" |
||||
title="<?php echo $form->keywords->attribute->placeholder ?>"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
{% for errors in form.keywords.error %} |
||||
{% for error in errors %} |
||||
<textarea class="width-100 margin-t-8-px" |
||||
name="description" |
||||
id="description" |
||||
{% if form.description.attribute.minlength %}required="required"{% endif %} |
||||
value="{{ form.description.attribute.value }}" |
||||
placeholder="{{ form.description.attribute.placeholder }}" |
||||
minlength="{{ form.description.attribute.minlength }}" |
||||
maxlength="{{ form.description.attribute.maxlength }}">{{ form.description.attribute.value }}</textarea> |
||||
</div> |
||||
<div class="margin-y-16-px"> |
||||
<label for="torrents"> |
||||
{{'Torrent files'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.torrents.attribute.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
{% for error in form.torrents.error %} |
||||
<div class="text-color-red margin-y-8-px"> |
||||
{{ error }} |
||||
</div> |
||||
{% endfor %} |
||||
{% endfor %} |
||||
<textarea class="width-100 margin-t-8-px" |
||||
name="keywords" |
||||
id="keywords" |
||||
{% if form.keywords.attribute.required %}required="required"{% endif %} |
||||
value="{{ form.keywords.attribute.value }}" |
||||
placeholder="{{ form.keywords.attribute.placeholder }}" |
||||
minlength="{{ form.keywords.attribute.minlength }}" |
||||
maxlength="{{ form.keywords.attribute.maxlength }}">{{ form.keywords.attribute.value }}</textarea> |
||||
</div> |
||||
<div class="margin-y-16-px"> |
||||
<input type="checkbox" |
||||
name="sensitive" |
||||
id="sensitive" |
||||
value="true" |
||||
{% form.sensitive.attribute.value %}checked="checked"{% endif %} /> |
||||
<label for="sensitive"> |
||||
{{'Sensitive'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.sensitive.attribute.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
</div> |
||||
<div class="text-right"> |
||||
<input class="button-green" type="submit" value="{{'Submit'|trans }}" /> |
||||
</div> |
||||
</form> |
||||
<input class="width-100 margin-t-8-px" type="file" name="torrents[]" id="torrents" value="" accept=".torrent" multiple="multiple" /> |
||||
</div> |
||||
<div class="margin-y-16-px"> |
||||
<input type="checkbox" |
||||
name="sensitive" |
||||
id="sensitive" |
||||
value="true" |
||||
{% if form.sensitive.attribute.value %}checked="checked"{% endif %} /> |
||||
<label for="sensitive"> |
||||
{{'Sensitive'|trans }} |
||||
</label> |
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.sensitive.attribute.placeholder }}"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> |
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/> |
||||
</svg> |
||||
</sub> |
||||
</div> |
||||
<div class="text-right"> |
||||
<input class="button-green" type="submit" value="{{'Submit'|trans }}" /> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
{% endblock %} |
||||
|
Loading…
Reference in new issue