Overview
Comment:PHP 5.4 inclue le pretty print pour json_encode maintenant
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9b53dc3f5331ddc5a8c20e9a3ea7de0422928487
User & Date: bohwaz on 2013-07-28 13:33:59
Other Links: manifest | tags
Context
2013-07-28
14:00
Le single-mode est le seul mode possible de l'exécutable, sinon il faut utiliser directement php en mode serveur.

Ca simplifie le code. Ensuite la commande devient facultative, UI est le comportement par défaut. check-in: 70a0af2c30 user: bohwaz tags: trunk

13:33
PHP 5.4 inclue le pretty print pour json_encode maintenant check-in: 9b53dc3f53 user: bohwaz tags: trunk
12:55
PHP 5.4 est exigé, plus besoin des corrections pour les installations boîteuses, car magic_quotes et register_globals n'existent plus check-in: 574216b119 user: bohwaz tags: trunk
Changes

Modified src/include/lib.utils.php from [94c20dd0d3] to [4548303020].

491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573

    static public function normalizePhoneNumber($n)
    {
        $n = preg_replace('![^\d\+]!', '', $n);
        return $n;
    }

    static public function json_readable_encode($in, $indent = 0, Closure $_escape = null)
    {
        if (__CLASS__ && isset($this))
        {
            $_myself = array($this, __FUNCTION__);
        }
        elseif (__CLASS__)
        {
            $_myself = array('self', __FUNCTION__);
        }
        else
        {
            $_myself = __FUNCTION__;
        }

        if (is_null($_escape))
        {
            $_escape = function ($str)
            {
                return str_replace(
                    array('\\', '"', "\n", "\r", "\b", "\f", "\t", '/', '\\\\u'),
                    array('\\\\', '\\"', "\\n", "\\r", "\\b", "\\f", "\\t", '\\/', '\\u'),
                    $str);
            };
        }

        $out = '';

        foreach ($in as $key=>$value)
        {
            $out .= str_repeat("\t", $indent + 1);
            $out .= "\"".$_escape((string)$key)."\": ";

            if (is_object($value) || is_array($value))
            {
                $out .= "\n";
                $out .= call_user_func($_myself, $value, $indent + 1, $_escape);
            }
            elseif (is_bool($value))
            {
                $out .= $value ? 'true' : 'false';
            }
            elseif (is_null($value))
            {
                $out .= 'null';
            }
            elseif (is_string($value))
            {
                $out .= "\"" . $_escape($value) ."\"";
            }
            else
            {
                $out .= $value;
            }

            $out .= ",\n";
        }

        if (!empty($out))
        {
            $out = substr($out, 0, -2);
        }

        $out = str_repeat("\t", $indent) . "{\n" . $out;
        $out .= "\n" . str_repeat("\t", $indent) . "}";

        return $out;
    }

    static public function write_ini_string($in)
    {
        $out = '';
        $get_ini_line = function ($key, $value) use (&$get_ini_line)
        {
            if (is_bool($value))
            {







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







491
492
493
494
495
496
497





































































498
499
500
501
502
503
504

    static public function normalizePhoneNumber($n)
    {
        $n = preg_replace('![^\d\+]!', '', $n);
        return $n;
    }






































































    static public function write_ini_string($in)
    {
        $out = '';
        $get_ini_line = function ($key, $value) use (&$get_ini_line)
        {
            if (is_bool($value))
            {

Modified tools/construire_plan_comptable.php from [9da6e0526c] to [157a9107dd].

571
572
573
574
575
576
577
578
579
580
581
582
583
        'code'      =>  $code,
        'nom'       =>  $nom,
        'parent'    =>  $parent,
        'position'  =>  $position,
    );
}

$json = utils::json_readable_encode($plan, 0);
file_put_contents('include/plan_comptable.json', $json);

die("OK\n");

?>







|





571
572
573
574
575
576
577
578
579
580
581
582
583
        'code'      =>  $code,
        'nom'       =>  $nom,
        'parent'    =>  $parent,
        'position'  =>  $position,
    );
}

$json = json_encode($plan, JSON_PRETTY_PRINT);
file_put_contents('include/plan_comptable.json', $json);

die("OK\n");

?>