[*] скорректировал работу диалогов
[+] добавил jquery в публичную часть
This commit is contained in:
1 parent
94f387b072
commit
27ba47465f
10 files changed
+108
-12
No files matched your search
Generated
+1
-1
@@ -107,7 +107,7 @@
|
||||
<component name="PhpInterpreters">
|
||||
<interpreters>
|
||||
<interpreter id="9b5f2f5e-509e-45e2-a30a-b4d1544b217e" name="rsgrinko@dev.it-stories.ru:22 password" home="sshConfig://DATA" debugger_id="php.debugger.XDebug">
|
||||
<remote_data INTERPRETER_PATH="/usr/bin/php" HELPERS_PATH="/home/rsgrinko/.phpstorm_helpers" INITIALIZED="false" VALID="true" RUN_AS_ROOT_VIA_SUDO="false" SSH_CONFIG_ID="b4bdc3dc-f3e4-4fbe-9d94-3cb514b49751" SSH_CONFIG_NAME="rsgrinko@dev.it-stories.ru:22 password" SSH_CREDENTIALS_ID="sshConfig://rsgrinko@dev.it-stories.ru:22 password" />
|
||||
<remote_data INTERPRETER_PATH="/usr/bin/php" HELPERS_PATH="/home/rsgrinko/.phpstorm_helpers" INITIALIZED="false" VALID="true" RUN_AS_ROOT_VIA_SUDO="false" SSH_CONFIG_ID="b4bdc3dc-f3e4-4fbe-9d94-3cb514b49751" SSH_CONFIG_NAME="rsgrinko@dev.it-stories.ru:2222 password" SSH_CREDENTIALS_ID="sshConfig://rsgrinko@dev.it-stories.ru:22 password" />
|
||||
</interpreter>
|
||||
</interpreters>
|
||||
</component>
|
||||
|
||||
Generated
+1
-1
@@ -3,7 +3,7 @@
|
||||
<component name="WebServers">
|
||||
<option name="servers">
|
||||
<webServer id="afaead60-4e07-45ee-a3a6-955b92f318f9" name="dev.it-stories.ru" url="http://dev.it-stories.ru">
|
||||
<fileTransfer rootFolder="/home/rsgrinko/sites/dev.it-stories.ru" accessType="SFTP" host="dev.it-stories.ru" port="22" sshConfigId="b4bdc3dc-f3e4-4fbe-9d94-3cb514b49751" sshConfig="rsgrinko@dev.it-stories.ru:22 password">
|
||||
<fileTransfer rootFolder="/home/rsgrinko/sites/dev.it-stories.ru" accessType="SFTP" host="dev.it-stories.ru" port="2222" sshConfigId="b4bdc3dc-f3e4-4fbe-9d94-3cb514b49751" sshConfig="rsgrinko@dev.it-stories.ru:2222 password">
|
||||
<advancedOptions>
|
||||
<advancedOptions dataProtectionLevel="Private" keepAliveTimeout="0" passiveMode="true" shareSSLContext="true" />
|
||||
</advancedOptions>
|
||||
|
||||
@@ -286,3 +286,47 @@ a.fileLink:before {
|
||||
.deliveryStatus.viewed {
|
||||
background: #00f700;
|
||||
}
|
||||
|
||||
.input-file {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.input-file span {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
vertical-align: middle;
|
||||
color: rgb(255 255 255);
|
||||
text-align: center;
|
||||
background-color: #00abff;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
margin: 0;
|
||||
}
|
||||
.input-file input[type=file] {
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
opacity: 0;
|
||||
display: block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* Hover/active */
|
||||
.input-file:hover span {
|
||||
background-color: #0085c7;
|
||||
}
|
||||
.input-file:active span {
|
||||
background-color: #2E703A;
|
||||
}
|
||||
|
||||
/* Disabled */
|
||||
.input-file input[type=file]:disabled + span {
|
||||
background-color: #eee;
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! jQuery v3.7.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */
|
||||
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},C=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||C).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.0",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}function fe(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}ce.fn=ce.prototype={jquery:t,constructor:ce,length:0,toArray:function(){return ae.call(this)},get:function(e){return null==e?ae.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=ce.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return ce.each(this,e)},map:function(n){return this.pushStack(ce.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(ae.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(ce.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(ce.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:oe.sort,splice:oe.splice},ce.extend=ce.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||v(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(ce.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||ce.isPlainObject(n)?n:{},i=!1,a[t]=ce.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},ce.extend({expando:"jQuery"+(t+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==i.call(e))&&(!(t=r(e))||"function"==typeof(n=ue.call(t,"constructor")&&t.constructor)&&o.call(n)===a)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){m(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(c(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},text:function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i)return e.textContent;if(3===i||4===i)return e.nodeValue}else while(t=e[r++])n+=ce.text(t);return n},makeArray:function(e,t){var n=t||[];return null!=e&&(c(Object(e))?ce.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:se.call(t,e,n)},isXMLDoc:function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!l.test(t||n&&n.nodeName||"HTML")},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(c(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:le}),"function"==typeof Symbol&&(ce.fn[Symbol.iterator]=oe[Symbol.iterator]),ce.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var pe=oe.pop,de=oe.sort,he=oe.splice,ge="[\\x20\\t\\r\\n\\f]",ve=new RegExp("^"+ge+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ge+"+$","g");ce.contains=function(e,t){var n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(e.contains?e.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))};var f=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function p(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e}ce.escapeSelector=function(e){return(e+"").replace(f,p)};var ye=C,me=s;!function(){var e,b,w,o,a,T,r,C,d,i,k=me,S=ce.expando,E=0,n=0,s=W(),c=W(),u=W(),h=W(),l=function(e,t){return e===t&&(a=!0),0},f="checked|selected|async|autofocus|autoplay|controlLine truncated
|
||||
@@ -0,0 +1,7 @@
|
||||
$(document).ready(function () {
|
||||
$('.input-file input[type=file]').on('change', function () {
|
||||
let file = this.files[0];
|
||||
$(this).next().html(file.name);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,6 +78,20 @@
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/config.local.php';
|
||||
}
|
||||
|
||||
function dd($data): void
|
||||
{
|
||||
echo '<pre>';
|
||||
print_r($data);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
function ddd($data): void
|
||||
{
|
||||
echo '<pre>';
|
||||
print_r($data);
|
||||
echo '</pre>';
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Реализация механизма автозагрузки классов
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
use Core\Helpers\Pagination;
|
||||
use Core\Helpers\Registry;
|
||||
use Core\Helpers\SystemFunctions;
|
||||
use Core\Models\{Posts, User};
|
||||
use Core\Models\{File, Posts, User};
|
||||
|
||||
class App
|
||||
{
|
||||
@@ -57,6 +57,7 @@
|
||||
'isAdmin' => User::isAuthorized() && $USER->isAdmin(),
|
||||
'userData' => User::isAuthorized() ? $USER->getAllUserData(true) : [],
|
||||
'currentYear' => date('Y'),
|
||||
'newMessages' => User::isAuthorized() ? $USER->getDialogObject()->getUnviewedMessagesCount() : 0,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -121,7 +122,15 @@
|
||||
{
|
||||
/** @var User $USER */
|
||||
global $USER;
|
||||
$USER->getDialogObject()->sendMessage($userId, $_REQUEST['message']);
|
||||
if (empty($_FILES['file']['tmp_name'])) {
|
||||
$USER->getDialogObject()->sendMessage($userId, $_REQUEST['message']);
|
||||
} else {
|
||||
$fileObject = new File();
|
||||
$fileObject->saveFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], true);
|
||||
|
||||
$USER->getDialogObject()->sendFile($userId, $fileObject->getId(), in_array($_FILES['file']['type'], ['image/jpeg', 'image/png', 'image/gif', 'image/webp'], true));
|
||||
}
|
||||
|
||||
header('Location: /dialog/' . (int)$_REQUEST['dialogId']);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
{
|
||||
/** @var $DB DB Объект базы данных */
|
||||
$DB = DB::getInstance();
|
||||
$messages = $DB->query('SELECT * FROM ' . self::TABLE_MESSAGES . ' WHERE `dialog_id`="' . $dialogId . '"');
|
||||
$messages = $DB->query('SELECT * FROM ' . self::TABLE_MESSAGES . ' WHERE `dialog_id`="' . $dialogId . '" ORDER BY id ASC');
|
||||
if ($markDialogViewed) {
|
||||
$this->markDialogViewed($dialogId);
|
||||
}
|
||||
@@ -173,12 +173,14 @@
|
||||
/**
|
||||
* Отправка файлов
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
* @param int $to
|
||||
* @param int $fileId
|
||||
* @param bool $sendAsImage
|
||||
*
|
||||
* @return bool
|
||||
* @throws CoreException
|
||||
*/
|
||||
public function sendFile(int $to, int $fileId): bool
|
||||
public function sendFile(int $to, int $fileId, bool $sendAsImage = false): bool
|
||||
{
|
||||
if (!User::isUserExistsByParams(['id' => $to])) {
|
||||
throw new CoreException('Пользователь с идентификатором ' . $to . ' отсутствует в базе', CoreException::ERROR_USER_NOT_FOUND);
|
||||
@@ -192,7 +194,7 @@
|
||||
$DB->update(self::TABLE_DIALOGS, ['id' => $dialogId], ['viewed'=> CODE_VALUE_N, 'send' => $this->user->getId(), 'receive' => $to]);
|
||||
}
|
||||
|
||||
$result = $DB->addItem(self::TABLE_MESSAGES, ['dialog_id' => $dialogId, 'type' => self::MESSAGE_TYPE_FILE, 'user_from' => $this->user->getId(), 'user_to' => $to, 'text' => $fileId]);
|
||||
$result = $DB->addItem(self::TABLE_MESSAGES, ['dialog_id' => $dialogId, 'type' => $sendAsImage ? self::MESSAGE_TYPE_IMAGE : self::MESSAGE_TYPE_FILE, 'user_from' => $this->user->getId(), 'user_to' => $to, 'text' => $fileId]);
|
||||
return (int)$result > 0;
|
||||
}
|
||||
|
||||
@@ -210,5 +212,17 @@
|
||||
return $DB->getCountItems(self::TABLE_MESSAGES, ['dialog_id' => $dialogId, 'viewed' => CODE_VALUE_N, 'user_to' => $this->user->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение количества непрочитанных сообщений
|
||||
*
|
||||
* @return int Количество
|
||||
*/
|
||||
public function getUnviewedMessagesCount(): int
|
||||
{
|
||||
/** @var $DB DB Объект базы данных */
|
||||
$DB = DB::getInstance();
|
||||
return $DB->getCountItems(self::TABLE_MESSAGES, ['viewed' => CODE_VALUE_N, 'user_to' => $this->user->getId()]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -36,10 +36,14 @@
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<form method="POST" action="/users/{{ companionId }}/sendMessage">
|
||||
<form method="POST" action="/users/{{ companionId }}/sendMessage" enctype="multipart/form-data">
|
||||
<input type="hidden" name="dialogId" value="{{ dialog_id }}">
|
||||
<textarea name="message"></textarea>
|
||||
<button class="button w100" type="submit">Отправить</button>
|
||||
<label class="input-file w100">
|
||||
<input type="file" name="file">
|
||||
<span class="w100">Выберите файл</span>
|
||||
</label>
|
||||
<button class="button w100" type="submit" value="sendMessage">Отправить</button>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<title>{% block title %}Delta Framework{% endblock %}</title>
|
||||
<link href="/assets/css/style.css?{{ salt }}" rel="stylesheet">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<script src="/assets/js/jquery-3.7.0.min.js?{{ salt }}"></script>
|
||||
<script src="/assets/js/script.js?{{ salt }}"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -18,7 +20,7 @@
|
||||
<div class="menuItem {% if currentPage == 'index' %}active{% endif %}"><a href="/">Главная</a></div>
|
||||
<div class="menuItem"><a href="/admin/">Админка</a></div>
|
||||
{% if isAuthorized %}
|
||||
<div class="menuItem {% if currentPage == 'dialogs' %}active{% endif %}"><a href="/dialogs">Диалоги</a></div>
|
||||
<div class="menuItem {% if currentPage == 'dialogs' %}active{% endif %}"><a href="/dialogs">Диалоги{% if newMessages > 0 %} ({{ newMessages }}){% endif %}</a></div>
|
||||
{% endif %}
|
||||
<div class="menuItem {% if currentPage == 'users' %}active{% endif %}"><a href="/users">Список пользователей</a></div>
|
||||
<div class="menuItem {% if currentPage == 'info' %}active{% endif %}"><a href="/info">Информация о сборке</a></div>
|
||||
|
||||
Reference in new issue
Block a user