Differences From Artifact [a85f914a56]:

To Artifact [70aece96a9]:


496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
        return $out;
    }

    public function fetch($template, $no_display = false)
    {
        $this->currentTemplate = $template;

        $path = file_exists(GARRADIN_ROOT . '/squelettes/' . $template)
            ? GARRADIN_ROOT . '/squelettes/' . $template
            : GARRADIN_ROOT . '/squelettes-dist/' . $template;

        $tpl_id = basename(dirname($path)) . '/' . $template;

        if (!self::compile_check($tpl_id, $path))
        {
            if (!file_exists($path))
            {







|
|
|







496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
        return $out;
    }

    public function fetch($template, $no_display = false)
    {
        $this->currentTemplate = $template;

        $path = file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . $template)
            ? GARRADIN_DATA_ROOT . '/squelettes/' . $template
            : GARRADIN_DATA_ROOT . '/squelettes-dist/' . $template;

        $tpl_id = basename(dirname($path)) . '/' . $template;

        if (!self::compile_check($tpl_id, $path))
        {
            if (!file_exists($path))
            {
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
            throw new UserException('Cette page n\'existe pas.');
        }
        else
        {
            $_GET['uri'] = $_REQUEST['uri'] = substr($uri, 1);

            if (preg_match('!^[\w\d_-]+$!i', $_GET['uri'])
                && file_exists(GARRADIN_ROOT . '/squelettes/' . strtolower($_GET['uri']) . '.html'))
            {
                $skel = strtolower($_GET['uri']) . '.html';
            }
            else
            {
                $skel = 'article.html';
            }
        }

        $this->display($skel);
    }

    static private function compile_get_path($path)
    {
        $hash = sha1($path);
        return GARRADIN_ROOT . '/cache/compiled/s_' . $hash . '.php';
    }

    static private function compile_check($tpl, $check)
    {
        if (!file_exists(self::compile_get_path($tpl)))
            return false;








|















|







570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
            throw new UserException('Cette page n\'existe pas.');
        }
        else
        {
            $_GET['uri'] = $_REQUEST['uri'] = substr($uri, 1);

            if (preg_match('!^[\w\d_-]+$!i', $_GET['uri'])
                && file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . strtolower($_GET['uri']) . '.html'))
            {
                $skel = strtolower($_GET['uri']) . '.html';
            }
            else
            {
                $skel = 'article.html';
            }
        }

        $this->display($skel);
    }

    static private function compile_get_path($path)
    {
        $hash = sha1($path);
        return GARRADIN_DATA_ROOT . '/cache/compiled/s_' . $hash . '.php';
    }

    static private function compile_check($tpl, $check)
    {
        if (!file_exists(self::compile_get_path($tpl)))
            return false;

658
659
660
661
662
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
    }

    static public function getSource($template)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        $path = file_exists(GARRADIN_ROOT . '/squelettes/' . $template)
            ? GARRADIN_ROOT . '/squelettes/' . $template
            : GARRADIN_ROOT . '/squelettes-dist/' . $template;

        if (!file_exists($path))
            return false;

        return file_get_contents($path);
    }

    static public function editSource($template, $content)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        $path = GARRADIN_ROOT . '/squelettes/' . $template;

        return file_put_contents($path, $content);
    }

    static public function resetSource($template)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        if (file_exists(GARRADIN_ROOT . '/squelettes/' . $template))
        {
            unlink(GARRADIN_ROOT . '/squelettes/' . $template);
        }

        return true;
    }

    static public function listSources()
    {
        $sources = array();

        $dir = dir(GARRADIN_ROOT . '/squelettes-dist');

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
                $sources[] = $file;
        }

        $dir->close();

        $dir = dir(GARRADIN_ROOT . '/squelettes');

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
                $sources[] = $file;
        }








|
|
|












|









|

|









|









|







658
659
660
661
662
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
    }

    static public function getSource($template)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        $path = file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . $template)
            ? GARRADIN_DATA_ROOT . '/squelettes/' . $template
            : GARRADIN_DATA_ROOT . '/squelettes-dist/' . $template;

        if (!file_exists($path))
            return false;

        return file_get_contents($path);
    }

    static public function editSource($template, $content)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        $path = GARRADIN_DATA_ROOT . '/squelettes/' . $template;

        return file_put_contents($path, $content);
    }

    static public function resetSource($template)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        if (file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . $template))
        {
            unlink(GARRADIN_DATA_ROOT . '/squelettes/' . $template);
        }

        return true;
    }

    static public function listSources()
    {
        $sources = array();

        $dir = dir(GARRADIN_DATA_ROOT . '/squelettes-dist');

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
                $sources[] = $file;
        }

        $dir->close();

        $dir = dir(GARRADIN_DATA_ROOT . '/squelettes');

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
                $sources[] = $file;
        }