Balise #VALID_ID pour SPIP

Cette balise permet de générer un attribut de type ID ou NAME valide.

Pour utiliser la balise #VALID_ID, il vous suffit de copier le code suivant dans le fichier « mes_fonctions.php » (ou créer ce fichier) dans le dossier « squelettes » de SPIP.

  • La syntaxe complète est [(#VALID_ID{label_perso})] ;
  • {label_perso} permet de fixer l’intitulé si le titre ne comporte aucun caractère latin ;
  • Cette balise est a priori utilisable dans n’importe quelle boucle renvoyant un #TITRE.
// sanitize a title to make it match HTML specs
// http://www.w3.org/TR/html4/types.html#h-6.2
function cleanText($texte,$label='section') {
// strips all HTML tags
$texte = supprimer_tags($texte);

// replace all non latin character
$texte = preg_replace('#([^a-z0-9:-_]|[!"#$%&'()*+,/;<=>?@[\\\]^`{|}~])#i', '_', $texte);

// strips all empty characters at the beginning of the text
// the ID or NAME should start with a letter
$texte = preg_replace('#^([_0-9]+)#i', "", $texte);

// If there's no more latin character, then we return nothing
$count = strlen(preg_replace('#([_0-9])#i', "", $texte));
if($count<1) { return false; }

return $texte;
}
function balise_VALID_ID_dist($p) {
// If no alternate label is provided, we just use 'label'
if (!$label = interprete_argument_balise(1,$p)) {$label = "'label'";}

// gets the id of the current object
$_id_objet = $p->boucles[$p->id_boucle]->primary;
$_id = champ_sql($_id_objet, $p);

// gets the title
$_titre = champ_sql('titre', $p);

// Use the clean title or an alternate version if no suitable title
$p->code = "((\$a = cleanText($_titre)) ? \$a : $label.'_'.$_id)";

return $p;
}

Un gros merci à marcimat et sa patience.

J’ai remplacé [[:punct:]]|\^ par [!"#$%&'()*+,/;<=>?@[\\\]^`{|}~]. Cela permet de conserver les caractères « . », « :» et « - ».

naming and sorting things

It’s getting usual that I’m confronted to a visual void when looking for the application I want to use, the feed I want to read, or any other thing ordered in list by its default name.

This feed hosted by David Larlet which is called “Flux RSS des billets et des pensées du site biologeek.com” was the last straw today (just the expression, I’m just one of his fan so far :) ). In our case, every non–French speaking person is going to wonder what this title means, and the answer could be “RSS feed of posts and thoughts from biologeek.com website”.

Now. In English, this feed would then be listed with the “r” items (“RSS”) while it would be listed with “f”s in French (“Flux”). And the same thing happens in my Ubuntu applications menu (though I use GNOME DO a lot): The same software will appear at different positions in the menu depending on the language of the OS.

I don’t know for others, but as far as I’m concerned, I’m looking for the name of the application I want to use first (or website if we refer to a list of feeds), not its purpose (since there’s already categories for this). I’m using English and French OS at the same time on different computers, and I can tell how annoying it is to look for “Navigateur Web Firefox” on one computer in French, then “Firefox Web Browser” on another. Using the name of the application or website, or the domain name as the first words in the item’s name would allow some consistency throughout internationalized navigations! It’s that simple.

And if I’m taking David’s feed as an example again, I’d be waiting for “biologeek.com : billets et pensées” in my list of feeds, but the first thing that appears is “Flux”, which is somehow like a pleonasm in a feed reader’s context. We can make art and draw a pipe while writing that it’s not (ou pas), but well... You know...

You can comment if you think my remark is not appropriate. I’m willing to understand if I’m wrong, but as far as I can see, this is a cognitive accessibility problem for me.

Searching for items in a menu is not right.