Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

This is the right place to report general bugs, make suggestions or ask for help.
laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by laborix » Sun Sep 18, 2022 10:28 am

Hi,

a quick solution for the Flatpress 1.2.1 problem described in the Flatpress Github here:
-> https://github.com/flatpressblog/flatpress/issues/132

Download the file "/fp-includes/smarty/plugins/function.html_select_date.php", edit it with a UTF-8 Editor and replace the lines 227 - 230

Code: Select all

for ($i = 1; $i <= 31; $i++) {
  $days[] = sprintf($day_format, $i);
  $day_values[] = sprintf($day_value_format, $i);
}
with this "quick" solution:

Code: Select all

/*
 * Flatpress issue #132
 * Months are displayed in the wrong language in the search
 *
 * Debug: 2022-09-18 
 * Using now the month_names from the Flatpress language files
 */
global $lang;
    
$replace_month_names = array();
$replace_month_names[0] = '-';
$fp_lang_months = array();
$fp_lang_months = $lang['date']['month'];
$fplm = 0;
for ($lm = 1; $lm <= 12; $lm++) {      
  $replace_month_names[$lm] = $fp_lang_months[$fplm];
  $fplm++;
}
for ($i = 1; $i <= 12; $i++) {
  $month_names[$i] = $replace_month_names[$i];
  $month_values[$i] = date($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
save this changes and upload the file "/fp-includes/smarty/plugins/function.html_select_date.php" into your Flatpress 1.2.1 Online version. No more changes are needed, the Month in the search list box are now shown with the current Flatpress 1.2.1 language.

Tested with Flatpress 1.2.1 on a Web server with PHP 8.0.23.

laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by laborix » Sat Sep 24, 2022 6:17 am

Sorry, I posted the wrong lines to replace :roll:

Please replace lines 190 - 193 in the file "/fp-includes/smarty/plugins/function.html_select_date.php"

Code: Select all

        for ($i = 1; $i <= 12; $i++) {
            $month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
            $month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
        }
with the same code from my last posting:

Code: Select all

/*
 * Flatpress issue #132
 * Months are displayed in the wrong language in the search
 *
 * Debug: 2022-09-18 
 * Using now the month_names from the Flatpress language files
 */
global $lang;
    
$replace_month_names = array();
$replace_month_names[0] = '-';
$fp_lang_months = array();
$fp_lang_months = $lang['date']['month'];
$fplm = 0;
for ($lm = 1; $lm <= 12; $lm++) {      
  $replace_month_names[$lm] = $fp_lang_months[$fplm];
  $fplm++;
}
for ($i = 1; $i <= 12; $i++) {
  $month_names[$i] = $replace_month_names[$i];
  $month_values[$i] = date($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}

User avatar
fraenkiman
Posts: 210
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by fraenkiman » Sun Sep 25, 2022 12:14 am

Hello @laborix,

thank you for your support.
I haven't been able to test the solution yet - will do so in the next few days.
I've added your solution to the issue. Maybe Arvid has the possibility to install the PHP8.1 compatible right away.

Best Regards
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by laborix » Sun Sep 25, 2022 6:56 am

fraenkiman wrote: ↑Sun Sep 25, 2022 12:14 am... the PHP8.1 compatible ...
The solution work fine on PHP 7.x and PHP 8.x, no matter, you only need a FlatPress Version higher than 1.0 :)

User avatar
fraenkiman
Posts: 210
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by fraenkiman » Mon Sep 26, 2022 9:42 pm

Hello @laborix,

I tested your solution. The translation in the set language works wonderfully.
However, the search then no longer works as expected.
In my case, there is a post from September 13th.
I'm looking for the following setting:
Keyword: ist
full-text search
Date: September 13, 2022
"Start search" button

I then get all the posts that appear to contain the word "ist".

But I should only get one post as a result from the viewfinder.

Would you like to take a look there again?
My flatpress version: FlatPress fp-1.3.dev [master]
PHP Version 7.4.30

Best Regards
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by laborix » Tue Sep 27, 2022 3:51 pm

fraenkiman wrote: ↑Mon Sep 26, 2022 9:42 pm...
Keyword: ist
full-text search
Date: September 13, 2022
"Start search" button

I then get all the posts that appear to contain the word "ist".

But I should only get one post as a result from the viewfinder.
...
Ok, very interesting what FlatPress generates from/with PHP commands in combination with the Smarty Engine 2.6.

Here is the complete correction again to avoid errors:

Replace the lines 190 - 193 in the file "/fp-includes/smarty/plugins/function.html_select_date.php"

Code: Select all

for ($i = 1; $i <= 12; $i++) {
  $month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
  $month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
with this code:

Code: Select all

/*
 * Flatpress issue #132
 * Months are displayed in the wrong language in the search
 *
 * Debug: 2022-09-27 
 * Using now the month_names from the Flatpress language files
 */
global $lang;
    
$replace_month_names = array();
$replace_month_names[0] = '-';
$replace_month_value_format = array("00","01","02","03","04","05","06","07","08","09","10","11","12");
$fp_lang_months = array();
$fp_lang_months = $lang['date']['month'];
$fplm = 0;
for ($lm = 1; $lm <= 12; $lm++) {      
  $replace_month_names[$lm] = $fp_lang_months[$fplm];
  $fplm++;
}
for ($i = 1; $i <= 12; $i++) {
  $month_names[$i] = $replace_month_names[$i];
  $month_values[$i] = $replace_month_value_format[$i];
}
The correct search results should now appear (tested with FlatPress 1.2.1 under PHP 8.0) and run under PHP 7.x, as well as PHP 8.0 and PHP 8.1.

User avatar
fraenkiman
Posts: 210
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by fraenkiman » Tue Sep 27, 2022 9:58 pm

Hello @laborix,

this looks very good. The search now works again as expected and also the translation of the months into the respective language.

I added your solution as a comment to the issue.

Thank you very much for your solution

Best regards and have a restful night
Frank
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by Arvid » Sat Oct 01, 2022 11:01 am

Thank you both very much, I changed the code according to your suggestions with 225e3b1. Works nicely :)

All the best,
Arvid

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by Arvid » Sat Oct 08, 2022 1:45 pm

Unfortunately, updating Smarty changed the code of function.html_select_date.php significantly - we'll have to adapt the fix to the new Smarty code. Please see my posting here.
I opened a new issue.

All the best,
Arvid

User avatar
fraenkiman
Posts: 210
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Flatpress 1.2.1 issue #132 - Months are displayed in the wrong language in the search

Post by fraenkiman » Sat Oct 08, 2022 8:50 pm

Hello @laborix,

can you please look at lines 290 to 325 in the function.html_select_date.php file?
I've tried to put your previous code there, to no avail.

Best regards
Frank
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 45 guests