Added ability to access posts using their hashes
This commit is contained in:
parent
174fd80a73
commit
ef4ba5a348
7 changed files with 105 additions and 90 deletions
|
@ -90,19 +90,20 @@ class PostController extends AbstractController
|
||||||
$this->listView('order:random', $page, 'random');
|
$this->listView('order:random', $page, 'random');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleTagAction($id, $tag, $enable)
|
public function toggleTagAction($identifier, $tag, $enable)
|
||||||
{
|
{
|
||||||
Access::assert(new Privilege(
|
Access::assert(new Privilege(
|
||||||
Privilege::MassTag,
|
Privilege::MassTag,
|
||||||
Access::getIdentity(PostModel::getById($id)->getUploader())));
|
Access::getIdentity(PostModel::getByIdOrName($identifier)->getUploader())));
|
||||||
|
|
||||||
Api::run(
|
$jobArgs =
|
||||||
new TogglePostTagJob(),
|
[
|
||||||
[
|
JobArgs::ARG_TAG_NAME => $tag,
|
||||||
JobArgs::ARG_POST_ID => $id,
|
JobArgs::ARG_NEW_STATE => $enable,
|
||||||
JobArgs::ARG_TAG_NAME => $tag,
|
];
|
||||||
JobArgs::ARG_NEW_STATE => $enable,
|
$jobArgs = $this->appendPostIdentifierArgument($args, $identifier);
|
||||||
]);
|
|
||||||
|
Api::run(new TogglePostTagJob(), $jobArgs);
|
||||||
|
|
||||||
if ($this->isAjax())
|
if ($this->isAjax())
|
||||||
$this->renderAjax();
|
$this->renderAjax();
|
||||||
|
@ -147,18 +148,19 @@ class PostController extends AbstractController
|
||||||
$this->redirectToPostList();
|
$this->redirectToPostList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editView($id)
|
public function editView($identifier)
|
||||||
{
|
{
|
||||||
$post = Api::run(new GetPostJob(), [
|
$jobArgs = [];
|
||||||
JobArgs::ARG_POST_ID => $id]);
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
|
$post = Api::run(new GetPostJob(), $jobArgs);
|
||||||
|
|
||||||
$context = Core::getContext()->transport->post = $post;
|
$context = Core::getContext()->transport->post = $post;
|
||||||
$this->renderView('post-edit');
|
$this->renderView('post-edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editAction($id)
|
public function editAction($identifier)
|
||||||
{
|
{
|
||||||
$post = PostModel::getByIdOrName($id);
|
$post = PostModel::getByIdOrName($identifier);
|
||||||
|
|
||||||
$editToken = InputHelper::get('edit-token');
|
$editToken = InputHelper::get('edit-token');
|
||||||
if ($editToken != $post->getEditToken())
|
if ($editToken != $post->getEditToken())
|
||||||
|
@ -166,12 +168,12 @@ class PostController extends AbstractController
|
||||||
|
|
||||||
$jobArgs =
|
$jobArgs =
|
||||||
[
|
[
|
||||||
JobArgs::ARG_POST_ID => $id,
|
|
||||||
JobArgs::ARG_NEW_SAFETY => InputHelper::get('safety'),
|
JobArgs::ARG_NEW_SAFETY => InputHelper::get('safety'),
|
||||||
JobArgs::ARG_NEW_TAG_NAMES => $this->splitTags(InputHelper::get('tags')),
|
JobArgs::ARG_NEW_TAG_NAMES => $this->splitTags(InputHelper::get('tags')),
|
||||||
JobArgs::ARG_NEW_SOURCE => InputHelper::get('source'),
|
JobArgs::ARG_NEW_SOURCE => InputHelper::get('source'),
|
||||||
JobArgs::ARG_NEW_RELATED_POST_IDS => $this->splitPostIds(InputHelper::get('relations')),
|
JobArgs::ARG_NEW_RELATED_POST_IDS => $this->splitPostIds(InputHelper::get('relations')),
|
||||||
];
|
];
|
||||||
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
|
|
||||||
if (!empty(InputHelper::get('url')))
|
if (!empty(InputHelper::get('url')))
|
||||||
{
|
{
|
||||||
|
@ -202,97 +204,100 @@ class PostController extends AbstractController
|
||||||
if ($this->isAjax())
|
if ($this->isAjax())
|
||||||
$this->renderAjax();
|
$this->renderAjax();
|
||||||
else
|
else
|
||||||
$this->redirectToGenericView($id);
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function flagAction($id)
|
public function flagAction($identifier)
|
||||||
{
|
{
|
||||||
Api::run(new FlagPostJob(), [JobArgs::ARG_POST_ID => $id]);
|
$jobArgs = [];
|
||||||
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
|
Api::run(new FlagPostJob(), $jobArgs);
|
||||||
|
|
||||||
if ($this->isAjax())
|
if ($this->isAjax())
|
||||||
$this->renderAjax();
|
$this->renderAjax();
|
||||||
else
|
else
|
||||||
$this->redirectToGenericView($id);
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hideAction($id)
|
public function hideAction($identifier)
|
||||||
{
|
{
|
||||||
Api::run(new TogglePostVisibilityJob(), [
|
$jobArgs = [JobArgs::ARG_NEW_STATE => false];
|
||||||
JobArgs::ARG_POST_ID => $id,
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
JobArgs::ARG_NEW_STATE => false]);
|
Api::run(new TogglePostVisibilityJob(), $jobArgs);
|
||||||
$this->redirectToGenericView($id);
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unhideAction($id)
|
public function unhideAction($identifier)
|
||||||
{
|
{
|
||||||
Api::run(new TogglePostVisibilityJob(), [
|
$jobArgs = [JobArgs::ARG_NEW_STATE => true];
|
||||||
JobArgs::ARG_POST_ID => $id,
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
JobArgs::ARG_NEW_STATE => true]);
|
Api::run(new TogglePostVisibilityJob(), $jobArgs);
|
||||||
$this->redirectToGenericView($id);
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteAction($id)
|
public function deleteAction($identifier)
|
||||||
{
|
{
|
||||||
Api::run(new DeletePostJob(), [
|
$jobArgs = [];
|
||||||
JobArgs::ARG_POST_ID => $id]);
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
|
Api::run(new DeletePostJob(), $jobArgs);
|
||||||
$this->redirectToPostList();
|
$this->redirectToPostList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addFavoriteAction($id)
|
public function addFavoriteAction($identifier)
|
||||||
{
|
{
|
||||||
Api::run(new TogglePostFavoriteJob(), [
|
$jobArgs = [JobArgs::ARG_NEW_STATE => true];
|
||||||
JobArgs::ARG_POST_ID => $id,
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
JobArgs::ARG_NEW_STATE => true]);
|
Api::run(new TogglePostFavoriteJob(), $jobArgs);
|
||||||
$this->redirectToGenericView($id);
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeFavoriteAction($id)
|
public function removeFavoriteAction($identifier)
|
||||||
{
|
{
|
||||||
Api::run(new TogglePostFavoriteJob(), [
|
$jobArgs = [JobArgs::ARG_NEW_STATE => false];
|
||||||
JobArgs::ARG_POST_ID => $id,
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
JobArgs::ARG_NEW_STATE => false]);
|
Api::run(new TogglePostFavoriteJob(), $jobArgs);
|
||||||
$this->redirectToGenericView($id);
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scoreAction($id, $score)
|
public function scoreAction($identifier, $score)
|
||||||
{
|
{
|
||||||
Api::run(new ScorePostJob(), [
|
$jobArgs = [JobArgs::ARG_NEW_POST_SCORE => $score];
|
||||||
JobArgs::ARG_POST_ID => $id,
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
JobArgs::ARG_NEW_POST_SCORE => $score]);
|
Api::run(new ScorePostJob(), $jobArgs);
|
||||||
$this->redirectToGenericView($id);
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function featureAction($id)
|
public function featureAction($identifier)
|
||||||
{
|
{
|
||||||
Api::run(new FeaturePostJob(), [
|
$jobArgs = [];
|
||||||
JobArgs::ARG_POST_ID => $id]);
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
$this->redirectToGenericView($id);
|
Api::run(new FeaturePostJob(), $jobArgs);
|
||||||
|
$this->redirectToGenericView($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function genericView($id)
|
public function genericView($identifier)
|
||||||
{
|
{
|
||||||
$context = Core::getContext();
|
$context = Core::getContext();
|
||||||
|
|
||||||
$post = Api::run(new GetPostJob(), [
|
$jobArgs = [];
|
||||||
JobArgs::ARG_POST_ID => $id]);
|
$jobArgs = $this->appendPostIdentifierArgument($jobArgs, $identifier);
|
||||||
|
$post = Api::run(new GetPostJob(), $jobArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$context->transport->lastSearchQuery = InputHelper::get('last-search-query');
|
$context->transport->lastSearchQuery = InputHelper::get('last-search-query');
|
||||||
list ($prevPostId, $nextPostId) =
|
list ($prevPostId, $nextPostId) =
|
||||||
PostSearchService::getPostIdsAround(
|
PostSearchService::getPostIdsAround(
|
||||||
$context->transport->lastSearchQuery, $id);
|
$context->transport->lastSearchQuery, $identifier);
|
||||||
}
|
}
|
||||||
#search for some reason was invalid, e.g. tag was deleted in the meantime
|
#search for some reason was invalid, e.g. tag was deleted in the meantime
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$context->transport->lastSearchQuery = '';
|
$context->transport->lastSearchQuery = '';
|
||||||
list ($prevPostId, $nextPostId) =
|
list ($prevPostId, $nextPostId) =
|
||||||
PostSearchService::getPostIdsAround($context->transport->lastSearchQuery, $id);
|
PostSearchService::getPostIdsAround($context->transport->lastSearchQuery, $identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo:
|
|
||||||
//move these to PostEntity when implementing ApiController
|
|
||||||
$isUserFavorite = Auth::getCurrentUser()->hasFavorited($post);
|
$isUserFavorite = Auth::getCurrentUser()->hasFavorited($post);
|
||||||
$userScore = Auth::getCurrentUser()->getScore($post);
|
$userScore = Auth::getCurrentUser()->getScore($post);
|
||||||
$flagged = in_array(TextHelper::reprPost($post), SessionHelper::get('flagged', []));
|
$flagged = in_array(TextHelper::reprPost($post), SessionHelper::get('flagged', []));
|
||||||
|
@ -336,6 +341,15 @@ class PostController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function appendPostIdentifierArgument(array $arguments, $postIdentifier)
|
||||||
|
{
|
||||||
|
if (is_numeric($postIdentifier))
|
||||||
|
$arguments[JobArgs::ARG_POST_ID] = $postIdentifier;
|
||||||
|
else
|
||||||
|
$arguments[JobArgs::ARG_POST_NAME] = $postIdentifier;
|
||||||
|
return $arguments;
|
||||||
|
}
|
||||||
|
|
||||||
private function splitPostIds($string)
|
private function splitPostIds($string)
|
||||||
{
|
{
|
||||||
$ids = preg_split('/\D/', trim($string));
|
$ids = preg_split('/\D/', trim($string));
|
||||||
|
@ -358,10 +372,10 @@ class PostController extends AbstractController
|
||||||
$this->redirect(\Chibi\Router::linkTo(['PostController', 'listView']));
|
$this->redirect(\Chibi\Router::linkTo(['PostController', 'listView']));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function redirectToGenericView($id)
|
private function redirectToGenericView($identifier)
|
||||||
{
|
{
|
||||||
$this->redirect(\Chibi\Router::linkTo(
|
$this->redirect(\Chibi\Router::linkTo(
|
||||||
['PostController', 'genericView'],
|
['PostController', 'genericView'],
|
||||||
['id' => $id]));
|
['identifier' => $identifier]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ class CustomMarkdown extends \Michelf\MarkdownExtra
|
||||||
|
|
||||||
protected function doPosts($text)
|
protected function doPosts($text)
|
||||||
{
|
{
|
||||||
$link = \Chibi\Router::linkTo(['PostController', 'genericView'], ['id' => '_post_']);
|
$link = \Chibi\Router::linkTo(['PostController', 'genericView'], ['identifier' => '_post_']);
|
||||||
return preg_replace_callback('/(?:(?<![^\s\(\)\[\]]))@(\d+)/', function($x) use ($link)
|
return preg_replace_callback('/(?:(?<![^\s\(\)\[\]]))@(\d+)/', function($x) use ($link)
|
||||||
{
|
{
|
||||||
return $this->hashPart('<a href="' . str_replace('_post_', $x[1], $link) . '"><code>' . $x[0] . '</code></a>');
|
return $this->hashPart('<a href="' . str_replace('_post_', $x[1], $link) . '"><code>' . $x[0] . '</code></a>');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<form method="post"
|
<form method="post"
|
||||||
action="<?= \Chibi\Router::linkTo(
|
action="<?= \Chibi\Router::linkTo(
|
||||||
['PostController', 'editAction'],
|
['PostController', 'editAction'],
|
||||||
['id' => $this->context->transport->post->getId()]) ?>"
|
['identifier' => $this->context->transport->post->getId()]) ?>"
|
||||||
enctype="multipart/form-data"
|
enctype="multipart/form-data"
|
||||||
class="edit-post">
|
class="edit-post">
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ if ($masstag)
|
||||||
<?php if ($masstag): ?>
|
<?php if ($masstag): ?>
|
||||||
<a class="toggle-tag"
|
<a class="toggle-tag"
|
||||||
href="<?= \Chibi\Router::linkTo(['PostController', 'toggleTagAction'], [
|
href="<?= \Chibi\Router::linkTo(['PostController', 'toggleTagAction'], [
|
||||||
'id' => $this->context->post->getId(),
|
'identifier' => $this->context->post->getId(),
|
||||||
'tag' => $this->context->additionalInfo,
|
'tag' => $this->context->additionalInfo,
|
||||||
'enable' => in_array('tagged', $classNames) ? '0' : '1']) ?>"
|
'enable' => in_array('tagged', $classNames) ? '0' : '1']) ?>"
|
||||||
data-text-tagged="Tagged"
|
data-text-tagged="Tagged"
|
||||||
|
@ -45,7 +45,7 @@ if ($masstag)
|
||||||
<?php if (Auth::getCurrentUser()->getSettings()->hasEnabledPostTagTitles()): ?>
|
<?php if (Auth::getCurrentUser()->getSettings()->hasEnabledPostTagTitles()): ?>
|
||||||
title="<?= TextHelper::reprTags($this->context->post->getTags()) ?>"
|
title="<?= TextHelper::reprTags($this->context->post->getTags()) ?>"
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
href="<?= \Chibi\Router::linkTo(['PostController', 'genericView'], ['id' => $this->context->post->getId()]) ?>">
|
href="<?= \Chibi\Router::linkTo(['PostController', 'genericView'], ['identifier' => $this->context->post->getId()]) ?>">
|
||||||
|
|
||||||
<img
|
<img
|
||||||
class="thumb"
|
class="thumb"
|
||||||
|
|
|
@ -32,7 +32,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
<?php if ($this->context->transport->nextPostId): ?>
|
<?php if ($this->context->transport->nextPostId): ?>
|
||||||
<a href="<?= \Chibi\Router::linkTo(
|
<a href="<?= \Chibi\Router::linkTo(
|
||||||
['PostController', 'genericView'],
|
['PostController', 'genericView'],
|
||||||
['id' => $this->context->transport->nextPostId]) ?>">
|
['identifier' => $this->context->transport->nextPostId]) ?>">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a class="disabled">
|
<a class="disabled">
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -45,7 +45,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
<?php if ($this->context->transport->prevPostId): ?>
|
<?php if ($this->context->transport->prevPostId): ?>
|
||||||
<a href="<?= \Chibi\Router::linkTo(
|
<a href="<?= \Chibi\Router::linkTo(
|
||||||
['PostController', 'genericView'],
|
['PostController', 'genericView'],
|
||||||
['id' => $this->context->transport->prevPostId]) ?>">
|
['identifier' => $this->context->transport->prevPostId]) ?>">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a class="disabled">
|
<a class="disabled">
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -155,7 +155,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
{
|
{
|
||||||
return \Chibi\Router::linkTo(
|
return \Chibi\Router::linkTo(
|
||||||
['PostController', 'scoreAction'],
|
['PostController', 'scoreAction'],
|
||||||
['id' => $this->context->transport->post->getId(), 'score' => $score]);
|
['identifier' => $this->context->transport->post->getId(), 'score' => $score]);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php if (Access::check(new Privilege(
|
<?php if (Access::check(new Privilege(
|
||||||
|
@ -211,7 +211,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
<a class="add-fav icon simple-action"
|
<a class="add-fav icon simple-action"
|
||||||
href="<?= \Chibi\Router::linkTo(
|
href="<?= \Chibi\Router::linkTo(
|
||||||
['PostController', 'addFavoriteAction'],
|
['PostController', 'addFavoriteAction'],
|
||||||
['id' => $this->context->transport->post->getId()]) ?>">
|
['identifier' => $this->context->transport->post->getId()]) ?>">
|
||||||
<i class="icon-fav"></i>
|
<i class="icon-fav"></i>
|
||||||
<span>Add to favorites</span>
|
<span>Add to favorites</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -219,7 +219,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
<a class="rem-fav icon simple-action"
|
<a class="rem-fav icon simple-action"
|
||||||
href="<?= \Chibi\Router::linkTo(
|
href="<?= \Chibi\Router::linkTo(
|
||||||
['PostController', 'removeFavoriteAction'],
|
['PostController', 'removeFavoriteAction'],
|
||||||
['id' => $this->context->transport->post->getId()]) ?>">
|
['identifier' => $this->context->transport->post->getId()]) ?>">
|
||||||
<i class="icon-fav"></i>
|
<i class="icon-fav"></i>
|
||||||
<span>Remove from favorites</span>
|
<span>Remove from favorites</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -231,7 +231,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
<div class="hl-option">
|
<div class="hl-option">
|
||||||
<a class="edit-post icon" href="<?= \Chibi\Router::linkTo(
|
<a class="edit-post icon" href="<?= \Chibi\Router::linkTo(
|
||||||
['PostController', 'editView'],
|
['PostController', 'editView'],
|
||||||
['id' => $this->context->transport->post->getId()]) ?>">
|
['identifier' => $this->context->transport->post->getId()]) ?>">
|
||||||
<i class="icon-edit"></i>
|
<i class="icon-edit"></i>
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -264,7 +264,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= \Chibi\Router::linkTo(
|
<a href="<?= \Chibi\Router::linkTo(
|
||||||
['PostController', 'genericView'],
|
['PostController', 'genericView'],
|
||||||
['id' => $relatedPost->getId()]) ?>">
|
['identifier' => $relatedPost->getId()]) ?>">
|
||||||
<?= TextHelper::reprPost($relatedPost) ?>
|
<?= TextHelper::reprPost($relatedPost) ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -286,7 +286,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
'text' => 'Feature on main page',
|
'text' => 'Feature on main page',
|
||||||
'simple-action' => \Chibi\Router::linkTo(
|
'simple-action' => \Chibi\Router::linkTo(
|
||||||
['PostController', 'featureAction'],
|
['PostController', 'featureAction'],
|
||||||
['id' => $this->context->transport->post->getId()]),
|
['identifier' => $this->context->transport->post->getId()]),
|
||||||
'data-confirm-text' => 'Are you sure you want to feature this post on the main page?',
|
'data-confirm-text' => 'Are you sure you want to feature this post on the main page?',
|
||||||
'data-redirect-url' => \Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']),
|
'data-redirect-url' => \Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']),
|
||||||
];
|
];
|
||||||
|
@ -313,7 +313,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
'text' => 'Flag for moderator attention',
|
'text' => 'Flag for moderator attention',
|
||||||
'simple-action' => \Chibi\Router::linkTo(
|
'simple-action' => \Chibi\Router::linkTo(
|
||||||
['PostController', 'flagAction'],
|
['PostController', 'flagAction'],
|
||||||
['id' => $this->context->transport->post->getId()]),
|
['identifier' => $this->context->transport->post->getId()]),
|
||||||
'data-confirm-text' => 'Are you sure you want to flag this post?',
|
'data-confirm-text' => 'Are you sure you want to flag this post?',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
'text' => 'Unhide',
|
'text' => 'Unhide',
|
||||||
'simple-action' => \Chibi\Router::linkTo(
|
'simple-action' => \Chibi\Router::linkTo(
|
||||||
['PostController', 'unhideAction'],
|
['PostController', 'unhideAction'],
|
||||||
['id' => $this->context->transport->post->getId()]),
|
['identifier' => $this->context->transport->post->getId()]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -342,7 +342,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
'text' => 'Hide',
|
'text' => 'Hide',
|
||||||
'simple-action' => \Chibi\Router::linkTo(
|
'simple-action' => \Chibi\Router::linkTo(
|
||||||
['PostController', 'hideAction'],
|
['PostController', 'hideAction'],
|
||||||
['id' => $this->context->transport->post->getId()]),
|
['identifier' => $this->context->transport->post->getId()]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
'text' => 'Delete',
|
'text' => 'Delete',
|
||||||
'simple-action' => \Chibi\Router::linkTo(
|
'simple-action' => \Chibi\Router::linkTo(
|
||||||
['PostController', 'deleteAction'],
|
['PostController', 'deleteAction'],
|
||||||
['id' => $this->context->transport->post->getId()]),
|
['identifier' => $this->context->transport->post->getId()]),
|
||||||
'data-confirm-text' => 'Are you sure you want to delete this post?',
|
'data-confirm-text' => 'Are you sure you want to delete this post?',
|
||||||
'data-redirect-url' => \Chibi\Router::linkTo(['PostController', 'listView']),
|
'data-redirect-url' => \Chibi\Router::linkTo(['PostController', 'listView']),
|
||||||
];
|
];
|
||||||
|
|
|
@ -18,8 +18,9 @@ $this->assets->addStylesheet('static-main.css');
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<?php
|
<?php
|
||||||
$this->context->transport->post = $this->context->featuredPost;
|
$this->context->transport->post = $this->context->featuredPost;
|
||||||
$this->context->imageLink = \Chibi\Router::linkTo(['PostController', 'genericView'], [
|
$this->context->imageLink = \Chibi\Router::linkTo(
|
||||||
'id' => $this->context->featuredPost->getId()]);
|
['PostController', 'genericView'],
|
||||||
|
['identifier' => $this->context->featuredPost->getId()]);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php $this->renderExternal('post-file-render') ?>
|
<?php $this->renderExternal('post-file-render') ?>
|
||||||
|
|
|
@ -32,9 +32,9 @@ $postValidation =
|
||||||
|
|
||||||
\Chibi\Router::register(['PostController', 'uploadView'], 'GET', '/posts/upload', $postValidation);
|
\Chibi\Router::register(['PostController', 'uploadView'], 'GET', '/posts/upload', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'uploadAction'], 'POST', '/posts/upload', $postValidation);
|
\Chibi\Router::register(['PostController', 'uploadAction'], 'POST', '/posts/upload', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'editView'], 'GET', '/post/{id}/edit', $postValidation);
|
\Chibi\Router::register(['PostController', 'editView'], 'GET', '/post/{identifier}/edit', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'editAction'], 'POST', '/post/{id}/edit', $postValidation);
|
\Chibi\Router::register(['PostController', 'editAction'], 'POST', '/post/{identifier}/edit', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'deleteAction'], null, '/post/{id}/delete', $postValidation);
|
\Chibi\Router::register(['PostController', 'deleteAction'], null, '/post/{identifier}/delete', $postValidation);
|
||||||
|
|
||||||
\Chibi\Router::register(['PostController', 'listView'], 'GET', '/{source}', $postValidation);
|
\Chibi\Router::register(['PostController', 'listView'], 'GET', '/{source}', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'listView'], 'GET', '/{source}/{page}', $postValidation);
|
\Chibi\Router::register(['PostController', 'listView'], 'GET', '/{source}/{page}', $postValidation);
|
||||||
|
@ -49,18 +49,18 @@ $postValidation =
|
||||||
\Chibi\Router::register(['PostController', 'upvotedView'], 'GET', '/upvoted', $postValidation);
|
\Chibi\Router::register(['PostController', 'upvotedView'], 'GET', '/upvoted', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'upvotedView'], 'GET', '/upvoted/{page}', $postValidation);
|
\Chibi\Router::register(['PostController', 'upvotedView'], 'GET', '/upvoted/{page}', $postValidation);
|
||||||
|
|
||||||
\Chibi\Router::register(['PostController', 'genericView'], 'GET', '/post/{id}', $postValidation);
|
\Chibi\Router::register(['PostController', 'genericView'], 'GET', '/post/{identifier}', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'fileView'], 'GET', '/post/{name}/retrieve', $postValidation);
|
\Chibi\Router::register(['PostController', 'fileView'], 'GET', '/post/{name}/retrieve', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'thumbnailView'], 'GET', '/post/{name}/thumb', $postValidation);
|
\Chibi\Router::register(['PostController', 'thumbnailView'], 'GET', '/post/{name}/thumb', $postValidation);
|
||||||
|
|
||||||
\Chibi\Router::register(['PostController', 'toggleTagAction'], null, '/post/{id}/toggle-tag/{tag}/{enable}', $postValidation);
|
\Chibi\Router::register(['PostController', 'toggleTagAction'], null, '/post/{identifier}/toggle-tag/{tag}/{enable}', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'flagAction'], null, '/post/{id}/flag', $postValidation);
|
\Chibi\Router::register(['PostController', 'flagAction'], null, '/post/{identifier}/flag', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'hideAction'], null, '/post/{id}/hide', $postValidation);
|
\Chibi\Router::register(['PostController', 'hideAction'], null, '/post/{identifier}/hide', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'unhideAction'], null, '/post/{id}/unhide', $postValidation);
|
\Chibi\Router::register(['PostController', 'unhideAction'], null, '/post/{identifier}/unhide', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'removeFavoriteAction'], null, '/post/{id}/rem-fav', $postValidation);
|
\Chibi\Router::register(['PostController', 'removeFavoriteAction'], null, '/post/{identifier}/rem-fav', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'addFavoriteAction'], null, '/post/{id}/add-fav', $postValidation);
|
\Chibi\Router::register(['PostController', 'addFavoriteAction'], null, '/post/{identifier}/add-fav', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'scoreAction'], null, '/post/{id}/score/{score}', $postValidation);
|
\Chibi\Router::register(['PostController', 'scoreAction'], null, '/post/{identifier}/score/{score}', $postValidation);
|
||||||
\Chibi\Router::register(['PostController', 'featureAction'], null, '/post/{id}/feature', $postValidation);
|
\Chibi\Router::register(['PostController', 'featureAction'], null, '/post/{identifier}/feature', $postValidation);
|
||||||
|
|
||||||
$commentValidation =
|
$commentValidation =
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in a new issue