Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #46 from flatCore/develop
Browse files Browse the repository at this point in the history
Develop Branch v2.0.6
  • Loading branch information
patkon committed Mar 26, 2021
2 parents cc01014 + e810a1c commit 7a73474
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 22 deletions.
58 changes: 52 additions & 6 deletions acp/core/dashboard.top.php
Expand Up @@ -3,6 +3,19 @@
//prohibit unauthorized access
require 'core/access.php';

if(isset($_GET['a'])) {

if($_GET['a'] == 'delete_cache') {
fc_delete_smarty_cache('all');
}
if($_GET['a'] == 'update_index') {
fc_update_bulk_page_index();
}

}



$tpl_file = file_get_contents('templates/dashboard_top.tpl');

/* get latest infos from user database */
Expand Down Expand Up @@ -53,10 +66,12 @@
}
$user_latest5 .= '<a href="acp.php?tn=user&sub=edit&edituser='.$user_id.'" class="list-group-item list-group-item-ghost list-group-item-action flex-column align-items-start">';
$user_latest5 .= '<div class="d-flex w-100 justify-content-between">';
$user_latest5 .= '<h6 class="mb-1">'.$user_nick.'</h6>';
$user_latest5 .= '<div>';
$user_latest5 .= '<h6 class="mb-0">'.$user_nick.'</h6>';
$user_latest5 .= '<small>'.$user_name.'</small>';
$user_latest5 .= '</div>';
$user_latest5 .= '<small>'.$user_registerdate.'</small>';
$user_latest5 .= '</div>';
$user_latest5 .= '<small>'.$user_name.'</small>';
$user_latest5 .= '</a>';
}

Expand Down Expand Up @@ -104,13 +119,16 @@

$top5pages .= '<div class="list-group-item list-group-item-ghost list-group-item-action flex-column align-items-start">';
$top5pages .= '<div class="d-flex w-100 justify-content-between">';
$top5pages .= '<div>';
$top5pages .= '<h6 class="mb-0">'.$page_linkname.' ';
$top5pages .= '<small>('.$last_edit.')</small></h6>';
$top5pages .= '<small>'.$page_title.'</small>';
$top5pages .= '</div>';
$top5pages .= '<form class="inline" action="?tn=pages&sub=edit" method="POST">';
$top5pages .= '<button class="btn btn-fc btn-sm" name="editpage" value="'.$allPages[$i]['page_id'].'">'.$icon['edit'].'</button>';
$top5pages .= '</form>';
$top5pages .= '</div>';
$top5pages .= '<small>'.$page_title.'</small>';

$top5pages .= '</div>';

}
Expand Down Expand Up @@ -147,13 +165,16 @@

$top5posts .= '<div class="list-group-item list-group-item-ghost list-group-item-action flex-column align-items-start">';
$top5posts .= '<div class="d-flex w-100 justify-content-between">';
$top5posts .= '<div>';
$top5posts .= '<h6 class="mb-0">'.$allPosts[$i]['post_title'].' ';
$top5posts .= '<small>('.$last_edit.')</small></h6>';
$top5posts .= '<small>'.$post_teaser.'</small>';
$top5posts .= '</div>';
$top5posts .= '<form class="inline" action="?tn=posts&sub=edit" method="POST">';
$top5posts .= '<button class="btn btn-fc btn-sm" name="post_id" value="'.$allPosts[$i]['post_id'].'">'.$icon['edit'].'</button>';
$top5posts .= '</form>';
$top5posts .= '</div>';
$top5posts .= '<small>'.$post_teaser.'</small>';

$top5posts .= '</div>';
}

Expand Down Expand Up @@ -182,14 +203,16 @@

$top5comments .= '<div class="list-group-item list-group-item-ghost list-group-item-action flex-column align-items-start">';
$top5comments .= '<div class="d-flex w-100 justify-content-between">';
$top5comments .= '<div>';
$top5comments .= '<h6 class="mb-0">'.$allComments[$i]['comment_author'].' ';
$top5comments .= '<small>('.$last_edit.')</small></h6>';
$top5comments .= '<small>'.$comment_text.'</small>';
$top5comments .= '</div>';
$top5comments .= '<form class="inline" action="?tn=comments&sub=list#comid'.$allComments[$i]['comment_id'].'" method="POST">';
$top5comments .= '<button class="btn btn-fc btn-sm" name="editid" value="'.$allComments[$i]['comment_id'].'">'.$icon['edit'].'</button>';
$top5comments .= '</form>';
$top5comments .= '</div>';
$top5comments .= '<small>'.$comment_text.'</small>';
$top5comments .= '</div>';
$top5comments .= '</div>';

}

Expand Down Expand Up @@ -261,6 +284,29 @@
$tpl_file = str_replace('{tab_user}', $lang['tn_usermanagement'], $tpl_file);
$tpl_file = str_replace('{tab_user_stats}', $lang['h_status'], $tpl_file);

$btn_page_overview = '<a href="acp.php?tn=pages" class="btn btn-fc btn-sm">'.$icon['sitemap'].'</a>';
$btn_new_page = '<a href="acp.php?tn=pages&sub=new" class="btn btn-fc btn-sm">'.$icon['plus'].' '.$lang['new_page'].'</a>';
$btn_update_index = '<a href="acp.php?tn=dashboard&a=update_index" class="btn btn-fc btn-sm">'.$icon['sync_alt'].' Index</a>';
$btn_delete_cache = '<a href="acp.php?tn=dashboard&a=delete_cache" class="btn btn-fc btn-sm">'.$icon['trash_alt'].' Cache</a>';

$btn_post_overview = '<a href="acp.php?tn=posts" class="btn btn-fc btn-sm">'.$lang['tn_posts'].'</a>';
$btn_new_post = '<a href="acp.php?tn=posts&sub=edit" class="btn btn-fc btn-sm">'.$icon['plus'].' '.$lang['label_new_post'].'</a>';
$btn_comments_overview = '<a href="acp.php?tn=comments" class="btn btn-fc btn-sm">'.$lang['tn_comments'].'</a>';

$btn_user_overview = '<a href="acp.php?tn=user" class="btn btn-fc btn-sm">'.$lang['list_user'].'</a>';
$btn_new_user = '<a href="acp.php?tn=user&sub=new" class="btn btn-fc btn-sm">'.$icon['plus'].' '.$lang['new_user'].'</a>';

$tpl_file = str_replace('{btn_page_overview}', $btn_page_overview, $tpl_file);
$tpl_file = str_replace('{btn_new_page}', $btn_new_page, $tpl_file);
$tpl_file = str_replace('{btn_update_index}', $btn_update_index, $tpl_file);
$tpl_file = str_replace('{btn_delete_cache}', $btn_delete_cache, $tpl_file);

$tpl_file = str_replace('{btn_post_overview}', $btn_post_overview, $tpl_file);
$tpl_file = str_replace('{btn_new_post}', $btn_new_post, $tpl_file);
$tpl_file = str_replace('{btn_comments_overview}', $btn_comments_overview, $tpl_file);

$tpl_file = str_replace('{btn_user_overview}', $btn_user_overview, $tpl_file);
$tpl_file = str_replace('{btn_new_user}', $btn_new_user, $tpl_file);

echo $tpl_file;

Expand Down
2 changes: 1 addition & 1 deletion acp/core/list.themes.php
Expand Up @@ -132,7 +132,7 @@
echo '</form><hr>';



unset($theme_options);
if(is_file("../styles/$template/php/options.php")) {
include '../styles/'.$template.'/php/options.php';
}
Expand Down
8 changes: 5 additions & 3 deletions acp/core/pages.edit.php
Expand Up @@ -81,12 +81,14 @@
]
]);
} else {
$subpages = '';
$subpages = array();
}

if(count($subpages) > 0) {
$cnt_subpages = count($subpages);

if($cnt_subpages > 0) {
echo '<div class="alert alert-danger">';
echo $lang['msg_error_deleting_sub_pages'];
echo $lang['msg_error_deleting_sub_pages'] .' ('.$cnt_subpages.')';
echo '<ol>';
foreach($subpages as $pages) {
echo '<li>'.$pages['page_title'].'</li>';
Expand Down
70 changes: 67 additions & 3 deletions acp/core/pages.shortcodes.php
Expand Up @@ -6,6 +6,15 @@
/*save or update shortcode */
if(isset($_POST['write_shortcode'])) {

/* labels */
$arr_labels = $_POST['shortcode_labels'];
if(is_array($arr_labels)) {
sort($arr_labels);
$string_labels = implode(",", $arr_labels);
} else {
$string_labels = "";
}


if($_POST['shortcode_id'] != '') {
$db_mode = 'update';
Expand All @@ -20,6 +29,7 @@
$data = $db_content->update("fc_textlib", [
"textlib_content" => $_POST['longcode'],
"textlib_shortcode" => $_POST['shortcode'],
"textlib_labels" => $string_labels,
"textlib_type" => "shortcode"
],[
"textlib_id" => $shortcode_id
Expand All @@ -31,6 +41,7 @@
$data = $db_content->insert("fc_textlib", [
"textlib_content" => $_POST['longcode'],
"textlib_shortcode" => $_POST['shortcode'],
"textlib_labels" => $string_labels,
"textlib_type" => "shortcode"
]);

Expand Down Expand Up @@ -71,14 +82,15 @@


echo '<div class="row">';
echo '<div class="col-md-8">';
echo '<div class="col-md-6">';


echo '<table class="table table-sm">';
echo '<thead>';
echo '<tr>';
echo '<th>Shortcode</th>';
echo '<th>Longcode</th>';
echo '<th>Label</th>';
echo '<th></th>';
echo '</tr>';
echo '</thead>';
Expand All @@ -92,9 +104,33 @@
$btn_delete .= '<button type="submit" name="delete" value="'.$shortcodes[$i]['textlib_id'].'" class="btn btn-danger btn-sm">'.$icon['trash_alt'].'</button>';
$btn_delete .= '</form>';

$get_sc_labels = explode(',',$shortcodes[$i]['textlib_labels']);


$label = '';
if($shortcodes[$i]['textlib_labels'] != '') {
foreach($get_sc_labels as $sc_label) {

foreach($fc_labels as $l) {
if($sc_label == $l['label_id']) {
$label_color = $l['label_color'];
$label_title = $l['label_title'];
}
}

$label .= '<span class="label-dot" style="background-color:'.$label_color.';" title="'.$label_title.'"></span>';
}
}

$longcode = htmlentities($shortcodes[$i]['textlib_content']);
if(strlen($longcode) > 75) {
$longcode = substr($longcode, 0,75). ' <em><small>(...)</small></em>';
}

echo '<tr>';
echo '<td>'.$shortcodes[$i]['textlib_shortcode'].'</td>';
echo '<td><code>'.htmlentities($shortcodes[$i]['textlib_content']).'</code></td>';
echo '<td><code>'.$longcode.'</code></td>';
echo '<td>'.$label.'</td>';
echo '<td class="text-right">'.$btn_edit.' '.$btn_delete.'</td>';
echo '</tr>';
}
Expand All @@ -104,7 +140,7 @@


echo '</div>';
echo '<div class="col-md-4">';
echo '<div class="col-md-6">';

echo '<div class="card p-3">';
echo '<form action="?tn=pages&sub=shortcodes" method="POST">';
Expand All @@ -120,6 +156,34 @@
echo '</div>';



$cnt_labels = count($fc_labels);
$arr_checked_labels = explode(",", $get_shortcode['textlib_labels']);

for($i=0;$i<$cnt_labels;$i++) {
$label_title = $fc_labels[$i]['label_title'];
$label_id = $fc_labels[$i]['label_id'];
$label_color = $fc_labels[$i]['label_color'];

if(in_array("$label_id", $arr_checked_labels)) {
$checked_label = "checked";
} else {
$checked_label = "";
}

$checkbox_set_labels .= '<div class="form-check form-check-inline">';
$checkbox_set_labels .= '<input class="form-check-input" id="label'.$label_id.'" type="checkbox" '.$checked_label.' name="shortcode_labels[]" value="'.$label_id.'">';
$checkbox_set_labels .= '<label class="form-check-label" for="label'.$label_id.'">'.$label_title.'</label>';
$checkbox_set_labels .= '</div>';
}

echo '<div class="form-group">';
echo '<p>'.$lang['labels'].'</p>';
echo $checkbox_set_labels;
echo '</div>';



echo '<input type="hidden" name="csrf_token" value="'.$_SESSION['token'].'">';

if($get_shortcode['textlib_id'] != '') {
Expand Down
2 changes: 1 addition & 1 deletion acp/core/pages.snippets.php
Expand Up @@ -210,7 +210,7 @@
}
$snippet_label_filter = substr("$snippet_label_filter", 0, -3); // cut the last ' OR'

$filter_string = "WHERE textlib_id IS NOT NULL";
$filter_string = "WHERE textlib_id IS NOT NULL AND textlib_type NOT IN('shortcode')";

if($_SESSION['type'] == 'all') {
$filter_type = '';
Expand Down

0 comments on commit 7a73474

Please sign in to comment.