Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

InternationalPTVs

Summary: Allow international characters in the names of PageTextVariables
Version: 20121012
Prerequisites: PmWiki 2.2.x
Status: experimental
Maintainer: Petko
Users: (view? / edit)
License: PD

Description

Allow international characters in the names of PageTextVariables.

In the default installation, PageTextVariables can only have a name containing basic Latin/Roman (ASCII) letters, digits, dash and underscore. This is a limitation for international wikis. The recipe makes it possible to have variable names containing international characters in addition (or in place) of the basic Latin. With this recipe, PageTextVariables names can contain extended/accented Latin characters, Cyrillic alphabet, Greek alphabet, Chinese and other alphabets.

Demo: the recipe is enabled on this page and in the UTF8 group (it should work both with UTF-8 enabled and disabled).

Installation

Add to a local config file these lines:

$PageTextVarPatterns = array(
  'var:'        => '/^(:*\\s*([\\w\\x80-\\xff][-\\w\\x80-\\xff]*)\\s*:[ \\t]?)(.*)($)/m',
  '(:var:...:)' => '/(\\(: *([\\w\\x80-\\xff][-\\w\\x80-\\xff]*) *:(?!\\))\\s?)(.*?)(:\\))/s'
  );

Markup('textvar:', '<split',
  '/\\(: *[\\w\\x80-\\xff][-\\w\\x80-\\xff]* *:(?!\\)).*?:\\)/s', '');

Markup('{$var}', '>$[phrase]',
  '/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?[\\w\\x80-\\xff][-\\w\\x80-\\xff]*)\\}/e',
  "PRR(PVSE(PageVar(\$pagename, '$2', '$1')))");

$PageListArgPattern = '((?:\\$:?)?[\\w\\x80-\\xff][-\\w\\x80-\\xff]*)[:=]';

Correction for php5.5 it's OK for me but without garanty

Markup_e('{$var}', '>$[phrase]',
  '/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?[\\w\\x80-\\xff][-\\w\\x80-\\xff]*)\\}/',
  "PRR(PVSE(PageVar(\$pagename, \$m[2], \$m[1])))");

Usage

You can use any international characters as variable names.

(:Adreça: Carrer Casa Blanca, Alcoi (PV):)
(:Петко: "Petko" in Cyrillic alphabet:)
(:檢視:Something in Chinese:)
VoilàEnFrançais: Here you go in French

* Петко : %navy%{$:Петко}%%
* Adreça : %red%{$:Adreça}%%
* VoilàEnFrançais : %blue%{$:VoilàEnFrançais}%%
* 檢視 : %yellow%{$:檢視}%%

From another page ([[PITS.01272]]):
* Institució: %green%{PITS.01272$:Institució} %%
* Telèfon: %red%{PITS.01272$:Telèfon} %%

VoilàEnFrançais: Here you go in French

  • Петко : "Petko" in Cyrillic alphabet
  • Adreça : Carrer Casa Blanca, Alcoi (PV)
  • VoilàEnFrançais : Here you go in French
  • 檢視 : Something in Chinese

From another page (PITS.01272):

  • Institució: Universitat Jaume I
  • Telèfon: +34 964 72 80 00

Notes

Currently PageLists cannot work with international PageTextVariables,

  • one could have (:pagelist $:ïñţvàя=search:)
  • but not (:pagelist order=$:ïñţvàя:) or use {=$:ïñţvàя} in PageList templates.

Change log / Release notes

  • 20121012 first release, ready to be tested.

See also

Contributors

Written by Petko.

Comments

See discussion at InternationalPTVs-Talk?

test

nameInstitucióTelèfon
01270{=$Institució}{=$Telèfon}
01271{=$Institució}{=$Telèfon}
01272{=$Institució}{=$Telèfon}
01273{=$Institució}{=$Telèfon}
01274{=$Institució}{=$Telèfon}
01275{=$Institució}{=$Telèfon}
01276{=$Institució}{=$Telèfon}
01277{=$Institució}{=$Telèfon}
01278{=$Institució}{=$Telèfon}
01279{=$Institució}{=$Telèfon}
[[#testfmt]]
(:template first:)
|| border=1
||! name ||! Institució ||! Telèfon ||
(:template each:)
|| [[{=$Group}/{=$Name}]] || {=$Institució} || {=$Telèfon} ||
[[#testfmtend]]
(:pagelist name=PITS.0127* $:Telèfon=*72* order=$:Institució:)
PITS /
01272  Locale letters not recognized by page text variables. (Open)
01271  PHP Code Injection Vulnerability (Closed, fixed for 2.2.35)
(:pagelist name=PITS.0127* $:Telèfon=*72* order=-$:Institució:)
PITS /
01272  Locale letters not recognized by page text variables. (Open)
01271  PHP Code Injection Vulnerability (Closed, fixed for 2.2.35)

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on April 12, 2016, at 11:12 AM