From b84a80559a1167b5500fbc5eb4965d3b08b371ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 23 Jan 2015 14:58:17 +0100 Subject: some parameters, new entry form, etc. --- src/WallabagBundle/Controller/EntryController.php | 42 +++++++++++++++++++++ src/WallabagBundle/Entity/Entries.php | 2 + .../Repository/EntriesRepository.php | 42 +++++++++++++++++---- .../Resources/views/Entry/new.html.twig | 11 ++++++ .../Resources/views/Static/about.html.twig | 43 +++------------------- src/WallabagBundle/Resources/views/_menu.html.twig | 4 +- 6 files changed, 95 insertions(+), 49 deletions(-) create mode 100644 src/WallabagBundle/Resources/views/Entry/new.html.twig (limited to 'src') diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php index fbbb76aa..dc1876fa 100644 --- a/src/WallabagBundle/Controller/EntryController.php +++ b/src/WallabagBundle/Controller/EntryController.php @@ -7,9 +7,51 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use WallabagBundle\Repository; use WallabagBundle\Entity\Entries; +use Wallabag\Wallabag\Tools; +use Wallabag\Wallabag\Url; class EntryController extends Controller { + + /** + * @param Request $request + * @Route("/new", name="new_entry") + * @return \Symfony\Component\HttpFoundation\Response + */ + public function addEntryAction(Request $request) + { + $entry = new Entries(); + $entry->setUserId(1); + + $form = $this->createFormBuilder($entry) + ->add('url', 'url') + ->add('save', 'submit') + ->getForm(); + + $form->handleRequest($request); + + if ($form->isValid()) { + + $content = Tools::getPageContent(new Url($entry->getUrl())); + var_dump($content);die; + + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($entry); + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Entry saved' + ); + + return $this->redirect($this->generateUrl('homepage')); + } + + return $this->render('WallabagBundle:Entry:new.html.twig', array( + 'form' => $form->createView(), + )); + } + /** * Shows unread entries for current user * diff --git a/src/WallabagBundle/Entity/Entries.php b/src/WallabagBundle/Entity/Entries.php index b364e0c3..5849a216 100644 --- a/src/WallabagBundle/Entity/Entries.php +++ b/src/WallabagBundle/Entity/Entries.php @@ -3,6 +3,7 @@ namespace WallabagBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Entries @@ -31,6 +32,7 @@ class Entries /** * @var string * + * @Assert\NotBlank() * @ORM\Column(name="url", type="text", nullable=true) */ private $url; diff --git a/src/WallabagBundle/Repository/EntriesRepository.php b/src/WallabagBundle/Repository/EntriesRepository.php index c4428a1d..3eb1733d 100644 --- a/src/WallabagBundle/Repository/EntriesRepository.php +++ b/src/WallabagBundle/Repository/EntriesRepository.php @@ -8,6 +8,14 @@ use Doctrine\ORM\Tools\Pagination\Paginator; class EntriesRepository extends EntityRepository { + /** + * Retrieves unread entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findUnreadByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -18,11 +26,19 @@ class EntriesRepository extends EntityRepository ->andWhere('e.userId =:userId')->setParameter('userId', $userId) ->getQuery(); - $pag = new Paginator($qb); + $paginator = new Paginator($qb); - return $pag; + return $paginator; } + /** + * Retrieves read entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findArchiveByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -31,12 +47,21 @@ class EntriesRepository extends EntityRepository ->setMaxResults($maxResults) ->where('e.isRead = 1') ->andWhere('e.userId =:userId')->setParameter('userId', $userId) - ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getQuery(); + + $paginator = new Paginator($qb); - return $qb; + return $paginator; } + /** + * Retrieves starred entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findStarredByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -45,9 +70,10 @@ class EntriesRepository extends EntityRepository ->setMaxResults($maxResults) ->where('e.isFav = 1') ->andWhere('e.userId =:userId')->setParameter('userId', $userId) - ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getQuery(); + + $paginator = new Paginator($qb); - return $qb; + return $paginator; } } diff --git a/src/WallabagBundle/Resources/views/Entry/new.html.twig b/src/WallabagBundle/Resources/views/Entry/new.html.twig new file mode 100644 index 00000000..78da791f --- /dev/null +++ b/src/WallabagBundle/Resources/views/Entry/new.html.twig @@ -0,0 +1,11 @@ +{% extends "WallabagBundle::layout.html.twig" %} + +{% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %} + +{% block menu %} + {% include "WallabagBundle::_menu.html.twig" %} +{% endblock %} + +{% block content %} + {{ form(form) }} +{% endblock %} \ No newline at end of file diff --git a/src/WallabagBundle/Resources/views/Static/about.html.twig b/src/WallabagBundle/Resources/views/Static/about.html.twig index 1a3c927e..752526e1 100755 --- a/src/WallabagBundle/Resources/views/Static/about.html.twig +++ b/src/WallabagBundle/Resources/views/Static/about.html.twig @@ -14,7 +14,7 @@
{% trans %}Main developer{% endtrans %}
Nicolas Lœuillet{% trans %}website{% endtrans %}
-
{% trans %}Contributors:{% endtrans %}
+
{% trans %}Contributors ♥:{% endtrans %}
{% trans %}on Github{% endtrans %}
{% trans %}Bug reports{% endtrans %}
@@ -24,7 +24,7 @@
MIT
{% trans %}Version{% endtrans %}
-
+
{{ version }}

{% trans %}wallabag is a read-it-later application: you can save a web page by keeping only content. Elements like ads or menus are deleted.{% endtrans %}

@@ -33,7 +33,7 @@
{% trans %}Documentation{% endtrans %}
-
Offline documentation and online documentation (up to date)
+
Online documentation
{% trans %}Support{% endtrans %}
http://support.wallabag.org/
@@ -44,41 +44,8 @@

{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}

-
{% trans %}via Paypal{% endtrans %}
+
{% trans %}via Paypal{% endtrans %}
-
{% trans %}via Flattr{% endtrans %}
+
{% trans %}via Flattr{% endtrans %}
- -

{% trans %}Credits{% endtrans %}

-
-
PHP Readability
-
https://bitbucket.org/fivefilters/php-readability
- -
Full Text RSS
-
http://code.fivefilters.org/full-text-rss/src
- -
logo by Maylis Agniel
-
https://github.com/wallabag/logo
- -
icons
-
http://icomoon.io
- -
PHP Simple HTML DOM Parser
-
http://simplehtmldom.sourceforge.net/
- -
Session
-
https://github.com/tontof/kriss_feed/blob/master/src/class/Session.php
- -
Twig
-
http://twig.sensiolabs.org
- -
Flash messages
-
https://github.com/plasticbrain/PHP-Flash-Messages
- -
Pagination
-
https://github.com/daveismyname/pagination
- -
PHPePub
-
https://github.com/Grandt/PHPePub/
-
{% endblock %} diff --git a/src/WallabagBundle/Resources/views/_menu.html.twig b/src/WallabagBundle/Resources/views/_menu.html.twig index 4c6a0a1b..419a676b 100644 --- a/src/WallabagBundle/Resources/views/_menu.html.twig +++ b/src/WallabagBundle/Resources/views/_menu.html.twig @@ -4,9 +4,7 @@
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • {% trans %}tags{% endtrans %}
  • -
  • {% trans %}save a link{% endtrans %} - {% include "WallabagBundle::_save_form.html.twig" %} -
  • +
  • {% trans %}save a link{% endtrans %}
  • {% trans %}search{% endtrans %} {% include "WallabagBundle::_search_form.html.twig" %}
  • -- cgit v1.2.3