Jump to content

Recommended Posts

A community member raised a question and I thought a new sanitizer method for the purpose would be useful, hence...

Sanitizer Transliterate

Adds a transliterate method to $sanitizer that performs character replacements as defined in the module config. The default character replacements are based on the defaults from InputfieldPageName, but with uppercase characters included too.


Install the Sanitizer Transliterate module.

Customise the character replacements in the module config as needed.

Use the sanitizer on strings like so:

$transliterated_string = $sanitizer->transliterate($string);





  • Like 10
  • Thanks 2

Share this post

Link to post
Share on other sites

Hey @bernhard - just an FYI regarding your PR which I think it a great idea by the way, but I don't think Ryan wants "all" to actually be all sanitizers:  https://github.com/processwire/processwire-issues/issues/85


excluded sanitizers are those that require secondary/non-value arguments, like match(), option() and options().


  • Like 1

Share this post

Link to post
Share on other sites

Hey @Robin S - this looks great!

I just noticed that the contents of your $default_replacements array is much more comprehensive than the list of character replacements in the InputfieldPageName settings in the core. Not sure whether Ryan would be willing to change those, but it seems to me that your list should be used there. Then perhaps you could pull that list in for your module and users of your module would benefit from any manual additions they have made to those settings, rather than using the character_replacements_str config setting in this module - it seems to me that users may need to add their custom replacements to both places at the moment.

  • Like 3

Share this post

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

your $default_replacements array is much more comprehensive than the list of character replacements in the InputfieldPageName settings in the core

It would be great having "ő", "Ő" (=> "o") and "ű", "Ű" (=> "u") on the list. I've requested it years ago but it haven't found its way to the core.

  • Like 2

Share this post

Link to post
Share on other sites
10 hours ago, bernhard said:

I think it would be nice to also list this sanitizer in the testAll()

Sure, I will keep an eye on the core and merge your PR as soon as Ryan adds support for it.

8 hours ago, adrian said:

I just noticed that the contents of your $default_replacements array is much more comprehensive than the list of character replacements in the InputfieldPageName settings in the core.

It's actually not that much more comprehensive. 🙂
The only additions are the macronised vowels (āēīōū), which is something I wanted for my New Zealand context because they are used in Maori. The difference is that the list includes uppercase versions of the characters. I simply took the character list from InputfieldPageName, added the macronised vowels, and ran it through mb_strtoupper(). Adding uppercase characters to InputfieldPageName wouldn't make sense because page names are forced to lowercase.

8 hours ago, adrian said:

it seems to me that users may need to add their custom replacements to both places at the moment

I had in mind that this sanitizer could be used for broader purposes besides converting characters to ASCII. Using the character replacements from InputfieldPageName seemed like a good starting point (particularly given the question that gave rise to the module) but a person could configure all kinds of replacements to suit their needs. There could well be cases where these substitutions would not be wanted in InputfieldPageName.


  • Like 2

Share this post

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

It's actually not that much more comprehensive. 🙂

Sorry, I didn't notice that it was mostly uppercase variants that were new - I just saw a lot more options 🙂

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By dimitrios
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version to 2.10, add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.

    • By thomasaull
      I created a little helper module to trigger a CI pipeline when your website has been changed. It's quite simple and works like this: As soon as you save a page the module sets a Boolean via a pages save after hook. Once a day via LazyCron the module checks if the Boolean is set and sends a POST Request to a configurable Webhook URL.
      Some ideas to extend this:
      make request type configurable (GET, POST) make the module trigger at a specified time (probably only possible with a server cronjob) trigger manually Anything else? If there's interest, I might put in some more functionality. Let me know what you're interested in. Until then, maybe it is useful for a couple of people 🙂
      Github Repo: https://github.com/thomasaull/CiTrigger
    • By Robin S
      I created this module a while ago and never got around to publicising it, but it has been outed in the latest PW Weekly so here goes the support thread...
      Unique Image Variations
      Ensures that all ImageSizer options and focus settings affect image variation filenames.

      When using methods that produce image variations such as Pageimage::size(), ProcessWire includes some of the ImageSizer settings (height, width, cropping location, etc) in the variation filename. This is useful so that if you change these settings in your size() call a new variation is generated and you see this variation on the front-end.
      However, ProcessWire does not include several of the other ImageSizer settings in the variation filename:
      upscaling cropping, when set to false or a blank string interlace sharpening quality hidpi quality focus (whether any saved focus area for an image should affect cropping) focus data (the top/left/zoom data for the focus area) This means that if you change any of these settings, either in $config->imageSizerOptions or in an $options array passed to a method like size(), and you already have variations at the requested size/crop, then ProcessWire will not create new variations and will continue to serve the old variations. In other words you won't see the effect of your changed ImageSizer options on the front-end until you delete the old variations.
      The Unique Image Variations module ensures that any changes to ImageSizer options and any changes to the focus area made in Page Edit are reflected in the variation filename, so new variations will always be generated and displayed on the front-end.
      Install the Unique Image Variations module.
      In the module config, set the ImageSizer options that you want to include in image variation filenames.
      Installing the module (and keeping one or more of the options selected in the module config) will cause all existing image variations to be regenerated the next time they are requested. If you have an existing website with a large number of images you may not want the performance impact of that. The module is perhaps best suited to new sites where image variations have not yet been generated.
      Similarly, if you change the module config settings on an existing site then all image variations will be regenerated the next time they are requested.
      If you think you might want to change an ImageSizer option in the future (I'm thinking here primarily of options such as interlace that are typically set in $config->imageSizerOptions) and would not want that change to cause existing image variations to be regenerated then best to not include that option in the module config after you first install the module.
    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      ProcessWire-Module: http://modules.processwire.com/modules/page-access-releasetime/
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By netcarver
      Markup Cross-Fade
      On Github.
      In the Module Repository.
      Thanks to the good people at Lightning.pw for hosting the demo for free!  Demo no longer available.

      A full-screen cross-fading background animation module with optional, per-slide, overlay text. It's based on an article by Mary Lou over on codrops. 
      Here's the home.php template code for the entire site...
      <?php $cf = wire('modules')->get('MarkupCrossfade'); $settings = array( 'pages' => wire('pages')->get("template=slides")->children(), 'title_xforms' => "scale(1.0) translateY(300px)\nscale(1.0)\nscale(1.0)\ntranslateY(300px)", ); ?><html lang="en"> <head> <meta charset="utf-8"> <title>MarkupCrossfade Demo</title> <style> @font-face { font-family: 'BebasNeueRegular'; src: url('<?php echo wire('config')->urls->assets; ?>fonts/BebasNeue-webfont.eot'); src: url('<?php echo wire('config')->urls->assets; ?>fonts/BebasNeue-webfont.ttf') format('truetype'); font-weight: normal; font-style: normal; } body { background-color: #333; overflow-x: hidden; padding: 0; border: 0; margin: 0; } <?php echo $cf->renderCss($settings); ?> .markup-crossfade li div h3 {     font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif; font-size: 80px; letter-spacing: 2px; } </style> </head> <body> <?php echo $cf->renderHtml($settings); ?> </body> </html>  
      The only other work involved was adding a 'slides' and a 'slide' template ('slides' having children of template 'slide') and adding an image field called 'image' (NB. not "images"), a text/textarea called 'body' and a required integer field called 'duration' to the slide template. Add a parent to the page tree called 'slides' using template 'slides' and add as many manually sorted children as you need, setting the image, body text and duration for each.
      After that, the only thing left to do was to upload BebasNeue from fontsquirrel to 'assets/fonts'. That's it.
      There are a number of parameters you can configure and pass in to the render methods. Here's the list of settings and their defaults taken straight from the source code...
      array( 'pages' => $pages, // WireArray of pages defining the slides of the slideshow. 'duration_field' => 'duration', // Field of the slide page that provides the duration (in seconds) 'overlay_field' => 'body', // Field of the slide page that provides the overlay text 'image_field' => 'image', // Field of the slide page that provides the image (url) 'title_xform_field' => '', // Textarea field of the slide page that provides the title transformations 'image_xform_field' => '', // Textarea field of the slide page that provides the image transformations 'title_xforms' => '', // Default title transformations - one per line (\n separator please) - leave blank for none. 'image_xforms' => '', // Default image transformations - one per line (\n separator please) - leave blank for none. 'html_class' => 'markup-crossfade', // What class to apply to the owning list 'z_index' => '-10', // z-index of slideshow container and its spans 'li_id' => 'slide_', // What id to use for each slide. The slide # will be appended to this 'browsers' => array( // Array of browsers extensions to render CSS for '', '-webkit-', '-moz-', '-o-', '-ms-' ), 'skip_css' => false, // only generate the keyframes, don't output a modified copy of the module's static css file. 'mask_image' => '', // location of mask image relative to the site root. Leave blank if none. ); In order to use per-slide image and/or title transformations you need to add either one or two textarea fields to your slide templates. Each textarea should have a maximum of five lines of text. Each line of text is used to define the transformation(s) applied at each of the 5 stages of the animation that gets generated. The following (used for the global title animation on the demo site)...
      scale(1.0) translateY(300px) scale(1.0) scale(1.0) translateY(300px) ...defines the start keyframe with the title scaled at 1.0 and translated along the Y axis by 300px. The next keyframe is not translated so the browser animates it up into the visible area. It stays there in the next frame and is animated back out in the fourth frame. 
      The skip_css setting lets the renderCss() method know if it should include its default css scaffolding file (included with the module) in the output. If set to true, only the CSS for the actual animations is output and you'll have to supply your own scaffolding CSS in your page templates.
      Whilst this works great in Chrome on linux, could you let me know what the experience is like for you on your OS/Browser combination.
      Thank you!
  • Create New...