mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 19:46:21 +05:30
Simple custom fields
Currently only supports text, textarea, checkbox and select types. Can add custom fields to posts, pages/subpages, profile.
This commit is contained in:
parent
ea2c17473f
commit
3ca9ed1922
41 changed files with 1276 additions and 67 deletions
|
|
@ -26,6 +26,11 @@ if (file_exists($tagslang)) {
|
|||
|
||||
$images = image_gallery(null, 1, 40);
|
||||
|
||||
$fields = array();
|
||||
$field_file= 'content/data/field/post.json';
|
||||
if (file_exists($field_file)) {
|
||||
$fields = json_decode(file_get_contents($field_file, true));
|
||||
}
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css"/>
|
||||
|
|
@ -188,8 +193,40 @@ $( function() {
|
|||
<label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
|
||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
||||
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error'; } } ?>" name="content" cols="20" rows="15"><?php if (isset($postContent)) { echo $postContent;} ?></textarea><br>
|
||||
<?php if(!empty($fields)):?>
|
||||
<details id="custom-fields" >
|
||||
<summary id="custom-fields-click" style="padding:10px; margin-bottom:10px; <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "background-color: #E4EBF1;" : "background-color: rgba(255,255,255,.1);");?>"><strong>Custom fields</strong></summary>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php foreach ($fields as $fld):?>
|
||||
<?php if ($fld->type == 'text'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<input type="<?php echo $fld->type;?>" class="form-control text" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" value=""/>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'textarea'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<textarea class="form-control text" id="<?php echo $fld->name;?>" rows="3" name="<?php echo $fld->name;?>"></textarea>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'checkbox'):?>
|
||||
<input type="<?php echo $fld->type;?>" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" >
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'select'):?>
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<select id="<?php echo $fld->name;?>" class="form-control" name="<?php echo $fld->name;?>">
|
||||
<?php foreach ($fld->options as $val):?>
|
||||
<option value="<?php echo $val->value;?>" ><?php echo $val->label;?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
<?php endif;?>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<br>
|
||||
<?php endif;?>
|
||||
<input type="submit" name="publish" class="btn btn-primary submit" value="<?php echo i18n('Publish');?>"/> <input type="submit" name="draft" class="btn btn-primary draft" value="<?php echo i18n('Save_as_draft');?>"/>
|
||||
<br><br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6" id="preview-col">
|
||||
|
|
@ -215,7 +252,7 @@ $( function() {
|
|||
margin: 2px 2px;
|
||||
border-top-right-radius: 2px;
|
||||
width: 190px;
|
||||
height: 140px;
|
||||
height: 140px;
|
||||
vertical-align: top;
|
||||
background-position: top left;
|
||||
background-repeat: no-repeat;
|
||||
|
|
@ -314,6 +351,7 @@ $( function() {
|
|||
var parent_page = '';
|
||||
var addEdit = 'add';
|
||||
var saveInterval = 60000;
|
||||
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
||||
|
|
@ -377,5 +415,16 @@ $('.img-container').on("click", ".the-img", function(e) {
|
|||
localStorage.setItem("preview-state", 'open');
|
||||
}
|
||||
})
|
||||
if (localStorage.getItem("custom-fields-state") === "open") {
|
||||
document.getElementById("custom-fields").setAttribute("open", "");
|
||||
}
|
||||
|
||||
document.getElementById("custom-fields-click").addEventListener("click", () => {
|
||||
if (document.getElementById("custom-fields").open) {
|
||||
localStorage.setItem("custom-fields-state", 'close');
|
||||
} else {
|
||||
localStorage.setItem("custom-fields-state", 'open');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<?php $images = image_gallery(null, 1, 40); ?>
|
||||
<?php
|
||||
|
||||
$fields = array();
|
||||
if ($type == 'is_page') {
|
||||
$field_file = 'content/data/field/page.json';
|
||||
if (file_exists($field_file)) {
|
||||
$fields = json_decode(file_get_contents($field_file, true));
|
||||
}
|
||||
} elseif ($type == 'is_subpage') {
|
||||
$field_file = 'content/data/field/subpage.json';
|
||||
if (file_exists($field_file)) {
|
||||
$fields = json_decode(file_get_contents($field_file, true));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css"/>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/jquery.min.js"></script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/jquery-ui.min.js"></script>
|
||||
|
|
@ -45,7 +61,39 @@
|
|||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
||||
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) {if (empty($postContent)) {echo 'error';}} ?>" name="content" cols="20" rows="10"><?php if (isset($postContent)) {echo $postContent;} ?></textarea>
|
||||
<br>
|
||||
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||
<?php if(!empty($fields) && $type != 'is_category'):?>
|
||||
<details id="custom-fields" >
|
||||
<summary id="custom-fields-click" style="padding:10px; margin-bottom:10px; <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "background-color: #E4EBF1;" : "background-color: rgba(255,255,255,.1);");?>"><strong>Custom fields</strong></summary>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php foreach ($fields as $fld):?>
|
||||
<?php if ($fld->type == 'text'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<input type="<?php echo $fld->type;?>" class="form-control text" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" value=""/>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'textarea'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<textarea class="form-control text" id="<?php echo $fld->name;?>" rows="3" name="<?php echo $fld->name;?>"></textarea>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'checkbox'):?>
|
||||
<input type="<?php echo $fld->type;?>" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" >
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'select'):?>
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<select id="<?php echo $fld->name;?>" class="form-control" name="<?php echo $fld->name;?>">
|
||||
<?php foreach ($fld->options as $val):?>
|
||||
<option value="<?php echo $val->value;?>" ><?php echo $val->label;?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
<?php endif;?>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<br>
|
||||
<?php endif;?>
|
||||
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||
<input id="oldfile" type="hidden" name="oldfile" class="text"/>
|
||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
||||
<?php if ($type == 'is_page' || $type == 'is_subpage') :?>
|
||||
|
|
@ -78,7 +126,7 @@
|
|||
margin: 2px 2px;
|
||||
border-top-right-radius: 2px;
|
||||
width: 190px;
|
||||
height: 140px;
|
||||
height: 140px;
|
||||
vertical-align: top;
|
||||
background-position: top left;
|
||||
background-repeat: no-repeat;
|
||||
|
|
@ -134,6 +182,7 @@
|
|||
var parent_page = '<?php echo isset($parent) ? $parent : '';?>';
|
||||
var addEdit = 'add';
|
||||
var saveInterval = 60000;
|
||||
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||
<script>
|
||||
|
|
@ -198,4 +247,15 @@ $('.img-container').on("click", ".the-img", function(e) {
|
|||
localStorage.setItem("preview-state", 'open');
|
||||
}
|
||||
})
|
||||
if (localStorage.getItem("custom-fields-state") === "open") {
|
||||
document.getElementById("custom-fields").setAttribute("open", "");
|
||||
}
|
||||
|
||||
document.getElementById("custom-fields-click").addEventListener("click", () => {
|
||||
if (document.getElementById("custom-fields").open) {
|
||||
localStorage.setItem("custom-fields-state", 'close');
|
||||
} else {
|
||||
localStorage.setItem("custom-fields-state", 'open');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
63
system/admin/views/custom-field-page.html.php
Normal file
63
system/admin/views/custom-field-page.html.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<h2 class="post-index"><?php echo i18n('custom_fields');?>: Page</h2>
|
||||
<br>
|
||||
<?php
|
||||
$field = array();
|
||||
$field_file= 'content/data/field/page.json';
|
||||
if (file_exists($field_file)) {
|
||||
$field = file_get_contents($field_file, true);
|
||||
}
|
||||
?>
|
||||
<!-- Preview Section -->
|
||||
<div id="form-preview"></div>
|
||||
<br><br>
|
||||
<!-- Form Input Section -->
|
||||
<div>
|
||||
<label for="type">Field Type</label>
|
||||
<select id="type">
|
||||
<option value="text">Text</option>
|
||||
<option value="textarea">Textarea</option>
|
||||
<option value="checkbox">Checkbox</option>
|
||||
<option value="select">Select</option>
|
||||
</select>
|
||||
<input type="text" id="name" placeholder="Name (ID)">
|
||||
<input type="text" id="label" placeholder="Label">
|
||||
<input type="text" id="value" placeholder="Value (optional)">
|
||||
|
||||
<button id="add-field" class="btn btn-primary">Add Field</button>
|
||||
|
||||
<div id="options-container" style="display: none;">
|
||||
<strong>Options</strong>
|
||||
<div id="option-list"></div>
|
||||
<button id="add-option" class="btn btn-primary">Add Option</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
<!-- Form submit Section -->
|
||||
<button class="btn btn-primary" id="saveButton"><?php echo i18n('save');?></button>
|
||||
<br><br>
|
||||
<!-- JSON Output Section -->
|
||||
<details>
|
||||
<summary>JSON Output</summary>
|
||||
<textarea id="json-output" name="page-field" style="field-sizing: content;" rows="20" class="form-control text" readonly></textarea>
|
||||
</details>
|
||||
<br><br>
|
||||
|
||||
<script>
|
||||
const fields = <?php print_r($field);?>;
|
||||
$("#saveButton").click(function(){
|
||||
var data = $('#json-output').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url();?>admin/field/page',
|
||||
dataType: 'json',
|
||||
data: {'json': data},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/form.builder.js"></script>
|
||||
63
system/admin/views/custom-field-post.html.php
Normal file
63
system/admin/views/custom-field-post.html.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<h2 class="post-index"><?php echo i18n('custom_fields');?>: Post</h2>
|
||||
<br>
|
||||
<?php
|
||||
$field = array();
|
||||
$field_file = 'content/data/field/post.json';
|
||||
if (file_exists($field_file)) {
|
||||
$field = file_get_contents($field_file, true);
|
||||
}
|
||||
?>
|
||||
<!-- Preview Section -->
|
||||
<div id="form-preview"></div>
|
||||
<br><br>
|
||||
<!-- Form Input Section -->
|
||||
<div>
|
||||
<label for="type">Field Type</label>
|
||||
<select id="type">
|
||||
<option value="text">Text</option>
|
||||
<option value="textarea">Textarea</option>
|
||||
<option value="checkbox">Checkbox</option>
|
||||
<option value="select">Select</option>
|
||||
</select>
|
||||
<input type="text" id="name" placeholder="Name (ID)">
|
||||
<input type="text" id="label" placeholder="Label">
|
||||
<input type="text" id="value" placeholder="Value (optional)">
|
||||
|
||||
<button id="add-field" class="btn btn-primary">Add Field</button>
|
||||
|
||||
<div id="options-container" style="display: none;">
|
||||
<strong>Options</strong>
|
||||
<div id="option-list"></div>
|
||||
<button id="add-option" class="btn btn-primary">Add Option</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
<!-- Form submit Section -->
|
||||
<button class="btn btn-primary" id="saveButton"><?php echo i18n('save');?></button>
|
||||
<br><br>
|
||||
<!-- JSON Output Section -->
|
||||
<details>
|
||||
<summary>JSON Output</summary>
|
||||
<textarea id="json-output" name="page-field" style="field-sizing: content;" rows="20" class="form-control text" readonly></textarea>
|
||||
</details>
|
||||
<br><br>
|
||||
|
||||
<script>
|
||||
const fields = <?php print_r($field);?>;
|
||||
$("#saveButton").click(function(){
|
||||
var data = $('#json-output').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url();?>admin/field/post',
|
||||
dataType: 'json',
|
||||
data: {'json': data},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/form.builder.js"></script>
|
||||
63
system/admin/views/custom-field-profile.html.php
Normal file
63
system/admin/views/custom-field-profile.html.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<h2 class="post-index"><?php echo i18n('custom_fields');?>: Profile</h2>
|
||||
<br>
|
||||
<?php
|
||||
$field = array();
|
||||
$field_file = 'content/data/field/profile.json';
|
||||
if (file_exists($field_file)) {
|
||||
$field = file_get_contents($field_file, true);
|
||||
}
|
||||
?>
|
||||
<!-- Preview Section -->
|
||||
<div id="form-preview"></div>
|
||||
<br><br>
|
||||
<!-- Form Input Section -->
|
||||
<div>
|
||||
<label for="type">Field Type</label>
|
||||
<select id="type">
|
||||
<option value="text">Text</option>
|
||||
<option value="textarea">Textarea</option>
|
||||
<option value="checkbox">Checkbox</option>
|
||||
<option value="select">Select</option>
|
||||
</select>
|
||||
<input type="text" id="name" placeholder="Name (ID)">
|
||||
<input type="text" id="label" placeholder="Label">
|
||||
<input type="text" id="value" placeholder="Value (optional)">
|
||||
|
||||
<button id="add-field" class="btn btn-primary">Add Field</button>
|
||||
|
||||
<div id="options-container" style="display: none;">
|
||||
<strong>Options</strong>
|
||||
<div id="option-list"></div>
|
||||
<button id="add-option" class="btn btn-primary">Add Option</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
<!-- Form submit Section -->
|
||||
<button class="btn btn-primary" id="saveButton"><?php echo i18n('save');?></button>
|
||||
<br><br>
|
||||
<!-- JSON Output Section -->
|
||||
<details>
|
||||
<summary>JSON Output</summary>
|
||||
<textarea id="json-output" name="page-field" style="field-sizing: content;" rows="20" class="form-control text" readonly></textarea>
|
||||
</details>
|
||||
<br><br>
|
||||
|
||||
<script>
|
||||
const fields = <?php print_r($field);?>;
|
||||
$("#saveButton").click(function(){
|
||||
var data = $('#json-output').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url();?>admin/field/profile',
|
||||
dataType: 'json',
|
||||
data: {'json': data},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/form.builder.js"></script>
|
||||
63
system/admin/views/custom-field-subpage.html.php
Normal file
63
system/admin/views/custom-field-subpage.html.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<h2 class="post-index"><?php echo i18n('custom_fields');?>: Subpage</h2>
|
||||
<br>
|
||||
<?php
|
||||
$field = array();
|
||||
$field_file = 'content/data/field/subpage.json';
|
||||
if (file_exists($field_file)) {
|
||||
$field = file_get_contents($field_file, true);
|
||||
}
|
||||
?>
|
||||
<!-- Preview Section -->
|
||||
<div id="form-preview"></div>
|
||||
<br><br>
|
||||
<!-- Form Input Section -->
|
||||
<div>
|
||||
<label for="type">Field Type</label>
|
||||
<select id="type">
|
||||
<option value="text">Text</option>
|
||||
<option value="textarea">Textarea</option>
|
||||
<option value="checkbox">Checkbox</option>
|
||||
<option value="select">Select</option>
|
||||
</select>
|
||||
<input type="text" id="name" placeholder="Name (ID)">
|
||||
<input type="text" id="label" placeholder="Label">
|
||||
<input type="text" id="value" placeholder="Value (optional)">
|
||||
|
||||
<button id="add-field" class="btn btn-primary">Add Field</button>
|
||||
|
||||
<div id="options-container" style="display: none;">
|
||||
<strong>Options</strong>
|
||||
<div id="option-list"></div>
|
||||
<button id="add-option" class="btn btn-primary">Add Option</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
<!-- Form submit Section -->
|
||||
<button class="btn btn-primary" id="saveButton"><?php echo i18n('save');?></button>
|
||||
<br><br>
|
||||
<!-- JSON Output Section -->
|
||||
<details>
|
||||
<summary>JSON Output</summary>
|
||||
<textarea id="json-output" name="page-field" style="field-sizing: content;" rows="20" class="form-control text" readonly></textarea>
|
||||
</details>
|
||||
<br><br>
|
||||
|
||||
<script>
|
||||
const fields = <?php print_r($field);?>;
|
||||
$("#saveButton").click(function(){
|
||||
var data = $('#json-output').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url();?>admin/field/subpage',
|
||||
dataType: 'json',
|
||||
data: {'json': data},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/form.builder.js"></script>
|
||||
36
system/admin/views/custom-field.html.php
Normal file
36
system/admin/views/custom-field.html.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<h2 class="post-index"><?php echo i18n('custom_fields');?></h2>
|
||||
<br>
|
||||
<p>Custom fields enable users to add extra, specific data fields to their content, allowing for more detailed and flexible content management.</p>
|
||||
|
||||
<p>Use <code>get_field()</code> function in your template. Example:
|
||||
<ul><li>Post, Page, Subpage: <code><?php echo get_field('field_name', $p->raw);?></code></code></li>
|
||||
<li>Profile: <code><?php echo get_field('field_name', $author->raw);?></code></code></li></ul>
|
||||
</p>
|
||||
|
||||
<table class="table post-list">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th>Type</th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Post</td>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo site_url();?>admin/field/post"><?php echo i18n('edit');?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Page</td>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo site_url();?>admin/field/page"><?php echo i18n('edit');?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Subpage</td>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo site_url();?>admin/field/subpage"><?php echo i18n('edit');?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Profile</td>
|
||||
<td><a class="btn btn-primary btn-xs" href="<?php echo site_url();?>admin/field/profile"><?php echo i18n('edit');?></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -71,6 +71,12 @@ if (file_exists($tagslang)) {
|
|||
|
||||
$images = image_gallery(null, 1, 40);
|
||||
|
||||
$fields = array();
|
||||
$field_file = 'content/data/field/post.json';
|
||||
if (file_exists($field_file)) {
|
||||
$fields = json_decode(file_get_contents($field_file, true));
|
||||
}
|
||||
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css"/>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/jquery.min.js"></script>
|
||||
|
|
@ -233,13 +239,48 @@ $( function() {
|
|||
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||
<label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
|
||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
||||
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error'; } } ?>" name="content" cols="20" rows="15"><?php echo $oldcontent ?></textarea><br>
|
||||
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error'; } } ?>" name="content" cols="20" rows="15"><?php echo $oldcontent ?></textarea>
|
||||
<br>
|
||||
|
||||
<?php if(!empty($fields)):?>
|
||||
<details id="custom-fields" >
|
||||
<summary id="custom-fields-click" style="padding:10px; margin-bottom:10px; <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "background-color: #E4EBF1;" : "background-color: rgba(255,255,255,.1);");?>"><strong>Custom fields</strong></summary>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php foreach ($fields as $fld):?>
|
||||
<?php if ($fld->type == 'text'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<input type="<?php echo $fld->type;?>" class="form-control text" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" value="<?php echo get_field($fld->name, $content);?>"/>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'textarea'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<textarea class="form-control text" id="<?php echo $fld->name;?>" rows="3" name="<?php echo $fld->name;?>"><?php echo get_field($fld->name, $content);?></textarea>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'checkbox'):?>
|
||||
<input type="<?php echo $fld->type;?>" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" <?php echo get_field($fld->name, $content);?>>
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'select'):?>
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<select id="<?php echo $fld->name;?>" class="form-control" name="<?php echo $fld->name;?>">
|
||||
<?php foreach ($fld->options as $val):?>
|
||||
<option value="<?php echo $val->value;?>" <?php if (get_field($fld->name, $content) === $val->value) { echo 'selected="selected"';} ?>><?php echo $val->label;?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
<?php endif;?>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<br>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ($isdraft[4] == 'draft') { ?>
|
||||
<input type="submit" name="publishdraft" class="btn btn-primary submit" value="<?php echo i18n('Publish_draft');?>"/> <input type="submit" name="updatedraft" class="btn btn-primary draft" value="<?php echo i18n('Update_draft');?>"/> <a class="btn btn-danger" href="<?php echo $delete ?>"><?php echo i18n('Delete');?></a>
|
||||
<?php } else { ?>
|
||||
<input type="submit" name="updatepost" class="btn btn-primary submit" value="<?php echo i18n('Update_post');?>"/> <input type="submit" name="revertpost" class="btn btn-primary revert" value="<?php echo i18n('Revert_to_draft');?>"/> <a class="btn btn-danger" href="<?php echo $delete ?>"><?php echo i18n('Delete');?></a>
|
||||
<?php }?>
|
||||
<br><br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6" id="preview-col">
|
||||
|
|
@ -265,7 +306,7 @@ $( function() {
|
|||
margin: 2px 2px;
|
||||
border-top-right-radius: 2px;
|
||||
width: 190px;
|
||||
height: 140px;
|
||||
height: 140px;
|
||||
vertical-align: top;
|
||||
background-position: top left;
|
||||
background-repeat: no-repeat;
|
||||
|
|
@ -363,6 +404,7 @@ $( function() {
|
|||
var parent_page = '';
|
||||
var addEdit = 'edit';
|
||||
var saveInterval = 60000;
|
||||
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
||||
|
|
@ -428,4 +470,15 @@ $('.img-container').on("click", ".the-img", function(e) {
|
|||
localStorage.setItem("preview-state", 'open');
|
||||
}
|
||||
})
|
||||
if (localStorage.getItem("custom-fields-state") === "open") {
|
||||
document.getElementById("custom-fields").setAttribute("open", "");
|
||||
}
|
||||
|
||||
document.getElementById("custom-fields-click").addEventListener("click", () => {
|
||||
if (document.getElementById("custom-fields").open) {
|
||||
localStorage.setItem("custom-fields-state", 'close');
|
||||
} else {
|
||||
localStorage.setItem("custom-fields-state", 'open');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ if ($type == 'is_frontpage') {
|
|||
$oldtitle = get_content_tag('t', $content, 'Welcome');
|
||||
$oldcontent = remove_html_comments($content);
|
||||
} else {
|
||||
$content = 'Welcome to our website.';
|
||||
$oldtitle = 'Welcome';
|
||||
$oldcontent = 'Welcome to our website.';
|
||||
}
|
||||
|
|
@ -27,6 +28,7 @@ if ($type == 'is_frontpage') {
|
|||
$oldcontent = remove_html_comments($content);
|
||||
$oldimage = get_content_tag('image', $content);
|
||||
} else {
|
||||
$content = i18n('Author_Description');
|
||||
$oldtitle = $user;
|
||||
$olddescription = i18n('Author_Description');
|
||||
$oldcontent = i18n('Author_Description');
|
||||
|
|
@ -34,12 +36,20 @@ if ($type == 'is_frontpage') {
|
|||
}
|
||||
|
||||
} elseif ($type == 'is_category') {
|
||||
$content = $p->body;
|
||||
$oldtitle = $p->title;
|
||||
$olddescription = $p->description;
|
||||
$oldcontent = $p->body;
|
||||
$oldmd = $p->slug;
|
||||
$url = 'content/data/category/'. $p->slug . '.md';
|
||||
if (file_exists($url)) {
|
||||
$content = file_get_contents($url);
|
||||
$oldtitle = get_content_tag('t', $content, $p->slug);
|
||||
$olddescription = get_content_tag('d', $content, remove_html_comments($content));
|
||||
$oldcontent = remove_html_comments($content);
|
||||
$oldmd = $p->slug;
|
||||
} else {
|
||||
$content = $p->body;
|
||||
$oldtitle = $p->title;
|
||||
$olddescription = $p->description;
|
||||
$oldcontent = $p->body;
|
||||
$oldmd = $p->slug;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (isset($p->file)) {
|
||||
|
|
@ -82,6 +92,24 @@ if ($type == 'is_frontpage') {
|
|||
|
||||
$images = image_gallery(null, 1, 40);
|
||||
|
||||
$fields = array();
|
||||
if ($type == 'is_page' || $type == 'is_frontpage') {
|
||||
$field_file = 'content/data/field/page.json';
|
||||
if (file_exists($field_file)) {
|
||||
$fields = json_decode(file_get_contents($field_file, true));
|
||||
}
|
||||
} elseif ($type == 'is_subpage') {
|
||||
$field_file = 'content/data/field/subpage.json';
|
||||
if (file_exists($field_file)) {
|
||||
$fields = json_decode(file_get_contents($field_file, true));
|
||||
}
|
||||
} elseif ($type == 'is_profile') {
|
||||
$field_file = 'content/data/field/profile.json';
|
||||
if (file_exists($field_file)) {
|
||||
$fields = json_decode(file_get_contents($field_file, true));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css"/>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/jquery.min.js"></script>
|
||||
|
|
@ -132,7 +160,6 @@ $images = image_gallery(null, 1, 40);
|
|||
<input type="hidden" name="is_image" value="is_image">
|
||||
<br>
|
||||
<?php endif;?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
@ -146,6 +173,38 @@ $images = image_gallery(null, 1, 40);
|
|||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
||||
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) {if (empty($postContent)) {echo 'error';}} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea>
|
||||
<br>
|
||||
<?php if(!empty($fields) && $type != 'is_category'):?>
|
||||
<details id="custom-fields" >
|
||||
<summary id="custom-fields-click" style="padding:10px; margin-bottom:10px; <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "background-color: #E4EBF1;" : "background-color: rgba(255,255,255,.1);");?>"><strong>Custom fields</strong></summary>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php foreach ($fields as $fld):?>
|
||||
<?php if ($fld->type == 'text'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<input type="<?php echo $fld->type;?>" class="form-control text" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" value="<?php echo get_field($fld->name, $content);?>"/>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'textarea'):?>
|
||||
<label><?php echo $fld->label;?></label>
|
||||
<textarea class="form-control text" id="<?php echo $fld->name;?>" rows="3" name="<?php echo $fld->name;?>"><?php echo get_field($fld->name, $content);?></textarea>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'checkbox'):?>
|
||||
<input type="<?php echo $fld->type;?>" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" <?php echo get_field($fld->name, $content);?>>
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<br>
|
||||
<?php elseif ($fld->type == 'select'):?>
|
||||
<label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
|
||||
<select id="<?php echo $fld->name;?>" class="form-control" name="<?php echo $fld->name;?>">
|
||||
<?php foreach ($fld->options as $val):?>
|
||||
<option value="<?php echo $val->value;?>" <?php if (get_field($fld->name, $content) === $val->value) { echo 'selected="selected"';} ?>><?php echo $val->label;?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
<?php endif;?>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<br>
|
||||
<?php endif;?>
|
||||
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
||||
<?php if($type == 'is_frontpage' || $type == 'is_profile') { ?>
|
||||
|
|
@ -188,7 +247,7 @@ $images = image_gallery(null, 1, 40);
|
|||
margin: 2px 2px;
|
||||
border-top-right-radius: 2px;
|
||||
width: 190px;
|
||||
height: 140px;
|
||||
height: 140px;
|
||||
vertical-align: top;
|
||||
background-position: top left;
|
||||
background-repeat: no-repeat;
|
||||
|
|
@ -277,7 +336,7 @@ $images = image_gallery(null, 1, 40);
|
|||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- Declare the base path. Important -->
|
||||
<script type="text/javascript">
|
||||
|
|
@ -286,6 +345,7 @@ $images = image_gallery(null, 1, 40);
|
|||
var parent_page = '<?php echo isset($parent) ? $parent : '';?>';
|
||||
var addEdit = 'edit';
|
||||
var saveInterval = 60000;
|
||||
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||
<?php if ($type == 'is_profile'):?>
|
||||
|
|
@ -355,4 +415,15 @@ $('.img-container').on("click", ".the-img", function(e) {
|
|||
localStorage.setItem("preview-state", 'open');
|
||||
}
|
||||
})
|
||||
if (localStorage.getItem("custom-fields-state") === "open") {
|
||||
document.getElementById("custom-fields").setAttribute("open", "");
|
||||
}
|
||||
|
||||
document.getElementById("custom-fields-click").addEventListener("click", () => {
|
||||
if (document.getElementById("custom-fields").open) {
|
||||
localStorage.setItem("custom-fields-state", 'close');
|
||||
} else {
|
||||
localStorage.setItem("custom-fields-state", 'open');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -177,6 +177,13 @@ if (isset($author[0])) {
|
|||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="<?php echo site_url();?>admin/field" class="nav-link">
|
||||
<p>
|
||||
<?php echo i18n('custom_fields');?>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif;?>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue