add setting type
This commit is contained in:
parent
a73228fa09
commit
ec82e77e7d
1 changed files with 175 additions and 19 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
class Setting
|
class Setting
|
||||||
{
|
{
|
||||||
|
public static $etc_max = 20;
|
||||||
public static $fonts;
|
public static $fonts;
|
||||||
public $idx;
|
public $idx;
|
||||||
public $html;
|
public $html;
|
||||||
|
|
@ -106,6 +107,12 @@ class Setting
|
||||||
case "fontsize":
|
case "fontsize":
|
||||||
$this->addFontSizeSetting($set["desc"], array_key_exists("default", $set) ? (is_array($set["default"]) ? $set["default"] : "16") : []);
|
$this->addFontSizeSetting($set["desc"], array_key_exists("default", $set) ? (is_array($set["default"]) ? $set["default"] : "16") : []);
|
||||||
break;
|
break;
|
||||||
|
case "number":
|
||||||
|
$this->addNumberSetting($set["desc"], array_key_exists("default", $set) ? $set["default"] : "0");
|
||||||
|
break;
|
||||||
|
case "background":
|
||||||
|
$this->addBackgroundSetting($set["desc"], array_key_exists("default", $set) ? (is_array($set["default"]) ? $set["default"] : []) : []);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,7 +128,7 @@ class Setting
|
||||||
$set->cs_value = $row['cs_value'];
|
$set->cs_value = $row['cs_value'];
|
||||||
$set->cs_name = $row['cs_name'];
|
$set->cs_name = $row['cs_name'];
|
||||||
$set->cs_descript = $row['cs_descript'];
|
$set->cs_descript = $row['cs_descript'];
|
||||||
for ($i = 1; $i <= 20; $i++) {
|
for ($i = 1; $i <= self::$etc_max; $i++) {
|
||||||
$key = "cs_etc_{$i}";
|
$key = "cs_etc_{$i}";
|
||||||
$set->$key = $row[$key];
|
$set->$key = $row[$key];
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +150,7 @@ class Setting
|
||||||
$set->cs_value = $row['cs_value'];
|
$set->cs_value = $row['cs_value'];
|
||||||
$set->cs_name = $row['cs_name'];
|
$set->cs_name = $row['cs_name'];
|
||||||
$set->cs_descript = $row['cs_descript'];
|
$set->cs_descript = $row['cs_descript'];
|
||||||
for ($i = 1; $i <= 20; $i++) {
|
for ($i = 1; $i <= self::$etc_max; $i++) {
|
||||||
$key = "cs_etc_{$i}";
|
$key = "cs_etc_{$i}";
|
||||||
$set->$key = $row[$key];
|
$set->$key = $row[$key];
|
||||||
}
|
}
|
||||||
|
|
@ -161,14 +168,14 @@ class Setting
|
||||||
$this->cs_name = $data['cs_name'];
|
$this->cs_name = $data['cs_name'];
|
||||||
$this->cs_value = $data['cs_value'];
|
$this->cs_value = $data['cs_value'];
|
||||||
$this->cs_descript = $data['cs_descript'];
|
$this->cs_descript = $data['cs_descript'];
|
||||||
for ($i = 1; $i <= 20; $i++) {
|
for ($i = 1; $i <= self::$etc_max; $i++) {
|
||||||
$key = "cs_etc_{$i}";
|
$key = "cs_etc_{$i}";
|
||||||
$this->$key = $data[$key];
|
$this->$key = $data[$key];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->cs_value = "";
|
$this->cs_value = "";
|
||||||
$this->cs_descript = "";
|
$this->cs_descript = "";
|
||||||
for ($i = 1; $i <= 20; $i++) {
|
for ($i = 1; $i <= self::$etc_max; $i++) {
|
||||||
$key = "cs_etc_{$i}";
|
$key = "cs_etc_{$i}";
|
||||||
$this->$key = "";
|
$this->$key = "";
|
||||||
}
|
}
|
||||||
|
|
@ -183,6 +190,9 @@ class Setting
|
||||||
$count += count(array_filter($this->settings, function ($setting) {
|
$count += count(array_filter($this->settings, function ($setting) {
|
||||||
return $setting["type"] == "image";
|
return $setting["type"] == "image";
|
||||||
})) ? 2 : 0;
|
})) ? 2 : 0;
|
||||||
|
$count += count(array_filter($this->settings, function ($setting) {
|
||||||
|
return $setting["type"] == "background";
|
||||||
|
})) ? 3 : 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>";
|
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>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,7 +275,7 @@ class Setting
|
||||||
public function addFontSetting($desc, $default, $placeholder = "")
|
public function addFontSetting($desc, $default, $placeholder = "")
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 20) {
|
if ($idx <= self::$etc_max) {
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$val = $this->$key1 ? $this->$key1 : (isset($default) ? $default : "");
|
$val = $this->$key1 ? $this->$key1 : (isset($default) ? $default : "");
|
||||||
|
|
||||||
|
|
@ -279,7 +289,7 @@ class Setting
|
||||||
public function addFontSizeSetting($desc, $default)
|
public function addFontSizeSetting($desc, $default)
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 20) {
|
if ($idx <= self::$etc_max) {
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$val = $this->$key1 ? $this->$key1 : (isset($default) ? $default : 16);
|
$val = $this->$key1 ? $this->$key1 : (isset($default) ? $default : 16);
|
||||||
|
|
||||||
|
|
@ -290,10 +300,24 @@ class Setting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addNumberSetting($desc, $default)
|
||||||
|
{
|
||||||
|
$idx = $this->getCurrentCount() + 1;
|
||||||
|
if ($idx <= self::$etc_max) {
|
||||||
|
$key1 = "cs_etc_{$idx}";
|
||||||
|
$val = $this->$key1 ? $this->$key1 : (isset($default) ? $default : 0);
|
||||||
|
|
||||||
|
$this->settings[] = [
|
||||||
|
"type" => "number",
|
||||||
|
"html" => "<td class=\"bo-right\">{$desc}</td><td><div class=\"setter\"><input type=\"number\" name=\"cs_etc_{$idx}[{$this->idx}]\" value=\"{$val}\" style=\"width: 60px\" min=\"-5000\" max=\"5000\" /></div></td></tr>"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function addRectSetting($desc, $default)
|
public function addRectSetting($desc, $default)
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 20) {
|
if ($idx <= self::$etc_max) {
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$values = explode("||", $this->$key1);
|
$values = explode("||", $this->$key1);
|
||||||
|
|
||||||
|
|
@ -329,7 +353,7 @@ class Setting
|
||||||
public function addRadiusSetting($desc, $default)
|
public function addRadiusSetting($desc, $default)
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 20) {
|
if ($idx <= self::$etc_max) {
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$values = explode("||", $this->$key1);
|
$values = explode("||", $this->$key1);
|
||||||
|
|
||||||
|
|
@ -365,7 +389,7 @@ class Setting
|
||||||
public function addMarginSetting($desc, $default)
|
public function addMarginSetting($desc, $default)
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 20) {
|
if ($idx <= self::$etc_max) {
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$values = explode("||", $this->$key1);
|
$values = explode("||", $this->$key1);
|
||||||
|
|
||||||
|
|
@ -401,7 +425,7 @@ class Setting
|
||||||
public function addColorSetting($desc, $default)
|
public function addColorSetting($desc, $default)
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 19) {
|
if ($idx <= self::$etc_max - 1) {
|
||||||
$idx2 = $idx + 1;
|
$idx2 = $idx + 1;
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$key2 = "cs_etc_{$idx2}";
|
$key2 = "cs_etc_{$idx2}";
|
||||||
|
|
@ -422,7 +446,7 @@ class Setting
|
||||||
public function addColor2Setting($desc, $default)
|
public function addColor2Setting($desc, $default)
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 20) {
|
if ($idx <= self::$etc_max) {
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
if (empty($default)) {
|
if (empty($default)) {
|
||||||
if ($this->$key1 === "")
|
if ($this->$key1 === "")
|
||||||
|
|
@ -454,10 +478,16 @@ class Setting
|
||||||
"outset" => "외부"
|
"outset" => "외부"
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($idx <= 19) {
|
if ($idx <= self::$etc_max - 1) {
|
||||||
$idx2 = $idx + 1;
|
$idx2 = $idx + 1;
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$key2 = "cs_etc_{$idx2}";
|
$key2 = "cs_etc_{$idx2}";
|
||||||
|
if (is_array($default) && isset($default[0]) && isset($default[1])) {
|
||||||
|
if (!isset($this->$key1))
|
||||||
|
$this->$key1 = array_key_exists($default[0], $options) ? $default[0] : "";
|
||||||
|
if (!isset($this->$key2))
|
||||||
|
$this->$key2 = intval($default[1]);
|
||||||
|
}
|
||||||
$options_html = "";
|
$options_html = "";
|
||||||
foreach ($options as $key => $val) {
|
foreach ($options as $key => $val) {
|
||||||
$k = trim($key);
|
$k = trim($key);
|
||||||
|
|
@ -471,11 +501,137 @@ class Setting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addBackgroundSetting($desc, $default)
|
||||||
|
{
|
||||||
|
if ($this->is_value_added)
|
||||||
|
return;
|
||||||
|
$idx = $this->getCurrentCount();
|
||||||
|
if ($idx == 0) {
|
||||||
|
$imgval = $this->cs_value;
|
||||||
|
$img = $this->cs_value ? "<img src=\"{$imgval}\" class=\"prev_thumb\"/>" : "이미지 미등록";
|
||||||
|
$color1 = $this->cs_etc_1;
|
||||||
|
$repeat = $this->cs_etc_2;
|
||||||
|
$align = $this->cs_etc_3;
|
||||||
|
$size = $this->cs_etc_4;
|
||||||
|
$position = $this->cs_etc_5 == "fixed" ? " selected" : "";
|
||||||
|
|
||||||
|
$repeats = ["", "", ""];
|
||||||
|
$aligns = ["", "", "", "", "", "", "", ""];
|
||||||
|
$sizes = ["", "", ""];
|
||||||
|
|
||||||
|
switch ($repeat) {
|
||||||
|
case "no-repeat":
|
||||||
|
$repeats[0] = " selected";
|
||||||
|
break;
|
||||||
|
case "repeat-x":
|
||||||
|
$repeats[1] = " selected";
|
||||||
|
break;
|
||||||
|
case "repeat-y":
|
||||||
|
$repeats[2] = " selected";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch ($align) {
|
||||||
|
case "left center":
|
||||||
|
$aligns[0] = " selected";
|
||||||
|
break;
|
||||||
|
case "left bottom":
|
||||||
|
$aligns[1] = " selected";
|
||||||
|
break;
|
||||||
|
case "center top":
|
||||||
|
$aligns[2] = " selected";
|
||||||
|
break;
|
||||||
|
case "center center":
|
||||||
|
$aligns[3] = " selected";
|
||||||
|
break;
|
||||||
|
case "center bottom":
|
||||||
|
$aligns[4] = " selected";
|
||||||
|
break;
|
||||||
|
case "right top":
|
||||||
|
$aligns[5] = " selected";
|
||||||
|
break;
|
||||||
|
case "right center":
|
||||||
|
$aligns[6] = " selected";
|
||||||
|
break;
|
||||||
|
case "right bottom":
|
||||||
|
$aligns[7] = " selected";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($size) {
|
||||||
|
case "contain":
|
||||||
|
$sizes[0] = " selected";
|
||||||
|
break;
|
||||||
|
case "cover":
|
||||||
|
$sizes[0] = " selected";
|
||||||
|
break;
|
||||||
|
case "100% 100%":
|
||||||
|
$sizes[0] = " selected";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->settings[] = [
|
||||||
|
"type" => "background",
|
||||||
|
"html" => "
|
||||||
|
<td rowspan=\"4\" class=\"bo-right bo-left txt-center\">
|
||||||
|
{$img}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class=\"setter\">직접등록<input type=\"file\" name=\"cs_value_file[{$this->idx}]\" value=\"\" size=\"50\"></div>
|
||||||
|
</td></tr><tr>
|
||||||
|
<td>
|
||||||
|
<div class=\"setter\">외부경로<input type=\"text\" name=\"cs_value[{$this->idx}]\" value=\"{$imgval}\" size=\"50\"/></div>
|
||||||
|
</td></tr><tr>
|
||||||
|
<td>
|
||||||
|
<div class=\"setter\">색상<input type=\"text\" name=\"cs_etc_1[{$this->idx}]\" value=\"{$color1}\" class=\"neo_color\" size=\"30\" maxlength=\"255\" placeholder=\"#색상코드\" /></div>
|
||||||
|
</td></tr><tr>
|
||||||
|
<td>
|
||||||
|
<div class=\"setter\">배경반복
|
||||||
|
<select name=\"cs_etc_2[{$this->idx}]\">
|
||||||
|
<option value=\"\">반복</option>
|
||||||
|
<option value=\"no-repeat\"{$repeats[0]}>반복없음</option>
|
||||||
|
<option value=\"repeat-x\"{$repeats[1]}>가로반복</option>
|
||||||
|
<option value=\"repeat-y\"{$repeats[2]}>세로반복</option>
|
||||||
|
</select>
|
||||||
|
배경위치
|
||||||
|
<select name=\"cs_etc_3[{$this->idx}]\">
|
||||||
|
<option value=\"\">왼쪽 상단</option>
|
||||||
|
<option value=\"left center\"{$aligns[0]}>왼쪽 중단</option>
|
||||||
|
<option value=\"left bottom\"{$aligns[1]}>왼쪽 하단</option>
|
||||||
|
|
||||||
|
<option value=\"center top\"{$aligns[2]}>중간 상단</option>
|
||||||
|
<option value=\"center center\"{$aligns[3]}>중간 중단</option>
|
||||||
|
<option value=\"center bottom\"{$aligns[4]}>중간 하단</option>
|
||||||
|
|
||||||
|
<option value=\"right top\"{$aligns[5]}>오른쪽 상단</option>
|
||||||
|
<option value=\"right center\"{$aligns[6]}>오른쪽 중단</option>
|
||||||
|
<option value=\"right bottom\"{$aligns[7]}>오른쪽 하단</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class=\"setter\">
|
||||||
|
배경크기
|
||||||
|
<select name=\"cs_etc_4[{$this->idx}]\">
|
||||||
|
<option value=\"\">원본크기</option>
|
||||||
|
<option value=\"contain\"{$sizes[0]}>맞춤</option>
|
||||||
|
<option value=\"cover\"{$sizes[1]}>꽉참</option>
|
||||||
|
<option value=\"100% 100%\"{$sizes[2]}>늘이기</option>
|
||||||
|
</select>
|
||||||
|
고정
|
||||||
|
<select name=\"cs_etc_5[{$this->idx}]\">
|
||||||
|
<option value=\"\">스크롤</option>
|
||||||
|
<option value=\"fixed\"{$position}>고정</option>
|
||||||
|
</select></div>
|
||||||
|
</td>"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function addSelectSetting($desc, $default, $values)
|
public function addSelectSetting($desc, $default, $values)
|
||||||
{
|
{
|
||||||
$idx = $this->getCurrentCount() + 1;
|
$idx = $this->getCurrentCount() + 1;
|
||||||
if ($idx <= 19) {
|
if ($idx <= self::$etc_max - 1) {
|
||||||
$key1 = "cs_etc_{$idx}";
|
$key1 = "cs_etc_{$idx}";
|
||||||
$options_html = "";
|
$options_html = "";
|
||||||
foreach ($values as $key => $val) {
|
foreach ($values as $key => $val) {
|
||||||
|
|
@ -509,11 +665,11 @@ class Setting
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_editor_js($id, $is_dhtml_editor = true)
|
public function get_editor_js($id, $is_dhtml_editor = true)
|
||||||
{
|
{
|
||||||
if ($is_dhtml_editor) {
|
if ($is_dhtml_editor) {
|
||||||
$js = "var {$id}_editor_data = oEditors.getById['{$id}'].getIR();\n";
|
$js = "var {$id}_editor_data = oEditors.getById['{$id}'].getIR();\n";
|
||||||
$js .= "oEditors.getById['{$id}'].exec('UPDATE_CONTENTS_FIELD', []);\n";
|
$js .= "oEditors.getById['{$id}'].exec('UPDATE_CONTENTS_FIELD', []);\n";
|
||||||
$js .= "if (jQuery.inArray(document.getElementById('{$id}').value.toLowerCase().replace(/^\s*|\s*$/g, ''), [' ','<p> </p>','<p><br></p>','<div><br></div>','<p></p>','<br>','']) != -1) {\n";
|
$js .= "if (jQuery.inArray(document.getElementById('{$id}').value.toLowerCase().replace(/^\s*|\s*$/g, ''), [' ','<p> </p>','<p><br></p>','<div><br></div>','<p></p>','<br>','']) != -1) {\n";
|
||||||
$js .= "document.getElementById('{$id}').value='';\n";
|
$js .= "document.getElementById('{$id}').value='';\n";
|
||||||
|
|
@ -552,16 +708,16 @@ class Setting
|
||||||
if (!self::$fonts) {
|
if (!self::$fonts) {
|
||||||
$sql = "SELECT * FROM {$g5['font_table']} ORDER BY font_name ASC";
|
$sql = "SELECT * FROM {$g5['font_table']} ORDER BY font_name ASC";
|
||||||
$result = sql_query($sql);
|
$result = sql_query($sql);
|
||||||
|
|
||||||
$addFontList = [];
|
$addFontList = [];
|
||||||
|
|
||||||
while ($row = sql_fetch_array($result)) {
|
while ($row = sql_fetch_array($result)) {
|
||||||
$font_name = addslashes($row['font_name']);
|
$font_name = addslashes($row['font_name']);
|
||||||
$font_family = addslashes($row['font_family']);
|
$font_family = addslashes($row['font_family']);
|
||||||
|
|
||||||
$addFontList[] = "['{$font_family}', '{$font_name}']";
|
$addFontList[] = "['{$font_family}', '{$font_name}']";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($addFontList) > 0) {
|
if (count($addFontList) > 0) {
|
||||||
self::$fonts = implode(",", $addFontList);
|
self::$fonts = implode(",", $addFontList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue