Beispiel #1
0
function loadTwigi18n()
{
    $loader = new Twig_Loader_Filesystem('../public');
    $twig = new Twig_Environment($loader, array());
    //$twig->clearCacheFiles();
    \Slim\Extras\Views\Twig::$twigOptions = array('debug' => true);
    $twig->addExtension(new Twig_Extensions_Extension_I18n());
    \Slim\Extras\Views\Twig::$twigExtensions = array('Twig_Extension_Debug', 'Twig_Extensions_Extension_I18n');
}
// Configuration
# ORM::configure('sqlite:' . ROOT_PATH . '/sql/database.db');
ORM::configure('mysql:host=localhost;dbname=blog');
ORM::configure('username', 'root');
ORM::configure('password', '');
#ORM::logging(true);
// Slim Configuration
\Slim\Slim::registerAutoloader();
// Twig Configuration
\Slim\Extras\Views\Twig::$twigDirectory = VENDOR_PATH . 'Twig';
\Slim\Extras\Views\Twig::$twigOptions = array("debug" => true);
if (is_writable(ROOT_PATH . 'cache')) {
    \Slim\Extras\Views\Twig::$twigOptions['cache'] = ROOT_PATH . 'cache';
}
// Twig i18n config
\Slim\Extras\Views\Twig::$twigExtensions = array('Twig_Extensions_Extension_I18n');
$locality = $site_cfg['website']['i18n'];
// locality should be determined here
require_once APP_PATH . 'config/locales.php';
// Setup $app
$app = new \Slim\Slim(array('templates.path' => APP_PATH . 'views/' . $site_cfg['website']['theme'] . '/', 'locales.path' => APP_PATH . 'i18n/', 'debug' => true, 'view' => new \Slim\Extras\Views\Twig(), 'log.enabled' => false, 'log.writer' => new \Slim\Extras\Log\DateTimeFileWriter(array('path' => ROOT_PATH . 'logs', 'name_format' => 'Y-m-d', 'message_format' => '%label% - %date% - %message%'))));
// Cookie
$app->add(new \Slim\Middleware\SessionCookie(array('expires' => '40 minutes', 'path' => '/', 'domain' => 'slim', 'secure' => false, 'httponly' => false, 'encrypt' => false, 'name' => 'slimblog', 'secret' => md5($site_cfg['website']['secret']))));
// Authenticate
$app->add(new \SlimBasicAuth('', 'admin'));
$app->add(new \CsrfGuard());
// Set our app name
$app->setName($site_cfg['website']['name']);
// Template Globals
$twig = $app->view()->getEnvironment();
$twig->addGlobal('SITE_NAME', $site_cfg['website']['name']);
Beispiel #3
0
<?php

//ini_set('display_errors', "On");
require __DIR__ . '/../vendor/autoload.php';
require '../config.php';
$dbAdapter = new Zend\Db\Adapter\Adapter($dbConfig);
$TwigView = new \Slim\Extras\Views\Twig();
$TwigView::$twigTemplateDirs = '../templates';
$app = new \Slim\Slim(array('view' => $TwigView, 'charset' => 'utf-8', 'cache' => realpath('../templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true));
$twig = $TwigView->getEnvironment();
$twig->addExtension(new \Twig_Extensions_Slim());
// Twig globals
$twig->addGlobal("assetsRoot", ROOT_URL . '/assets');
$twig->addGlobal("mediaUrl", MEDIA_URL);
$twig->addGlobal("rootURL", ROOT_URL);
/**
 * Include routes
 */
require '../routes/home.php';
require '../routes/sample.php';
$app->run();
Beispiel #4
0
<?php

require 'vendor/autoload.php';
require 'lib/idiorm.php';
require 'config.php';
$pdf_enable = file_exists($WKHTMLTOPDF_BIN_PATH) ? TRUE : FALSE;
define('PROJECT_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
define('WKHTMLTOPDF_BIN_PATH', $WKHTMLTOPDF_BIN_PATH);
define('PDF_ENABLE', $pdf_enable);
ORM::configure("mysql:dbname={$DB_NAME};host={$DB_HOST}");
ORM::configure('username', $DB_USER);
ORM::configure('password', $DB_PASS);
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
ORM::configure('id_column_overrides', array('customer' => 'customer_id', 'quotation' => 'quotation_id', 'option' => 'option_id'));
$app = new \Slim\Slim(array('mode' => 'production', 'debug' => false, 'log.enable' => true, 'templates.path' => 'tpl'));
\Slim\Extras\Views\Twig::$twigOptions = array('charset' => 'utf-8', 'cache' => realpath('./tpl_cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true);
$app->view(new \Slim\Extras\Views\Twig());
require 'app.php';
$app->run();
Beispiel #5
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$app = new \Slim\Slim(array('templates.path' => __DIR__ . '/../templates'));
\Slim\Extras\Views\Twig::$twigOptions = array('charset' => 'utf-8', 'cache' => realpath('../templates/cache'));
$app->view(new \Slim\Extras\Views\Twig());
$app->get('/', function () use($app) {
    $app->render('index.html.twig');
});
$app->run();
Beispiel #6
0
<?php

require_once '../vendor/Pimple.php';
require_once '../vendor/php-activerecord/ActiveRecord.php';
require_once '../vendor/Slim/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
require_once '../vendor/Slim/Views/Extension/TwigAutoloader.php';
Twig_Extensions_Autoloader::register();
Slim\Extras\Views\Twig::$twigDirectory = '../vendor/Twig';
Slim\Extras\Views\Twig::$twigExtensions = array('Twig_Extensions_Slim');
$twigView = new \Slim\Views\Twig();
require_once '../vendor/firephp-core/lib/FirePHPCore/FirePHP.class.php';
ob_start();
$config = new Pimple(array('slim' => array('view' => '\\Slim\\Views\\Twig', 'name', 'markettrader', 'twig' => $twigView, 'templates.path' => 'view'), 'log' => $firephp = FirePHP::getInstance(true)));
return $config;
Beispiel #7
0
        if (in_array(\PTA\App::$Cat_Engage_Code, $ProductTypes) == true) {
            if (preg_match('/^\\/home/', $request_path) != 0 || preg_match('/^\\/support/', $request_path) != 0 || preg_match('/^\\/amember/', $request_path) != 0) {
                return true;
            } else {
                $app->redirect('/amember4/member');
            }
        }
        $app->redirect('/amember4/signup');
    }
});
$app->hook('slim.after.router', function () use($app) {
    # Disable caching for all content types other than images
    $response = $app->response();
    if (substr($response['Content-Type'], 0, 6) === 'image/') {
        $response['Cache-Control'] = 'public, max-age=86400';
        $response['Expires'] = gmdate('D, d M Y H:i:s GMT', strtotime('+1 day'));
    } else {
        $response['Pragma'] = 'nocache';
        $response['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate';
        $response['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT';
    }
});
# Set options for the Twig template engine
\Slim\Extras\Views\Twig::$twigOptions = ['auto_reload' => true, 'autoescape' => true, 'charset' => 'utf-8', 'strict_variables' => false];
$twig = $app->view()->getEnvironment();
$twig->addGlobal('remote_ip', $_SERVER['REMOTE_ADDR']);
# Import routes from separate include files
require 'lib/routes.inc.php';
require 'lib/routes-api.inc.php';
# Execute Slim to handle the request
$app->run();
Beispiel #8
0
<?php

$config = ['slim' => ['templates.path' => SS_APP_PATH . '/templates', 'log.level' => \Slim\Log::DEBUG, 'log.enabled' => TRUE, 'log.writer' => new \Slim\Extras\Log\DateTimeFileWriter(['path' => SS_APP_PATH . '/logs', 'name_format' => 'Y-m-d.\\l\\o\\g'])], 'twig' => ['charset' => 'utf-8', 'cache' => SS_APP_PATH . '/cache/templates', 'auto_reload' => TRUE, 'strict_variables' => FALSE, 'autoescape' => TRUE]];
$app = new \Slim\Slim($config['slim']);
\Slim\Extras\Views\Twig::$twigOptions = $config['twig'];
$app->view(new \Slim\Extras\Views\Twig());
<?php

// Vendor Autoloader
require_once VENDOR_PATH . 'autoloader.php';
\Vendors\Autoloader::setIncludePath(VENDOR_PATH);
\Vendors\Autoloader::register();
// Import Site configuration
$site_cfg = parse_ini_file(APP_PATH . 'config/config.ini', TRUE);
// Slim Configuration
\Slim\Slim::registerAutoloader();
// Twig Configuration
\Slim\Extras\Views\Twig::$twigDirectory = VENDOR_PATH . 'Twig';
\Slim\Extras\Views\Twig::$twigOptions = array("debug" => true);
if (is_writable(ROOT_PATH . 'cache')) {
    \Slim\Extras\Views\Twig::$twigOptions['cache'] = ROOT_PATH . 'cache';
}
// Setup $app
$app = new \Slim\Slim(array('templates.path' => APP_PATH . 'views/', 'debug' => false, 'view' => new \Slim\Extras\Views\Twig(), 'cookies.secret_key' => md5($site_cfg['website']['secret']), 'log.enabled' => false, 'log.writer' => new \Slim\Extras\Log\DateTimeFileWriter(array('path' => ROOT_PATH . 'logs', 'name_format' => 'Y-m-d', 'message_format' => '%label% - %date% - %message%'))));
// Set our app name
$app->setName($site_cfg['website']['name']);
// Template Globals
$twig = $app->view()->getEnvironment();
$twig->addGlobal('SITE_NAME', $site_cfg['website']['name']);
$twig->addGlobal('SITE_VER', $site_cfg['website']['version']);
$twig->addGlobal('SITE_AUTHOR', $site_cfg['website']['author']);
if (isset($site_cfg['website']['ua_id'])) {
    $twig->addGlobal('GOOGLE_UA_ID', $site_cfg['website']['ua_id']);
}
// Load Controllers
if (!is_dir(APP_PATH . 'controllers/')) {
    throw new Exception('Invalid controller path: ' . APP_PATH . 'controllers/');