Added rss controller...

main
Robert 4 months ago
parent 2fbe6fd9f0
commit 21596160e9
  1. 11
      protected/src/configs/on_footer_banner.php
  2. 13
      protected/src/controllers/app/home_ctrl.php
  3. 47
      protected/src/controllers/app/rss_ctrl.php

@ -7,10 +7,10 @@ declare(strict_types=1);
* @copyright (c) 2025, Robert Strutts * @copyright (c) 2025, Robert Strutts
* @license MIT * @license MIT
*/ */
namespace Project;
?> function get_footer(): string {
return '<footer style="
<footer style="
background-color: #333; background-color: #333;
color: white; color: white;
text-align: center; text-align: center;
@ -22,11 +22,12 @@ declare(strict_types=1);
border-top: 2px solid #444; border-top: 2px solid #444;
"> ">
<div style="max-width: 800px; margin: 0 auto;"> <div style="max-width: 800px; margin: 0 auto;">
<p style="margin: 0; padding: 0;">&copy; <?= date('Y') ?> Your Company Name. All rights reserved.</p> <p style="margin: 0; padding: 0;">&copy; <?= date("Y") ?> Your Company Name. All rights reserved.</p>
<p style="margin: 10px 0 0 0; padding: 0; font-size: 0.8em;"> <p style="margin: 10px 0 0 0; padding: 0; font-size: 0.8em;">
<a href="/privacy" style="color: #4da6ff; text-decoration: none;">Privacy Policy</a> | <a href="/privacy" style="color: #4da6ff; text-decoration: none;">Privacy Policy</a> |
<a href="/terms" style="color: #4da6ff; text-decoration: none;">Terms of Service</a> | <a href="/terms" style="color: #4da6ff; text-decoration: none;">Terms of Service</a> |
<a href="/contact" style="color: #4da6ff; text-decoration: none;">Contact Us</a> <a href="/contact" style="color: #4da6ff; text-decoration: none;">Contact Us</a>
</p> </p>
</div> </div>
</footer> </footer>';
}

@ -16,9 +16,16 @@ use CodeHydrater\enums\view_type as ViewType;
* /app/home/name_demo * /app/home/name_demo
*/ */
class home_ctrl { class home_ctrl {
private $footer;
public function __construct() {
// FROM on_footer_banner.php in the configs folder...
$this->footer = \Project\get_footer();
}
public function index() { public function index() {
$html = new \CodeHydrater\html_document(); $html = new \CodeHydrater\html_document();
$html->set_footer($this->footer);
$html->set_author("Robert Strutts, plus ME!"); $html->set_author("Robert Strutts, plus ME!");
$view = new \CodeHydrater\view(); $view = new \CodeHydrater\view();
@ -30,12 +37,16 @@ class home_ctrl {
} }
public function name_demo() { public function name_demo() {
echo $this->footer;
$view = new \CodeHydrater\view(); $view = new \CodeHydrater\view();
$view->set('twig_data', ['name' => "John Doe"]); $view->set('twig_data', ['name' => "John Doe"]);
$view->render($this, "app/test", ViewType::TWIG); $view->render($this, "app/test", ViewType::TWIG);
} }
public function liquid() { public function liquid() {
echo $this->footer;
$view = new \CodeHydrater\view(); $view = new \CodeHydrater\view();
$view->set('template_assigns', [ $view->set('template_assigns', [
'name' => "James Smith", 'name' => "James Smith",

@ -0,0 +1,47 @@
<?php
declare(strict_types = 1);
/**
* @author Robert Strutts <Bob_586@Yahoo.com>
* @copyright (c) 2025, Robert Strutts
* @license MIT
*/
namespace Project\controllers\app;
class rss_ctrl {
public function feed() {
$root = [
"feed_link" => "https://example.com/app/rss/feed",
"title" => "Example News",
"description" => "Cool New Stuff...",
"site_link" => "https://example.com",
"lang" => "en-us",
"pub_date" => "Tue, 29 Jul 2025 22:08:18 +0000", // DATE_RSS format
"last_build_date" => date(DATE_RSS),
];
// Should be populating items from a Database...
$items = [
[
'title' => 'First Article',
'link' => 'http://example.com/article1',
'description' => 'This is the description of the first article.',
'pubDate' => date(DATE_RSS, strtotime('-2 days')),
'guid' => 'http://example.com/article1',
'author' => 'author@example.com (John Doe)'
],
[
'title' => 'Second Article',
'link' => 'http://example.com/article2',
'description' => 'This is the description of the second article.',
'pubDate' => date(DATE_RSS, strtotime('-1 day')),
'guid' => 'http://example.com/article2',
'author' => 'author@example.com (Jane Smith)'
]
];
$rss = \CodeHydrater\rss_feed::generate_rss_feed($root, $items);
\CodeHydrater\rss_feed::output_rss($rss);
// \CodeHydrater\rss_feed::save_to_xml_file($rss); // this would make feed.xml in the Public folder...
}
}
Loading…
Cancel
Save