Dynamic: Add DynamicContentIncludePage to allow including pages

Tá an tiomantas seo le fáil i:
2022-03-27 21:36:53 +02:00
tuismitheoir 7bb7600d39
tiomantas 1ae5495e61
D'athraigh 7 comhad le 42 breiseanna agus 12 scriosta

Féach ar an gComhad

@ -11,9 +11,15 @@ class DynamicContent
Database *database;
UrlProvider *urlProvider;
std::string argument;
public:
DynamicContent(Template &templ, Database &database, UrlProvider &urlProvider);
virtual std::string render() = 0;
virtual void setArgument(std::string argument)
{
this->argument = argument;
}
virtual ~DynamicContent()
{
}

Féach ar an gComhad

@ -0,0 +1,14 @@
#include "dynamiccontentincludepage.h"
#include "../parser.h"
std::string DynamicContentIncludePage::render()
{
auto revisionDao = this->database->createRevisionDao();
auto rev = revisionDao->getCurrentForPage(this->argument);
if(rev)
{
Parser parser;
auto result = parser.parse(*this->database->createPageDao(), *this->urlProvider, rev->content);
return result;
}
return {};
}

Féach ar an gComhad

@ -0,0 +1,12 @@
#ifndef DYNAMICCONTENTINCLUDEPAGE_H
#define DYNAMICCONTENTINCLUDEPAGE_H
#include "dynamiccontent.h"
class DynamicContentIncludePage : public DynamicContent
{
public:
using DynamicContent::DynamicContent;
std::string render();
};
#endif // DYNAMICCONTENTINCLUDEPAGE_H

Féach ar an gComhad

@ -1,11 +1,6 @@
#include <chrono>
#include "dynamiccontentpostlist.h"
void DynamicContentPostList::setCategory(std::string catname)
{
this->catname = catname;
}
std::string DynamicContentPostList::render()
{
auto categoryDao = this->database->createCategoryDao();
@ -13,7 +8,7 @@ std::string DynamicContentPostList::render()
auto revisionDao = this->database->createRevisionDao();
QueryOption option;
option.includeInvisible = false;
auto members = categoryDao->fetchMembers(this->catname, option);
auto members = categoryDao->fetchMembers(this->argument, option);
std::vector<std::pair<std::string, time_t>> pageList;
for(std::string &member : members)
{

Féach ar an gComhad

@ -4,12 +4,8 @@
#include "dynamiccontent.h"
class DynamicContentPostList : public DynamicContent
{
private:
std::string catname;
public:
using DynamicContent::DynamicContent;
void setCategory(std::string catname);
std::string render() override;
};