Controller.php 1.21 KB
Newer Older
Mindiell's avatar
Mindiell committed
1 2 3 4 5 6 7 8 9
<?php

class Controller {
	function __construct() {
		$f3=Base::instance();
    }

    // Function called before routing
    function beforeRoute($f3, $args) {
Mindiell's avatar
Mindiell committed
10 11 12
        // Include configuration
        require_once('config.php');

13 14 15 16 17 18
        // Languages available
        $languages = array(
            array("iso" => "fr", "name"=>"Français"),
            array("iso" => "en", "name"=>"English"),
        );
        $f3->set('languages', $languages);
19 20 21

        // Init campaign informations
        $f3->set('campaign', Api::get_campaign());
22

okhin's avatar
okhin committed
23 24
        // Get organization informations
        $f3->set('organization', Api::get_organization());
25 26
        // Init contacts list if needed
        if (!$f3->exists('contacts')) {
27
            $f3->set('contacts', Api::get_contacts(), API_TIMEOUT);
28 29 30
        }
        // Workaround for caching variables
        $f3->set('contacts', $f3->get('contacts'));
okhin's avatar
okhin committed
31

okhin's avatar
okhin committed
32 33 34
        $groups = Api::get_groups();
        $f3->set('groups', $groups);

okhin's avatar
okhin committed
35 36
        $group_types = Api::get_group_types();
        $f3->set('group_types', $group_types);
Mindiell's avatar
Mindiell committed
37 38 39 40 41 42 43 44 45 46
    }

    // Function called after routing
    function afterRoute($f3, $args) {
		// Rendu HTML de la page
		echo Template::instance()->render('base.html');
    }

};