Exemple #1
0
<?php

require_once 'vendor/autoload.php';
$app = new \Slim\App();
$container = $app->getContainer();
$container['view'] = function ($c) {
    $view = new \Slim\Views\Smarty(__DIR__ . '/templates/');
    $view->addSlimPlugins($c['router'], $c['request']->getUri());
    $view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme');
    return $view;
};
$app->get('/', array('ESSInfo\\Controller\\FrontController', 'index'))->setName('index');
$app->get('/search/', array('ESSInfo\\Controller\\FrontController', 'searchResults'))->setName('searchResults');
$app->get('/company/{siret}', array('ESSInfo\\Controller\\FrontController', 'company'))->setName('company');
$app->run();
Exemple #2
0
<?php

error_reporting(E_ALL & ~E_NOTICE);
// Smarty setup
// -----------------------------------------------------------------------------
$baseTemplate = strpos($_SERVER["REQUEST_URI"], 'admin') !== false ? 'admin-base' : 'base';
// figure out which main template to use
define('IS_AJAX', (bool) (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'));
// Fetch DI Container
$container = $app->getContainer();
// Register Smarty View helper
$container['view'] = function ($c) {
    $view = new \Slim\Views\Smarty(dirname(__FILE__) . '/templates', ['cacheDir' => dirname(__FILE__) . '/templates/cache', 'compileDir' => dirname(__FILE__) . '/templates/compiled', 'pluginsDir' => [dirname(__FILE__) . '/vendor/smarty/smarty/libs/plugins']]);
    $view->parserExtensions = array(dirname(__FILE__) . '/vendor/slim/views/SmartyPlugins');
    $view->addSlimPlugins($c['router'], $c['request']->getUri());
    return $view;
};
$smarty = $container['view']->getSmarty();
$smarty->compile_id = (bool) IS_AJAX ? 'ajaxResponse' : $baseTemplate;
// Auth
// -----------------------------------------------------------------------------
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
use Slim\Middleware\HttpBasicAuthentication\PdoAuthenticator;
$pdo = new PDO('mysql:host=' . $_ENV["BOOYA_DB_HOST"] . ';dbname=' . $_ENV["BOOYA_DB"], $_ENV["BOOYA_DB_USER"], $_ENV["BOOYA_DB_PASSWD"]);
$app->add(new \Slim\Middleware\HttpBasicAuthentication(["path" => "/admin", "secure" => false, "authenticator" => new PdoAuthenticator(["pdo" => $pdo])]));
// Page Routes
// -----------------------------------------------------------------------------
$app->get('/', function ($request, $response, $args) use($smarty) {
    return $this->view->render($response, 'pages/home.tpl', ['ParentTemplate' => $smarty->compile_id . '.tpl', 'page' => 'home']);
})->setName('home');
Exemple #3
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Alltube\Controller\FrontController;
if (strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
    header('Location: ' . str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
    die;
}
$app = new \Slim\App();
$container = $app->getContainer();
$container['view'] = function ($c) {
    $view = new \Slim\Views\Smarty(__DIR__ . '/templates/');
    $smartyPlugins = new \Slim\Views\SmartyPlugins($c['router'], $c['request']->getUri());
    $view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
    $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
    $view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme');
    return $view;
};
$controller = new FrontController($container);
$container['errorHandler'] = [$controller, 'error'];
$app->get('/', [$controller, 'index'])->setName('index');
$app->get('/extractors', [$controller, 'extractors'])->setName('extractors');
$app->get('/video', [$controller, 'video'])->setName('video');
$app->get('/redirect', [$controller, 'redirect'])->setName('redirect');
$app->get('/json', [$controller, 'json']);
$app->run();