EDIT: Именованный маршрут (category)

This commit is contained in:
Evg 2022-08-14 19:26:22 +03:00
parent a0ec9771f6
commit c74416c72f
18 changed files with 34 additions and 33 deletions

View file

@ -84,6 +84,7 @@ class AddFacetController extends Controller
SubscriptionModel::focus($new_facet_id['facet_id'], $this->user['id'], 'facet');
$msg = $type == 'blog' ? __('msg.blog_added') : __('msg.change_saved');
is_return($msg, 'success', '/' . $facet_type . '/' . $facet_slug);
is_return($msg, 'success', url('redirect.facet', ['id' => $new_facet_id['facet_id']]));
}
}

View file

@ -21,7 +21,7 @@ class RedirectController extends Controller
$utl = url('blog', ['slug' => $facet['facet_slug']]);
break;
case 'category':
$utl = url('web.dir', ['grouping' => 'all', 'slug' => $facet['facet_slug']]);
$utl = url('category', ['sort' => 'all', 'slug' => $facet['facet_slug']]);
break;
case 'section':
$utl = url('admin.facets.type', ['type' => 'section']);

View file

@ -45,7 +45,7 @@ class DirController extends Controller
$m = [
'og' => false,
'url' => url('web.dir', ['sort' => 'all', 'slug' => $category['facet_slug']]),
'url' => url('category', ['sort' => 'all', 'slug' => $category['facet_slug']]),
];
$title = __('web.' . $sort . '_title', ['name' => $category['facet_title']]);
@ -87,7 +87,7 @@ class DirController extends Controller
$result = [];
foreach ($tree as $row) {
$result[] = ["name" => $row['name'], "link" => url('web.dir', ['sort' => $sort, 'slug' => $row['link']])];
$result[] = ["name" => $row['name'], "link" => url('category', ['sort' => $sort, 'slug' => $row['link']])];
}
return array_merge($arr, $result);

View file

@ -25,7 +25,7 @@ class Img
];
// Blog, topic or category
public static function facets($facet, $type, $url, $css, $sort = 'all')
public static function facets($facet, $type, $css, $sort = 'all')
{
$facets = preg_split('/(@)/', $facet ?? false);
@ -33,9 +33,9 @@ class Img
foreach (array_chunk($facets, 3) as $row) {
if ($row[0] == $type) {
if ($type == 'category') {
$result[] = '<a class="' . $css . '" href="' . url($url, ['sort' => $sort, 'slug' => $row[1]]) . '">' . $row[2] . '</a>';
$result[] = '<a class="' . $css . '" href="' . url($type, ['sort' => $sort, 'slug' => $row[1]]) . '">' . $row[2] . '</a>';
} else {
$result[] = '<a class="' . $css . '" href="' . url($url, ['slug' => $row[1]]) . '">' . $row[2] . '</a>';
$result[] = '<a class="' . $css . '" href="' . url($type, ['slug' => $row[1]]) . '">' . $row[2] . '</a>';
}
}
}

View file

@ -25,7 +25,7 @@
<?php
switch ($topic['facet_type']):
case 'category':
$url = url('web.dir', ['grouping' => 'all', 'slug' => $topic['facet_slug']]);
$url = url('category', ['sort' => 'all', 'slug' => $topic['facet_slug']]);
break;
default:
$url = url($topic['facet_type'], ['slug' => $topic['facet_slug']]);
@ -73,7 +73,7 @@
<svg class="icons gray-600 text-sm mr5 ml5">
<use xlink:href="/assets/svg/icons.svg#git-merge"></use>
</svg>
<?= Img::facets($topic['matching_list'], $topic['facet_type'], $topic['facet_type'], 'gray-600 text-sm mr15'); ?>
<?= Img::facets($topic['matching_list'], $topic['facet_type'], 'gray-600 text-sm mr15'); ?>
</div>
<?php endif; ?>
</div>

View file

@ -5,12 +5,12 @@ if ($category) : ?>
<h2 class="inline m0"><?= Html::numWord($data['count'], __('web.num_website'), false); ?>: <?= $data['count']; ?></h2>
<ul class="nav">
<li<?php if ($data['sort'] == 'all') { ?> class="active" <?php } ?>>
<a href="<?= url('web.dir', ['sort' => 'all', 'slug' => $category['facet_slug']]); ?>">
<a href="<?= url('category', ['sort' => 'all', 'slug' => $category['facet_slug']]); ?>">
<?= __('web.by_date'); ?>
</a>
</li>
<li<?php if ($data['sort'] == 'top') { ?> class="active" <?php } ?>>
<a href="<?= url('web.dir', ['sort' => 'top', 'slug' => $category['facet_slug']]); ?>">
<a href="<?= url('category', ['sort' => 'top', 'slug' => $category['facet_slug']]); ?>">
TOP
</a>
</li>

View file

@ -7,12 +7,12 @@
<div class="item-categories">
<?php foreach (config('catalog/home-categories') as $cat) : ?>
<div class="categories-telo">
<a class="text-2xl block" href="<?= url('web.dir', ['sort' => 'all', 'slug' => $cat['url']]); ?>">
<a class="text-2xl block" href="<?= url('category', ['sort' => 'all', 'slug' => $cat['url']]); ?>">
<?= $cat['title']; ?>
</a>
<?php if (!empty($cat['sub'])) : ?>
<?php foreach ($cat['sub'] as $sub) : ?>
<a class="mr10 text-sm black mb-none" href="<?= url('web.dir', ['sort' => 'all', 'slug' => $sub['url']]); ?>">
<a class="mr10 text-sm black mb-none" href="<?= url('category', ['sort' => 'all', 'slug' => $sub['url']]); ?>">
<?= $sub['title']; ?>
</a>
<?php endforeach; ?>

View file

@ -13,7 +13,7 @@
<?= Img::website($item['item_domain'], 'thumbs', $item['item_title'], 'list-items__thumb-image'); ?>
</div>
<div class="list-items__description">
<?= Img::facets($item['facet_list'], 'category', 'web.dir', 'tag mr15', $sort); ?>
<?= Img::facets($item['facet_list'], 'category', 'tag mr15', $sort); ?>
<?php if (Access::author('item', $item['item_user_id'], $item['item_date'], 30) === true) : ?>
<a href="<?= url('content.edit', ['type' => 'item', 'id' => $item['item_id']]); ?>">

View file

@ -7,7 +7,7 @@
<h3 class="title"><?= $item['item_title']; ?>
<?php $date = date_diff(new DateTime(), new DateTime($item['item_date']))->days; ?>
<?php if ($date < 3) : ?><sup class="red text-sm">new</sup><?php endif; ?>
<?= Img::facets($item['facet_list'], 'category', 'web.dir', 'tag mr15', $screening); ?>
<?= Img::facets($item['facet_list'], 'category', 'tag mr15', $screening); ?>
</h3>
</a>
<div class="content">

View file

@ -22,7 +22,7 @@
<div class="item-categories">
<?php foreach ($data['childrens'] as $lt) : ?>
<div>
<a class="text-2xl" href="<?= url('web.dir', ['sort' => $data['sort'], 'slug' => $lt['facet_slug']]); ?>">
<a class="text-2xl" href="<?= url('category', ['sort' => $data['sort'], 'slug' => $lt['facet_slug']]); ?>">
<?= $lt['facet_title']; ?>
</a> <sup class="gray-600"><?= $lt['counts']; ?></sup>
<?php if (UserData::checkAdmin()) : ?>
@ -40,7 +40,7 @@
<div class="ml20 mb20 mb-block">
<?php foreach ($data['low_matching'] as $rl) : ?>
<div class="inline mr20">
<a class="text-2xl" href="<?= url('web.dir', ['sort' => $data['sort'], 'slug' => $rl['facet_slug']]); ?>">
<a class="text-2xl" href="<?= url('category', ['sort' => $data['sort'], 'slug' => $rl['facet_slug']]); ?>">
@<?= $rl['facet_title']; ?>
</a>
<?php if (UserData::checkAdmin()) : ?>
@ -61,7 +61,7 @@
<div class="item-categories mb-block">
<?php foreach ($data['low_matching'] as $rl) : ?>
<div class="inline mr20">
<a class="text-2xl" href="<?= url('web.dir', ['sort' => $data['sort'], 'slug' => $rl['facet_slug']]); ?>">
<a class="text-2xl" href="<?= url('category', ['sort' => $data['sort'], 'slug' => $rl['facet_slug']]); ?>">
@<?= $rl['facet_title']; ?>
</a>
<?php if (UserData::checkAdmin()) : ?>
@ -87,7 +87,7 @@
<?= insert('/_block/no-content', ['type' => 'small', 'text' => __('web.no'), 'icon' => 'info']); ?>
<?php endif; ?>
<?php $url = url('web.dir', ['sort' => 'all', 'slug' => $data['category']['facet_slug']]); ?>
<?php $url = url('category', ['sort' => 'all', 'slug' => $data['category']['facet_slug']]); ?>
<?= Html::pagination($data['pNum'], $data['pagesCount'], false, $url . '/page'); ?>
</main>
<aside>

View file

@ -22,7 +22,7 @@
<?= __('web.moderation'); ?>
</span>
<?php endif; ?>
<?= Img::facets($item['facet_list'], 'category', 'web.dir', 'tag mr15', 'all'); ?>
<?= Img::facets($item['facet_list'], 'category', 'tag mr15', 'all'); ?>
<?php if (Access::author('item', $item['item_user_id'], $item['item_date'], 30) === true) : ?>
<a href="<?= url('content.edit', ['type' => 'item', 'id' => $item['item_id']]); ?>">

View file

@ -29,7 +29,7 @@
'state' => is_array($data['item_signed']),
]); ?>
<div class="mt15">
<?= Img::facets($item['facet_list'], 'category', 'web.dir', 'tag', 'all'); ?>
<?= Img::facets($item['facet_list'], 'category', 'tag', 'all'); ?>
</div>
<div class="tems-center flex gap mt15">
<?= Html::votes($item, 'item'); ?>

View file

@ -20,8 +20,8 @@ use Hleb\Constructor\Handlers\Request; ?>
</a>
<div class="flex gap lowercase">
<?= Img::facets($post['facet_list'], 'blog', 'blog', 'gray text-sm'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'topic', 'gray-600 text-sm'); ?>
<?= Img::facets($post['facet_list'], 'blog', 'gray text-sm'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'gray-600 text-sm'); ?>
<?php if ($post['post_url_domain']) : ?>
<a class="gray-600 text-sm" href="<?= url('domain', ['domain' => $post['post_url_domain']]); ?>">
<svg class="icons">

View file

@ -24,8 +24,8 @@ use Hleb\Constructor\Handlers\Request; ?>
</h3>
</a>
<div class="flex gap lowercase">
<?= Img::facets($post['facet_list'], 'blog', 'blog', 'gray text-sm'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'topic', 'gray-600 text-sm'); ?>
<?= Img::facets($post['facet_list'], 'blog', 'gray text-sm'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'gray-600 text-sm'); ?>
<?php if ($post['post_url_domain']) : ?>
<a class="gray-600 text-sm" href="<?= url('domain', ['domain' => $post['post_url_domain']]); ?>">
<svg class="icons">

View file

@ -5,7 +5,7 @@ $sw = $sw ?? '?';
<main class="box">
<?php foreach ($data['tags'] as $tag) : ?>
<?php $url = $type == 'post' ? url('topic', ['slug' => $tag['facet_slug']]) : url('web.dir', ['grouping' => 'all', 'slug' => $tag['facet_slug']]);?>
<?php $url = $type == 'post' ? url('topic', ['slug' => $tag['facet_slug']]) : url('category', ['sort' => 'all', 'slug' => $tag['facet_slug']]);?>
<a class="mr20 tag" href="<?= $url; ?>">
<?= $tag['facet_title']; ?>
</a>
@ -47,7 +47,7 @@ $sw = $sw ?? '?';
</div>
<?php else : ?>
<div>
<?= Img::facets($result['facet_list'], 'topic', 'topic', 'tag mr15'); ?>
<?= Img::facets($result['facet_list'], 'topic', 'tag mr15'); ?>
</div>
<?php endif; ?>
<?= Content::fragment(Content::text($result['content'], 'line'), 250); ?>

View file

@ -38,8 +38,8 @@ use Hleb\Constructor\Handlers\Request; ?>
</a>
<div class="flex flex-row flex-auto items-center justify-between lowercase">
<div class="flex-auto">
<?= Img::facets($post['facet_list'], 'blog', 'blog', 'gray text-xs mr15'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'topic', 'tag-grey'); ?>
<?= Img::facets($post['facet_list'], 'blog', 'gray text-xs mr15'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'tag-grey'); ?>
<?php if ($post['post_url_domain']) : ?>
<a class="gray-600 text-sm ml10" href="<?= url('domain', ['domain' => $post['post_url_domain']]); ?>">
<svg class="icons">

View file

@ -22,8 +22,8 @@
<?= $post['post_title']; ?>
<?= insert('/content/post/post-title', ['post' => $post]); ?>
</a>
<?= Img::facets($post['facet_list'], 'blog', 'blog', 'tag'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'topic', 'tag-yellow'); ?>
<?= Img::facets($post['facet_list'], 'blog', 'tag'); ?>
<?= Img::facets($post['facet_list'], 'topic', 'tag-yellow'); ?>
</div>
<div class="flex text-sm mt3">
<a class="items-center gray-600 mr10" href="<?= url('profile', ['login' => $post['login']]); ?>">

View file

@ -131,9 +131,9 @@ Route::get('/domain/{domain}/{page?}')->controller('Post\PostController@domain',
Route::get('/web')->controller('Item\HomeController')->name('web');
Route::get('/web/website/{slug}')->controller('Item\DetailedController')->name('website');
Route::get('/web/dir/{sort}/{slug}')->controller('Item\DirController')->name('web.dir');
Route::get('/web/dir/{sort}/{slug}')->controller('Item\DirController')->name('category');
Route::get('/web/dir/{sort}/{slug}/page/{page?}')->controller('Item\DirController');
Route::get('/web/{grouping}/dir/{sort}/{slug}')->controller('Item\DirController')->name('web.dir.gr');
Route::get('/web/{grouping}/dir/{sort}/{slug}')->controller('Item\DirController');
Route::type(['get', 'post'])->get('/cleek')->controller('Item\DirController@cleek');