mirror of
https://github.com/danpros/htmly.git
synced 2026-04-21 13:06:22 +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
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -341,3 +341,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -332,3 +332,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Tambahkan postingan ke Indeks"
|
||||||
clear_search_index = "Hapus Indeks Pencarian"
|
clear_search_index = "Hapus Indeks Pencarian"
|
||||||
unindexed_posts = "Postingan berikut belum masuk ke Indeks Pencarian"
|
unindexed_posts = "Postingan berikut belum masuk ke Indeks Pencarian"
|
||||||
indexed_posts = "Postingan sudah terindeks"
|
indexed_posts = "Postingan sudah terindeks"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Aggiungi gli articoli all'Indice di ricerca"
|
||||||
clear_search_index = "Cancella l'Indice di ricerca"
|
clear_search_index = "Cancella l'Indice di ricerca"
|
||||||
unindexed_posts = "Qui ci sono gli articoli che non sono stati indicizzati"
|
unindexed_posts = "Qui ci sono gli articoli che non sono stati indicizzati"
|
||||||
indexed_posts = "Gli articoli sono stati indicizzati"
|
indexed_posts = "Gli articoli sono stati indicizzati"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Voeg berichten toe aan Zoek Index"
|
||||||
clear_search_index = "Maak de Zoek Index leeg"
|
clear_search_index = "Maak de Zoek Index leeg"
|
||||||
unindexed_posts = "Hier zijn de berichten die nog niet geindexeerd zijn"
|
unindexed_posts = "Hier zijn de berichten die nog niet geindexeerd zijn"
|
||||||
indexed_posts = "Berichten zijn deindexeerd"
|
indexed_posts = "Berichten zijn deindexeerd"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -331,3 +331,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -331,3 +331,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -342,3 +342,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "添加文章到索引"
|
||||||
clear_search_index = "清除搜索索引"
|
clear_search_index = "清除搜索索引"
|
||||||
unindexed_posts = "未被索引的文章"
|
unindexed_posts = "未被索引的文章"
|
||||||
indexed_posts = "文章已被索引"
|
indexed_posts = "文章已被索引"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ add_search_index = "Add posts to Search Index"
|
||||||
clear_search_index = "Clear Search Index"
|
clear_search_index = "Clear Search Index"
|
||||||
unindexed_posts = "Here are the posts that have not been indexed"
|
unindexed_posts = "Here are the posts that have not been indexed"
|
||||||
indexed_posts = "Posts has been indexed"
|
indexed_posts = "Posts has been indexed"
|
||||||
|
custom_fields = "Custom fields"
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ function remove_accent($str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add content
|
// Add content
|
||||||
function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null, $autoSave = null, $oldfile = null)
|
function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null, $autoSave = null, $oldfile = null, $field = null)
|
||||||
{
|
{
|
||||||
if (!is_null($autoSave)) {
|
if (!is_null($autoSave)) {
|
||||||
$draft = 'draft';
|
$draft = 'draft';
|
||||||
|
|
@ -214,7 +214,15 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty
|
||||||
} else {
|
} else {
|
||||||
$post_media = "";
|
$post_media = "";
|
||||||
}
|
}
|
||||||
$post_content = "<!--t " . $post_title . " t-->" . $post_description . $tagmd . $post_media . "\n\n" . $content;
|
|
||||||
|
$customField = "";
|
||||||
|
if (!empty($field)) {
|
||||||
|
foreach ($field as $key => $val) {
|
||||||
|
$customField .= "\n<!--" . $key . ' ' . $val . ' ' . $key . "-->";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_content = "<!--t " . $post_title . " t-->" . $post_description . $tagmd . $post_media . $customField . "\n\n" . $content;
|
||||||
|
|
||||||
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
||||||
|
|
||||||
|
|
@ -312,7 +320,7 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit content
|
// Edit content
|
||||||
function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null, $autoSave = null)
|
function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null, $autoSave = null, $field = null)
|
||||||
{
|
{
|
||||||
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
|
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
|
||||||
$tag = array_filter(array_unique($tag));
|
$tag = array_filter(array_unique($tag));
|
||||||
|
|
@ -398,7 +406,15 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
|
||||||
} else {
|
} else {
|
||||||
$post_media = "";
|
$post_media = "";
|
||||||
}
|
}
|
||||||
$post_content = "<!--t " . $post_title . " t-->" . $post_description . $tagmd . $post_media . "\n\n" . $content;
|
|
||||||
|
$customField = "";
|
||||||
|
if (!empty($field)) {
|
||||||
|
foreach ($field as $key => $val) {
|
||||||
|
$customField .= "\n<!--" . $key . ' ' . $val . ' ' . $key . "-->";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_content = "<!--t " . $post_title . " t-->" . $post_description . $tagmd . $post_media . $customField . "\n\n" . $content;
|
||||||
|
|
||||||
$dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/' . $type . '/';
|
$dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/' . $type . '/';
|
||||||
$dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/';
|
$dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/';
|
||||||
|
|
@ -578,7 +594,7 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add static page
|
// Add static page
|
||||||
function add_page($title, $url, $content, $draft, $description = null, $autoSave = null, $oldfile = null)
|
function add_page($title, $url, $content, $draft, $description = null, $autoSave = null, $oldfile = null, $field = null)
|
||||||
{
|
{
|
||||||
if (!is_null($autoSave)) {
|
if (!is_null($autoSave)) {
|
||||||
$draft = 'draft';
|
$draft = 'draft';
|
||||||
|
|
@ -613,7 +629,14 @@ function add_page($title, $url, $content, $draft, $description = null, $autoSave
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
$customField = "";
|
||||||
|
if (!empty($field)) {
|
||||||
|
foreach ($field as $key => $val) {
|
||||||
|
$customField .= "\n<!--" . $key . ' ' . $val . ' ' . $key . "-->";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $customField . "\n\n" . $content;
|
||||||
|
|
||||||
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
||||||
|
|
||||||
|
|
@ -663,7 +686,7 @@ function add_page($title, $url, $content, $draft, $description = null, $autoSave
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add static sub page
|
// Add static sub page
|
||||||
function add_sub_page($title, $url, $content, $static, $draft, $description = null, $autoSave = null, $oldfile = null)
|
function add_sub_page($title, $url, $content, $static, $draft, $description = null, $autoSave = null, $oldfile = null, $field = null)
|
||||||
{
|
{
|
||||||
if (!is_null($autoSave)) {
|
if (!is_null($autoSave)) {
|
||||||
$draft = 'draft';
|
$draft = 'draft';
|
||||||
|
|
@ -698,9 +721,16 @@ function add_sub_page($title, $url, $content, $static, $draft, $description = nu
|
||||||
} else {
|
} else {
|
||||||
$post_url = $post_url;
|
$post_url = $post_url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$customField = "";
|
||||||
|
if (!empty($field)) {
|
||||||
|
foreach ($field as $key => $val) {
|
||||||
|
$customField .= "\n<!--" . $key . ' ' . $val . ' ' . $key . "-->";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $customField . "\n\n" . $content;
|
||||||
|
|
||||||
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
||||||
|
|
||||||
|
|
@ -744,7 +774,7 @@ function add_sub_page($title, $url, $content, $static, $draft, $description = nu
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit static page and sub page
|
// Edit static page and sub page
|
||||||
function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination = null, $description = null, $static = null, $autoSave = null)
|
function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination = null, $description = null, $static = null, $autoSave = null, $field = null)
|
||||||
{
|
{
|
||||||
$dir = pathinfo($oldfile, PATHINFO_DIRNAME);
|
$dir = pathinfo($oldfile, PATHINFO_DIRNAME);
|
||||||
$fn = explode('.', pathinfo($oldfile, PATHINFO_FILENAME));
|
$fn = explode('.', pathinfo($oldfile, PATHINFO_FILENAME));
|
||||||
|
|
@ -770,7 +800,14 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
|
||||||
$post_description = "";
|
$post_description = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
$customField = "";
|
||||||
|
if (!empty($field)) {
|
||||||
|
foreach ($field as $key => $val) {
|
||||||
|
$customField .= "\n<!--" . $key . ' ' . $val . ' ' . $key . "-->";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $customField . "\n\n" . $content;
|
||||||
|
|
||||||
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
||||||
|
|
||||||
|
|
@ -980,7 +1017,7 @@ function edit_category($title, $url, $content, $oldfile, $destination = null, $d
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit user profile
|
// Edit user profile
|
||||||
function edit_profile($title, $content, $user, $description = null, $image = null)
|
function edit_profile($title, $content, $user, $description = null, $image = null, $field)
|
||||||
{
|
{
|
||||||
$description = safe_html($description);
|
$description = safe_html($description);
|
||||||
if ($description !== null) {
|
if ($description !== null) {
|
||||||
|
|
@ -997,8 +1034,16 @@ function edit_profile($title, $content, $user, $description = null, $image = nul
|
||||||
} else {
|
} else {
|
||||||
$avatar = "";
|
$avatar = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$customField = "";
|
||||||
|
if (!empty($field)) {
|
||||||
|
foreach ($field as $key => $val) {
|
||||||
|
$customField .= "\n<!--" . $key . ' ' . $val . ' ' . $key . "-->";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$user_title = safe_html($title);
|
$user_title = safe_html($title);
|
||||||
$user_content = '<!--t ' . $user_title . ' t-->' . $profile_description . $avatar . "\n\n" . $content;
|
$user_content = '<!--t ' . $user_title . ' t-->' . $profile_description . $avatar . $customField . "\n\n" . $content;
|
||||||
|
|
||||||
if (!empty($user_title) && !empty($user_content)) {
|
if (!empty($user_title) && !empty($user_content)) {
|
||||||
|
|
||||||
|
|
@ -1017,10 +1062,18 @@ function edit_profile($title, $content, $user, $description = null, $image = nul
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit homepage
|
// Edit homepage
|
||||||
function edit_frontpage($title, $content)
|
function edit_frontpage($title, $content, $field = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$customField = "";
|
||||||
|
if (!empty($field)) {
|
||||||
|
foreach ($field as $key => $val) {
|
||||||
|
$customField .= "\n<!--" . $key . ' ' . $val . ' ' . $key . "-->";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$front_title = safe_html($title);
|
$front_title = safe_html($title);
|
||||||
$front_content = '<!--t ' . $front_title . ' t-->' . "\n\n" . $content;
|
$front_content = '<!--t ' . $front_title . ' t-->' . $customField . "\n\n" . $content;
|
||||||
|
|
||||||
if (!empty($front_title) && !empty($front_content)) {
|
if (!empty($front_title) && !empty($front_content)) {
|
||||||
|
|
||||||
|
|
@ -1261,7 +1314,7 @@ function find_draft_page($static = null)
|
||||||
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||||
|
|
||||||
if ($counter == 'true') {
|
if ($counter == 'true') {
|
||||||
$post->views = get_views('page_' . $post->slug, $post->file, $views);
|
$post->views = get_views('page_' . $post->slug, $views);
|
||||||
} else {
|
} else {
|
||||||
$post->views = null;
|
$post->views = null;
|
||||||
}
|
}
|
||||||
|
|
@ -1340,7 +1393,7 @@ function find_draft_subpage($static = null, $sub_static = null)
|
||||||
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||||
|
|
||||||
if ($counter == 'true') {
|
if ($counter == 'true') {
|
||||||
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file, $views);
|
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $views);
|
||||||
} else {
|
} else {
|
||||||
$post->views = null;
|
$post->views = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@ if (file_exists($tagslang)) {
|
||||||
|
|
||||||
$images = image_gallery(null, 1, 40);
|
$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"/>
|
<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>
|
<label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
|
||||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
<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>
|
<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');?>"/>
|
<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>
|
</div>
|
||||||
<div class="col-sm-6" id="preview-col">
|
<div class="col-sm-6" id="preview-col">
|
||||||
|
|
@ -215,7 +252,7 @@ $( function() {
|
||||||
margin: 2px 2px;
|
margin: 2px 2px;
|
||||||
border-top-right-radius: 2px;
|
border-top-right-radius: 2px;
|
||||||
width: 190px;
|
width: 190px;
|
||||||
height: 140px;
|
height: 140px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
background-position: top left;
|
background-position: top left;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
@ -314,6 +351,7 @@ $( function() {
|
||||||
var parent_page = '';
|
var parent_page = '';
|
||||||
var addEdit = 'add';
|
var addEdit = 'add';
|
||||||
var saveInterval = 60000;
|
var saveInterval = 60000;
|
||||||
|
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||||
</script>
|
</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/admin/editor/js/editor.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.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');
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,21 @@
|
||||||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||||
<?php $images = image_gallery(null, 1, 40); ?>
|
<?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"/>
|
<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.min.js"></script>
|
||||||
<script src="<?php echo site_url() ?>system/resources/js/jquery-ui.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>
|
<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>
|
<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>
|
<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 id="oldfile" type="hidden" name="oldfile" class="text"/>
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
||||||
<?php if ($type == 'is_page' || $type == 'is_subpage') :?>
|
<?php if ($type == 'is_page' || $type == 'is_subpage') :?>
|
||||||
|
|
@ -78,7 +126,7 @@
|
||||||
margin: 2px 2px;
|
margin: 2px 2px;
|
||||||
border-top-right-radius: 2px;
|
border-top-right-radius: 2px;
|
||||||
width: 190px;
|
width: 190px;
|
||||||
height: 140px;
|
height: 140px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
background-position: top left;
|
background-position: top left;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
@ -134,6 +182,7 @@
|
||||||
var parent_page = '<?php echo isset($parent) ? $parent : '';?>';
|
var parent_page = '<?php echo isset($parent) ? $parent : '';?>';
|
||||||
var addEdit = 'add';
|
var addEdit = 'add';
|
||||||
var saveInterval = 60000;
|
var saveInterval = 60000;
|
||||||
|
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||||
</script>
|
</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/admin/editor/js/editor.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -198,4 +247,15 @@ $('.img-container').on("click", ".the-img", function(e) {
|
||||||
localStorage.setItem("preview-state", 'open');
|
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>
|
</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);
|
$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"/>
|
<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.min.js"></script>
|
||||||
|
|
@ -233,13 +239,48 @@ $( function() {
|
||||||
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||||
<label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
|
<label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
|
||||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
<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') { ?>
|
<?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>
|
<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 { ?>
|
<?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>
|
<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 }?>
|
<?php }?>
|
||||||
<br><br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6" id="preview-col">
|
<div class="col-sm-6" id="preview-col">
|
||||||
|
|
@ -265,7 +306,7 @@ $( function() {
|
||||||
margin: 2px 2px;
|
margin: 2px 2px;
|
||||||
border-top-right-radius: 2px;
|
border-top-right-radius: 2px;
|
||||||
width: 190px;
|
width: 190px;
|
||||||
height: 140px;
|
height: 140px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
background-position: top left;
|
background-position: top left;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
@ -363,6 +404,7 @@ $( function() {
|
||||||
var parent_page = '';
|
var parent_page = '';
|
||||||
var addEdit = 'edit';
|
var addEdit = 'edit';
|
||||||
var saveInterval = 60000;
|
var saveInterval = 60000;
|
||||||
|
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||||
</script>
|
</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/admin/editor/js/editor.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.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');
|
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>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ if ($type == 'is_frontpage') {
|
||||||
$oldtitle = get_content_tag('t', $content, 'Welcome');
|
$oldtitle = get_content_tag('t', $content, 'Welcome');
|
||||||
$oldcontent = remove_html_comments($content);
|
$oldcontent = remove_html_comments($content);
|
||||||
} else {
|
} else {
|
||||||
|
$content = 'Welcome to our website.';
|
||||||
$oldtitle = 'Welcome';
|
$oldtitle = 'Welcome';
|
||||||
$oldcontent = 'Welcome to our website.';
|
$oldcontent = 'Welcome to our website.';
|
||||||
}
|
}
|
||||||
|
|
@ -27,6 +28,7 @@ if ($type == 'is_frontpage') {
|
||||||
$oldcontent = remove_html_comments($content);
|
$oldcontent = remove_html_comments($content);
|
||||||
$oldimage = get_content_tag('image', $content);
|
$oldimage = get_content_tag('image', $content);
|
||||||
} else {
|
} else {
|
||||||
|
$content = i18n('Author_Description');
|
||||||
$oldtitle = $user;
|
$oldtitle = $user;
|
||||||
$olddescription = i18n('Author_Description');
|
$olddescription = i18n('Author_Description');
|
||||||
$oldcontent = i18n('Author_Description');
|
$oldcontent = i18n('Author_Description');
|
||||||
|
|
@ -34,12 +36,20 @@ if ($type == 'is_frontpage') {
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($type == 'is_category') {
|
} 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';
|
$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 {
|
} else {
|
||||||
|
|
||||||
if (isset($p->file)) {
|
if (isset($p->file)) {
|
||||||
|
|
@ -82,6 +92,24 @@ if ($type == 'is_frontpage') {
|
||||||
|
|
||||||
$images = image_gallery(null, 1, 40);
|
$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"/>
|
<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.min.js"></script>
|
||||||
|
|
@ -132,7 +160,6 @@ $images = image_gallery(null, 1, 40);
|
||||||
<input type="hidden" name="is_image" value="is_image">
|
<input type="hidden" name="is_image" value="is_image">
|
||||||
<br>
|
<br>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -146,6 +173,38 @@ $images = image_gallery(null, 1, 40);
|
||||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
<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>
|
<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>
|
<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" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
||||||
<?php if($type == 'is_frontpage' || $type == 'is_profile') { ?>
|
<?php if($type == 'is_frontpage' || $type == 'is_profile') { ?>
|
||||||
|
|
@ -188,7 +247,7 @@ $images = image_gallery(null, 1, 40);
|
||||||
margin: 2px 2px;
|
margin: 2px 2px;
|
||||||
border-top-right-radius: 2px;
|
border-top-right-radius: 2px;
|
||||||
width: 190px;
|
width: 190px;
|
||||||
height: 140px;
|
height: 140px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
background-position: top left;
|
background-position: top left;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
@ -277,7 +336,7 @@ $images = image_gallery(null, 1, 40);
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Declare the base path. Important -->
|
<!-- Declare the base path. Important -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
@ -286,6 +345,7 @@ $images = image_gallery(null, 1, 40);
|
||||||
var parent_page = '<?php echo isset($parent) ? $parent : '';?>';
|
var parent_page = '<?php echo isset($parent) ? $parent : '';?>';
|
||||||
var addEdit = 'edit';
|
var addEdit = 'edit';
|
||||||
var saveInterval = 60000;
|
var saveInterval = 60000;
|
||||||
|
const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
|
||||||
</script>
|
</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/admin/editor/js/editor.js"></script>
|
||||||
<?php if ($type == 'is_profile'):?>
|
<?php if ($type == 'is_profile'):?>
|
||||||
|
|
@ -355,4 +415,15 @@ $('.img-container').on("click", ".the-img", function(e) {
|
||||||
localStorage.setItem("preview-state", 'open');
|
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>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,13 @@ if (isset($author[0])) {
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</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;?>
|
<?php endif;?>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
429
system/htmly.php
429
system/htmly.php
|
|
@ -406,6 +406,23 @@ post('/edit/profile', function () {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/profile.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$title = from($_REQUEST, 'title');
|
$title = from($_REQUEST, 'title');
|
||||||
|
|
@ -413,7 +430,7 @@ post('/edit/profile', function () {
|
||||||
$image = from($_REQUEST, 'image');
|
$image = from($_REQUEST, 'image');
|
||||||
$content = from($_REQUEST, 'content');
|
$content = from($_REQUEST, 'content');
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
edit_profile($title, $content, $user, $description, $image);
|
edit_profile($title, $content, $user, $description, $image, $field);
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -621,6 +638,23 @@ post('/edit/frontpage', function () {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/page.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
|
@ -628,7 +662,7 @@ post('/edit/frontpage', function () {
|
||||||
$content = from($_REQUEST, 'content');
|
$content = from($_REQUEST, 'content');
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
edit_frontpage($title, $content);
|
edit_frontpage($title, $content, $field);
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -712,6 +746,23 @@ post('/add/content', function () {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/post.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$is_image = from($_REQUEST, 'is_image');
|
$is_image = from($_REQUEST, 'is_image');
|
||||||
$is_audio = from($_REQUEST, 'is_audio');
|
$is_audio = from($_REQUEST, 'is_audio');
|
||||||
$is_video = from($_REQUEST, 'is_video');
|
$is_video = from($_REQUEST, 'is_video');
|
||||||
|
|
@ -765,17 +816,17 @@ post('/add/content', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null, $dateTime);
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null, $dateTime, null, null, $field);
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image, $dateTime);
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image, $dateTime, null, null, $field);
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video, $dateTime);
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video, $dateTime, null, null, $field);
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio, $dateTime);
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio, $dateTime, null, null, $field);
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote, $dateTime);
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote, $dateTime, null, null, $field);
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link, $dateTime);
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link, $dateTime, null, null, $field);
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -882,6 +933,23 @@ post('/add/page', function () {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/page.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
$title = from($_REQUEST, 'title');
|
$title = from($_REQUEST, 'title');
|
||||||
$url = from($_REQUEST, 'url');
|
$url = from($_REQUEST, 'url');
|
||||||
|
|
@ -895,7 +963,7 @@ post('/add/page', function () {
|
||||||
}
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content) && login()) {
|
if ($proper && !empty($title) && !empty($content) && login()) {
|
||||||
add_page($title, $url, $content, $draft, $description);
|
add_page($title, $url, $content, $draft, $description, null, null, $field);
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -932,7 +1000,8 @@ post('/add/page', function () {
|
||||||
// Autosave
|
// Autosave
|
||||||
post('/admin/autosave', function () {
|
post('/admin/autosave', function () {
|
||||||
|
|
||||||
if (login()) {
|
if (login()) {
|
||||||
|
|
||||||
$title = $_REQUEST['title'];
|
$title = $_REQUEST['title'];
|
||||||
$url = $_REQUEST['url'];
|
$url = $_REQUEST['url'];
|
||||||
$content = $_REQUEST['content'];
|
$content = $_REQUEST['content'];
|
||||||
|
|
@ -944,6 +1013,34 @@ post('/admin/autosave', function () {
|
||||||
$addEdit = $_REQUEST['addEdit'];
|
$addEdit = $_REQUEST['addEdit'];
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
if ($posttype == 'is_post') {
|
||||||
|
$field_file = 'content/data/field/post.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
} elseif ($posttype == 'is_page') {
|
||||||
|
$field_file = 'content/data/field/page.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
} elseif ($posttype == 'is_subpage') {
|
||||||
|
$field_file = 'content/data/field/subpage.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = !empty($_REQUEST[$af->name]) ? "checked" : '';
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($url)) {
|
if (empty($url)) {
|
||||||
$url = $title;
|
$url = $title;
|
||||||
|
|
@ -960,18 +1057,18 @@ post('/admin/autosave', function () {
|
||||||
if ($posttype == 'is_page') {
|
if ($posttype == 'is_page') {
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($addEdit == 'add') {
|
if ($addEdit == 'add') {
|
||||||
$response = add_page($title, $url, $content, $draft, $description, $autoSave, $oldfile);
|
$response = add_page($title, $url, $content, $draft, $description, $autoSave, $oldfile, $field);
|
||||||
} else {
|
} else {
|
||||||
$response = edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, null, $autoSave);
|
$response = edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, null, $autoSave, $field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($posttype == 'is_subpage') {
|
} elseif ($posttype == 'is_subpage') {
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
$static = $_REQUEST['parent_page'];
|
$static = $_REQUEST['parent_page'];
|
||||||
if ($addEdit == 'add') {
|
if ($addEdit == 'add') {
|
||||||
$response = add_sub_page($title, $url, $content, $static, $draft, $description, $autoSave, $oldfile);
|
$response = add_sub_page($title, $url, $content, $static, $draft, $description, $autoSave, $oldfile, $field);
|
||||||
} else {
|
} else {
|
||||||
$response = edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static, $autoSave);
|
$response = edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static, $autoSave, $field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1001,11 +1098,11 @@ post('/admin/autosave', function () {
|
||||||
if ($type == 'post') {
|
if ($type == 'post') {
|
||||||
if (!empty($title) && !empty($tag) && !empty($content)) {
|
if (!empty($title) && !empty($tag) && !empty($content)) {
|
||||||
if ($addEdit == 'add') {
|
if ($addEdit == 'add') {
|
||||||
$response = add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime, $autoSave, $oldfile);
|
$response = add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime, $autoSave, $oldfile, $field);
|
||||||
} else {
|
} else {
|
||||||
$arr = explode('/', $oldfile);
|
$arr = explode('/', $oldfile);
|
||||||
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
||||||
$response = edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination, $description, $dateTime, $media, $autoSave);
|
$response = edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination, $description, $dateTime, $media, $autoSave, $field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1014,11 +1111,11 @@ post('/admin/autosave', function () {
|
||||||
} else {
|
} else {
|
||||||
if (!empty($title) && !empty($tag) && !empty($content) && !empty($media)) {
|
if (!empty($title) && !empty($tag) && !empty($content) && !empty($media)) {
|
||||||
if ($addEdit == 'add') {
|
if ($addEdit == 'add') {
|
||||||
$response = add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime, $autoSave, $oldfile);
|
$response = add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime, $autoSave, $oldfile, $field);
|
||||||
} else {
|
} else {
|
||||||
$arr = explode('/', $oldfile);
|
$arr = explode('/', $oldfile);
|
||||||
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
||||||
$response = edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination, $description, $dateTime, $media, $autoSave);
|
$response = edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination, $description, $dateTime, $media, $autoSave, $field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2969,6 +3066,183 @@ get('/admin/categories/:category', function ($category) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Show admin/field
|
||||||
|
get('/admin/field', function () {
|
||||||
|
if (login()) {
|
||||||
|
config('views.root', 'system/admin/views');
|
||||||
|
render('custom-field', array(
|
||||||
|
'title' => generate_title('is_default', i18n('custom_fields')),
|
||||||
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
|
'canonical' => site_url(),
|
||||||
|
'metatags' => generate_meta(null, null),
|
||||||
|
'type' => 'is_admin-content',
|
||||||
|
'is_admin' => true,
|
||||||
|
'bodyclass' => 'admin-content',
|
||||||
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('custom_fields')
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$login = site_url() . 'login';
|
||||||
|
header("location: $login");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show admin/field/post
|
||||||
|
get('/admin/field/post', function () {
|
||||||
|
if (login()) {
|
||||||
|
config('views.root', 'system/admin/views');
|
||||||
|
render('custom-field-post', array(
|
||||||
|
'title' => generate_title('is_default', i18n('post')),
|
||||||
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
|
'canonical' => site_url(),
|
||||||
|
'metatags' => generate_meta(null, null),
|
||||||
|
'type' => 'is_admin-content',
|
||||||
|
'is_admin' => true,
|
||||||
|
'bodyclass' => 'admin-content',
|
||||||
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('post')
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$login = site_url() . 'login';
|
||||||
|
header("location: $login");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
post('/admin/field/post', function () {
|
||||||
|
|
||||||
|
if (login()) {
|
||||||
|
$user = $_SESSION[site_url()]['user'];
|
||||||
|
$role = user('role', $user);
|
||||||
|
|
||||||
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
|
$dir = 'content/data/field/';
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0775, true);
|
||||||
|
}
|
||||||
|
$json = $_REQUEST['json'];
|
||||||
|
save_json_pretty('content/data/field/post.json', json_decode($json));
|
||||||
|
echo json_encode(array(
|
||||||
|
'message' => 'Post fields saved successfully!',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show admin/field/page
|
||||||
|
get('/admin/field/page', function () {
|
||||||
|
if (login()) {
|
||||||
|
config('views.root', 'system/admin/views');
|
||||||
|
render('custom-field-page', array(
|
||||||
|
'title' => generate_title('is_default', i18n('page')),
|
||||||
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
|
'canonical' => site_url(),
|
||||||
|
'metatags' => generate_meta(null, null),
|
||||||
|
'type' => 'is_admin-content',
|
||||||
|
'is_admin' => true,
|
||||||
|
'bodyclass' => 'admin-content',
|
||||||
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('page')
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$login = site_url() . 'login';
|
||||||
|
header("location: $login");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
post('/admin/field/page', function () {
|
||||||
|
|
||||||
|
if (login()) {
|
||||||
|
$user = $_SESSION[site_url()]['user'];
|
||||||
|
$role = user('role', $user);
|
||||||
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
|
$dir = 'content/data/field/';
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0775, true);
|
||||||
|
}
|
||||||
|
$json = $_REQUEST['json'];
|
||||||
|
save_json_pretty('content/data/field/page.json', json_decode($json));
|
||||||
|
echo json_encode(array(
|
||||||
|
'message' => 'Page fields saved successfully!',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show admin/field/subpage
|
||||||
|
get('/admin/field/subpage', function () {
|
||||||
|
if (login()) {
|
||||||
|
config('views.root', 'system/admin/views');
|
||||||
|
render('custom-field-subpage', array(
|
||||||
|
'title' => generate_title('is_default', i18n('subpage')),
|
||||||
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
|
'canonical' => site_url(),
|
||||||
|
'metatags' => generate_meta(null, null),
|
||||||
|
'type' => 'is_admin-content',
|
||||||
|
'is_admin' => true,
|
||||||
|
'bodyclass' => 'admin-content',
|
||||||
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('subpage')
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$login = site_url() . 'login';
|
||||||
|
header("location: $login");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
post('/admin/field/subpage', function () {
|
||||||
|
|
||||||
|
if (login()) {
|
||||||
|
$user = $_SESSION[site_url()]['user'];
|
||||||
|
$role = user('role', $user);
|
||||||
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
|
$dir = 'content/data/field/';
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0775, true);
|
||||||
|
}
|
||||||
|
$json = $_REQUEST['json'];
|
||||||
|
save_json_pretty('content/data/field/subpage.json', json_decode($json));
|
||||||
|
echo json_encode(array(
|
||||||
|
'message' => 'Subpage fields saved successfully!',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show admin/field/profile
|
||||||
|
get('/admin/field/profile', function () {
|
||||||
|
if (login()) {
|
||||||
|
config('views.root', 'system/admin/views');
|
||||||
|
render('custom-field-profile', array(
|
||||||
|
'title' => generate_title('is_default', i18n('profile')),
|
||||||
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
|
'canonical' => site_url(),
|
||||||
|
'metatags' => generate_meta(null, null),
|
||||||
|
'type' => 'is_admin-content',
|
||||||
|
'is_admin' => true,
|
||||||
|
'bodyclass' => 'admin-content',
|
||||||
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('profile')
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$login = site_url() . 'login';
|
||||||
|
header("location: $login");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
post('/admin/field/profile', function () {
|
||||||
|
|
||||||
|
if (login()) {
|
||||||
|
$user = $_SESSION[site_url()]['user'];
|
||||||
|
$role = user('role', $user);
|
||||||
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
|
$dir = 'content/data/field/';
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0775, true);
|
||||||
|
}
|
||||||
|
$json = $_REQUEST['json'];
|
||||||
|
save_json_pretty('content/data/field/profile.json', json_decode($json));
|
||||||
|
echo json_encode(array(
|
||||||
|
'message' => 'Profile fields saved successfully!',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Show the category page
|
// Show the category page
|
||||||
get('/category/:category', function ($category) {
|
get('/category/:category', function ($category) {
|
||||||
|
|
||||||
|
|
@ -3846,6 +4120,23 @@ post('/'. permalink_type() .'/:name/edit', function () {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/post.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
$title = from($_REQUEST, 'title');
|
$title = from($_REQUEST, 'title');
|
||||||
$is_post = from($_REQUEST, 'is_post');
|
$is_post = from($_REQUEST, 'is_post');
|
||||||
|
|
@ -3899,27 +4190,27 @@ post('/'. permalink_type() .'/:name/edit', function () {
|
||||||
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null,null, $field);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
|
|
@ -4327,6 +4618,23 @@ post('/:static/add', function ($static) {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file= 'content/data/field/subpage.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
$title = from($_REQUEST, 'title');
|
$title = from($_REQUEST, 'title');
|
||||||
$url = from($_REQUEST, 'url');
|
$url = from($_REQUEST, 'url');
|
||||||
|
|
@ -4340,7 +4648,7 @@ post('/:static/add', function ($static) {
|
||||||
}
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
add_sub_page($title, $url, $content, $static, $draft, $description);
|
add_sub_page($title, $url, $content, $static, $draft, $description, null, null, $field);
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -4432,6 +4740,23 @@ post('/:static/edit', function () {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/page.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$title = from($_REQUEST, 'title');
|
$title = from($_REQUEST, 'title');
|
||||||
$url = from($_REQUEST, 'url');
|
$url = from($_REQUEST, 'url');
|
||||||
$content = from($_REQUEST, 'content');
|
$content = from($_REQUEST, 'content');
|
||||||
|
|
@ -4447,7 +4772,7 @@ post('/:static/edit', function () {
|
||||||
}
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description);
|
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, null, null, $field);
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -4462,7 +4787,7 @@ post('/:static/edit', function () {
|
||||||
config('views.root', 'system/admin/views');
|
config('views.root', 'system/admin/views');
|
||||||
|
|
||||||
render('edit-page', array(
|
render('edit-page', array(
|
||||||
'title' => generate_title('is_default', i18n('Edit') . ': ' . $post->title),
|
'title' => generate_title('is_default', i18n('Edit') . ': ' . $title),
|
||||||
'description' => safe_html(strip_tags(blog_description())),
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'metatags' => generate_meta(null, null),
|
'metatags' => generate_meta(null, null),
|
||||||
|
|
@ -4703,6 +5028,23 @@ post('/:static/:sub/edit', function ($static, $sub) {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/subpage.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$title = from($_REQUEST, 'title');
|
$title = from($_REQUEST, 'title');
|
||||||
$url = from($_REQUEST, 'url');
|
$url = from($_REQUEST, 'url');
|
||||||
$content = from($_REQUEST, 'content');
|
$content = from($_REQUEST, 'content');
|
||||||
|
|
@ -4721,7 +5063,7 @@ post('/:static/:sub/edit', function ($static, $sub) {
|
||||||
}
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static);
|
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static, null, $field);
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -4736,7 +5078,7 @@ post('/:static/:sub/edit', function ($static, $sub) {
|
||||||
config('views.root', 'system/admin/views');
|
config('views.root', 'system/admin/views');
|
||||||
|
|
||||||
render('edit-page', array(
|
render('edit-page', array(
|
||||||
'title' => generate_title('is_default', i18n('Edit') . ': ' . $page->title),
|
'title' => generate_title('is_default', i18n('Edit') . ': ' . $title),
|
||||||
'description' => safe_html(strip_tags(blog_description())),
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'metatags' => generate_meta(null, null),
|
'metatags' => generate_meta(null, null),
|
||||||
|
|
@ -5024,6 +5366,23 @@ post('/:year/:month/:name/edit', function () {
|
||||||
$login = site_url() . 'login';
|
$login = site_url() . 'login';
|
||||||
header("location: $login");
|
header("location: $login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field = array();
|
||||||
|
$aField = array();
|
||||||
|
$field_file = 'content/data/field/post.json';
|
||||||
|
if (file_exists($field_file)) {
|
||||||
|
$aField = json_decode(file_get_contents($field_file, true));
|
||||||
|
}
|
||||||
|
if(!empty($aField)) {
|
||||||
|
foreach ($aField as $af) {
|
||||||
|
if ($af->type == 'checkbox' && isset($_REQUEST[$af->name])) {
|
||||||
|
$field[$af->name] = isset($_REQUEST[$af->name]) ? "checked" : 0;
|
||||||
|
} else {
|
||||||
|
$field[$af->name] = from($_REQUEST, $af->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
$title = from($_REQUEST, 'title');
|
$title = from($_REQUEST, 'title');
|
||||||
$is_post = from($_REQUEST, 'is_post');
|
$is_post = from($_REQUEST, 'is_post');
|
||||||
|
|
@ -5078,27 +5437,27 @@ post('/:year/:month/:name/edit', function () {
|
||||||
|
|
||||||
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image, null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio,null, $field);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
||||||
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null,null, $field);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
|
|
|
||||||
241
system/resources/js/form.builder.js
Normal file
241
system/resources/js/form.builder.js
Normal file
|
|
@ -0,0 +1,241 @@
|
||||||
|
/*!
|
||||||
|
* Simple Form Builder for HTMLy - @author danpros
|
||||||
|
*
|
||||||
|
* const fields = [];
|
||||||
|
*/
|
||||||
|
let editingIndex = -1; // Track index of the field being edited (-1 means not editing)
|
||||||
|
|
||||||
|
// Elements
|
||||||
|
const typeEl = document.getElementById('type');
|
||||||
|
const nameEl = document.getElementById('name');
|
||||||
|
const labelEl = document.getElementById('label');
|
||||||
|
const valueEl = document.getElementById('value');
|
||||||
|
const optionsContainerEl = document.getElementById('options-container');
|
||||||
|
const optionListEl = document.getElementById('option-list');
|
||||||
|
const addOptionBtn = document.getElementById('add-option');
|
||||||
|
const addFieldBtn = document.getElementById('add-field');
|
||||||
|
const formPreviewEl = document.getElementById('form-preview');
|
||||||
|
const jsonOutputEl = document.getElementById('json-output');
|
||||||
|
|
||||||
|
// Show or hide the options container and reset fields
|
||||||
|
typeEl.addEventListener('change', () => {
|
||||||
|
nameEl.value = '';
|
||||||
|
labelEl.value = '';
|
||||||
|
valueEl.value = '';
|
||||||
|
optionsContainerEl.style.display = typeEl.value === 'select' ? 'block' : 'none';
|
||||||
|
optionListEl.innerHTML = '';
|
||||||
|
addFieldBtn.textContent = "Add Field";
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add new option for select field
|
||||||
|
addOptionBtn.addEventListener('click', () => {
|
||||||
|
const optionDiv = document.createElement('div');
|
||||||
|
optionDiv.classList.add('option-item');
|
||||||
|
|
||||||
|
const labelInput = document.createElement('input');
|
||||||
|
labelInput.type = 'text';
|
||||||
|
labelInput.placeholder = 'Option Label';
|
||||||
|
labelInput.classList.add('option-label');
|
||||||
|
|
||||||
|
const valueInput = document.createElement('input');
|
||||||
|
valueInput.type = 'text';
|
||||||
|
valueInput.placeholder = 'Option Value';
|
||||||
|
valueInput.classList.add('option-value');
|
||||||
|
|
||||||
|
const removeBtn = document.createElement('button');
|
||||||
|
removeBtn.textContent = 'Remove';
|
||||||
|
removeBtn.addEventListener('click', () => optionDiv.remove());
|
||||||
|
removeBtn.setAttribute('class', 'btn btn-danger');
|
||||||
|
|
||||||
|
optionDiv.appendChild(labelInput);
|
||||||
|
optionDiv.appendChild(valueInput);
|
||||||
|
optionDiv.appendChild(removeBtn);
|
||||||
|
optionListEl.appendChild(optionDiv);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add field button logic (works for both adding and updating fields)
|
||||||
|
addFieldBtn.addEventListener('click', () => {
|
||||||
|
let field = {
|
||||||
|
type: typeEl.value,
|
||||||
|
name: nameEl.value.trim().replace(/\s+/g, ''), // Remove spaces
|
||||||
|
label: labelEl.value.trim(),
|
||||||
|
value: valueEl.value.trim()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (field.type === 'select') {
|
||||||
|
const options = Array.from(document.querySelectorAll('.option-item')).map(item => {
|
||||||
|
const label = item.querySelector('.option-label').value.trim();
|
||||||
|
const value = item.querySelector('.option-value').value.trim();
|
||||||
|
return { label, value };
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.some(opt => !opt.label || !opt.value)) {
|
||||||
|
alert("All options for a select field must have both label and value!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
field.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!field.name || !field.label || !field.type) {
|
||||||
|
alert("Please fill in all required fields: Type, Name, and Label.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editingIndex === -1) {
|
||||||
|
const existingNames = fields.map(f => f.name);
|
||||||
|
if (existingNames.includes(field.name)) {
|
||||||
|
const timestamp = Date.now();
|
||||||
|
field.name = `${field.name}_${timestamp}`;
|
||||||
|
}
|
||||||
|
fields.push(field);
|
||||||
|
} else {
|
||||||
|
fields[editingIndex] = field;
|
||||||
|
editingIndex = -1;
|
||||||
|
addFieldBtn.textContent = "Add Field";
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePreviewAndOutput();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Delete field logic
|
||||||
|
function deleteField(index) {
|
||||||
|
if (confirm("Are you sure you want to delete this field?")) {
|
||||||
|
fields.splice(index, 1);
|
||||||
|
updatePreviewAndOutput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit field logic
|
||||||
|
function editField(index) {
|
||||||
|
const field = fields[index];
|
||||||
|
|
||||||
|
typeEl.value = field.type;
|
||||||
|
nameEl.value = field.name.replace(/\s+/g, ''); // Remove spaces
|
||||||
|
labelEl.value = field.label;
|
||||||
|
valueEl.value = field.value || '';
|
||||||
|
|
||||||
|
if (field.type === 'select') {
|
||||||
|
optionsContainerEl.style.display = 'block';
|
||||||
|
optionListEl.innerHTML = '';
|
||||||
|
field.options.forEach(opt => {
|
||||||
|
const optionDiv = document.createElement('div');
|
||||||
|
optionDiv.classList.add('option-item');
|
||||||
|
|
||||||
|
const labelInput = document.createElement('input');
|
||||||
|
labelInput.type = 'text';
|
||||||
|
labelInput.placeholder = 'Option Label';
|
||||||
|
labelInput.value = opt.label;
|
||||||
|
labelInput.classList.add('option-label');
|
||||||
|
|
||||||
|
const valueInput = document.createElement('input');
|
||||||
|
valueInput.type = 'text';
|
||||||
|
valueInput.placeholder = 'Option Value';
|
||||||
|
valueInput.value = opt.value;
|
||||||
|
valueInput.classList.add('option-value');
|
||||||
|
|
||||||
|
const removeBtn = document.createElement('button');
|
||||||
|
removeBtn.textContent = 'Remove';
|
||||||
|
removeBtn.setAttribute('class', 'btn btn-danger');
|
||||||
|
removeBtn.addEventListener('click', () => {
|
||||||
|
if (confirm("Are you sure you want to remove this option?")) {
|
||||||
|
optionDiv.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
optionDiv.appendChild(labelInput);
|
||||||
|
optionDiv.appendChild(valueInput);
|
||||||
|
optionDiv.appendChild(removeBtn);
|
||||||
|
optionListEl.appendChild(optionDiv);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
optionsContainerEl.style.display = 'none';
|
||||||
|
optionListEl.innerHTML = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
editingIndex = index;
|
||||||
|
addFieldBtn.textContent = "Update Field";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update preview with Edit and Delete buttons
|
||||||
|
function updatePreviewAndOutput() {
|
||||||
|
formPreviewEl.innerHTML = '';
|
||||||
|
|
||||||
|
fields.forEach((f, index) => {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
wrapper.setAttribute('class', 'field-preview form-group');
|
||||||
|
|
||||||
|
if (f.type !== 'checkbox') {
|
||||||
|
const label = document.createElement('label');
|
||||||
|
label.textContent = f.label;
|
||||||
|
wrapper.appendChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
let el;
|
||||||
|
if (f.type === 'textarea') {
|
||||||
|
el = document.createElement('textarea');
|
||||||
|
el.placeholder = f.label;
|
||||||
|
el.setAttribute('class', 'form-control');
|
||||||
|
el.value = f.value;
|
||||||
|
} else if (f.type === 'checkbox') {
|
||||||
|
el = document.createElement('input');
|
||||||
|
el.type = 'checkbox';
|
||||||
|
el.checked = f.value === 'true';
|
||||||
|
const checkboxLabel = document.createElement('span');
|
||||||
|
checkboxLabel.textContent = ` ${f.label} `;
|
||||||
|
wrapper.appendChild(el);
|
||||||
|
wrapper.appendChild(checkboxLabel);
|
||||||
|
el = null;
|
||||||
|
} else if (f.type === 'select') {
|
||||||
|
el = document.createElement('select');
|
||||||
|
el.setAttribute('class', 'form-control');
|
||||||
|
f.options.forEach(opt => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = opt.value;
|
||||||
|
option.textContent = opt.label;
|
||||||
|
el.appendChild(option);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
el = document.createElement('input');
|
||||||
|
el.type = f.type;
|
||||||
|
el.value = f.value;
|
||||||
|
el.placeholder = f.label;
|
||||||
|
el.setAttribute('class', 'form-control');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (el) {
|
||||||
|
wrapper.appendChild(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
const editBtn = document.createElement('button');
|
||||||
|
editBtn.textContent = 'Edit';
|
||||||
|
editBtn.addEventListener('click', () => editField(index));
|
||||||
|
editBtn.setAttribute('class', 'btn btn-primary btn-xs');
|
||||||
|
wrapper.appendChild(editBtn);
|
||||||
|
|
||||||
|
const deleteBtn = document.createElement('button');
|
||||||
|
deleteBtn.textContent = 'Delete';
|
||||||
|
deleteBtn.addEventListener('click', () => deleteField(index));
|
||||||
|
deleteBtn.setAttribute('class', 'btn btn-danger btn-xs');
|
||||||
|
wrapper.appendChild(deleteBtn);
|
||||||
|
|
||||||
|
formPreviewEl.appendChild(wrapper);
|
||||||
|
});
|
||||||
|
|
||||||
|
jsonOutputEl.value = JSON.stringify(fields, null, 2);
|
||||||
|
nameEl.value = '';
|
||||||
|
labelEl.value = '';
|
||||||
|
valueEl.value = '';
|
||||||
|
optionsContainerEl.style.display = 'none';
|
||||||
|
optionListEl.innerHTML = '';
|
||||||
|
typeEl.value = "text";
|
||||||
|
addFieldBtn.textContent = "Add Field";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Real-time removal of spaces in the name field
|
||||||
|
nameEl.addEventListener('input', () => {
|
||||||
|
nameEl.value = nameEl.value.replace(/\s+/g, ''); // Remove spaces in real-time
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
updatePreviewAndOutput();
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue