<commit_before><?php

/**
 * Datawrapper main index
 *
 */


// load YAML parser and config
require_once '../vendor/spyc/spyc.php';
$GLOBALS['dw_config'] = Spyc::YAMLLoad('../config.yaml');

if ($GLOBALS['dw_config']['debug'] == true) {
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
}

define('DATAWRAPPER_VERSION', '1.0.2');

// include datawrapper session serialization
require '../lib/session/Datawrapper.php';


// Require the Slim PHP 5 Framework
require '../vendor/Slim/Slim.php';

// Include the main Propel script
// Initialize Propel with the runtime configuration
// Add the generated 'classes' directory to the include path
require_once '../vendor/propel/runtime/lib/Propel.php';
Propel::init("../lib/core/build/conf/datawrapper-conf.php");
set_include_path("../lib/core/build/classes" . PATH_SEPARATOR . get_include_path());

// Load TwigView
require_once '../vendor/Slim-Extras/Views/TwigView.php';
TwigView::$twigDirectory = '../vendor/Twig';


$app = new Slim(array(
    'view' => new TwigView(),
    'templates.path' => '../templates'
));


// Load twig instance
$twig = $app->view()->getEnvironment();

// Twig Extension to convert strings to nice JavaScript class names, e.g. bar-chart --> BarChart
$twig->addFilter('classify', new Twig_Filter_Function('str_classify'));
function str_classify($s) {
    return preg_replace('/\s/', '', ucwords(preg_replace('/[_\-\.]/', ' ', $s)));
}

// Twig Extension to jsonify objects
$twig->addFilter('json', new Twig_Filter_Function('toJSON'));
function toJSON($arr) {
    return json_encode($arr);
}

// Twig Extension to clean HTML from malicious code
require_once '../vendor/htmlpurifier/HTMLPurifier.standalone.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'a[href],p,b,strong,u,i,em,q,blockquote,*[style]');
$_HTMLPurifier = new HTMLPurifier($config);
$twig->addFilter('purify', new Twig_Filter_Function('str_purify'));

function str_purify($dirty_html) {
    global $_HTMLPurifier;
    return $_HTMLPurifier->purify($dirty_html);
}

// loae I18n extension for Twig
$twig->addExtension(new Twig_Extension_I18n());

require_once '../lib/utils/i18n.php';


function add_header_vars(&$page, $active = null) {
    // define the header links
    global $app;
    if (!isset($active)) {
        $active = explode('/', $app->request()->getResourceUri());
        $active = $active[1];
    }

    $user = DatawrapperSession::getUser();
    $headlinks = array();
    $headlinks[] = array('url' => '/chart/create', 'id' => 'chart', 'title' => _('Create Chart'), 'icon' => 'pencil');
    if ($user->isLoggedIn() && $user->hasCharts()) {
        $headlinks[] = array('url' => '/mycharts/', 'id' => 'mycharts', 'title' => _('My Charts'), 'icon' => 'signal');
    } else {
        //$headlinks[] = array('url' => '/gallery/', 'id' => 'gallery', 'title' => _('Gallery'), 'icon' => 'signal');
    }
    $headlinks[] = array('url' => '/docs', 'id' => 'about', 'title' => _('About'), 'icon' => 'info-sign');
    $headlinks[] = array('url' => 'http://blog.datawrapper.de', 'id' => 'blog', 'title' => _('Blog'), 'icon' => 'tag');

    $headlinks[] = array(
        'url' => '',
        'id' => 'lang',
        'dropdown' => array(array(
            'url' => '#lang-de-DE',
            'title' => 'Deutsch'
        ), array(
            'url' => '#lang-en-GB',
            'title' => 'English'
        ), array(
            'url' => '#lang-fr-FR',
            'title' => 'Français'
        )/*, array(
            'url' => '#lang-es-ES',
            'title' => 'Español'
        )*/),
        'title' => _('Language'),
        'icon' => 'font'
    );
    if ($user->isLoggedIn()) {
        $headlinks[] = array(
            'url' => '#user',
            'id' => 'user',
            'title' => $user->getEmail(),
            'icon' => 'user',
            'dropdown' => array(array(
                'url' => '/account/settings',<commit_msg>removed link to dw blog & docs added link to tutorial<commit_after><?php

/**
 * Datawrapper main index
 *
 */


// load YAML parser and config
require_once '../vendor/spyc/spyc.php';
$GLOBALS['dw_config'] = Spyc::YAMLLoad('../config.yaml');

if ($GLOBALS['dw_config']['debug'] == true) {
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
}

define('DATAWRAPPER_VERSION', '1.0.2');

// include datawrapper session serialization
require '../lib/session/Datawrapper.php';


// Require the Slim PHP 5 Framework
require '../vendor/Slim/Slim.php';

// Include the main Propel script
// Initialize Propel with the runtime configuration
// Add the generated 'classes' directory to the include path
require_once '../vendor/propel/runtime/lib/Propel.php';
Propel::init("../lib/core/build/conf/datawrapper-conf.php");
set_include_path("../lib/core/build/classes" . PATH_SEPARATOR . get_include_path());

// Load TwigView
require_once '../vendor/Slim-Extras/Views/TwigView.php';
TwigView::$twigDirectory = '../vendor/Twig';


$app = new Slim(array(
    'view' => new TwigView(),
    'templates.path' => '../templates'
));


// Load twig instance
$twig = $app->view()->getEnvironment();

// Twig Extension to convert strings to nice JavaScript class names, e.g. bar-chart --> BarChart
$twig->addFilter('classify', new Twig_Filter_Function('str_classify'));
function str_classify($s) {
    return preg_replace('/\s/', '', ucwords(preg_replace('/[_\-\.]/', ' ', $s)));
}

// Twig Extension to jsonify objects
$twig->addFilter('json', new Twig_Filter_Function('toJSON'));
function toJSON($arr) {
    return json_encode($arr);
}

// Twig Extension to clean HTML from malicious code
require_once '../vendor/htmlpurifier/HTMLPurifier.standalone.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'a[href],p,b,strong,u,i,em,q,blockquote,*[style]');
$_HTMLPurifier = new HTMLPurifier($config);
$twig->addFilter('purify', new Twig_Filter_Function('str_purify'));

function str_purify($dirty_html) {
    global $_HTMLPurifier;
    return $_HTMLPurifier->purify($dirty_html);
}

// loae I18n extension for Twig
$twig->addExtension(new Twig_Extension_I18n());

require_once '../lib/utils/i18n.php';


function add_header_vars(&$page, $active = null) {
    // define the header links
    global $app;
    if (!isset($active)) {
        $active = explode('/', $app->request()->getResourceUri());
        $active = $active[1];
    }

    $user = DatawrapperSession::getUser();
    $headlinks = array();
    $headlinks[] = array('url' => '/chart/create', 'id' => 'chart', 'title' => _('Create Chart'), 'icon' => 'pencil');
    if ($user->isLoggedIn() && $user->hasCharts()) {
        $headlinks[] = array('url' => '/mycharts/', 'id' => 'mycharts', 'title' => _('My Charts'), 'icon' => 'signal');
    } else {
        //$headlinks[] = array('url' => '/gallery/', 'id' => 'gallery', 'title' => _('Gallery'), 'icon' => 'signal');
    }
    $headlinks[] = array('url' => '/docs/tutorial', 'id' => 'tutorial', 'title' => _('Tutorial'), 'icon' => 'question-sign');
    //$headlinks[] = array('url' => '/docs', 'id' => 'about', 'title' => _('About'), 'icon' => 'info-sign');
    //$headlinks[] = array('url' => 'http://blog.datawrapper.de', 'id' => 'blog', 'title' => _('Blog'), 'icon' => 'tag');

    $headlinks[] = array(
        'url' => '',
        'id' => 'lang',
        'dropdown' => array(array(
            'url' => '#lang-de-DE',
            'title' => 'Deutsch'
        ), array(
            'url' => '#lang-en-GB',
            'title' => 'English'
        ), array(
            'url' => '#lang-fr-FR',
            'title' => 'Français'
        )/*, array(
            'url' => '#lang-es-ES',
            'title' => 'Español'
        )*/),
        'title' => _('Language'),
        'icon' => 'font'
    );
    if ($user->isLoggedIn()) {
        $headlinks[] = array(
            'url' => '#user',
            'id' => 'user',
            'title' => $user->getEmail(),
            'icon' => 'user',
            'dropdown' => array(array(
                'url' => '/account/settings',
{'fraction_non_alphanumeric': 0.21414342629482072, 'fraction_numerical': 0.00298804780876494, 'mean_word_length': 3.2013598326359833, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 119, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5405252', 'n_tokens_mistral': 2711, 'n_tokens_neox': 2655, 'n_words': 551}