<?php
/**
 * Created by PhpStorm.
 * User: Игорь
 * Date: 23.01.2017
 * Time: 00:07
 */

require_once __DIR__ . '/../vendor/autoload.php';


setlocale(LC_ALL,'ru_RU.UTF-8');


$config = (object) [
  "views_dir"  => __DIR__ . '/V/',
  "public_dir" => dirname(__DIR__) . '/public/',
  "db"         => (object) [
    'host'     => '127.0.0.1',
    'port'     => '3306',
    'dbname'   => 'test',
    'user'     => 'testuser',
    'password' => 'testpassword',
  ],
  "controller_namespace" => "\\PTEST\\C\\",
  "site_name" => "Доска объявлений"
];

$app = new PFRM\App( $config );

$app->setRoute( '/^\/CAPTCHA.png\?*\d*$/', 'CAPTCHA' );
$app->setRoute( '|^/page/((?<id>\d+)/)?$|', 'Index', 'index');
$app->setRoute( '|^/(?<column>date)/(?<order>desc)/(page/(?<id>\d+)/)?$|', 'Index', 'sort');
$app->setRoute( '|^/(?<column>user)/(?<order>asc)/(page/(?<id>\d+)/)?$|', 'Index', 'sort');
$app->setRoute( '|^/(?<column>user)/(?<order>desc)/(page/(?<id>\d+)/)?$|', 'Index', 'sort');
$app->setRoute( '|^/(?<column>mail)/(?<order>asc)/(page/(?<id>\d+)/)?$|', 'Index', 'sort');
$app->setRoute( '|^/(?<column>mail)/(?<order>desc)/(page/(?<id>\d+)/)?$|', 'Index', 'sort');
$app->setRoute( '|^/full/(?<id>\d+)/$|', 'Index', 'full');
$app->setRoute( '|^/new/$|', 'Index', 'new');
$app->setRoute( '/^.*$/', 'error404' );

$app->run();