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,12 +8,10 @@ use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Repository;
use Wallabag\CoreBundle\Entity\Entries;
use Wallabag\CoreBundle\Service\Extractor;
use Wallabag\CoreBundle\Helper\Tools;
use Wallabag\CoreBundle\Helper\Url;
class EntryController extends Controller
{
/**
* @param Request $request
* @Route("/new", name="new_entry")
@ -32,7 +30,6 @@ class EntryController extends Controller
$form->handleRequest($request);
if ($form->isValid()) {
$content = Extractor::extract($entry->getUrl());
$entry->setTitle($content->getTitle());

View file

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

View file

@ -3,7 +3,6 @@
namespace Wallabag\CoreBundle\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use FOS\RestBundle\Controller\Annotations\View;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\Entries;
@ -12,7 +11,6 @@ use Wallabag\CoreBundle\Service\Extractor;
class WallabagRestController extends Controller
{
/**
* Retrieve all entries. It could be filtered by many options.
*
@ -51,7 +49,6 @@ class WallabagRestController extends Controller
}
return $entries;
}
/**
@ -119,7 +116,6 @@ class WallabagRestController extends Controller
*/
public function patchEntriesAction(Entries $entry)
{
}
/**
@ -133,10 +129,8 @@ class WallabagRestController extends Controller
*/
public function deleteEntriesAction(Entries $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)
{
}
/**
@ -187,8 +180,8 @@ class WallabagRestController extends Controller
* @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)
{
}
}

View file

@ -35,8 +35,6 @@ class Config
*/
private $value;
/**
* Get id
*

View file

@ -66,8 +66,6 @@ class Entries
*/
private $userId;
/**
* Get id
*
@ -150,6 +148,7 @@ class Entries
public function toggleArchive()
{
$this->isRead = $this->getIsRead() ^ 1;
return $this;
}

View file

@ -28,8 +28,6 @@ class Tags
*/
private $value;
/**
* Get id
*

View file

@ -35,8 +35,6 @@ class TagsEntries
*/
private $tagId;
/**
* Get id
*

View file

@ -4,7 +4,6 @@ namespace Wallabag\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
/**

View file

@ -42,8 +42,6 @@ class UsersConfig
*/
private $value;
/**
* Get id
*

View file

@ -8,8 +8,8 @@ class Content
private $body;
public function __constructor() {
public function __constructor()
{
}
public function getTitle()

View file

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

View file

@ -2,9 +2,6 @@
namespace Wallabag\CoreBundle\Helper;
use \RecursiveIteratorIterator;
use \RecursiveDirectoryIterator;
final class Tools
{
/**
@ -30,8 +27,8 @@ final class Tools
curl_setopt($curl, CURLOPT_HEADER, false);
# for ssl, do not verified certificate
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE );
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
# FeedBurner requires a proper USER-AGENT...
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
@ -49,12 +46,12 @@ final class Tools
'http' => array(
'timeout' => $timeout,
'header' => "User-Agent: ".$useragent,
'follow_location' => true
'follow_location' => true,
),
'ssl' => array(
'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);
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 (isset($data) and isset($httpcodeOK) and $httpcodeOK) {
# take charset of page and get it
preg_match('#<meta .*charset=.*>#Usi', $data, $meta);
@ -77,7 +73,9 @@ final class Tools
preg_match('#charset="?(.*)"#si', $meta[0], $encoding);
# if charset is found set it otherwise, set it to 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 {
$html_charset = 'utf-8';
$encoding[1] = '';
@ -87,9 +85,8 @@ final class Tools
$data = str_replace('charset='.$encoding[1], 'charset='.$html_charset, $data);
return $data;
}
else {
return FALSE;
} else {
return false;
}
}
@ -113,12 +110,10 @@ final class Tools
} else {
$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);
}
return str_replace('+', '', $token);
}
}

View file

@ -6,20 +6,23 @@ class Url
{
public $url;
function __construct($url)
public function __construct($url)
{
$this->url = base64_decode($url);
}
public function getUrl() {
public function getUrl()
{
return $this->url;
}
public function setUrl($url) {
public function setUrl($url)
{
$this->url = $url;
}
public function isCorrect() {
return filter_var($this->url, FILTER_VALIDATE_URL) !== FALSE;
public function isCorrect()
{
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\Tools\Pagination\Paginator;
use Wallabag\CoreBundle\Entity\Entries;
use Wallabag\CoreBundle\Service\Extractor;
class EntriesRepository extends EntityRepository
{

View file

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

View file

@ -37,4 +37,3 @@
<script src="{{ asset('themes/_global/js/saveLink.js') }}"></script>
<script src="{{ asset('themes/_global/js/popupForm.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 class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
</ul>

View file

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

View file

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

View file

@ -7,14 +7,15 @@ use Wallabag\CoreBundle\Helper\Url;
final class Extractor
{
public static function extract($url) {
public static function extract($url)
{
$pageContent = Extractor::getPageContent(new Url(base64_encode($url)));
$title = ($pageContent['rss']['channel']['item']['title'] != '') ? $pageContent['rss']['channel']['item']['title'] : _('Untitled');
$body = $pageContent['rss']['channel']['item']['description'];
$content = new Content();
$content->setTitle($title);
$content->setBody($body);;
$content->setBody($body);
return $content;
}
@ -52,12 +53,13 @@ final class Extractor
"links" => "preserve",
"exc" => "",
"format" => "json",
"submit" => "Create Feed"
"submit" => "Create Feed",
);
ob_start();
require func_get_arg(0);
$json = ob_get_contents();
ob_end_clean();
return $json;
};