Пример #1
0
    define('DEFAULT_PICTURE', 'main.jpg');
}
$app->hook('slim.before.dispatch', function () use($app, $conf, $lang, $app_base_url) {
    //let's send view parameters before dispatching
    $v = $app->view();
    $ui = $conf->getUI();
    $v->setData('app_base_url', $app_base_url);
    $v->setData('app_web_url', str_replace(array('/index.php', '/debug.php'), array('', ''), $app_base_url));
    $v->setData('enable_right_click', $ui['enable_right_click']);
    $v->setData('lang', $lang);
    $v->setData('negate', $ui['negate']);
    $v->setData('contrast', $ui['contrast']);
    $v->setData('brightness', $ui['brightness']);
    $v->setData('print', $ui['print']);
    $v->setData('comment', $conf->getComment());
    $fmts = $conf->getFormats();
    $v->setData('thumb_format', $fmts['thumb']);
    $remote_infos = $conf->getRemoteInfos();
    if ($remote_infos !== false) {
        $v->setData('remote_method', $remote_infos['method']);
        $v->setData('remote_uri', $remote_infos['uri']);
    }
});
//set default conditions
Route::setDefaultConditions(array('image' => '.+\\.[a-zA-Z]{3,4}', 'series' => '.+', 'format' => 'full|' . implode('|', array_keys($conf->getFormats()))));
//404 handler
$app->notFound(function () use($app) {
    $app->render('404.html.twig');
});
//custom error handler
$app->error(function (\Exception $e) use($app, $conf, $app_base_url) {