Merge pull request #1037 from j0k3r/refactor-cs

CS
This commit is contained in:
Nicolas Lœuillet 2015-01-31 21:24:20 +01:00
commit 4cfbd5d893
47 changed files with 153 additions and 183 deletions

View file

@ -8,14 +8,12 @@ use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Repository; use Wallabag\CoreBundle\Repository;
use Wallabag\CoreBundle\Entity\Entries; use Wallabag\CoreBundle\Entity\Entries;
use Wallabag\CoreBundle\Service\Extractor; use Wallabag\CoreBundle\Service\Extractor;
use Wallabag\CoreBundle\Helper\Tools;
use Wallabag\CoreBundle\Helper\Url; use Wallabag\CoreBundle\Helper\Url;
class EntryController extends Controller class EntryController extends Controller
{ {
/** /**
* @param Request $request * @param Request $request
* @Route("/new", name="new_entry") * @Route("/new", name="new_entry")
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
@ -32,7 +30,6 @@ class EntryController extends Controller
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isValid()) { if ($form->isValid()) {
$content = Extractor::extract($entry->getUrl()); $content = Extractor::extract($entry->getUrl());
$entry->setTitle($content->getTitle()); $entry->setTitle($content->getTitle());
@ -115,7 +112,7 @@ class EntryController extends Controller
/** /**
* Shows entry content * Shows entry content
* *
* @param Entries $entry * @param Entries $entry
* @Route("/view/{id}", requirements={"id" = "\d+"}, name="view") * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
@ -130,8 +127,8 @@ class EntryController extends Controller
/** /**
* Changes read status for an entry * Changes read status for an entry
* *
* @param Request $request * @param Request $request
* @param Entries $entry * @param Entries $entry
* @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry") * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
* @return \Symfony\Component\HttpFoundation\RedirectResponse * @return \Symfony\Component\HttpFoundation\RedirectResponse
*/ */
@ -151,8 +148,8 @@ class EntryController extends Controller
/** /**
* Changes favorite status for an entry * Changes favorite status for an entry
* *
* @param Request $request * @param Request $request
* @param Entries $entry * @param Entries $entry
* @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry") * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
* @return \Symfony\Component\HttpFoundation\RedirectResponse * @return \Symfony\Component\HttpFoundation\RedirectResponse
*/ */
@ -172,8 +169,8 @@ class EntryController extends Controller
/** /**
* Deletes entry * Deletes entry
* *
* @param Request $request * @param Request $request
* @param Entries $entry * @param Entries $entry
* @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry") * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
* @return \Symfony\Component\HttpFoundation\RedirectResponse * @return \Symfony\Component\HttpFoundation\RedirectResponse
*/ */

View file

@ -18,10 +18,11 @@ class SecurityController extends Controller
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR); $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR); $session->remove(SecurityContext::AUTHENTICATION_ERROR);
} }
return $this->render('WallabagCoreBundle:Security:login.html.twig', array( return $this->render('WallabagCoreBundle:Security:login.html.twig', array(
// last username entered by the user // last username entered by the user
'last_username' => $session->get(SecurityContext::LAST_USERNAME), 'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error, 'error' => $error,
)); ));
} }
} }

View file

@ -3,7 +3,6 @@
namespace Wallabag\CoreBundle\Controller; namespace Wallabag\CoreBundle\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use FOS\RestBundle\Controller\Annotations\View;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\Entries; use Wallabag\CoreBundle\Entity\Entries;
@ -12,7 +11,6 @@ use Wallabag\CoreBundle\Service\Extractor;
class WallabagRestController extends Controller class WallabagRestController extends Controller
{ {
/** /**
* Retrieve all entries. It could be filtered by many options. * Retrieve all entries. It could be filtered by many options.
* *
@ -44,14 +42,13 @@ class WallabagRestController extends Controller
$entries = $this $entries = $this
->getDoctrine() ->getDoctrine()
->getRepository('WallabagCoreBundle:Entries') ->getRepository('WallabagCoreBundle:Entries')
->findEntries(1, (int)$isArchived, (int)$isStarred, (int)$isDeleted, $sort, $order); ->findEntries(1, (int) $isArchived, (int) $isStarred, (int) $isDeleted, $sort, $order);
if(!is_array($entries)) { if (!is_array($entries)) {
throw $this->createNotFoundException(); throw $this->createNotFoundException();
} }
return $entries; return $entries;
} }
/** /**
@ -119,7 +116,6 @@ class WallabagRestController extends Controller
*/ */
public function patchEntriesAction(Entries $entry) public function patchEntriesAction(Entries $entry)
{ {
} }
/** /**
@ -133,10 +129,8 @@ class WallabagRestController extends Controller
*/ */
public function deleteEntriesAction(Entries $entry) public function deleteEntriesAction(Entries $entry)
{ {
} }
/** /**
* Retrieve all tags for an entry * Retrieve all tags for an entry
* *
@ -146,8 +140,8 @@ class WallabagRestController extends Controller
* } * }
* ) * )
*/ */
public function getEntriesTagsAction(Entries $entry) { public function getEntriesTagsAction(Entries $entry)
{
} }
/** /**
@ -162,8 +156,8 @@ class WallabagRestController extends Controller
* } * }
* ) * )
*/ */
public function postEntriesTagsAction(Entries $entry) { public function postEntriesTagsAction(Entries $entry)
{
} }
/** /**
@ -178,7 +172,6 @@ class WallabagRestController extends Controller
*/ */
public function deleteEntriesTagsAction(Entries $entry, Tags $tag) public function deleteEntriesTagsAction(Entries $entry, Tags $tag)
{ {
} }
/** /**
@ -187,8 +180,8 @@ class WallabagRestController extends Controller
* @ApiDoc( * @ApiDoc(
* ) * )
*/ */
public function getTagsAction() { public function getTagsAction()
{
} }
/** /**
@ -200,8 +193,8 @@ class WallabagRestController extends Controller
* } * }
* ) * )
*/ */
public function getTagAction(Tags $tag) { public function getTagAction(Tags $tag)
{
} }
/** /**
@ -215,6 +208,5 @@ class WallabagRestController extends Controller
*/ */
public function deleteTagAction(Tags $tag) public function deleteTagAction(Tags $tag)
{ {
} }
} }

View file

@ -37,4 +37,4 @@ class WsseFactory implements SecurityFactoryInterface
public function addConfiguration(NodeDefinition $node) public function addConfiguration(NodeDefinition $node)
{ {
} }
} }

View file

@ -35,12 +35,10 @@ class Config
*/ */
private $value; private $value;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
@ -50,7 +48,7 @@ class Config
/** /**
* Set name * Set name
* *
* @param string $name * @param string $name
* @return Config * @return Config
*/ */
public function setName($name) public function setName($name)
@ -63,7 +61,7 @@ class Config
/** /**
* Get name * Get name
* *
* @return string * @return string
*/ */
public function getName() public function getName()
{ {
@ -73,7 +71,7 @@ class Config
/** /**
* Set value * Set value
* *
* @param string $value * @param string $value
* @return Config * @return Config
*/ */
public function setValue($value) public function setValue($value)
@ -86,7 +84,7 @@ class Config
/** /**
* Get value * Get value
* *
* @return string * @return string
*/ */
public function getValue() public function getValue()
{ {

View file

@ -66,12 +66,10 @@ class Entries
*/ */
private $userId; private $userId;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
@ -81,7 +79,7 @@ class Entries
/** /**
* Set title * Set title
* *
* @param string $title * @param string $title
* @return Entries * @return Entries
*/ */
public function setTitle($title) public function setTitle($title)
@ -94,7 +92,7 @@ class Entries
/** /**
* Get title * Get title
* *
* @return string * @return string
*/ */
public function getTitle() public function getTitle()
{ {
@ -104,7 +102,7 @@ class Entries
/** /**
* Set url * Set url
* *
* @param string $url * @param string $url
* @return Entries * @return Entries
*/ */
public function setUrl($url) public function setUrl($url)
@ -117,7 +115,7 @@ class Entries
/** /**
* Get url * Get url
* *
* @return string * @return string
*/ */
public function getUrl() public function getUrl()
{ {
@ -127,7 +125,7 @@ class Entries
/** /**
* Set isRead * Set isRead
* *
* @param string $isRead * @param string $isRead
* @return Entries * @return Entries
*/ */
public function setIsRead($isRead) public function setIsRead($isRead)
@ -140,7 +138,7 @@ class Entries
/** /**
* Get isRead * Get isRead
* *
* @return string * @return string
*/ */
public function getIsRead() public function getIsRead()
{ {
@ -150,13 +148,14 @@ class Entries
public function toggleArchive() public function toggleArchive()
{ {
$this->isRead = $this->getIsRead() ^ 1; $this->isRead = $this->getIsRead() ^ 1;
return $this; return $this;
} }
/** /**
* Set isFav * Set isFav
* *
* @param string $isFav * @param string $isFav
* @return Entries * @return Entries
*/ */
public function setIsFav($isFav) public function setIsFav($isFav)
@ -169,7 +168,7 @@ class Entries
/** /**
* Get isFav * Get isFav
* *
* @return string * @return string
*/ */
public function getIsFav() public function getIsFav()
{ {
@ -186,7 +185,7 @@ class Entries
/** /**
* Set content * Set content
* *
* @param string $content * @param string $content
* @return Entries * @return Entries
*/ */
public function setContent($content) public function setContent($content)
@ -199,7 +198,7 @@ class Entries
/** /**
* Get content * Get content
* *
* @return string * @return string
*/ */
public function getContent() public function getContent()
{ {
@ -209,7 +208,7 @@ class Entries
/** /**
* Set userId * Set userId
* *
* @param string $userId * @param string $userId
* @return Entries * @return Entries
*/ */
public function setUserId($userId) public function setUserId($userId)
@ -222,7 +221,7 @@ class Entries
/** /**
* Get userId * Get userId
* *
* @return string * @return string
*/ */
public function getUserId() public function getUserId()
{ {

View file

@ -28,12 +28,10 @@ class Tags
*/ */
private $value; private $value;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
@ -43,7 +41,7 @@ class Tags
/** /**
* Set value * Set value
* *
* @param string $value * @param string $value
* @return Tags * @return Tags
*/ */
public function setValue($value) public function setValue($value)
@ -56,7 +54,7 @@ class Tags
/** /**
* Get value * Get value
* *
* @return string * @return string
*/ */
public function getValue() public function getValue()
{ {

View file

@ -35,12 +35,10 @@ class TagsEntries
*/ */
private $tagId; private $tagId;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
@ -50,7 +48,7 @@ class TagsEntries
/** /**
* Set entryId * Set entryId
* *
* @param integer $entryId * @param integer $entryId
* @return TagsEntries * @return TagsEntries
*/ */
public function setEntryId($entryId) public function setEntryId($entryId)
@ -63,7 +61,7 @@ class TagsEntries
/** /**
* Get entryId * Get entryId
* *
* @return integer * @return integer
*/ */
public function getEntryId() public function getEntryId()
{ {
@ -73,7 +71,7 @@ class TagsEntries
/** /**
* Set tagId * Set tagId
* *
* @param integer $tagId * @param integer $tagId
* @return TagsEntries * @return TagsEntries
*/ */
public function setTagId($tagId) public function setTagId($tagId)
@ -86,7 +84,7 @@ class TagsEntries
/** /**
* Get tagId * Get tagId
* *
* @return integer * @return integer
*/ */
public function getTagId() public function getTagId()
{ {

View file

@ -4,7 +4,6 @@ namespace Wallabag\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface; use Symfony\Component\Security\Core\User\AdvancedUserInterface;
/** /**
@ -71,7 +70,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
@ -81,7 +80,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Set username * Set username
* *
* @param string $username * @param string $username
* @return Users * @return Users
*/ */
public function setUsername($username) public function setUsername($username)
@ -94,7 +93,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Get username * Get username
* *
* @return string * @return string
*/ */
public function getUsername() public function getUsername()
{ {
@ -120,7 +119,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Set password * Set password
* *
* @param string $password * @param string $password
* @return Users * @return Users
*/ */
public function setPassword($password) public function setPassword($password)
@ -133,7 +132,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Get password * Get password
* *
* @return string * @return string
*/ */
public function getPassword() public function getPassword()
{ {
@ -143,7 +142,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Set name * Set name
* *
* @param string $name * @param string $name
* @return Users * @return Users
*/ */
public function setName($name) public function setName($name)
@ -156,7 +155,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Get name * Get name
* *
* @return string * @return string
*/ */
public function getName() public function getName()
{ {
@ -166,7 +165,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Set email * Set email
* *
* @param string $email * @param string $email
* @return Users * @return Users
*/ */
public function setEmail($email) public function setEmail($email)
@ -179,7 +178,7 @@ class Users implements AdvancedUserInterface, \Serializable
/** /**
* Get email * Get email
* *
* @return string * @return string
*/ */
public function getEmail() public function getEmail()
{ {
@ -208,7 +207,7 @@ class Users implements AdvancedUserInterface, \Serializable
*/ */
public function unserialize($serialized) public function unserialize($serialized)
{ {
list ( list(
$this->id, $this->id,
) = unserialize($serialized); ) = unserialize($serialized);
} }

View file

@ -42,12 +42,10 @@ class UsersConfig
*/ */
private $value; private $value;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
@ -57,7 +55,7 @@ class UsersConfig
/** /**
* Set userId * Set userId
* *
* @param string $userId * @param string $userId
* @return UsersConfig * @return UsersConfig
*/ */
public function setUserId($userId) public function setUserId($userId)
@ -70,7 +68,7 @@ class UsersConfig
/** /**
* Get userId * Get userId
* *
* @return string * @return string
*/ */
public function getUserId() public function getUserId()
{ {
@ -80,7 +78,7 @@ class UsersConfig
/** /**
* Set name * Set name
* *
* @param string $name * @param string $name
* @return UsersConfig * @return UsersConfig
*/ */
public function setName($name) public function setName($name)
@ -93,7 +91,7 @@ class UsersConfig
/** /**
* Get name * Get name
* *
* @return string * @return string
*/ */
public function getName() public function getName()
{ {
@ -103,7 +101,7 @@ class UsersConfig
/** /**
* Set value * Set value
* *
* @param string $value * @param string $value
* @return UsersConfig * @return UsersConfig
*/ */
public function setValue($value) public function setValue($value)
@ -116,7 +114,7 @@ class UsersConfig
/** /**
* Get value * Get value
* *
* @return string * @return string
*/ */
public function getValue() public function getValue()
{ {

View file

@ -8,8 +8,8 @@ class Content
private $body; private $body;
public function __constructor() { public function __constructor()
{
} }
public function getTitle() public function getTitle()
@ -31,4 +31,4 @@ class Content
{ {
$this->body = $body; $this->body = $body;
} }
} }

View file

@ -2,9 +2,6 @@
namespace Wallabag\CoreBundle\Helper; namespace Wallabag\CoreBundle\Helper;
class Entries
class Entries { {
}
}

View file

@ -2,9 +2,6 @@
namespace Wallabag\CoreBundle\Helper; namespace Wallabag\CoreBundle\Helper;
use \RecursiveIteratorIterator;
use \RecursiveDirectoryIterator;
final class Tools final class Tools
{ {
/** /**
@ -18,7 +15,7 @@ final class Tools
$timeout = 15; $timeout = 15;
$useragent = "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"; $useragent = "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0";
if (in_array ('curl', get_loaded_extensions())) { if (in_array('curl', get_loaded_extensions())) {
# Fetch feed from URL # Fetch feed from URL
$curl = curl_init(); $curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_URL, $url);
@ -30,8 +27,8 @@ final class Tools
curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_HEADER, false);
# for ssl, do not verified certificate # for ssl, do not verified certificate
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE ); curl_setopt($curl, CURLOPT_AUTOREFERER, true);
# FeedBurner requires a proper USER-AGENT... # FeedBurner requires a proper USER-AGENT...
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true); curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
@ -48,13 +45,13 @@ final class Tools
array( array(
'http' => array( 'http' => array(
'timeout' => $timeout, 'timeout' => $timeout,
'header' => "User-Agent: " . $useragent, 'header' => "User-Agent: ".$useragent,
'follow_location' => true 'follow_location' => true,
), ),
'ssl' => array( 'ssl' => array(
'verify_peer' => false, 'verify_peer' => false,
'allow_self_signed' => true 'allow_self_signed' => true,
) ),
) )
); );
@ -62,13 +59,12 @@ final class Tools
$data = @file_get_contents($url, false, $context, -1, 4000000); $data = @file_get_contents($url, false, $context, -1, 4000000);
if (isset($http_response_header) and isset($http_response_header[0])) { if (isset($http_response_header) and isset($http_response_header[0])) {
$httpcodeOK = isset($http_response_header) and isset($http_response_header[0]) and ((strpos($http_response_header[0], '200 OK') !== FALSE) or (strpos($http_response_header[0], '301 Moved Permanently') !== FALSE)); $httpcodeOK = isset($http_response_header) and isset($http_response_header[0]) and ((strpos($http_response_header[0], '200 OK') !== false) or (strpos($http_response_header[0], '301 Moved Permanently') !== false));
} }
} }
# if response is not empty and response is OK # if response is not empty and response is OK
if (isset($data) and isset($httpcodeOK) and $httpcodeOK) { if (isset($data) and isset($httpcodeOK) and $httpcodeOK) {
# take charset of page and get it # take charset of page and get it
preg_match('#<meta .*charset=.*>#Usi', $data, $meta); preg_match('#<meta .*charset=.*>#Usi', $data, $meta);
@ -77,19 +73,20 @@ final class Tools
preg_match('#charset="?(.*)"#si', $meta[0], $encoding); preg_match('#charset="?(.*)"#si', $meta[0], $encoding);
# if charset is found set it otherwise, set it to utf-8 # if charset is found set it otherwise, set it to utf-8
$html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8'; $html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8';
if (empty($encoding[1])) $encoding[1] = 'utf-8'; if (empty($encoding[1])) {
$encoding[1] = 'utf-8';
}
} else { } else {
$html_charset = 'utf-8'; $html_charset = 'utf-8';
$encoding[1] = ''; $encoding[1] = '';
} }
# replace charset of url to charset of page # replace charset of url to charset of page
$data = str_replace('charset=' . $encoding[1], 'charset=' . $html_charset, $data); $data = str_replace('charset='.$encoding[1], 'charset='.$html_charset, $data);
return $data; return $data;
} } else {
else { return false;
return FALSE;
} }
} }
@ -101,7 +98,7 @@ final class Tools
*/ */
public static function encodeString($string) public static function encodeString($string)
{ {
return sha1($string . SALT); return sha1($string.SALT);
} }
public static function generateToken() public static function generateToken()
@ -113,12 +110,10 @@ final class Tools
} else { } else {
$token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
} }
} } else {
else {
$token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
} }
return str_replace('+', '', $token); return str_replace('+', '', $token);
} }
} }

View file

@ -6,20 +6,23 @@ class Url
{ {
public $url; public $url;
function __construct($url) public function __construct($url)
{ {
$this->url = base64_decode($url); $this->url = base64_decode($url);
} }
public function getUrl() { public function getUrl()
{
return $this->url; return $this->url;
} }
public function setUrl($url) { public function setUrl($url)
{
$this->url = $url; $this->url = $url;
} }
public function isCorrect() { public function isCorrect()
return filter_var($this->url, FILTER_VALIDATE_URL) !== FALSE; {
return filter_var($this->url, FILTER_VALIDATE_URL) !== false;
} }
} }

View file

@ -6,7 +6,6 @@ use Doctrine\ORM\Query;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\ORM\Tools\Pagination\Paginator;
use Wallabag\CoreBundle\Entity\Entries; use Wallabag\CoreBundle\Entity\Entries;
use Wallabag\CoreBundle\Service\Extractor;
class EntriesRepository extends EntityRepository class EntriesRepository extends EntityRepository
{ {
@ -15,7 +14,7 @@ class EntriesRepository extends EntityRepository
* *
* @param $userId * @param $userId
* @param $firstResult * @param $firstResult
* @param int $maxResults * @param int $maxResults
* @return Paginator * @return Paginator
*/ */
public function findUnreadByUser($userId, $firstResult, $maxResults = 12) public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
@ -38,7 +37,7 @@ class EntriesRepository extends EntityRepository
* *
* @param $userId * @param $userId
* @param $firstResult * @param $firstResult
* @param int $maxResults * @param int $maxResults
* @return Paginator * @return Paginator
*/ */
public function findArchiveByUser($userId, $firstResult, $maxResults = 12) public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
@ -61,7 +60,7 @@ class EntriesRepository extends EntityRepository
* *
* @param $userId * @param $userId
* @param $firstResult * @param $firstResult
* @param int $maxResults * @param int $maxResults
* @return Paginator * @return Paginator
*/ */
public function findStarredByUser($userId, $firstResult, $maxResults = 12) public function findStarredByUser($userId, $firstResult, $maxResults = 12)

View file

@ -1,3 +1,3 @@
_wllbg: _wllbg:
resource: "@WallabagCoreBundle/Controller/EntryController.php" resource: "@WallabagCoreBundle/Controller/EntryController.php"
type: annotation type: annotation

View file

@ -1,4 +1,4 @@
entries: entries:
type: rest type: rest
resource: "WallabagCoreBundle:WallabagRest" resource: "WallabagCoreBundle:WallabagRest"
name_prefix: api_ name_prefix: api_

View file

@ -25,5 +25,3 @@
</services> </services>
</container> </container>

View file

@ -101,4 +101,4 @@
}); });
}); });
</script> </script>
{% endblock %} {% endblock %}

View file

@ -8,4 +8,4 @@
{% block content %} {% block content %}
{{ form(form) }} {{ form(form) }}
{% endblock %} {% endblock %}

View file

@ -30,11 +30,11 @@
<p>{% 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 %}</p> <p>{% 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 %}</p>
<h2>{% trans %}Getting help{% endtrans %}</h2> <h2>{% trans %}Getting help{% endtrans %}</h2>
<dl> <dl>
<dt>{% trans %}Documentation{% endtrans %}</dt> <dt>{% trans %}Documentation{% endtrans %}</dt>
<dd><a href="https://doc.wallabag.org/">Online documentation</a></dd> <dd><a href="https://doc.wallabag.org/">Online documentation</a></dd>
<dt>{% trans %}Support{% endtrans %}</dt> <dt>{% trans %}Support{% endtrans %}</dt>
<dd><a href="http://support.wallabag.org/">http://support.wallabag.org/</a></dd> <dd><a href="http://support.wallabag.org/">http://support.wallabag.org/</a></dd>
</dl> </dl>

View file

@ -1,3 +1,3 @@
<script type="text/javascript"> <script type="text/javascript">
top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>" top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>"
</script> </script>

View file

@ -1,3 +1,3 @@
<footer class="w600p center mt3 mb3 smaller txtright"> <footer class="w600p center mt3 mb3 smaller txtright">
<p>{% trans %}powered by{% endtrans %} <a href="http://wallabag.org">wallabag</a></p> <p>{% trans %}powered by{% endtrans %} <a href="http://wallabag.org">wallabag</a></p>
</footer> </footer>

View file

@ -37,4 +37,3 @@
<script src="{{ asset('themes/_global/js/saveLink.js') }}"></script> <script src="{{ asset('themes/_global/js/saveLink.js') }}"></script>
<script src="{{ asset('themes/_global/js/popupForm.js') }}"></script> <script src="{{ asset('themes/_global/js/popupForm.js') }}"></script>
<script src="{{ asset('themes/baggy/js/closeMessage.js') }}"></script> <script src="{{ asset('themes/baggy/js/closeMessage.js') }}"></script>

View file

@ -12,4 +12,3 @@
<li><a href={{ path('about') }}>{% trans %}about{% endtrans %}</a></li> <li><a href={{ path('about') }}>{% trans %}about{% endtrans %}</a></li>
<li><a class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li> <li><a class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
</ul> </ul>

View file

@ -160,7 +160,7 @@
</div> </div>
</fieldset> </fieldset>
</form> </form>
<h2>{% trans "Delete account" %}</h2> <h2>{% trans "Delete account" %}</h2>
{% if not only_user %}<form method="post" action="?deluser"> {% if not only_user %}<form method="post" action="?deluser">
<p>{% trans "You can delete your account by entering your password and validating." %}<br /><b>{% trans "Be careful, data will be erased forever (that is a very long time)." %}</b></p> <p>{% trans "You can delete your account by entering your password and validating." %}<br /><b>{% trans "Be careful, data will be erased forever (that is a very long time)." %}</b></p>

View file

@ -28,4 +28,4 @@
</div> </div>
{% include '_footer.twig' %} {% include '_footer.twig' %}
</body> </body>
</html> </html>

View file

@ -17,7 +17,7 @@
<input class="col" type="password" id="password" name="password" placeholder="{% trans "Password" %}" tabindex="2" {% if constant('MODE_DEMO') == 1 %}value="poche"{% endif %} /> <input class="col" type="password" id="password" name="password" placeholder="{% trans "Password" %}" tabindex="2" {% if constant('MODE_DEMO') == 1 %}value="poche"{% endif %} />
</div> </div>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<input type="checkbox" id="longlastingsession" name="longlastingsession" tabindex="3" /> <label for="longlastingsession">{% trans "Stay signed in" %}</label><br /> <input type="checkbox" id="longlastingsession" name="longlastingsession" tabindex="3" /> <label for="longlastingsession">{% trans "Stay signed in" %}</label><br />
<small class="inbl">{% trans "(Do not check on public computers)" %}</small> <small class="inbl">{% trans "(Do not check on public computers)" %}</small>

View file

@ -1,3 +1,3 @@
<script type="text/javascript"> <script type="text/javascript">
top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="{{poche_url}}tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>" top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="{{poche_url}}tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>"
</script> </script>

View file

@ -1,4 +1,4 @@
<footer class="w600p center mt3 mb3 smaller txtright"> <footer class="w600p center mt3 mb3 smaller txtright">
<p>{% trans "powered by" %} <a href="http://wallabag.org">wallabag</a></p> <p>{% trans "powered by" %} <a href="http://wallabag.org">wallabag</a></p>
{% if constant('DEBUG_POCHE') == 1 %}<p><strong>{% trans "debug mode is on so cache is off." %} {% trans "your wallabag version:" %}{{constant('WALLABAG')}}. {% trans "storage:" %} {{constant('STORAGE')}}</strong></p>{% endif %} {% if constant('DEBUG_POCHE') == 1 %}<p><strong>{% trans "debug mode is on so cache is off." %} {% trans "your wallabag version:" %}{{constant('WALLABAG')}}. {% trans "storage:" %} {{constant('STORAGE')}}</strong></p>{% endif %}
</footer> </footer>

View file

@ -2,7 +2,7 @@
<!-- <!--
$(document).ready(function() { $(document).ready(function() {
$("body").css("cursor", "wait"); $("body").css("cursor", "wait");
setTimeout(function(){ setTimeout(function(){
window.location = './?import'; window.location = './?import';
}, {{ import.delay }} ); }, {{ import.delay }} );

View file

@ -11,4 +11,3 @@
</ul> </ul>
{% include '_pocheit-form.twig' %} {% include '_pocheit-form.twig' %}
{% include '_search-form.twig' %} {% include '_search-form.twig' %}

View file

@ -1 +1 @@
{{ messages | raw }} {{ messages | raw }}

View file

@ -1,4 +1,4 @@
<div id="search-form" class="messages info"> <div id="search-form" class="messages info">
<form method="get" action="index.php"> <form method="get" action="index.php">
<p> <p>
<input type="hidden" name="view" value="search"></input> <input type="hidden" name="view" value="search"></input>

View file

@ -70,5 +70,5 @@
<dt>PHPePub</dt> <dt>PHPePub</dt>
<dd><a href="https://github.com/Grandt/PHPePub/">https://github.com/Grandt/PHPePub/</a></dd> <dd><a href="https://github.com/Grandt/PHPePub/">https://github.com/Grandt/PHPePub/</a></dd>
</dl> </dl>
{% endblock %} {% endblock %}

View file

@ -45,7 +45,7 @@
{% trans "You can regenerate your token: <a href='?feed&amp;action=generate'>generate!</a>." %} {% trans "You can regenerate your token: <a href='?feed&amp;action=generate'>generate!</a>." %}
</p> </p>
{% endif %} {% endif %}
<h2>{% trans "Change your theme" %}</h2> <h2>{% trans "Change your theme" %}</h2>
<form method="post" action="?updatetheme" name="changethemeform"> <form method="post" action="?updatetheme" name="changethemeform">
<fieldset class="w500p inline"> <fieldset class="w500p inline">

View file

@ -1 +1 @@
{{ export }} {{ export }}

View file

@ -28,4 +28,4 @@
</div> </div>
{% include '_footer.twig' %} {% include '_footer.twig' %}
</body> </body>
</html> </html>

View file

@ -15,4 +15,4 @@
{% endfor %} {% endfor %}
</div> </div>
{% endblock %} {% endblock %}

View file

@ -42,7 +42,7 @@
<script src="{{ poche_url }}themes/_global/js/restoreScroll.js"></script> <script src="{{ poche_url }}themes/_global/js/restoreScroll.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
// toggle read property of current article // toggle read property of current article
$('#markAsRead').click(function(){ $('#markAsRead').click(function(){
$("body").css("cursor", "wait"); $("body").css("cursor", "wait");
@ -50,11 +50,11 @@
function( data ) { function( data ) {
if ( data == '1' ) { if ( data == '1' ) {
if ( $('#markAsRead').hasClass("archive-off") ) { if ( $('#markAsRead').hasClass("archive-off") ) {
$('#markAsRead').removeClass("archive-off"); $('#markAsRead').removeClass("archive-off");
$('#markAsRead').addClass("archive"); $('#markAsRead').addClass("archive");
} }
else { else {
$('#markAsRead').removeClass("archive"); $('#markAsRead').removeClass("archive");
$('#markAsRead').addClass("archive-off"); $('#markAsRead').addClass("archive-off");
} }
} }
@ -64,7 +64,7 @@
}); });
$("body").css("cursor", "auto"); $("body").css("cursor", "auto");
}); });
// toggle favorite property of current article // toggle favorite property of current article
$('#setFav').click(function(){ $('#setFav').click(function(){
$("body").css("cursor", "wait"); $("body").css("cursor", "wait");
@ -72,11 +72,11 @@
function( data ) { function( data ) {
if ( data == '1' ) { if ( data == '1' ) {
if ( $('#setFav').hasClass("fav-off") ) { if ( $('#setFav').hasClass("fav-off") ) {
$('#setFav').removeClass("fav-off"); $('#setFav').removeClass("fav-off");
$('#setFav').addClass("fav"); $('#setFav').addClass("fav");
} }
else { else {
$('#setFav').removeClass("fav"); $('#setFav').removeClass("fav");
$('#setFav').addClass("fav-off"); $('#setFav').addClass("fav-off");
} }
} }
@ -86,8 +86,8 @@
}); });
$("body").css("cursor", "auto"); $("body").css("cursor", "auto");
}); });
// set percent of read on startup // set percent of read on startup
if ( $(document).height() <= $(window).innerHeight() ) { if ( $(document).height() <= $(window).innerHeight() ) {
pp = 100; pp = 100;
} }
@ -95,7 +95,7 @@
pp = 0; pp = 0;
} }
$('#readLeftPercent').text( pp + '%' ); $('#readLeftPercent').text( pp + '%' );
$(window).scroll(function(e){ $(window).scroll(function(e){
var scrollTop = $(window).scrollTop(); var scrollTop = $(window).scrollTop();
@ -103,7 +103,7 @@
var scrollPercent = (scrollTop) / (docHeight); var scrollPercent = (scrollTop) / (docHeight);
var scrollPercentRounded = Math.round(scrollPercent*100)/100; var scrollPercentRounded = Math.round(scrollPercent*100)/100;
savePercent({{ entry.id|e }}, scrollPercentRounded); savePercent({{ entry.id|e }}, scrollPercentRounded);
// change percent of read on scroll // change percent of read on scroll
pp = Math.round(scrollTop * 100 / ( docHeight - $(window).innerHeight() )); pp = Math.round(scrollTop * 100 / ( docHeight - $(window).innerHeight() ));
$('#readLeftPercent').text( pp + '%' ); $('#readLeftPercent').text( pp + '%' );

View file

@ -23,4 +23,4 @@
</div> </div>
{% include "WallabagCoreBundle::_footer.html.twig" %} {% include "WallabagCoreBundle::_footer.html.twig" %}
</body> </body>
</html> </html>

View file

@ -30,4 +30,4 @@
</div> </div>
{% include "WallabagCoreBundle::_footer.html.twig" %} {% include "WallabagCoreBundle::_footer.html.twig" %}
</body> </body>
</html> </html>

View file

@ -56,4 +56,4 @@ class WsseProvider implements AuthenticationProviderInterface
{ {
return $token instanceof WsseUserToken; return $token instanceof WsseUserToken;
} }
} }

View file

@ -20,4 +20,4 @@ class WsseUserToken extends AbstractToken
{ {
return ''; return '';
} }
} }

View file

@ -52,7 +52,6 @@ class WsseListener implements ListenerInterface
$response = new Response(); $response = new Response();
$response->setStatusCode(403); $response->setStatusCode(403);
$event->setResponse($response); $event->setResponse($response);
} }
} }
} }

View file

@ -7,29 +7,30 @@ use Wallabag\CoreBundle\Helper\Url;
final class Extractor final class Extractor
{ {
public static function extract($url) { public static function extract($url)
{
$pageContent = Extractor::getPageContent(new Url(base64_encode($url))); $pageContent = Extractor::getPageContent(new Url(base64_encode($url)));
$title = ($pageContent['rss']['channel']['item']['title'] != '') ? $pageContent['rss']['channel']['item']['title'] : _('Untitled'); $title = ($pageContent['rss']['channel']['item']['title'] != '') ? $pageContent['rss']['channel']['item']['title'] : _('Untitled');
$body = $pageContent['rss']['channel']['item']['description']; $body = $pageContent['rss']['channel']['item']['description'];
$content = new Content(); $content = new Content();
$content->setTitle($title); $content->setTitle($title);
$content->setBody($body);; $content->setBody($body);
return $content; return $content;
} }
/** /**
* Get the content for a given URL (by a call to FullTextFeed) * Get the content for a given URL (by a call to FullTextFeed)
* *
* @param Url $url * @param Url $url
* @return mixed * @return mixed
*/ */
public static function getPageContent(Url $url) public static function getPageContent(Url $url)
{ {
// Saving and clearing context // Saving and clearing context
$REAL = array(); $REAL = array();
foreach( $GLOBALS as $key => $value ) { foreach ($GLOBALS as $key => $value) {
if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) { if ($key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS') {
$GLOBALS[$key] = array(); $GLOBALS[$key] = array();
$REAL[$key] = $value; $REAL[$key] = $value;
} }
@ -37,38 +38,39 @@ final class Extractor
// Saving and clearing session // Saving and clearing session
if (isset($_SESSION)) { if (isset($_SESSION)) {
$REAL_SESSION = array(); $REAL_SESSION = array();
foreach( $_SESSION as $key => $value ) { foreach ($_SESSION as $key => $value) {
$REAL_SESSION[$key] = $value; $REAL_SESSION[$key] = $value;
unset($_SESSION[$key]); unset($_SESSION[$key]);
} }
} }
// Running code in different context // Running code in different context
$scope = function() { $scope = function () {
extract( func_get_arg(1) ); extract(func_get_arg(1));
$_GET = $_REQUEST = array( $_GET = $_REQUEST = array(
"url" => $url->getUrl(), "url" => $url->getUrl(),
"max" => 5, "max" => 5,
"links" => "preserve", "links" => "preserve",
"exc" => "", "exc" => "",
"format" => "json", "format" => "json",
"submit" => "Create Feed" "submit" => "Create Feed",
); );
ob_start(); ob_start();
require func_get_arg(0); require func_get_arg(0);
$json = ob_get_contents(); $json = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $json; return $json;
}; };
// Silence $scope function to avoid // Silence $scope function to avoid
// issues with FTRSS when error_reporting is to high // issues with FTRSS when error_reporting is to high
// FTRSS generates PHP warnings which break output // FTRSS generates PHP warnings which break output
$json = @$scope(__DIR__ . "/../../../../vendor/wallabag/Fivefilters_Libraries/makefulltextfeed.php", array("url" => $url)); $json = @$scope(__DIR__."/../../../../vendor/wallabag/Fivefilters_Libraries/makefulltextfeed.php", array("url" => $url));
// Clearing and restoring context // Clearing and restoring context
foreach ($GLOBALS as $key => $value) { foreach ($GLOBALS as $key => $value) {
if($key != "GLOBALS" && $key != "_SESSION" ) { if ($key != "GLOBALS" && $key != "_SESSION") {
unset($GLOBALS[$key]); unset($GLOBALS[$key]);
} }
} }
@ -78,15 +80,15 @@ final class Extractor
// Clearing and restoring session // Clearing and restoring session
if (isset($REAL_SESSION)) { if (isset($REAL_SESSION)) {
foreach($_SESSION as $key => $value) { foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]); unset($_SESSION[$key]);
} }
foreach($REAL_SESSION as $key => $value) { foreach ($REAL_SESSION as $key => $value) {
$_SESSION[$key] = $value; $_SESSION[$key] = $value;
} }
} }
return json_decode($json, true); return json_decode($json, true);
} }
} }

View file

@ -38,4 +38,4 @@ class WallabagExtension extends \Twig_Extension
{ {
return 'wallabag_extension'; return 'wallabag_extension';
} }
} }