Skip to content

Commit

Permalink
Bugfix and Import for TVS GB
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasKrais committed Sep 14, 2017
1 parent d6d1c5a commit d15b676
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 29 deletions.
7 changes: 4 additions & 3 deletions install.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php
$sql = rex_sql::factory();

// Install database
$sql->setQuery("CREATE TABLE IF NOT EXISTS `". rex::getTablePrefix() ."d2u_guestbook` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`description` text NOT NULL,
`clang_id` int(10) NOT NULL,
`rating` tinyint(1) DEFAULT NULL,
`recommendation` tinyint(1) DEFAULT NULL,
`rating` tinyint(1) DEFAULT 0,
`recommendation` tinyint(1) DEFAULT 0,
`online_status` varchar(10) DEFAULT NULL,
`create_date` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
1 change: 0 additions & 1 deletion lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ d2u_guestbook_no_entries_found = Es sind noch keine Gästebucheinträge vorhande
d2u_guestbook_online_status = Online
d2u_guestbook_rating = Bewertung (1=schlecht / 5=sgt)
d2u_guestbook_recommendation = Empfehlung
d2u_guestbook_settings = Einstellungen
d2u_guestbook_setup = Setup
d2u_guestbook_url = Webseite

Expand Down
18 changes: 10 additions & 8 deletions modules/60/1/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@
print '<div class="entry-body">';
print '<div class="row">';
print '<div class="col-12">'. nl2br($entry->description) .'</div>';
print '<div class="col-12"><b>'. $tag_open .'d2u_guestbook_rating'. $tag_close .': ';
for($i = 1; $i <= 5; $i++) {
if($i <= $entry->rating) {
print ' <span class="icon star-full"></span>';
}
else {
print ' <span class="icon star-empty"></span>';
if($entry->rating > 0) {
print '<div class="col-12"><b>'. $tag_open .'d2u_guestbook_rating'. $tag_close .': ';
for($i = 1; $i <= 5; $i++) {
if($i <= $entry->rating) {
print ' <span class="icon star-full"></span>';
}
else {
print ' <span class="icon star-empty"></span>';
}
}
print '</b></div>';
}
print '</b></div>';
print '</div>';
print '</div>';

Expand Down
18 changes: 10 additions & 8 deletions modules/60/3/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,18 @@ function click_stars(wert) {
print '<div class="entry-body">';
print '<div class="row">';
print '<div class="col-12">'. nl2br($entry->description) .'</div>';
print '<div class="col-12"><b>'. $tag_open .'d2u_guestbook_rating'. $tag_close .': ';
for($i = 1; $i <= 5; $i++) {
if($i <= $entry->rating) {
print ' <span class="icon star-full"></span>';
}
else {
print ' <span class="icon star-empty"></span>';
if($entry->rating > 0) {
print '<div class="col-12"><b>'. $tag_open .'d2u_guestbook_rating'. $tag_close .': ';
for($i = 1; $i <= 5; $i++) {
if($i <= $entry->rating) {
print ' <span class="icon star-full"></span>';
}
else {
print ' <span class="icon star-empty"></span>';
}
}
print '</b></div>';
}
print '</b></div>';
print '</div>';
print '</div>';

Expand Down
8 changes: 4 additions & 4 deletions pages/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$entry->clang_id = $form['clang_id'];
$entry->name = $form['name'];
$entry->email = $form['email'];
$entry->rating = $form['rating'];
$entry->rating = $form['rating'] != '' ? $form['rating'] : 0;
$entry->recommendation = array_key_exists('recommendation', $form) ? TRUE : FALSE;
$entry->description = $form['description'];
$entry->online_status = array_key_exists('online_status', $form) ? 'online' : 'offline';
Expand All @@ -30,10 +30,10 @@

// Redirect to make reload and thus double save impossible
if(filter_input(INPUT_POST, "btn_apply") == 1 && $entry !== FALSE) {
header("Location: ". rex_url::currentBackendPage(array("entry_id"=>$entry->id, "func"=>'edit', "message"=>$message), FALSE));
header("Location: ". rex_url::currentBackendPage(["entry_id" => $entry->id, "func" => 'edit', "message" => $message], FALSE));
}
else {
header("Location: ". rex_url::currentBackendPage(array("message"=>$message), FALSE));
header("Location: ". rex_url::currentBackendPage(["message"=>$message], FALSE));
}
exit;
}
Expand Down Expand Up @@ -83,7 +83,7 @@
}

d2u_addon_backend_helper::form_input('d2u_guestbook_name', 'form[name]', $entry->name, TRUE, FALSE);
d2u_addon_backend_helper::form_input('d2u_guestbook_email', 'form[email]', $entry->email, FALSE, FALSE);
d2u_addon_backend_helper::form_input('d2u_guestbook_email', 'form[email]', $entry->email, FALSE, FALSE, 'email');
d2u_addon_backend_helper::form_input('d2u_guestbook_rating', 'form[rating]', $entry->rating, FALSE, FALSE, 'number');
d2u_addon_backend_helper::form_checkbox('d2u_guestbook_recommendation', 'form[recommendation]', 'true', $entry->recommendation);
d2u_addon_backend_helper::form_textarea('d2u_guestbook_description', "form[description]", $entry->description, 10, TRUE, FALSE, FALSE);
Expand Down
4 changes: 2 additions & 2 deletions pages/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
?>
<form action="<?php print rex_url::currentBackendPage(); ?>" method="post">
<div class="panel panel-edit">
<header class="panel-heading"><div class="panel-title"><?php print rex_i18n::msg('d2u_guestbook_settings'); ?></div></header>
<header class="panel-heading"><div class="panel-title"><?php print rex_i18n::msg('d2u_helper_settings'); ?></div></header>
<div class="panel-body">
<fieldset>
<legend><small><i class="rex-icon fa-book"></i></small> <?php echo rex_i18n::msg('d2u_helper_meta_settings'); ?></legend>
<legend><small><i class="rex-icon fa-book"></i></small> <?php echo rex_i18n::msg('d2u_helper_settings'); ?></legend>
<div class="panel-body-wrapper slide">
<?php
d2u_addon_backend_helper::form_input('d2u_guestbook_settings_request_form_email', 'settings[request_form_email]', $this->getConfig('request_form_email'), TRUE, FALSE, 'email');
Expand Down
29 changes: 26 additions & 3 deletions pages/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,31 @@
// D2UModuleManager show list
$d2u_module_manager->showManagerList();

/*
* Templates
*/
// Import from TVS Guestbook
$sql = rex_sql::factory();
$sql->setQuery("SHOW TABLES LIKE '". rex::getTablePrefix() ."771_entries'");
$tvsgb_available = $sql->getRows() > 0 ? TRUE : FALSE;
if(rex_request('import', 'string') == "tvsgb" && $tvsgb_available) {
$sql->setQuery("UPDATE `". rex::getTablePrefix() ."771_entries` SET description = REPLACE(description, '\r\n', '<br>');
INSERT INTO rex_d2u_guestbook (`name`, `email`, `description`, `clang_id`, `online_status`, `create_date`)
SELECT `create_user`, `email`, `description`, `clang`, `status`, `create_date` FROM rex_771_entries;
UPDATE `". rex::getTablePrefix() ."d2u_guestbook` SET `online_status` = 'online' WHERE `online_status` = '1';
UPDATE `". rex::getTablePrefix() ."d2u_guestbook` SET `online_status` = 'offline' WHERE `online_status` = '0';
UPDATE `". rex::getTablePrefix() ."d2u_guestbook` SET rating = 0 WHERE rating = NULL;
DROP TABLE `". rex::getTablePrefix() ."771_entries`;");
if($sql->hasError()) {
print rex_view::error('Fehler beim Import: '. $sql->getError());
}
else {
print rex_view::success('Daten aus TVS Gästebucherfolgreich importiert und alte Tabelle gelöscht');
}
}
else if($tvsgb_available) {
print "<h2>Import aus Redaxo 4 TVS Gästebuch</h2>";
print "<p>Es wurde eine TVS Gästebuch Tabelle aus Redaxo 4 in der Datenbank gefunden."
. "Sollen die Daten importiert werden und die alte Tabelle gelöscht werden?</p>";
print '<a href="'. rex_url::currentBackendPage(["import" => "tvsgb"], FALSE) .'"><button class="btn btn-save">Import</button></a>';
}
?>
<h2>Installation der Module</h2>
<p>Die zu den obigen Modulen gehörenden CSS Vorlagen befinden sich im Addon
Expand All @@ -35,6 +57,7 @@
<p>1.0.1:</p>
<ul>
<li>Neues Modul ohne Tabs.</li>
<li>Import aus Redaxo 4 TVS Gästebuch, sofern Tabelle in Datenbank vorhanden ist.</li>
</ul>
<p>1.0.0:</p>
<ul>
Expand Down

0 comments on commit d15b676

Please sign in to comment.