Initial emoticon management stuff.
This commit is contained in:
parent
05db5e00cf
commit
46aa7cee81
9 changed files with 210 additions and 1 deletions
4
assets/less/emoticon.less
Normal file
4
assets/less/emoticon.less
Normal file
|
@ -0,0 +1,4 @@
|
|||
.emoticon {
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
}
|
|
@ -137,6 +137,7 @@ html {
|
|||
// Base styles
|
||||
@import "avatar";
|
||||
@import "container";
|
||||
@import "emoticon";
|
||||
@import "flag";
|
||||
@import "navigation";
|
||||
@import "pagination";
|
||||
|
|
46
assets/less/manage/emotes.less
Normal file
46
assets/less/manage/emotes.less
Normal file
|
@ -0,0 +1,46 @@
|
|||
.manage__emotes {
|
||||
|
||||
&__actions {
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
&__emoticon {
|
||||
max-width: 100px;
|
||||
max-height: 100px;
|
||||
}
|
||||
|
||||
&__list {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__entry {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 2px;
|
||||
text-align: center;
|
||||
|
||||
&--header {
|
||||
border-bottom: 1px solid var(--accent-colour);
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
&__id,
|
||||
&__order,
|
||||
&__hierarchy {
|
||||
min-width: 40px;
|
||||
}
|
||||
|
||||
&__string {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
&__image {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
min-width: 164px;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
}
|
||||
|
||||
@import "blacklist";
|
||||
@import "emotes";
|
||||
@import "navigation";
|
||||
@import "role-item";
|
||||
@import "roles";
|
||||
|
|
|
@ -40,6 +40,7 @@ require_once 'src/comments.php';
|
|||
require_once 'src/config.php';
|
||||
require_once 'src/csrf.php';
|
||||
require_once 'src/db.php';
|
||||
require_once 'src/emotes.php';
|
||||
require_once 'src/general.php';
|
||||
require_once 'src/git.php';
|
||||
require_once 'src/integer.php';
|
||||
|
|
|
@ -6,4 +6,6 @@ if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), MSZ_PER
|
|||
return;
|
||||
}
|
||||
|
||||
echo tpl_render('manage.general.emoticons');
|
||||
echo tpl_render('manage.general.emoticons', [
|
||||
'emotes' => emotes_list(PHP_INT_MAX),
|
||||
]);
|
||||
|
|
91
src/emotes.php
Normal file
91
src/emotes.php
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
function emotes_list(int $hierarchy = 0, bool $order = true, bool $refresh = false): array {
|
||||
static $emotes = null;
|
||||
|
||||
if($refresh) {
|
||||
$emotes = null;
|
||||
}
|
||||
|
||||
if(is_null($emotes)) {
|
||||
$getEmotes = db_prepare('
|
||||
SELECT `emote_id`, `emote_order`, `emote_hierarchy`,
|
||||
`emote_string`, `emote_url`
|
||||
FROM `msz_emoticons`
|
||||
WHERE `emote_hierarchy` <= :hierarchy
|
||||
ORDER BY IF(:order, `emote_order`, `emote_id`)
|
||||
');
|
||||
$getEmotes->bindValue('hierarchy', $hierarchy);
|
||||
$getEmotes->bindValue('order', $order);
|
||||
$emotes = db_fetch_all($getEmotes);
|
||||
}
|
||||
|
||||
return $emotes ?? [];
|
||||
}
|
||||
|
||||
function emotes_add(string $string, string $url, int $hierarchy = 0, int $order = 0): int {
|
||||
if(empty($string) || empty($url)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$insertEmote = db_prepare('
|
||||
INSERT INTO `msz_emoticons` (
|
||||
`emote_order`, `emote_hierarchy`, `emote_string`, `emote_url`
|
||||
)
|
||||
VALUES (
|
||||
:order, :hierarchy, :string, :url
|
||||
)
|
||||
');
|
||||
$insertEmote->bindValue('order', $order);
|
||||
$insertEmote->bindValue('hierarchy', $hierarchy);
|
||||
$insertEmote->bindValue('string', $string);
|
||||
$insertEmote->bindValue('url', $url);
|
||||
|
||||
if(!$insertEmote->execute()) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
return db_last_insert_id();
|
||||
}
|
||||
|
||||
function emotes_add_alias(string $string, string $alias): int {
|
||||
if(empty($string) || empty($alias)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$createAlias = db_prepare('
|
||||
INSERT INTO `msz_emoticons` (
|
||||
`emote_order`, `emote_hierarchy`, `emote_string`, `emote_url`
|
||||
)
|
||||
SELECT `emote_order`, `emote_hierarchy`, :alias, `emote_url`
|
||||
FROM `msz_emoticons`
|
||||
WHERE `emote_string` = :string
|
||||
');
|
||||
$createAlias->bindValue('string', $string);
|
||||
$createAlias->bindValue('alias', $alias);
|
||||
|
||||
if(!$insertEmote->execute()) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
return db_last_insert_id();
|
||||
}
|
||||
|
||||
// use this for actually removing emoticons
|
||||
function emotes_remove_url(string $url): void {
|
||||
$removeByUrl = db_prepare('
|
||||
DELETE FROM `msz_emoticons`
|
||||
WHERE `emote_url` = :url
|
||||
');
|
||||
$removeByUrl->bindValue('url', $url);
|
||||
$removeByUrl->execute();
|
||||
}
|
||||
|
||||
// use this for removing single aliases
|
||||
function emotes_remove_string(string $string): void {
|
||||
$removeByString = db_prepare('
|
||||
DELETE FROM `msz_emoticons`
|
||||
WHERE `emote_string` = :string
|
||||
');
|
||||
$removeByString->bindValue('string', $string);
|
||||
$removeByString->execute();
|
||||
}
|
|
@ -97,6 +97,7 @@ define('MSZ_URLS', [
|
|||
'manage-general-overview' => ['/manage/general'],
|
||||
'manage-general-logs' => ['/manage/general/logs.php'],
|
||||
'manage-general-emoticons' => ['/manage/general/emoticons.php'],
|
||||
'manage-general-emoticon' => ['/manage/general/emoticon.php', ['e' => '<emote>']],
|
||||
'manage-general-settings' => ['/manage/general/settings.php'],
|
||||
'manage-general-blacklist' => ['/manage/general/blacklist.php'],
|
||||
|
||||
|
|
|
@ -1 +1,63 @@
|
|||
{% extends 'manage/general/master.twig' %}
|
||||
{% from 'macros.twig' import container_title %}
|
||||
|
||||
{% block manage_content %}
|
||||
<div class="container manage__emotes">
|
||||
{{ container_title('<i class="fas fa-grimace fa-fw"></i> Emoticons') }}
|
||||
|
||||
<div class="manage__description">
|
||||
Here you can manage emoticons and their aliases and other properties.
|
||||
</div>
|
||||
|
||||
<div class="manage__emotes__actions">
|
||||
<a class="input__button" href="{{ url('manage-general-emoticon') }}">Add New</a>
|
||||
</div>
|
||||
|
||||
<div class="manage__emotes__list">
|
||||
<div class="manage__emotes__entry manage__emotes__entry--header">
|
||||
<div class="manage__emotes__entry__id">
|
||||
ID
|
||||
</div>
|
||||
<div class="manage__emotes__entry__order">
|
||||
Order
|
||||
</div>
|
||||
<div class="manage__emotes__entry__hierarchy">
|
||||
Hier.
|
||||
</div>
|
||||
<div class="manage__emotes__entry__string">
|
||||
String
|
||||
</div>
|
||||
<div class="manage__emotes__entry__image">
|
||||
Image
|
||||
</div>
|
||||
<div class="manage__emotes__entry__actions">
|
||||
Actions
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% for emote in emotes %}
|
||||
<div id="emote-{{ emote.emote_id }}" class="manage__emotes__entry">
|
||||
<div class="manage__emotes__entry__id">
|
||||
#{{ emote.emote_id }}
|
||||
</div>
|
||||
<div class="manage__emotes__entry__order">
|
||||
{{ emote.emote_order }}
|
||||
</div>
|
||||
<div class="manage__emotes__entry__hierarchy">
|
||||
{{ emote.emote_hierarchy }}
|
||||
</div>
|
||||
<div class="manage__emotes__entry__string">
|
||||
{{ emote.emote_string }}
|
||||
</div>
|
||||
<div class="manage__emotes__entry__image">
|
||||
<img src="{{ emote.emote_url }}" alt="{{ emote.emote_string }}" class="emoticon manage__emotes__emoticon">
|
||||
</div>
|
||||
<div class="manage__emotes__entry__actions">
|
||||
<button class="input__button">Alias</button>
|
||||
<a class="input__button" href="{{ url('manage-general-emoticon', {'emote': emote.emote_id}) }}">Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Reference in a new issue