운영 기능 및 GA4 대시보드 반영

This commit is contained in:
박성필
2026-08-18 10:53:58 +09:00
parent 612e87847c
commit b492abd3b4
24 changed files with 1521 additions and 77 deletions

View File

@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
require dirname(__DIR__) . '/app/bootstrap.php';
$db = \App\Database::connection();
$slug = 'media-gallery-inline-preview';
$db->beginTransaction();
try {
$find = $db->prepare('SELECT id FROM posts WHERE slug = :slug LIMIT 1');
$find->execute(['slug' => $slug]);
$postId = (int) ($find->fetchColumn() ?: 0);
$body = implode("\n\n", [
'여러 장의 대표 이미지가 글 상단에서 자동으로 전환되는지 확인하기 위한 테스트 초안입니다.',
'[[image:1]]',
'본문 문단 사이에 현장 이미지를 배치할 수 있습니다. 이미지 토큰은 관리자 글쓰기 화면의 삽입 버튼으로 추가합니다.',
'[[image:2]]',
'이 글은 운영 반영 전 기능과 화면 구성을 확인하기 위한 전용 초안이며 공개 목록에는 노출되지 않습니다.',
]);
$values = [
'title' => '[테스트] 대표 이미지 슬라이드와 본문 이미지',
'slug' => $slug,
'category' => '시공사례',
'excerpt' => '여러 대표 이미지와 본문 중간 이미지 배치를 확인하는 테스트 전용 초안입니다.',
'body' => $body,
'author' => '(주)지티에스정보통신',
];
if ($postId === 0) {
$insertPost = $db->prepare(
"INSERT INTO posts (title, slug, category, excerpt, body, author, status, published_at)
VALUES (:title, :slug, :category, :excerpt, :body, :author, 'draft', NULL)"
);
$insertPost->execute($values);
$postId = (int) $db->lastInsertId();
} else {
$updatePost = $db->prepare(
"UPDATE posts SET title=:title, category=:category, excerpt=:excerpt, body=:body,
author=:author, status='draft', published_at=NULL, deleted_at=NULL WHERE id=:id"
);
$updatePost->execute([...$values, 'id' => $postId]);
$deleteImages = $db->prepare('DELETE FROM post_images WHERE post_id = :post_id');
$deleteImages->execute(['post_id' => $postId]);
}
$images = [
['/uploads/media-preview/slide1.jpg', '현장 통신 장비 설치 이미지', '@gtsit:gallery', 0],
['/uploads/media-preview/slide3.jpg', '건물 통신 인프라 시공 이미지', '@gtsit:gallery', 1],
['/uploads/media-preview/slide4.jpg', '사무실 네트워크 구축 이미지', '@gtsit:gallery', 2],
['/uploads/media-preview/case1.jpg', '본문에 배치한 현장 시공 이미지 첫 번째', '@gtsit:inline:1', 1001],
['/uploads/media-preview/case2.jpg', '본문에 배치한 현장 시공 이미지 두 번째', '@gtsit:inline:2', 1002],
];
$insertImage = $db->prepare(
'INSERT INTO post_images (post_id, file_path, alt_text, caption, sort_order)
VALUES (:post_id, :file_path, :alt_text, :caption, :sort_order)'
);
foreach ($images as [$filePath, $altText, $caption, $sortOrder]) {
$insertImage->execute([
'post_id' => $postId,
'file_path' => $filePath,
'alt_text' => $altText,
'caption' => $caption,
'sort_order' => $sortOrder,
]);
}
$db->commit();
echo $postId;
} catch (Throwable $exception) {
if ($db->inTransaction()) $db->rollBack();
throw $exception;
}