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

Commit

Permalink
New - Addons-Tab in the page editing mask
Browse files Browse the repository at this point in the history
Addons can now save own values for each individual page. A certain form (/…mod/backend/page-form.php) must be in the backend directory in the module.
  • Loading branch information
patkon committed Jan 8, 2020
1 parent fec062a commit 840f157
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 34 deletions.
12 changes: 11 additions & 1 deletion acp/core/pages.edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'page_thumbnail' => 'STR',
'page_modul' => 'STR',
'page_modul_query' => 'STR',
'page_addon_string' => 'STR',
'page_authorized_users' => 'STR',
'page_version' => 'STR',
'page_labels' => 'STR',
Expand Down Expand Up @@ -90,6 +91,7 @@
'page_thumbnail' => 'STR',
'page_modul' => 'STR',
'page_modul_query' => 'STR',
'page_addon_string' => 'STR',
'page_authorized_users' => 'STR',
'page_version' => 'STR',
'page_labels' => 'STR',
Expand Down Expand Up @@ -126,6 +128,7 @@
'page_thumbnail' => 'STR',
'page_modul' => 'STR',
'page_modul_query' => 'STR',
'page_addon_string' => 'STR',
'page_authorized_users' => 'STR',
'page_cache_type' => 'STR',
'page_version' => 'STR',
Expand Down Expand Up @@ -195,7 +198,7 @@
*/

if($_POST['save_the_page'] OR $_REQUEST['preview_the_page']) {

$page_lastedit = time();
$page_lastedit_from = $_SESSION['user_nick'];

Expand Down Expand Up @@ -276,6 +279,11 @@
/* page_meta_robots */
$page_meta_robots = implode(',',$_POST['page_meta_robots']);

/* addon injection */
$page_addon_string = '';
if(is_array($_POST['addon'])) {
$page_addon_string = json_encode($_POST['addon'],JSON_UNESCAPED_UNICODE);
}

// connect to database
$dbh = new PDO("sqlite:".CONTENT_DB);
Expand Down Expand Up @@ -306,6 +314,7 @@
$sth->bindParam(':page_meta_robots', $page_meta_robots, PDO::PARAM_STR);
$sth->bindParam(':page_thumbnail', $page_thumbnail, PDO::PARAM_STR);
$sth->bindParam(':page_psw', $page_psw, PDO::PARAM_STR);
$sth->bindParam(':page_addon_string', $page_addon_string, PDO::PARAM_STR);


$cnt_changes = $sth->execute();
Expand Down Expand Up @@ -346,6 +355,7 @@
$sth->bindParam(':page_meta_robots', $page_meta_robots, PDO::PARAM_STR);
$sth->bindParam(':page_thumbnail', $page_thumbnail, PDO::PARAM_STR);
$sth->bindParam(':page_psw', $page_psw, PDO::PARAM_STR);
$sth->bindParam(':page_addon_string', $page_addon_string, PDO::PARAM_STR);

$cnt_changes_c = $std->execute();

Expand Down
80 changes: 47 additions & 33 deletions acp/core/pages.edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
echo '<li class="nav-item"><a class="nav-link" href="#extracontent" data-toggle="tab">'.$lang['tab_extracontent'].'</a></li>';
echo '<li class="nav-item"><a class="nav-link" href="#meta" data-toggle="tab">'.$lang['tab_meta'].'</a></li>';
echo '<li class="nav-item"><a class="nav-link" href="#head" data-toggle="tab">'.$lang['tab_head'].'</a></li>';
echo '<li class="nav-item"><a class="nav-link" href="#addons" data-toggle="tab">'.$lang['tab_addons'].'</a></li>';
if($cnt_custom_fields > 0) {
echo '<li class="nav-item"><a class="nav-link" href="#custom" data-toggle="tab">'.$lang['legend_custom_fields'].'</a></li>';
}
Expand Down Expand Up @@ -317,6 +318,52 @@

echo '</div>'; /* EOL tab_head */

/* tab addons */
echo '<div class="tab-pane fade" id="addons">';

/* Select Modul */

$select_page_modul = '<select name="page_modul" class="custom-select form-control">';
$select_page_modul .= '<option value="">Kein Modul</option>';

for($i=0;$i<count($all_mods);$i++) {

$selected = "";
$mod_name = $all_mods[$i]['name'];
$mod_folder = $all_mods[$i]['folder'];

if($mod_folder == $page_modul) {
$selected = 'selected';
}

$select_page_modul .= "<option value='$mod_folder' $selected>$mod_name</option>";

}


$select_page_modul .= '</select>';


echo '<div class="form-group">';
echo '<label>'.$lang['f_page_modul'].'</label>';
echo $select_page_modul;
echo '</div>';

echo '<div class="form-group">';
echo '<label>'.$lang['f_page_modul_query'].'</label>';
echo "<input class='form-control' type='text' name='page_modul_query' value='$page_modul_query'>";
echo '</div>';

/* if there is */
if($page_modul != '') {
/* check if the module has its own form */
if(is_file("../modules/$page_modul/backend/page-form.php")) {
include "../modules/$page_modul/backend/page-form.php";
}
}


echo '</div>'; /* EOL tab addons */


if($cnt_custom_fields > 0) {
Expand Down Expand Up @@ -430,39 +477,6 @@
echo $select_select_template;
echo '</div>';

/* Select Modul */


$select_page_modul = '<select name="page_modul" class="custom-select form-control">';
$select_page_modul .= '<option value="">Kein Modul</option>';

for($i=0;$i<count($all_mods);$i++) {

$selected = "";
$mod_name = $all_mods[$i]['name'];
$mod_folder = $all_mods[$i]['folder'];

if($mod_folder == "$page_modul") {
$selected = "selected";
}

$select_page_modul .= "<option value='$mod_folder' $selected>$mod_name</option>";

}


$select_page_modul .= '</select>';


echo '<div class="form-group">';
echo '<label>'.$lang['f_page_modul'].'</label>';
echo $select_page_modul;
echo '</div>';

echo '<div class="form-group">';
echo '<label>'.$lang['f_page_modul_query'].'</label>';
echo "<input class='form-control' type='text' name='page_modul_query' value='$page_modul_query'>";
echo '</div>';


/* Select Status */
Expand Down
1 change: 1 addition & 0 deletions install/contents/fc_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"page_template_layout" => 'VARCHAR',
"page_modul" => 'VARCHAR',
"page_modul_query" => 'VARCHAR',
"page_addon_string" => 'VARCHAR',
"page_authorized_users" => 'VARCHAR',
"page_version" => 'INTEGER',
"page_version_date" => 'VARCHAR',
Expand Down
1 change: 1 addition & 0 deletions install/contents/fc_pages_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"page_template_layout" => 'VARCHAR',
"page_modul" => 'VARCHAR',
"page_modul_query" => 'VARCHAR',
"page_addon_string" => 'VARCHAR',
"page_authorized_users" => 'VARCHAR',
"page_version" => 'INTEGER',
"page_version_date" => 'VARCHAR',
Expand Down
2 changes: 2 additions & 0 deletions lib/lang/de/dict-backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@
$lang['tab_head'] = "Head (Code/HTML)";
$lang['tab_head_description'] = "Sonstige Header Informationen";

$lang['tab_addons'] = "Addons";

$lang['tab_page_preferences'] = "Einstellungen";
$lang['tab_page_preferences_description'] = "Templates....";

Expand Down
2 changes: 2 additions & 0 deletions lib/lang/en/dict-backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@
$lang['tab_head'] = "Head (Code/HTML)";
$lang['tab_head_description'] = "Other Header Informationen";

$lang['tab_addons'] = "Addons";

$lang['tab_page_preferences'] = "Preferences";
$lang['tab_page_preferences_description'] = "Templates, Rights Management ...";

Expand Down

0 comments on commit 840f157

Please sign in to comment.