forked from wallabag/wallabag
Merge remote-tracking branch 'origin/master' into 2.5.0
This commit is contained in:
@ -43,6 +43,16 @@ class ConfigController extends Controller
|
||||
$configForm->handleRequest($request);
|
||||
|
||||
if ($configForm->isSubmitted() && $configForm->isValid()) {
|
||||
// force theme to material to avoid using baggy
|
||||
if ('baggy' === $config->getTheme()) {
|
||||
$config->setTheme('material');
|
||||
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
'Baggy is deprecated, forced to Material theme.'
|
||||
);
|
||||
}
|
||||
|
||||
$em->persist($config);
|
||||
$em->flush();
|
||||
|
||||
|
||||
@ -8,7 +8,9 @@ use Pagerfanta\Exception\OutOfRangeCurrentPageException;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
@ -88,8 +90,19 @@ class FeedController extends Controller
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function showTagsFeedAction(User $user, Tag $tag, $page)
|
||||
public function showTagsFeedAction(Request $request, User $user, Tag $tag, $page)
|
||||
{
|
||||
$sort = $request->query->get('sort', 'created');
|
||||
|
||||
$sorts = [
|
||||
'created' => 'createdAt',
|
||||
'updated' => 'updatedAt',
|
||||
];
|
||||
|
||||
if (!isset($sorts[$sort])) {
|
||||
throw new BadRequestHttpException(sprintf('Sort "%s" is not available.', $sort));
|
||||
}
|
||||
|
||||
$url = $this->generateUrl(
|
||||
'tag_feed',
|
||||
[
|
||||
@ -102,7 +115,8 @@ class FeedController extends Controller
|
||||
|
||||
$entriesByTag = $this->get('wallabag_core.entry_repository')->findAllByTagId(
|
||||
$user->getId(),
|
||||
$tag->getId()
|
||||
$tag->getId(),
|
||||
$sorts[$sort]
|
||||
);
|
||||
|
||||
$pagerAdapter = new ArrayAdapter($entriesByTag);
|
||||
@ -137,11 +151,28 @@ class FeedController extends Controller
|
||||
'domainName' => $this->getParameter('domain_name'),
|
||||
'version' => $this->getParameter('wallabag_core.version'),
|
||||
'tag' => $tag->getSlug(),
|
||||
'updated' => $this->prepareFeedUpdatedDate($entries, $sort),
|
||||
],
|
||||
new Response('', 200, ['Content-Type' => 'application/atom+xml'])
|
||||
);
|
||||
}
|
||||
|
||||
private function prepareFeedUpdatedDate(Pagerfanta $entries, $sort = 'created')
|
||||
{
|
||||
$currentPageResults = $entries->getCurrentPageResults();
|
||||
|
||||
if (isset($currentPageResults[0])) {
|
||||
$firstEntry = $currentPageResults[0];
|
||||
if ('created' === $sort) {
|
||||
return $firstEntry->getCreatedAt();
|
||||
}
|
||||
|
||||
return $firstEntry->getUpdatedAt();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global method to retrieve entries depending on the given type
|
||||
* It returns the response to be send.
|
||||
@ -202,6 +233,7 @@ class FeedController extends Controller
|
||||
'user' => $user->getUsername(),
|
||||
'domainName' => $this->getParameter('domain_name'),
|
||||
'version' => $this->getParameter('wallabag_core.version'),
|
||||
'updated' => $this->prepareFeedUpdatedDate($entries),
|
||||
],
|
||||
new Response('', 200, ['Content-Type' => 'application/atom+xml'])
|
||||
);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Pagerfanta\Adapter\ArrayAdapter;
|
||||
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
@ -190,4 +191,35 @@ class TagController extends Controller
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag search results with the current search term.
|
||||
*
|
||||
* @Route("/tag/search/{filter}", name="tag_this_search")
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function tagThisSearchAction($filter, Request $request)
|
||||
{
|
||||
$currentRoute = $request->query->has('currentRoute') ? $request->query->get('currentRoute') : '';
|
||||
|
||||
/** @var QueryBuilder $qb */
|
||||
$qb = $this->get('wallabag_core.entry_repository')->getBuilderForSearchByUser($this->getUser()->getId(), $filter, $currentRoute);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entries = $qb->getQuery()->getResult();
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry(
|
||||
$entry,
|
||||
$filter
|
||||
);
|
||||
|
||||
$em->persist($entry);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user