Recommended Posts

1 hour ago, kixe said:

The module uses php function date() and NOT strftime(). To get what you expect use the following format string: 'date(M-d-Y)'.

That's not working for me since I'm grabbing the date from a datetime field which uses multi-language format. Here is what I did to make it work:

I replaced the 174 line:

$value = date($dateOutputFormat, $value);

into this:

$value = utf8_encode(strftime($dateOutputFormat, $value));

Can you add an option on the module where we can select if we want to use multi-language datetime formats?

Share this post


Link to post
Share on other sites

@kixe There is one last thing that I think needs to be fixed either you're using multi-language datetime formats or not.

The page name for all languages has only the default language's datetime format. If you can make it grab for the additional languages their datetime formats that would be perfect.

Share this post


Link to post
Share on other sites

@PWaddict

OK. I fixed the issue. For datetimefields the format will be pulled from the field settings including strftime formats.

58 minutes ago, PWaddict said:

The page name for all languages has only the default language's datetime format

Datetime fields are not true multilanguage fields. The language-specific output of a datetime field can not be influenced by changing the user language.

In a template, the output will be l
anguage-sensitive only by using setlocale() and if strftime formats for output are set in the datetime field settings. Inside PW datetime fields are not aware of the language.

It would actually be desirable to have a field for setting locales in Processwire for each language or an option to set the locale in datetimefields settings. You maybe want to start a topic in the wishlist and roadmap section to point out Ryan.


 

  • Like 2

Share this post


Link to post
Share on other sites
14 minutes ago, kixe said:

@PWaddict

OK. I fixed the issue. For datetimefields the format will be pulled from the field settings including strftime formats.

Datetime fields are not true multilanguage fields. The language-specific output of a datetime field can not be influenced by changing the user language.

In a template, the output will be l
anguage-sensitive only by using setlocale() and if strftime formats for output are set in the datetime field settings. Inside PW datetime fields are not aware of the language.

It would actually be desirable to have a field for setting locales in Processwire for each language or an option to set the locale in datetimefields settings. You maybe want to start a topic in the wishlist and roadmap section to point out Ryan.


 

Thank you for the update. It works great.

I'm settng the locale by translating the "C" string on LanguageSupport.module on each language which is the easiest method. The other method would be to add a field for locale inside the system's template "language".

I've changed the default's language locale from english to german and the module updates the page name from oct-17-2018 to okt-17-2018. So PW is aware of the datetime's language.

Do you think you can get the locale from the "C" string on LanguageSupport.module or from a field under the template "language" so the module can update the additional language page names too?

 

  • Like 2

Share this post


Link to post
Share on other sites

@PWaddict

Thanks for pointing on LanguageSupport::_('C'). I pushed an update 2.0.5 which is aware of this.

Share this post


Link to post
Share on other sites
13 minutes ago, kixe said:

@PWaddict

Thanks for pointing on LanguageSupport::_('C'). I pushed an update 2.0.5 which is aware of this.

I've tested the new update and It doesn't work. All the language page names are still getting the default language datetime format.

Share this post


Link to post
Share on other sites

Sorry for the trouble. I tested with translations 'en_EN' for default and 'de_DE' for german and it works.
If I set german as default it doesn't work. I will have a deeper look asap.

Share this post


Link to post
Share on other sites
6 minutes ago, kixe said:

Sorry for the trouble. I tested with translations 'en_EN' for default and 'de_DE' for german and it works.
If I set german as default it doesn't work. I will have a deeper look asap.

On my test site my default language is english and having 2 additional languages (spanish & german). All the language page names are getting the english format. If I switch the default language to german then all language page names are getting the german format and so on...

Share this post


Link to post
Share on other sites

It depends on your server settings. You should play around a bit with LanguageSupport:: _('C') translation strings.

In my local environment I am getting the following results in a test template:

setlocale(LC_TIME , 'de_DE');
echo $page->mydatetimefield; // getting Mai-27-2017

setlocale(LC_TIME , 'en_EN');
echo $page->mydatetimefield; // getting Mai-27-2017, expecting May-27-2017

setlocale(LC_TIME , 'en_US');
echo $page->mydatetimefield; // getting May-27-2017

As you can see I am not able to solve this via the module.
Have also a look here http://stackoverflow.com/questions/10909911/php-setlocale-has-no-effect

  • Like 1

Share this post


Link to post
Share on other sites

@kixe My locale settings are correct cause datetime formats on front-end are working fine. Even on the module datetime formats are working fine if it's on the default language. I wish I knew how to modify the module to get the correct datetime formats for the additional language too.

Here is exactly how my translated "C" string value is on each language:

Default
en_US.utf8, English_United States

Español
es_ES.utf8, Spanish_Spain

Deutsch
de_DE.utf8, German_Germany

Note: The first value is for my server (Linux) and the second is for XAMPP (Windows).

You should replace your en_EN to en_GB to get the proper value. As far as I know the en_EN isn't a correct locale.

When you said that you've tested the translations you meant on template just like on your example above or in the module?

Share this post


Link to post
Share on other sites

@kixe I'm suggesting you first to try to get ONLY the regular date format values from additional languages. Add on the default language: M d Y and then on additional language add d M Y. When you managed to get that values correctly on page names then continue by adding the code for setlocale and the strftime format values: %b %d %Y on the default language and %d %b %Y on the additional language.

Share this post


Link to post
Share on other sites

@PWaddict
Module works as expected. No failures here. Thanks, but I have no need for your suggestions. Feel free to fork it and adapt it for your needs. :rolleyes:

Share this post


Link to post
Share on other sites

@kixe Can you please confirm that the below example is working for you?

If you have %b %d %Y on the default language and %d %b %Y on the additional language are you getting these formats on their page names?

default: oct-17-2018
german: 17-okt-2018

Share this post


Link to post
Share on other sites

Screencast.gif.d71fa7a37da2c567d147bb278860af85.gif

It works for me, since I didn't use comma separated multiple values. With latest version it should work for your settings too.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, kixe said:

It works for me, since I didn't use comma separated multiple values. With latest version it should work for your settings too.

For me it's still not working :( All the page names having the format value from the default language. Thank you so much for updating the module with this feature. I hope I will figure out why it isn't working for me.

I'm on localhost with php7 and the pages are created from a pagetable. Do you think any of these is causing the issue?

My site url on localhost is http://localhost/mysite/ and I'm thinking that the problem might be that. For example the module "Admin Custom Files" can't inject the files properly on that url. Somehow can't see this part: /mysite/. On a live server it's working properly. So, maybe your module too can't see the correct urls of my additional languages. I have to upload it on a live server to make sure if that's the problem.

Thanks again. I will let you know if I find the problem.

Share this post


Link to post
Share on other sites

@PWaddict Just to be sure. You are talking about modules version 2.0.7 I pushed this morning?

Note
The strings you have posted doesn't work at all for me. I had to change from utf8 to utf-8 to get it work.
But this depends on the environment and if you get the right output of your datetime field in the frontend it should work in the module too.

Share this post


Link to post
Share on other sites
Just now, kixe said:

@PWaddict Just to be sure. You are talking about modules version 2.0.7 I pushed this morning?

Yes, I have the 2.0.7 version. I found the issue. I'm using 2 fields on "Name format for children": title tour_date
All these time I was only posting a title on default language. The only way to get the correct date format is If I post a title on an additional language. Can this be fixed from your module?

  • Like 1

Share this post


Link to post
Share on other sites
On 5/6/2017 at 2:36 PM, kixe said:

@PWaddict Thanks. I could reproduce. I will try to fix this.

Any news about the fix? Thanks.

Note: The problem happens only on multi-language title field. If use a regular text field everything is working properly.

Share this post


Link to post
Share on other sites

Love this module but I'm having an issue. This import script worked for me outside my module, but now I'm including it inside a module, and getting the following error upon install: 

Quote

Fatal Error

Call to a member function getLanguageValue() on string search►

Source file

File: .../ProcessSetupPageName.module:121

111: foreach ($formats as $_format) { 112: $_format = trim($_format, " \t\n\r,}{'\""); 113: if (!strlen($_format)) continue; 114: $_pageName = $this->createFromFormat($page, $_format, $languageID); 115: if ($_pageName == false) return false; 116: $pageName .= '-'.$_pageName; 117: } 118: } 119: 120: // case 2: title default
121: else if ($format == 'title' && strlen($page->title->getLanguageValue($languageID)))
{ 122: $pageName .= '-'.$page->title->getLanguageValue($languageID); 123: } 124: 125: // case 3: date()

Culprit file:

<?php namespace ProcessWire;


importUsers(__DIR__.'/data/users.csv');

function importUsers($filepath) {
  $csv = array_map('str_getcsv', file($filepath));
  array_walk($csv, function(&$a) use ($csv) {
    $a = array_combine($csv[0], $a); # set header keys
  });
  array_shift($csv); # remove column header
  //echo '<pre>'; print_r($csv); echo '</pre>';
  foreach($csv as $r) {
    $u = new User();
    $u->of(false);
    foreach($r as $k=>$v) {
      $v = trim($v);
      if($k == 'name') {
        if($v == '') $u->$k = wire('sanitizer')->pageName($u->email);
        else $u->name = wire('sanitizer')->pageName($v); continue;
      }
      if(wire('fields')->get('name='.$k)) {
        $fieldtype = wire('fields')->get('name='.$k)->type;
        if($fieldtype == 'FieldtypeMapMarker') {
          $u->$k->address = (string)$v;
        }
        elseif($fieldtype == 'FieldtypeImage') {
          $imgs = explode('|', $v);
          foreach($imgs as $i) {
            $u->$k = $i;
          }
        }
        elseif(in_array($fieldtype, ['FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeCheckbox', 'FieldtypePassword', 'FieldtypeEmail'])) $u->$k = $v;
      }
      if($k == 'roles') {
        $roles = explode('|', $v);
        foreach($roles as $role) {
          $u->addRole($role);
        }
      }
    }
    if(!$u->hasRole('guest')) $u->addRole('guest');
    $u->save(); //echo '<br>';

    if($u->password == '') {
      $u->password = crypt($u->email, $u->id);
      $u->save();
    }
  }
}

// email users welcome & verify


$mmpid = wire('pages')->get('template.name=mamo_makes')->id;

importCSV(__DIR__.'/data/manufacturers.csv', 'mamo_manufacturer', $mmpid);
//importCSV(__DIR__.'/data/models.csv', 'mamo_model', 0, $mmpid);
//importCSV(__DIR__.'/data/vessels.csv', 'boat_vessel', wire('pages')->get('template.name=boat_index')->id, 0);

function importCSV($filepath, $template, $parent_id = null, $grandparent_id = null) {
  $csv = array_map('str_getcsv', file($filepath));
  array_walk($csv, function(&$a) use ($csv) {
    $a = array_combine($csv[0], $a); # set header keys
  });
  array_shift($csv); # remove column header
  //echo '<pre>'; print_r($csv); echo '</pre>';
  foreach($csv as $r) {
    $p = new Page();
    $p->template = $template;
    if($parent_id !== 0||null) {
      $p->parent_id = $parent_id;
    } elseif($parent_id == 0||null) {
      //echo $r['parent'].' ';
      $parent = wire('sanitizer')->pageName($r['parent']);
      $parent = str_replace('---','-',$parent);
      //echo $parent.' ';//echo $grandparent_id.'gp ';
      $parent = wire('pages')->get('title=' . $r['parent'] . ', parent_id=' . $grandparent_id)->id;
      //echo $parent.'p ';
      $p->parent_id = $parent;
      unset($r['parent']);
    }
    $p->save();
    $p->of(false);
    foreach($r as $k=>$v) {
      $v = trim($v);
      $fieldtype = wire('fields')->get('name='.$k)->type;
      if($fieldtype == 'FieldtypeMapMarker') {
        $p->$k->address = (string)$v;
      }
      elseif($fieldtype == 'FieldtypeImage') {
        $imgs = explode('|', $v);
        foreach($imgs as $i) {
          $p->$k = $i;
        }
      }
      else $p->$k = $v;
    }
    $p->save(); //echo '<br>';
  }
}

The above portion (users) runs through ok. It's the latter section that produces the error. What is the string being referred to, how can I remedy this? Any ideas as to how I can troubleshoot?? Thanks a ton.

Share this post


Link to post
Share on other sites

It seems that the module isn't working anymore on websites without languages core modules installed. I've upgrade the module from 2.0.3 to 2.0.7 on a live website (without languages core modules installed) and when I tried to add a page that used by this module the page didn't even saved as unpublished and there was an error. I forgot to copy the error cause I was in hurry to switch back the module to the 2.0.3 version. I hope @kixe can fix it.

Share this post


Link to post
Share on other sites

Well I added this now it works not ideal and wasn't needed before but whatever 


    if($template == 'boat_vessel') $p->name = wire('sanitizer')->pageName($r['boat_model']) . '-' . wire('sanitizer')->pageName($r['title']);
    else $p->name = wire('sanitizer')->pageName($r['title']);

 

Share this post


Link to post
Share on other sites

PWaddict I suspected that and installed Languages Support. Prior to doing so it was actually producing a different error earlier up in the module file. Forgot to mention that. But installing it didn't solve the problem for me.

Share this post


Link to post
Share on other sites

@hellomoto

10 hours ago, hellomoto said:
111: foreach ($formats as $_format) { 112: $_format = trim($_format, " \t\n\r,}{'\""); 113: if (!strlen($_format)) continue; 114: $_pageName = $this->createFromFormat($page, $_format, $languageID); 115: if ($_pageName == false) return false; 116: $pageName .= '-'.$_pageName; 117: } 118: } 119: 120: // case 2: title default
121: else if ($format == 'title' && strlen($page->title->getLanguageValue($languageID)))
{ 122: $pageName .= '-'.$page->title->getLanguageValue($languageID); 123: } 124: 125: // case 3: date()

This issue was fixed in late 2016 (module version 2.0.0 or 2.0.1). Please update to last version and try again.

@PWaddict
I pushed a fix and tested the module in 3.0.64. Please update to 2.0.8

  • Like 2

Share this post


Link to post
Share on other sites
On 5/6/2017 at 2:32 PM, PWaddict said:

The only way to get the correct date format is If I post a title on an additional language. Can this be fixed from your module?

Wow you fixed that issue. Now it's working properly. Thank you so much :)

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By flydev
      PulsewayPush
      Send "push" from ProcessWire to Pulseway.
       
      Description
      PulsewayPush simply send a push to a Pulseway instance. If you are using this module, you probably installed Pulseway on your mobile device: you will receive notification on your mobile.
      To get more information about Pulseway, please visit their website.
      Note
      They have a free plan which include 10 notifications (push) each day.
       
      Usage
      Install the PulsewayPush module.
      Then call the module where you like in your module/template code :
      <?php $modules->get("PulsewayPush")->push("The title", "The notification message.", "elevated"); ?>  
      Hookable function
      ___push() ___notify() (the two function do the same thing)
       
      Download
      Github:  https://github.com/flydev-fr/PulsewayPush Modules Directory: https://modules.processwire.com/modules/pulseway-push/  
      Examples of use case
      I needed for our work a system which send notification to mobile device in case of a client request immediate support. Pulseway was choosen because it is already used to monitor our infrastructure.
      An idea, you could use the free plan to monitor your blog or website regarding the number of failed logins attempts (hooking Login/Register?), the automated tool then block the attacker's IP with firewall rules and send you a notification.
       

       
      - - - - - - - - - - - - - -
      11-22-2017: added the module to the modules directory
       
    • By netcarver
      Part 1 of a 2 part Module & Service Reveal.
      I'm currently working on a new module: ModuleReleaseNotes that was inspired by the work I originally did on making Ryan's ProcessWireUpgrades module "release" aware. In the end, I decided to ditch the approach I was originally taking and instead work on a module that hooked in to the UpgradeConfirmation dialog and the module edit page.
      Aims
      My aims for this module are as follows...
      Make discovery of a module's changes prior to an upgrade a trivial task. Make breaking changes very obvious. Make reading of a module's support documentation post-install a trivial task. Make module authors start to think about how they can improve the change discovery process for their modules. Make sure the display of information from the module support files/commit messages doesn't introduce a vulnerability. Looking at these in turn...
      Making discovery of a module's changes prior to upgrade a trivial task.
      This is done by adding a "What's changed section" to the upgrade confirmation dialog.  This section takes a best-effort approach to showing what's changed between the installed version and the updated version that's available via the module repository.
      At present, it is only able to talk to github-hosted repositories in order to ask them for the release notes, the changelog file (if present) and a list of commits between the git tag that matches the installed version and the tag matching the latest version.
      It will display the Release Notes (if the author is using the feature), else it will display the commits between the tags (if tagging is used by the module author) else it will show the changelog file (if present) else it will show the latest N commits on the master branch (N, of course, being configurable to your liking.)
      An example of the Github Release Notes pulled in for you, taken from Mike Rockett's TextformatterTypographer Module...

      An example of a tag-to-tag commit list from the same module...

      An example of a changelog - formatted to show just the changes (formatting styles will change)...

      Finally, an example of a fallback list of commits - sorry Adrian ...

       
      Making breaking changes obvious.
      This is currently done by searching for a set of configurable search strings. Later versions may be able to support breaking change detection via use of Semantic Versioning - but this may require some way of signalling the use of this versioning standard on a module-by-module basis.
      For now, then, you can customise the default set of change markers. Here I have added my own alias to the list of breaking change markers and the changes section of the changelog is styled accordingly (these will be improved)...

       
      Make reading of a module's support documentation, post-install, a trivial task.
      This is done by making some of the support files (like the README, CHANGELOG and LICENSE files) readable from the module's information/settings screen. There is an option to control the initial open/closed state of this section...

      Here is Tracy's README file from within the module settings page... 

       
      Make module authors start to think about how they can improve the change discovery process for their modules.
      There are notes in each of the sections displayed on the upgrade confirmation page that help authors use each of the features...

       
      Make sure display of external information doesn't introduce a vulnerability.
      This is an ongoing concern, and is the thing that is most likely to delay or prevent this module's release lead to this module's withdrawl should a vulnerability be found. Currently, output is formatted either via Markdown + HTML Purifier (if it was originally a Markdown file) or via htmlspecialchars() if it has come from a plaintext file.
      If you discover a vulnerability, please get in contact with me via the forum PM system.
       
      Ongoing...
      For now, I've concentrated on integration with GitHub, as most people use that platform to host their code. I know a few people are hosting their repositories with BitBucket (PWFoo comes to mind) and some with GitLab (Mike Rockett?) and I would eventually like to have adaptor implementations for these providers (and perhaps GitKraken) - but for now, GitHub rules and the other hosts are unsupported.
       
      Links
      Github: ModuleReleaseNotes
      PW Module Repository: Here
    • By FrancisChung
      Hi,
      I was wondering if anyone knew what this did? 

      If so, do you know what modules it actually impacts? Is there another log that lists the action it took?

      I'm having some weird problems with PHP duplicate declaration per link below, since this module was run.
       
       
    • By tpr
      AdminOnSteroids
      Various admin tweaks to enhance ProcessWire admin.
      http://modules.processwire.com/modules/admin-on-steroids/
      https://github.com/rolandtoth/AdminOnSteroids