|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\BasePageController; |
|
6
|
|
|
use App\Models\Category; |
|
7
|
|
|
use Blacklight\Regexes; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
|
|
10
|
|
|
class AdminCollectionRegexesController extends BasePageController |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @param \Illuminate\Http\Request $request |
|
14
|
|
|
* |
|
15
|
|
|
* @throws \Exception |
|
16
|
|
|
*/ |
|
17
|
|
|
public function index(Request $request) |
|
18
|
|
|
{ |
|
19
|
|
|
$this->setAdminPrefs(); |
|
20
|
|
|
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'collection_regexes']); |
|
21
|
|
|
|
|
22
|
|
|
$meta_title = $title = 'Collections Regex List'; |
|
23
|
|
|
|
|
24
|
|
|
$group = ($request->has('group') && ! empty($request->input('group')) ? $request->input('group') : ''); |
|
25
|
|
|
$regex = $regexes->getRegex($group); |
|
26
|
|
|
$this->smarty->assign(compact('group', 'regex')); |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
$content = $this->smarty->fetch('collection_regexes-list.tpl'); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
|
31
|
|
|
|
|
32
|
|
|
$this->adminrender(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param \Illuminate\Http\Request $request |
|
37
|
|
|
* |
|
38
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
|
39
|
|
|
* @throws \Exception |
|
40
|
|
|
*/ |
|
41
|
|
|
public function edit(Request $request) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->setAdminPrefs(); |
|
44
|
|
|
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'collection_regexes']); |
|
45
|
|
|
$error = ''; |
|
46
|
|
|
$regex = ['id' => '', 'regex' => '', 'description' => '', 'group_regex' => '', 'ordinal' => '', 'status' => 1]; |
|
47
|
|
|
|
|
48
|
|
|
switch ($request->input('action') ?? 'view') { |
|
49
|
|
|
case 'submit': |
|
50
|
|
|
if (empty($request->input('group_regex'))) { |
|
51
|
|
|
$error = 'Group regex must not be empty!'; |
|
52
|
|
|
break; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
if (empty($request->input('regex'))) { |
|
56
|
|
|
$error = 'Regex cannot be empty'; |
|
57
|
|
|
break; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
if (empty($request->input('description'))) { |
|
61
|
|
|
$request->merge(['description' => '']); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
if (! is_numeric($request->input('ordinal')) || $request->input('ordinal') < 0) { |
|
65
|
|
|
$error = 'Ordinal must be a number, 0 or higher.'; |
|
66
|
|
|
break; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if (empty($request->input('id'))) { |
|
70
|
|
|
$regexes->addRegex($request->all()); |
|
71
|
|
|
} else { |
|
72
|
|
|
$regexes->updateRegex($request->all()); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return redirect('admin/collection_regexes-list'); |
|
76
|
|
|
break; |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
case 'view': |
|
79
|
|
|
default: |
|
80
|
|
|
if ($request->has('id')) { |
|
81
|
|
|
$meta_title = $title = 'Collections Regex Edit'; |
|
82
|
|
|
$regex = $regexes->getRegexByID($request->input('id')); |
|
83
|
|
|
} else { |
|
84
|
|
|
$meta_title = $title = 'Collections Regex Add'; |
|
85
|
|
|
$regex += ['status' => 1]; |
|
86
|
|
|
} |
|
87
|
|
|
break; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
$this->smarty->assign('regex', $regex); |
|
91
|
|
|
$this->smarty->assign('error', $error); |
|
92
|
|
|
$this->smarty->assign('status_ids', [Category::STATUS_ACTIVE, Category::STATUS_INACTIVE]); |
|
93
|
|
|
$this->smarty->assign('status_names', ['Yes', 'No']); |
|
94
|
|
|
|
|
95
|
|
|
$content = $this->smarty->fetch('collection_regexes-edit.tpl'); |
|
96
|
|
|
|
|
97
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
|
98
|
|
|
|
|
99
|
|
|
$this->adminrender(); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param \Illuminate\Http\Request $request |
|
104
|
|
|
* |
|
105
|
|
|
* @throws \Exception |
|
106
|
|
|
*/ |
|
107
|
|
|
public function testRegex(Request $request) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->setAdminPrefs(); |
|
110
|
|
|
$meta_title = $title = 'Collections Regex Test'; |
|
111
|
|
|
|
|
112
|
|
|
$group = trim($request->has('group') && ! empty($request->input('group')) ? $request->input('group') : ''); |
|
113
|
|
|
$regex = trim($request->has('regex') && ! empty($request->input('regex')) ? $request->input('regex') : ''); |
|
114
|
|
|
$limit = ($request->has('limit') && is_numeric($request->input('limit')) ? $request->input('limit') : 50); |
|
115
|
|
|
$this->smarty->assign(['group' => $group, 'regex' => $regex, 'limit' => $limit]); |
|
116
|
|
|
|
|
117
|
|
|
if ($group && $regex) { |
|
118
|
|
|
$this->smarty->assign('data', (new Regexes(['Settings' => null, 'Table_Name' => 'collection_regexes']))->testCollectionRegex($group, $regex, $limit)); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
$content = $this->smarty->fetch('collection_regexes-test.tpl'); |
|
122
|
|
|
|
|
123
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
|
124
|
|
|
|
|
125
|
|
|
$this->adminrender(); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.