<commit_before><?php
require_once('tiki-setup.php');

/*
 * This script convert templates with the old preferences $truc to $pref.truc by getting the currently existing prefs keys.
 * Use with caution !
 * Copy it to the root of you're tiki, and run it with:
 * php convert_templates_prefs-1.10.php
 */

/* customize this to the directory you want to convert */
$dirtoscan='templates';

/*****************/

$src=array();
$dst=array();

foreach(array_keys($prefs) as $k => $v) {
    $src[$k]='$'.$v;
    $dst[$k]='$prefs.'.$v;
}

$elems=scandir($dirtoscan);

foreach($elems as $filename) {
    if (preg_match('/.tpl$/', $filename)) {
	echo "$filename... ";
	$content_src=file_get_contents($dirtoscan.'/'.$filename);
	$content_dst=str_replace($src, $dst, $content_src);
	if ($content_dst != $content_src) {
	    file_put_contents($dirtoscan.'/'.$filename, $content_dst);
	    echo " modified\n";
	} else {<commit_msg>[ENH] script now works with PHP4<commit_after><?php
require_once('tiki-setup.php');

/*
 * This script convert templates with the old preferences $truc to $pref.truc by getting the currently existing prefs keys.
 * Use with caution !
 * Copy it to the root of you're tiki, and run it with:
 * php convert_templates_prefs-1.10.php
 */

/* customize this to the directory you want to convert */
$dirtoscan='templates';

/*****************/

/* defines functions scandir and file_out_contents if running PHP<5 */
if (!function_exists('scandir')) {
    function scandir($dir) {
	$dh  = opendir($dir);
	while (false !== ($filename = readdir($dh))) {
	    $files[] = $filename;
	}
	sort($files);

	return $files;
    }
}
if (!function_exists('file_put_contents')) {
    function file_put_contents($filename, $data) {
        $f = @fopen($filename, 'w');
        if (!$f) {
            return false;
        } else {
            $bytes = fwrite($f, $data);
            fclose($f);
            return $bytes;
        }
    }
}

$src=array();
$dst=array();

foreach(array_keys($prefs) as $k => $v) {
    $src[$k]='$'.$v;
    $dst[$k]='$prefs.'.$v;
}

$elems=scandir($dirtoscan);

foreach($elems as $filename) {
    if (preg_match('/.tpl$/', $filename)) {
	echo "$filename... ";
	$content_src=file_get_contents($dirtoscan.'/'.$filename);
	$content_dst=str_replace($src, $dst, $content_src);
	if ($content_dst != $content_src) {
	    file_put_contents($dirtoscan.'/'.$filename, $content_dst);
	    echo " modified\n";
	} else {
{'fraction_non_alphanumeric': 0.19078947368421054, 'fraction_numerical': 0.003289473684210526, 'mean_word_length': 3.7799607072691552, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4545909', 'n_tokens_mistral': 865, 'n_tokens_neox': 861, 'n_words': 199}