Differences From Artifact [c134309b5d]:

To Artifact [7bf98c3058]:


469
470
471
472
473
474
475
476
477

478
479
480
481
482
483
484
485
469
470
471
472
473
474
475


476

477
478
479
480
481
482
483







-
-
+
-







    static public function checkBIC($bic)
    {
        return preg_match('!^[A-Z]{4}[A-Z]{2}[1-9A-Z]{2}(?:[A-Z\d]{3})?$!', $bic);
    }

    static public function normalizePhoneNumber($n)
    {
        $n = preg_replace('!(\+\d+)\(0\)!', '\\1', $n);
        $n = preg_replace('![^\d\+]!', '', $n);
        return preg_replace('![^\d\+\(\)p#,;-]!', '', trim($n));
        return $n;
    }

    static public function write_ini_string($in)
    {
        $out = '';
        $get_ini_line = function ($key, $value) use (&$get_ini_line)
        {
665
666
667
668
669
670
671
672

673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690




691
692
693
694
695
696
697
698
699
700

701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719




720
721
722
723
724
725
726
663
664
665
666
667
668
669

670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701

702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732







-
+


















+
+
+
+









-
+



















+
+
+
+







        array_walk($row, function (&$field) {
            $field = strtr($field, ['"' => '""', "\r\n" => "\n"]);
        });

        return sprintf("\"%s\"\r\n", implode('","', $row));
    }

    static public function toCSV($name, $iterator, $header = null)
    static public function toCSV($name, $iterator, $header = null, $row_map_callback = null)
    {
        header('Content-type: application/csv');
        header(sprintf('Content-Disposition: attachment; filename="%s.csv"', $name));

        $fp = fopen('php://output', 'w');

        if ($header)
        {
            fputs($fp, self::row_to_csv($header));
        }

        foreach ($iterator as $row)
        {
            if (!$header)
            {
                fputs($fp, self::row_to_csv(array_keys($row)));
                $header = true;
            }

            if (null !== $row_map_callback) {
                $row = call_user_func($row_map_callback, $row);
            }

            fputs($fp, self::row_to_csv($row));
        }

        fclose($fp);

        return true;
    }

    static public function toODS($name, $iterator, $header = null)
    static public function toODS($name, $iterator, $header = null, $row_map_callback = null)
    {
        header('Content-type: application/vnd.oasis.opendocument.spreadsheet');
        header(sprintf('Content-Disposition: attachment; filename="%s.ods"', $name));

        $ods = new ODSWriter;
        $ods->table_name = $name;

        if ($header)
        {
            $ods->add((array) $header);
        }

        foreach ($iterator as $row)
        {
            if (!$header)
            {
                $ods->add(array_keys($row));
                $header = true;
            }

            if (null !== $row_map_callback) {
                $row = call_user_func($row_map_callback, $row);
            }

            $ods->add((array) $row);
        }

        $ods->output();

        return true;