# Для разработчиков

# Структура Базы Данных

# Структура Базы Данных (Для разработчиков)

Компонент `Gallery3x` хранит данные в двух отдельных таблицах: одна для **файлов** (изображений) и одна для **видео**. Такое разделение позволяет гибко управлять каждым типом данных.

Вы можете взаимодействовать с этими таблицами, используя xPDO и соответствующие классы модели.

---

## Таблица Файлов (gallery3x\_files)

Здесь хранятся все загруженные файлы (в основном, изображения).

- **Имя класса:** `Gallery3x\Model\Gallery3xFile`
- **Имя таблицы:** `[[+modx.config.table_prefix]]gallery3x_files`

### Поля объекта `Gallery3xFile`

<table id="bkmrk-%D0%9A%D0%BB%D1%8E%D1%87-%28%D0%9F%D0%BE%D0%BB%D0%B5%29-%D0%A2%D0%B8%D0%BF-%D0%94%D0%B0%D0%BD%D0%BD" style="margin-bottom: 32px; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><thead style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**Ключ (Поле)**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**Тип Данных**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**Описание**</td></tr></thead><tbody style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`id`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Уникальный ID записи</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`resource_id`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ID ресурса MODX, к которому привязан файл.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`source_id`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ID источника файлов (modMediaSource).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`parent_id`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Зарезервировано для будущих функций.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`name`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Название файла (может быть отредактировано).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`description`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Описание файла.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`alt`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ALT-тег изображения.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`path`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Путь к файлу внутри источника (напр. `15/`).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`file`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Имя файла (напр. `image.jpg`).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`type`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">MIME-тип файла (`image/jpeg`).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`size`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Размер файла в байтах.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`position`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Позиция для сортировки.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**`group`**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**(Новое)** Группа (тег) для файла (напр. "Интерьер").</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`properties`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">json</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">JSON-массив с данными (превью, размеры).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`createdon`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">datetime</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Дата создания.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`createdby`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ID пользователя, создавшего запись.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`updatedon`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">datetime</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Дата последнего обновления.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`updatedby`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ID пользователя, обновившего запись.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`active`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">boolean</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Статус (1 = активен, 0 = скрыт).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`hash`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Хеш файла для проверки на дубликаты.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**`special`**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">boolean</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**(Новое)** Статус "Особенное" (1 = да, 0 = нет).</td></tr></tbody></table>

---

## Таблица Видео (gallery3x\_videos)

Здесь хранятся ссылки на видео и связанные с ними данные.

- **Имя класса:** `Gallery3x\Model\Gallery3xVideo`
- **Имя таблицы:** `[[+modx.config.table_prefix]]gallery3x_videos`

### Поля объекта `Gallery3xVideo`

<table id="bkmrk-%D0%9A%D0%BB%D1%8E%D1%87-%28%D0%9F%D0%BE%D0%BB%D0%B5%29-%D0%A2%D0%B8%D0%BF-%D0%94%D0%B0%D0%BD%D0%BD-1" style="margin-bottom: 32px; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><thead style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**Ключ (Поле)**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**Тип Данных**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**Описание**</td></tr></thead><tbody style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`id`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Уникальный ID записи</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`resource_id`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ID ресурса MODX, к которому привязано видео.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`url`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Полная ссылка на видео (YouTube, VK и т.д.).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`title`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Название видео (вводится пользователем).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`description`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Описание видео.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**`thumbnail`**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**Путь к файлу превью** (загружается вручную).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`position`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Позиция для сортировки.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**`group`**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Группа (тег) для видео.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**`service`**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">*На будущее:* Сервис видео (youtube, vk).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**`video_id`**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">string</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">*На будущее:* ID видео на сервисе.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`createdon`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">datetime</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Дата создания.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`createdby`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ID пользователя, создавшего запись.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`updatedon`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">datetime</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Дата последнего обновления.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`updatedby`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">integer</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">ID пользователя, обновившего запись.</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">`active`</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">boolean</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Статус (1 = активен, 0 = скрыт).</td></tr><tr style="font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;"><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">**`special`**</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">boolean</td><td style="border: 1px solid; font-family: 'Google Sans Text', sans-serif !important; line-height: 1.15 !important; margin-top: 0px !important;">Статус "Особенное" (1 = да, 0 = нет).</td></tr></tbody></table>

# Группы (теги) для фотографий

#### Группы (теги) для фотографий

Описание

Начиная с версии \*\*3.0.17\*\*, Gallery3x поддерживает группировку фотографий с помощью групп (тегов). Одной фотографии можно присвоить несколько групп одновременно, что позволяет гибко организовывать и фильтровать изображения.

##### Ключевые особенности:  
✅ Множественный выбор групп для одной фотографии  
✅ Глобальные группы доступны во всех галереях компонента  
✅ Быстрая фильтрация по группам в панели управления  
✅ Массовое присвоение групп выбранным фотографиям  
✅ Удобный интерфейс с визуальными "таблетками"

\---

##### Создание групп

Группы создаются динамически при редактировании фотографий. Для создания новой группы:

1\. Откройте контекстное меню на фотографии (правый клик)  
2\. Выберите "Изменить свойства"  
3\. В поле "Группа" начните вводить название группы (например, "Пейзаж")  
4\. ⚠️ ОБЯЗАТЕЛЬНО нажмите клавишу `Enter` — группа превратится в "таблетку" с крестиком  
5\. Повторите для добавления других групп  
6\. Нажмите "Сохранить"

&gt; 💡 Важно: Без нажатия `Enter` группа не будет создана! После нажатия `Enter` вы увидите, что текст превратился в цветную "таблетку" — это означает, что группа добавлена.

\---

Присвоение групп одной фотографии

Способ 1: Через свойства фотографии

1\. Правый клик на фотографии → "Изменить свойства"  
2\. В поле "Группа" введите название и нажмите `Enter`  
3\. Добавьте еще группы (каждый раз нажимая `Enter`)  
4\. Нажмите "Сохранить"

Способ 2: Выбор существующих групп

1\. Правый клик на фотографии → "Изменить свойства"  
2\. Кликните в поле "Группа" — откроется выпадающий список  
3\. Выберите существующие группы из списка (они уже созданы ранее)  
4\. Или введите новую группу и нажмите `Enter`  
5\. Нажмите "Сохранить"

\---

Массовое присвоение групп

Вы можете присвоить группы сразу нескольким фотографиям:

1\. Выделите несколько фотографий (удерживая `Ctrl` или `Shift`)  
2\. Правый клик → "Установить группу..."  
3\. В открывшемся окне выберите или создайте группы (не забывайте нажимать `Enter`)  
4\. Нажмите "Сохранить"  
5\. Группы будут \*\*добавлены\*\* к уже существующим группам этих фотографий

\---

Фильтрация по группам

В верхней панели галереи находится фильтр по группам:

1\. Откройте выпадающий список \*\*"Фильтр по группе:"\*\*  
2\. Выберите нужную группу  
3\. Галерея покажет только фотографии с этой группой  
4\. Для сброса фильтра нажмите кнопку \*\*"Сбросить"\*\*

\---

Удаление групп

Удаление группы у фотографии:

1.Правый клик на фотографии → "Изменить свойства"  
2\. Нажмите \*\*крестик (×)\*\* на "таблетке" нужной группы  
3\. Нажмите \*\*"Сохранить"\*\*

Удаление группы полностью:

Группы удаляются автоматически, когда ни одна фотография больше не использует эту группу.

\---

Где отображаются группы

\- В админке: Под каждой фотографией показываются все её группы через запятую  
\- В базе данных: Группы хранятся в поле `group` таблицы `gallery3x\_files` через разделитель `||` (стандарт MODX)

\---

Примеры использования

Пример 1: Организация по темам  
\- Создайте группы: `Природа`, `Архитектура`, `Люди`, `Животные`  
\- Присвойте фотографиям соответствующие группы  
\- Используйте фильтр для быстрого поиска нужной категории

Пример 2: Множественная классификация  
\- Фотографии могут иметь несколько групп: `Зима`, `Пейзаж`, `Закат`  
\- Это позволяет находить фото по разным критериям

Пример 3: Массовая работа  
\- Выделите 20 фотографий с одного мероприятия  
\- Присвойте им группу `Конференция 2025`  
\- Добавьте дополнительную группу `Корпоратив` некоторым из них

\---

Часто задаваемые вопросы (FAQ)

Q: Я ввожу название группы, но она не сохраняется. Почему?  
A: Вы забыли нажать клавишу \*\*`Enter`\*\* после ввода названия. Группа должна превратиться в "таблетку" с крестиком.

Q: Группы, созданные в одной галерее, видны в другой?  
A: Да! Группы теперь глобальные и доступны во всех галереях компонента.

Q: Можно ли переименовать группу?  
A: Нет, но вы можете удалить старую группу у всех фотографий и создать новую с нужным названием.

Q: Сколько групп можно присвоить одной фотографии?  
A: Неограниченное количество.

\---

Технические детали

\- Формат хранения: Группы хранятся в поле `group` через разделитель `||` (например: `Природа||Пейзаж||Зима`)  
\- Компонент UI:Используется стандартный MODX SuperBoxSelect  
\- Процессоры: `File/GetGroups`, `File/BulkSetGroup`, `File/Update`

# Кастомизация процессора получения групп (тэгов)

#####   
  
Как создать свой процессор:   


  
Пример: Фильтрация по resource\_id (Что группы были для каждого ресурса свои и не повторялись в других)  
Создайте файл: в core/components/gallery3x/src/Processors/GetGroupsByResource.php

```
<?php
namespace Gallery3x\Processors;
use Gallery3x\Model\Gallery3xFile;

class GetGroupsByResource extends GetGroupsCombined
{
    public function process()
    {
        $resourceId = $this->getProperty('resource_id');
        $allGroups = [];

        // Только для текущего ресурса
        $fileTableName = $this->modx->getTableName(Gallery3xFile::class);
        $sql = "SELECT DISTINCT `group` FROM {$fileTableName} 
                WHERE `group` IS NOT NULL 
                AND `group` != '' 
                AND `resource_id` = :resource_id
                ORDER BY `group` ASC";

        $stmt = $this->modx->prepare($sql);
        $stmt->bindValue(':resource_id', $resourceId);

        if ($stmt->execute()) {
            while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
                $groupsInRow = explode('||', $row['group']);
                foreach ($groupsInRow as $group) {
                    $group = trim($group);
                    if (!empty($group)) {
                        $allGroups[] = $group;
                    }
                }
            }
        }

        // То же для видео...

        $uniqueGroups = array_unique($allGroups);
        sort($uniqueGroups);

        $groups = [];
        foreach ($uniqueGroups as $group) {
            $groups[] = ['name' => $group];
        }

        return $this->success('', ['results' => $groups, 'total' => count($groups)]);
    }
}
```

##### Затем в настройках:

  
gallery3x.groups\_processor = Gallery3x\\Processors\\GetGroupsByResource