Update routes

This commit is contained in:
DariusIII
2018-04-18 11:50:15 +02:00
parent 822cf5e71c
commit dfdc0074e6
5 changed files with 6 additions and 121 deletions
+1
View File
@@ -1,4 +1,5 @@
2018-04-18 DariusIII
* Chg: Update routes
* Chg: Add CategoryRegexesController
2018-04-17 DariusIII
* Chg: Rename admin to oldadmin folder
@@ -53,7 +53,7 @@ class CategoryRegexesController extends BasePageController
$this->setAdminPrefs();
$regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'category_regexes']);
// Set the current action.
// Set the current action.
$action = $request->input('action') ?? 'view';
$regex = [
-87
View File
@@ -1,87 +0,0 @@
<?php
require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'resources/views/themes/smarty.php';
use Blacklight\Regexes;
use App\Models\Category;
use Blacklight\http\BasePage;
$page = new BasePage();
$page->setAdminPrefs();
$regexes = new Regexes(['Settings' => $page->pdo, 'Table_Name' => 'category_regexes']);
// Set the current action.
$action = request()->input('action') ?? 'view';
$regex = [
'id' => '',
'group_regex' => '',
'regex' => '',
'description' => '',
'ordinal' => '',
'categories_id' => '',
'status' => 1, ];
$page->smarty->assign('regex', $regex);
switch ($action) {
case 'submit':
if (request()->input('group_regex') === '') {
$page->smarty->assign('error', 'Group regex must not be empty!');
break;
}
if (request()->input('regex') === '') {
$page->smarty->assign('error', 'Regex cannot be empty');
break;
}
if (! is_numeric(request()->input('ordinal')) || request()->input('ordinal') < 0) {
$page->smarty->assign('error', 'Ordinal must be a number, 0 or higher.');
break;
}
if (request()->input('id') === '') {
$regexes->addRegex(request()->all());
} else {
$regexes->updateRegex(request()->all());
}
header('Location:'.WWW_TOP.'/category_regexes-list.php');
break;
case 'view':
default:
if (request()->has('id')) {
$page->title = 'Category Regex Edit';
$id = request()->input('id');
$regex = $regexes->getRegexByID($id);
} else {
$page->title = 'Category Regex Add';
}
$page->smarty->assign('regex', $regex);
break;
}
$page->smarty->assign('status_ids', [Category::STATUS_ACTIVE, Category::STATUS_INACTIVE]);
$page->smarty->assign('status_names', ['Yes', 'No']);
$categories_db = $page->pdo->queryDirect(
'SELECT c.id, c.title, cp.title AS parent_title
FROM categories c
INNER JOIN categories cp ON c.parentid = cp.id
WHERE c.parentid IS NOT NULL
ORDER BY c.id ASC'
);
$categories = ['category_names', 'category_ids'];
if ($categories_db) {
foreach ($categories_db as $category_db) {
$categories['category_names'][] = $category_db['parent_title'].' '.$category_db['title'].': '.$category_db['id'];
$categories['category_ids'][] = $category_db['id'];
}
}
$page->smarty->assign('category_names', $categories['category_names']);
$page->smarty->assign('category_ids', $categories['category_ids']);
$page->content = $page->smarty->fetch('category_regexes-edit.tpl');
$page->adminrender();
-33
View File
@@ -1,33 +0,0 @@
<?php
require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'resources/views/themes/smarty.php';
use Blacklight\Regexes;
use Blacklight\http\BasePage;
$page = new BasePage();
$page->setAdminPrefs();
$regexes = new Regexes(['Settings' => $page->pdo, 'Table_Name' => 'category_regexes']);
$page->title = 'Category Regex List';
$group = request()->has('group') && ! empty(request()->input('group')) ? request()->input('group') : '';
$offset = (request()->input('offset') ?? 0);
$regex = $regexes->getRegex($group, config('nntmux.items_per_page'), $offset);
$page->smarty->assign(
[
'group' => $group,
'pagertotalitems' => $regexes->getCount($group),
'pagerquerysuffix' => '',
'pageroffset' => $offset,
'pageritemsperpage' => config('nntmux.items_per_page'),
'regex' => $regex,
'pagerquerybase' => WWW_TOP.'/category_regexes-list.php?'.$group.'offset=',
]
);
$page->smarty->assign('pager', $page->smarty->fetch('pager.tpl'));
$page->content = $page->smarty->fetch('category_regexes-list.tpl');
$page->adminrender();
+4
View File
@@ -238,5 +238,9 @@ Route::prefix('admin')->group(function () {
Route::post('content-add', 'ContentController@create');
Route::get('content-delete', 'ContentController@destroy');
Route::post('content-delete', 'ContentController@destroy');
oute::get('category_regexes-list', 'CategoryRegexesController@index');
Route::post('category_regexes-list', 'CategoryRegexesController@index');
Route::get('category_regexes-edit', 'CategoryRegexesController@edit');
Route::post('category_regexes-edit', 'CategoryRegexesController@edit');
});
});