Skip to content

Commit

Permalink
[BUGFIX] Show hidden posts in backend module
Browse files Browse the repository at this point in the history
Fixes: #136
  • Loading branch information
benjaminkott committed Mar 6, 2020
1 parent 90a6bfc commit 31ef29d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public function setupWizardAction(): string
*/
public function postsAction(int $blogSetup = null): string
{
$query = $this->postRepository->createQuery();
$querySettings = $query->getQuerySettings();
$querySettings->setIgnoreEnableFields(true);
$this->postRepository->setDefaultQuerySettings($querySettings);

return $this->render('Backend/Posts.html', [
'blogSetups' => $this->setupService->determineBlogSetups(),
'activeBlogSetup' => $blogSetup,
Expand Down
33 changes: 33 additions & 0 deletions Classes/Domain/Model/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

class Post extends AbstractEntity
{
/**
* @var bool
*/
protected $hidden = false;

/**
* The blog post doktype
*
Expand Down Expand Up @@ -152,6 +157,16 @@ public function initializeObject(): void
$this->media = new ObjectStorage();
}

public function getHidden(): bool
{
return $this->hidden;
}

public function isHidden(): bool
{
return $this->getHidden();
}

/**
* @return int
*/
Expand Down Expand Up @@ -533,4 +548,22 @@ public function getUri(): string
->setTargetPageUid($this->getUid())
->build();
}

public function getAsArray(): array
{
return $this->__toArray();
}

public function __toArray(): array
{
return [
'uid' => $this->getUid(),
'hidden' => $this->getHidden(),
'doktype' => $this->getDoktype(),
'title' => $this->getTitle(),
'subtitle' => $this->getSubtitle(),
'abstract' => $this->getAbstract(),
'description' => $this->getDescription()
];
}
}
9 changes: 9 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@
<trans-unit id="backend.table.date" xml:space="preserve">
<source>Date</source>
</trans-unit>
<trans-unit id="backend.table.hidden" xml:space="preserve">
<source>Hidden</source>
</trans-unit>
<trans-unit id="backend.table.hidden.yes" xml:space="preserve">
<source>Yes</source>
</trans-unit>
<trans-unit id="backend.table.hidden.no" xml:space="preserve">
<source>No</source>
</trans-unit>
<trans-unit id="backend.comments.filter.all" xml:space="preserve">
<source>All</source>
</trans-unit>
Expand Down
11 changes: 9 additions & 2 deletions Resources/Private/Templates/Backend/Posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ <h1><f:translate key="backend.headline.posts" /></h1>
<f:if condition="{f:count() -> posts} > 0">
<f:then>

<table class="table table-striped table-hover dataTables" data-columns='[{"type": "string"}, {"type": "string"}, {"type": "string"}, {"type": "string"}, {"type": "num"}]'>
<table class="table table-striped table-hover dataTables" data-columns='[{"type": "string"}, {"type": "string"}, {"type": "string"}, {"type": "string"}, {"type": "string"}, {"type": "num"}]'>
<thead>
<tr>
<th><f:translate key="backend.table.title" /></th>
<th data-filter="true"><f:translate key="backend.table.hidden" /></th>
<th data-filter="true"><f:translate key="backend.table.author" /></th>
<th data-filter="true"><f:translate key="backend.table.categories" /></th>
<th data-filter="true"><f:translate key="backend.table.tags" /></th>
Expand All @@ -24,11 +25,17 @@ <h1><f:translate key="backend.headline.posts" /></h1>

<td class="nowrap" data-search="{post.title}" data-filter="{post.title}">
<blogvh:link.be.post post="{post}">
<core:icon identifier="record-blog-post" />
<core:iconForRecord table="pages" row="{post.asArray}" />
{post.title}
</blogvh:link.be.post>
</td>

<f:variable name="hiddenString" value="{f:if(condition: post.hidden, then: 'yes', else: 'no')}" />
<f:variable name="hiddenString" value="{f:translate(key: 'backend.table.hidden.{hiddenString}')}" />
<td class="nowrap" data-search="{hiddenString}" data-filter="{hiddenString}">
{hiddenString}
</td>

<f:variable name="authorString" value="" />
<f:if condition="{post.authors}">
<f:for each="{post.authors}" as="author" iteration="{iteration}">
Expand Down

0 comments on commit 31ef29d

Please sign in to comment.