DEV: Changing the design of forms
Let's add facet types to the configuration.
This commit is contained in:
parent
89b84a1160
commit
2a53418e2a
16 changed files with 182 additions and 94 deletions
9
app/Helpers/form_helper.php
Normal file
9
app/Helpers/form_helper.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
function sumbit($text)
|
||||
{
|
||||
$html = '<button type="submit" class="btn btn-primary">' . $text . '</button>';
|
||||
|
||||
return $html;
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
//declare(strict_types = 1);
|
||||
|
||||
// Topic for posts
|
||||
function html_topic($topic, $slug, $css)
|
||||
{
|
||||
|
@ -416,12 +414,6 @@ function no_content($text, $icon)
|
|||
return $html;
|
||||
}
|
||||
|
||||
function sumbit($text)
|
||||
{
|
||||
$html = '<button type="submit" class="btn btn-primary">' . $text . '</button>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function getMsg()
|
||||
{
|
45
app/Helpers/template_helper.php
Normal file
45
app/Helpers/template_helper.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Matching names for the functions used.
|
||||
*
|
||||
* Сопоставление названий для используемых функций.
|
||||
*/
|
||||
|
||||
function agTheme($user_theme, $file)
|
||||
{
|
||||
$tpl_puth = $user_theme . $file;
|
||||
if (!file_exists(TEMPLATES . DIRECTORY_SEPARATOR . $user_theme . $file . '.php')) {
|
||||
$tpl_puth = Config::get('general.template') . $file;
|
||||
}
|
||||
|
||||
return $tpl_puth;
|
||||
}
|
||||
|
||||
function agRender($name, $data = null)
|
||||
{
|
||||
return render(
|
||||
[
|
||||
agTheme($data['uid']['user_template'], '/header'),
|
||||
agTheme($data['uid']['user_template'], '/content' . $name),
|
||||
agTheme($data['uid']['user_template'], '/footer')
|
||||
],
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
function agIncludeCachedTemplate(string $template, array $params = [])
|
||||
{
|
||||
hleb_include_cached_template(agTheme($params['uid']['user_template'], $template), $params);
|
||||
}
|
||||
|
||||
function agIncludeTemplate(string $template, array $params = [])
|
||||
{
|
||||
return hleb_include_template(agTheme($params['uid']['user_template'], $template), $params);
|
||||
}
|
||||
|
||||
function import($template, array $params = [])
|
||||
{
|
||||
$uid = Base::getUid();
|
||||
insertTemplate($uid['user_template'] . $template, $params);
|
||||
}
|
|
@ -1,50 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Matching names for the functions used.
|
||||
* Secondary functions
|
||||
*
|
||||
* Сопоставление названий для используемых функций.
|
||||
* Вспомогательные функции
|
||||
*/
|
||||
|
||||
function agTheme($user_theme, $file)
|
||||
{
|
||||
$tpl_puth = $user_theme . $file;
|
||||
if (!file_exists(TEMPLATES . DIRECTORY_SEPARATOR . $user_theme . $file . '.php')) {
|
||||
$tpl_puth = Config::get('general.template') . $file;
|
||||
}
|
||||
|
||||
return $tpl_puth;
|
||||
}
|
||||
|
||||
function agRender($name, $data = null)
|
||||
{
|
||||
return render(
|
||||
[
|
||||
agTheme($data['uid']['user_template'], '/header'),
|
||||
agTheme($data['uid']['user_template'], '/content' . $name),
|
||||
agTheme($data['uid']['user_template'], '/footer')
|
||||
],
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
function agIncludeCachedTemplate(string $template, array $params = [])
|
||||
{
|
||||
hleb_include_cached_template(agTheme($params['uid']['user_template'], $template), $params);
|
||||
}
|
||||
|
||||
function agIncludeTemplate(string $template, array $params = [])
|
||||
{
|
||||
return hleb_include_template(agTheme($params['uid']['user_template'], $template), $params);
|
||||
}
|
||||
|
||||
function import($template, array $params = [])
|
||||
{
|
||||
$uid = Base::getUid();
|
||||
insertTemplate($uid['user_template'] . $template, $params);
|
||||
}
|
||||
|
||||
hleb_require(HLEB_GLOBAL_DIRECTORY . '/app/Helpers/Template.php');
|
||||
hleb_require(HLEB_GLOBAL_DIRECTORY . '/app/Helpers/Meta.php');
|
||||
hleb_require(HLEB_GLOBAL_DIRECTORY . '/app/Helpers/template_helper.php');
|
||||
hleb_require(HLEB_GLOBAL_DIRECTORY . '/app/Helpers/html_helper.php');
|
||||
hleb_require(HLEB_GLOBAL_DIRECTORY . '/app/Helpers/meta_helper.php');
|
||||
hleb_require(HLEB_GLOBAL_DIRECTORY . '/app/Helpers/form_helper.php');
|
||||
|
|
|
@ -40,5 +40,23 @@ return [
|
|||
'name' => Translate::get('psychology'),
|
||||
'url' => '/topic/psychology',
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
// Types of faces
|
||||
// Типы граней
|
||||
'facet_type' => [
|
||||
[
|
||||
'title' => Translate::get('topic'),
|
||||
'value' => 'topic',
|
||||
],
|
||||
[
|
||||
'title' => Translate::get('blog'),
|
||||
'value' => 'blog',
|
||||
],
|
||||
[
|
||||
'title' => Translate::get('section'),
|
||||
'value' => 'section',
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,18 +1,10 @@
|
|||
<?php if ($uid['user_trust_level'] == Base::USER_LEVEL_ADMIN) { ?>
|
||||
<div class="mt15 mb20">
|
||||
<label class="block mb5"><?= Translate::get('topic'); ?> / <?= Translate::get('blog'); ?>?</label>
|
||||
<?php if (!empty($data['facet_type'])) { ?>
|
||||
<input type="radio" name="facet_type" <?php if ($data['facet_type'] == 'topic') { ?>checked<?php } ?> value="topic">
|
||||
<?= Translate::get('topic'); ?>
|
||||
<input type="radio" name="facet_type" <?php if ($data['facet_type'] == 'blog') { ?>checked<?php } ?> value="blog">
|
||||
<?= Translate::get('blog'); ?>
|
||||
<input type="radio" name="facet_type" <?php if ($data['facet_type'] == 'section') { ?>checked<?php } ?> value="section">
|
||||
<?= Translate::get('section'); ?>
|
||||
<?php } else { ?>
|
||||
<input type="radio" name="facet_type" checked value="topic"> <?= Translate::get('topic'); ?>
|
||||
<input type="radio" name="facet_type" value="blog"> <?= Translate::get('blog'); ?>
|
||||
<input type="radio" name="facet_type" value="section"> <?= Translate::get('section'); ?>
|
||||
<div class="mb20 max-w640">
|
||||
<label class="block" for="post_content"><?= Translate::get('type'); ?></label>
|
||||
<select class="h40" name="facet_type">
|
||||
<?php foreach (Config::get('facets.facet_type') as $value) { ?>
|
||||
<option <?php if ($value['value'] == $type) { ?>selected<?php } ?> value="<?= $value['value']; ?>">
|
||||
<?= $value['title']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php if (!empty($fl['help'])) { ?><div class="text-sm gray-400"><?= $fl['help']; ?></div><?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
|
@ -3,7 +3,7 @@
|
|||
<label class="block mb5" for="post_title"><?= $fl['title']; ?>
|
||||
<?php if (!empty($fl['red'])) { ?><sup class="red-500">*</sup><?php } ?>
|
||||
</label>
|
||||
<input class="w-100 h30 pl5" <?php if (!empty($fl['min'])) { ?>minlength="<?= $fl['min']; ?>" <?php } ?> <?php if (!empty($fl['max'])) { ?>maxlength="<?= $fl['max']; ?>" <?php } ?> <?php if (!empty($fl['id'])) { ?>id="<?= $fl['id']; ?>" <?php } ?> type="<?= $fl['type']; ?>" <?php if (!empty($fl['value'])) { ?>value="<?= $fl['value']; ?>" <?php } ?> name="<?= $fl['name']; ?>">
|
||||
<input class="w-100 h40 pl5" <?php if (!empty($fl['min'])) { ?>minlength="<?= $fl['min']; ?>" <?php } ?> <?php if (!empty($fl['max'])) { ?>maxlength="<?= $fl['max']; ?>" <?php } ?> <?php if (!empty($fl['id'])) { ?>id="<?= $fl['id']; ?>" <?php } ?> type="<?= $fl['type']; ?>" <?php if (!empty($fl['value'])) { ?>value="<?= $fl['value']; ?>" <?php } ?> name="<?= $fl['name']; ?>">
|
||||
<?php if (!empty($fl['help'])) { ?><div class="text-sm gray-400"><?= $fl['help']; ?></div><?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
|
@ -1,10 +1,19 @@
|
|||
<?php foreach ($data as $value) {
|
||||
$checked = $value['checked'] ?? 0;
|
||||
$checked = $value['checked'] ?? 0;
|
||||
$help = $value['help'] ?? null;
|
||||
?>
|
||||
<div class="mb20 max-w640">
|
||||
<label class="block"><?= $value['title']; ?></label>
|
||||
<input type="radio" name="<?= $value['name']; ?>" <?php if ($checked == 0) { ?>checked<?php } ?> value="0"> <?= Translate::get('no'); ?>
|
||||
<input type="radio" name="<?= $value['name']; ?>" <?php if ($checked == 1) { ?>checked<?php } ?> value="1"> <?= Translate::get('yes'); ?>
|
||||
<?php if (!empty($value['help'])) { ?><div class="text-sm gray-400"><?= $value['help']; ?></div><?php } ?>
|
||||
<label class="block mb5"><?= $value['title']; ?></label>
|
||||
<label class="container-radio">
|
||||
<input type="radio" name="<?= $value['name']; ?>" <?php if ($checked == 0) { ?>checked<?php } ?> value="0">
|
||||
<span class="checkmark"></span>
|
||||
<?= Translate::get('no'); ?>
|
||||
</label>
|
||||
<label class="container-radio">
|
||||
<input type="radio" name="<?= $value['name']; ?>" <?php if ($checked == 1) { ?>checked<?php } ?> value="1">
|
||||
<span class="checkmark"></span>
|
||||
<?= Translate::get('yes'); ?>
|
||||
</label>
|
||||
<?php if ($help) { ?><div class="mt5 text-sm gray-400"><?= $help; ?></div><?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php if ($uid['user_trust_level'] > 4) { ?>
|
||||
<div class="mb20 max-w640">
|
||||
<?= Translate::get('author'); ?>: <span class="gray"><?= $user['user_login']; ?></span>
|
||||
<?= Translate::get('author'); ?>
|
||||
<input name='user_id' id="user_id">
|
||||
</div>
|
||||
|
||||
|
|
|
@ -82,11 +82,6 @@
|
|||
<?= sumbit(Translate::get('download')); ?>
|
||||
</div>
|
||||
|
||||
<?= import('/_block/facet/facet-type', [
|
||||
'uid' => $uid,
|
||||
'data' => $fs,
|
||||
]); ?>
|
||||
|
||||
<?= import('/_block/form/field-input', [
|
||||
'data' => [
|
||||
[
|
||||
|
@ -247,8 +242,12 @@
|
|||
'title' => Translate::get('author'),
|
||||
'help' => Translate::get('necessarily'),
|
||||
]); ?>
|
||||
|
||||
<?= import('/_block/facet/facet-type', [
|
||||
'uid' => $uid,
|
||||
'type' => $fs['facet_type'],
|
||||
]); ?>
|
||||
<?php } ?>
|
||||
|
||||
<div class="mb20">
|
||||
<input type="hidden" name="facet_id" value="<?= $fs['facet_id']; ?>">
|
||||
<?= sumbit(Translate::get('edit')); ?>
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
</article>
|
||||
<div class="p15 m15 hidden">
|
||||
<?= votes($uid['user_id'], $page, 'post', 'text-2xl middle', 'block'); ?>
|
||||
<div>
|
||||
<footer class="bg-gray-200 p60 hidden mt15">
|
||||
</div>
|
||||
<footer class="bg-gray-100 p60 hidden mt15 mb-pl-0 mb-pr-0">
|
||||
<div class="m15 pb15">
|
||||
<div class="p15 mr-auto bg-white hidden br-box-gray br-rd5 max-w640">
|
||||
<div class="p15 mr-auto bg-white hidden br-box-gray br-rd5 max-w640 mb-mr-10 mb-ml-10">
|
||||
<?php if ($data['facet']['facet_type'] == 'section') { ?>
|
||||
<h3 class="mt0 mb5 font-normal">
|
||||
<?= $data['facet']['facet_title']; ?>
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
[
|
||||
'data' => [
|
||||
[
|
||||
'title' => Translate::get('when the message came to PM'),
|
||||
'name' => 'setting_email_pm',
|
||||
'checked' => !empty($data['setting']['setting_email_pm'])
|
||||
'title' => Translate::get('when the message came to PM'),
|
||||
'name' => 'setting_email_pm',
|
||||
'checked' => $data['setting']['setting_email_pm'] ?? 0,
|
||||
],
|
||||
[
|
||||
'title' => Translate::get('when you contacted me via @'),
|
||||
'name' => 'setting_email_appealed',
|
||||
'checked' => !empty($data['setting']['setting_email_appealed'])
|
||||
'title' => Translate::get('when you contacted me via @'),
|
||||
'name' => 'setting_email_appealed',
|
||||
'checked' => $data['setting']['setting_email_appealed'] ?? 0,
|
||||
],
|
||||
]
|
||||
]
|
||||
|
|
|
@ -52,7 +52,11 @@ textarea {
|
|||
border: 1px solid $slate-300;
|
||||
}
|
||||
|
||||
input, select { border: 1px solid $slate-300; }
|
||||
input, select {
|
||||
border: 1px solid $slate-300;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
select { background-color: #fff; }
|
||||
|
||||
input:focus,
|
||||
|
@ -199,6 +203,62 @@ textarea:focus { border: 1px solid #9ccdf8; }
|
|||
padding: 1px 6px;
|
||||
}
|
||||
|
||||
/* Customize the label (the container) */
|
||||
.container-radio {
|
||||
display: block;
|
||||
position: relative;
|
||||
padding-left: 35px;
|
||||
margin-bottom: 12px;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.container-radio input {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.checkmark {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 25px;
|
||||
width: 25px;
|
||||
background-color: #eee;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.container-radio:hover input ~ .checkmark {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.container-radio input:checked ~ .checkmark {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
.checkmark:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.container-radio input:checked ~ .checkmark:after {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.container-radio .checkmark:after {
|
||||
top: 9px;
|
||||
left: 9px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* Tags */
|
||||
.tags-look .tagify__dropdown__item {
|
||||
display: inline-block;
|
||||
|
|
|
@ -27,9 +27,11 @@
|
|||
.mb-col-12 { grid-column: span 12 / span 12; }
|
||||
.mb-w-100 { width: $width-one-hundred; }
|
||||
.mb-ml-10 { margin-left: $px-ten; }
|
||||
.mb-mr-10 { margin-right: $px-ten; }
|
||||
.mb-mt-5 { margin-top: $px-five; }
|
||||
.mb-mr-5 { margin-right: $px-five; }
|
||||
.mb-mb-5 { margin-bottom: $px-five; }
|
||||
.mb-ml-5 { margin-left: $px-five; }
|
||||
.mb-ml-0 { margin-left: $px-zero; }
|
||||
.mb-pl-0 { padding-left: $px-zero; }
|
||||
.mb-pr-0 { padding-right: $px-zero; }
|
||||
|
|
Loading…
Reference in a new issue