'Blog RSS Feed', 'description' => 'An RSS feed generator for the RainLab Blog plugin', 'author' => 'Josh Hall', 'icon' => 'icon-rss' ]; } public function registerComponents() { return [ 'SoBoRed\Rss\Components\Link' => 'rssLink' ]; } public function boot() { // Event Listeners for RainLab Blog Event::listen('eloquent.created: RainLab\Blog\Models\Post', function($model) { $this->createRss(); }); Event::listen('eloquent.saved: RainLab\Blog\Models\Post', function($model) { $this->createRss(); }); Event::listen('eloquent.deleted: RainLab\Blog\Models\Post', function($model) { $this->createRss(); }); // Event Listeners for SoBoRed settings Event::listen('eloquent.saved: SoBoRed\Rss\Models\Settings', function($model) { $this->createRss(); }); } public function registerSettings() { return [ 'settings' => [ 'label' => 'Blog RSS Settings', 'description' => 'Manage the Blog RSS settings.', 'category' => 'Blog', 'icon' => 'icon-rss', 'class' => 'SoBoRed\Rss\Models\Settings', 'order' => 100 ] ]; } protected function createRss() { $fileContents = "\n" . "\n". "\t\n". "\t\t" . Settings::get('title') . "\n" . "\t\t" . Settings::get('link') . "\n" . "\t\t" . Settings::get('description') . "\n". "\t\t\n\n"; foreach($this->loadPosts() as $post) { $published = DateTime::createFromFormat('Y-m-d H:i:s', $post->published_at); $description = Settings::get('showFullPostContent') ? $post->content : $post->excerpt; $description = Markdown::parse(trim($description)); $fileContents .= "\t\t\n" . "\t\t\t" . htmlspecialchars($post->title, ENT_QUOTES, 'UTF-8') . "\n" . "\t\t\t" . Settings::get('link') . Settings::get('postPage') . "/" . $post->slug . "\n" . "\t\t\t" . Settings::get('link') . Settings::get('postPage') . "/" . $post->slug . "\n" . "\t\t\t" . $published->format(DateTime::RFC2822) . "\n" . "\t\t\t\n" . "\t\t\n"; } $fileContents .= "\t\n"; $fileContents .= "\n"; $file = File::put('rss.xml', $fileContents); return $file; } protected function loadPosts() { $posts = Db::table('rainlab_blog_posts') ->select('id','title','slug','published_at','content','excerpt','featured_image') ->orderBy('published_at', 'desc') ->where('published', '=', '1') ->get(); return $posts; } }