AvocadoAmber/AvocadoEdition_Light/adm/editor_font.php
2024-09-22 21:25:48 +09:00

142 lines
5 KiB
PHP

<?php
include_once __DIR__ . '/_common.php';
include_once G5_EDITOR_LIB;
if ($is_admin != 'super') {
alert_close('최고관리자만 접근 가능합니다.');
}
// 테이블이 없을 경우 생성
if (!sql_fetch_array(sql_query("DESC {$g5['font_table']}"))) {
$sql = "CREATE TABLE IF NOT EXISTS {$g5['font_table']} (
font_id INT(11) NOT NULL AUTO_INCREMENT,
font_name VARCHAR(255) NOT NULL,
font_family VARCHAR(255) NOT NULL,
font_url TEXT NOT NULL,
font_weight VARCHAR(50) NOT NULL DEFAULT 'normal',
font_style VARCHAR(50) NOT NULL DEFAULT 'normal',
PRIMARY KEY (font_id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3";
sql_query($sql, false);
}
// 목록 출력
$sql = " SELECT * FROM {$g5['font_table']} ORDER BY font_family ASC ";
$result = sql_query($sql);
$g5['title'] = "에디터 폰트 관리";
include_once __DIR__ . '/admin.head.php';
?>
<section>
<h2>폰트 등록</h2>
<form name="ffontform" method="post" action="./editor_font_update.php" onsubmit="return ffontform_submit(this);">
<input type="hidden" name="token" value="">
<input type="hidden" name="w" value="">
<div class="tbl_frm01 tbl_wrap">
<table>
<caption>폰트 입력</caption>
<colgroup>
<col class="grid_4" style="width: 140px">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row"><label for="font_name">폰트 이름<strong class="sound_only">필수</strong></label></th>
<td><input type="text" name="font_name" value="" id="font_name" required class="required frm_input"
size="50"></td>
</tr>
<tr>
<th scope="row"><label for="font_css">@font-face CSS<strong class="sound_only">필수</strong></label></th>
<td>
<span class="frm_info">@font-face CSS를 그대로 붙여넣으세요.</span>
<textarea name="font_css" id="font_css" rows="8" required class="required frm_input" style="width:100%;"
placeholder="@font-face {
font-family: 'FontName';
src: url('https://example.com/font.woff2') format('woff2');
font-weight: normal;
font-style: normal;
}"></textarea>
</td>
</tr>
</tbody>
</table>
</div>
<div class="list_confirm">
<input type="submit" value="등록" class="btn_submit" accesskey="s">
</div>
</form>
<div class="local_ov01 local_ov">
등록된 폰트 <?php echo number_format(sql_num_rows($result)) ?>개
</div>
<form name="ffontlist" id="ffontlist" method="post" action="./editor_font_update.php"
onsubmit="return ffontlist_submit(this);">
<input type="hidden" name="token" value="">
<input type="hidden" name="w" value="u">
<div class="tbl_head01 tbl_wrap">
<table>
<caption><?php echo $g5['title']; ?> 목록</caption>
<thead>
<tr>
<th scope="col" style="width: 200px">폰트 이름</th>
<th scope="col" style="width: 200px">Font Family</th>
<th scope="col">Font URL</th>
<th scope="col" style="width: 120px">Font Weight</th>
<th scope="col" style="width: 120px">Font Style</th>
<th scope="col" style="width: 80px">관리</th>
</tr>
</thead>
<tbody>
<?php
for ($i = 0; $row = sql_fetch_array($result); $i++) {
$font_id = $row['font_id'];
?>
<tr>
<td class="td_left"><?php echo get_text($row['font_name']); ?></td>
<td class="td_left"><?php echo get_text($row['font_family']); ?></td>
<td class="td_left"><?php echo get_text($row['font_url']); ?></td>
<td class="td_left"><?php echo get_text($row['font_weight']); ?></td>
<td class="td_left"><?php echo get_text($row['font_style']); ?></td>
<td class="td_mng td_mng_l">
<a href="./editor_font_update.php?w=d&amp;font_id=<?php echo $font_id ?>"
onclick="return delete_confirm(this);" class="btn btn_02">삭제</a>
</td>
</tr>
<?php
}
if ($i == 0) {
echo '<tr><td colspan="6" class="empty_table">등록된 폰트가 없습니다.</td></tr>';
}
?>
</tbody>
</table>
</div>
</form>
</section>
<section>
<?php echo help('폰트 출력을 미리 보기 위한 에디터입니다.') ?>
<?php echo editor_html('preview_content', ""); ?>
</section>
<script>
function ffontform_submit(f) {
if (f.font_css.value.trim() === "") {
alert("@font-face CSS를 입력해주세요.");
f.font_css.focus();
return false;
}
if (f.font_name.value.trim() === "") {
alert("폰트 이름을 입력해주세요.");
f.font_name.focus();
return false;
}
return true;
}
function delete_confirm(el) {
return confirm("선택한 폰트를 정말 삭제하시겠습니까?");
}
</script>
<?php
include_once __DIR__ . '/admin.tail.php';