juek / CustomSections

Developer plugin for rapid prototyping of custom section types in Typesetter CMS
GNU General Public License v2.0
3 stars 7 forks source link

setLocale() problem #48

Closed mahotilo closed 4 years ago

mahotilo commented 6 years ago

Very strange... After upgrade my test system to current version TS 5.1.1-b1 and CS I got a message

setLocale() failed! The locale 'en_US' is probably not available on your server.

And last patch for carousel with BS4 now works only for logged in user...

juek commented 6 years ago

The setLocale message is triggered in the demo types single_event and multi_date_event (for localized date format processing)

For BS4 carousel: I'd guess the sections need to be edited/saved or recreated in order to update their static content. When logged-in, section content will always be processed. When logged-off it will only be processed when $section['always_process_values'] = true;

mahotilo commented 6 years ago

The setLocale message is triggered in the demo types single_event and multi_date_event (for localized date format processing)

OMG, I forgot it. I have reinstalled Customsection plugin and forgot to turn this types off.

But now, when I click "Recreate custom section" button, I have message

index.php/Admin_CustomSections does not exist. Would you like to create it?

Even on new site with only one Customsection plugin.

UPD Yes, editing brings carousel back. Sorry, I forgot this detail since summer:) It happened due to my intensive reinstalling updating during BS4 testing. But error message persists.

juek commented 6 years ago

Should work with this commit. I wonder how it worked before (seemingly only with pretty URLs on).

However, you will have to "Upgrade" the plugin after changing Addon.ini in order to make it work.

mahotilo commented 6 years ago

Now I have such link with permalink "off"

http://www.test:8080/index.php/index.php/Admin_CustomSections?cmd=recreate_custom_sections&page_to_refresh=Home

but with permalink "on" it all works fine.

juek commented 6 years ago

Hmmm. Could you temporarily add

/* debug START */
global $dirPrefix, $linkPrefix;
msg('$dirPrefix = <em>' .  (empty($dirPrefix)  ? 'empty string' : $dirPrefix )  . '</em>');
msg('$linkPrefix = <em>' . (empty($linkPrefix) ? 'empty string' : $linkPrefix ) . '</em>');
msg('Home URL = ' . common::GetUrl('') );
msg('ServerName = ' . pre(common::ServerName(false, true)) );
/* debug END */

to template.php and tell the results? Best with both permalink settings on/off.

mahotilo commented 6 years ago

permalinks - off

index.php/Admin_CustomSections does not exist. Would you like to create it? $dirPrefix = empty string $linkPrefix = /index.php Home URL = /index.php/ ServerName = (string)www.test:8080

permalinks - on (after automatic moving back to page from Admin page)

$dirPrefix = empty string $linkPrefix = empty string Home URL = / ServerName = (string)www.test:8080

gtbu commented 4 years ago

I have the same error during installation of newest custom_sections under Xampp 73 (and in the web): setLocale() failed! The locale 'en_US' is probably not available on your server. If i change to german i get setLocale() failed! The locale 'de_DE' is probably not available on your server.

I appears constant after opening a site for editing (also in Your 5.1.1b1) and after login. setLocale is also set in section.php ($setLoc = setlocale(LC_TIME, $lang['locale']);) and 5 others . Perhaps it disappears if You add a similar setting to Your custom_sections ? Some process does not get the necessary information - just which process...(The system time is also 1 hour to 2 hours different from the actual time) Normal users will not modify any parameters..... (There is also a bootstrap grid editor at github which can be added as plugin - but wix.com will always be simpler to handle.)

juek commented 4 years ago

I commented the setlocale parts out with this commit. The setlocale part can be enabled and solved easily once you learn which locales are available on your host and if you want localized date/time formatting at all.

As stated in README.md, mind that neither CustomSections plugin itself nor the demo types are turnkey solutions. It's all about what you make of it. Disable the more complex demo section types and start with a simple one, to get started.

juek commented 4 years ago

The system time is also 1 hour to 2 hours different from the actual time

Because it's UTC time (servers use that). To localize your venue (when dealing with local events) you'll need timezone offset calculation, see PHP DateTime If you want to deal with client's local time, you won't get around some JavaScript.

juek commented 4 years ago

But wix.com will always be simpler to handle

Well, wix.com is a 6-billion-in-equity listed company. This might possibly give them a tiny little advantage, LOL

gtbu commented 4 years ago

I just wonder that i get this error with two providers - i will check it out : Put the setLocale into a variable and echo - otherwise construct a gp_setlocal()...out of system-variables. Tracy (https://github.com/nette/tracy) is also a good php debugger. There is also https://locutus.io/php/strings/setlocale/ .....setlocale in javascript

juek commented 4 years ago

What would you need a PHP debugger for in this case? There is no bug. The message gets constructed by testing for a certain locale. Insert 'en_US.UTF-8' or 'de_DE.UTF-8' and it will most likely work. Did you even read the code that outputs the message?