add setting extend

This commit is contained in:
Amberstone 2024-09-19 20:51:19 +09:00
parent dd8e0a2637
commit 2364b8d810
Signed by: amber
GPG key ID: 094B0E55F98D8BF1
6 changed files with 491 additions and 4 deletions

View file

@ -1,4 +1,7 @@
<?php
/**
* @suppress php0410
*/
$sub_menu = "300100";
include_once('./_common.php');
@ -178,7 +181,7 @@ if ($w == '') {
// 게시판 테이블 생성
$file = file('./assets/sql_write.sql');
$sql = implode($file, "\n");
$sql = implode("\n", $file);
$create_table = $g5['write_prefix'] . $bo_table;
@ -545,4 +548,3 @@ if ($all_fields) {
delete_cache_latest($bo_table);
goto_url("./board_form.php?w=u&bo_table={$bo_table}&amp;{$qstr}");
?>

View file

@ -1,4 +1,7 @@
<?php
/**
* @suppress php0410
*/
$sub_menu = "100300";
include_once('./_common.php');
@ -163,4 +166,4 @@ fwrite($f, $css);
fclose($f);
@chmod($file, G5_FILE_PERMISSION);
goto_url('./design_form.php', false);
goto_url('./design_form.php');

View file

@ -73,4 +73,4 @@ $sql = " update {$g5['config_table']}
cf_1 = '{$_POST['cf_1']}'";
sql_query($sql);
goto_url('./site_config_form.php', false);
goto_url('./site_config_form.php');

View file

@ -0,0 +1,15 @@
<?php
/**
* THIS MODULE PROHIBITS DISTRIBUTION TO OTHERS WITHOUT AUTHOR'S PERMISSION.
* @class sharlayan.extendlib.php
* @author arcturus (contact@sharlayan.net / https://info.drk.st/about)
* @brief extend gnuboard5 extend
* @license LGPL 2.1
* @suppress PHP0413
*/
define("__EXT_DIR__", __DIR__);
foreach (glob(__DIR__ . "/sharlayan" . '/*.php') as $filename) {
require_once $filename;
}

View file

@ -0,0 +1,72 @@
<?php
/**
* THIS MODULE PROHIBITS DISTRIBUTION TO OTHERS WITHOUT AUTHOR'S PERMISSION.
* @class Document
* @author arcturus (contact@sharlayan.net / https://info.drk.st/about)
* @brief gnuboard document extend class
* @version 1.1.0
* @license LGPL 2.1
*/
class Document
{
public $wr_id; // int
public $wr_num; // int
public $wr_reply; // string
public $wr_parent; // int
public $wr_is_comment; // int
public $wr_comment; // int
public $wr_comment_reply; // string
public $ca_name; // string
public $wr_option;
public $wr_subject; // string
public $wr_content; // string
public $wr_link1; // string
public $wr_link2; // string
public $wr_link1_hit; // int
public $wr_link2_hit; // int
public $wr_hit; // int
public $wr_good; // int
public $wr_nogood; // int
public $mb_id; // string
public $wr_password; // string
public $wr_name; // string
public $wr_email; // string
public $wr_homepage; // string
public $wr_datetime;
public $wr_file; // int
public $wr_last; // string
public $wr_ip; // string
public $wr_facebook_user; // string
public $wr_twitter_user; // string
public $wr_dice1; // int
public $wr_dice2; // int
public $wr_log; // string
public $wr_item; // int
public $wr_item_log; // string
public $wr_action; // string
public $wr_secret; // int
public $wr_adult; // int
public $wr_wide; // int
public $wr_plip; // int
public $wr_noname; // int
public $wr_ing; // int
public $ch_id; // int
public $ch_side; // int
public $ch_class; // int
public $ti_id; // int
public $ma_id; // int
public $wr_width; // int
public $wr_height; // int
public $wr_url; // string
public $wr_type; // string
public $wr_1; // string
public $wr_2; // string
public $wr_3; // string
public $wr_4; // string
public $wr_5; // string
public $wr_6; // string
public $wr_7; // string
public $wr_8; // string
public $wr_9; // string
public $wr_10; // string
}

View file

@ -0,0 +1,395 @@
<?php
/**
* THIS MODULE PROHIBITS DISTRIBUTION TO OTHERS WITHOUT AUTHOR'S PERMISSION.
* @class Setting
* @author arcturus (contact@sharlayan.net / https://info.drk.st/about)
* @brief gnuboard config extend class
* @version 1.1.0
* @license LGPL 2.1
*/
class Setting
{
public $idx;
public $html;
public array $settings;
public string $title;
public int $cs_id;
public string $cs_name;
public string $cs_value;
public string $cs_descript;
public string $cs_etc_1;
public string $cs_etc_2;
public string $cs_etc_3;
public string $cs_etc_4;
public string $cs_etc_5;
public string $cs_etc_6;
public string $cs_etc_7;
public string $cs_etc_8;
public string $cs_etc_9;
public string $cs_etc_10;
public string $cs_etc_11;
public string $cs_etc_12;
public string $cs_etc_13;
public string $cs_etc_14;
public string $cs_etc_15;
public string $cs_etc_16;
public string $cs_etc_17;
public string $cs_etc_18;
public string $cs_etc_19;
public string $cs_etc_20;
public bool $is_value_added;
public function __construct($idx, $title, $name, $data = [], $init = true)
{
$this->idx = $idx;
$this->cs_name = $name;
$this->title = $title;
$this->html = "";
$this->is_value_added = false;
if ($init) {
$this->init();
}
if (!empty($data)) {
foreach ($data as $val) {
switch ($val["type"]) {
case "desc":
$this->addDescription($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : []);
break;
case "text":
$this->addTextSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : [], array_key_exists("placeholder", $val) ? $val["placeholder"] : "");
break;
case "textarea":
$this->addTextareaSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : [], array_key_exists("placeholder", $val) ? $val["placeholder"] : "");
break;
case "image":
$this->addImageSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : []);
break;
case "select":
$this->addSelectSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : [], array_key_exists("values", $val) ? $val["values"] : "");
break;
case "color":
$this->addColorSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : []);
break;
case "color2":
$this->addColor2Setting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : []);
break;
case "border":
$this->addBorderSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : []);
break;
case "rect":
$this->addRectSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : []);
break;
case "radius":
$this->addRadiusSetting($val["desc"], array_key_exists("default", $val) ? (is_array($val["default"]) ? $val["default"] : []) : []);
break;
}
}
}
}
public static function getSettingList()
{
global $g5;
$css = [];
$sql = sql_query("SELECT * FROM {$g5['css_table']}");
while ($row = sql_fetch_array($sql)) {
$set = new Setting(0, "", "", [], false);
$set->cs_id = $row['cs_id'];
$set->cs_value = $row['cs_value'];
$set->cs_name = $row['cs_name'];
$set->cs_descript = $row['cs_descript'];
for ($i = 1; $i <= 20; $i++) {
$key = "cs_etc_{$i}";
$set->$key = $row[$key];
}
$css[$row['cs_name']] = $set;
}
return $css;
}
public function init()
{
global $g5;
$this->settings = [];
$data = sql_fetch("SELECT * FROM {$g5['css_table']} WHERE cs_name = '{$this->cs_name}'");
if ($data) {
$this->cs_id = intval($data['cs_id']);
$this->cs_name = $data['cs_name'];
$this->cs_value = $data['cs_value'];
$this->cs_descript = $data['cs_descript'];
for ($i = 1; $i <= 20; $i++) {
$key = "cs_etc_{$i}";
$this->$key = $data[$key];
}
} else {
$this->cs_value = "";
$this->cs_descript = "";
for ($i = 1; $i <= 20; $i++) {
$key = "cs_etc_{$i}";
$this->$key = "";
}
}
}
public function addHeader()
{
$count = count(array_filter($this->settings, function ($setting) {
return $setting["type"] != "image";
}));
$count += count(array_filter($this->settings, function ($setting) {
return $setting["type"] == "image";
})) ? 2 : 0;
return "<tr><th rowspan=\"{$count}\" scope=\"row\"><em>{$this->idx}</em>{$this->title}<input type=\"text\" name=\"cs_name[{$this->idx}]\" value=\"{$this->cs_name}\" readonly size=\"15\" /></th>";
}
public function getCurrentCount()
{
$count = 0;
foreach ($this->settings as $setting) {
switch ($setting["type"]) {
case "image":
case "text":
case "desc":
break;
case "color":
case "border":
$count += 2;
break;
default:
$count++;
break;
}
}
return $count;
}
public function addDescription($text, $default)
{
$this->settings[] = [
"type" => "desc",
"html" => "<td colspan=\"2\" style=\"color: #C66; font-size: 13px; background: #fff0f0\">{$text}</td></tr>"
];
}
public function addTextSetting($desc, $default, $placeholder)
{
if ($this->is_value_added)
return;
$this->settings[] = [
"type" => "text",
"html" => "<td class=\"bo-right\">{$desc}</td><td><div class=\"setter\"><input type=\"text\" name=\"cs_value[{$this->idx}]\" value=\"{$this->cs_value}\" size=\"100\" placeholder=\"{$placeholder}\" /></div></td></tr>"
];
$this->is_value_added = true;
}
public function addTextareaSetting($desc, $default, $placeholder)
{
if ($this->is_value_added)
return;
$this->settings[] = [
"type" => "text",
"html" => "<td class=\"bo-right\">{$desc}</td><td><div class=\"setter\"><textarea name=\"cs_value[{$this->idx}]\" placeholder=\"{$placeholder}\">{$this->cs_value}</textarea></div></td></tr>"
];
$this->is_value_added = true;
}
public function addImageSetting($desc, $default)
{
if ($this->is_value_added)
return;
$image_set = $this->cs_value != "" ? "<img src=\"{$this->cs_value}\" class=\"prev_thumb\">" : "{$desc} 이미지 미등록";
$this->settings[] = [
"type" => "image",
"html" => "<td rowspan=\"2\" class=\"bo-right\">{$image_set}</td><td><div class=\"setter\">직접등록<input type=\"file\" name=\"cs_value_file[{$this->idx}]\" value=\"\" size=\"50\"></div></td><tr><td><div class=\"setter\">외부경로<input type=\"text\" name=\"cs_value[{$this->idx}]\" value=\"{$this->cs_value}\" size=\"50\"/></div></td></tr>"
];
$this->is_value_added = true;
}
public function addRectSetting($desc, $default)
{
$idx = $this->getCurrentCount() + 1;
if ($idx <= 20) {
$key1 = "cs_etc_{$idx}";
$values = explode("||", $this->$key1);
if (empty($default)) {
$default = [0, 0, 0, 0];
}
if (count($values) < 6) {
$values = array_merge([""], $default, [""]);
}
foreach ($values as &$val) {
$val = intval($val);
}
$this->settings[] = [
"type" => "rect",
"html" => "<td class=\"bo-right\">{$desc}</td>
<td>
<div class=\"setter\">
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\">X<input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[1]}\"/>px</div>
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\">Y<input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[2]}\"/>px</div>
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\">너비<input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[3]}\"/>px</div>
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\">높이<input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[4]}\"/>px</div>
</div>
</td>
</tr>"
];
}
// error
}
public function addRadiusSetting($desc, $default)
{
$idx = $this->getCurrentCount() + 1;
if ($idx <= 20) {
$key1 = "cs_etc_{$idx}";
$values = explode("||", $this->$key1);
if (empty($default)) {
$default = [0, 0, 0, 0];
}
if (count($values) < 6) {
$values = array_merge([""], $default, [""]);
}
foreach ($values as &$val) {
$val = intval($val);
}
$this->settings[] = [
"type" => "radius",
"html" => "<td class=\"bo-right\">{$desc}</td>
<td>
<div class=\"setter\">
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\"><div style=\"width: 16px; height: 16px; background: #866; box-sizing: border-box; border-radius: 8px 0 0 0;\"></div><input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[1]}\"/>px</div>
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\"><div style=\"width: 16px; height: 16px; background: #866; box-sizing: border-box; border-radius: 0 8px 0 0;\"></div><input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[2]}\"/>px</div>
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\"><div style=\"width: 16px; height: 16px; background: #866; box-sizing: border-box; border-radius: 0 0 8px 0;\"></div><input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[3]}\"/>px</div>
<div style=\"display:flex;gap:8px;border:1px solid #F4F4F2;align-items:center;padding:4px 8px;width:120px;justify-content:end;\"><div style=\"width: 16px; height: 16px; background: #866; box-sizing: border-box; border-radius: 0 0 0 8px;\"></div><input type=\"number\" id=\"cs_etc_{$idx}_1_{$this->cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[4]}\"/>px</div>
</div>
</td>
</tr>"
];
}
// error
}
public function addColorSetting($desc, $default)
{
$idx = $this->getCurrentCount() + 1;
if ($idx <= 19) {
$idx2 = $idx + 1;
$key1 = "cs_etc_{$idx}";
$key2 = "cs_etc_{$idx2}";
if (empty($default)) {
if ($this->$key1 === "")
$this->$key1 = "#000000";
if ($this->$key2 === "")
$this->$key2 = "0";
}
$this->settings[] = [
"type" => "color",
"html" => "<td class=\"bo-right\">{$desc}</td><td><div class=\"setter\">색상<input type=\"text\" name=\"cs_etc_{$idx}[{$this->idx}]\" value=\"{$this->$key1}\" class=\"colorpicker\" size=\"30\" maxlength=\"255\" placeholder=\"#색상코드\" />투명도<input type=\"number\" name=\"cs_etc_{$idx2}[{$this->idx}]\" value=\"{$this->$key2}\" placeholder=\"0\" title=\"투명도\" style=\"width:45px;\"/>%</div></td></tr>"
];
}
// error
}
public function addColor2Setting($desc, $default)
{
$idx = $this->getCurrentCount() + 1;
if ($idx <= 20) {
$key1 = "cs_etc_{$idx}";
if (empty($default)) {
if ($this->$key1 === "")
$this->$key1 = "#000000FF";
} else {
if ($this->$key1 === "")
$this->$key1 = $default[0];
}
$this->settings[] = [
"type" => "color2",
"html" => "<td class=\"bo-right\">{$desc}</td><td><div class=\"setter\">색상<input type=\"text\" name=\"cs_etc_{$idx}[{$this->idx}]\" value=\"{$this->$key1}\" class=\"neo_color\" size=\"30\" maxlength=\"255\" placeholder=\"#색상코드\" /></td></tr>"
];
}
// error
}
public function addBorderSetting($desc, $default)
{
$idx = $this->getCurrentCount() + 1;
$options = [
" " => "사용 안 함",
"dotted" => "점선",
"dashed" => "대시",
"solid" => "직선",
"double" => "이중선",
"groove" => "내부 경사",
"ridge" => "외부 경사",
"inset" => "내부",
"outset" => "외부"
];
if ($idx <= 19) {
$idx2 = $idx + 1;
$key1 = "cs_etc_{$idx}";
$key2 = "cs_etc_{$idx2}";
$options_html = "";
foreach ($options as $key => $val) {
$k = trim($key);
$s = $this->$key1 == $k ? " selected" : "";
$options_html .= "<option value=\"{$k}\"{$s}>{$val}</option>";
}
$this->settings[] = [
"type" => "border",
"html" => "<td class=\"bo-right\">{$desc}</td><td><div class=\"setter\"><select name=\"cs_etc_{$idx}[{$this->idx}]\">{$options_html}</select>두께<input type=\"number\" name=\"cs_etc_{$idx2}[{$this->idx}]\" value=\"{$this->$key2}\" placeholder=\"0\" title=\"두께\" style=\"width:45px;\"/></div></td></tr>"
];
}
}
public function addSelectSetting($desc, $default, $values)
{
$idx = $this->getCurrentCount() + 1;
if ($idx <= 19) {
$key1 = "cs_etc_{$idx}";
$options_html = "";
foreach ($values as $key => $val) {
$k = trim($key);
$s = $this->$key1 == $k ? " selected" : "";
$options_html .= "<option value=\"{$k}\"{$s}>{$val}</option>";
}
$this->settings[] = [
"type" => "select",
"html" => "<td class=\"bo-right\">{$desc}</td><td><div class=\"setter\"><select name=\"cs_etc_{$idx}[{$this->idx}]\">{$options_html}</select></div></td></tr>"
];
}
}
public function getExplodeValue($idx)
{
$key = "cs_etc_{$idx}";
return explode("||", $this->$key);
}
public function getSettingHtml()
{
$html = "";
foreach ($this->settings as $idx => $val) {
if ($html == "") {
$html .= $this->addHeader();
} else {
$html .= "<tr>";
}
$html .= $val['html'];
}
return $html;
}
}