This commit is contained in:
themohooks 2025-02-11 19:30:48 +03:00
parent a4922fed39
commit 16322d1664
10 changed files with 181 additions and 7 deletions

View file

@ -0,0 +1,23 @@
<?php
namespace App\Controllers\Api\Admin\GeoDB;
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF};
use App\Models\{User, Vote, Photo};
class Create
{
public function __construct()
{
DB::query('INSERT INTO geodb VALUES (\'0\', :body)', array(':body' => $_POST['body']));
echo json_encode(
array(
'errorcode' => 0,
'error' => 0
)
);
}
}

View file

@ -0,0 +1,24 @@
<?php
namespace App\Controllers\Api\Admin\GeoDB;
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF, Date};
use App\Models\{User, Vote, Photo};
class Load
{
public function __construct()
{
$geodb = DB::query('SELECT * FROM geodb');
foreach ($geodb as $u) {
echo '<tr>
<th>' . $u['id'] . '</th>
<td>' . $u['title'] . '</td>
<td><div class="cmt-submit"><a class="btn btn-sm btn-primary" href="/admin?type=UserEdit&user_id=' . $u['id'] . '">Редактировать</a><a style="margin-left: 15px;" class="btn btn-sm btn-danger" href="/admin?type=UserEdit&user_id=' . $u['id'] . '">Удалить</a></div></td>
</tr>';
}
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Controllers\Api\GeoDB;
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF, Date};
use App\Models\{User, Vote, Photo};
class Search
{
public function __construct()
{
$query = $_GET['place'];
if ($query) {
$addresses = DB::query('SELECT title FROM geodb WHERE LOWER(title) LIKE LOWER(:query)', array(':query' => "%$query%"));
$titles = array_map(function($address) {
return $address['title'];
}, $addresses);
echo json_encode($titles, JSON_UNESCAPED_UNICODE);
} else {
echo json_encode(["error" => "No query provided"], JSON_UNESCAPED_UNICODE);
}
}
}

View file

@ -19,6 +19,7 @@ use \App\Controllers\Api\Images\Comments\Delete as PhotoCommentDelete;
use \App\Controllers\Api\Images\Comments\Pin as PhotoCommentPin;
use \App\Controllers\Api\Images\Comments\Load as PhotoCommentLoad;
use \App\Controllers\Api\Images\Comments\Rate as PhotoCommentVote;
use \App\Controllers\Api\GeoDB\Search as GeoDBSearch;
use \App\Controllers\Api\Vehicles\Load as VehiclesLoad;
use \App\Controllers\Api\Profile\Update as ProfileUpdate;
use \App\Controllers\Api\Users\LoadUser as UserLoad;
@ -27,6 +28,8 @@ use \App\Controllers\Api\Admin\Images\SetVisibility as AdminPhotoSetVisibility;
use \App\Controllers\Api\Admin\CreateNews as AdminCreateNews;
use \App\Controllers\Api\Admin\LoadNews as AdminLoadNews;
use \App\Controllers\Api\Admin\GetVehicleInputs as AdminGetVehicleInputs;
use \App\Controllers\Api\Admin\GeoDB\Create as AdminGeoDBCreate;
use \App\Controllers\Api\Admin\GeoDB\Load as AdminGeoDBLoad;
class ApiController
{
@ -73,6 +76,9 @@ class ApiController
public static function photocompress() {
return new PhotoCompress();
}
public static function geodbsearch() {
return new GeoDBSearch();
}
public static function adminsetvis() {
return new AdminPhotoSetVisibility();
}
@ -100,6 +106,12 @@ class ApiController
public static function admingetvehicleinputs() {
return new AdminGetVehicleInputs();
}
public static function admingeodbcreate() {
return new AdminGeoDBCreate();
}
public static function admingeodbload() {
return new AdminGeoDBLoad();
}
public static function vehiclesload() {
return new VehiclesLoad();
}

View file

@ -65,12 +65,15 @@ class Routes
Router::post('/api/photo/comment/$id/delete', 'ApiController@photocommentdelete');
Router::post('/api/photo/comment/$id/pin', 'ApiController@photocommentpin');
Router::get('/api/vehicles/load', 'ApiController@vehiclesload');
Router::get('/api/geodb/search', 'ApiController@geodbsearch');
if ($user->i('admin') > 0) {
Router::any('/admin', 'AdminController@index');
Router::any('/api/admin/images/setvisibility', 'ApiController@adminsetvis');
Router::any('/api/admin/createnews', 'ApiController@admincreatenews');
Router::any('/api/admin/loadnews', 'ApiController@adminloadnews');
Router::any('/api/admin/getvehicleinputs/$id', 'ApiController@admingetvehicleinputs');
Router::any('/api/admin/geodb/create', 'ApiController@admingeodbcreate');
Router::any('/api/admin/geodb/load', 'ApiController@admingeodbload');
}
Router::get('/logout', 'MainController@logout');
Router::get('/404', 'ExceptionRegister@notfound');

File diff suppressed because one or more lines are too long

BIN
static/img/loader_wb.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View file

@ -166,7 +166,16 @@ $(document).ready(function()
$('#place').autocompleteHL({
minLength: 3,
source: function(request, response)
{
var cid = $('#search_cid').val();
if (cid != 0)
$.getJSON('/api/geodb/search', { place: request.term }, response).fail(function(jx) { alert(jx.responseText); });
else response(null);
}
});
$('#image').click(function()
@ -223,7 +232,6 @@ $(document).ready(function()
$('#day, #month, #year').on('change', function() { $('#dateAbsent').hide(); });
$('#search_type').on('change', function() { changeColor(this); }).change();
// Комментарий
@ -415,7 +423,6 @@ function setDate(d, m, y)
function showHint(id) { $('#'+id+'_hint').fadeIn() }
function hideHint(id) { $('#'+id+'_hint').fadeOut() }
function changeColor(sel) { sel.className = sel.options[sel.selectedIndex].className }

View file

@ -12,12 +12,14 @@
<link rel="stylesheet" href="/static/css/notie.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>">
<link rel="stylesheet" href="/static/css/comments.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>">
<link rel="stylesheet" href="/static/css/map.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>">
<link rel="stylesheet" href="/static/css/jquery-ui-1.8.20.custom.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>">
<script src="/static/js/jquery.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/jquery-ui.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/jquery.form.min.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/core.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/index.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/core_lk.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/jquery-ui.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/selector.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/selector2.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/imageupload.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/progress.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/notie.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
@ -25,8 +27,7 @@
<script src="/static/js/comments.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/newcore.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/act.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/selector2.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/selector.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/core_lk.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/tablesort.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

View file

@ -0,0 +1,71 @@
<?php
use \App\Services\{Auth, DB};
use \App\Models\User;
?>
<h1><b>GeoDB</b></h1>
<a data-bs-toggle="modal" data-bs-target="#createGeoDB" href="#" class="btn btn-primary">Создать</a>
<table class="table" style="margin-top: 15px;">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Название</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php
$geodb = DB::query('SELECT * FROM geodb');
foreach ($geodb as $u) {
echo '<tr>
<th>' . $u['id'] . '</th>
<td>' . $u['title'] . '</td>
<td><div class="cmt-submit"><a class="btn btn-sm btn-primary" href="/admin?type=UserEdit&user_id=' . $u['id'] . '">Редактировать</a><a style="margin-left: 15px;" class="btn btn-sm btn-danger" href="/admin?type=UserEdit&user_id=' . $u['id'] . '">Удалить</a></div></td>
</tr>';
}
?>
</tbody>
</table>
<div class="modal fade" id="createGeoDB" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel"><b>Добавление элемента GeoDB</b></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Содержание</label>
<textarea class="form-control" id="exampleFormControlTextarea1" name="body" rows="3"></textarea>
</div>
</div>
<div class="modal-footer">
<a type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</a>
<a href="#" onclick="createGeoDB(document.querySelector(`textarea[name='body']`).value); return false;" data-bs-dismiss="modal" class="btn btn-primary">Добавить</a>
</div>
</div>
</div>
</div>
<script>
function createGeoDB(body) {
$.ajax({
type: "POST",
url: '/api/admin/geodb/create',
data: {
body: body
},
success: function(response) {
Notify.noty('success', 'OK!');
}
});
}
</script>