<?php

/**
* Download page
*/
$relative_path = "../";
require $relative_path . 'settings.php';
include $relative_path . "cache.php";
$page = 'good-practices';
require $relative_path . "common.php";
$best_practices = best_practices($page);
#print_r($best_practices['examples']);die();
$smarty->assign('categories', $best_practices['categories']);
$smarty->assign('examples', $best_practices['examples']);
$smarty->assign('filter', $best_practices['filter']);
$smarty->assign('relative_path', $relative_path);
$smarty->display($page . '.tpl');
if (!(isset($_GET['rot']) and in_array($_GET['rot'], [1, 2]))) {
    if (count($questions_selected) >= count($parliaments_selected)) {
        $_GET['rot'] = 2;
    } else {
        $_GET['rot'] = 1;
    }
    $force_rot = false;
} else {
    $force_rot = true;
}
//select data
$data_selected = select_data($data, $parliaments_selected, $questions_selected);
//create links
$data_selected = create_links($data_selected);
//get best practices
$best_practices = best_practices('good-practices');
//read info.md
//include('../Parsedown.php');
$mdurl = TEXT_URL . lang($page) . "/explore/info.md";
$contents = file_get_contents($mdurl);
$Parsedown = new Parsedown();
$smarty->assign('info_text', ltrim($Parsedown->text($contents), '<p>'));
//filters data by parameters cc and p
//$data = filter_data($data,$questions,$_GET);
//filter questions, put into array and sort them
//$questions_order = filter_questions($questions);
$smarty->assign('get', $_GET);
$smarty->assign('query_string', $_SERVER['QUERY_STRING']);
$smarty->assign('force_rot', $force_rot);
$smarty->assign('parliaments', $parliaments_ar);
$smarty->assign('regions', $regions);