Skip to content

Commit 4cdd725

Browse files
committed
Added theme selector to edit user page
1 parent 38d5ede commit 4cdd725

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

app/Http/Controllers/AdminController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,12 @@ public function editUser(request $request)
267267
$littlelink_description = $request->littlelink_description;
268268
$role = $request->role;
269269
$customBackground = $request->file('background');
270+
$theme = $request->theme;
270271

271272
if ($request->password == '') {
272-
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]);
273+
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role, 'theme' => $theme]);
273274
} else {
274-
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'password' => $password, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]);
275+
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'password' => $password, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role, 'theme' => $theme]);
275276
}
276277
if (!empty($profilePhoto)) {
277278
$profilePhoto->move(base_path('assets/img'), $id . '_' . time() . ".png");

resources/views/panel/edit-user.blade.php

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,47 @@
6262
@if($_SERVER['QUERY_STRING'] === 'deleteB' and File::exists(base_path('assets/img/background-img/'.findBackground($user->id))))@php File::delete(base_path('assets/img/background-img/'.findBackground($user->id))); header("Location: ".url()->current()); die(); @endphp @endif
6363
<br>
6464
</div><br>
65-
66-
<!--<div class="form-group col-lg-8">
67-
<label>Littlelink name </label>
68-
<input type="text" class="form-control" name="littlelink_name" value="{{ $user->id }}">
69-
</div>-->
65+
66+
<label>{{__('messages.Select theme')}}</label>
67+
<div class="form-group col-lg-8">
68+
<select id="theme-select" style="margin-bottom: 40px;" class="form-control" name="theme" data-base-url="{{ url('') }}/@<?= Auth::user()->littlelink_name ?>">
69+
<?php
70+
if ($handle = opendir('themes')) {
71+
while (false !== ($entry = readdir($handle))) {
72+
if ($entry != "." && $entry != "..") {
73+
if(file_exists(base_path('themes') . '/' . $entry . '/readme.md')){
74+
$text = file_get_contents(base_path('themes') . '/' . $entry . '/readme.md');
75+
$pattern = '/Theme Name:.*/';
76+
preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE);
77+
if(sizeof($matches) > 0) {
78+
$themeName = substr($matches[0][0],12);
79+
}
80+
}
81+
if($user->theme != $entry and isset($themeName)){
82+
echo '<option value="'.$entry.'" data-image="'.url('themes/'.$entry.'/screenshot.png').'">'.$themeName.'</option>';
83+
}
84+
}
85+
}
86+
}
87+
88+
if($user->theme != "default" and $user->theme != ""){
89+
if(file_exists(base_path('themes') . '/' . $user->theme . '/readme.md')){
90+
$text = file_get_contents(base_path('themes') . '/' . $user->theme . '/readme.md');
91+
$pattern = '/Theme Name:.*/';
92+
preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE);
93+
$themeName = substr($matches[0][0],12);
94+
}
95+
echo '<option value="'.$user->theme.'" data-image="'.url('themes/'.$user->theme.'/screenshot.png').'" selected>'.$themeName.'</option>';
96+
}
97+
98+
echo '<option value="default" data-image="'.url('themes/default/screenshot.png').'"';
99+
if($user->theme == "default" or $user->theme == ""){
100+
echo ' selected';
101+
}
102+
echo '>Default</option>';
103+
?>
104+
</select>
105+
</div>
70106

71107
<div class="form-group col-lg-8">
72108
<label>{{__('messages.Page URL')}}</label>

0 commit comments

Comments
 (0)