diff options
author | Christian Klinger | 2016-07-05 10:18:52 +0200 |
---|---|---|
committer | Christian Klinger | 2016-07-05 10:18:52 +0200 |
commit | 1c364128619b838f8245d898e9cde902ac7a42bf (patch) | |
tree | 70977c7cc0d232d58a2cf278f8778e88829723b9 /modules-available/news | |
parent | minimal changes (diff) | |
parent | Update translations (diff) | |
download | slx-admin-1c364128619b838f8245d898e9cde902ac7a42bf.tar.gz slx-admin-1c364128619b838f8245d898e9cde902ac7a42bf.tar.xz slx-admin-1c364128619b838f8245d898e9cde902ac7a42bf.zip |
Merge branch 'modularization' of git.openslx.org:openslx-ng/slx-admin into modularization
Conflicts:
modules-available/main/templates/main-menu.html
Diffstat (limited to 'modules-available/news')
-rw-r--r-- | modules-available/news/api.inc.php | 29 | ||||
-rw-r--r-- | modules-available/news/install.inc.php | 49 | ||||
-rw-r--r-- | modules-available/news/style.css | 6 | ||||
-rw-r--r-- | modules-available/news/templates/page-news.html | 6 |
4 files changed, 61 insertions, 29 deletions
diff --git a/modules-available/news/api.inc.php b/modules-available/news/api.inc.php new file mode 100644 index 00000000..cbfaa82b --- /dev/null +++ b/modules-available/news/api.inc.php @@ -0,0 +1,29 @@ +<?php + +header('Content-Type: application/xml; charset=utf-8'); + +$type = Request::any('type', 'news', 'string'); + +// Fetch news from DB +$row = Database::queryFirst('SELECT title, content, dateline FROM vmchooser_pages' + . ' WHERE type = :type ORDER BY dateline DESC LIMIT 1', compact('type')); +if ($row !== false ) { + + echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; + echo "<news>" . "\n"; + echo "\t" . '<headline>' . "\n"; + echo "\t\t" . htmlspecialchars($row['title']) . "\n"; + echo "\t" . '</headline>' . "\n"; + echo "\t" . "<info>" . "\n"; + echo "\t\t" . htmlspecialchars(nl2br($row['content'])) . "\n"; + echo "\t" . '</info>' . "\n"; + echo "\t" . "<date>" . "\n"; + echo "\t\t" . $row['dateline'] . "\n"; + echo "\t" . "</date>" . "\n"; + echo "</news>"; + +} else { + // no news in DB, output a 'null' news xml + echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; + echo "<news>null</news>"; +} diff --git a/modules-available/news/install.inc.php b/modules-available/news/install.inc.php index 48e13a41..620a4580 100644 --- a/modules-available/news/install.inc.php +++ b/modules-available/news/install.inc.php @@ -5,32 +5,35 @@ $res = array(); if (tableExists('news')) { - /* rename news and add column "type" */ - tableRename('news', 'vmchooser_pages'); - Database::exec("ALTER TABLE `vmchooser_pages` ADD COLUMN type varchar(10)", []); - Database::exec("UPDATE `vmchooser_pages` set `type`='news` WHERE 1", []); - - finalResponse(UPDATE_DONE, 'Tables updated successfully'); - -} else { - $res[] = tableCreate('vmchooser_pages', " - `newsid` int(10) unsigned NOT NULL AUTO_INCREMENT, - `dateline` int(10) unsigned NOT NULL, - `title` varchar(200) DEFAULT NULL, - `content` text, - `type` varchar(10), - PRIMARY KEY (`newsid`), - KEY `dateline` (`dateline`) - "); + /* rename news and add column "type" */ + if (!tableRename('news', 'vmchooser_pages')) { + finalResponse(UPDATE_FAILED, "Could not rename news to vmchooser_pages: " . Database::lastError()); + } + $res[] = UPDATE_DONE; + if (false === Database::exec("ALTER TABLE `vmchooser_pages` ADD COLUMN type VARCHAR(10)")) { + EventLog::warning("Could not add type column to vmchooser_pages: " . Database::lastError()); + } + if (false === Database::exec("UPDATE `vmchooser_pages` SET `type` = 'news' WHERE 1")) { + EventLog::warning("News module update: Could not set default type to news: " . Database::lastError()); + } - // *crickets* +} - // Create response for browser +$res[] = tableCreate('vmchooser_pages', " + `newsid` int(10) unsigned NOT NULL AUTO_INCREMENT, + `dateline` int(10) unsigned NOT NULL, + `title` varchar(200) DEFAULT NULL, + `content` text, + `type` varchar(10), + PRIMARY KEY (`newsid`), + KEY `dateline` (`dateline`) +"); - if (in_array(UPDATE_DONE, $res)) { - finalResponse(UPDATE_DONE, 'Tables created successfully'); - } +// Create response for browser - finalResponse(UPDATE_NOOP, 'Everything already up to date'); +if (in_array(UPDATE_DONE, $res)) { + finalResponse(UPDATE_DONE, 'Tables created successfully'); } + +finalResponse(UPDATE_NOOP, 'Everything already up to date'); diff --git a/modules-available/news/style.css b/modules-available/news/style.css new file mode 100644 index 00000000..c11567ec --- /dev/null +++ b/modules-available/news/style.css @@ -0,0 +1,6 @@ +/* Make things look more like they will show up in vmchooser (Qt) */ + +.note-editor pre { + background: none; + border: none; +} diff --git a/modules-available/news/templates/page-news.html b/modules-available/news/templates/page-news.html index c698e408..7750137e 100644 --- a/modules-available/news/templates/page-news.html +++ b/modules-available/news/templates/page-news.html @@ -102,9 +102,3 @@ </div> </div> </div> -{{#hasSummernote}} -<script> -document.addEventListener("DOMContentLoaded", function () { -}); -</script> -{{/hasSummernote}} |