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

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
patkon committed May 5, 2021
0 parents commit 6f6e4e4
Show file tree
Hide file tree
Showing 14 changed files with 1,301 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## bulkedit.mod - flatCore Module


This Addon helps you to organize your Page structure. You can also easily edit the metadata of all pages.

### __ATTENTION__

* If you change the structure, this has an immediate effect on your site. You really have to be sure if you use this addon.
* If you change pages here, only the latest version will be saved. The version control of flatCore is not taken into account here.
* The forms will be submit onchange()

### Questions? Suggestions? Ideas?
Please use the discussion function in our main repository on GitHub:
https://github.com/flatCore/flatCore-CMS/discussions

### Contribution
You are very welcome to take part in this project. We are happy for every contribution!

### License
GPL-3.0 License
115 changes: 115 additions & 0 deletions backend/ajax.sitemap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

session_start();
error_reporting(E_ALL ^E_NOTICE);

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';


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

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


}

require_once '../../../acp/core/access.php';
require_once '../../../acp/core/functions.php';
require 'functions.php';


$all_pages = be_get_ordered_pages($_SESSION['be_lang']);

$cnt_all_pages = count($all_pages);
$sm_string .= '<ul class="page-list">';

for($i=0;$i<$cnt_all_pages;$i++) {

$sm_page_id = $all_pages[$i]['page_id'];
$sm_page_sort = $all_pages[$i]['page_sort'];
$sm_page_linkname = $all_pages[$i]['page_linkname'];
$sm_page_title = $all_pages[$i]['page_title'];
$sm_page_status = $all_pages[$i]['page_status'];
$sm_page_permalink = $all_pages[$i]['page_permalink'];
$sm_page_lang = $all_pages[$i]['page_language'];

$short_title = first_words($all_pages[$i]['page_title'], 6);

if($sm_page_sort == '') { continue; }

$points_of_item[$i] = substr_count($sm_page_sort, '.');

// new level
$start_ul = '';
if($points_of_item[$i] > $points_of_item[$i-1]) {
$start_ul = '<ul>';
$sm_string = substr(trim($sm_string), 0, -5);
}

// end this level </ul>
$end_ul = '';
if($points_of_item[$i] < $points_of_item[$i-1]) {
$div_level = abs($points_of_item[$i] - $points_of_item[$i-1]);
$end_ul = str_repeat("</ul>", $div_level);
$end_ul .= '</li>';
}

$start_li = '<li>';
$end_li = '</li>';


if($pos = strripos($page_sort,".")) {
$string = substr($page_sort,0,$pos);
}


$sm_string .= "$start_ul";
$sm_string .= "$end_ul";
$sm_string .= $start_li;
$sm_string .= '<label class="page-container" for="radio'.$i.'">';
$sm_string .= '<code>'.$sm_page_sort.'</code> - <strong>'.$sm_page_linkname.'</strong> '.$short_title;
$sm_string .= '</label>';
$sm_string .= $end_li;



}

$sm_string .= '</ul>';

echo $sm_string;

?>
74 changes: 74 additions & 0 deletions backend/ajax.sorting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

session_start();
error_reporting(E_ALL ^E_NOTICE);

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';


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

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


}

require_once '../../../acp/core/access.php';
require 'functions.php';


$new_parts = $_POST['page_part'];
$new_page_sort = implode('.',$new_parts);

$data = $db_content->update("fc_pages", [
"page_sort" => $new_page_sort
], [
"page_id" => $_POST['page_id']
]);

$rows = $data->rowCount();



if($rows > 0) {
echo '<span class="text-success">UPDATED PAGE ID '. $_POST['page_id'].'</span>';
} else {
echo '<span class="text-danger">FAILED</span>';
}



?>
70 changes: 70 additions & 0 deletions backend/ajax.updatemetas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

session_start();
error_reporting(E_ALL ^E_NOTICE);

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';


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

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


}

require_once '../../../acp/core/access.php';


$data = $db_content->update("fc_pages", [
"page_title" => $_POST['page_title'],
"page_linkname" => $_POST['page_linkname'],
"page_meta_description" => $_POST['page_meta_description']
], [
"page_id" => $_POST['page_id']
]);

$rows = $data->rowCount();



if($rows > 0) {
echo '<span class="text-success">UPDATED PAGE ID '. $_POST['page_id'].'</span>';
} else {
echo '<span class="text-danger">FAILED</span>';
}

?>
77 changes: 77 additions & 0 deletions backend/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

/**
* show all pages from $db_content
* filter a = all, o = ordered, u = unordered
* lang a = all, en/de/es/ ... filter by language
*/

function be_get_pages($type,$lang) {

global $db_content;
global $languagePack;

if($type == 'a') {
$type_query = "page_sort = '' OR page_sort != '' ";
}
if($type == 'o') {
$type_query = "page_sort != '' ";
}
if($type == 's') {
$type_query = "page_sort = '' ";
}


if($lang == '') {
$lang = $languagePack;
}



$query = "SELECT * FROM fc_pages WHERE (($type_query) AND (page_language = '$lang')) ORDER BY page_sort *1 ASC, LENGTH(page_sort), page_sort ASC";
$get_pages = $db_content->query($query)->fetchAll();
return $get_pages;

}



function be_get_ordered_pages($lang) {

global $db_content;
global $languagePack;

if($lang == '') {
$lang = $languagePack;
}

$rows = array("page_id","page_sort","page_linkname","page_title");


$query = "SELECT * FROM fc_pages WHERE (page_sort != '' AND page_language = '$lang') ORDER BY page_sort *1 ASC, LENGTH(page_sort), page_sort ASC";

$get_pages = $db_content->query($query)->fetchAll();

return $get_pages;

}

function be_get_page_data($id) {

global $db_content;

$rows = array("page_id","page_sort");

$get_page = $db_content->select("fc_pages", $rows,[

"page_id" => $id

]);

return $get_page;

}



?>
6 changes: 6 additions & 0 deletions backend/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

include 'functions.php';


?>
Loading

0 comments on commit 6f6e4e4

Please sign in to comment.