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 #61 from flatCore/develop
Browse files Browse the repository at this point in the history
Merge Develop Branch
  • Loading branch information
patkon authored Sep 15, 2021
2 parents dd2af3a + ec2dbcc commit 0a84a03
Show file tree
Hide file tree
Showing 64 changed files with 3,773 additions and 1,429 deletions.
28 changes: 21 additions & 7 deletions acp/acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,6 @@ function showScaledPrices(price,addition,tax) {


}


});

</script>
Expand Down Expand Up @@ -949,9 +947,7 @@ function expandHelpSidebar(){
}
}
}




if(sidebarHelpState == "collapsed" || typeof sidebarHelpState==='undefined' || sidebarHelpState===null){
collapseHelpSidebar();
} else {
Expand Down Expand Up @@ -982,11 +978,29 @@ function expandHelpSidebar(){
return false;
})



})

//SIDEBAR


$('.page-info-btn').click(function(){

var pageid = $(this).data('id');

// AJAX request
$.ajax({
url: 'core/pages.info.php',
type: 'post',
data: {pageid: pageid},
success: function(response){
// Add response in Modal body
$('#pageInfoModal .modal-body').html(response);

// Display Modal
$('#pageInfoModal').modal('show');
}
});
});


});
Expand Down
39 changes: 30 additions & 9 deletions acp/core/files.browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,10 @@ function delete_folder($dir) {
echo '<input type="text" name="new_folder" class="form-control">';
echo '<div class="input-group-append">';
echo '<input type="submit" name="submit" value="'.$lang['create_new_folder'].'" class="btn btn-fc">';
echo '<input type="hidden" name="csrf_token" value="'.$_SESSION['token'].'">';
echo '</div>';
echo '</div>';
echo '</form>';
echo '</div>';

echo '<div class="col-md-4">';
Expand Down Expand Up @@ -536,13 +538,18 @@ function delete_folder($dir) {


if(isset($_GET['start'])) {
$start = (int) $_GET['start'];
$_SESSION['file_browser_start'] = (int) $_GET['start'];
}

if(isset($_SESSION['file_browser_start'])) {
$start = (int) $_SESSION['file_browser_start'];
}

if($start<0) {
$start = 0;
}


$next_start = $start+$files_per_page;
$prev_start = $start-$files_per_page;

Expand Down Expand Up @@ -571,8 +578,8 @@ function delete_folder($dir) {
$cnt_pages = ceil($nbr_of_files/$files_per_page);
$cnt_get_files = count($get_files);

$pag_backlink = '<a class="btn btn-fc '.$disable_prev_start.'" href="acp.php?tn=filebrowser&start='.$prev_start.'">'.$icon['angle_double_left'].'</a>';
$pag_forwardlink = '<a class="btn btn-fc '.$disable_next_start.'" href="acp.php?tn=filebrowser&start='.$next_start.'">'.$icon['angle_double_right'].'</a>';
$pag_backlink = '<li class="page-item"><a class="btn btn-fc '.$disable_prev_start.'" href="acp.php?tn=filebrowser&start='.$prev_start.'">'.$icon['angle_double_left'].'</a></li>';
$pag_forwardlink = '<li class="page-item"><a class="btn btn-fc '.$disable_next_start.'" href="acp.php?tn=filebrowser&start='.$next_start.'">'.$icon['angle_double_right'].'</a></li>';

unset($pag_string);
for($x=0;$x<$cnt_pages;$x++) {
Expand All @@ -596,7 +603,7 @@ function delete_folder($dir) {
}
}

$a_pag_string[] = "<a class='$aclass' href='acp.php?tn=filebrowser&start=$page_start'>$page_nbr</a> ";
$a_pag_string[] = '<li class="page-item"><a class="'.$aclass.'" href="acp.php?tn=filebrowser&start='.$page_start.'">'.$page_nbr.'</a></li>';

}

Expand All @@ -615,6 +622,16 @@ function delete_folder($dir) {

echo '<div class="card p-3">';

echo '<nav aria-label="Page navigation example">';
echo '<ul class="pagination justify-content-center">';
echo $pag_backlink .' ';
foreach(range($pag_start, $pag_end) as $number) {
echo $a_pag_string[$number];
}
echo ' '. $pag_forwardlink;
echo '</ul>';
echo '</nav>';

echo '<div class="'.$tpl_container_class.'">';


Expand All @@ -637,14 +654,15 @@ function delete_folder($dir) {


$delete_btn = '<button type="submit" onclick="return confirm(\''.$lang['confirm_delete_file'].'\')" class="btn btn-fc btn-sm w-100 text-danger" name="delete" value="'.$id.'">'.$icon['trash_alt'].'</button>';
$edit_btn = '<a data-fancybox data-type="ajax" data-src="/acp/core/ajax.media.php?file='.$filename.'&folder='.$disk.'" href="javascript:;" class="btn btn-sm btn-fc w-100 text-success">'.$icon['edit'].'</a>';

//$edit_btn = '<a data-fancybox data-type="ajax" data-src="/acp/core/ajax.media.php?file='.$filename.'&folder='.$disk.'" href="javascript:;" class="btn btn-sm btn-fc w-100 text-success">'.$icon['edit'].'</a>';

$edit_btn = '<button type="submit" class="btn btn-sm btn-fc w-100 text-success">'.$icon['edit'].'</button>';

$tpl_list = $tpl_file;

$fileinfo = pathinfo($filename);
$suffix = $fileinfo['extension'];
$ext = array("jpeg","jpg","png","svg","gif");
$ext = array("jpeg","jpg","png","svg","gif","webp");

if(in_array($suffix,$ext) === true) {
$set_style = '';
Expand Down Expand Up @@ -710,13 +728,16 @@ function delete_folder($dir) {
echo '</div>'; // columns


echo '<div id="well well-sm"><p class="text-center">';
echo '<nav aria-label="Page navigation example">';
echo '<ul class="pagination justify-content-center">';
echo $pag_backlink .' ';
foreach(range($pag_start, $pag_end) as $number) {
echo $a_pag_string[$number];
}
echo ' '. $pag_forwardlink;
echo '</div>'; //EOL PAGINATION
echo '</ul>';
echo '</nav>';


echo '</div>'; // card

Expand Down
145 changes: 22 additions & 123 deletions acp/core/ajax.media.php → acp/core/files.edit.php
Original file line number Diff line number Diff line change
@@ -1,79 +1,17 @@
<?php

session_start();
error_reporting(0);

require '../../lib/Medoo.php';
use Medoo\Medoo;

require '../../config.php';


if(is_file('../../config_database.php')) {
include '../../config_database.php';
$db_type = 'mysql';

$database = new Medoo([

'database_type' => 'mysql',
'database_name' => "$database_name",
'server' => "$database_host",
'username' => "$database_user",
'password' => "$database_psw",

'charset' => 'utf8',
'port' => $database_port,

'prefix' => DB_PREFIX
]);

$db_content = $database;
$db_user = $database;
$db_statistics = $database;



} else {
$db_type = 'sqlite';

if(isset($fc_content_files) && is_array($fc_content_files)) {
/* switch database file $fc_db_content */
include 'core/contentSwitch.php';
}


define("CONTENT_DB", "$fc_db_content");

$db_content = new Medoo([
'database_type' => 'sqlite',
'database_file' => CONTENT_DB
]);


}





define("FC_ROOT", str_replace("/acp","",FC_INC_DIR));
define("IMAGES_FOLDER", "../$img_path");
define("FILES_FOLDER", "../$files_path");
define("FC_SOURCE", "backend");



require_once 'access.php';
require_once 'functions.php';
require '../../lib/lang/'.$_SESSION['lang'].'/dict-backend.php';

$set_lang = $_SESSION['lang'];
$set_lang = $languagePack;
if(isset($_REQUEST['set_lang'])) {
$set_lang = $_REQUEST['set_lang'];
}

$fc_labels = fc_get_labels();
$form_tpl = file_get_contents('templates/media-edit-form.tpl');

$form_tpl = file_get_contents('../templates/media-edit-form.tpl');

if(isset($_REQUEST['file'])) {
$media_filename = strip_tags($_REQUEST['file']);
Expand All @@ -85,18 +23,19 @@
} else {
$preview_src = '<img src="'. $media_filename.'" class="img-fluid">';
$realpath = $media_filename;
list($img_width, $img_height) = getimagesize("../$media_filename");
list($img_width, $img_height) = getimagesize("./$media_filename");
$img_dimensions = ' | '.$img_width.' x '.$img_height.' px';
$shortcode = 'image';
}
}

$abs_path = str_replace('../','/',$realpath);
$filesize = filesize("../$realpath");
$rfilesize = readable_filesize(filesize("../$realpath"));
$lastedit = date('d.m.Y H:i',filemtime("../$realpath"));
$rfilesize = readable_filesize(filesize("$realpath"));
$lastedit = date('d.m.Y H:i',filemtime("$realpath"));


if(isset($_POST['saveMedia'])) {
if(isset($_POST['save'])) {
$savedMedia = fc_write_media_data($_POST['realpath'],$_POST['title'],$_POST['notes'],$_POST['keywords'],$_POST['text'],$_POST['url'],$_POST['alt'],$set_lang,$_POST['credit'],$_POST['priority'],$_POST['license'],time(),$filesize,$_POST['version'],$_POST['media_labels']);
if($savedMedia == 'success') {
$message = '<div class="alert alert-success alert-auto-close">'.$lang['db_changed'].'</div>';
Expand All @@ -109,22 +48,27 @@
}


/* language switch */
echo '<div class="subHeader">';
echo '<a class="btn btn-fc" href="?tn=filebrowser&sub=browse">'.$icon['angle_left'].'</a> ';
echo '<span class="ms-3">' . $media_filename.'</span>';
echo '</div>';

$arr_lang = get_all_languages($d='../../lib/lang');
$langSwitch = '<div class="btn-group" role="group">';
$arr_lang = get_all_languages();
$langSwitch = '<form action="?tn=filebrowser&sub=edit">';
$langSwitch .= '<div class="btn-group" role="group">';
foreach($arr_lang as $langs) {
$btn_status = '';
if($langs['lang_sign'] == "$set_lang") { $btn_status = 'active'; }
$langSwitch .= '<a data-fancybox data-type="ajax" class="change-fb btn btn-fc btn-sm '.$btn_status.'" data-src="../acp/core/ajax.media.php?file='.$media_filename.'&folder='.$_REQUEST['folder'].'&set_lang='.$langs['lang_sign'].'" href="javascript:;">'.$langs['lang_sign'].'</a>';
$langSwitch .= '<button type="submit" class="btn btn-fc btn-sm '.$btn_status.'" name="set_lang" value="'.$langs['lang_sign'].'">'.$langs['lang_sign'].'</button>';
}
$langSwitch .= '</div>';

$langSwitch .= '<input type="hidden" name="file" value="'.$media_filename.'">';
$langSwitch .= '<input type="hidden" name="folder" value="'.$_REQUEST['folder'].'">';
$langSwitch .= '</form>';

$media_data = fc_get_media_data($realpath,$set_lang);



/* labels */

$cnt_labels = count($fc_labels);
Expand All @@ -149,9 +93,7 @@

$form_tpl = str_replace('{media_labels}', $checkbox_set_labels, $form_tpl);



$form_tpl = str_replace('{form_action}', "#", $form_tpl);
$form_tpl = str_replace('{form_action}', "?tn=filebrowser&sub=edit", $form_tpl);
$form_tpl = str_replace('{filename}', $media_filename, $form_tpl);
$form_tpl = str_replace('{file}', $media_filename, $form_tpl);
$form_tpl = str_replace('{basename}', basename($media_filename), $form_tpl);
Expand Down Expand Up @@ -190,51 +132,8 @@
$form_tpl = str_replace('{lang_switch}', $langSwitch, $form_tpl);
$form_tpl = str_replace('{shortcode}', $shortcode, $form_tpl);
$form_tpl = str_replace('{token}',$_SESSION['token'],$form_tpl);
echo $form_tpl;


?>

<script>
echo $form_tpl;

$(document).ready(function(){

$('a.change-fb').click(function(e) {
e.preventDefault();
var target = $(this).data('src');
$.get(target, function (data) {
$.fancybox.getInstance().setContent( $.fancybox.getInstance().current, data );
});

});


$("#media_form").bind("submit", function() {
$.ajax({
type : "POST",
cache : false,
url: "../acp/core/ajax.media.php",
data: $(this).serializeArray(),
success:function(data){
$.fancybox.getInstance().setContent( $.fancybox.getInstance().current, data );
}
});
return false;
});


$("[data-fancybox]").fancybox({
type: 'ajax',
minWidth: '450px',
height: '90%'
});


setTimeout(function() {
$(".alert-auto-close").slideUp('slow');
}, 2000);


});

</script>
?>
Loading

0 comments on commit 0a84a03

Please sign in to comment.