update bootstrap

This commit is contained in:
ghost 2023-09-25 01:01:48 +03:00
parent d949474737
commit 5a3ac70fd2
8 changed files with 356 additions and 60 deletions

View File

@ -4,21 +4,9 @@ class AppControllerModuleFooter
{
public function render()
{
$response['trackers'] = [];
$trackers = Environment::config('trackers');
if ($trackers = json_decode(file_get_contents(__DIR__ . '/../../../config/trackers.json')))
{
foreach ($trackers as $tracker)
{
if (!empty($tracker->announce) && !empty($tracker->stats))
{
$response['trackers'][] = [
'announce' => $tracker->announce,
'stats' => $tracker->stats,
];
}
}
}
$api = Environment::config('website')->api->export;
include __DIR__ . '../../../view/theme/default/module/footer.phtml';
}

View File

@ -7,7 +7,7 @@ class AppControllerModuleHeader
$name = str_replace(
'YGG',
'<span>YGG</span>',
WEBSITE_NAME
Environment::config('website')->name
);
require_once __DIR__ . '/search.php';

209
src/app/controller/page.php Normal file
View File

@ -0,0 +1,209 @@
<?php
class AppControllerPage
{
private $_database;
private $_validator;
private $_user;
public function __construct()
{
require_once __DIR__ . '/../model/database.php';
$this->_database = new AppModelDatabase(
Environment::config('database')
);
require_once __DIR__ . '/../model/validator.php';
$this->_validator = new AppModelValidator(
Environment::config('validator')
);
require_once __DIR__ . '/user.php';
$this->_user = new AppControllerUser(
$_SERVER['REMOTE_ADDR']
);
}
private function _response(string $title, string $h1, string $text, int $code = 200)
{
require_once __DIR__ . '/response.php';
$appControllerResponse = new AppControllerResponse(
$title,
$h1,
$text,
$code
);
$appControllerResponse->render();
exit;
}
public function renderFormDescription()
{
// Init form
$form = (object)
[
'title' => (object)
[
'error' => [],
'attribute' => (object)
[
'value' => null,
'required' => $this->_validator->getPageTitleRequired(),
'minlength' => $this->_validator->getPageTitleLengthMin(),
'maxlength' => $this->_validator->getPageTitleLengthMax(),
'placeholder' => sprintf(
_('Page subject (%s-%s chars)'),
number_format($this->_validator->getPageTitleLengthMin()),
number_format($this->_validator->getPageTitleLengthMax())
),
]
],
'description' => (object)
[
'error' => [],
'attribute' => (object)
[
'value' => null,
'required' => $this->_validator->getPageDescriptionRequired(),
'minlength' => $this->_validator->getPageDescriptionLengthMin(),
'maxlength' => $this->_validator->getPageDescriptionLengthMax(),
'placeholder' => sprintf(
_('Page description text (%s-%s chars)'),
number_format($this->_validator->getPageDescriptionLengthMin()),
number_format($this->_validator->getPageDescriptionLengthMax())
),
]
],
'keywords' => (object)
[
'error' => [],
'attribute' => (object)
[
'value' => null,
'required' => $this->_validator->getPageKeywordsRequired(),
'placeholder' => sprintf(
_('Page keywords (%s-%s total / %s-%s chars per item)'),
number_format($this->_validator->getPageKeywordsQuantityMin()),
number_format($this->_validator->getPageKeywordsQuantityMax()),
number_format($this->_validator->getPageKeywordLengthMin()),
number_format($this->_validator->getPageKeywordLengthMax())
),
]
],
'sensitive' => (object)
[
'error' => [],
'attribute' => (object)
[
'value' => null,
'placeholder' => _('Apply NSFW filters for this publication'),
]
]
];
// Submit request
if (isset($_POST))
{
if (isset($_POST['title']))
{
$error = [];
if (!$this->_validator->pageTitle($_POST['title'], $error))
{
$form->title->error[] = $error;
}
// @TODO check for page duplicates
$form->title->attribute->value = htmlentities($_POST['title']);
}
if (isset($_POST['description']))
{
$error = [];
if (!$this->_validator->pageDescription($_POST['description'], $error))
{
$form->description->error[] = $error;
}
$form->description->attribute->value = htmlentities($_POST['description']);
}
if (isset($_POST['keywords']))
{
$error = [];
if (!$this->_validator->pageKeywords($_POST['keywords'], $error))
{
$form->keywords->error[] = $error;
}
$form->keywords->attribute->value = htmlentities($_POST['keywords']);
}
if (isset($_POST['sensitive']))
{
$form->sensitive->attribute->value = (bool) $_POST['sensitive'];
}
// Request valid
if (empty($error))
{
// @TODO redirect
}
}
// Render template
require_once __DIR__ . '/module/head.php';
$appControllerModuleHead = new AppControllerModuleHead(
Environment::config('website')->url,
sprintf(
_('Submit - %s'),
Environment::config('website')->name
),
[
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/common.css?%s',
CSS_VERSION
),
],
[
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => sprintf(
'assets/theme/default/css/framework.css?%s',
CSS_VERSION
),
],
]
);
require_once __DIR__ . '/module/profile.php';
$appControllerModuleProfile = new AppControllerModuleProfile(
$this->_user
);
require_once __DIR__ . '/module/header.php';
$appControllerModuleHeader = new AppControllerModuleHeader();
require_once __DIR__ . '/module/footer.php';
$appControllerModuleFooter = new AppControllerModuleFooter();
include __DIR__ . '../../view/theme/default/page/form/description.phtml';
}
}

View File

@ -3,48 +3,33 @@
class AppControllerUser
{
private $_database;
private $_validator;
private $_user;
public function __construct(string $address)
{
// Connect DB
require_once __DIR__ . '/../model/database.php';
try
{
$this->_database = new AppModelDatabase(
DB_HOST,
DB_PORT,
DB_NAME,
DB_USERNAME,
DB_PASSWORD
Environment::config('database')
);
}
catch (Exception $error)
{
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
),
_('500'),
print_r($error, true),
500
require_once __DIR__ . '/../model/validator.php';
$this->_validator = new AppModelValidator(
Environment::config('validator')
);
}
// Validate user address
require_once __DIR__ . '/../../library/valid.php';
// Validate address
$error = [];
if (!Valid::host($address, $error))
if (!$this->_validator->host($address, $error))
{
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
Environment::config('website')->name
),
_('406'),
print_r($error, true),
@ -60,7 +45,7 @@ class AppControllerUser
$this->_user = $this->_database->getUser(
$this->_database->initUserId(
$address,
USER_DEFAULT_APPROVED,
Environment::config('website')->default->user->approved,
time()
)
);
@ -75,13 +60,24 @@ class AppControllerUser
$this->_response(
sprintf(
_('Error - %s'),
WEBSITE_NAME
Environment::config('website')->name
),
_('500'),
print_r($error, true),
500
);
}
// Require account type selection
if (is_null($this->getPublic()))
{
header(
sprintf(
'Location: %s/welcome',
trim($this->_config->url, '/')
)
);
}
}
private function _response(string $title, string $h1, string $text, int $code = 200)

View File

@ -13,7 +13,7 @@
<a href="node"><?php echo _('Node') ?></a>
|
<a rel="nofollow" href="rss"><?php echo _('RSS') ?></a>
<?php if (API_EXPORT_ENABLED) { ?>
<?php if ($api) { ?>
|
<a rel="nofollow" href="api/manifest.json"><?php echo _('API') ?></a>
<?php } ?>

View File

@ -152,7 +152,7 @@
</span>
</a>
<?php } ?>
<?php if ($route == 'submit') { ?>
<?php if ($route == 'page/form') { ?>
<span class="padding-x-16 padding-y-8 display-block background-color-green cursor-default text-color-white">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-plus-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/>

View File

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html>
<?php $appControllerModuleHead->render() ?>
<body>
<?php $appControllerModuleHeader->render() ?>
<main>
<div class="container">
<div class="row">
<div class="column width-100">
<?php $appControllerModuleProfile->render() ?>
<div class="padding-16 margin-y-8 border-radius-3 background-color-night">
<div class="margin-b-24 padding-b-16 border-bottom-default">
<h1><?php echo _('Submit') ?></h1>
</div>
<form class="margin-t-8" name="submit" method="post" enctype="multipart/form-data" action="page/form">
<div class="margin-b-16">
<label for="title">
<?php echo _('Title') ?>
</label>
<sub class="opacity-0 parent-hover-opacity-09"
title="<?php echo $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>
<?php foreach ($form->title->error as $errors) { ?>
<?php foreach ($errors as $error) { ?>
<div class="text-color-red margin-y-8">
<?php echo $error ?>
</div>
<?php } ?>
<?php } ?>
<input class="width-100 margin-t-8"
type="text"
name="title"
id="title"
<?php echo $form->title->attribute->required ? 'required="required"' : false ?>
value="<?php echo $form->title->attribute->value ?>"
placeholder="<?php echo $form->title->attribute->placeholder ?>"
minlength="<?php echo $form->title->attribute->minlength ?>"
maxlength="<?php echo $form->title->attribute->maxlength ?>" />
</div>
<div class="margin-y-8 padding-t-4">
<label for="description">
<?php echo _('Description') ?>
</label>
<sub class="opacity-0 parent-hover-opacity-09"
title="<?php echo $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>
<?php foreach ($form->description->error as $errors) { ?>
<?php foreach ($errors as $error) { ?>
<div class="text-color-red margin-y-8">
<?php echo $error ?>
</div>
<?php } ?>
<?php } ?>
<textarea class="width-100 margin-t-8"
name="description"
id="description"
<?php echo $form->description->attribute->required ? 'required="required"' : false ?>
placeholder="<?php echo $form->description->attribute->placeholder ?>"
minlength="<?php echo $form->description->attribute->minlength ?>"
maxlength="<?php echo $form->description->attribute->maxlength ?>"><?php echo $form->description->attribute->value ?></textarea>
</div>
<div class="margin-y-8 padding-t-4">
<label for="keywords">
<?php echo _('Keywords') ?>
</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>
<?php foreach ($form->keywords->error as $errors) { ?>
<?php foreach ($errors as $error) { ?>
<div class="text-color-red margin-y-8">
<?php echo $error ?>
</div>
<?php } ?>
<?php } ?>
<textarea class="width-100 margin-t-8"
name="keywords"
<?php echo $form->keywords->attribute->required ? 'required="required"' : false ?>
placeholder="<?php echo $form->keywords->attribute->placeholder ?>"
minlength="<?php echo $form->keywords->attribute->minlength ?>"
maxlength="<?php echo $form->keywords->attribute->maxlength ?>"><?php echo $form->keywords->attribute->value ?></textarea>
</div>
<div class="margin-y-16">
<input type="checkbox" name="sensitive" id="sensitive" value="true" <?php echo $form->sensitive->attribute->value ? 'checked="checked"' : false ?> />
<label for="sensitive">
<?php echo _('Sensitive') ?>
</label>
<sub class="opacity-0 parent-hover-opacity-09"
title="<?php echo $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="<?php echo _('Submit') ?>" />
</div>
</form>
</div>
</div>
</div>
</div>
</main>
<?php $appControllerModuleFooter->render() ?>
</body>
</html>

View File

@ -90,21 +90,9 @@ if (isset($request['_route_']))
require_once __DIR__ . '/../app/controller/page.php';
$appControllerPage = new AppControllerPage(
Environment::config('website')
);
$appControllerPage = new AppControllerPage();
require_once __DIR__ . '/../app/model/database.php';
require_once __DIR__ . '/../app/model/validator.php';
$appControllerPage->renderFormDescription(
new AppModelDatabase(
Environment::config('database')
),
new AppModelValidator(
Environment::config('validator')
)
);
$appControllerPage->renderFormDescription();
break;