Merge pull request #1429 from wallabag/v2-language

V2 – Handle language in entry
This commit is contained in:
Nicolas Lœuillet 2015-09-23 09:13:34 +02:00
commit 5716249455
14 changed files with 382 additions and 124 deletions

221
composer.lock generated
View file

@ -285,16 +285,16 @@
}, },
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "v2.5.1", "version": "v2.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/dbal.git", "url": "https://github.com/doctrine/dbal.git",
"reference": "628c2256b646ae2417d44e063bce8aec5199d48d" "reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/628c2256b646ae2417d44e063bce8aec5199d48d", "url": "https://api.github.com/repos/doctrine/dbal/zipball/01dbcbc5cd0a913d751418e635434a18a2f2a75c",
"reference": "628c2256b646ae2417d44e063bce8aec5199d48d", "reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -352,20 +352,20 @@
"persistence", "persistence",
"queryobject" "queryobject"
], ],
"time": "2015-01-12 21:52:47" "time": "2015-09-16 16:29:33"
}, },
{ {
"name": "doctrine/doctrine-bundle", "name": "doctrine/doctrine-bundle",
"version": "v1.5.1", "version": "v1.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/DoctrineBundle.git", "url": "https://github.com/doctrine/DoctrineBundle.git",
"reference": "8c5cedb4f2f7ebb66a963ae46ad9daa1e31cee01" "reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/8c5cedb4f2f7ebb66a963ae46ad9daa1e31cee01", "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3",
"reference": "8c5cedb4f2f7ebb66a963ae46ad9daa1e31cee01", "reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -392,7 +392,7 @@
"type": "symfony-bundle", "type": "symfony-bundle",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.5.x-dev" "dev-master": "1.6.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -430,7 +430,7 @@
"orm", "orm",
"persistence" "persistence"
], ],
"time": "2015-08-12 15:52:00" "time": "2015-08-31 14:47:06"
}, },
{ {
"name": "doctrine/doctrine-cache-bundle", "name": "doctrine/doctrine-cache-bundle",
@ -948,12 +948,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git", "url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
"reference": "6b7bb04c6d507bb5356bf70b2d1bc30ce64ffc60" "reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/6b7bb04c6d507bb5356bf70b2d1bc30ce64ffc60", "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/d5b28c367d393f9d9fbc48c4138b2a74d51c0c83",
"reference": "6b7bb04c6d507bb5356bf70b2d1bc30ce64ffc60", "reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1007,7 +1007,7 @@
"keywords": [ "keywords": [
"User management" "User management"
], ],
"time": "2015-09-07 08:53:52" "time": "2015-09-15 13:15:07"
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
@ -1267,16 +1267,16 @@
}, },
{ {
"name": "j0k3r/graby", "name": "j0k3r/graby",
"version": "1.0.0-alpha.1", "version": "1.0.0-alpha.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/j0k3r/graby.git", "url": "https://github.com/j0k3r/graby.git",
"reference": "9d4f62aa83a7cd563fe3ca9fcc4b176d7e1d264c" "reference": "9cc399bbe70f12b302ea65e604a80ea738042599"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/j0k3r/graby/zipball/9d4f62aa83a7cd563fe3ca9fcc4b176d7e1d264c", "url": "https://api.github.com/repos/j0k3r/graby/zipball/9cc399bbe70f12b302ea65e604a80ea738042599",
"reference": "9d4f62aa83a7cd563fe3ca9fcc4b176d7e1d264c", "reference": "9cc399bbe70f12b302ea65e604a80ea738042599",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1289,6 +1289,7 @@
"neitanod/forceutf8": "^1.4", "neitanod/forceutf8": "^1.4",
"php": ">=5.4", "php": ">=5.4",
"simplepie/simplepie": "^1.3.1", "simplepie/simplepie": "^1.3.1",
"smalot/pdfparser": "~0.9.24",
"symfony/options-resolver": "^2.6.6" "symfony/options-resolver": "^2.6.6"
}, },
"type": "library", "type": "library",
@ -1314,20 +1315,20 @@
} }
], ],
"description": "Graby helps you extract article content from web pages", "description": "Graby helps you extract article content from web pages",
"time": "2015-09-13 10:07:45" "time": "2015-09-17 11:43:10"
}, },
{ {
"name": "j0k3r/graby-site-config", "name": "j0k3r/graby-site-config",
"version": "1.0.2", "version": "1.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/j0k3r/graby-site-config.git", "url": "https://github.com/j0k3r/graby-site-config.git",
"reference": "9ad65e69bb21397dfededd420e1d4ab22006993c" "reference": "1b0ac25687aa33785c5d9d8ede92b26f757354f5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/j0k3r/graby-site-config/zipball/9ad65e69bb21397dfededd420e1d4ab22006993c", "url": "https://api.github.com/repos/j0k3r/graby-site-config/zipball/1b0ac25687aa33785c5d9d8ede92b26f757354f5",
"reference": "9ad65e69bb21397dfededd420e1d4ab22006993c", "reference": "1b0ac25687aa33785c5d9d8ede92b26f757354f5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1350,20 +1351,20 @@
} }
], ],
"description": "Graby site config files", "description": "Graby site config files",
"time": "2015-09-13 10:26:25" "time": "2015-09-17 17:32:42"
}, },
{ {
"name": "j0k3r/php-readability", "name": "j0k3r/php-readability",
"version": "v1.0.4", "version": "v1.0.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/j0k3r/php-readability.git", "url": "https://github.com/j0k3r/php-readability.git",
"reference": "c5a4a490e155fa20809c9bbcf3e318defbb7a261" "reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/j0k3r/php-readability/zipball/c5a4a490e155fa20809c9bbcf3e318defbb7a261", "url": "https://api.github.com/repos/j0k3r/php-readability/zipball/1830dc45d4fccfe09d2d107ab59890f07adc35c4",
"reference": "c5a4a490e155fa20809c9bbcf3e318defbb7a261", "reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1413,7 +1414,7 @@
"extraction", "extraction",
"html" "html"
], ],
"time": "2015-08-24 09:10:54" "time": "2015-09-20 19:05:55"
}, },
{ {
"name": "jdorn/sql-formatter", "name": "jdorn/sql-formatter",
@ -2058,20 +2059,20 @@
}, },
{ {
"name": "neitanod/forceutf8", "name": "neitanod/forceutf8",
"version": "v1.4", "version": "v1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/neitanod/forceutf8.git", "url": "https://github.com/neitanod/forceutf8.git",
"reference": "28d50d579179abac1f6a55b03c6d9d3f6573867c" "reference": "1b577b9430cb7bd20d8dd7435f36120b85880ace"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/neitanod/forceutf8/zipball/28d50d579179abac1f6a55b03c6d9d3f6573867c", "url": "https://api.github.com/repos/neitanod/forceutf8/zipball/1b577b9430cb7bd20d8dd7435f36120b85880ace",
"reference": "28d50d579179abac1f6a55b03c6d9d3f6573867c", "reference": "1b577b9430cb7bd20d8dd7435f36120b85880ace",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.2.0" "php": ">=5.3.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -2088,7 +2089,7 @@
], ],
"description": "PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.", "description": "PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.",
"homepage": "https://github.com/neitanod/forceutf8", "homepage": "https://github.com/neitanod/forceutf8",
"time": "2014-09-24 14:59:43" "time": "2015-01-02 13:36:36"
}, },
{ {
"name": "nelmio/api-doc-bundle", "name": "nelmio/api-doc-bundle",
@ -2685,6 +2686,49 @@
], ],
"time": "2012-10-30 17:54:03" "time": "2012-10-30 17:54:03"
}, },
{
"name": "smalot/pdfparser",
"version": "v0.9.25",
"source": {
"type": "git",
"url": "https://github.com/smalot/pdfparser.git",
"reference": "31590f7938a22f1c7fc4fb292611e3742a62ebaa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smalot/pdfparser/zipball/31590f7938a22f1c7fc4fb292611e3742a62ebaa",
"reference": "31590f7938a22f1c7fc4fb292611e3742a62ebaa",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"tecnickcom/tcpdf": ">=6.0.050"
},
"require-dev": {
"atoum/atoum": "dev-master"
},
"type": "library",
"autoload": {
"psr-0": {
"Smalot\\PdfParser\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0"
],
"authors": [
{
"name": "Sebastien MALOT",
"email": "sebastien@malot.fr",
"homepage": "http://www.malot.fr",
"role": "Developer"
}
],
"description": "Pdf parser library. Can read and extract information from pdf file.",
"homepage": "http://www.pdfparser.org",
"time": "2015-09-18 08:29:33"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v5.4.1", "version": "v5.4.1",
@ -3109,6 +3153,69 @@
], ],
"time": "2015-08-02 12:30:27" "time": "2015-08-02 12:30:27"
}, },
{
"name": "tecnickcom/tcpdf",
"version": "6.2.12",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
"reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/2f732eaa91b5665274689b1d40b285a7bacdc37f",
"reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"classmap": [
"fonts",
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPLv3"
],
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"homepage": "http://nicolaasuni.tecnick.com"
}
],
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"homepage": "http://www.tcpdf.org/",
"keywords": [
"PDFD32000-2008",
"TCPDF",
"barcodes",
"datamatrix",
"pdf",
"pdf417",
"qrcode"
],
"time": "2015-09-12 10:08:34"
},
{ {
"name": "twig/extensions", "name": "twig/extensions",
"version": "v1.3.0", "version": "v1.3.0",
@ -3163,16 +3270,16 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v1.21.2", "version": "v1.22.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "ddce1136beb8db29b9cd7dffa8ab518b978c9db3" "reference": "79249fc8c9ff62e41e217e0c630e2e00bcadda6a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ddce1136beb8db29b9cd7dffa8ab518b978c9db3", "url": "https://api.github.com/repos/twigphp/Twig/zipball/79249fc8c9ff62e41e217e0c630e2e00bcadda6a",
"reference": "ddce1136beb8db29b9cd7dffa8ab518b978c9db3", "reference": "79249fc8c9ff62e41e217e0c630e2e00bcadda6a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3185,7 +3292,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.21-dev" "dev-master": "1.22-dev"
} }
}, },
"autoload": { "autoload": {
@ -3220,7 +3327,7 @@
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2015-09-09 05:28:51" "time": "2015-09-22 13:59:32"
}, },
{ {
"name": "willdurand/hateoas", "name": "willdurand/hateoas",
@ -3655,16 +3762,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "2.2.2", "version": "2.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c" "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2d7c03c0e4e080901b8f33b2897b0577be18a13c", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c", "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3713,7 +3820,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-08-04 03:42:39" "time": "2015-09-14 06:51:16"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -3846,16 +3953,16 @@
}, },
{ {
"name": "phpunit/php-token-stream", "name": "phpunit/php-token-stream",
"version": "1.4.6", "version": "1.4.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git", "url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b" "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3ab72c62e550370a6cd5dc873e1a04ab57562f5b", "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b", "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3891,20 +3998,20 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"time": "2015-08-16 08:51:00" "time": "2015-09-15 10:49:45"
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "4.8.6", "version": "4.8.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "2246830f4a1a551c67933e4171bf2126dc29d357" "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2246830f4a1a551c67933e4171bf2126dc29d357", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/73fad41adb5b7bc3a494bb930d90648df1d5e74b",
"reference": "2246830f4a1a551c67933e4171bf2126dc29d357", "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3963,7 +4070,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-08-24 04:09:38" "time": "2015-09-20 12:56:44"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",

View file

@ -192,7 +192,7 @@ class EntryController extends Controller
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
} }
$form = $this->get('form.factory')->create(new EntryFilterType()); $form = $this->get('form.factory')->create(new EntryFilterType($repository, $this->getUser()));
if ($request->query->has($form->getName())) { if ($request->query->has($form->getName())) {
// manually bind values from the request // manually bind values from the request

View file

@ -19,6 +19,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry1->setUrl('http://0.0.0.0'); $entry1->setUrl('http://0.0.0.0');
$entry1->setTitle('test title entry1'); $entry1->setTitle('test title entry1');
$entry1->setContent('This is my content /o/'); $entry1->setContent('This is my content /o/');
$entry1->setLanguage('en');
$manager->persist($entry1); $manager->persist($entry1);
@ -28,6 +29,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry2->setUrl('http://0.0.0.0'); $entry2->setUrl('http://0.0.0.0');
$entry2->setTitle('test title entry2'); $entry2->setTitle('test title entry2');
$entry2->setContent('This is my content /o/'); $entry2->setContent('This is my content /o/');
$entry2->setLanguage('fr');
$manager->persist($entry2); $manager->persist($entry2);
@ -37,6 +39,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry3->setUrl('http://0.0.0.0'); $entry3->setUrl('http://0.0.0.0');
$entry3->setTitle('test title entry3'); $entry3->setTitle('test title entry3');
$entry3->setContent('This is my content /o/'); $entry3->setContent('This is my content /o/');
$entry3->setLanguage('en');
$tag1 = new Tag($this->getReference('bob-user')); $tag1 = new Tag($this->getReference('bob-user'));
$tag1->setLabel('foo'); $tag1->setLabel('foo');
@ -54,6 +57,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry4->setUrl('http://0.0.0.0'); $entry4->setUrl('http://0.0.0.0');
$entry4->setTitle('test title entry4'); $entry4->setTitle('test title entry4');
$entry4->setContent('This is my content /o/'); $entry4->setContent('This is my content /o/');
$entry4->setLanguage('en');
$tag1 = new Tag($this->getReference('admin-user')); $tag1 = new Tag($this->getReference('admin-user'));
$tag1->setLabel('foo'); $tag1->setLabel('foo');
@ -72,6 +76,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry5->setTitle('test title entry5'); $entry5->setTitle('test title entry5');
$entry5->setContent('This is my content /o/'); $entry5->setContent('This is my content /o/');
$entry5->setStarred(true); $entry5->setStarred(true);
$entry5->setLanguage('fr');
$manager->persist($entry5); $manager->persist($entry5);
@ -82,6 +87,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry6->setTitle('test title entry6'); $entry6->setTitle('test title entry6');
$entry6->setContent('This is my content /o/'); $entry6->setContent('This is my content /o/');
$entry6->setArchived(true); $entry6->setArchived(true);
$entry6->setLanguage('de');
$manager->persist($entry6); $manager->persist($entry6);

View file

@ -94,6 +94,13 @@ class Entry
*/ */
private $mimetype; private $mimetype;
/**
* @var string
*
* @ORM\Column(name="language", type="text", nullable=true)
*/
private $language;
/** /**
* @var int * @var int
* *
@ -450,4 +457,28 @@ class Entry
{ {
return $this->previewPicture; return $this->previewPicture;
} }
/**
* Set language.
*
* @param string $language
*
* @return Entry
*/
public function setLanguage($language)
{
$this->language = $language;
return $this;
}
/**
* Get language.
*
* @return string
*/
public function getLanguage()
{
return $this->language;
}
} }

View file

@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface; use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\ExclusionPolicy; use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Expose; use JMS\Serializer\Annotation\Expose;
use FOS\UserBundle\Model\User as BaseUser; use FOS\UserBundle\Model\User as BaseUser;

View file

@ -6,9 +6,26 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
use Doctrine\ORM\EntityRepository;
use Wallabag\CoreBundle\Entity\User;
class EntryFilterType extends AbstractType class EntryFilterType extends AbstractType
{ {
private $user;
private $repository;
/**
* Repository & user are used to get a list of language entries for this user
*
* @param EntityRepository $entryRepository
* @param User $user
*/
public function __construct(EntityRepository $entryRepository, User $user)
{
$this->repository = $entryRepository;
$this->user = $user;
}
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
@ -53,7 +70,11 @@ class EntryFilterType extends AbstractType
return $filterQuery->createCondition($expression); return $filterQuery->createCondition($expression);
}, },
)); ))
->add('language', 'filter_choice', array(
'choices' => $this->repository->findDistinctLanguageByUser($this->user->getId()),
))
;
} }
public function getName() public function getName()

View file

@ -49,6 +49,7 @@ class ContentProxy
$entry->setUrl($content['url'] ?: $url); $entry->setUrl($content['url'] ?: $url);
$entry->setTitle($title); $entry->setTitle($title);
$entry->setContent($html); $entry->setContent($html);
$entry->setLanguage($content['language']);
$entry->setMimetype($content['content_type']); $entry->setMimetype($content['content_type']);
if (isset($content['open_graph']['og_image'])) { if (isset($content['open_graph']['og_image'])) {

View file

@ -134,4 +134,31 @@ class EntryRepository extends EntityRepository
return $qb->getQuery()->getResult(); return $qb->getQuery()->getResult();
} }
/**
* Find distinct language for a given user.
* Used to build the filter language list.
*
* @param int $userId User id
*
* @return array
*/
public function findDistinctLanguageByUser($userId)
{
$results = $this->createQueryBuilder('e')
->select('e.language')
->where('e.user = :userId')->setParameter('userId', $userId)
->andWhere('e.language IS NOT NULL')
->groupBy('e.language')
->orderBy('e.language', ' ASC')
->getQuery()
->getResult();
$languages = array();
foreach ($results as $result) {
$languages[$result['language']] = $result['language'];
}
return $languages;
}
} }

View file

@ -71,6 +71,14 @@
<label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label> <label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label>
</div> </div>
</div> </div>
<div id="filter-language" class="filter-group">
<label for="entry_filter_language">{% trans %}Language{% endtrans %}</label>
<div class="input-field ">
{{ form_widget(form.language) }}
</div>
</div>
<div id="filter-reading-time" class="filter-group"> <div id="filter-reading-time" class="filter-group">
<div class=""> <div class="">
<label>{% trans %}Reading time in minutes{% endtrans %}</label> <label>{% trans %}Reading time in minutes{% endtrans %}</label>

View file

@ -949,7 +949,7 @@ pre code {
padding: 15px; padding: 15px;
padding-right: 30px; padding-right: 30px;
padding-top: 30px; padding-top: 30px;
border-left: 1px #333 solid;
z-index: 12; z-index: 12;
/*transition-property: transform; /*transition-property: transform;

View file

@ -98,27 +98,37 @@
<h4 class="center">{% trans %}Filters{% endtrans %}</h1> <h4 class="center">{% trans %}Filters{% endtrans %}</h1>
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<label>{% trans %}Status{% endtrans %}</label> <label>{% trans %}Status{% endtrans %}</label>
</div> </div>
<div class="input-field col s6"> <div class="input-field col s6 with-checkbox">
{{ form_widget(form.previewPicture) }}
<label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label>
</div>
<div class="input-field col s6">
{{ form_widget(form.isArchived) }} {{ form_widget(form.isArchived) }}
<label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label> <label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label>
</div> </div>
<div class="input-field col s6"> <div class="input-field col s6 with-checkbox">
{{ form_widget(form.isStarred) }} {{ form_widget(form.isStarred) }}
<label for="entry_filter_isStarred">{% trans %}Starred{% endtrans %}</label> <label for="entry_filter_isStarred">{% trans %}Starred{% endtrans %}</label>
</div> </div>
<div class="col s12">
<label>{% trans %}Preview picture{% endtrans %}</label>
</div>
<div class="input-field col s12 with-checkbox">
{{ form_widget(form.previewPicture) }}
<label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label>
</div>
<div class="col s12">
<label>{% trans %}Language{% endtrans %}</label>
</div>
<div class="input-field col s12">
{{ form_widget(form.language) }}
</div>
<div class="col s12"> <div class="col s12">
<label>{% trans %}Reading time in minutes{% endtrans %}</label> <label>{% trans %}Reading time in minutes{% endtrans %}</label>
</div> </div>

View file

@ -209,6 +209,11 @@ nav input {
overflow-y: visible; overflow-y: visible;
} }
#filters div.with-checkbox {
height: 3rem;
margin-top: 0px;
}
/* ========================================================================== /* ==========================================================================
4 = Cards 4 = Cards
========================================================================== */ ========================================================================== */

View file

@ -382,4 +382,27 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->submit($form); $crawler = $client->submit($form);
$this->assertCount(1, $crawler->filter('div[class=entry]')); $this->assertCount(1, $crawler->filter('div[class=entry]'));
} }
public function testFilterOnLanguage()
{
$this->logInAs('admin');
$client = $this->getClient();
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
'entry_filter[language]' => 'de',
);
$crawler = $client->submit($form, $data);
$this->assertCount(1, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
'entry_filter[language]' => 'en',
);
$crawler = $client->submit($form, $data);
$this->assertCount(2, $crawler->filter('div[class=entry]'));
}
} }

View file

@ -18,7 +18,13 @@ class ContentProxyTest extends KernelTestCase
$graby->expects($this->any()) $graby->expects($this->any())
->method('fetchContent') ->method('fetchContent')
->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => '')); ->willReturn(array(
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
));
$proxy = new ContentProxy($graby); $proxy = new ContentProxy($graby);
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
@ -28,6 +34,7 @@ class ContentProxyTest extends KernelTestCase
$this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture()); $this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getMimetype()); $this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage());
} }
public function testWithEmptyContentButOG() public function testWithEmptyContentButOG()
@ -39,7 +46,17 @@ class ContentProxyTest extends KernelTestCase
$graby->expects($this->any()) $graby->expects($this->any())
->method('fetchContent') ->method('fetchContent')
->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => '', 'open_graph' => array('og_title' => 'my title', 'og_description' => 'desc'))); ->willReturn(array(
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
'open_graph' => array(
'og_title' => 'my title',
'og_description' => 'desc',
),
));
$proxy = new ContentProxy($graby); $proxy = new ContentProxy($graby);
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
@ -48,6 +65,7 @@ class ContentProxyTest extends KernelTestCase
$this->assertEquals('my title', $entry->getTitle()); $this->assertEquals('my title', $entry->getTitle());
$this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent()); $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture()); $this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getLanguage());
$this->assertEmpty($entry->getMimetype()); $this->assertEmpty($entry->getMimetype());
} }
@ -65,6 +83,7 @@ class ContentProxyTest extends KernelTestCase
'title' => 'this is my title', 'title' => 'this is my title',
'url' => 'http://1.1.1.1', 'url' => 'http://1.1.1.1',
'content_type' => 'text/html', 'content_type' => 'text/html',
'language' => 'fr',
'open_graph' => array( 'open_graph' => array(
'og_title' => 'my OG title', 'og_title' => 'my OG title',
'og_description' => 'OG desc', 'og_description' => 'OG desc',
@ -80,5 +99,6 @@ class ContentProxyTest extends KernelTestCase
$this->assertEquals('this is my content', $entry->getContent()); $this->assertEquals('this is my content', $entry->getContent());
$this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertEquals('text/html', $entry->getMimetype()); $this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
} }
} }