From 4bb8548eccf22b40c25352fe27c66f1f8039ebcd Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 8 Feb 2015 20:51:41 -0500 Subject: Add a way to parse search string to extract keywords This feature is not in use at the moment, but it will be handy to reorganize the query building process. It allows to have more than one keyword in the search box. Full tests are available as well. It probably needs a refactoring later, but I think this is the first step to make the application full object oriented and testable. --- app/Models/Context.php | 149 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) (limited to 'app') diff --git a/app/Models/Context.php b/app/Models/Context.php index 1c770c756..645639907 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -301,4 +301,153 @@ class FreshRSS_Context { } return false; } + + /** + * Parse search string to extract the different keywords. + * + * @return array + */ + public function parseSearch() { + $search = self::$search; + $intitle = $this->parseIntitleSearch($search); + $author = $this->parseAuthorSearch($intitle['string']); + $inurl = $this->parseInurlSearch($author['string']); + $pubdate = $this->parsePubdateSearch($inurl['string']); + $date = $this->parseDateSearch($pubdate['string']); + + $remaining = array(); + $remaining_search = trim($date['string']); + if (strcmp($remaining_search, '') != 0) { + $remaining['search'] = $remaining_search; + } + + return array_merge($intitle['search'], $author['search'], $inurl['search'], $date['search'], $pubdate['search'], $remaining); + } + + /** + * Parse the search string to find intitle keyword and the search related + * to it. + * The search is the first word following the keyword. + * It returns an array containing the matched string and the search. + * + * @param string $search + * @return array + */ + private function parseIntitleSearch($search) { + if (preg_match('/intitle:(?P[\'"])(?P.*)(?P=delim)/U', $search, $matches)) { + return array( + 'string' => str_replace($matches[0], '', $search), + 'search' => array('intitle' => $matches['search']), + ); + } + if (preg_match('/intitle:(?P\w*)/', $search, $matches)) { + return array( + 'string' => str_replace($matches[0], '', $search), + 'search' => array('intitle' => $matches['search']), + ); + } + return array( + 'string' => $search, + 'search' => array(), + ); + } + + /** + * Parse the search string to find author keyword and the search related + * to it. + * The search is the first word following the keyword except when using + * a delimiter. Supported delimiters are single quote (') and double + * quotes ("). + * It returns an array containing the matched string and the search. + * + * @param string $search + * @return array + */ + private function parseAuthorSearch($search) { + if (preg_match('/author:(?P[\'"])(?P.*)(?P=delim)/U', $search, $matches)) { + return array( + 'string' => str_replace($matches[0], '', $search), + 'search' => array('author' => $matches['search']), + ); + } + if (preg_match('/author:(?P\w*)/', $search, $matches)) { + return array( + 'string' => str_replace($matches[0], '', $search), + 'search' => array('author' => $matches['search']), + ); + } + return array( + 'string' => $search, + 'search' => array(), + ); + } + + /** + * Parse the search string to find inurl keyword and the search related + * to it. + * The search is the first word following the keyword except. + * It returns an array containing the matched string and the search. + * + * @param string $search + * @return array + */ + private function parseInurlSearch($search) { + if (preg_match('/inurl:(?P[^\s]*)/', $search, $matches)) { + return array( + 'string' => str_replace($matches[0], '', $search), + 'search' => array('inurl' => $matches['search']), + ); + } + return array( + 'string' => $search, + 'search' => array(), + ); + } + + /** + * Parse the search string to find date keyword and the search related + * to it. + * The search is the first word following the keyword. + * It returns an array containing the matched string and the search. + * + * @param string $search + * @return array + */ + private function parseDateSearch($search) { + if (preg_match('/date:(?P[^\s]*)/', $search, $matches)) { + list($min_date, $max_date) = parseDateInterval($matches['search']); + return array( + 'string' => str_replace($matches[0], '', $search), + 'search' => array('min_date' => $min_date, 'max_date' => $max_date), + ); + } + return array( + 'string' => $search, + 'search' => array(), + ); + } + + /** + * Parse the search string to find pubdate keyword and the search related + * to it. + * The search is the first word following the keyword. + * It returns an array containing the matched string and the search. + * + * @param string $search + * @return array + */ + private function parsePubdateSearch($search) { + if (preg_match('/pubdate:(?P[^\s]*)/', $search, $matches)) { + list($min_date, $max_date) = parseDateInterval($matches['search']); + return array( + 'string' => str_replace($matches[0], '', $search), + 'search' => array('min_pubdate' => $min_date, 'max_pubdate' => $max_date), + ); + } + return array( + 'string' => $search, + 'search' => array(), + ); + } + } -- cgit v1.2.3 From f30ded2f863ed4a33ae8194d6cf00eaa877c9b6a Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 11 Feb 2015 20:41:00 -0500 Subject: Extract the search code from the context I figured that the code for the search could be extracted from the context to have separation of concern. It supports multiple keywords. It suports also multiple tag keywords. --- app/Models/Context.php | 148 --------------------- app/Models/Search.php | 189 +++++++++++++++++++++++++++ tests/app/Models/ContextTest.php | 236 --------------------------------- tests/app/Models/SearchTest.php | 276 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 465 insertions(+), 384 deletions(-) create mode 100644 app/Models/Search.php create mode 100644 tests/app/Models/SearchTest.php (limited to 'app') diff --git a/app/Models/Context.php b/app/Models/Context.php index 645639907..f00bb1e97 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -302,152 +302,4 @@ class FreshRSS_Context { return false; } - /** - * Parse search string to extract the different keywords. - * - * @return array - */ - public function parseSearch() { - $search = self::$search; - $intitle = $this->parseIntitleSearch($search); - $author = $this->parseAuthorSearch($intitle['string']); - $inurl = $this->parseInurlSearch($author['string']); - $pubdate = $this->parsePubdateSearch($inurl['string']); - $date = $this->parseDateSearch($pubdate['string']); - - $remaining = array(); - $remaining_search = trim($date['string']); - if (strcmp($remaining_search, '') != 0) { - $remaining['search'] = $remaining_search; - } - - return array_merge($intitle['search'], $author['search'], $inurl['search'], $date['search'], $pubdate['search'], $remaining); - } - - /** - * Parse the search string to find intitle keyword and the search related - * to it. - * The search is the first word following the keyword. - * It returns an array containing the matched string and the search. - * - * @param string $search - * @return array - */ - private function parseIntitleSearch($search) { - if (preg_match('/intitle:(?P[\'"])(?P.*)(?P=delim)/U', $search, $matches)) { - return array( - 'string' => str_replace($matches[0], '', $search), - 'search' => array('intitle' => $matches['search']), - ); - } - if (preg_match('/intitle:(?P\w*)/', $search, $matches)) { - return array( - 'string' => str_replace($matches[0], '', $search), - 'search' => array('intitle' => $matches['search']), - ); - } - return array( - 'string' => $search, - 'search' => array(), - ); - } - - /** - * Parse the search string to find author keyword and the search related - * to it. - * The search is the first word following the keyword except when using - * a delimiter. Supported delimiters are single quote (') and double - * quotes ("). - * It returns an array containing the matched string and the search. - * - * @param string $search - * @return array - */ - private function parseAuthorSearch($search) { - if (preg_match('/author:(?P[\'"])(?P.*)(?P=delim)/U', $search, $matches)) { - return array( - 'string' => str_replace($matches[0], '', $search), - 'search' => array('author' => $matches['search']), - ); - } - if (preg_match('/author:(?P\w*)/', $search, $matches)) { - return array( - 'string' => str_replace($matches[0], '', $search), - 'search' => array('author' => $matches['search']), - ); - } - return array( - 'string' => $search, - 'search' => array(), - ); - } - - /** - * Parse the search string to find inurl keyword and the search related - * to it. - * The search is the first word following the keyword except. - * It returns an array containing the matched string and the search. - * - * @param string $search - * @return array - */ - private function parseInurlSearch($search) { - if (preg_match('/inurl:(?P[^\s]*)/', $search, $matches)) { - return array( - 'string' => str_replace($matches[0], '', $search), - 'search' => array('inurl' => $matches['search']), - ); - } - return array( - 'string' => $search, - 'search' => array(), - ); - } - - /** - * Parse the search string to find date keyword and the search related - * to it. - * The search is the first word following the keyword. - * It returns an array containing the matched string and the search. - * - * @param string $search - * @return array - */ - private function parseDateSearch($search) { - if (preg_match('/date:(?P[^\s]*)/', $search, $matches)) { - list($min_date, $max_date) = parseDateInterval($matches['search']); - return array( - 'string' => str_replace($matches[0], '', $search), - 'search' => array('min_date' => $min_date, 'max_date' => $max_date), - ); - } - return array( - 'string' => $search, - 'search' => array(), - ); - } - - /** - * Parse the search string to find pubdate keyword and the search related - * to it. - * The search is the first word following the keyword. - * It returns an array containing the matched string and the search. - * - * @param string $search - * @return array - */ - private function parsePubdateSearch($search) { - if (preg_match('/pubdate:(?P[^\s]*)/', $search, $matches)) { - list($min_date, $max_date) = parseDateInterval($matches['search']); - return array( - 'string' => str_replace($matches[0], '', $search), - 'search' => array('min_pubdate' => $min_date, 'max_pubdate' => $max_date), - ); - } - return array( - 'string' => $search, - 'search' => array(), - ); - } - } diff --git a/app/Models/Search.php b/app/Models/Search.php new file mode 100644 index 000000000..0475bc685 --- /dev/null +++ b/app/Models/Search.php @@ -0,0 +1,189 @@ +raw_input = $input; + $input = $this->parseIntitleSearch($input); + $input = $this->parseAuthorSearch($input); + $input = $this->parseInurlSearch($input); + $input = $this->parsePubdateSearch($input); + $input = $this->parseDateSearch($input); + $input = $this->parseTagsSeach($input); + $this->search = $input; + } + + public function getRawInput() { + return $this->raw_input; + } + + public function getIntitle() { + return $this->intitle; + } + + public function getMinDate() { + return $this->min_date; + } + + public function getMaxDate() { + return $this->max_date; + } + + public function getMinPubdate() { + return $this->min_pubdate; + } + + public function getMaxPubdate() { + return $this->max_pubdate; + } + + public function getInurl() { + return $this->inurl; + } + + public function getAuthor() { + return $this->author; + } + + public function getTags() { + return $this->tags; + } + + public function getSearch() { + return $this->search; + } + + /** + * Parse the search string to find intitle keyword and the search related + * to it. + * The search is the first word following the keyword. + * + * @param string $input + * @return string + */ + private function parseIntitleSearch($input) { + if (preg_match('/intitle:(?P[\'"])(?P.*)(?P=delim)/U', $input, $matches)) { + $this->intitle = $matches['search']; + $input = str_replace($matches[0], '', $input); + } else if (preg_match('/intitle:(?P\w*)/', $input, $matches)) { + $this->intitle = $matches['search']; + $input = str_replace($matches[0], '', $input); + } + return $this->cleanSearch($input); + } + + /** + * Parse the search string to find author keyword and the search related + * to it. + * The search is the first word following the keyword except when using + * a delimiter. Supported delimiters are single quote (') and double + * quotes ("). + * + * @param string $input + * @return string + */ + private function parseAuthorSearch($input) { + if (preg_match('/author:(?P[\'"])(?P.*)(?P=delim)/U', $input, $matches)) { + $this->author = $matches['search']; + $input = str_replace($matches[0], '', $input); + } else if (preg_match('/author:(?P\w*)/', $input, $matches)) { + $this->author = $matches['search']; + $input = str_replace($matches[0], '', $input); + } + return $this->cleanSearch($input); + } + + /** + * Parse the search string to find inurl keyword and the search related + * to it. + * The search is the first word following the keyword except. + * + * @param string $input + * @return string + */ + private function parseInurlSearch($input) { + if (preg_match('/inurl:(?P[^\s]*)/', $input, $matches)) { + $this->inurl = $matches['search']; + $input = str_replace($matches[0], '', $input); + } + return $this->cleanSearch($input); + } + + /** + * Parse the search string to find date keyword and the search related + * to it. + * The search is the first word following the keyword. + * + * @param string $input + * @return string + */ + private function parseDateSearch($input) { + if (preg_match('/date:(?P[^\s]*)/', $input, $matches)) { + list($this->min_date, $this->max_date) = parseDateInterval($matches['search']); + $input = str_replace($matches[0], '', $input); + } + return $this->cleanSearch($input); + } + + /** + * Parse the search string to find pubdate keyword and the search related + * to it. + * The search is the first word following the keyword. + * + * @param string $input + * @return string + */ + private function parsePubdateSearch($input) { + if (preg_match('/pubdate:(?P[^\s]*)/', $input, $matches)) { + list($this->min_pubdate, $this->max_pubdate) = parseDateInterval($matches['search']); + $input = str_replace($matches[0], '', $input); + } + return $this->cleanSearch($input); + } + + /** + * Parse the search string to find tags keyword (# followed by a word) + * and the search related to it. + * The search is the first word following the #. + * + * @param string $input + * @return string + */ + private function parseTagsSeach($input) { + if (preg_match_all('/#(?P[^\s]+)/', $input, $matches)) { + $this->tags = $matches['search']; + $input = str_replace($matches[0], '', $input); + } + return $this->cleanSearch($input); + } + + private function cleanSearch($input) { + $input = preg_replace('/\s+/', ' ', $input); + return trim($input); + } + +} diff --git a/tests/app/Models/ContextTest.php b/tests/app/Models/ContextTest.php index c5da6f667..4dc8b7757 100644 --- a/tests/app/Models/ContextTest.php +++ b/tests/app/Models/ContextTest.php @@ -1,241 +1,5 @@ context = new FreshRSS_Context(); - } - - public function testParseSearch_whenEmpty_returnsEmptyArray() { - $this->assertCount(0, $this->context->parseSearch()); - } - - /** - * @dataProvider provideMultipleKeywordSearch - * @param string $search - * @param string $expected_values - */ - public function testParseSearch_whenMultipleKeywords_returnArrayWithMultipleValues($search, $expected_values) { - FreshRSS_Context::$search = $search; - $parsed_search = $this->context->parseSearch(); - $this->assertEquals($expected_values, $parsed_search); - } - - /** - * @return array - */ - public function provideMultipleKeywordSearch() { - return array( - array( - 'intitle:word1 author:word2', - array( - 'intitle' => 'word1', - 'author' => 'word2', - ), - ), - array( - 'author:word2 intitle:word1', - array( - 'intitle' => 'word1', - 'author' => 'word2', - ), - ), - array( - 'author:word1 inurl:word2', - array( - 'author' => 'word1', - 'inurl' => 'word2', - ), - ), - array( - 'inurl:word2 author:word1', - array( - 'author' => 'word1', - 'inurl' => 'word2', - ), - ), - array( - 'date:2008-01-01/2008-02-01 pubdate:2007-01-01/2007-02-01', - array( - 'min_date' => '1199163600', - 'max_date' => '1201928399', - 'min_pubdate' => '1167627600', - 'max_pubdate' => '1170392399', - ), - ), - array( - 'pubdate:2007-01-01/2007-02-01 date:2008-01-01/2008-02-01', - array( - 'min_date' => '1199163600', - 'max_date' => '1201928399', - 'min_pubdate' => '1167627600', - 'max_pubdate' => '1170392399', - ), - ), - array( - 'inurl:word1 author:word2 intitle:word3 pubdate:2007-01-01/2007-02-01 date:2008-01-01/2008-02-01 hello world', - array( - 'inurl' => 'word1', - 'author' => 'word2', - 'intitle' => 'word3', - 'min_date' => '1199163600', - 'max_date' => '1201928399', - 'min_pubdate' => '1167627600', - 'max_pubdate' => '1170392399', - 'search' => 'hello world', - ), - ), - ); - } - - /** - * @dataProvider provideIntitleSearch - * @param string $search - * @param string $expected_value - */ - public function testParseSearch_whenIntitleKeyword_returnArrayWithIntitleValue($search, $expected_value) { - FreshRSS_Context::$search = $search; - $parsed_search = $this->context->parseSearch(); - $this->assertEquals($expected_value, $parsed_search['intitle']); - } - - /** - * @return array - */ - public function provideIntitleSearch() { - return array( - array('intitle:word1', 'word1'), - array('intitle:word1 word2', 'word1'), - array('intitle:"word1 word2"', 'word1 word2'), - array("intitle:'word1 word2'", 'word1 word2'), - array('word1 intitle:word2', 'word2'), - array('word1 intitle:word2 word3', 'word2'), - array('word1 intitle:"word2 word3"', 'word2 word3'), - array("word1 intitle:'word2 word3'", 'word2 word3'), - array('intitle:word1 intitle:word2', 'word1'), - array('intitle: word1 word2', ''), - array('intitle:123', '123'), - array('intitle:"word1 word2" word3"', 'word1 word2'), - array("intitle:'word1 word2' word3'", 'word1 word2'), - array('intitle:"word1 word2\' word3"', "word1 word2' word3"), - array("intitle:'word1 word2\" word3'", 'word1 word2" word3'), - ); - } - - /** - * @dataProvider provideAuthorSearch - * @param string $search - * @param string $expected_value - */ - public function testParseSearch_whenAuthorKeyword_returnArrayWithAuthorValue($search, $expected_value) { - FreshRSS_Context::$search = $search; - $parsed_search = $this->context->parseSearch(); - $this->assertEquals($expected_value, $parsed_search['author']); - } - - /** - * @return array - */ - public function provideAuthorSearch() { - return array( - array('author:word1', 'word1'), - array('author:word1 word2', 'word1'), - array('author:"word1 word2"', 'word1 word2'), - array("author:'word1 word2'", 'word1 word2'), - array('word1 author:word2', 'word2'), - array('word1 author:word2 word3', 'word2'), - array('word1 author:"word2 word3"', 'word2 word3'), - array("word1 author:'word2 word3'", 'word2 word3'), - array('author:word1 author:word2', 'word1'), - array('author: word1 word2', ''), - array('author:123', '123'), - array('author:"word1 word2" word3"', 'word1 word2'), - array("author:'word1 word2' word3'", 'word1 word2'), - array('author:"word1 word2\' word3"', "word1 word2' word3"), - array("author:'word1 word2\" word3'", 'word1 word2" word3'), - ); - } - - /** - * @dataProvider provideInurlSearch - * @param string $search - * @param string $expected_value - */ - public function testParseSearch_whenInurlKeyword_returnArrayWithInurlValue($search, $expected_value) { - FreshRSS_Context::$search = $search; - $parsed_search = $this->context->parseSearch(); - $this->assertEquals($expected_value, $parsed_search['inurl']); - } - - /** - * @return array - */ - public function provideInurlSearch() { - return array( - array('inurl:word1', 'word1'), - array('inurl: word1', ''), - array('inurl:123', '123'), - array('inurl:word1 word2', 'word1'), - array('inurl:"word1 word2"', '"word1'), - ); - } - - /** - * @dataProvider provideDateSearch - * @param string $search - * @param string $expected_min_value - * @param string $expected_max_value - */ - public function testParseSearch_whenDateKeyword_returnArrayWithDateValues($search, $expected_min_value, $expected_max_value) { - FreshRSS_Context::$search = $search; - $parsed_search = $this->context->parseSearch(); - $this->assertEquals($expected_min_value, $parsed_search['min_date']); - $this->assertEquals($expected_max_value, $parsed_search['max_date']); - } - - /** - * @return array - */ - public function provideDateSearch() { - return array( - array('date:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), - array('date:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), - array('date:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), - array('date:2007-03-01/2008-05-11', '1172725200', '1210564799'), - array('date:2007-03-01/', '1172725200', ''), - array('date:/2008-05-11', '', '1210564799'), - ); - } - - /** - * @dataProvider providePubdateSearch - * @param string $search - * @param string $expected_min_value - * @param string $expected_max_value - */ - public function testParseSearch_whenPubdateKeyword_returnArrayWithPubdateValues($search, $expected_min_value, $expected_max_value) { - FreshRSS_Context::$search = $search; - $parsed_search = $this->context->parseSearch(); - $this->assertEquals($expected_min_value, $parsed_search['min_pubdate']); - $this->assertEquals($expected_max_value, $parsed_search['max_pubdate']); - } - - /** - * @return array - */ - public function providePubdateSearch() { - return array( - array('pubdate:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), - array('pubdate:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), - array('pubdate:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), - array('pubdate:2007-03-01/2008-05-11', '1172725200', '1210564799'), - array('pubdate:2007-03-01/', '1172725200', ''), - array('pubdate:/2008-05-11', '', '1210564799'), - ); - } - } diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php new file mode 100644 index 000000000..6ddfc0370 --- /dev/null +++ b/tests/app/Models/SearchTest.php @@ -0,0 +1,276 @@ +assertNull($search->getRawInput()); + $this->assertNull($search->getIntitle()); + $this->assertNull($search->getMinDate()); + $this->assertNull($search->getMaxDate()); + $this->assertNull($search->getMinPubdate()); + $this->assertNull($search->getMaxPubdate()); + $this->assertNull($search->getAuthor()); + $this->assertNull($search->getTags()); + $this->assertNull($search->getSearch()); + } + + /** + * Return an array of values for the search object. + * Here is the description of the values + * @return array + */ + public function provideEmptyInput() { + return array( + array(''), + array(null), + ); + } + + /** + * @dataProvider provideIntitleSearch + * @param string $input + * @param string $intitle_value + * @param string|null $search_value + */ + public function test__construct_whenInputContainsIntitle_setsIntitlePropery($input, $intitle_value, $search_value) { + $search = new FreshRSS_Search($input); + $this->assertEquals($intitle_value, $search->getIntitle()); + $this->assertEquals($search_value, $search->getSearch()); + } + + /** + * @return array + */ + public function provideIntitleSearch() { + return array( + array('intitle:word1', 'word1', null), + array('intitle:word1 word2', 'word1', 'word2'), + array('intitle:"word1 word2"', 'word1 word2', null), + array("intitle:'word1 word2'", 'word1 word2', null), + array('word1 intitle:word2', 'word2', 'word1'), + array('word1 intitle:word2 word3', 'word2', 'word1 word3'), + array('word1 intitle:"word2 word3"', 'word2 word3', 'word1'), + array("word1 intitle:'word2 word3'", 'word2 word3', 'word1'), + array('intitle:word1 intitle:word2', 'word1', 'intitle:word2'), + array('intitle: word1 word2', null, 'word1 word2'), + array('intitle:123', '123', null), + array('intitle:"word1 word2" word3"', 'word1 word2', 'word3"'), + array("intitle:'word1 word2' word3'", 'word1 word2', "word3'"), + array('intitle:"word1 word2\' word3"', "word1 word2' word3", null), + array("intitle:'word1 word2\" word3'", 'word1 word2" word3', null), + ); + } + + /** + * @dataProvider provideAuthorSearch + * @param string $input + * @param string $author_value + * @param string|null $search_value + */ + public function test__construct_whenInputContainsAuthor_setsAuthorValue($input, $author_value, $search_value) { + $search = new FreshRSS_Search($input); + $this->assertEquals($author_value, $search->getAuthor()); + $this->assertEquals($search_value, $search->getSearch()); + } + + /** + * @return array + */ + public function provideAuthorSearch() { + return array( + array('author:word1', 'word1', null), + array('author:word1 word2', 'word1', 'word2'), + array('author:"word1 word2"', 'word1 word2', null), + array("author:'word1 word2'", 'word1 word2', null), + array('word1 author:word2', 'word2', 'word1'), + array('word1 author:word2 word3', 'word2', 'word1 word3'), + array('word1 author:"word2 word3"', 'word2 word3', 'word1'), + array("word1 author:'word2 word3'", 'word2 word3', 'word1'), + array('author:word1 author:word2', 'word1', 'author:word2'), + array('author: word1 word2', null, 'word1 word2'), + array('author:123', '123', null), + array('author:"word1 word2" word3"', 'word1 word2', 'word3"'), + array("author:'word1 word2' word3'", 'word1 word2', "word3'"), + array('author:"word1 word2\' word3"', "word1 word2' word3", null), + array("author:'word1 word2\" word3'", 'word1 word2" word3', null), + ); + } + + /** + * @dataProvider provideInurlSearch + * @param string $input + * @param string $inurl_value + * @param string|null $search_value + */ + public function test__construct_whenInputContainsInurl_setsInurlValue($input, $inurl_value, $search_value) { + $search = new FreshRSS_Search($input); + $this->assertEquals($inurl_value, $search->getInurl()); + $this->assertEquals($search_value, $search->getSearch()); + } + + /** + * @return array + */ + public function provideInurlSearch() { + return array( + array('inurl:word1', 'word1', null), + array('inurl: word1', null, 'word1'), + array('inurl:123', '123', null), + array('inurl:word1 word2', 'word1', 'word2'), + array('inurl:"word1 word2"', '"word1', 'word2"'), + ); + } + + /** + * @dataProvider provideDateSearch + * @param string $input + * @param string $min_date_value + * @param string $max_date_value + */ + public function test__construct_whenInputContainsDate_setsDateValues($input, $min_date_value, $max_date_value) { + $search = new FreshRSS_Search($input); + $this->assertEquals($min_date_value, $search->getMinDate()); + $this->assertEquals($max_date_value, $search->getMaxDate()); + } + + /** + * @return array + */ + public function provideDateSearch() { + return array( + array('date:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), + array('date:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), + array('date:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), + array('date:2007-03-01/2008-05-11', '1172725200', '1210564799'), + array('date:2007-03-01/', '1172725200', ''), + array('date:/2008-05-11', '', '1210564799'), + ); + } + + /** + * @dataProvider providePubdateSearch + * @param string $input + * @param string $min_pubdate_value + * @param string $max_pubdate_value + */ + public function test__construct_whenInputContainsPubdate_setsPubdateValues($input, $min_pubdate_value, $max_pubdate_value) { + $search = new FreshRSS_Search($input); + $this->assertEquals($min_pubdate_value, $search->getMinPubdate()); + $this->assertEquals($max_pubdate_value, $search->getMaxPubdate()); + } + + /** + * @return array + */ + public function providePubdateSearch() { + return array( + array('pubdate:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), + array('pubdate:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), + array('pubdate:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), + array('pubdate:2007-03-01/2008-05-11', '1172725200', '1210564799'), + array('pubdate:2007-03-01/', '1172725200', ''), + array('pubdate:/2008-05-11', '', '1210564799'), + ); + } + + /** + * @dataProvider provideTagsSearch + * @param string $input + * @param string $tags_value + * @param string|null $search_value + */ + public function test__construct_whenInputContainsTags_setsTagsValue($input, $tags_value, $search_value) { + $search = new FreshRSS_Search($input); + $this->assertEquals($tags_value, $search->getTags()); + $this->assertEquals($search_value, $search->getSearch()); + } + + /** + * @return array + */ + public function provideTagsSearch() { + return array( + array('#word1', array('word1'), null), + array('# word1', null, '# word1'), + array('#123', array('123'), null), + array('#word1 word2', array('word1'), 'word2'), + array('#"word1 word2"', array('"word1'), 'word2"'), + array('#word1 #word2', array('word1', 'word2'), null), + ); + } + + /** + * @dataProvider provideMultipleSearch + * @param string $input + * @param string $author_value + * @param string $min_date_value + * @param string $max_date_value + * @param string $intitle_value + * @param string $inurl_value + * @param string $min_pubdate_value + * @param string $max_pubdate_value + * @param array $tags_value + * @param string|null $search_value + */ + public function test__construct_whenInputContainsMultipleKeywords_setsValues($input, $author_value, $min_date_value, $max_date_value, $intitle_value, $inurl_value, $min_pubdate_value, $max_pubdate_value, $tags_value, $search_value) { + $search = new FreshRSS_Search($input); + $this->assertEquals($author_value, $search->getAuthor()); + $this->assertEquals($min_date_value, $search->getMinDate()); + $this->assertEquals($max_date_value, $search->getMaxDate()); + $this->assertEquals($intitle_value, $search->getIntitle()); + $this->assertEquals($inurl_value, $search->getInurl()); + $this->assertEquals($min_pubdate_value, $search->getMinPubdate()); + $this->assertEquals($max_pubdate_value, $search->getMaxPubdate()); + $this->assertEquals($tags_value, $search->getTags()); + $this->assertEquals($search_value, $search->getSearch()); + } + + public function provideMultipleSearch() { + return array( + array( + 'author:word1 date:2007-03-01/2008-05-11 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 #word5', + 'word1', + '1172725200', + '1210564799', + 'word2', + 'word3', + '1172725200', + '1210564799', + array('word4', 'word5'), + null, + ), + array( + 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 date:2007-03-01/2008-05-11', + 'word1', + '1172725200', + '1210564799', + 'word2', + 'word3', + '1172725200', + '1210564799', + array('word4', 'word5'), + 'word6', + ), + array( + 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 word7 date:2007-03-01/2008-05-11', + 'word1', + '1172725200', + '1210564799', + 'word2', + 'word3', + '1172725200', + '1210564799', + array('word4', 'word5'), + 'word6 word7', + ), + ); + } + +} -- cgit v1.2.3 From 9cee5c1a17947d3f3d10554844b7089e28cf8500 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 11 Feb 2015 21:52:10 -0500 Subject: Remove code generated by netbeans --- app/Models/Search.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'app') diff --git a/app/Models/Search.php b/app/Models/Search.php index 0475bc685..e64f6cb88 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -5,8 +5,6 @@ * * It allows to extract meaningful bits of the search and store them in a * convenient object - * - * @author alexis */ class FreshRSS_Search { -- cgit v1.2.3 From 9f83aa5fe79618be98cb027bb1070f5a11c51723 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Thu, 12 Feb 2015 21:05:33 -0500 Subject: Refactor the code to make less unnecessaty calls There were multiple calls made to the cleaning method that were unnecessary since it is useful only on the last call. It allows to simplify code by returning values ealier. --- app/Models/Search.php | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'app') diff --git a/app/Models/Search.php b/app/Models/Search.php index e64f6cb88..ef8fc883d 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -32,7 +32,7 @@ class FreshRSS_Search { $input = $this->parsePubdateSearch($input); $input = $this->parseDateSearch($input); $input = $this->parseTagsSeach($input); - $this->search = $input; + $this->search = $this->cleanSearch($input); } public function getRawInput() { @@ -86,12 +86,13 @@ class FreshRSS_Search { private function parseIntitleSearch($input) { if (preg_match('/intitle:(?P[\'"])(?P.*)(?P=delim)/U', $input, $matches)) { $this->intitle = $matches['search']; - $input = str_replace($matches[0], '', $input); - } else if (preg_match('/intitle:(?P\w*)/', $input, $matches)) { + return str_replace($matches[0], '', $input); + } + if (preg_match('/intitle:(?P\w*)/', $input, $matches)) { $this->intitle = $matches['search']; - $input = str_replace($matches[0], '', $input); + return str_replace($matches[0], '', $input); } - return $this->cleanSearch($input); + return $input; } /** @@ -107,12 +108,13 @@ class FreshRSS_Search { private function parseAuthorSearch($input) { if (preg_match('/author:(?P[\'"])(?P.*)(?P=delim)/U', $input, $matches)) { $this->author = $matches['search']; - $input = str_replace($matches[0], '', $input); - } else if (preg_match('/author:(?P\w*)/', $input, $matches)) { + return str_replace($matches[0], '', $input); + } + if (preg_match('/author:(?P\w*)/', $input, $matches)) { $this->author = $matches['search']; - $input = str_replace($matches[0], '', $input); + return str_replace($matches[0], '', $input); } - return $this->cleanSearch($input); + return $input; } /** @@ -126,9 +128,9 @@ class FreshRSS_Search { private function parseInurlSearch($input) { if (preg_match('/inurl:(?P[^\s]*)/', $input, $matches)) { $this->inurl = $matches['search']; - $input = str_replace($matches[0], '', $input); + return str_replace($matches[0], '', $input); } - return $this->cleanSearch($input); + return $input; } /** @@ -142,9 +144,9 @@ class FreshRSS_Search { private function parseDateSearch($input) { if (preg_match('/date:(?P[^\s]*)/', $input, $matches)) { list($this->min_date, $this->max_date) = parseDateInterval($matches['search']); - $input = str_replace($matches[0], '', $input); + return str_replace($matches[0], '', $input); } - return $this->cleanSearch($input); + return $input; } /** @@ -158,9 +160,9 @@ class FreshRSS_Search { private function parsePubdateSearch($input) { if (preg_match('/pubdate:(?P[^\s]*)/', $input, $matches)) { list($this->min_pubdate, $this->max_pubdate) = parseDateInterval($matches['search']); - $input = str_replace($matches[0], '', $input); + return str_replace($matches[0], '', $input); } - return $this->cleanSearch($input); + return $input; } /** @@ -174,11 +176,17 @@ class FreshRSS_Search { private function parseTagsSeach($input) { if (preg_match_all('/#(?P[^\s]+)/', $input, $matches)) { $this->tags = $matches['search']; - $input = str_replace($matches[0], '', $input); + return str_replace($matches[0], '', $input); } - return $this->cleanSearch($input); + return $input; } + /** + * Remove all unnecessary spaces in the search + * + * @param string $input + * @return string + */ private function cleanSearch($input) { $input = preg_replace('/\s+/', ' ', $input); return trim($input); -- cgit v1.2.3 From b8fd3caf8306e8616fcb2f2c0add95b74c2ec024 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 14 Feb 2015 11:00:26 -0500 Subject: Harmonize share configuration view. Before, for shares that don't need options, only a button to remove it was visible. It was source of confusion for users. I changed the look of those shares by using the same layout as others (minus the help). As there is no configuration possible for the url, the field is disabled but it is possible to change the name of the share. See #787 --- app/Models/Share.php | 2 +- app/i18n/de/gen.php | 1 + app/i18n/en/gen.php | 1 + app/i18n/fr/gen.php | 1 + app/views/configure/sharing.phtml | 20 +++++++++++--------- p/scripts/main.js | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/Models/Share.php b/app/Models/Share.php index db6feda19..2a05f2ee9 100644 --- a/app/Models/Share.php +++ b/app/Models/Share.php @@ -152,7 +152,7 @@ class FreshRSS_Share { * Return the current name of the share option. */ public function name($real = false) { - if ($real || is_null($this->custom_name)) { + if ($real || is_null($this->custom_name) || empty($this->custom_name)) { return $this->name; } else { return $this->custom_name; diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index f3479ed53..3170b29c2 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -156,6 +156,7 @@ return array( 'damn' => 'Verdammt!', 'default_category' => 'Unkategorisiert', 'no' => 'Nein', + 'not_applicable' => 'N/A', 'ok' => 'OK!', 'or' => 'oder', 'yes' => 'Ja', diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 2143822ed..420e73f36 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -156,6 +156,7 @@ return array( 'damn' => 'Damn!', 'default_category' => 'Uncategorized', 'no' => 'No', + 'not_applicable' => 'N/A', 'ok' => 'Ok!', 'or' => 'or', 'yes' => 'Yes', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index 1cfec6969..ae946ce0c 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -156,6 +156,7 @@ return array( 'damn' => 'Arf !', 'default_category' => 'Sans catégorie', 'no' => 'Non', + 'not_applicable' => 'N/A', 'ok' => 'Ok !', 'or' => 'ou', 'yes' => 'Oui', diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index da7557480..deb1ed6b7 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -4,7 +4,8 @@
+ data-simple='
+
' data-advanced='
@@ -26,16 +27,17 @@
+
+ formType() === 'advanced') { ?> -
- - - -
- - + - + + + +
+ formType() === 'advanced') { ?> +
diff --git a/p/scripts/main.js b/p/scripts/main.js index 1be75bb12..7fb583d39 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1097,7 +1097,7 @@ function init_share_observers() { $('.share.add').on('click', function(e) { var opt = $(this).siblings('select').find(':selected'); var row = $(this).parents('form').data(opt.data('form')); - row = row.replace('##label##', opt.html(), 'g'); + row = row.replace('##label##', opt.html().trim(), 'g'); row = row.replace('##type##', opt.val(), 'g'); row = row.replace('##help##', opt.data('help'), 'g'); row = row.replace('##key##', shares, 'g'); -- cgit v1.2.3 From 58bf976f6923b5ad9c6e8e57a0daa06ec05462f4 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Tue, 17 Feb 2015 21:05:28 -0500 Subject: Change translation I change the translation for the 3 languages. German has to be checked since I used Google translate to get the translation. --- app/i18n/de/gen.php | 2 +- app/i18n/en/gen.php | 2 +- app/i18n/fr/gen.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index 3170b29c2..1b30a5be4 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -156,7 +156,7 @@ return array( 'damn' => 'Verdammt!', 'default_category' => 'Unkategorisiert', 'no' => 'Nein', - 'not_applicable' => 'N/A', + 'not_applicable' => 'Nicht verfügbar', 'ok' => 'OK!', 'or' => 'oder', 'yes' => 'Ja', diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 420e73f36..fdca01a43 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -156,7 +156,7 @@ return array( 'damn' => 'Damn!', 'default_category' => 'Uncategorized', 'no' => 'No', - 'not_applicable' => 'N/A', + 'not_applicable' => 'Not available', 'ok' => 'Ok!', 'or' => 'or', 'yes' => 'Yes', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index ae946ce0c..48fc4a7e9 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -156,7 +156,7 @@ return array( 'damn' => 'Arf !', 'default_category' => 'Sans catégorie', 'no' => 'Non', - 'not_applicable' => 'N/A', + 'not_applicable' => 'Non disponible', 'ok' => 'Ok !', 'or' => 'ou', 'yes' => 'Oui', -- cgit v1.2.3 From f5028d30d047ae50ac2d89a9a66266de086ac718 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 21 Feb 2015 07:53:45 -0500 Subject: Add required library The lib_date.php library was missing in the Search object file. It is required to make date conversion in that object. --- app/Models/Search.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/Models/Search.php b/app/Models/Search.php index ef8fc883d..a22e242af 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -1,5 +1,7 @@ Date: Sat, 21 Feb 2015 09:08:06 -0500 Subject: Use the search object to get values in the search It is now possible to combine multiple keywords to do a search. The separation of concern is better now since the search extraction is not done in the DAO anymore. At the moment, a multiple keyword search is stored as this. It could be nice to have it rendered differently in the search page to make it more readable. At the moment, there is a problem with search enclosed by ". Same search works well when enclosed by '. --- app/Controllers/indexController.php | 2 +- app/Models/Context.php | 2 +- app/Models/EntryDAO.php | 84 +++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 48 deletions(-) (limited to 'app') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index c53d3223e..c1aaca53f 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -173,7 +173,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; } - FreshRSS_Context::$search = Minz_Request::param('search', ''); + FreshRSS_Context::$search = new FreshRSS_Search(Minz_Request::param('search', '')); FreshRSS_Context::$order = Minz_Request::param( 'order', FreshRSS_Context::$user_conf->sort_order ); diff --git a/app/Models/Context.php b/app/Models/Context.php index f00bb1e97..dbdbfaa69 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -30,7 +30,7 @@ class FreshRSS_Context { public static $state = 0; public static $order = 'DESC'; public static $number = 0; - public static $search = ''; + public static $search; public static $first_id = ''; public static $next_id = ''; public static $id_max = ''; diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 61beeea13..0cf4e1367 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -441,54 +441,46 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $where .= 'AND e1.id >= ' . $date_min . '000000 '; } $search = ''; - if ($filter !== '') { - require_once(LIB_PATH . '/lib_date.php'); - $filter = trim($filter); - $filter = addcslashes($filter, '\\%_'); - $terms = array_unique(explode(' ', $filter)); - //sort($terms); //Put #tags first //TODO: Put the cheapest filters first - foreach ($terms as $word) { - $word = trim($word); - if (stripos($word, 'intitle:') === 0) { - $word = substr($word, strlen('intitle:')); - $search .= 'AND e1.title LIKE ? '; - $values[] = '%' . $word .'%'; - } elseif (stripos($word, 'inurl:') === 0) { - $word = substr($word, strlen('inurl:')); - $search .= 'AND CONCAT(e1.link, e1.guid) LIKE ? '; - $values[] = '%' . $word .'%'; - } elseif (stripos($word, 'author:') === 0) { - $word = substr($word, strlen('author:')); - $search .= 'AND e1.author LIKE ? '; - $values[] = '%' . $word .'%'; - } elseif (stripos($word, 'date:') === 0) { - $word = substr($word, strlen('date:')); - list($minDate, $maxDate) = parseDateInterval($word); - if ($minDate) { - $search .= 'AND e1.id >= ' . $minDate . '000000 '; - } - if ($maxDate) { - $search .= 'AND e1.id <= ' . $maxDate . '000000 '; - } - } elseif (stripos($word, 'pubdate:') === 0) { - $word = substr($word, strlen('pubdate:')); - list($minDate, $maxDate) = parseDateInterval($word); - if ($minDate) { - $search .= 'AND e1.date >= ' . $minDate . ' '; - } - if ($maxDate) { - $search .= 'AND e1.date <= ' . $maxDate . ' '; - } - } else { - if ($word[0] === '#' && isset($word[1])) { - $search .= 'AND e1.tags LIKE ? '; - $values[] = '%' . $word .'%'; - } else { - $search .= 'AND ' . $this->sqlconcat('e1.title', $this->isCompressed() ? 'UNCOMPRESS(content_bin)' : 'content') . ' LIKE ? '; - $values[] = '%' . $word .'%'; - } + if ($filter instanceof FreshRSS_Search) { + if ($filter->getIntitle()) { + $search .= 'AND e1.title LIKE ? '; + $values[] = "%{$filter->getIntitle()}%"; + } + if ($filter->getInurl()) { + $search .= 'AND CONCAT(e1.link, e1.guid) LIKE ? '; + $values[] = "%{$filter->getInurl()}%"; + } + if ($filter->getAuthor()) { + $search .= 'AND e1.author LIKE ? '; + $values[] = "%{$filter->getAuthor()}%"; + } + if ($filter->getMinDate()) { + $search .= 'AND e1.id >= ? '; + $values[] = "{$filter->getMinDate()}000000"; + } + if ($filter->getMaxDate()) { + $search .= 'AND e1.id <= ?'; + $values[] = "{$filter->getMaxDate()}000000"; + } + if ($filter->getMinPubdate()) { + $search .= 'AND e1.date >= ? '; + $values[] = $filter->getMinPubdate(); + } + if ($filter->getMaxPubdate()) { + $search .= 'AND e1.date <= ? '; + $values[] = $filter->getMaxPubdate(); + } + if ($filter->getTags()) { + $tags = $filter->getTags(); + foreach ($tags as $tag) { + $search .= 'AND e1.tags LIKE ? '; + $values[] = "%{$tag}%"; } } + if ($filter->getSearch()) { + $search .= 'AND ' . $this->sqlconcat('e1.title', $this->isCompressed() ? 'UNCOMPRESS(content_bin)' : 'content') . ' LIKE ? '; + $values[] = "%{$filter->getSearch()}%"; + } } return array($values, -- cgit v1.2.3 From 50b6a02578c29c780e6fe36af712bdc7cfe81d3d Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 21 Feb 2015 09:42:06 -0500 Subject: Add search default raw value Before, the default value was undefined. Now it always has a value even when no value is provided. --- app/Models/Search.php | 2 +- tests/app/Models/SearchTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/Models/Search.php b/app/Models/Search.php index a22e242af..85340ff13 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -11,7 +11,7 @@ require_once(LIB_PATH . '/lib_date.php'); class FreshRSS_Search { // This contains the user input string - private $raw_input; + private $raw_input = ''; // The following properties are extracted from the raw input private $intitle; private $min_date; diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php index 20ea09433..9e3ca6765 100644 --- a/tests/app/Models/SearchTest.php +++ b/tests/app/Models/SearchTest.php @@ -10,7 +10,7 @@ class SearchTest extends \PHPUnit_Framework_TestCase { */ public function test__construct_whenInputIsEmpty_getsOnlyNullValues($input) { $search = new FreshRSS_Search($input); - $this->assertNull($search->getRawInput()); + $this->assertEquals('', $search->getRawInput()); $this->assertNull($search->getIntitle()); $this->assertNull($search->getMinDate()); $this->assertNull($search->getMaxDate()); -- cgit v1.2.3 From 74c020edc846d0afdecb05ae1e1f30a516dee002 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 21 Feb 2015 09:44:02 -0500 Subject: Add a default string representation In some part of the code, the search is displayed as is and crash since there is no way to display the search object as a string. --- app/Models/Search.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app') diff --git a/app/Models/Search.php b/app/Models/Search.php index 85340ff13..84688be2e 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -36,6 +36,10 @@ class FreshRSS_Search { $input = $this->parseTagsSeach($input); $this->search = $this->cleanSearch($input); } + + public function __toString() { + return $this->getRawInput(); + } public function getRawInput() { return $this->raw_input; -- cgit v1.2.3 From e897afa7ccb2c625705bce25c003d9cf37179227 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 22 Feb 2015 17:38:33 -0500 Subject: Change test to verify if there is a filter --- app/Models/EntryDAO.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 0cf4e1367..d2a8e0fd9 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -441,7 +441,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $where .= 'AND e1.id >= ' . $date_min . '000000 '; } $search = ''; - if ($filter instanceof FreshRSS_Search) { + if ($filter !== null) { if ($filter->getIntitle()) { $search .= 'AND e1.title LIKE ? '; $values[] = "%{$filter->getIntitle()}%"; -- cgit v1.2.3 From fe24636e0416df4bb3507a0ac8cfe7e27d5b4c90 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Mon, 2 Mar 2015 20:27:15 -0500 Subject: Add missing white space --- app/Models/EntryDAO.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index d2a8e0fd9..cf75a02c9 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -459,7 +459,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $values[] = "{$filter->getMinDate()}000000"; } if ($filter->getMaxDate()) { - $search .= 'AND e1.id <= ?'; + $search .= 'AND e1.id <= ? '; $values[] = "{$filter->getMaxDate()}000000"; } if ($filter->getMinPubdate()) { -- cgit v1.2.3 From aacd1ffd4052b04c724c2783b3ee2845ca4ada35 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 4 Mar 2015 23:32:20 -0500 Subject: Refactor exceptions I removed unnecessary constructors and unnecessary inheritance --- app/Exceptions/BadUrlException.php | 5 ++++- app/Exceptions/ContextException.php | 6 ++---- app/Exceptions/EntriesGetterException.php | 6 ++---- app/Exceptions/FeedException.php | 7 +++---- 4 files changed, 11 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/Exceptions/BadUrlException.php b/app/Exceptions/BadUrlException.php index 59574e1e5..406efb9b3 100644 --- a/app/Exceptions/BadUrlException.php +++ b/app/Exceptions/BadUrlException.php @@ -1,6 +1,9 @@ Date: Thu, 5 Mar 2015 06:51:16 -0500 Subject: Revert inheritance As I do not have the time at the moment to verify the change of inheritance, I changed it back to the original. --- app/Exceptions/BadUrlException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/Exceptions/BadUrlException.php b/app/Exceptions/BadUrlException.php index 406efb9b3..d2509e4ba 100644 --- a/app/Exceptions/BadUrlException.php +++ b/app/Exceptions/BadUrlException.php @@ -1,6 +1,6 @@ Date: Sun, 1 Mar 2015 09:18:06 -0500 Subject: Introduce user queries objects There is now an object to manipulate user queries. It allows to move logic to handle those from the view and the controller in the model. Thus making the view and the controller easier to read. I introduced a new interface to start using dependency injection. There is still some rough edges but we are moving in the right direction. The new object is fully tested but it still need some improvements, for instance, it is still tied to the search object. There might be a better way to do that. --- app/Controllers/configureController.php | 83 +++--------- app/Exceptions/DAOException.php | 5 + app/Models/CategoryDAO.php | 2 +- app/Models/ConfigurationSetter.php | 7 +- app/Models/EntryDAO.php | 2 +- app/Models/FeedDAO.php | 2 +- app/Models/Searchable.php | 6 + app/Models/UserQuery.php | 226 +++++++++++++++++++++++++++++++ app/views/configure/queries.phtml | 47 +++---- tests/app/Models/UserQueryTest.php | 229 ++++++++++++++++++++++++++++++++ 10 files changed, 505 insertions(+), 104 deletions(-) create mode 100644 app/Exceptions/DAOException.php create mode 100644 app/Models/Searchable.php create mode 100644 app/Models/UserQuery.php create mode 100644 tests/app/Models/UserQueryTest.php (limited to 'app') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 38ccd2b2d..fc92aa0c2 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -241,13 +241,16 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * checking if categories and feeds are still in use. */ public function queriesAction() { + $category_dao = new FreshRSS_CategoryDAO(); + $feed_dao = FreshRSS_Factory::createFeedDao(); if (Minz_Request::isPost()) { - $queries = Minz_Request::param('queries', array()); + $params = Minz_Request::param('queries', array()); - foreach ($queries as $key => $query) { + foreach ($params as $key => $query) { if (!$query['name']) { $query['name'] = _t('conf.query.number', $key + 1); } + $queries[] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao); } FreshRSS_Context::$user_conf->queries = $queries; FreshRSS_Context::$user_conf->save(); @@ -255,62 +258,9 @@ class FreshRSS_configure_Controller extends Minz_ActionController { Minz_Request::good(_t('feedback.conf.updated'), array('c' => 'configure', 'a' => 'queries')); } else { - $this->view->query_get = array(); - $cat_dao = new FreshRSS_CategoryDAO(); - $feed_dao = FreshRSS_Factory::createFeedDao(); + $this->view->queries = array(); foreach (FreshRSS_Context::$user_conf->queries as $key => $query) { - if (!isset($query['get'])) { - continue; - } - - switch ($query['get'][0]) { - case 'c': - $category = $cat_dao->searchById(substr($query['get'], 2)); - - $deprecated = true; - $cat_name = ''; - if ($category) { - $cat_name = $category->name(); - $deprecated = false; - } - - $this->view->query_get[$key] = array( - 'type' => 'category', - 'name' => $cat_name, - 'deprecated' => $deprecated, - ); - break; - case 'f': - $feed = $feed_dao->searchById(substr($query['get'], 2)); - - $deprecated = true; - $feed_name = ''; - if ($feed) { - $feed_name = $feed->name(); - $deprecated = false; - } - - $this->view->query_get[$key] = array( - 'type' => 'feed', - 'name' => $feed_name, - 'deprecated' => $deprecated, - ); - break; - case 's': - $this->view->query_get[$key] = array( - 'type' => 'favorite', - 'name' => 'favorite', - 'deprecated' => false, - ); - break; - case 'a': - $this->view->query_get[$key] = array( - 'type' => 'all', - 'name' => 'all', - 'deprecated' => false, - ); - break; - } + $this->view->queries[$key] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao); } } @@ -325,16 +275,17 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * lean data. */ public function addQueryAction() { - $whitelist = array('get', 'order', 'name', 'search', 'state'); - $queries = FreshRSS_Context::$user_conf->queries; - $query = Minz_Request::params(); - $query['name'] = _t('conf.query.number', count($queries) + 1); - foreach ($query as $key => $value) { - if (!in_array($key, $whitelist)) { - unset($query[$key]); - } + $category_dao = new FreshRSS_CategoryDAO(); + $feed_dao = FreshRSS_Factory::createFeedDao(); + $queries = array(); + foreach (FreshRSS_Context::$user_conf->queries as $key => $query) { + $queries[$key] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao); } - $queries[] = $query; + $params = Minz_Request::params(); + $params['url'] = Minz_Url::display(array('params' => $params)); + $params['name'] = _t('conf.query.number', count($queries) + 1); + $queries[] = new FreshRSS_UserQuery($params, $feed_dao, $category_dao); + FreshRSS_Context::$user_conf->queries = $queries; FreshRSS_Context::$user_conf->save(); diff --git a/app/Exceptions/DAOException.php b/app/Exceptions/DAOException.php new file mode 100644 index 000000000..6bd8f4ff0 --- /dev/null +++ b/app/Exceptions/DAOException.php @@ -0,0 +1,5 @@ +prefix . 'category`(name) VALUES(?)'; $stm = $this->bd->prepare($sql); diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php index eeb1f2f4c..d7689752f 100644 --- a/app/Models/ConfigurationSetter.php +++ b/app/Models/ConfigurationSetter.php @@ -117,12 +117,7 @@ class FreshRSS_ConfigurationSetter { private function _queries(&$data, $values) { $data['queries'] = array(); foreach ($values as $value) { - $value = array_filter($value); - $params = $value; - unset($params['name']); - unset($params['url']); - $value['url'] = Minz_Url::display(array('params' => $params)); - $data['queries'][] = $value; + $data['queries'][] = $value->toArray(); } } diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index cf75a02c9..b8a1a43b0 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -1,6 +1,6 @@ prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history, ttl) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)'; $stm = $this->bd->prepare($sql); diff --git a/app/Models/Searchable.php b/app/Models/Searchable.php new file mode 100644 index 000000000..d5bcea49d --- /dev/null +++ b/app/Models/Searchable.php @@ -0,0 +1,6 @@ +category_dao = $category_dao; + $this->feed_dao = $feed_dao; + if (isset($query['get'])) { + $this->parseGet($query['get']); + } + if (isset($query['name'])) { + $this->name = $query['name']; + } + if (isset($query['order'])) { + $this->order = $query['order']; + } + if (!isset($query['search'])) { + $query['search'] = ''; + } + // linked to deeply with the search object, need to use dependency injection + $this->search = new FreshRSS_Search($query['search']); + if (isset($query['state'])) { + $this->state = $query['state']; + } + if (isset($query['url'])) { + $this->url = $query['url']; + } + } + + /** + * Convert the current object to an array. + * + * @return array + */ + public function toArray() { + return array_filter(array( + 'get' => $this->get, + 'name' => $this->name, + 'order' => $this->order, + 'search' => $this->search->__toString(), + 'state' => $this->state, + 'url' => $this->url, + )); + } + + /** + * Parse the get parameter in the query string to extract its name and + * type + * + * @param string $get + */ + private function parseGet($get) { + $this->get = $get; + if (preg_match('/(?P[acfs])(_(?P\d+))?/', $get, $matches)) { + switch ($matches['type']) { + case 'a': + $this->parseAll(); + break; + case 'c': + $this->parseCategory($matches['id']); + break; + case 'f': + $this->parseFeed($matches['id']); + break; + case 's': + $this->parseFavorite(); + break; + } + } + } + + /** + * Parse the query string when it is an "all" query + */ + private function parseAll() { + $this->get_name = 'all'; + $this->get_type = 'all'; + } + + /** + * Parse the query string when it is a "category" query + * + * @param integer $id + * @throws FreshRSS_DAOException + */ + private function parseCategory($id) { + if (is_null($this->category_dao)) { + throw new FreshRSS_DAOException('Category DAO is not loaded i UserQuery'); + } + $category = $this->category_dao->searchById($id); + if ($category) { + $this->get_name = $category->name(); + } else { + $this->deprecated = true; + } + $this->get_type = 'category'; + } + + /** + * Parse the query string when it is a "feed" query + * + * @param integer $id + * @throws FreshRSS_DAOException + */ + private function parseFeed($id) { + if (is_null($this->feed_dao)) { + throw new FreshRSS_DAOException('Feed DAO is not loaded i UserQuery'); + } + $feed = $this->feed_dao->searchById($id); + if ($feed) { + $this->get_name = $feed->name(); + } else { + $this->deprecated = true; + } + $this->get_type = 'feed'; + } + + /** + * Parse the query string when it is a "favorite" query + */ + private function parseFavorite() { + $this->get_name = 'favorite'; + $this->get_type = 'favorite'; + } + + /** + * Check if the current user query is deprecated. + * It is deprecated if the category or the feed used in the query are + * not existing. + * + * @return boolean + */ + public function isDeprecated() { + return $this->deprecated; + } + + /** + * Check if the user query has parameters. + * If the type is 'all', it is considered equal to no parameters + * + * @return boolean + */ + public function hasParameters() { + if ($this->get_type === 'all') { + return false; + } + if ($this->hasSearch()) { + return true; + } + if ($this->state) { + return true; + } + if ($this->order) { + return true; + } + if ($this->get) { + return true; + } + return false; + } + + /** + * Check if there is a search in the search object + * + * @return boolean + */ + public function hasSearch() { + return $this->search->getRawInput() != ""; + } + + public function getGet() { + return $this->get; + } + + public function getGetName() { + return $this->get_name; + } + + public function getGetType() { + return $this->get_type; + } + + public function getName() { + return $this->name; + } + + public function getOrder() { + return $this->order; + } + + public function getSearch() { + return $this->search; + } + + public function getState() { + return $this->state; + } + + public function getUrl() { + return $this->url; + } + +} diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml index 5f449deb3..69efcf365 100644 --- a/app/views/configure/queries.phtml +++ b/app/views/configure/queries.phtml @@ -6,27 +6,28 @@ - queries as $key => $query) { ?> + queries as $key => $query) { ?>
- "/> - "/> - "/> - "/> + + + + +
- + @@ -35,23 +36,11 @@
- query_get[$key]) && - $this->query_get[$key]['deprecated']); - ?> - - + hasParameters()) { ?>
- + isDeprecated()) { ?>
@@ -60,20 +49,20 @@
    - -
  • + hasSearch()) { ?> +
  • getSearch()->getRawInput()); ?>
  • - -
  • + getState()) { ?> +
  • getState()); ?>
  • - -
  • + getOrder()) { ?> +
  • getOrder())); ?>
  • - -
  • query_get[$key]['type'], $this->query_get[$key]['name']); ?>
  • + getGet()) { ?> +
  • getGetType(), $query->getGetName()); ?>
diff --git a/tests/app/Models/UserQueryTest.php b/tests/app/Models/UserQueryTest.php new file mode 100644 index 000000000..2234be6e1 --- /dev/null +++ b/tests/app/Models/UserQueryTest.php @@ -0,0 +1,229 @@ + 'a'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertEquals('all', $user_query->getGetName()); + $this->assertEquals('all', $user_query->getGetType()); + } + + public function test__construct_whenFavoriteQuery_storesFavoriteParameters() { + $query = array('get' => 's'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertEquals('favorite', $user_query->getGetName()); + $this->assertEquals('favorite', $user_query->getGetType()); + } + + /** + * @expectedException Exceptions/FreshRSS_DAOException + * @expectedExceptionMessage Category DAO is not loaded in UserQuery + */ + public function test__construct_whenCategoryQueryAndNoDao_throwsException() { + $this->markTestIncomplete('There is a problem with the exception autoloading. We need to make a better autoloading process'); + $query = array('get' => 'c_1'); + new FreshRSS_UserQuery($query); + } + + public function test__construct_whenCategoryQuery_storesCategoryParameters() { + $category_name = 'some category name'; + $cat = $this->getMock('FreshRSS_Category'); + $cat->expects($this->atLeastOnce()) + ->method('name') + ->withAnyParameters() + ->willReturn($category_name); + $cat_dao = $this->getMock('FreshRSS_Searchable'); + $cat_dao->expects($this->atLeastOnce()) + ->method('searchById') + ->withAnyParameters() + ->willReturn($cat); + $query = array('get' => 'c_1'); + $user_query = new FreshRSS_UserQuery($query, null, $cat_dao); + $this->assertEquals($category_name, $user_query->getGetName()); + $this->assertEquals('category', $user_query->getGetType()); + } + + /** + * @expectedException Exceptions/FreshRSS_DAOException + * @expectedExceptionMessage Feed DAO is not loaded in UserQuery + */ + public function test__construct_whenFeedQueryAndNoDao_throwsException() { + $this->markTestIncomplete('There is a problem with the exception autoloading. We need to make a better autoloading process'); + $query = array('get' => 'c_1'); + new FreshRSS_UserQuery($query); + } + + public function test__construct_whenFeedQuery_storesFeedParameters() { + $feed_name = 'some feed name'; + $feed = $this->getMock('FreshRSS_Feed', array(), array('', false)); + $feed->expects($this->atLeastOnce()) + ->method('name') + ->withAnyParameters() + ->willReturn($feed_name); + $feed_dao = $this->getMock('FreshRSS_Searchable'); + $feed_dao->expects($this->atLeastOnce()) + ->method('searchById') + ->withAnyParameters() + ->willReturn($feed); + $query = array('get' => 'f_1'); + $user_query = new FreshRSS_UserQuery($query, $feed_dao, null); + $this->assertEquals($feed_name, $user_query->getGetName()); + $this->assertEquals('feed', $user_query->getGetType()); + } + + public function test__construct_whenUnknownQuery_doesStoreParameters() { + $query = array('get' => 'q'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertNull($user_query->getGetName()); + $this->assertNull($user_query->getGetType()); + } + + public function test__construct_whenName_storesName() { + $name = 'some name'; + $query = array('name' => $name); + $user_query = new FreshRSS_UserQuery($query); + $this->assertEquals($name, $user_query->getName()); + } + + public function test__construct_whenOrder_storesOrder() { + $order = 'some order'; + $query = array('order' => $order); + $user_query = new FreshRSS_UserQuery($query); + $this->assertEquals($order, $user_query->getOrder()); + } + + public function test__construct_whenState_storesState() { + $state = 'some state'; + $query = array('state' => $state); + $user_query = new FreshRSS_UserQuery($query); + $this->assertEquals($state, $user_query->getState()); + } + + public function test__construct_whenUrl_storesUrl() { + $url = 'some url'; + $query = array('url' => $url); + $user_query = new FreshRSS_UserQuery($query); + $this->assertEquals($url, $user_query->getUrl()); + } + + public function testToArray_whenNoData_returnsEmptyArray() { + $user_query = new FreshRSS_UserQuery(array()); + $this->assertInternalType('array', $user_query->toArray()); + $this->assertCount(0, $user_query->toArray()); + } + + public function testToArray_whenData_returnsArray() { + $query = array( + 'get' => 's', + 'name' => 'some name', + 'order' => 'some order', + 'search' => 'some search', + 'state' => 'some state', + 'url' => 'some url', + ); + $user_query = new FreshRSS_UserQuery($query); + $this->assertInternalType('array', $user_query->toArray()); + $this->assertCount(6, $user_query->toArray()); + $this->assertEquals($query, $user_query->toArray()); + } + + public function testHasSearch_whenSearch_returnsTrue() { + $query = array( + 'search' => 'some search', + ); + $user_query = new FreshRSS_UserQuery($query); + $this->assertTrue($user_query->hasSearch()); + } + + public function testHasSearch_whenNoSearch_returnsFalse() { + $user_query = new FreshRSS_UserQuery(array()); + $this->assertFalse($user_query->hasSearch()); + } + + public function testHasParameters_whenAllQuery_returnsFalse() { + $query = array('get' => 'a'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertFalse($user_query->hasParameters()); + } + + public function testHasParameters_whenNoParameter_returnsFalse() { + $query = array(); + $user_query = new FreshRSS_UserQuery($query); + $this->assertFalse($user_query->hasParameters()); + } + + public function testHasParameters_whenParameter_returnTrue() { + $query = array('get' => 's'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertTrue($user_query->hasParameters()); + } + + public function testIsDeprecated_whenCategoryExists_returnFalse() { + $cat = $this->getMock('FreshRSS_Category'); + $cat_dao = $this->getMock('FreshRSS_Searchable'); + $cat_dao->expects($this->atLeastOnce()) + ->method('searchById') + ->withAnyParameters() + ->willReturn($cat); + $query = array('get' => 'c_1'); + $user_query = new FreshRSS_UserQuery($query, null, $cat_dao); + $this->assertFalse($user_query->isDeprecated()); + } + + public function testIsDeprecated_whenCategoryDoesNotExist_returnTrue() { + $cat_dao = $this->getMock('FreshRSS_Searchable'); + $cat_dao->expects($this->atLeastOnce()) + ->method('searchById') + ->withAnyParameters() + ->willReturn(null); + $query = array('get' => 'c_1'); + $user_query = new FreshRSS_UserQuery($query, null, $cat_dao); + $this->assertTrue($user_query->isDeprecated()); + } + + public function testIsDeprecated_whenFeedExists_returnFalse() { + $feed = $this->getMock('FreshRSS_Feed', array(), array('', false)); + $feed_dao = $this->getMock('FreshRSS_Searchable'); + $feed_dao->expects($this->atLeastOnce()) + ->method('searchById') + ->withAnyParameters() + ->willReturn($feed); + $query = array('get' => 'f_1'); + $user_query = new FreshRSS_UserQuery($query, $feed_dao, null); + $this->assertFalse($user_query->isDeprecated()); + } + + public function testIsDeprecated_whenFeedDoesNotExist_returnTrue() { + $feed_dao = $this->getMock('FreshRSS_Searchable'); + $feed_dao->expects($this->atLeastOnce()) + ->method('searchById') + ->withAnyParameters() + ->willReturn(null); + $query = array('get' => 'f_1'); + $user_query = new FreshRSS_UserQuery($query, $feed_dao, null); + $this->assertTrue($user_query->isDeprecated()); + } + + public function testIsDeprecated_whenAllQuery_returnFalse() { + $query = array('get' => 'a'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertFalse($user_query->isDeprecated()); + } + + public function testIsDeprecated_whenFavoriteQuery_returnFalse() { + $query = array('get' => 's'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertFalse($user_query->isDeprecated()); + } + + public function testIsDeprecated_whenUnknownQuery_returnFalse() { + $query = array('get' => 'q'); + $user_query = new FreshRSS_UserQuery($query); + $this->assertFalse($user_query->isDeprecated()); + } + +} -- cgit v1.2.3 From 96d5d9d034daadb2357f27b3763854b647f2086c Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Thu, 5 Mar 2015 06:45:00 -0500 Subject: Fix DAO exception Change the name and messages --- app/Exceptions/DAOException.php | 2 +- app/Models/UserQuery.php | 8 ++++---- tests/app/Models/UserQueryTest.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/Exceptions/DAOException.php b/app/Exceptions/DAOException.php index 6bd8f4ff0..e48e521ab 100644 --- a/app/Exceptions/DAOException.php +++ b/app/Exceptions/DAOException.php @@ -1,5 +1,5 @@ category_dao)) { - throw new FreshRSS_DAOException('Category DAO is not loaded i UserQuery'); + throw new FreshRSS_DAO_Exception('Category DAO is not loaded in UserQuery'); } $category = $this->category_dao->searchById($id); if ($category) { @@ -123,11 +123,11 @@ class FreshRSS_UserQuery { * Parse the query string when it is a "feed" query * * @param integer $id - * @throws FreshRSS_DAOException + * @throws FreshRSS_DAO_Exception */ private function parseFeed($id) { if (is_null($this->feed_dao)) { - throw new FreshRSS_DAOException('Feed DAO is not loaded i UserQuery'); + throw new FreshRSS_DAO_Exception('Feed DAO is not loaded in UserQuery'); } $feed = $this->feed_dao->searchById($id); if ($feed) { diff --git a/tests/app/Models/UserQueryTest.php b/tests/app/Models/UserQueryTest.php index 2234be6e1..a0928d5ae 100644 --- a/tests/app/Models/UserQueryTest.php +++ b/tests/app/Models/UserQueryTest.php @@ -20,7 +20,7 @@ class UserQueryTest extends \PHPUnit_Framework_TestCase { } /** - * @expectedException Exceptions/FreshRSS_DAOException + * @expectedException Exceptions/FreshRSS_DAO_Exception * @expectedExceptionMessage Category DAO is not loaded in UserQuery */ public function test__construct_whenCategoryQueryAndNoDao_throwsException() { @@ -48,7 +48,7 @@ class UserQueryTest extends \PHPUnit_Framework_TestCase { } /** - * @expectedException Exceptions/FreshRSS_DAOException + * @expectedException Exceptions/FreshRSS_DAO_Exception * @expectedExceptionMessage Feed DAO is not loaded in UserQuery */ public function test__construct_whenFeedQueryAndNoDao_throwsException() { -- cgit v1.2.3 From 24f6c1eabb4cea941e40307c2f732c0ca384ffd2 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Thu, 5 Mar 2015 06:47:13 -0500 Subject: Fix spacing --- app/Models/CategoryDAO.php | 2 +- app/Models/EntryDAO.php | 2 +- app/Models/FeedDAO.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index 4eee226ba..189a5f0e4 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -1,6 +1,6 @@ prefix . 'category`(name) VALUES(?)'; $stm = $this->bd->prepare($sql); diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index b8a1a43b0..9736d5cd3 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -1,6 +1,6 @@ prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history, ttl) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)'; $stm = $this->bd->prepare($sql); -- cgit v1.2.3 From dd4fb519be801254a8aa9baedb2a7f87dd608f2b Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 14 Mar 2015 09:43:08 -0400 Subject: Add an unsaved changes alert on config pages Before, you could leave a configuration page without knowing if you saved your changes or not. Now, there is an alert poping up if you have unsaved changes. It will ask you if you want to stay on the page and save your changes or leave the page and loose your changes. See #739 --- app/views/auth/index.phtml | 12 ++++++------ app/views/configure/archiving.phtml | 6 +++--- app/views/configure/display.phtml | 28 ++++++++++++++-------------- app/views/configure/queries.phtml | 1 + app/views/configure/reading.phtml | 34 +++++++++++++++++----------------- app/views/configure/sharing.phtml | 4 ++-- app/views/configure/shortcut.phtml | 28 ++++++++++++++-------------- p/scripts/main.js | 28 ++++++++++++++++++++++++++++ 8 files changed, 85 insertions(+), 56 deletions(-) (limited to 'app') diff --git a/app/views/auth/index.phtml b/app/views/auth/index.phtml index f7a862ac9..8e4df8c2c 100644 --- a/app/views/auth/index.phtml +++ b/app/views/auth/index.phtml @@ -9,7 +9,7 @@
- auth_type, array('form', 'persona', 'http_auth', 'none'))) { ?> @@ -25,7 +25,7 @@
@@ -35,7 +35,7 @@
@@ -45,7 +45,7 @@
@@ -58,7 +58,7 @@ token; ?>
/> + echo FreshRSS_Auth::accessNeedsAction() ? '' : ' disabled="disabled"'; ?> data-leave-validation=""/> array('output' => 'rss', 'token' => $token)), 'html', true); ?>
@@ -69,7 +69,7 @@
diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index 875463137..52ee98a48 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -10,14 +10,14 @@
- +  
- ttl_default; ?>"> '20min', 1500 => '25min', 1800 => '30min', 2700 => '45min', 3600 => '1h', 5400 => '1.5h', 7200 => '2h', 10800 => '3h', 14400 => '4h', 18800 => '5h', 21600 => '6h', 25200 => '7h', 28800 => '8h', diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 02249bc55..91b0b8189 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -9,7 +9,7 @@
- @@ -24,7 +24,7 @@
    themes); $i = 1; ?> themes as $theme) { ?> - theme === $theme['id']) {echo "checked";}?> value=""/> + theme === $theme['id']) {echo "checked";}?> value="" data-leave-validation="theme === $theme['id']) ? 1 : 0; ?>"/>
  • @@ -53,7 +53,7 @@
    - @@ -87,20 +87,20 @@ - topline_read ? ' checked="checked"' : ''; ?> /> - topline_favorite ? ' checked="checked"' : ''; ?> /> + topline_read ? ' checked="checked"' : ''; ?> data-leave-validation="topline_read; ?>"/> + topline_favorite ? ' checked="checked"' : ''; ?> data-leave-validation="topline_favorite; ?>"/> - topline_date ? ' checked="checked"' : ''; ?> /> - topline_link ? ' checked="checked"' : ''; ?> /> + topline_date ? ' checked="checked"' : ''; ?> data-leave-validation="topline_date; ?>"/> + topline_link ? ' checked="checked"' : ''; ?> data-leave-validation="topline_link; ?>"/> - bottomline_read ? ' checked="checked"' : ''; ?> /> - bottomline_favorite ? ' checked="checked"' : ''; ?> /> - bottomline_sharing ? ' checked="checked"' : ''; ?> /> - bottomline_tags ? ' checked="checked"' : ''; ?> /> - bottomline_date ? ' checked="checked"' : ''; ?> /> - bottomline_link ? ' checked="checked"' : ''; ?> /> + bottomline_read ? ' checked="checked"' : ''; ?> data-leave-validation="bottomline_read; ?>"/> + bottomline_favorite ? ' checked="checked"' : ''; ?> data-leave-validation="bottomline_favorite; ?>"/> + bottomline_sharing ? ' checked="checked"' : ''; ?> data-leave-validation="bottomline_sharing; ?>"/> + bottomline_tags ? ' checked="checked"' : ''; ?> data-leave-validation="bottomline_tags; ?>"/> + bottomline_date ? ' checked="checked"' : ''; ?> data-leave-validation="bottomline_date; ?>"/> + bottomline_link ? ' checked="checked"' : ''; ?> data-leave-validation="bottomline_link; ?>"/>
    @@ -109,7 +109,7 @@
    - +
    diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml index 69efcf365..50df4cfea 100644 --- a/app/views/configure/queries.phtml +++ b/app/views/configure/queries.phtml @@ -25,6 +25,7 @@ id="queries__name" name="queries[][name]" value="getName(); ?>" + data-leave-validation="getName(); ?>" /> diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml index 636671f14..8b123afa8 100644 --- a/app/views/configure/reading.phtml +++ b/app/views/configure/reading.phtml @@ -9,7 +9,7 @@
    - +
    @@ -17,7 +17,7 @@
    - @@ -27,7 +27,7 @@
    - @@ -38,7 +38,7 @@
    - @@ -49,7 +49,7 @@
    @@ -58,7 +58,7 @@
    @@ -68,7 +68,7 @@
    @@ -78,7 +78,7 @@
    @@ -88,7 +88,7 @@
    @@ -98,7 +98,7 @@
    @@ -108,7 +108,7 @@
    @@ -118,7 +118,7 @@
    @@ -129,19 +129,19 @@
    @@ -151,7 +151,7 @@
    diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index deb1ed6b7..7bf435777 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -28,9 +28,9 @@
    - + formType() === 'advanced') { ?> - + diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml index f68091af9..264a5f805 100644 --- a/app/views/configure/shortcut.phtml +++ b/app/views/configure/shortcut.phtml @@ -23,28 +23,28 @@
    - +
    - +
    - +
    - +
    @@ -53,7 +53,7 @@
    - +
    @@ -61,21 +61,21 @@
    - +
    - +
    - +
    @@ -83,7 +83,7 @@
    - +
    @@ -92,21 +92,21 @@
    - +
    - +
    - +
    @@ -114,14 +114,14 @@
    - +
    - +
    diff --git a/p/scripts/main.js b/p/scripts/main.js index b7c143cc1..eaf6067f7 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1229,6 +1229,33 @@ function init_slider_observers() { }); } +function init_configuration_alert() { + $(window).on('beforeunload', function(e){ + if (e.originalEvent.explicitOriginalTarget.type === 'submit') { + // we don't want an alert when submitting the form with the submit button + return; + } + if ($(e.originalEvent.explicitOriginalTarget).attr('data-leave-validation') !== undefined) { + // we don't want an alert when submitting the form by pressing the enter key + return; + } + var fields = $("[data-leave-validation]"); + for (var i = 0; i < fields.length; i++) { + if ($(fields[i]).attr('type') === 'checkbox' || $(fields[i]).attr('type') === 'radio') { + // The use of != is done on purpose to check boolean against integer + if ($(fields[i]).is(':checked') != $(fields[i]).attr('data-leave-validation')) { + return false; + } + } else { + if ($(fields[i]).attr('data-leave-validation') !== $(fields[i]).val()) { + return false; + } + } + } + return; + }); +} + function init_all() { if (!(window.$ && window.context)) { if (window.console) { @@ -1260,6 +1287,7 @@ function init_all() { init_password_observers(); init_stats_observers(); init_slider_observers(); + init_configuration_alert(); } if (window.console) { -- cgit v1.2.3 From 1a35e2271d3b9383e882371d37d5fef16abd745d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 21 Mar 2015 18:20:36 +0100 Subject: SimplePie option to restaure syslog of HTTP requests https://github.com/FreshRSS/FreshRSS/issues/711 --- app/Models/Feed.php | 4 ++-- data/config.default.php | 1 + lib/SimplePie/SimplePie.php | 41 ++++++++++++++++++++++++++++++++++------ lib/SimplePie/SimplePie/File.php | 7 +++++-- lib/lib_rss.php | 1 + 5 files changed, 44 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 5ce03be5d..5f67ea6ce 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -246,10 +246,10 @@ class FreshRSS_Feed extends Minz_Model { } if (($mtime === true) ||($mtime > $this->lastUpdate)) { - Minz_Log::notice('FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $clean_url); + //Minz_Log::debug('FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $clean_url); $this->loadEntries($feed); // et on charge les articles du flux } else { - Minz_Log::notice('FreshRSS use cache for ' . $clean_url); + //Minz_Log::debug('FreshRSS use cache for ' . $clean_url); $this->entries = array(); } diff --git a/data/config.default.php b/data/config.default.php index 97df3a299..839bd1687 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -12,6 +12,7 @@ return array( 'auth_type' => 'none', 'api_enabled' => false, 'unsafe_autologin_enabled' => false, + 'simplepie_syslog_enabled' => true, 'limits' => array( 'cache_duration' => 800, 'timeout' => 10, diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index c4872b5be..bb8ce4191 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -74,6 +74,12 @@ define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed */ define('SIMPLEPIE_LINKBACK', '' . SIMPLEPIE_NAME . ''); +/** + * Use syslog to report HTTP requests done by SimplePie. + * @see SimplePie::set_syslog() + */ +define('SIMPLEPIE_SYSLOG', true); //FreshRSS + /** * No Autodiscovery * @see SimplePie::set_autodiscovery_level() @@ -622,6 +628,12 @@ class SimplePie */ public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); + /** + * Use syslog to report HTTP requests done by SimplePie. + * @see SimplePie::set_syslog() + */ + public $syslog_enabled = SIMPLEPIE_SYSLOG; + /** * The SimplePie class contains feed level data and options * @@ -1136,7 +1148,7 @@ class SimplePie $this->sanitize->strip_attributes($attribs); } - public function add_attributes($attribs = '') + public function add_attributes($attribs = '') //FreshRSS { if ($attribs === '') { @@ -1145,6 +1157,14 @@ class SimplePie $this->sanitize->add_attributes($attribs); } + /** + * Use syslog to report HTTP requests done by SimplePie. + */ + public function set_syslog($value = SIMPLEPIE_SYSLOG) //FreshRSS + { + $this->syslog_enabled = $value == true; + } + /** * Set the output encoding * @@ -1231,7 +1251,8 @@ class SimplePie $this->enable_exceptions = $enable; } - function cleanMd5($rss) { //FreshRSS + function cleanMd5($rss) //FreshRSS + { return md5(preg_replace(array('#<(lastBuildDate|pubDate|updated|feedDate|dc:date|slash:comments)>[^<]+#', '##s'), '', $rss)); } @@ -1329,7 +1350,8 @@ class SimplePie list($headers, $sniffed) = $fetched; - if (isset($this->data['md5'])) { //FreshRSS + if (isset($this->data['md5'])) //FreshRSS + { $md5 = $this->data['md5']; } } @@ -1455,7 +1477,8 @@ class SimplePie { // Load the Cache $this->data = $cache->load(); - if ($cache->mtime() + $this->cache_duration > time()) { //FreshRSS + if ($cache->mtime() + $this->cache_duration > time()) //FreshRSS + { $this->raw_data = false; return true; // If the cache is still valid, just return true } @@ -1529,11 +1552,17 @@ class SimplePie { //FreshRSS $md5 = $this->cleanMd5($file->body); if ($this->data['md5'] === $md5) { - // syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url); + if ($this->syslog_enabled) + { + syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url); + } $cache->touch(); return true; //Content unchanged even though server did not send a 304 } else { - // syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url); + if ($this->syslog_enabled) + { + syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url); + } $this->data['md5'] = $md5; } } diff --git a/lib/SimplePie/SimplePie/File.php b/lib/SimplePie/SimplePie/File.php index 9625af2a9..56fe72196 100644 --- a/lib/SimplePie/SimplePie/File.php +++ b/lib/SimplePie/SimplePie/File.php @@ -66,7 +66,7 @@ class SimplePie_File var $method = SIMPLEPIE_FILE_SOURCE_NONE; var $permanent_url; //FreshRSS - public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) + public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $syslog_enabled = SIMPLEPIE_SYSLOG) { if (class_exists('idna_convert')) { @@ -79,7 +79,10 @@ class SimplePie_File $this->useragent = $useragent; if (preg_match('/^http(s)?:\/\//i', $url)) { - // syslog(LOG_INFO, 'SimplePie GET ' . $url); //FreshRSS + if ($syslog_enabled) + { + syslog(LOG_INFO, 'SimplePie GET ' . $url); //FreshRSS + } if ($useragent === null) { $useragent = ini_get('user_agent'); diff --git a/lib/lib_rss.php b/lib/lib_rss.php index e5fe73041..16ae3097f 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -123,6 +123,7 @@ function customSimplePie() { $limits = $system_conf->limits; $simplePie = new SimplePie(); $simplePie->set_useragent(_t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); + $simplePie->set_syslog($system_conf->simplepie_syslog_enabled); $simplePie->set_cache_location(CACHE_PATH); $simplePie->set_cache_duration($limits['cache_duration']); $simplePie->set_timeout($limits['timeout']); -- cgit v1.2.3 From ad9fe52f5a76faf58d13fcf7bde8f58e85abe82b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 22 Mar 2015 22:54:29 +0100 Subject: SimplePie sanitize URLs for syslog https://github.com/FreshRSS/FreshRSS/issues/711 https://github.com/FreshRSS/FreshRSS/pull/715 --- app/Models/Feed.php | 2 +- lib/SimplePie/SimplePie.php | 4 ++-- lib/SimplePie/SimplePie/File.php | 2 +- lib/SimplePie/SimplePie/Misc.php | 10 ++++++++++ lib/lib_rss.php | 12 +----------- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'app') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 5f67ea6ce..15cbb7d0a 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -240,7 +240,7 @@ class FreshRSS_Feed extends Minz_Model { $subscribe_url = $feed->subscribe_url(true); } - $clean_url = url_remove_credentials($subscribe_url); + $clean_url = SimplePie_Misc::url_remove_credentials($subscribe_url); if ($subscribe_url !== null && $subscribe_url !== $url) { $this->_url($clean_url); } diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index bb8ce4191..54f4c5770 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -1554,14 +1554,14 @@ class SimplePie if ($this->data['md5'] === $md5) { if ($this->syslog_enabled) { - syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url); + syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . SimplePie_Misc::url_remove_credentials($this->feed_url)); } $cache->touch(); return true; //Content unchanged even though server did not send a 304 } else { if ($this->syslog_enabled) { - syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url); + syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . SimplePie_Misc::url_remove_credentials($this->feed_url)); } $this->data['md5'] = $md5; } diff --git a/lib/SimplePie/SimplePie/File.php b/lib/SimplePie/SimplePie/File.php index 56fe72196..1f9e3d502 100644 --- a/lib/SimplePie/SimplePie/File.php +++ b/lib/SimplePie/SimplePie/File.php @@ -81,7 +81,7 @@ class SimplePie_File { if ($syslog_enabled) { - syslog(LOG_INFO, 'SimplePie GET ' . $url); //FreshRSS + syslog(LOG_INFO, 'SimplePie GET ' . SimplePie_Misc::url_remove_credentials($url)); //FreshRSS } if ($useragent === null) { diff --git a/lib/SimplePie/SimplePie/Misc.php b/lib/SimplePie/SimplePie/Misc.php index 5a263a2e5..de50d37b8 100644 --- a/lib/SimplePie/SimplePie/Misc.php +++ b/lib/SimplePie/SimplePie/Misc.php @@ -2240,5 +2240,15 @@ function embed_wmedia(width, height, link) { { // No-op } + + /** + * Sanitize a URL by removing HTTP credentials. + * @param $url the URL to sanitize. + * @return the same URL without HTTP credentials. + */ + function url_remove_credentials($url) //FreshRSS + { + return preg_replace('#(?<=//)[^/:@]+:[^/:@]+@#', '', $url); + } } diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 16ae3097f..65a1a8e04 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -181,7 +181,7 @@ function sanitizeHTML($data, $base = '') { function get_content_by_parsing ($url, $path) { require_once (LIB_PATH . '/lib_phpQuery.php'); - Minz_Log::notice('FreshRSS GET ' . url_remove_credentials($url)); + Minz_Log::notice('FreshRSS GET ' . SimplePie_Misc::url_remove_credentials($url)); $html = file_get_contents ($url); if ($html) { @@ -430,13 +430,3 @@ function array_push_unique(&$array, $value) { function array_remove(&$array, $value) { $array = array_diff($array, array($value)); } - - -/** - * Sanitize a URL by removing HTTP credentials. - * @param $url the URL to sanitize. - * @return the same URL without HTTP credentials. - */ -function url_remove_credentials($url) { - return preg_replace('/[^\/]*:[^:]*@/', '', $url); -} -- cgit v1.2.3 From 239a010ef23127429698b6be5f4a5453b0bfbad7 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 24 Mar 2015 22:45:27 +0100 Subject: Error when deleting a feed https://github.com/FreshRSS/FreshRSS/issues/816 --- app/Models/ConfigurationSetter.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php index d7689752f..978cc8cb9 100644 --- a/app/Models/ConfigurationSetter.php +++ b/app/Models/ConfigurationSetter.php @@ -117,7 +117,9 @@ class FreshRSS_ConfigurationSetter { private function _queries(&$data, $values) { $data['queries'] = array(); foreach ($values as $value) { - $data['queries'][] = $value->toArray(); + if ($value != null) { + $data['queries'][] = $value->toArray(); + } } } -- cgit v1.2.3 From d7706b66f586b36e44e471b5c06526de258af8b8 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 24 Mar 2015 22:51:51 +0100 Subject: Error when deleting a feed, wrong object https://github.com/FreshRSS/FreshRSS/issues/816 --- app/Models/ConfigurationSetter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php index 978cc8cb9..7f433239c 100644 --- a/app/Models/ConfigurationSetter.php +++ b/app/Models/ConfigurationSetter.php @@ -117,7 +117,7 @@ class FreshRSS_ConfigurationSetter { private function _queries(&$data, $values) { $data['queries'] = array(); foreach ($values as $value) { - if ($value != null) { + if ($value instanceof FreshRSS_UserQuery) { $data['queries'][] = $value->toArray(); } } -- cgit v1.2.3 From 4744a2a2d82f2b18df70b37f8cff5043dde12770 Mon Sep 17 00:00:00 2001 From: Tets Date: Thu, 26 Mar 2015 09:27:23 +0100 Subject: Added Czech translation --- app/i18n/cz/admin.php | 170 +++++++++++++++++++++++++++++++++++++++++++++++ app/i18n/cz/conf.php | 169 ++++++++++++++++++++++++++++++++++++++++++++++ app/i18n/cz/feedback.php | 110 ++++++++++++++++++++++++++++++ app/i18n/cz/gen.php | 164 +++++++++++++++++++++++++++++++++++++++++++++ app/i18n/cz/index.php | 61 +++++++++++++++++ app/i18n/cz/install.php | 107 +++++++++++++++++++++++++++++ app/i18n/cz/sub.php | 61 +++++++++++++++++ 7 files changed, 842 insertions(+) create mode 100644 app/i18n/cz/admin.php create mode 100644 app/i18n/cz/conf.php create mode 100644 app/i18n/cz/feedback.php create mode 100644 app/i18n/cz/gen.php create mode 100644 app/i18n/cz/index.php create mode 100644 app/i18n/cz/install.php create mode 100644 app/i18n/cz/sub.php (limited to 'app') diff --git a/app/i18n/cz/admin.php b/app/i18n/cz/admin.php new file mode 100644 index 000000000..b9ef707cf --- /dev/null +++ b/app/i18n/cz/admin.php @@ -0,0 +1,170 @@ + array( + 'allow_anonymous' => 'Umožnit anonymně číst články výchozího uživatele (%s)', + 'allow_anonymous_refresh' => 'Umožnit anonymní obnovení článků', + 'api_enabled' => 'Povolit přístup k API (vyžadováno mobilními aplikacemi)', + 'form' => 'Webový formulář (tradiční, vyžaduje JavaScript)', + 'http' => 'HTTP (pro pokročilé uživatele s HTTPS)', + 'none' => 'Žádný (nebezpečné)', + 'persona' => 'Mozilla Persona (moderní, vyžaduje JavaScript)', + 'title' => 'Přihlášení', + 'title_reset' => 'Reset přihlášení', + 'token' => 'Authentizační token', + 'token_help' => 'Umožňuje přístup k RSS kanálu článků výchozího uživatele bez přihlášení:', + 'type' => 'Způsob přihlášení', + 'unsafe_autologin' => 'Povolit nebezpečné automatické přihlášení přes: ', + ), + 'check_install' => array( + 'cache' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/cache. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře cache jsou v pořádku.', + ), + 'categories' => array( + 'nok' => 'Tabulka kategorií je nastavena špatně.', + 'ok' => 'Tabulka kategorií je v pořádku.', + ), + 'connection' => array( + 'nok' => 'Nelze navázat spojení s databází.', + 'ok' => 'Připojení k databázi je v pořádku.', + ), + 'ctype' => array( + 'nok' => 'Nemáte požadovanou knihovnu pro ověřování znaků (php-ctype).', + 'ok' => 'Máte požadovanou knihovnu pro ověřování znaků (ctype).', + ), + 'curl' => array( + 'nok' => 'Nemáte cURL (balíček php5-curl).', + 'ok' => 'Máte rozšíření cURL.', + ), + 'data' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře data jsou v pořádku.', + ), + 'database' => 'Instalace databáze', + 'dom' => array( + 'nok' => 'Nemáte požadovanou knihovnu pro procházení DOM (balíček php-xml).', + 'ok' => 'Máte požadovanou knihovnu pro procházení DOM.', + ), + 'entries' => array( + 'nok' => 'Tabulka článků je nastavena špatně.', + 'ok' => 'Tabulka kategorií je v pořádku.', + ), + 'favicons' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/favicons. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře favicons jsou v pořádku.', + ), + 'feeds' => array( + 'nok' => 'Tabulka kanálů je nastavena špatně.', + 'ok' => 'Tabulka kanálů je v pořádku.', + ), + 'files' => 'Instalace souborů', + 'json' => array( + 'nok' => 'Nemáte JSON (balíček php5-json).', + 'ok' => 'Máte rozšíření JSON.', + ), + 'minz' => array( + 'nok' => 'Nemáte framework Minz.', + 'ok' => 'Máte framework Minz.', + ), + 'pcre' => array( + 'nok' => 'Nemáte požadovanou knihovnu pro regulární výrazy (php-pcre).', + 'ok' => 'Máte požadovanou knihovnu pro regulární výrazy (PCRE).', + ), + 'pdo' => array( + 'nok' => 'Nemáte PDO nebo některý z podporovaných ovladačů (pdo_mysql, pdo_sqlite).', + 'ok' => 'Máte PDO a alespoň jeden z podporovaných ovladačů (pdo_mysql, pdo_sqlite).', + ), + 'persona' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/persona. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře Mozilla Persona jsou v pořádku.', + ), + 'php' => array( + '_' => 'PHP instalace', + 'nok' => 'Vaše verze PHP je %s, ale FreshRSS vyžaduje alespoň verzi %s.', + 'ok' => 'Vaše verze PHP je %s a je kompatibilní s FreshRSS.', + ), + 'tables' => array( + 'nok' => 'V databázi chybí jedna nevo více tabulek.', + 'ok' => 'V databázi jsou všechny tabulky.', + ), + 'title' => 'Kontrola instalace', + 'tokens' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/tokens. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře tokens jsou v pořádku.', + ), + 'users' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/users. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře users jsou v pořádku.', + ), + 'zip' => array( + 'nok' => 'Nemáte rozšíření ZIP (balíček php5-zip).', + 'ok' => 'Máte rozšíření ZIP.', + ), + ), + 'extensions' => array( + 'disabled' => 'Vypnuto', + 'empty_list' => 'Není naistalováno žádné rozšíření', + 'enabled' => 'Zapnuto', + 'no_configure_view' => 'Toto rozšíření nemá žádné možnosti nastavení.', + 'system' => array( + '_' => 'Systémová rozšíření', + 'no_rights' => 'Systémová rozšíření (na ně nemáte oprávnění)', + ), + 'title' => 'Rozšíření', + 'user' => 'Uživatelská rozšíření', + ), + 'stats' => array( + '_' => 'Statistika', + 'all_feeds' => 'Všechny kanály', + 'category' => 'Kategorie', + 'entry_count' => 'Počet článků', + 'entry_per_category' => 'Článků na kategorii', + 'entry_per_day' => 'Článků za den (posledních 30 dní)', + 'entry_per_day_of_week' => 'Za den v týdnu (průměr: %.2f zprávy)', + 'entry_per_hour' => 'Za hodinu (průměr: %.2f zprávy)', + 'entry_per_month' => 'Za měsíc (průměr: %.2f zprávy)', + 'entry_repartition' => 'Rozdělení článků', + 'feed' => 'Kanál', + 'feed_per_category' => 'Článků na kategorii', + 'idle' => 'Neaktivní kanály', + 'main' => 'Přehled', + 'main_stream' => 'Všechny kanály', + 'menu' => array( + 'idle' => 'Neaktivní kanály', + 'main' => 'Přehled', + 'repartition' => 'Rozdělení článků', + ), + 'no_idle' => 'Žádné neaktivní kanály!', + 'number_entries' => '%d článků', + 'percent_of_total' => '%% ze všech', + 'repartition' => 'Rozdělení článků', + 'status_favorites' => 'Oblíbené', + 'status_read' => 'Přečtené', + 'status_total' => 'Celkem', + 'status_unread' => 'Nepřečtené', + 'title' => 'Statistika', + 'top_feed' => 'Top ten kanálů', + ), + 'update' => array( + '_' => 'Aktualizace systému', + 'apply' => 'Použít', + 'check' => 'Zkontrolovat aktualizace', + 'current_version' => 'Vaše instalace FreshRSS je verze %s.', + 'last' => 'Poslední kontrola: %s', + 'none' => 'Žádné nové aktualizace', + 'title' => 'Aktualizovat systém', + ), + 'user' => array( + 'articles_and_size' => '%s článků (%s)', + 'create' => 'Vytvořit nového uživatele', + 'email_persona' => 'Email pro přihlášení
    (pro Mozilla Persona)', + 'language' => 'Jazyk', + 'password_form' => 'Heslo
    (pro přihlášení webovým formulářem)', + 'password_format' => 'Alespoň 7 znaků', + 'title' => 'Správa uživatelů', + 'user_list' => 'Seznam uživatelů', + 'username' => 'Přihlašovací jméno', + 'users' => 'Uživatelé', + ), +); diff --git a/app/i18n/cz/conf.php b/app/i18n/cz/conf.php new file mode 100644 index 000000000..29fb1e4d4 --- /dev/null +++ b/app/i18n/cz/conf.php @@ -0,0 +1,169 @@ + array( + '_' => 'Archivace', + 'advanced' => 'Pokročilé', + 'delete_after' => 'Smazat články starší než', + 'help' => 'Více možností je dostupných v nastavení jednotlivých kanálů', + 'keep_history_by_feed' => 'Zachovat tento minimální počet článků v každém kanálu', + 'optimize' => 'Optimalizovat databázi', + 'optimize_help' => 'Občasná údržba zmenší velikost databáze', + 'purge_now' => 'Vyčistit nyní', + 'title' => 'Archivace', + 'ttl' => 'Neaktualizovat častěji než', + ), + 'display' => array( + '_' => 'Zobrazení', + 'icon' => array( + 'bottom_line' => 'Spodní řádek', + 'entry' => 'Ikony článků', + 'publication_date' => 'Datum vydání', + 'related_tags' => 'Související tagy', + 'sharing' => 'Sdílení', + 'top_line' => 'Horní řádek', + ), + 'language' => 'Jazyk', + 'notif_html5' => array( + 'seconds' => 'sekund (0 znamená žádný timeout)', + 'timeout' => 'Timeout HTML5 notifikací', + ), + 'theme' => 'Vzhled', + 'title' => 'Zobrazení', + 'width' => array( + 'content' => 'Šířka obsahu', + 'large' => 'Velká', + 'medium' => 'Střední', + 'no_limit' => 'Bez limitu', + 'thin' => 'Tenká', + ), + ), + 'query' => array( + '_' => 'Uživatelské dotazy', + 'deprecated' => 'Tento dotaz již není platný. Odkazovaná kategorie nebo kanál byly smazány.', + 'filter' => 'Filtr aplikován:', + 'get_all' => 'Zobrazit všechny články', + 'get_category' => 'Zobrazit "%s" kategorii', + 'get_favorite' => 'Zobrazit oblíbené články', + 'get_feed' => 'Zobrazit "%s" článkek', + 'no_filter' => 'Zrušit filtr', + 'none' => 'Ještě jste nevytvořil žádný uživatelský dotaz.', + 'number' => 'Dotaz n°%d', + 'order_asc' => 'Zobrazit nejdříve nejstarší články', + 'order_desc' => 'Zobrazit nejdříve nejnovější články', + 'search' => 'Hledat "%s"', + 'state_0' => 'Zobrazit všechny články', + 'state_1' => 'Zobrazit přečtené články', + 'state_2' => 'Zobrazit nepřečtené články', + 'state_3' => 'Zobrazit všechny články', + 'state_4' => 'Zobrazit oblíbené články', + 'state_5' => 'Zobrazit oblíbené přečtené články', + 'state_6' => 'Zobrazit oblíbené nepřečtené články', + 'state_7' => 'Zobrazit oblíbené články', + 'state_8' => 'Zobrazit všechny články vyjma oblíbených', + 'state_9' => 'Zobrazit všechny přečtené články vyjma oblíbených', + 'state_10' => 'Zobrazit všechny nepřečtené články vyjma oblíbených', + 'state_11' => 'Zobrazit všechny články vyjma oblíbených', + 'state_12' => 'Zobrazit všechny články', + 'state_13' => 'Zobrazit přečtené články', + 'state_14' => 'Zobrazit nepřečtené články', + 'state_15' => 'Zobrazit všechny články', + 'title' => 'Uživatelské dotazy', + ), + 'profile' => array( + '_' => 'Správa profilu', + 'email_persona' => 'Email pro přihlášení
    (pro
    Mozilla Persona)', + 'password_api' => 'Password API
    (tzn. pro mobilní aplikace)', + 'password_form' => 'Heslo
    (pro přihlášení webovým formulářem)', + 'password_format' => 'Alespoň 7 znaků', + 'title' => 'Profil', + ), + 'reading' => array( + '_' => 'Čtení', + 'after_onread' => 'Po “označit vše jako přečtené”,', + 'articles_per_page' => 'Počet článků na stranu', + 'auto_load_more' => 'Načítat další články dole na stránce', + 'auto_remove_article' => 'Po přečtení články schovat', + 'confirm_enabled' => 'Vyžadovat potvrzení pro akci “označit vše jako přečtené”', + 'display_articles_unfolded' => 'Ve výchozím stavu zobrazovat články otevřené', + 'display_categories_unfolded' => 'Ve výchozím stavu zobrazovat kategorie zavřené', + 'hide_read_feeds' => 'Schovat kategorie a kanály s nulovým počtem nepřečtených článků (nefunguje s nastavením “Zobrazit všechny články”)', + 'img_with_lazyload' => 'Použít "lazy load" mód pro načítaní obrázků', + 'jump_next' => 'skočit na další nepřečtený (kanál nebo kategorii)', + 'number_divided_when_reader' => 'V režimu “Čtení” děleno dvěma.', + 'read' => array( + 'article_open_on_website' => 'když je otevřen původní web s článkem', + 'article_viewed' => 'během čtení článku', + 'scroll' => 'během skrolování', + 'upon_reception' => 'po načtení článku', + 'when' => 'Označit článek jako přečtený…', + ), + 'show' => array( + '_' => 'Počet zobrazených článků', + 'adaptive' => 'Vyberte zobrazení', + 'all_articles' => 'Zobrazit všechny články', + 'unread' => 'Zobrazit jen nepřečtené', + ), + 'sort' => array( + '_' => 'Řazení', + 'newer_first' => 'Nejdříve nejnovější', + 'older_first' => 'Nejdříve nejstarší', + ), + 'sticky_post' => 'Při otevření posunout článek nahoru', + 'title' => 'Čtení', + 'view' => array( + 'default' => 'Výchozí', + 'global' => 'Přehled', + 'normal' => 'Normální', + 'reader' => 'Čtení', + ), + ), + 'sharing' => array( + '_' => 'Sdílení', + 'blogotext' => 'Blogotext', + 'diaspora' => 'Diaspora*', + 'email' => 'Email', + 'facebook' => 'Facebook', + 'g+' => 'Google+', + 'more_information' => 'Více informací', + 'print' => 'Tisk', + 'shaarli' => 'Shaarli', + 'share_name' => 'Jméno pro zobrazení', + 'share_url' => 'Jakou URL použít pro sdílení', + 'title' => 'Sdílení', + 'twitter' => 'Twitter', + 'wallabag' => 'wallabag', + ), + 'shortcut' => array( + '_' => 'Zkratky', + 'article_action' => 'Články - akce', + 'auto_share' => 'Sdílet', + 'auto_share_help' => 'Je-li nastavena pouze jedna možnost sdílení, bude použita. Další možnosti jsou dostupné pomocí jejich čísla.', + 'close_dropdown' => 'Zavřít menu', + 'collapse_article' => 'Srolovat', + 'first_article' => 'Skočit na první článek', + 'focus_search' => 'Hledání', + 'help' => 'Zobrazit documentaci', + 'javascript' => 'Pro použití zkratek musí být povolen JavaScript', + 'last_article' => 'Skočit na poslední článek', + 'load_more' => 'Načíst více článků', + 'mark_read' => 'Označit jako přečtené', + 'mark_favorite' => 'Označit jako oblíbené', + 'navigation' => 'Navigace', + 'navigation_help' => 'Pomocí přepínače "Shift" fungují navigační zkratky v rámci kanálů.
    Pomocí přepínače "Alt" fungují v rámci kategorií.', + 'next_article' => 'Skočit na další článek', + 'other_action' => 'Ostatní akce', + 'previous_article' => 'Skočit na předchozí článek', + 'see_on_website' => 'Navštívit původní webovou stránku', + 'shift_for_all_read' => '+ shift označí vše jako přečtené', + 'title' => 'Zkratky', + 'user_filter' => 'Aplikovat uživatelské filtry', + 'user_filter_help' => 'Je-li nastaven pouze jeden filtr, bude použit. Další filtry jsou dostupné pomocí jejich čísla.', + ), + 'user' => array( + 'articles_and_size' => '%s článků (%s)', + 'current' => 'Aktuální uživatel', + 'is_admin' => 'je administrátor', + 'users' => 'Uživatelé', + ), +); diff --git a/app/i18n/cz/feedback.php b/app/i18n/cz/feedback.php new file mode 100644 index 000000000..52ff029ef --- /dev/null +++ b/app/i18n/cz/feedback.php @@ -0,0 +1,110 @@ + array( + 'optimization_complete' => 'Optimalizace dokončena', + ), + 'access' => array( + 'denied' => 'Nemáte oprávnění přistupovat na tuto stránku', + 'not_found' => 'Tato stránka neexistuje', + ), + 'auth' => array( + 'form' => array( + 'not_set' => 'Nastal problém s konfigurací přihlašovacího systému. Zkuste to prosím později.', + 'set' => 'Webové formulář je nyní výchozí přihlašovací systém.', + ), + 'login' => array( + 'invalid' => 'Login není platný', + 'success' => 'Jste přihlášen', + ), + 'logout' => array( + 'success' => 'Jste odhlášen', + ), + 'no_password_set' => 'Heslo administrátora nebylo nastaveno. Tato funkce není k dispozici.', + 'not_persona' => 'Resetovat lze pouze systém Persona.', + ), + 'conf' => array( + 'error' => 'Během ukládání nastavení došlo k chybě', + 'query_created' => 'Dotaz "%s" byl vytvořen.', + 'shortcuts_updated' => 'Zkratky byly aktualizovány', + 'updated' => 'Nastavení bylo aktualizováno', + ), + 'extensions' => array( + 'already_enabled' => '%s je již zapnut', + 'disable' => array( + 'ko' => '%s nelze vypnout. Pro více detailů zkontrolujte logy FressRSS.', + 'ok' => '%s je nyní vypnut', + ), + 'enable' => array( + 'ko' => '%s nelze zapnout. Pro více detailů zkontrolujte logy FressRSS.', + 'ok' => '%s je nyní zapnut', + ), + 'no_access' => 'Nemáte přístup k %s', + 'not_enabled' => '%s není ještě zapnut', + 'not_found' => '%s neexistuje', + ), + 'import_export' => array( + 'export_no_zip_extension' => 'Na serveru není naistalována podpora zip. Zkuste prosím exportovat soubory jeden po druhém.', + 'feeds_imported' => 'Vaše kanály byly naimportovány a nyní budou aktualizovány', + 'feeds_imported_with_errors' => 'Vaše kanály byly naimportovány, došlo ale k nějakým chybám', + 'file_cannot_be_uploaded' => 'Soubor nelze nahrát!', + 'no_zip_extension' => 'Na serveru není naistalována podpora zip.', + 'zip_error' => 'Během importu zip souboru došlo k chybě.', + ), + 'sub' => array( + 'actualize' => 'Aktualizovat', + 'category' => array( + 'created' => 'Kategorie %s byla vytvořena.', + 'deleted' => 'Kategorie byla smazána.', + 'emptied' => 'Kategorie byla vyprázdněna', + 'error' => 'Kategorii nelze aktualizovat', + 'name_exists' => 'Název kategorie již existuje.', + 'no_id' => 'Musíte upřesnit id kategorie.', + 'no_name' => 'Název kategorie nemůže být prázdný.', + 'not_delete_default' => 'Nelze smazat výchozí kategorii!', + 'not_exist' => 'Tato kategorie neexistuje!', + 'over_max' => 'Dosáhl jste maximálního počtu kategorií (%d)', + 'updated' => 'Kategorie byla aktualizována.', + ), + 'feed' => array( + 'actualized' => '%s bylo aktualizováno', + 'actualizeds' => 'RSS kanály byly aktualizovány', + 'added' => 'RSS kanál %s byl přidán', + 'already_subscribed' => 'Již jste přihlášen k odběru %s', + 'deleted' => 'Kanál byl smazán', + 'error' => 'Kanál nelze aktualizovat', + 'internal_problem' => 'RSS kanál nelze přidat. Pro detaily zkontrolujte logy FressRSS.', + 'invalid_url' => 'URL %s není platné', + 'marked_read' => 'Kanály byly označeny jako přečtené', + 'n_actualized' => '%d kanálů bylo aktualizováno', + 'n_entries_deleted' => '%d článků bylo smazáno', + 'no_refresh' => 'Nelze obnovit žádné kanály…', + 'not_added' => '%s nemůže být přidán', + 'over_max' => 'Dosáhl jste maximálního počtu kanálů (%d)', + 'updated' => 'Kanál byl aktualizován', + ), + 'purge_completed' => 'Vyprázdněno (smazáno %d článků)', + ), + 'update' => array( + 'can_apply' => 'FreshRSS bude nyní upgradováno na verzi %s.', + 'error' => 'Během upgrade došlo k chybě: %s', + 'file_is_nok' => 'Zkontrolujte oprávnění adresáře %s. HTTP server musí mít do tohoto adresáře práva zápisu', + 'finished' => 'Upgrade hotov!', + 'none' => 'Novější verze není k dispozici', + 'server_not_found' => 'Nelze nalézt server s instalačním souborem. [%s]', + ), + 'user' => array( + 'created' => array( + '_' => 'Uživatel %s byl vytvořen', + 'error' => 'Uživatele %s nelze vytvořit', + ), + 'deleted' => array( + '_' => 'Uživatel %s byl smazán', + 'error' => 'Uživatele %s nelze smazat', + ), + ), + 'profile' => array( + 'error' => 'Váš profil nelze změnit', + 'updated' => 'Váš profil byl změněn', + ), +); diff --git a/app/i18n/cz/gen.php b/app/i18n/cz/gen.php new file mode 100644 index 000000000..7c333a9c8 --- /dev/null +++ b/app/i18n/cz/gen.php @@ -0,0 +1,164 @@ + array( + 'actualize' => 'Aktualizovat', + 'back_to_rss_feeds' => '← Zpět na seznam RSS kanálů', + 'cancel' => 'Zrušit', + 'create' => 'Vytvořit', + 'disable' => 'Zakázat', + 'empty' => 'Vyprázdnit', + 'enable' => 'Povolit', + 'export' => 'Export', + 'filter' => 'Filtrovat', + 'import' => 'Import', + 'manage' => 'Spravovat', + 'mark_read' => 'Označit jako přečtené', + 'mark_favorite' => 'Označit jako oblíbené', + 'remove' => 'Odstranit', + 'see_website' => 'Navštívit WWW stránku', + 'submit' => 'Odeslat', + 'truncate' => 'Smazat všechny články', + ), + 'auth' => array( + 'keep_logged_in' => 'Zapamatovat přihlášení (1 měsíc)', + 'login' => 'Login', + 'login_persona' => 'Přihlášení pomocí Persona', + 'login_persona_problem' => 'Problém s připojením k Persona?', + 'logout' => 'Odhlášení', + 'password' => 'Heslo', + 'reset' => 'Reset přihlášení', + 'username' => 'Uživatel', + 'username_admin' => 'Název administrátorského účtu', + 'will_reset' => 'Přihlašovací systém bude vyresetován: místo sytému Persona bude použito přihlášení formulářem.', + ), + 'date' => array( + 'Apr' => '\\D\\u\\b\\e\\n', + 'Aug' => '\\S\\r\\p\\e\\n', + 'Dec' => '\\P\\r\\o\\s\\i\\n\\e\\c', + 'Feb' => '\\Ú\\n\\o\\r', + 'Jan' => '\\L\\e\\d\\e\\n', + 'Jul' => '\\Č\\e\\r\\v\\e\\n\\e\\c', + 'Jun' => '\\Č\\e\\r\\v\\e\\n', + 'Mar' => '\\B\\ř\\e\\z\\e\\n', + 'May' => '\\K\\v\\ě\\t\\e\\n', + 'Nov' => '\\L\\i\\s\\t\\o\\p\\a\\d', + 'Oct' => '\\Ř\\í\\j\\e\\n', + 'Sep' => '\\Z\\á\\ř\\í', + 'apr' => 'dub', + 'april' => 'Dub', + 'aug' => 'srp', + 'august' => 'Srp', + 'before_yesterday' => 'Předevčírem', + 'dec' => 'pro', + 'december' => 'Pro', + 'feb' => 'úno', + 'february' => 'Úno', + 'format_date' => 'j\\. %s Y', + 'format_date_hour' => 'j\\. %s Y \\v H\\:i', + 'fri' => 'Pá', + 'jan' => 'led', + 'january' => 'Led', + 'jul' => 'čvn', + 'july' => 'Čvn', + 'jun' => 'čer', + 'june' => 'Čer', + 'last_3_month' => 'Minulé tři měsíce', + 'last_6_month' => 'Minulých šest měsíců', + 'last_month' => 'Minulý měsíc', + 'last_week' => 'Minulý týden', + 'last_year' => 'Minulý rok', + 'mar' => 'bře', + 'march' => 'Bře', + 'may' => 'Kvě', + 'mon' => 'Po', + 'month' => 'měsíce', + 'nov' => 'lis', + 'november' => 'Lis', + 'oct' => 'říj', + 'october' => 'Říj', + 'sat' => 'So', + 'sep' => 'zář', + 'september' => 'Zář', + 'sun' => 'Ne', + 'thu' => 'Čt', + 'today' => 'Dnes', + 'tue' => 'Út', + 'wed' => 'St', + 'yesterday' => 'Včera', + ), + 'freshrss' => array( + '_' => 'FreshRSS', + 'about' => 'O FreshRSS', + ), + 'js' => array( + 'category_empty' => 'Prázdná kategorie', + 'confirm_action' => 'Jste si jist, že chcete provést tuto akci? Změny nelze vrátit zpět!', + 'confirm_action_feed_cat' => 'Jste si jist, že chcete provést tuto akci? Přijdete o související oblíbené položky a uživatelské dotazy. Změny nelze vrátit zpět!', + 'feedback' => array( + 'body_new_articles' => 'Je \\d nových článků k přečtení v FreshRSS.', + 'request_failed' => 'Požadavek selhal, což může být způsobeno problémy s připojení k internetu.', + 'title_new_articles' => 'FreshRSS: nové články!', + ), + 'new_article' => 'Jsou k dispozici nové články, stránku obnovíte kliknutím zde.', + 'should_be_activated' => 'JavaScript musí být povolen', + ), + 'lang' => array( + 'de' => 'Deutsch', + 'en' => 'English', + 'fr' => 'Français', + 'cz' => 'Čeština', + ), + 'menu' => array( + 'about' => 'O aplikaci', + 'admin' => 'Administrace', + 'archiving' => 'Archivace', + 'authentication' => 'Přihlášení', + 'check_install' => 'Ověření instalace', + 'configuration' => 'Nastavení', + 'display' => 'Zobrazení', + 'extensions' => 'Rozšíření', + 'logs' => 'Logy', + 'queries' => 'Uživatelské dotazy', + 'reading' => 'Čtení', + 'search' => 'Hledat výraz nebo #tagy', + 'sharing' => 'Sdílení', + 'shortcuts' => 'Zkratky', + 'stats' => 'Statistika', + 'update' => 'Aktualizace', + 'user_management' => 'Správa uživatelů', + 'user_profile' => 'Profil', + ), + 'pagination' => array( + 'first' => 'První', + 'last' => 'Poslední', + 'load_more' => 'Načíst více článků', + 'mark_all_read' => 'Označit vše jako přečtené', + 'next' => 'Další', + 'nothing_to_load' => 'Žádné nové články', + 'previous' => 'Předchozí', + ), + 'share' => array( + 'blogotext' => 'Blogotext', + 'diaspora' => 'Diaspora*', + 'email' => 'Email', + 'facebook' => 'Facebook', + 'g+' => 'Google+', + 'print' => 'Tisk', + 'shaarli' => 'Shaarli', + 'twitter' => 'Twitter', + 'wallabag' => 'wallabag', + ), + 'short' => array( + 'attention' => 'Upozornění!', + 'blank_to_disable' => 'Zakázat - ponechte prázdné', + 'by_author' => 'Od %s', + 'by_default' => 'Výchozí', + 'damn' => 'Sakra!', + 'default_category' => 'Nezařazeno', + 'no' => 'Ne', + 'ok' => 'Ok!', + 'or' => 'nebo', + 'yes' => 'Ano', + ), +); diff --git a/app/i18n/cz/index.php b/app/i18n/cz/index.php new file mode 100644 index 000000000..5691d12af --- /dev/null +++ b/app/i18n/cz/index.php @@ -0,0 +1,61 @@ + array( + '_' => 'O FreshRSS', + 'agpl3' => 'AGPL 3', + 'bugs_reports' => 'Hlášení chyb', + 'credits' => 'Poděkování', + 'credits_content' => 'Některé designové prvky pocházejí z Bootstrap, FreshRSS ale tuto platformu nevyužívá. Ikony pocházejí z GNOME projektu. Font Open Sans vytvořil Steve Matteson. Favicony jsou shromažďovány pomocí getFavicon API. FreshRSS je založen na PHP framework Minz.', + 'freshrss_description' => 'FreshRSS je čtečka RSS kanálů určená k provozu na vlastním serveru, podobná Kriss Feed nebo Leed. Je to nenáročný a jednoduchý, zároveň ale mocný a konfigurovatelný nástroj.', + 'github' => 'na Github', + 'license' => 'Licence', + 'project_website' => 'Stránka projektu', + 'title' => 'O FreshRSS', + 'version' => 'Verze', + 'website' => 'Webové stránka', + ), + 'feed' => array( + 'add' => 'Můžete přidat kanály.', + 'empty' => 'Žádné články k zobrazení.', + 'rss_of' => 'RSS kanál %s', + 'title' => 'RSS kanály', + 'title_global' => 'Přehled', + 'title_fav' => 'Oblíbené', + ), + 'log' => array( + '_' => 'Logy', + 'clear' => 'Vymazat logy', + 'empty' => 'Log je prázdný', + 'title' => 'Logy', + ), + 'menu' => array( + 'about' => 'O FreshRSS', + 'add_query' => 'Vytvořit dotaz', + 'before_one_day' => 'Den nazpět', + 'before_one_week' => 'Před týdnem', + 'favorites' => 'Oblíbené (%s)', + 'global_view' => 'Přehled', + 'main_stream' => 'Všechny kanály', + 'mark_all_read' => 'Označit vše jako přečtené', + 'mark_cat_read' => 'Označit kategorii jako přečtenou', + 'mark_feed_read' => 'Označit kanál jako přečtený', + 'newer_first' => 'Nové nejdříve', + 'non-starred' => 'Zobrazit vše vyjma oblíbených', + 'normal_view' => 'Normální', + 'older_first' => 'Nejstarší nejdříve', + 'queries' => 'Uživatelské dotazy', + 'read' => 'Zobrazovat přečtené', + 'reader_view' => 'Čtení', + 'rss_view' => 'RSS kanál', + 'search_short' => 'Hledat', + 'starred' => 'Zobrazit oblíbené', + 'stats' => 'Statistika', + 'subscription' => 'Správa subskripcí', + 'unread' => 'Zobrazovat nepřečtené', + ), + 'share' => 'Sdílet', + 'tag' => array( + 'related' => 'Související tagy', + ), +); diff --git a/app/i18n/cz/install.php b/app/i18n/cz/install.php new file mode 100644 index 000000000..53257c84f --- /dev/null +++ b/app/i18n/cz/install.php @@ -0,0 +1,107 @@ + array( + 'finish' => 'Dokončit instalaci', + 'fix_errors_before' => 'Chyby prosím před přechodem na další krok opravte.', + 'next_step' => 'Přejít na další krok', + ), + 'auth' => array( + 'email_persona' => 'Email pro přihlášení
    (pro Mozilla Persona)', + 'form' => 'Webový formulář (tradiční, vyžaduje JavaScript)', + 'http' => 'HTTP (pro pokročilé uživatele s HTTPS)', + 'none' => 'Žádný (nebezpečné)', + 'password_form' => 'Heslo
    (pro přihlášení webovým formulářem)', + 'password_format' => 'Alespoň 7 znaků', + 'persona' => 'Mozilla Persona (moderní, vyžaduje JavaScript)', + 'type' => 'Způsob přihlášení', + ), + 'bdd' => array( + '_' => 'Databáze', + 'conf' => array( + '_' => 'Nastavení databáze', + 'ko' => 'Ověřte informace o databázi.', + 'ok' => 'Nastavení databáze bylo uloženo.', + ), + 'host' => 'Hostitel', + 'prefix' => 'Prefix tabulky', + 'password' => 'Heslo', + 'type' => 'Typ databáze', + 'username' => 'Uživatel', + ), + 'check' => array( + '_' => 'Kontrola', + 'cache' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/cache. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře cache jsou v pořádku.', + ), + 'ctype' => array( + 'nok' => 'Není nainstalována požadovaná knihovna pro ověřování znaků (php-ctype).', + 'ok' => 'Je nainstalována požadovaná knihovna pro ověřování znaků (ctype).', + ), + 'curl' => array( + 'nok' => 'Nemáte cURL (balíček php5-curl).', + 'ok' => 'Máte rozšíření cURL.', + ), + 'data' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře data jsou v pořádku.', + ), + 'dom' => array( + 'nok' => 'Nemáte požadovanou knihovnu pro procházení DOM (balíček php-xml).', + 'ok' => 'Máte požadovanou knihovnu pro procházení DOM.', + ), + 'favicons' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/favicons. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře favicons jsou v pořádku.', + ), + 'http_referer' => array( + 'nok' => 'Zkontrolujte prosím že neměníte HTTP REFERER.', + 'ok' => 'Váš HTTP REFERER je znám a odpovídá Vašemu serveru.', + ), + 'minz' => array( + 'nok' => 'Nemáte framework Minz.', + 'ok' => 'Máte framework Minz.', + ), + 'pcre' => array( + 'nok' => 'Nemáte požadovanou knihovnu pro regulární výrazy (php-pcre).', + 'ok' => 'Máte požadovanou knihovnu pro regulární výrazy (PCRE).', + ), + 'pdo' => array( + 'nok' => 'Nemáte PDO nebo některý z podporovaných ovladačů (pdo_mysql, pdo_sqlite).', + 'ok' => 'Máte PDO a alespoň jeden z podporovaných ovladačů (pdo_mysql, pdo_sqlite).', + ), + 'persona' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/persona. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře Mozilla Persona jsou v pořádku.', + ), + 'php' => array( + 'nok' => 'Vaše verze PHP je %s, ale FreshRSS vyžaduje alespoň verzi %s.', + 'ok' => 'Vaše verze PHP je %s a je kompatibilní s FreshRSS.', + ), + 'users' => array( + 'nok' => 'Zkontrolujte oprávnění adresáře ./data/users. HTTP server musí mít do tohoto adresáře práva zápisu', + 'ok' => 'Oprávnění adresáře users jsou v pořádku.', + ), + ), + 'conf' => array( + '_' => 'Obecná nastavení', + 'ok' => 'Nastavení bylo uloženo.', + ), + 'congratulations' => 'Gratulujeme!', + 'default_user' => 'Jméno výchozího uživatele (maximálně 16 alfanumerických znaků)', + 'delete_articles_after' => 'Smazat články starší než', + 'fix_errors_before' => 'Chyby prosím před přechodem na další krok opravte.', + 'javascript_is_better' => 'Práce s FreshRSS je příjemnější se zapnutým JavaScriptem', + 'language' => array( + '_' => 'Jazyk', + 'choose' => 'Vyberte jazyk FreshRSS', + 'defined' => 'Jazyk byl nastaven.', + ), + 'not_deleted' => 'Nastala chyba, soubor %s musíte smazat ručně.', + 'ok' => 'Instalace byla úspěšná.', + 'step' => 'krok %d', + 'steps' => 'Kroky', + 'title' => 'Instalace · FreshRSS', + 'this_is_the_end' => 'Konec', +); diff --git a/app/i18n/cz/sub.php b/app/i18n/cz/sub.php new file mode 100644 index 000000000..d7ff63fe9 --- /dev/null +++ b/app/i18n/cz/sub.php @@ -0,0 +1,61 @@ + array( + '_' => 'Kategorie', + 'add' => 'Přidat kategorii', + 'empty' => 'Vyprázdit kategorii', + 'new' => 'Nová kategorie', + ), + 'feed' => array( + 'add' => 'Přidat RSS kanál', + 'advanced' => 'Pokročilé', + 'archiving' => 'Archivace', + 'auth' => array( + 'configuration' => 'Přihlášení', + 'help' => 'Umožní přístup k RSS kanálům chráneným HTTP autentizací', + 'http' => 'HTTP přihlášení', + 'password' => 'Heslo', + 'username' => 'Přihlašovací jméno', + ), + 'css_help' => 'Stáhne zkrácenou verzi RSS kanálů (pozor, náročnější na čas!)', + 'css_path' => 'Původní CSS soubor článku z webových stránek', + 'description' => 'Popis', + 'empty' => 'Kanál je prazdný. Ověřte prosím zda je ještě autorem udržován.', + 'error' => 'Vyskytl se problém s kanálem. Ověřte že je vždy dostupný, prosím, a poté jej aktualizujte.', + 'in_main_stream' => 'Zobrazit ve “Všechny kanály”', + 'informations' => 'Informace', + 'keep_history' => 'Zachovat tento minimální počet článků', + 'moved_category_deleted' => 'Po smazání kategorie budou v ní obsažené kanály automaticky přesunuty do %s.', + 'no_selected' => 'Nejsou označeny žádné kanály.', + 'number_entries' => '%d článků', + 'stats' => 'Statistika', + 'think_to_add' => 'Můžete přidat kanály.', + 'title' => 'Název', + 'title_add' => 'Přidat RSS kanál', + 'ttl' => 'Neobnovovat častěji než', + 'url' => 'URL kanálu', + 'validator' => 'Zkontrolovat platnost kanálu', + 'website' => 'URL webové stránky', + ), + 'import_export' => array( + 'export' => 'Export', + 'export_opml' => 'Exportovat seznam kanálů (OPML)', + 'export_starred' => 'Exportovat oblíbené', + 'feed_list' => 'Seznam %s článků', + 'file_to_import' => 'Soubor k importu
    (OPML, Json nebo Zip)', + 'file_to_import_no_zip' => 'Soubor k importu
    (OPML nebo Json)', + 'import' => 'Import', + 'starred_list' => 'Seznam oblíbených článků', + 'title' => 'Import / export', + ), + 'menu' => array( + 'bookmark' => 'Přihlásit (FreshRSS bookmark)', + 'import_export' => 'Import / export', + 'subscription_management' => 'Správa subskripcí', + ), + 'title' => array( + '_' => 'Správa subskripcí', + 'feed_management' => 'Správa RSS kanálů', + ), +); -- cgit v1.2.3 From 6283fe99b2ded06d05d01c595a1d067010b4b886 Mon Sep 17 00:00:00 2001 From: Tets Date: Fri, 27 Mar 2015 08:13:34 +0100 Subject: Added Czech to the list in other languages in gen.php --- app/i18n/de/gen.php | 1 + app/i18n/en/gen.php | 1 + app/i18n/fr/gen.php | 1 + 3 files changed, 3 insertions(+) (limited to 'app') diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index 1b30a5be4..8970d5003 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -104,6 +104,7 @@ return array( 'should_be_activated' => 'JavaScript muss aktiviert sein', ), 'lang' => array( + 'cz' => 'Čeština', 'de' => 'Deutsch', 'en' => 'English', 'fr' => 'Français', diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index fdca01a43..b02b9f0f2 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -104,6 +104,7 @@ return array( 'should_be_activated' => 'JavaScript must be enabled', ), 'lang' => array( + 'cz' => 'Čeština', 'de' => 'Deutsch', 'en' => 'English', 'fr' => 'Français', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index 48fc4a7e9..c81e57bf7 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -104,6 +104,7 @@ return array( 'should_be_activated' => 'Le JavaScript doit être activé.', ), 'lang' => array( + 'cz' => 'Čeština', 'de' => 'Deutsch', 'en' => 'English', 'fr' => 'Français', -- cgit v1.2.3 From 711530a512b370d79b079205ce1f8376174f7f03 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 4 Apr 2015 22:39:31 +0200 Subject: SQL: detection of updates, and preparation for better burge https://github.com/FreshRSS/FreshRSS/issues/798 https://github.com/FreshRSS/FreshRSS/issues/493 SQLite not yet tested. Only MySQL tested so far. --- app/Controllers/feedController.php | 98 ++++++++------ app/Controllers/importExportController.php | 3 +- app/Models/Entry.php | 16 +++ app/Models/EntryDAO.php | 198 +++++++++++++++++++++-------- app/Models/Feed.php | 1 + app/SQL/install.sql.mysql.php | 7 +- app/SQL/install.sql.sqlite.php | 7 +- lib/lib_rss.php | 2 +- 8 files changed, 231 insertions(+), 101 deletions(-) (limited to 'app') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 6f544d834..08a0257a2 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -145,7 +145,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // Call the extension hook $name = $feed->name(); $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); - if (is_null($feed)) { + if ($feed === null) { Minz_Request::bad(_t('feed_not_added', $name), $url_redirect); } @@ -181,7 +181,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // Use a shared statement and a transaction to improve a LOT the // performances. - $prepared_statement = $entryDAO->addEntryPrepare(); $feedDAO->beginTransaction(); foreach ($entries as $entry) { // Entries are added without any verification. @@ -190,13 +189,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $entry->_isRead($is_read); $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); - if (is_null($entry)) { + if ($entry === null) { // An extension has returned a null value, there is nothing to insert. continue; } $values = $entry->toArray(); - $entryDAO->addEntry($values, $prepared_statement); + $entryDAO->addEntry($values); } $feedDAO->updateLastUpdate($feed->id()); $feedDAO->commit(); @@ -307,7 +306,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed->load(false); } catch (FreshRSS_Feed_Exception $e) { Minz_Log::notice($e->getMessage()); - $feedDAO->updateLastUpdate($feed->id(), 1); + $feedDAO->updateLastUpdate($feed->id(), true); $feed->unlock(); continue; } @@ -323,50 +322,69 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // We want chronological order and SimplePie uses reverse order. $entries = array_reverse($feed->entries()); if (count($entries) > 0) { - // For this feed, check last n entry GUIDs already in database. - $existing_guids = array_fill_keys($entryDAO->listLastGuidsByFeed( - $feed->id(), count($entries) + 10 - ), 1); - $use_declared_date = empty($existing_guids); + $newGuids = array(); + foreach ($entries as $entry) { + $newGuids[] = $entry->guid(); + } + // For this feed, check existing GUIDs already in database. + $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); + unset($newGuids); + $use_declared_date = empty($existingHashForGuids); + $oldGuids = array(); // Add entries in database if possible. - $prepared_statement = $entryDAO->addEntryPrepare(); - $feedDAO->beginTransaction(); foreach ($entries as $entry) { $entry_date = $entry->date(true); - if (isset($existing_guids[$entry->guid()]) || - ($feed_history == 0 && $entry_date < $date_min)) { - // This entry already exists in DB or should not be added - // considering configuration and date. - continue; - } - - $id = uTimeString(); - if ($use_declared_date || $entry_date < $date_min) { - // Use declared date at first import. - $id = min(time(), $entry_date) . uSecString(); + if (isset($existingHashForGuids[$entry->guid()])) { + $existingHash = $existingHashForGuids[$entry->guid()]; + if (strcasecmp($existingHash, $entry->hash()) === 0 || $existingHash === '00000000000000000000000000000000') { + //This entry already exists and is unchanged. TODO: Remove the test with the zero'ed hash in FreshRSS v1.3 + $oldGuids[] = $entry->guid(); + } else { //This entry already exists but has been updated + Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() . + ', old hash ' . $existingHash . ', new hash ' . $entry->hash()); + $entry->_isRead($is_read); //Reset is_read + if (!$entryDAO->hasTransaction()) { + $entryDAO->beginTransaction(); + } + $entryDAO->updateEntry($entry->toArray()); + } + } elseif ($feed_history == 0 && $entry_date < $date_min) { + // This entry should not be added considering configuration and date. + $oldGuids[] = $entry->guid(); + } else { + $id = uTimeString(); + if ($use_declared_date || $entry_date < $date_min) { + // Use declared date at first import. + $id = min(time(), $entry_date) . uSecString(); + } + + $entry->_id($id); + $entry->_isRead($is_read); + + $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); + if ($entry === null) { + // An extension has returned a null value, there is nothing to insert. + continue; + } + + if (!$entryDAO->hasTransaction()) { + $entryDAO->beginTransaction(); + } + $entryDAO->addEntry($entry->toArray()); } - - $entry->_id($id); - $entry->_isRead($is_read); - - $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); - if (is_null($entry)) { - // An extension has returned a null value, there is nothing to insert. - continue; - } - - $values = $entry->toArray(); - $entryDAO->addEntry($values, $prepared_statement); } + $entryDAO->updateLastSeen($feed->id(), $oldGuids); } + //TODO: updateLastSeen old GUIDS once in a while, in the case of caching (i.e. the whole feed content has not changed) if ($feed_history >= 0 && rand(0, 30) === 1) { // TODO: move this function in web cron when available (see entry::purge) // Remove old entries once in 30. - if (!$feedDAO->hasTransaction()) { - $feedDAO->beginTransaction(); + if (!$entryDAO->hasTransaction()) { + $entryDAO->beginTransaction(); } + //TODO: more robust system based on entry.lastSeen to avoid cleaning entries that are still published in the RSS feed. $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, @@ -377,9 +395,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } - $feedDAO->updateLastUpdate($feed->id(), 0, $feedDAO->hasTransaction()); - if ($feedDAO->hasTransaction()) { - $feedDAO->commit(); + $feedDAO->updateLastUpdate($feed->id(), 0, $entryDAO->hasTransaction()); + if ($entryDAO->hasTransaction()) { + $entryDAO->commit(); } if ($feed->url() !== $url) { diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 589777b2a..26b163e43 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -361,7 +361,6 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } // Then, articles are imported. - $prepared_statement = $this->entryDAO->addEntryPrepare(); $this->entryDAO->beginTransaction(); foreach ($article_object['items'] as $item) { if (!isset($article_to_feed[$item['id']])) { @@ -396,7 +395,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } $values = $entry->toArray(); - $id = $this->entryDAO->addEntry($values, $prepared_statement); + $id = $this->entryDAO->addEntry($values); if (!$error && ($id === false)) { $error = true; diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 346c98a92..6931c9f25 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -14,6 +14,7 @@ class FreshRSS_Entry extends Minz_Model { private $content; private $link; private $date; + private $hash = null; private $is_read; private $is_favorite; private $feed; @@ -88,6 +89,14 @@ class FreshRSS_Entry extends Minz_Model { } } + public function hash() { + if ($this->hash === null) { + //Do not include $this->date because it may be automatically generated when lacking + $this->hash = md5($this->link . $this->title . $this->author . $this->content . $this->tags(true)); + } + return $this->hash; + } + public function _id($value) { $this->id = $value; } @@ -95,18 +104,23 @@ class FreshRSS_Entry extends Minz_Model { $this->guid = $value; } public function _title($value) { + $this->hash = null; $this->title = $value; } public function _author($value) { + $this->hash = null; $this->author = $value; } public function _content($value) { + $this->hash = null; $this->content = $value; } public function _link($value) { + $this->hash = null; $this->link = $value; } public function _date($value) { + $this->hash = null; $value = intval($value); $this->date = $value > 1 ? $value : time(); } @@ -120,6 +134,7 @@ class FreshRSS_Entry extends Minz_Model { $this->feed = $value; } public function _tags($value) { + $this->hash = null; if (!is_array($value)) { $value = array($value); } @@ -182,6 +197,7 @@ class FreshRSS_Entry extends Minz_Model { 'content' => $this->content(), 'link' => $this->link(), 'date' => $this->date(true), + 'hash' => $this->hash(), 'is_read' => $this->isRead(), 'is_favorite' => $this->isFavorite(), 'id_feed' => $this->feed(), diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 9736d5cd3..5b4b85547 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -6,20 +6,57 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return parent::$sharedDbType !== 'sqlite'; } - public function addEntryPrepare() { - $sql = 'INSERT INTO `' . $this->prefix . 'entry`(id, guid, title, author, ' - . ($this->isCompressed() ? 'content_bin' : 'content') - . ', link, date, is_read, is_favorite, id_feed, tags) ' - . 'VALUES(?, ?, ?, ?, ' - . ($this->isCompressed() ? 'COMPRESS(?)' : '?') - . ', ?, ?, ?, ?, ?, ?)'; - return $this->bd->prepare($sql); + protected function autoAddColumn($errorInfo) { + if (isset($errorInfo[0])) { + if ($errorInfo[0] == '42S22') { //ER_BAD_FIELD_ERROR + $hasTransaction = false; + try { + $stm = null; + if (stripos($errorInfo[2], 'lastSeen') !== false) { //v1.2 + if (!$this->bd->inTransaction()) { + $this->bd->beginTransaction(); + $hasTransaction = true; + } + $stm = $this->bd->prepare('ALTER TABLE `' . $this->prefix . 'entry` ADD COLUMN lastSeen INT(11) NOT NULL'); + if ($stm && $stm->execute()) { + $stm = $this->bd->prepare('CREATE INDEX entry_lastSeen_index ON `' . $this->prefix . 'entry`(`lastSeen`);'); //"IF NOT EXISTS" does not exist in MySQL 5.7 + if ($stm && $stm->execute()) { + if ($hasTransaction) { + $this->bd->commit(); + } + return true; + } + } + if ($hasTransaction) { + $this->bd->rollBack(); + } + } elseif (stripos($errorInfo[2], 'hash') !== false) { //v1.2 + $stm = $this->bd->prepare('ALTER TABLE `' . $this->prefix . 'entry` ADD COLUMN hash BINARY(16) NOT NULL'); + return $stm && $stm->execute(); + } + } catch (Exception $e) { + Minz_Log::debug('FreshRSS_EntryDAO::autoAddColumn error: ' . $e->getMessage()); + if ($hasTransaction) { + $this->bd->rollBack(); + } + } + } + } + return false; } - public function addEntry($valuesTmp, $preparedStatement = null) { - $stm = $preparedStatement === null ? - FreshRSS_EntryDAO::addEntryPrepare() : - $preparedStatement; + private $addEntryPrepared = null; + + public function addEntry($valuesTmp) { + if ($this->addEntryPrepared === null) { + $sql = 'INSERT INTO `' . $this->prefix . 'entry` (id, guid, title, author, ' + . ($this->isCompressed() ? 'content_bin' : 'content') + . ', link, date, lastSeen, hash, is_read, is_favorite, id_feed, tags) ' + . 'VALUES(?, ?, ?, ?, ' + . ($this->isCompressed() ? 'COMPRESS(?)' : '?') + . ', ?, ?, ?, X?, ?, ?, ?, ?)'; + $this->addEntryPrepared = $this->bd->prepare($sql); + } $values = array( $valuesTmp['id'], @@ -29,55 +66,65 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $valuesTmp['content'], substr($valuesTmp['link'], 0, 1023), $valuesTmp['date'], + time(), + $valuesTmp['hash'], $valuesTmp['is_read'] ? 1 : 0, $valuesTmp['is_favorite'] ? 1 : 0, $valuesTmp['id_feed'], substr($valuesTmp['tags'], 0, 1023), ); - if ($stm && $stm->execute($values)) { + if ($this->addEntryPrepared && $this->addEntryPrepared->execute($values)) { return $this->bd->lastInsertId(); } else { - $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - if ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries + $info = $this->addEntryPrepared == null ? array(2 => 'syntax error') : $this->addEntryPrepared->errorInfo(); + if ($this->autoAddColumn($info)) { + return $this->addEntry($valuesTmp); + } elseif ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries Minz_Log::error('SQL error addEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']); - } /*else { - Minz_Log::debug('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] - . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']); - }*/ + } return false; } } - public function addEntryObject($entry, $conf, $feedHistory) { - $existingGuids = array_fill_keys( - $this->listLastGuidsByFeed($entry->feed(), 20), 1 - ); - - $nb_month_old = max($conf->old_entries, 1); - $date_min = time() - (3600 * 24 * 30 * $nb_month_old); + private $updateEntryPrepared = null; - $eDate = $entry->date(true); - - if ($feedHistory == -2) { - $feedHistory = $conf->keep_history_default; + public function updateEntry($valuesTmp) { + if ($this->updateEntryPrepared === null) { + $sql = 'UPDATE `' . $this->prefix . 'entry` ' + . 'SET title=?, author=?, ' + . ($this->isCompressed() ? 'content_bin=COMPRESS(?)' : 'content=?') + . ', link=?, date=?, lastSeen=?, hash=X?, is_read=?, tags=? ' + . 'WHERE id_feed=? AND guid=?'; + $this->updateEntryPrepared = $this->bd->prepare($sql); } - if (!isset($existingGuids[$entry->guid()]) && - ($feedHistory != 0 || $eDate >= $date_min || $entry->isFavorite())) { - $values = $entry->toArray(); - - $useDeclaredDate = empty($existingGuids); - $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? - min(time(), $eDate) . uSecString() : - uTimeString(); + $values = array( + substr($valuesTmp['title'], 0, 255), + substr($valuesTmp['author'], 0, 255), + $valuesTmp['content'], + substr($valuesTmp['link'], 0, 1023), + $valuesTmp['date'], + time(), + $valuesTmp['hash'], + $valuesTmp['is_read'] ? 1 : 0, + substr($valuesTmp['tags'], 0, 1023), + $valuesTmp['id_feed'], + substr($valuesTmp['guid'], 0, 760), + ); - return $this->addEntry($values); + if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute($values)) { + return $this->bd->lastInsertId(); + } else { + $info = $this->updateEntryPrepared == null ? array(2 => 'syntax error') : $this->updateEntryPrepared->errorInfo(); + if ($this->autoAddColumn($info)) { + return $this->updateEntry($valuesTmp); + } + Minz_Log::error('SQL error updateEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] + . ' while updating entry with GUID ' . $valuesTmp['guid'] . ' in feed ' . $valuesTmp['id_feed']); + return false; } - - // We don't return Entry object to avoid a research in DB - return -1; } /** @@ -94,6 +141,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if (!is_array($ids)) { $ids = array($ids); } + if (count($ids) < 1) { + return 0; + } $sql = 'UPDATE `' . $this->prefix . 'entry` ' . 'SET is_favorite=? ' . 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)'; @@ -296,11 +346,11 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { * * If $idMax equals 0, a deprecated debug message is logged * - * @param integer $id feed ID + * @param integer $id_feed feed ID * @param integer $idMax fail safe article ID * @return integer affected rows */ - public function markReadFeed($id, $idMax = 0) { + public function markReadFeed($id_feed, $idMax = 0) { if ($idMax == 0) { $idMax = time() . '000000'; Minz_Log::debug('Calling markReadFeed(0) is deprecated!'); @@ -310,7 +360,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $sql = 'UPDATE `' . $this->prefix . 'entry` ' . 'SET is_read=1 ' . 'WHERE id_feed=? AND is_read=0 AND id <= ?'; - $values = array($id, $idMax); + $values = array($id_feed, $idMax); $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); @@ -324,7 +374,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $sql = 'UPDATE `' . $this->prefix . 'feed` ' . 'SET cache_nbUnreads=cache_nbUnreads-' . $affected . ' WHERE id=?'; - $values = array($id); + $values = array($id_feed); $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); @@ -338,7 +388,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $affected; } - public function searchByGuid($feed_id, $id) { + public function searchByGuid($id_feed, $guid) { // un guid est unique pour un flux donné $sql = 'SELECT id, guid, title, author, ' . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') @@ -347,8 +397,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $stm = $this->bd->prepare($sql); $values = array( - $feed_id, - $id + $id_feed, + $guid, ); $stm->execute($values); @@ -519,12 +569,52 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $stm->fetchAll(PDO::FETCH_COLUMN, 0); } - public function listLastGuidsByFeed($id, $n) { - $sql = 'SELECT guid FROM `' . $this->prefix . 'entry` WHERE id_feed=? ORDER BY id DESC LIMIT ' . intval($n); + public function listHashForFeedGuids($id_feed, $guids) { + if (count($guids) < 1) { + return array(); + } + $sql = 'SELECT guid, hex(hash) AS hexHash FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND guid IN (' . str_repeat('?,', count($guids) - 1). '?)'; $stm = $this->bd->prepare($sql); - $values = array($id); - $stm->execute($values); - return $stm->fetchAll(PDO::FETCH_COLUMN, 0); + $values = array($id_feed); + $values = array_merge($values, $guids); + if ($stm && $stm->execute($values)) { + $result = array(); + $rows = $stm->fetchAll(PDO::FETCH_ASSOC); + foreach ($rows as $row) { + $result[$row['guid']] = $row['hexHash']; + } + return $result; + } else { + + $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); + if ($this->autoAddColumn($info)) { + return $this->listHashForFeedGuids($id_feed, $guids); + } + Minz_Log::error('SQL error listHashForFeedGuids: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] + . ' while querying feed ' . $id_feed); + return false; + } + } + + public function updateLastSeen($id_feed, $guids) { + if (count($guids) < 1) { + return 0; + } + $sql = 'UPDATE `' . $this->prefix . 'entry` SET lastSeen=? WHERE id_feed=? AND guid IN (' . str_repeat('?,', count($guids) - 1). '?)'; + $stm = $this->bd->prepare($sql); + $values = array(time(), $id_feed); + $values = array_merge($values, $guids); + if ($stm && $stm->execute($values)) { + return $stm->rowCount(); + } else { + $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); + if ($this->autoAddColumn($info)) { + return $this->updateLastSeen($id_feed, $guids); + } + Minz_Log::error('SQL error updateLastSeen: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] + . ' while updating feed ' . $id_feed); + return false; + } } public function countUnreadRead() { diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 5ce03be5d..27c83ffd5 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -255,6 +255,7 @@ class FreshRSS_Feed extends Minz_Model { $feed->__destruct(); //http://simplepie.org/wiki/faq/i_m_getting_memory_leaks unset($feed); + //TODO: Return a different information in case of cache/no-cache, and give access to the GUIDs in case of cache } } } diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php index cf0159199..afdd821b2 100644 --- a/app/SQL/install.sql.mysql.php +++ b/app/SQL/install.sql.mysql.php @@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS `%1$sfeed` ( `name` varchar(255) NOT NULL, `website` varchar(255) CHARACTER SET latin1, `description` text, - `lastUpdate` int(11) DEFAULT 0, + `lastUpdate` int(11) DEFAULT 0, -- Until year 2038 `priority` tinyint(2) NOT NULL DEFAULT 10, `pathEntries` varchar(511) DEFAULT NULL, `httpAuth` varchar(511) DEFAULT NULL, @@ -40,7 +40,9 @@ CREATE TABLE IF NOT EXISTS `%1$sentry` ( `author` varchar(255), `content_bin` blob, -- v0.7 `link` varchar(1023) CHARACTER SET latin1 NOT NULL, - `date` int(11), + `date` int(11), -- Until year 2038 + `lastSeen` INT(11) NOT NULL, -- v1.2, Until year 2038 + `hash` BINARY(16), -- v1.2 `is_read` boolean NOT NULL DEFAULT 0, `is_favorite` boolean NOT NULL DEFAULT 0, `id_feed` SMALLINT, -- v0.7 @@ -50,6 +52,7 @@ CREATE TABLE IF NOT EXISTS `%1$sentry` ( UNIQUE KEY (`id_feed`,`guid`), -- v0.7 INDEX (`is_favorite`), -- v0.7 INDEX (`is_read`) -- v0.7 + INDEX entry_lastSeen_index (`lastSeen`) -- v1.2 ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB; diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php index 30bca2810..7517ead45 100644 --- a/app/SQL/install.sql.sqlite.php +++ b/app/SQL/install.sql.sqlite.php @@ -14,7 +14,7 @@ $SQL_CREATE_TABLES = array( `name` varchar(255) NOT NULL, `website` varchar(255), `description` text, - `lastUpdate` int(11) DEFAULT 0, + `lastUpdate` int(11) DEFAULT 0, -- Until year 2038 `priority` tinyint(2) NOT NULL DEFAULT 10, `pathEntries` varchar(511) DEFAULT NULL, `httpAuth` varchar(511) DEFAULT NULL, @@ -38,7 +38,9 @@ $SQL_CREATE_TABLES = array( `author` varchar(255), `content` text, `link` varchar(1023) NOT NULL, - `date` int(11), + `date` int(11), -- Until year 2038 + `lastSeen` INT(11) NOT NULL, -- v1.2, Until year 2038 + `hash` BINARY(16), -- v1.2 `is_read` boolean NOT NULL DEFAULT 0, `is_favorite` boolean NOT NULL DEFAULT 0, `id_feed` SMALLINT, @@ -50,6 +52,7 @@ $SQL_CREATE_TABLES = array( 'CREATE INDEX IF NOT EXISTS entry_is_favorite_index ON `%1$sentry`(`is_favorite`);', 'CREATE INDEX IF NOT EXISTS entry_is_read_index ON `%1$sentry`(`is_read`);', +'CREATE INDEX IF NOT EXISTS entry_lastSeen_index ON `%1$sentry`(`lastSeen`);', //v1.2 'INSERT OR IGNORE INTO `%1$scategory` (id, name) VALUES(1, "%2$s");', ); diff --git a/lib/lib_rss.php b/lib/lib_rss.php index e5fe73041..c6bdfde0e 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -38,7 +38,7 @@ function classAutoloader($class) { include(APP_PATH . '/Models/' . $components[1] . '.php'); return; case 3: //Controllers, Exceptions - @include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php'); + include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php'); return; } } elseif (strpos($class, 'Minz') === 0) { -- cgit v1.2.3 From d229216cccbd746b46630a44fa508ef0367ea1a1 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 22 Apr 2015 00:24:22 -0400 Subject: Split the search into values Before, the search was a single value. Now it is splited in chuncks when separated by spaces. Except if they are enclosed by single quotes or double quotes. For some reasons, the unit tests are working for both single and double quotes but the search box isn't. It is working only with single quotes. We need to investigate the reason of this behavior. See #823 --- app/Models/EntryDAO.php | 8 +++-- app/Models/Search.php | 32 +++++++++++++++++-- tests/app/Models/SearchTest.php | 68 +++++++++++++++++++++++++---------------- 3 files changed, 77 insertions(+), 31 deletions(-) (limited to 'app') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 9736d5cd3..5bdc216bc 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -478,11 +478,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { } } if ($filter->getSearch()) { - $search .= 'AND ' . $this->sqlconcat('e1.title', $this->isCompressed() ? 'UNCOMPRESS(content_bin)' : 'content') . ' LIKE ? '; - $values[] = "%{$filter->getSearch()}%"; + $search_values = $filter->getSearch(); + foreach ($search_values as $search_value) { + $search .= 'AND ' . $this->sqlconcat('e1.title', $this->isCompressed() ? 'UNCOMPRESS(content_bin)' : 'content') . ' LIKE ? '; + $values[] = "%{$search_value}%"; + } } } - return array($values, 'SELECT e1.id FROM `' . $this->prefix . 'entry` e1 ' . ($joinFeed ? 'INNER JOIN `' . $this->prefix . 'feed` f ON e1.id_feed=f.id ' : '') diff --git a/app/Models/Search.php b/app/Models/Search.php index 84688be2e..575a9a2cb 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -34,9 +34,9 @@ class FreshRSS_Search { $input = $this->parsePubdateSearch($input); $input = $this->parseDateSearch($input); $input = $this->parseTagsSeach($input); - $this->search = $this->cleanSearch($input); + $this->parseSearch($input); } - + public function __toString() { return $this->getRawInput(); } @@ -187,6 +187,34 @@ class FreshRSS_Search { return $input; } + /** + * Parse the search string to find search values. + * Every word is a distinct search value, except when using a delimiter. + * Supported delimiters are single quote (') and double quotes ("). + * + * @param string $input + * @return string + */ + private function parseSearch($input) { + $input = $this->cleanSearch($input); + if (strcmp($input, '') == 0) { + return; + } + if (preg_match_all('/(?P[\'"])(?P.*)(?P=delim)/U', $input, $matches)) { + $this->search = $matches['search']; + $input = str_replace($matches[0], '', $input); + } + $input = $this->cleanSearch($input); + if (strcmp($input, '') == 0) { + return; + } + if (is_array($this->search)) { + $this->search = array_merge($this->search, explode(' ', $input)); + } else { + $this->search = explode(' ', $input); + } + } + /** * Remove all unnecessary spaces in the search * diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php index 9e3ca6765..73ff56cc6 100644 --- a/tests/app/Models/SearchTest.php +++ b/tests/app/Models/SearchTest.php @@ -51,20 +51,21 @@ class SearchTest extends \PHPUnit_Framework_TestCase { public function provideIntitleSearch() { return array( array('intitle:word1', 'word1', null), - array('intitle:word1 word2', 'word1', 'word2'), + array('intitle:word1 word2', 'word1', array('word2')), array('intitle:"word1 word2"', 'word1 word2', null), array("intitle:'word1 word2'", 'word1 word2', null), - array('word1 intitle:word2', 'word2', 'word1'), - array('word1 intitle:word2 word3', 'word2', 'word1 word3'), - array('word1 intitle:"word2 word3"', 'word2 word3', 'word1'), - array("word1 intitle:'word2 word3'", 'word2 word3', 'word1'), - array('intitle:word1 intitle:word2', 'word1', 'intitle:word2'), - array('intitle: word1 word2', null, 'word1 word2'), + array('word1 intitle:word2', 'word2', array('word1')), + array('word1 intitle:word2 word3', 'word2', array('word1', 'word3')), + array('word1 intitle:"word2 word3"', 'word2 word3', array('word1')), + array("word1 intitle:'word2 word3'", 'word2 word3', array('word1')), + array('intitle:word1 intitle:word2', 'word1', array('intitle:word2')), + array('intitle: word1 word2', null, array('word1', 'word2')), array('intitle:123', '123', null), - array('intitle:"word1 word2" word3"', 'word1 word2', 'word3"'), - array("intitle:'word1 word2' word3'", 'word1 word2', "word3'"), + array('intitle:"word1 word2" word3"', 'word1 word2', array('word3"')), + array("intitle:'word1 word2' word3'", 'word1 word2', array("word3'")), array('intitle:"word1 word2\' word3"', "word1 word2' word3", null), array("intitle:'word1 word2\" word3'", 'word1 word2" word3', null), + array("intitle:word1 'word2 word3' word4", 'word1', array('word2 word3', 'word4')), ); } @@ -86,20 +87,21 @@ class SearchTest extends \PHPUnit_Framework_TestCase { public function provideAuthorSearch() { return array( array('author:word1', 'word1', null), - array('author:word1 word2', 'word1', 'word2'), + array('author:word1 word2', 'word1', array('word2')), array('author:"word1 word2"', 'word1 word2', null), array("author:'word1 word2'", 'word1 word2', null), - array('word1 author:word2', 'word2', 'word1'), - array('word1 author:word2 word3', 'word2', 'word1 word3'), - array('word1 author:"word2 word3"', 'word2 word3', 'word1'), - array("word1 author:'word2 word3'", 'word2 word3', 'word1'), - array('author:word1 author:word2', 'word1', 'author:word2'), - array('author: word1 word2', null, 'word1 word2'), + array('word1 author:word2', 'word2', array('word1')), + array('word1 author:word2 word3', 'word2', array('word1', 'word3')), + array('word1 author:"word2 word3"', 'word2 word3', array('word1')), + array("word1 author:'word2 word3'", 'word2 word3', array('word1')), + array('author:word1 author:word2', 'word1', array('author:word2')), + array('author: word1 word2', null, array('word1', 'word2')), array('author:123', '123', null), - array('author:"word1 word2" word3"', 'word1 word2', 'word3"'), - array("author:'word1 word2' word3'", 'word1 word2', "word3'"), + array('author:"word1 word2" word3"', 'word1 word2', array('word3"')), + array("author:'word1 word2' word3'", 'word1 word2', array("word3'")), array('author:"word1 word2\' word3"', "word1 word2' word3", null), array("author:'word1 word2\" word3'", 'word1 word2" word3', null), + array("author:word1 'word2 word3' word4", 'word1', array('word2 word3', 'word4')), ); } @@ -121,10 +123,11 @@ class SearchTest extends \PHPUnit_Framework_TestCase { public function provideInurlSearch() { return array( array('inurl:word1', 'word1', null), - array('inurl: word1', null, 'word1'), + array('inurl: word1', null, array('word1')), array('inurl:123', '123', null), - array('inurl:word1 word2', 'word1', 'word2'), - array('inurl:"word1 word2"', '"word1', 'word2"'), + array('inurl:word1 word2', 'word1', array('word2')), + array('inurl:"word1 word2"', '"word1', array('word2"')), + array("inurl:word1 'word2 word3' word4", 'word1', array('word2 word3', 'word4')), ); } @@ -198,11 +201,12 @@ class SearchTest extends \PHPUnit_Framework_TestCase { public function provideTagsSearch() { return array( array('#word1', array('word1'), null), - array('# word1', null, '# word1'), + array('# word1', null, array('#', 'word1')), array('#123', array('123'), null), - array('#word1 word2', array('word1'), 'word2'), - array('#"word1 word2"', array('"word1'), 'word2"'), + array('#word1 word2', array('word1'), array('word2')), + array('#"word1 word2"', array('"word1'), array('word2"')), array('#word1 #word2', array('word1', 'word2'), null), + array("#word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), ); } @@ -257,7 +261,7 @@ class SearchTest extends \PHPUnit_Framework_TestCase { '1172725200', '1210564799', array('word4', 'word5'), - 'word6', + array('word6'), ), array( 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 word7 date:2007-03-01/2008-05-11', @@ -269,7 +273,19 @@ class SearchTest extends \PHPUnit_Framework_TestCase { '1172725200', '1210564799', array('word4', 'word5'), - 'word6 word7', + array('word6', 'word7'), + ), + array( + 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 "word7 word8" date:2007-03-01/2008-05-11', + 'word1', + '1172725200', + '1210564799', + 'word2', + 'word3', + '1172725200', + '1210564799', + array('word4', 'word5'), + array('word7 word8', 'word6'), ), ); } -- cgit v1.2.3 From 7f7de31c1dcb6599be5c5713f36b4bde1d03d47a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 9 May 2015 13:07:54 +0200 Subject: SQL: update request for updated articles https://github.com/FreshRSS/FreshRSS/issues/798 --- app/Controllers/feedController.php | 2 +- app/Models/Entry.php | 4 ++-- app/Models/EntryDAO.php | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 08a0257a2..59c9174fb 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -343,7 +343,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } else { //This entry already exists but has been updated Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() . ', old hash ' . $existingHash . ', new hash ' . $entry->hash()); - $entry->_isRead($is_read); //Reset is_read + $entry->_isRead(null); //Change is_read according to policy. //TODO: Implement option if (!$entryDAO->hasTransaction()) { $entryDAO->beginTransaction(); } diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 6931c9f25..a562a963a 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -15,7 +15,7 @@ class FreshRSS_Entry extends Minz_Model { private $link; private $date; private $hash = null; - private $is_read; + private $is_read; //Nullable boolean private $is_favorite; private $feed; private $tags; @@ -125,7 +125,7 @@ class FreshRSS_Entry extends Minz_Model { $this->date = $value > 1 ? $value : time(); } public function _isRead($value) { - $this->is_read = $value; + $this->is_read = $value === null ? null : (bool)$value; } public function _isFavorite($value) { $this->is_favorite = $value; diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 5b4b85547..543b61573 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -91,11 +91,17 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { private $updateEntryPrepared = null; public function updateEntry($valuesTmp) { + if (!isset($valuesTmp['is_read'])) { + $valuesTmp['is_read'] = null; + } + if ($this->updateEntryPrepared === null) { $sql = 'UPDATE `' . $this->prefix . 'entry` ' . 'SET title=?, author=?, ' . ($this->isCompressed() ? 'content_bin=COMPRESS(?)' : 'content=?') - . ', link=?, date=?, lastSeen=?, hash=X?, is_read=?, tags=? ' + . ', link=?, date=?, lastSeen=?, hash=X?, ' + . ($valuesTmp['is_read'] === null ? '' : 'is_read=?, ') + . 'tags=? ' . 'WHERE id_feed=? AND guid=?'; $this->updateEntryPrepared = $this->bd->prepare($sql); } @@ -108,11 +114,15 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $valuesTmp['date'], time(), $valuesTmp['hash'], - $valuesTmp['is_read'] ? 1 : 0, + ); + if ($valuesTmp['is_read'] !== null) { + $values[] = $valuesTmp['is_read'] ? 1 : 0; + } + $values = array_merge($values, array( substr($valuesTmp['tags'], 0, 1023), $valuesTmp['id_feed'], substr($valuesTmp['guid'], 0, 760), - ); + )); if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute($values)) { return $this->bd->lastInsertId(); -- cgit v1.2.3 From 993466844405bd9854d890d6d5ebf763ed8b78cb Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 9 May 2015 23:37:56 +0200 Subject: SQL: more robust purge https://github.com/FreshRSS/FreshRSS/issues/798 https://github.com/FreshRSS/FreshRSS/issues/493 --- app/Controllers/feedController.php | 13 +++++-------- app/Models/Feed.php | 3 +-- app/Models/FeedDAO.php | 8 +++++--- 3 files changed, 11 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 59c9174fb..5657d4a88 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -329,7 +329,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // For this feed, check existing GUIDs already in database. $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); unset($newGuids); - $use_declared_date = empty($existingHashForGuids); $oldGuids = array(); // Add entries in database if possible. @@ -353,14 +352,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // This entry should not be added considering configuration and date. $oldGuids[] = $entry->guid(); } else { - $id = uTimeString(); - if ($use_declared_date || $entry_date < $date_min) { - // Use declared date at first import. + if ($entry_date < $date_min) { $id = min(time(), $entry_date) . uSecString(); + $entry->_isRead(true); //Old article that was not in database. Probably an error, so mark as read + } else { + $id = uTimeString(); + $entry->_isRead($is_read); } - $entry->_id($id); - $entry->_isRead($is_read); $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); if ($entry === null) { @@ -376,7 +375,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } $entryDAO->updateLastSeen($feed->id(), $oldGuids); } - //TODO: updateLastSeen old GUIDS once in a while, in the case of caching (i.e. the whole feed content has not changed) if ($feed_history >= 0 && rand(0, 30) === 1) { // TODO: move this function in web cron when available (see entry::purge) @@ -384,7 +382,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if (!$entryDAO->hasTransaction()) { $entryDAO->beginTransaction(); } - //TODO: more robust system based on entry.lastSeen to avoid cleaning entries that are still published in the RSS feed. $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 27c83ffd5..5d377de9a 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -245,7 +245,7 @@ class FreshRSS_Feed extends Minz_Model { $this->_url($clean_url); } - if (($mtime === true) ||($mtime > $this->lastUpdate)) { + if (($mtime === true) || ($mtime > $this->lastUpdate)) { Minz_Log::notice('FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $clean_url); $this->loadEntries($feed); // et on charge les articles du flux } else { @@ -255,7 +255,6 @@ class FreshRSS_Feed extends Minz_Model { $feed->__destruct(); //http://simplepie.org/wiki/faq/i_m_getting_memory_leaks unset($feed); - //TODO: Return a different information in case of cache/no-cache, and give access to the GUIDs in case of cache } } } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index f48beee6e..c13e2b008 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -322,10 +322,12 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $affected; } - public function cleanOldEntries($id, $date_min, $keep = 15) { //Remember to call updateLastUpdate($id) just after + public function cleanOldEntries($id, $date_min, $keep = 15) { //Remember to call updateLastUpdate($id) or updateCachedValues() just after $sql = 'DELETE FROM `' . $this->prefix . 'entry` ' - . 'WHERE id_feed = :id_feed AND id <= :id_max AND is_favorite=0 AND id NOT IN ' - . '(SELECT id FROM (SELECT e2.id FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed = :id_feed ORDER BY id DESC LIMIT :keep) keep)'; //Double select MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' + . 'WHERE id_feed = :id_feed AND id <= :id_max ' + . 'AND is_favorite=0 ' //Do not remove favourites + . 'AND lastSeen < (SELECT maxLastSeen FROM (SELECT (MAX(e3.lastSeen) - 99) AS maxLastSeen FROM `' . $this->prefix . 'entry` e3 WHERE e3.id_feed = :id_feed) recent) ' //Do not remove the most newly seen articles, plus a few seconds of tolerance + . 'AND id NOT IN (SELECT id FROM (SELECT e2.id FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed = :id_feed ORDER BY id DESC LIMIT :keep) keep)'; //Double select: MySQL doesn't support 'LIMIT & IN/ALL/ANY/SOME subquery' $stm = $this->bd->prepare($sql); $id_max = intval($date_min) . '000000'; -- cgit v1.2.3 From a7bc54bb996a87a66127101be548d181dc8dd935 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 9 May 2015 23:45:52 +0200 Subject: Minor spaces --- app/Models/FeedDAO.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index c13e2b008..76025ff53 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -324,10 +324,10 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function cleanOldEntries($id, $date_min, $keep = 15) { //Remember to call updateLastUpdate($id) or updateCachedValues() just after $sql = 'DELETE FROM `' . $this->prefix . 'entry` ' - . 'WHERE id_feed = :id_feed AND id <= :id_max ' + . 'WHERE id_feed=:id_feed AND id<=:id_max ' . 'AND is_favorite=0 ' //Do not remove favourites - . 'AND lastSeen < (SELECT maxLastSeen FROM (SELECT (MAX(e3.lastSeen) - 99) AS maxLastSeen FROM `' . $this->prefix . 'entry` e3 WHERE e3.id_feed = :id_feed) recent) ' //Do not remove the most newly seen articles, plus a few seconds of tolerance - . 'AND id NOT IN (SELECT id FROM (SELECT e2.id FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed = :id_feed ORDER BY id DESC LIMIT :keep) keep)'; //Double select: MySQL doesn't support 'LIMIT & IN/ALL/ANY/SOME subquery' + . 'AND lastSeen < (SELECT maxLastSeen FROM (SELECT (MAX(e3.lastSeen)-99) AS maxLastSeen FROM `' . $this->prefix . 'entry` e3 WHERE e3.id_feed=:id_feed) recent) ' //Do not remove the most newly seen articles, plus a few seconds of tolerance + . 'AND id NOT IN (SELECT id FROM (SELECT e2.id FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed=:id_feed ORDER BY id DESC LIMIT :keep) keep)'; //Double select: MySQL doesn't support 'LIMIT & IN/ALL/ANY/SOME subquery' $stm = $this->bd->prepare($sql); $id_max = intval($date_min) . '000000'; -- cgit v1.2.3 From 5f545dfda2b6700579b856c815e1914a2dd62553 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 10 May 2015 12:14:38 +0200 Subject: Global option to mark updated articles as unread https://github.com/FreshRSS/FreshRSS/issues/798 --- app/Controllers/feedController.php | 3 ++- data/config.default.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 5657d4a88..03f438888 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -342,7 +342,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } else { //This entry already exists but has been updated Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() . ', old hash ' . $existingHash . ', new hash ' . $entry->hash()); - $entry->_isRead(null); //Change is_read according to policy. //TODO: Implement option + //TODO: Make an updated/is_read policy by feed, in addition to the global one. + $entry->_isRead(FreshRSS_Context::$system_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy. if (!$entryDAO->hasTransaction()) { $entryDAO->beginTransaction(); } diff --git a/data/config.default.php b/data/config.default.php index 8be203d36..dc947f154 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -55,6 +55,10 @@ return array( # SimplePie, which is retrieving RSS feeds via HTTP requests. 'simplepie_syslog_enabled' => true, + # In the case an article has changed (e.g. updated content): + # Set to `true` to mark it unread, or `false` to leave it as-is. + 'mark_updated_article_unread' => false, + 'limits' => array( # Duration in seconds of the SimplePie cache, -- cgit v1.2.3 From 0d0c6b7493161d350ca2eb1d4c45c0c70cfcbb92 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 10 May 2015 14:04:12 +0200 Subject: Moved updated/unread option from global to user https://github.com/FreshRSS/FreshRSS/issues/798 --- app/Controllers/configureController.php | 1 + app/Controllers/feedController.php | 2 +- app/Models/ConfigurationSetter.php | 4 ++++ app/i18n/de/conf.php | 1 + app/i18n/en/conf.php | 1 + app/i18n/fr/conf.php | 1 + app/views/configure/reading.phtml | 9 +++++++++ data/config.default.php | 4 ---- data/users/_/config.default.php | 5 +++++ 9 files changed, 23 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index fc92aa0c2..248a3edcc 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -112,6 +112,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { FreshRSS_Context::$user_conf->sticky_post = Minz_Request::param('sticky_post', false); FreshRSS_Context::$user_conf->reading_confirm = Minz_Request::param('reading_confirm', false); FreshRSS_Context::$user_conf->auto_remove_article = Minz_Request::param('auto_remove_article', false); + FreshRSS_Context::$user_conf->mark_updated_article_unread = Minz_Request::param('mark_updated_article_unread', false); FreshRSS_Context::$user_conf->sort_order = Minz_Request::param('sort_order', 'DESC'); FreshRSS_Context::$user_conf->mark_when = array( 'article' => Minz_Request::param('mark_open_article', false), diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 03f438888..a36a38ce2 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -343,7 +343,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() . ', old hash ' . $existingHash . ', new hash ' . $entry->hash()); //TODO: Make an updated/is_read policy by feed, in addition to the global one. - $entry->_isRead(FreshRSS_Context::$system_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy. + $entry->_isRead(FreshRSS_Context::$user_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy. if (!$entryDAO->hasTransaction()) { $entryDAO->beginTransaction(); } diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php index 7f433239c..4bd29ecb0 100644 --- a/app/Models/ConfigurationSetter.php +++ b/app/Models/ConfigurationSetter.php @@ -189,6 +189,10 @@ class FreshRSS_ConfigurationSetter { $data['auto_remove_article'] = $this->handleBool($value); } + private function _mark_updated_article_unread(&$data, $value) { + $data['mark_updated_article_unread'] = $this->handleBool($value); + } + private function _display_categories(&$data, $value) { $data['display_categories'] = $this->handleBool($value); } diff --git a/app/i18n/de/conf.php b/app/i18n/de/conf.php index 64c2c0945..df2c07d49 100644 --- a/app/i18n/de/conf.php +++ b/app/i18n/de/conf.php @@ -84,6 +84,7 @@ return array( 'articles_per_page' => 'Anzahl der Artikel pro Seite', 'auto_load_more' => 'Die nächsten Artikel am Seitenende laden', 'auto_remove_article' => 'Artikel nach dem Lesen verstecken', + 'mark_updated_article_unread' => 'Markieren Sie aktualisierte Artikel als ungelesen', 'confirm_enabled' => 'Bei der Aktion „Alle als gelesen markieren“ einen Bestätigungsdialog anzeigen', 'display_articles_unfolded' => 'Artikel standardmäßig ausgeklappt zeigen', 'display_categories_unfolded' => 'Kategorien standardmäßig eingeklappt zeigen', diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php index 308c45d2c..683781696 100644 --- a/app/i18n/en/conf.php +++ b/app/i18n/en/conf.php @@ -84,6 +84,7 @@ return array( 'articles_per_page' => 'Number of articles per page', 'auto_load_more' => 'Load next articles at the page bottom', 'auto_remove_article' => 'Hide articles after reading', + 'mark_updated_article_unread' => 'Mark updated articles as unread', 'confirm_enabled' => 'Display a confirmation dialog on “mark all as read” actions', 'display_articles_unfolded' => 'Show articles unfolded by default', 'display_categories_unfolded' => 'Show categories folded by default', diff --git a/app/i18n/fr/conf.php b/app/i18n/fr/conf.php index d38445b99..87f9be290 100644 --- a/app/i18n/fr/conf.php +++ b/app/i18n/fr/conf.php @@ -84,6 +84,7 @@ return array( 'articles_per_page' => 'Nombre d’articles par page', 'auto_load_more' => 'Charger les articles suivants en bas de page', 'auto_remove_article' => 'Cacher les articles après lecture', + 'mark_updated_article_unread' => 'Marquer les articles mis à jour comme non-lus', 'confirm_enabled' => 'Afficher une confirmation lors des actions “marquer tout comme lu”', 'display_articles_unfolded' => 'Afficher les articles dépliés par défaut', 'display_categories_unfolded' => 'Afficher les catégories pliées par défaut', diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml index 8b123afa8..1b7a101df 100644 --- a/app/views/configure/reading.phtml +++ b/app/views/configure/reading.phtml @@ -125,6 +125,15 @@
    +
    +
    + +
    +
    +
    diff --git a/data/config.default.php b/data/config.default.php index dc947f154..8be203d36 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -55,10 +55,6 @@ return array( # SimplePie, which is retrieving RSS feeds via HTTP requests. 'simplepie_syslog_enabled' => true, - # In the case an article has changed (e.g. updated content): - # Set to `true` to mark it unread, or `false` to leave it as-is. - 'mark_updated_article_unread' => false, - 'limits' => array( # Duration in seconds of the SimplePie cache, diff --git a/data/users/_/config.default.php b/data/users/_/config.default.php index 6d3f73a13..bf74ca1de 100644 --- a/data/users/_/config.default.php +++ b/data/users/_/config.default.php @@ -22,6 +22,11 @@ return array ( 'sticky_post' => true, 'reading_confirm' => false, 'auto_remove_article' => false, + + # In the case an article has changed (e.g. updated content): + # Set to `true` to mark it unread, or `false` to leave it as-is. + 'mark_updated_article_unread' => false, + 'sort_order' => 'DESC', 'anon_access' => false, 'mark_when' => array ( -- cgit v1.2.3 From 79f0f2bbb48f5f4fb1ebd9350bf9bf6e1182e6cf Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 10 May 2015 18:21:21 +0200 Subject: Bug Page 403 ne peut s'afficher si Translate n'est pas instancié avant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/FreshRSS/FreshRSS/issues/821 --- app/Controllers/feedController.php | 2 +- app/FreshRSS.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index a36a38ce2..0443b4159 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -146,7 +146,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $name = $feed->name(); $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); if ($feed === null) { - Minz_Request::bad(_t('feed_not_added', $name), $url_redirect); + Minz_Request::bad(_t('feedback.sub.feed.not_added', $name), $url_redirect); } $values = array( diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 021687999..044de9cd4 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -63,10 +63,11 @@ class FreshRSS extends Minz_FrontController { // Basic protection against XSRF attacks FreshRSS_Auth::removeAccess(); $http_referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; + Minz_Translate::init('en'); //TODO: Better choice of fallback language Minz_Error::error( 403, array('error' => array( - _t('access_denied'), + _t('feedback.access.denied'), ' [HTTP_REFERER=' . htmlspecialchars($http_referer) . ']' )) ); -- cgit v1.2.3 From f7a502b06e7b0fe0b8bbc5f41d96d4ea08eee98a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 10 May 2015 19:20:46 +0200 Subject: Cannot create an account with sqlite https://github.com/FreshRSS/FreshRSS/issues/770 --- app/install.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app') diff --git a/app/install.php b/app/install.php index 177173fdb..5f43b6415 100644 --- a/app/install.php +++ b/app/install.php @@ -741,6 +741,13 @@ function printStep3() { -- cgit v1.2.3 From 0745252b68f6f9b7c91ea437893b5f33b7a224c3 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 10 May 2015 20:31:03 +0200 Subject: Hexadecimal literals do not work with SQLite/PDO X'09AF' hexadecimal literals do not work with SQLite/PDO. Replaced by PHP hex2bin(). https://github.com/FreshRSS/FreshRSS/commit/711530a512b370d79b079205ce1f8376174f7f03 --- app/Models/EntryDAO.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index ebaeb3868..172eac897 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -54,7 +54,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { . ', link, date, lastSeen, hash, is_read, is_favorite, id_feed, tags) ' . 'VALUES(?, ?, ?, ?, ' . ($this->isCompressed() ? 'COMPRESS(?)' : '?') - . ', ?, ?, ?, X?, ?, ?, ?, ?)'; + . ', ?, ?, ?, ?, ?, ?, ?, ?)'; $this->addEntryPrepared = $this->bd->prepare($sql); } @@ -67,7 +67,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { substr($valuesTmp['link'], 0, 1023), $valuesTmp['date'], time(), - $valuesTmp['hash'], + hex2bin($valuesTmp['hash']), // X'09AF' hexadecimal literals do not work with SQLite/PDO $valuesTmp['is_read'] ? 1 : 0, $valuesTmp['is_favorite'] ? 1 : 0, $valuesTmp['id_feed'], @@ -77,7 +77,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if ($this->addEntryPrepared && $this->addEntryPrepared->execute($values)) { return $this->bd->lastInsertId(); } else { - $info = $this->addEntryPrepared == null ? array(2 => 'syntax error') : $this->addEntryPrepared->errorInfo(); + $info = $this->addEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->addEntryPrepared->errorInfo(); if ($this->autoAddColumn($info)) { return $this->addEntry($valuesTmp); } elseif ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries @@ -99,7 +99,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $sql = 'UPDATE `' . $this->prefix . 'entry` ' . 'SET title=?, author=?, ' . ($this->isCompressed() ? 'content_bin=COMPRESS(?)' : 'content=?') - . ', link=?, date=?, lastSeen=?, hash=X?, ' + . ', link=?, date=?, lastSeen=?, hash=?, ' . ($valuesTmp['is_read'] === null ? '' : 'is_read=?, ') . 'tags=? ' . 'WHERE id_feed=? AND guid=?'; @@ -113,7 +113,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { substr($valuesTmp['link'], 0, 1023), $valuesTmp['date'], time(), - $valuesTmp['hash'], + hex2bin($valuesTmp['hash']), ); if ($valuesTmp['is_read'] !== null) { $values[] = $valuesTmp['is_read'] ? 1 : 0; @@ -127,7 +127,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute($values)) { return $this->bd->lastInsertId(); } else { - $info = $this->updateEntryPrepared == null ? array(2 => 'syntax error') : $this->updateEntryPrepared->errorInfo(); + $info = $this->updateEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->updateEntryPrepared->errorInfo(); if ($this->autoAddColumn($info)) { return $this->updateEntry($valuesTmp); } @@ -598,7 +598,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $result; } else { - $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); + $info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo(); if ($this->autoAddColumn($info)) { return $this->listHashForFeedGuids($id_feed, $guids); } @@ -619,7 +619,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if ($stm && $stm->execute($values)) { return $stm->rowCount(); } else { - $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); + $info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo(); if ($this->autoAddColumn($info)) { return $this->updateLastSeen($id_feed, $guids); } -- cgit v1.2.3 From ead849dbe3717966dff50e55d6bf849dafde87b7 Mon Sep 17 00:00:00 2001 From: Tets Date: Mon, 11 May 2015 10:20:17 +0200 Subject: Czech translation --- app/i18n/cz/feedback.php | 2 +- app/i18n/cz/sub.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/i18n/cz/feedback.php b/app/i18n/cz/feedback.php index 52ff029ef..b75a4a15a 100644 --- a/app/i18n/cz/feedback.php +++ b/app/i18n/cz/feedback.php @@ -11,7 +11,7 @@ return array( 'auth' => array( 'form' => array( 'not_set' => 'Nastal problém s konfigurací přihlašovacího systému. Zkuste to prosím později.', - 'set' => 'Webové formulář je nyní výchozí přihlašovací systém.', + 'set' => 'Webový formulář je nyní výchozí přihlašovací systém.', ), 'login' => array( 'invalid' => 'Login není platný', diff --git a/app/i18n/cz/sub.php b/app/i18n/cz/sub.php index d7ff63fe9..78712506c 100644 --- a/app/i18n/cz/sub.php +++ b/app/i18n/cz/sub.php @@ -21,7 +21,7 @@ return array( 'css_help' => 'Stáhne zkrácenou verzi RSS kanálů (pozor, náročnější na čas!)', 'css_path' => 'Původní CSS soubor článku z webových stránek', 'description' => 'Popis', - 'empty' => 'Kanál je prazdný. Ověřte prosím zda je ještě autorem udržován.', + 'empty' => 'Kanál je prázdný. Ověřte prosím zda je ještě autorem udržován.', 'error' => 'Vyskytl se problém s kanálem. Ověřte že je vždy dostupný, prosím, a poté jej aktualizujte.', 'in_main_stream' => 'Zobrazit ve “Všechny kanály”', 'informations' => 'Informace', -- cgit v1.2.3 From 217c191a1ba3ac03b847d261a32e19975380fcad Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 11 May 2015 22:42:41 +0200 Subject: More SQLite compatibility Additional changes to add compatibility with SQLite for the new hash/lastSeen mode of updating articles. --- app/Models/EntryDAO.php | 71 ++++++++++++++++++++++++------------------ app/Models/EntryDAOSQLite.php | 15 +++++++++ app/Models/FeedDAO.php | 11 ++++--- app/SQL/install.sql.mysql.php | 2 +- app/SQL/install.sql.sqlite.php | 2 +- app/install.php | 2 ++ lib/Minz/ModelPdo.php | 5 +++ 7 files changed, 70 insertions(+), 38 deletions(-) (limited to 'app') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 172eac897..eae9683ad 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -6,38 +6,48 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return parent::$sharedDbType !== 'sqlite'; } - protected function autoAddColumn($errorInfo) { - if (isset($errorInfo[0])) { - if ($errorInfo[0] == '42S22') { //ER_BAD_FIELD_ERROR - $hasTransaction = false; - try { - $stm = null; - if (stripos($errorInfo[2], 'lastSeen') !== false) { //v1.2 - if (!$this->bd->inTransaction()) { - $this->bd->beginTransaction(); - $hasTransaction = true; - } - $stm = $this->bd->prepare('ALTER TABLE `' . $this->prefix . 'entry` ADD COLUMN lastSeen INT(11) NOT NULL'); - if ($stm && $stm->execute()) { - $stm = $this->bd->prepare('CREATE INDEX entry_lastSeen_index ON `' . $this->prefix . 'entry`(`lastSeen`);'); //"IF NOT EXISTS" does not exist in MySQL 5.7 - if ($stm && $stm->execute()) { - if ($hasTransaction) { - $this->bd->commit(); - } - return true; - } - } + protected function addColumn($name) { + Minz_Log::debug('FreshRSS_EntryDAO::autoAddColumn: ' . $name); + $hasTransaction = false; + try { + $stm = null; + if ($name === 'lastSeen') { //v1.2 + if (!$this->bd->inTransaction()) { + $this->bd->beginTransaction(); + $hasTransaction = true; + } + $stm = $this->bd->prepare('ALTER TABLE `' . $this->prefix . 'entry` ADD COLUMN lastSeen INT(11) DEFAULT 0'); + if ($stm && $stm->execute()) { + $stm = $this->bd->prepare('CREATE INDEX entry_lastSeen_index ON `' . $this->prefix . 'entry`(`lastSeen`);'); //"IF NOT EXISTS" does not exist in MySQL 5.7 + if ($stm && $stm->execute()) { if ($hasTransaction) { - $this->bd->rollBack(); + $this->bd->commit(); } - } elseif (stripos($errorInfo[2], 'hash') !== false) { //v1.2 - $stm = $this->bd->prepare('ALTER TABLE `' . $this->prefix . 'entry` ADD COLUMN hash BINARY(16) NOT NULL'); - return $stm && $stm->execute(); + return true; } - } catch (Exception $e) { - Minz_Log::debug('FreshRSS_EntryDAO::autoAddColumn error: ' . $e->getMessage()); - if ($hasTransaction) { - $this->bd->rollBack(); + } + if ($hasTransaction) { + $this->bd->rollBack(); + } + } elseif ($name === 'hash') { //v1.2 + $stm = $this->bd->prepare('ALTER TABLE `' . $this->prefix . 'entry` ADD COLUMN hash BINARY(16)'); + return $stm && $stm->execute(); + } + } catch (Exception $e) { + Minz_Log::debug('FreshRSS_EntryDAO::autoAddColumn error: ' . $e->getMessage()); + if ($hasTransaction) { + $this->bd->rollBack(); + } + } + return false; + } + + protected function autoAddColumn($errorInfo) { + if (isset($errorInfo[0])) { + if ($errorInfo[0] == '42S22') { //ER_BAD_FIELD_ERROR + foreach (array('lastSeen', 'hash') as $column) { + if (stripos($errorInfo[2], $column) !== false) { + return $this->addColumn($column); } } } @@ -82,7 +92,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $this->addEntry($valuesTmp); } elseif ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries Minz_Log::error('SQL error addEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] - . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']); + . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']. ' ' . $this->addEntryPrepared); } return false; } @@ -597,7 +607,6 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { } return $result; } else { - $info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo(); if ($this->autoAddColumn($info)) { return $this->listHashForFeedGuids($id_feed, $guids); diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index ffe0f037c..ff049d813 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -2,6 +2,21 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { + protected function autoAddColumn($errorInfo) { + if (empty($errorInfo[0]) || $errorInfo[0] == '42S22') { //ER_BAD_FIELD_ERROR + if ($tableInfo = $this->bd->query("SELECT sql FROM sqlite_master where name='entry'")) { + $showCreate = $tableInfo->fetchColumn(); + Minz_Log::debug('FreshRSS_EntryDAOSQLite::autoAddColumn: ' . $showCreate); + foreach (array('lastSeen', 'hash') as $column) { + if (stripos($showCreate, $column) === false) { + return $this->addColumn($column); + } + } + } + } + return false; + } + protected function sqlConcat($s1, $s2) { return $s1 . '||' . $s2; } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 76025ff53..475d39286 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -330,11 +330,12 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { . 'AND id NOT IN (SELECT id FROM (SELECT e2.id FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed=:id_feed ORDER BY id DESC LIMIT :keep) keep)'; //Double select: MySQL doesn't support 'LIMIT & IN/ALL/ANY/SOME subquery' $stm = $this->bd->prepare($sql); - $id_max = intval($date_min) . '000000'; - - $stm->bindParam(':id_feed', $id, PDO::PARAM_INT); - $stm->bindParam(':id_max', $id_max, PDO::PARAM_STR); - $stm->bindParam(':keep', $keep, PDO::PARAM_INT); + if ($stm) { + $id_max = intval($date_min) . '000000'; + $stm->bindParam(':id_feed', $id, PDO::PARAM_INT); + $stm->bindParam(':id_max', $id_max, PDO::PARAM_STR); + $stm->bindParam(':keep', $keep, PDO::PARAM_INT); + } if ($stm && $stm->execute()) { return $stm->rowCount(); diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php index afdd821b2..9c6af405d 100644 --- a/app/SQL/install.sql.mysql.php +++ b/app/SQL/install.sql.mysql.php @@ -41,7 +41,7 @@ CREATE TABLE IF NOT EXISTS `%1$sentry` ( `content_bin` blob, -- v0.7 `link` varchar(1023) CHARACTER SET latin1 NOT NULL, `date` int(11), -- Until year 2038 - `lastSeen` INT(11) NOT NULL, -- v1.2, Until year 2038 + `lastSeen` INT(11) DEFAULT 0, -- v1.2, Until year 2038 `hash` BINARY(16), -- v1.2 `is_read` boolean NOT NULL DEFAULT 0, `is_favorite` boolean NOT NULL DEFAULT 0, diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php index 7517ead45..77e8e094c 100644 --- a/app/SQL/install.sql.sqlite.php +++ b/app/SQL/install.sql.sqlite.php @@ -39,7 +39,7 @@ $SQL_CREATE_TABLES = array( `content` text, `link` varchar(1023) NOT NULL, `date` int(11), -- Until year 2038 - `lastSeen` INT(11) NOT NULL, -- v1.2, Until year 2038 + `lastSeen` INT(11) DEFAULT 0, -- v1.2, Until year 2038 `hash` BINARY(16), -- v1.2 `is_read` boolean NOT NULL DEFAULT 0, `is_favorite` boolean NOT NULL DEFAULT 0, diff --git a/app/install.php b/app/install.php index 177173fdb..86afb9318 100644 --- a/app/install.php +++ b/app/install.php @@ -168,8 +168,10 @@ function saveStep3() { $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] .(empty($_SESSION['default_user']) ? '' :($_SESSION['default_user'] . '_')); } + //TODO: load `config.default.php` as default $config_array = array( 'environment' => 'production', + 'simplepie_syslog_enabled' => true, 'salt' => $_SESSION['salt'], 'title' => $_SESSION['title'], 'default_user' => $_SESSION['default_user'], diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index ac7a1bed7..3e8ec1f43 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -134,4 +134,9 @@ class MinzPDO extends PDO { MinzPDO::check($statement); return parent::exec($statement); } + + public function query($statement) { + MinzPDO::check($statement); + return parent::query($statement); + } } -- cgit v1.2.3 From 5adaf177210bcd7af0df30d8bebea9b3de67b443 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 15 May 2015 15:38:54 +0200 Subject: Revert bug HTTP 301 introduced by Refactor feedController https://github.com/FreshRSS/FreshRSS/commit/e2da6e6e6b871dc3dbc289cdd40ba401a21d8e91 --- app/Controllers/feedController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 0443b4159..8db273aca 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -301,6 +301,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { continue; } + $url = $feed->url(); //For detection of HTTP 301 try { // Load entries $feed->load(false); @@ -311,7 +312,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { continue; } - $url = $feed->url(); $feed_history = $feed->keepHistory(); if ($feed_history == -2) { // TODO: -2 must be a constant! -- cgit v1.2.3 From 9fe8a7c62dcd815065983613991f000b17444f5c Mon Sep 17 00:00:00 2001 From: thomasE1993 Date: Fri, 15 May 2015 20:09:58 +0200 Subject: Update admin.php --- app/i18n/de/admin.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'app') diff --git a/app/i18n/de/admin.php b/app/i18n/de/admin.php index bcd0fcc61..8550805ee 100644 --- a/app/i18n/de/admin.php +++ b/app/i18n/de/admin.php @@ -19,15 +19,15 @@ return array( 'check_install' => array( 'cache' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/cache. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/cache sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/cache sind in Ordnung.', ), 'categories' => array( 'nok' => 'Die Tabelle category ist schlecht konfiguriert.', - 'ok' => 'Die Tabelle category ist in Ordnung.', + 'ok' => 'Die Tabelle category ist korrekt konfiguriert.', ), 'connection' => array( 'nok' => 'Verbindung zur Datenbank kann nicht aufgebaut werden.', - 'ok' => 'Verbindung zur Datenbank ist in Ordnung.', + 'ok' => 'Verbindung zur Datenbank konnte aufgebaut werden.', ), 'ctype' => array( 'nok' => 'Ihnen fehlt eine benötigte Bibliothek für die Überprüfung von Zeichentypen (php-ctype).', @@ -39,7 +39,7 @@ return array( ), 'data' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data sind in Ordnung.', ), 'database' => 'Datenbank-Installation', 'dom' => array( @@ -48,19 +48,19 @@ return array( ), 'entries' => array( 'nok' => 'Die Tabelle entry ist schlecht konfiguriert.', - 'ok' => 'Die Tabelle entry ist in Ordnung.', + 'ok' => 'Die Tabelle entry ist korrekt konfiguriert.', ), 'favicons' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/favicons. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/favicons sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/favicons sind in Ordnung.', ), 'feeds' => array( 'nok' => 'Die Tabelle feed ist schlecht konfiguriert.', - 'ok' => 'Die Tabelle feed ist in Ordnung.', + 'ok' => 'Die Tabelle feed ist korrekt konfiguriert.', ), 'files' => 'Datei-Installation', 'json' => array( - 'nok' => 'Ihnen fehlt JSON (Paket php5-json).', + 'nok' => 'Ihnen fehlt die JSON-Erweiterung (Paket php5-json).', 'ok' => 'Sie haben die JSON-Erweiterung.', ), 'minz' => array( @@ -77,7 +77,7 @@ return array( ), 'persona' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/persona. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/persona sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/persona sind in Ordnung.', ), 'php' => array( '_' => 'PHP-Installation', @@ -91,11 +91,11 @@ return array( 'title' => 'Installationsüberprüfung', 'tokens' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/tokens. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/tokens sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/tokens sind in Ordnung.', ), 'users' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/users. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/users sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/users sind in Ordnung.', ), 'zip' => array( 'nok' => 'Ihnen fehlt die ZIP-Erweiterung (Paket php5-zip).', @@ -120,22 +120,22 @@ return array( 'category' => 'Kategorie', 'entry_count' => 'Anzahl der Einträge', 'entry_per_category' => 'Einträge pro Kategorie', - 'entry_per_day' => 'Einträge pro Tag (letzte 30 Tage)', + 'entry_per_day' => 'Einträge pro Tag (letzten 30 Tage)', 'entry_per_day_of_week' => 'Pro Wochentag (Durchschnitt: %.2f Nachrichten)', 'entry_per_hour' => 'Pro Stunde (Durchschnitt: %.2f Nachrichten)', 'entry_per_month' => 'Pro Monat (Durchschnitt: %.2f Nachrichten)', 'entry_repartition' => 'Einträge-Verteilung', 'feed' => 'Feed', 'feed_per_category' => 'Feeds pro Kategorie', - 'idle' => 'Untätige Feeds', + 'idle' => 'Inkative Feeds', 'main' => 'Haupt-Statistiken', 'main_stream' => 'Haupt-Feeds', 'menu' => array( - 'idle' => 'Untätige Feeds', + 'idle' => 'Inkative Feeds', 'main' => 'Haupt-Statistiken', 'repartition' => 'Artikel-Verteilung', ), - 'no_idle' => 'Es gibt keinen untätigen Feed!', + 'no_idle' => 'Es gibt keinen inaktiven Feed!', 'number_entries' => '%d Artikel', 'percent_of_total' => '%% Gesamt', 'repartition' => 'Artikel-Verteilung', @@ -152,7 +152,7 @@ return array( 'check' => 'Auf neue Aktualisierungen prüfen', 'current_version' => 'Ihre aktuelle Version von FreshRSS ist %s.', 'last' => 'Letzte Überprüfung: %s', - 'none' => 'Keine Aktualisierung zum Anwenden', + 'none' => 'Keine ausstehende Aktualisierung', 'title' => 'System aktualisieren', ), 'user' => array( -- cgit v1.2.3 From bd21838bd0edd0169c583d25a475f9eea7636333 Mon Sep 17 00:00:00 2001 From: thomasE1993 Date: Fri, 15 May 2015 20:18:24 +0200 Subject: Update conf.php --- app/i18n/de/conf.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/i18n/de/conf.php b/app/i18n/de/conf.php index df2c07d49..4a0a77ddd 100644 --- a/app/i18n/de/conf.php +++ b/app/i18n/de/conf.php @@ -5,8 +5,8 @@ return array( '_' => 'Archivierung', 'advanced' => 'Erweitert', 'delete_after' => 'Entferne Artikel nach', - 'help' => 'Weitere Optionen sind in den Einstellungen der individuellen Nachrichten-Feeds vorhanden.', - 'keep_history_by_feed' => 'Minimale Anzahl an Artikeln, die pro Feed behalten wird', + 'help' => 'Weitere Optionen sind in den Einstellungen der individuellen Feeds verfügbar.', + 'keep_history_by_feed' => 'Minimale Anzahl an Artikeln, die pro Feed behalten werden', 'optimize' => 'Datenbank optimieren', 'optimize_help' => 'Sollte gelegentlich durchgeführt werden, um die Größe der Datenbank zu reduzieren.', 'purge_now' => 'Jetzt bereinigen', @@ -32,10 +32,10 @@ return array( 'title' => 'Anzeige', 'width' => array( 'content' => 'Inhaltsbreite', - 'large' => 'Weit', + 'large' => 'Gross', 'medium' => 'Mittel', 'no_limit' => 'Keine Begrenzung', - 'thin' => 'Schmal', + 'thin' => 'Klein', ), ), 'query' => array( @@ -136,14 +136,14 @@ return array( 'wallabag' => 'wallabag', ), 'shortcut' => array( - '_' => 'Tastaturkürzel', + '_' => 'Tastenkombination', 'article_action' => 'Artikelaktionen', 'auto_share' => 'Teilen', 'auto_share_help' => 'Wenn es nur eine Option zum Teilen gibt, wird diese verwendet. Ansonsten sind die Optionen über ihre Nummer erreichbar.', 'close_dropdown' => 'Menüs schließen', - 'collapse_article' => 'Zusammenfalten', + 'collapse_article' => 'Einklappen', 'first_article' => 'Zum ersten Artikel springen', - 'focus_search' => 'Auf Suchfeld zugreifen', + 'focus_search' => 'Auf das Suchfeld zugreifen', 'help' => 'Dokumentation anzeigen', 'javascript' => 'JavaScript muss aktiviert sein, um Tastaturkürzel benutzen zu können', 'last_article' => 'Zum letzten Artikel springen', @@ -151,13 +151,13 @@ return array( 'mark_read' => 'Als gelesen markieren', 'mark_favorite' => 'Als Favorit markieren', 'navigation' => 'Navigation', - 'navigation_help' => 'Mit der "Umschalttaste" finden die Tastaturkürzel auf Feeds Anwendung.
    Mit der "Alt-Taste" finden die Tastaturkürzel auf Kategorien Anwendung.', + 'navigation_help' => 'Mit der "Umschalttaste" finden die Tastenkombination auf Feeds Anwendung.
    Mit der "Alt-Taste" finden die Tastenkombination auf Kategorien Anwendung.', 'next_article' => 'Zum nächsten Artikel springen', 'other_action' => 'Andere Aktionen', 'previous_article' => 'Zum vorherigen Artikel springen', 'see_on_website' => 'Auf der Original-Webseite ansehen', 'shift_for_all_read' => '+ Umschalttaste, um alle Artikel als gelesen zu markieren.', - 'title' => 'Tastaturkürzel', + 'title' => 'Tastenkombination', 'user_filter' => 'Auf Benutzerfilter zugreifen', 'user_filter_help' => 'Wenn es nur einen Benutzerfilter gibt, wird dieser verwendet. Ansonsten sind die Filter über ihre Nummer erreichbar.', ), -- cgit v1.2.3 From 70f0fc8d614ae49aa21ef9f1ce1b3f06e294512f Mon Sep 17 00:00:00 2001 From: thomasE1993 Date: Sat, 16 May 2015 18:52:08 +0200 Subject: Update feedback.php --- app/i18n/de/feedback.php | 60 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'app') diff --git a/app/i18n/de/feedback.php b/app/i18n/de/feedback.php index 48f8b74f5..4c15aadc3 100644 --- a/app/i18n/de/feedback.php +++ b/app/i18n/de/feedback.php @@ -15,19 +15,19 @@ return array( ), 'login' => array( 'invalid' => 'Anmeldung ist ungültig', - 'success' => 'Sie sind verbunden', + 'success' => 'Sie sind angemeldet', ), 'logout' => array( - 'success' => 'Sie sind getrennt', + 'success' => 'Sie sind abgemeldet', ), 'no_password_set' => 'Administrator-Passwort ist nicht gesetzt worden. Dieses Feature ist nicht verfügbar.', 'not_persona' => 'Nur das Persona-System kann zurückgesetzt werden.', ), 'conf' => array( - 'error' => 'Während des Speicherung der Konfiguration trat ein Fehler auf', + 'error' => 'Während der Speicherung der Konfiguration trat ein Fehler auf', 'query_created' => 'Abfrage "%s" ist erstellt worden.', - 'shortcuts_updated' => 'Tastaturkürzel sind aktualisiert worden', - 'updated' => 'Konfiguration ist aktualisiert worden', + 'shortcuts_updated' => 'Die Tastenkombinationen sind aktualisiert worden', + 'updated' => 'Die Konfiguration ist aktualisiert worden', ), 'extensions' => array( 'already_enabled' => '%s ist bereits aktiviert', @@ -44,44 +44,44 @@ return array( 'not_found' => '%s existiert nicht', ), 'import_export' => array( - 'export_no_zip_extension' => 'Die Zip-Erweiterung fehlt auf Ihrem Server. Bitte versuchen Sie, Dateien eine nach der anderen zu exportieren.', + 'export_no_zip_extension' => 'Die Zip-Erweiterung fehlt auf Ihrem Server. Bitte versuchen Sie die Dateien eine nach der anderen zu exportieren.', 'feeds_imported' => 'Ihre Feeds sind importiert worden und werden jetzt aktualisiert', 'feeds_imported_with_errors' => 'Ihre Feeds sind importiert worden, aber es traten einige Fehler auf', - 'file_cannot_be_uploaded' => 'Datei kann nicht hochgeladen werden!', + 'file_cannot_be_uploaded' => 'Die Datei kann nicht hochgeladen werden!', 'no_zip_extension' => 'Die Zip-Erweiterung ist auf Ihrem Server nicht vorhanden.', 'zip_error' => 'Ein Fehler trat während des Zip-Imports auf.', ), 'sub' => array( 'actualize' => 'Aktualisieren', 'category' => array( - 'created' => 'Kategorie %s ist erstellt worden.', - 'deleted' => 'Kategorie ist gelöscht worden.', - 'emptied' => 'Kategorie ist geleert worden.', - 'error' => 'Kategorie kann nicht aktualisiert werden', - 'name_exists' => 'Kategorie-Name existiert bereits.', + 'created' => 'Die Kategorie %s ist erstellt worden.', + 'deleted' => 'Die Kategorie ist gelöscht worden.', + 'emptied' => 'Die Kategorie ist geleert worden.', + 'error' => 'Die Kategorie kann nicht aktualisiert werden', + 'name_exists' => 'Der Kategorie-Name existiert bereits.', 'no_id' => 'Sie müssen die ID der Kategorie präzisieren.', - 'no_name' => 'Kategorie-Name kann nicht leer sein.', + 'no_name' => 'Der Kategorie-Name kann nicht leer sein.', 'not_delete_default' => 'Sie können die Vorgabe-Kategorie nicht löschen!', 'not_exist' => 'Die Kategorie existiert nicht!', - 'over_max' => 'Sie haben Ihr Kategorien-Limit erreicht (%d)', - 'updated' => 'Kategorie ist aktualisiert worden.', + 'over_max' => 'Sie haben Ihre Kategorien-Limite erreicht (%d)', + 'updated' => 'Die Kategorie ist aktualisiert worden.', ), 'feed' => array( 'actualized' => '%s ist aktualisiert worden', - 'actualizeds' => 'RSS-Feeds sind aktualisiert worden', - 'added' => 'RSS-Feed %s ist hinzugefügt worden', + 'actualizeds' => 'Die RSS-Feeds sind aktualisiert worden', + 'added' => 'Der RSS-Feed %s ist hinzugefügt worden', 'already_subscribed' => 'Sie haben %s bereits abonniert', - 'deleted' => 'Feed ist gelöscht worden', - 'error' => 'Feed kann nicht aktualisiert werden', + 'deleted' => 'Der Feed ist gelöscht worden', + 'error' => 'Der Feed kann nicht aktualisiert werden', 'internal_problem' => 'Der RSS-Feed konnte nicht hinzugefügt werden. Für Details prüfen Sie die FressRSS-Protokolle.', - 'invalid_url' => 'URL %s ist ungültig', - 'marked_read' => 'Feeds sind als gelesen markiert worden', - 'n_actualized' => '%d Feeds sind aktualisiert worden', - 'n_entries_deleted' => '%d Artikel sind gelöscht worden', + 'invalid_url' => 'Die URL %s ist ungültig', + 'marked_read' => 'Die Feeds sind als gelesen markiert worden', + 'n_actualized' => 'Die %d Feeds sind aktualisiert worden', + 'n_entries_deleted' => 'Die %d Artikel sind gelöscht worden', 'no_refresh' => 'Es gibt keinen Feed zum Aktualisieren…', 'not_added' => '%s konnte nicht hinzugefügt werden', - 'over_max' => 'Sie haben Ihr Feeds-Limit erreicht (%d)', - 'updated' => 'Feed ist aktualisiert worden', + 'over_max' => 'Sie haben Ihre Feeds-Limite erreicht (%d)', + 'updated' => 'Der Feed ist aktualisiert worden', ), 'purge_completed' => 'Bereinigung abgeschlossen (%d Artikel gelöscht)', ), @@ -91,16 +91,16 @@ return array( 'file_is_nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses %s. Der HTTP-Server muss Schreibrechte besitzen', 'finished' => 'Aktualisierung abgeschlossen!', 'none' => 'Keine Aktualisierung zum Anwenden', - 'server_not_found' => 'Aktualisierungs-Server kann nicht gefunden werden. [%s]', + 'server_not_found' => 'Der Aktualisierungs-Server kann nicht gefunden werden. [%s]', ), 'user' => array( 'created' => array( - '_' => 'Benutzer %s ist erstellt worden', - 'error' => 'Benutzer %s kann nicht erstellt werden', + '_' => 'Der Benutzer %s ist erstellt worden', + 'error' => 'Der Benutzer %s kann nicht erstellt werden', ), 'deleted' => array( - '_' => 'Benutzer %s ist gelöscht worden', - 'error' => 'Benutzer %s kann nicht gelöscht werden', + '_' => 'Der Benutzer %s ist gelöscht worden', + 'error' => 'Der Benutzer %s kann nicht gelöscht werden', ), ), 'profile' => array( -- cgit v1.2.3 From 7c6ce30f59295d06ad7fc7f6c3e935d058836877 Mon Sep 17 00:00:00 2001 From: thomasE1993 Date: Sat, 16 May 2015 18:54:23 +0200 Subject: Update gen.php --- app/i18n/de/gen.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index 8970d5003..f24a52c2e 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -49,7 +49,7 @@ return array( 'april' => 'April', 'aug' => 'Aug', 'august' => 'August', - 'before_yesterday' => 'Vor gestern', + 'before_yesterday' => 'Vor vorgestern', 'dec' => 'Dez', 'december' => 'Dezember', 'feb' => 'Feb', @@ -93,7 +93,7 @@ return array( ), 'js' => array( 'category_empty' => 'Kategorie leeren', - 'confirm_action' => 'Sind Sie sicher, dass Sie diese Aktion durchführen wollen? Dies kann nicht abgebrochen werden!', + 'confirm_action' => 'Sind Sie sicher, dass Sie diese Aktion durchführen wollen? Diese Aktion kann nicht abgebrochen werden!', 'confirm_action_feed_cat' => 'Sind Sie sicher, dass Sie diese Aktion durchführen wollen? Sie werden zugehörige Favoriten und Benutzerabfragen verlieren. Dies kann nicht abgebrochen werden!', 'feedback' => array( 'body_new_articles' => 'Es gibt \\d neue Artikel zum Lesen auf FreshRSS.', -- cgit v1.2.3 From 450cc2d66f55817f85090ab742ebc351df9cbc43 Mon Sep 17 00:00:00 2001 From: thomasE1993 Date: Sat, 16 May 2015 18:55:31 +0200 Subject: Update index.php --- app/i18n/de/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/i18n/de/index.php b/app/i18n/de/index.php index 3449de87d..04798cdce 100644 --- a/app/i18n/de/index.php +++ b/app/i18n/de/index.php @@ -17,7 +17,7 @@ return array( ), 'feed' => array( 'add' => 'Sie können Feeds hinzufügen.', - 'empty' => 'Es gibt keinen Artikel zum Zeigen.', + 'empty' => 'Es gibt keinen Artikel zum Anzeigen.', 'rss_of' => 'RSS-Feed von %s', 'title' => 'Ihre RSS-Feeds', 'title_global' => 'Globale Ansicht', -- cgit v1.2.3 From fe2f6c74b9b2f5ed0f4c3f57b4bf2828e38e1f6a Mon Sep 17 00:00:00 2001 From: thomasE1993 Date: Sat, 16 May 2015 18:58:57 +0200 Subject: Update install.php --- app/i18n/de/install.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/i18n/de/install.php b/app/i18n/de/install.php index e9267bbbd..a5899bb52 100644 --- a/app/i18n/de/install.php +++ b/app/i18n/de/install.php @@ -3,8 +3,8 @@ return array( 'action' => array( 'finish' => 'Installation fertigstellen', - 'fix_errors_before' => 'Fehler korrigieren, bevor zum nächsten Schritt gesprungen wird.', - 'next_step' => 'Zum nächsten Schritt gehen', + 'fix_errors_before' => 'Bitte Fehler korrigieren, bevor zum nächsten Schritt gesprungen wird.', + 'next_step' => 'Zum nächsten Schritt springen', ), 'auth' => array( 'email_persona' => 'Anmelde-E-Mail-Adresse
    (für Mozilla Persona)', @@ -33,7 +33,7 @@ return array( '_' => 'Überprüfungen', 'cache' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/cache. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/cache sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/cache sind in Ordnung.', ), 'ctype' => array( 'nok' => 'Ihnen fehlt eine benötigte Bibliothek für die Überprüfung von Zeichentypen (php-ctype).', @@ -45,7 +45,7 @@ return array( ), 'data' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data sind in Ordnung.', ), 'dom' => array( 'nok' => 'Ihnen fehlt eine benötigte Bibliothek um DOM zu durchstöbern (Paket php-xml).', @@ -53,7 +53,7 @@ return array( ), 'favicons' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/favicons. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/favicons sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/favicons sind in Ordnung.', ), 'http_referer' => array( 'nok' => 'Bitte stellen Sie sicher, dass Sie Ihren HTTP REFERER nicht abändern.', @@ -73,7 +73,7 @@ return array( ), 'persona' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/persona. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/persona sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/persona sind in Ordnung.', ), 'php' => array( 'nok' => 'Ihre PHP-Version ist %s aber FreshRSS benötigt mindestens Version %s.', @@ -81,22 +81,22 @@ return array( ), 'users' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/users. Der HTTP-Server muss Schreibrechte besitzen.', - 'ok' => 'Berechtigungen des Verzeichnisses ./data/users sind in Ordnung.', + 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/users sind in Ordnung.', ), ), 'conf' => array( '_' => 'Allgemeine Konfiguration', - 'ok' => 'Allgemeine Konfiguration ist gespeichert worden.', + 'ok' => 'Die allgemeine Konfiguration ist gespeichert worden.', ), 'congratulations' => 'Glückwunsch!', 'default_user' => 'Nutzername des Standardbenutzers (maximal 16 alphanumerische Zeichen)', 'delete_articles_after' => 'Entferne Artikel nach', - 'fix_errors_before' => 'Fehler korrigieren, bevor zum nächsten Schritt gesprungen wird.', + 'fix_errors_before' => 'Bitte den Fehler korrigieren, bevor zum nächsten Schritt gesprungen wird.', 'javascript_is_better' => 'FreshRSS ist ansprechender mit aktiviertem JavaScript', 'language' => array( '_' => 'Sprache', 'choose' => 'Wählen Sie eine Sprache für FreshRSS', - 'defined' => 'Sprache ist festgelegt worden.', + 'defined' => 'Die Sprache ist festgelegt worden.', ), 'not_deleted' => 'Etwas ist schiefgelaufen; Sie müssen die Datei %s manuell löschen.', 'ok' => 'Der Installationsvorgang war erfolgreich.', -- cgit v1.2.3 From 044c4428062ea215c9fe2f46fb47078854048e61 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 16 May 2015 19:36:42 +0200 Subject: i18n: German Completed cherry-pick of https://github.com/FreshRSS/FreshRSS/pull/832 + corrections --- app/i18n/de/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/i18n/de/admin.php b/app/i18n/de/admin.php index 8550805ee..c0cbf6787 100644 --- a/app/i18n/de/admin.php +++ b/app/i18n/de/admin.php @@ -127,11 +127,11 @@ return array( 'entry_repartition' => 'Einträge-Verteilung', 'feed' => 'Feed', 'feed_per_category' => 'Feeds pro Kategorie', - 'idle' => 'Inkative Feeds', + 'idle' => 'Inaktive Feeds', 'main' => 'Haupt-Statistiken', 'main_stream' => 'Haupt-Feeds', 'menu' => array( - 'idle' => 'Inkative Feeds', + 'idle' => 'Inaktive Feeds', 'main' => 'Haupt-Statistiken', 'repartition' => 'Artikel-Verteilung', ), -- cgit v1.2.3 From 6985a73f1c2f9ca774d50f5b4aa3a5f4742e1faf Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sat, 16 May 2015 23:37:28 +0200 Subject: Typo fix --- app/i18n/en/gen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index b02b9f0f2..013c3495d 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -10,7 +10,7 @@ return array( 'empty' => 'Empty', 'enable' => 'Enable', 'export' => 'Export', - 'filter' => 'Filtrer', + 'filter' => 'Filter', 'import' => 'Import', 'manage' => 'Manage', 'mark_read' => 'Mark as read', -- cgit v1.2.3 From 6d31c60976f2cf8ca8adab7cb64a3d67f1ac6a00 Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 17 May 2015 01:18:49 +0200 Subject: Language fix --- app/i18n/en/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/i18n/en/admin.php b/app/i18n/en/admin.php index d2fcd3e82..155384afd 100644 --- a/app/i18n/en/admin.php +++ b/app/i18n/en/admin.php @@ -12,7 +12,7 @@ return array( 'title' => 'Authentication', 'title_reset' => 'Authentication reset', 'token' => 'Authentication token', - 'token_help' => 'Allows to access RSS output of the default user without authentication:', + 'token_help' => 'Allows access to RSS output of the default user without authentication:', 'type' => 'Authentication method', 'unsafe_autologin' => 'Allow unsafe automatic login using the format: ', ), -- cgit v1.2.3 From 35cdb89eed82ec7458b85cc734d384bdada111a3 Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 17 May 2015 01:30:35 +0200 Subject: Language fix + en_GB standardisation --- app/i18n/en/feedback.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/i18n/en/feedback.php b/app/i18n/en/feedback.php index 19af81e5b..c9189c0d0 100644 --- a/app/i18n/en/feedback.php +++ b/app/i18n/en/feedback.php @@ -2,7 +2,7 @@ return array( 'admin' => array( - 'optimization_complete' => 'Optimization complete', + 'optimization_complete' => 'Optimisation complete', ), 'access' => array( 'denied' => 'You don’t have permission to access this page', @@ -52,7 +52,7 @@ return array( 'zip_error' => 'An error occured during Zip import.', ), 'sub' => array( - 'actualize' => 'Actualize', + 'actualize' => 'Actualise', 'category' => array( 'created' => 'Category %s has been created.', 'deleted' => 'Category has been deleted.', @@ -86,7 +86,7 @@ return array( 'purge_completed' => 'Purge completed (%d articles deleted)', ), 'update' => array( - 'can_apply' => 'FreshRSS will be now updated to the version %s.', + 'can_apply' => 'FreshRSS will now be updated to the version %s.', 'error' => 'The update process has encountered an error: %s', 'file_is_nok' => 'Check permissions on %s directory. HTTP server must have rights to write into', 'finished' => 'Update completed!', -- cgit v1.2.3 From af166f6c5344d727744e08d22f605cc57ec618f8 Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 17 May 2015 01:33:43 +0200 Subject: Language fix --- app/i18n/en/install.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/i18n/en/install.php b/app/i18n/en/install.php index 2bc6bd38f..742c73313 100644 --- a/app/i18n/en/install.php +++ b/app/i18n/en/install.php @@ -3,11 +3,11 @@ return array( 'action' => array( 'finish' => 'Complete installation', - 'fix_errors_before' => 'Fix errors before skip to the next step.', + 'fix_errors_before' => 'Please fix errors before before skipping to the next step.', 'next_step' => 'Go to the next step', ), 'auth' => array( - 'email_persona' => 'Login mail address
    (for Mozilla Persona)', + 'email_persona' => 'Login email address
    (for Mozilla Persona)', 'form' => 'Web form (traditional, requires JavaScript)', 'http' => 'HTTP (for advanced users with HTTPS)', 'none' => 'None (dangerous)', @@ -91,7 +91,7 @@ return array( 'congratulations' => 'Congratulations!', 'default_user' => 'Username of the default user (maximum 16 alphanumeric characters)', 'delete_articles_after' => 'Remove articles after', - 'fix_errors_before' => 'Fix errors before skip to the next step.', + 'fix_errors_before' => 'Please fix errors before before skipping to the next step.', 'javascript_is_better' => 'FreshRSS is more pleasant with JavaScript enabled', 'language' => array( '_' => 'Language', -- cgit v1.2.3 From cad42ea55f8f974899328bed74cf2b9d7fffe4a2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 17 May 2015 12:32:46 +0200 Subject: i18n: en-GB revert https://github.com/FreshRSS/FreshRSS/commit/af166f6c5344d727744e08d22f605cc57ec618f8#commitcomment-11229341 --- app/i18n/en/install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/i18n/en/install.php b/app/i18n/en/install.php index 742c73313..d4137309a 100644 --- a/app/i18n/en/install.php +++ b/app/i18n/en/install.php @@ -3,7 +3,7 @@ return array( 'action' => array( 'finish' => 'Complete installation', - 'fix_errors_before' => 'Please fix errors before before skipping to the next step.', + 'fix_errors_before' => 'Please fix errors before skipping to the next step.', 'next_step' => 'Go to the next step', ), 'auth' => array( @@ -91,7 +91,7 @@ return array( 'congratulations' => 'Congratulations!', 'default_user' => 'Username of the default user (maximum 16 alphanumeric characters)', 'delete_articles_after' => 'Remove articles after', - 'fix_errors_before' => 'Please fix errors before before skipping to the next step.', + 'fix_errors_before' => 'Please fix errors before skipping to the next step.', 'javascript_is_better' => 'FreshRSS is more pleasant with JavaScript enabled', 'language' => array( '_' => 'Language', -- cgit v1.2.3 From 265f09f25726102249ff3819ae810f85dee2849f Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Mon, 18 May 2015 09:02:28 +0200 Subject: Language fix --- app/i18n/en/gen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 013c3495d..6e47e0921 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -150,7 +150,7 @@ return array( 'wallabag' => 'wallabag', ), 'short' => array( - 'attention' => 'Attention!', + 'attention' => 'Warning!', 'blank_to_disable' => 'Leave blank to disable', 'by_author' => 'By %s', 'by_default' => 'By default', -- cgit v1.2.3 From 6263ecef2fde84aa317ccd4d0b784ac6c2ad2295 Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Mon, 18 May 2015 09:06:37 +0200 Subject: Language fix --- app/i18n/en/conf.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php index 683781696..42a06906d 100644 --- a/app/i18n/en/conf.php +++ b/app/i18n/en/conf.php @@ -5,9 +5,9 @@ return array( '_' => 'Archiving', 'advanced' => 'Advanced', 'delete_after' => 'Remove articles after', - 'help' => 'More options are available in the individual stream settings', + 'help' => 'More options are available in the individual feed settings', 'keep_history_by_feed' => 'Minimum number of articles to keep by feed', - 'optimize' => 'Optimize database', + 'optimize' => 'Optimise database', 'optimize_help' => 'To do occasionally to reduce the size of the database', 'purge_now' => 'Purge now', 'title' => 'Archiving', @@ -72,7 +72,7 @@ return array( ), 'profile' => array( '_' => 'Profile management', - 'email_persona' => 'Login mail address
    (for Mozilla Persona)', + 'email_persona' => 'Login email address
    (for Mozilla Persona)', 'password_api' => 'Password API
    (e.g., for mobile apps)', 'password_form' => 'Password
    (for the Web-form login method)', 'password_format' => 'At least 7 characters', -- cgit v1.2.3 From 7524811c963d4e90df60ef9b3ebdae62e4da3e60 Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Mon, 18 May 2015 09:09:28 +0200 Subject: Language fix --- app/i18n/en/sub.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/i18n/en/sub.php b/app/i18n/en/sub.php index 2b62e4775..8fe150bb2 100644 --- a/app/i18n/en/sub.php +++ b/app/i18n/en/sub.php @@ -18,7 +18,7 @@ return array( 'password' => 'HTTP password', 'username' => 'HTTP username', ), - 'css_help' => 'Retrieves truncated RSS feeds (attention, requires more time!)', + 'css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)', 'css_path' => 'Articles CSS path on original website', 'description' => 'Description', 'empty' => 'This feed is empty. Please verify that it is still maintained.', @@ -26,7 +26,7 @@ return array( 'in_main_stream' => 'Show in main stream', 'informations' => 'Information', 'keep_history' => 'Minimum number of articles to keep', - 'moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under %s.', + 'moved_category_deleted' => 'When you delete a category, its feeds are automatically classified under %s.', 'no_selected' => 'No feed selected.', 'number_entries' => '%d articles', 'stats' => 'Statistics', -- cgit v1.2.3 From 27d2b88a19345dfc665dc086d3c2b2e4547e1b7f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 23 May 2015 02:23:38 +0200 Subject: Minz getBaseUrl correction and RSS template bug https://github.com/FreshRSS/FreshRSS/issues/848 Corrections in Minz (HTTP_HOST was not sanitized, getURI() was never used and not working anyway with absolute base_url) $this->url was not defined in rss.phtml --- app/Controllers/indexController.php | 1 + constants.php | 3 ++- lib/Minz/Request.php | 46 +++++++++++-------------------------- lib/Minz/Url.php | 10 +------- 4 files changed, 18 insertions(+), 42 deletions(-) (limited to 'app') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index c1aaca53f..baaf99065 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -137,6 +137,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } // No layout for RSS output. + $this->view->url = empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']; $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); $this->view->_useLayout(false); header('Content-Type: application/rss+xml; charset=utf-8'); diff --git a/constants.php b/constants.php index b20bf0710..d32fdfa9b 100644 --- a/constants.php +++ b/constants.php @@ -11,7 +11,8 @@ define('PHP_COMPRESSION', false); define('FRESHRSS_PATH', dirname(__FILE__)); define('PUBLIC_PATH', FRESHRSS_PATH . '/p'); - define('INDEX_PATH', PUBLIC_PATH . '/i'); + define('PUBLIC_TO_INDEX_PATH', '/i'); + define('INDEX_PATH', PUBLIC_PATH . PUBLIC_TO_INDEX_PATH); define('PUBLIC_RELATIVE', '..'); define('DATA_PATH', FRESHRSS_PATH . '/data'); diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 6db2e9c7a..b9eda82a5 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -84,45 +84,27 @@ class Minz_Request { self::magicQuotesOff(); } - /** - * Retourn le nom de domaine du site - */ - public static function getDomainName() { - return $_SERVER['HTTP_HOST']; - } - /** * Détermine la base de l'url * @return la base de l'url */ - public static function getBaseUrl() { + public static function getBaseUrl($baseUrlSuffix = '') { $conf = Minz_Configuration::get('system'); - $defaultBaseUrl = $conf->base_url; - if (!empty($defaultBaseUrl)) { - return $defaultBaseUrl; - } elseif (isset($_SERVER['REQUEST_URI'])) { - return dirname($_SERVER['REQUEST_URI']) . '/'; - } else { - return '/'; - } - } - - /** - * Récupère l'URI de la requête - * @return l'URI - */ - public static function getURI() { - if (isset($_SERVER['REQUEST_URI'])) { - $base_url = self::getBaseUrl(); - $uri = $_SERVER['REQUEST_URI']; - - $len_base_url = strlen($base_url); - $real_uri = substr($uri, $len_base_url); + $url = $conf->base_url; + if ($url == '' || !preg_match('%^https?://%i', $url)) { + $url = 'http'; + $host = empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']; + $port = empty($_SERVER['SERVER_PORT']) ? 80 : $_SERVER['SERVER_PORT']; + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { + $url .= 's://' . $host . ($port == 443 ? '' : ':' . $port); + } else { + $url .= '://' . $host . ($port == 80 ? '' : ':' . $port); + } + $url .= isset($_SERVER['REQUEST_URI']) ? dirname($_SERVER['REQUEST_URI']) : ''; } else { - $real_uri = ''; + $url = rtrim($url, '/\\') . $baseUrlSuffix; } - - return $real_uri; + return filter_var($url . '/', FILTER_SANITIZE_URL); } /** diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index af555a277..a47d8f1a6 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -10,7 +10,6 @@ class Minz_Url { * $url['c'] = controller * $url['a'] = action * $url['params'] = tableau des paramètres supplémentaires - * $url['protocol'] = protocole à utiliser (http par défaut) * ou comme une chaîne de caractère * @param $encodage pour indiquer comment encoder les & (& ou & pour html) * @return l'url formatée @@ -25,14 +24,7 @@ class Minz_Url { $url_string = ''; if ($absolute) { - if ($isArray && isset ($url['protocol'])) { - $protocol = $url['protocol']; - } elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { - $protocol = 'https:'; - } else { - $protocol = 'http:'; - } - $url_string = $protocol . '//' . Minz_Request::getDomainName () . Minz_Request::getBaseUrl (); + $url_string = Minz_Request::getBaseUrl(PUBLIC_TO_INDEX_PATH); } else { $url_string = $isArray ? '.' : PUBLIC_RELATIVE; } -- cgit v1.2.3 From 9d55ee5ae9e41fe460ff82b4d51bf1673fb1b836 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 24 May 2015 01:49:13 +0200 Subject: Bug EntryDAO filter https://github.com/FreshRSS/FreshRSS/issues/850 --- app/Models/EntryDAO.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index eae9683ad..f939a0fb3 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -511,7 +511,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $where .= 'AND e1.id >= ' . $date_min . '000000 '; } $search = ''; - if ($filter !== null) { + if ($filter) { if ($filter->getIntitle()) { $search .= 'AND e1.title LIKE ? '; $values[] = "%{$filter->getIntitle()}%"; -- cgit v1.2.3