<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
$langRegExp = '(en|ru)';
return array(
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => 'Auto-Life',
    'language' => 'ru',

    // preloading 'log' component
    'preload' => array('log'),

    // autoloading model and component classes
    'import' => array(
        'application.models.*',
        'application.components.*',
        'vendor.z_bodya.yii-i18d-gallery-manager.*',
        'vendor.z_bodya.yii-i18d-gallery-manager.models.*',
        'vendor.z_bodya.yii-multiselect.*',
        'vendor.z_bodya.yii-chosen.*',
        'vendor.z_bodya.yii-swiftmailer.*',
        'vendor.z_bodya.yii-tinymce.*',
        'vendor.z_bodya.yii-elfinder.*',
        'vendor.z_bodya.yii-image.*',
        'vendor.z_bodya.yii-fileimagearbehavior.*',
        'application.extensions.CAdvancedArFindBehavior',
    ),

    'modules' => array(
        // uncomment the following to enable the Gii tool
        'gii' => array(
            'class' => 'system.gii.GiiModule',
            'password' => 'co4rymew',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters' => array('127.0.0.1', '::1'),
            'generatorPaths' => array(
                'application.modules.admin.gii', // a path alias
            ),
        ),
        'admin',
    ),

    // application components
    'components' => array(
        'swiftMailer' =>  require('mailer.php'),
        'request'=>array(
            'enableCsrfValidation'=>false,
        ),
        'messages' => array(
            'class' => 'CDbMessageSource',
            'language' => 'ru',
        ),
        'assetManager' => array(
            //'linkAssets' => true,
        ),
        'widgetFactory' => array(
            'class' => 'CWidgetFactory',
            'widgets' => array(
                'TinyMce' => array(
                    'compressorRoute' => 'admin/tinyMce/compressor',
                    'spellcheckerRoute' => 'admin/tinyMce/spellchecker',
                    'fileManager' => array(
                        'class' => 'TinyMceElFinder',
                        'connectorRoute' => 'admin/elfinder/connector',
                    ),
                    'settings' => array(
                        'content_css' => '/wysiwyg/wysiwyg.css',
                        'template_external_list_url' => '/wysiwyg/templates.js',
                    ),
                ),
                'GalleryManager' => array(
                    'controllerRoute' => '/admin/gallery',
                ),
                'ServerFileInput' => array(
                    'connectorRoute' => 'admin/elfinder/connector',
                ),
                'ElFinderWidget' => array(
                    'connectorRoute' => 'admin/elfinder/connector',
                ),
            )
        ),
        'image' => array(
            'class' => 'vendor.z_bodya.yii-image.CImageComponent',
            // GD or ImageMagick
            'driver' => 'GD',
            // ImageMagick setup path
            'params' => array('directory' => '/opt/local/bin'),
        ),

        'user' => array(
            // enable cookie-based authentication
            'allowAutoLogin' => true,
        ),
        // uncomment the following to enable URLs in path-format
        'urlManager' => array(
            'urlFormat' => 'path',
            'showScriptName' => false,
            'class' => 'UrlManager',
            'rules' => array(
                // admin module
                'admin' => array('admin', 'params' => array('defaultParams' => 'ru')),
                'admin/<controller:\w+>' => array('admin/<controller>', 'defaultParams' => array('lang' => 'ru')),
                'admin/<controller:\w+>/<action:\w+>' => array('admin/<controller>/<action>', 'defaultParams' => array('lang' => 'ru')),

                //site links
                'sitemap.xml' => 'site/siteMap',

                "<lang:$langRegExp>/" => 'site/index',
                "<lang:$langRegExp>/error" => 'site/error',
                "<lang:$langRegExp>/contact" => 'site/contact',
                //  "<lang:$langRegExp>/reviews" => 'site/reviews',
                "<lang:$langRegExp>/feed" => 'site/feed',

                //about section links
//                "<lang:$langRegExp>/about" => 'about/index',
//                "<lang:$langRegExp>/partners" => 'about/partners',
//                "<lang:$langRegExp>/partners/<link:[^\/]+>" => 'about/partner',
//                "<lang:$langRegExp>/jobs" => 'about/jobs',
//                "<lang:$langRegExp>/jobs/<link:[^\/]+>" => 'about/job',

                //  "<lang:$langRegExp>/about" => 'about/index',
                //  "<lang:$langRegExp>/about/partners" => 'about/partners',
                //  "<lang:$langRegExp>/about/partners/<link:[^\/]+>" => 'about/partner',
                //  "<lang:$langRegExp>/about/jobs" => 'about/jobs',
                //  "<lang:$langRegExp>/about/jobs/<link:[^\/]+>" => 'about/job',

                //tuning section links
                //  "<lang:$langRegExp>/tuning" => 'tuning/index',
                //  "<lang:$langRegExp>/tuning/services/<link:[^\/]+>" => 'tuning/service',
                //  "<lang:$langRegExp>/tuning/<brand:[^\/]+>" => 'tuning/brand',
                //  "<lang:$langRegExp>/tuning/<brand:[^\/]+>/<model:[^\/]+>" => 'tuning/model',
                //  "<lang:$langRegExp>/tuning/<brand:[^\/]+>/<model:[^\/]+>/<set:[^\/]+>" => 'tuning/view',

                //work section links
                //  "<lang:$langRegExp>/work" => 'work/index',
                //  "<lang:$langRegExp>/work/<brand:[^\/]+>" => 'work/brand',
                //  "<lang:$langRegExp>/work/<brand:[^\/]+>/<model:[^\/]+>" => 'work/model',
                //  "<lang:$langRegExp>/work/<brand:[^\/]+>/<model:[^\/]+>/<set:[^\/]+>" => 'work/view',

                //service section
                "<lang:$langRegExp>/service" => 'service/index',
                "<lang:$langRegExp>/service/<category:[^\/]+>" => 'service/category',
                "<lang:$langRegExp>/service/<category:[^\/]+>/<link:[^\/]+>" => 'service/view',
                "<lang:$langRegExp>/service-center/<center:[^\/]+>" => 'service/center',

                //news section
                //  "<lang:$langRegExp>/news" => 'news/index',
                //  "<lang:$langRegExp>/feed" => 'news/feed',
                //  "<lang:$langRegExp>/news-categories/<link:[^\/]+>" => 'news/category',
                //  "<lang:$langRegExp>/show/<link:[^\/]+>" => 'news/show',
                //  "<lang:$langRegExp>/news/<link:[^\/]+>" => 'news/view',
                //  "<lang:$langRegExp>/publications/<link:[^\/]+>" => 'news/publications',
                //  "<lang:$langRegExp>/publication/<link:[^\/]+>" => 'news/publication',

                //action section
                "<lang:$langRegExp>/action" => 'action/index',
                "<lang:$langRegExp>/action/finished" => 'action/finished',
                "<lang:$langRegExp>/action/<link:[^\/]+>" => 'action/category',
                "<lang:$langRegExp>/action/<category:[^\/]+>/<link:[^\/]+>" => 'action/view',



                "<lang:$langRegExp>/stoFilter" => 'stoFilter/index',
                "<lang:$langRegExp>/stoFilter/finished" => 'stoFilter/finished',
                "<lang:$langRegExp>/stoFilter/<link:[^\/]+>" => 'stoFilter/category',
                "<lang:$langRegExp>/stoFilter/<category:[^\/]+>/<link:[^\/]+>" => 'stoFilter/view',



                //auto-sport section
                //  "<lang:$langRegExp>/sport" => 'sport/index',
                //  "<lang:$langRegExp>/sport/study" => 'sport/study',
                //  "<lang:$langRegExp>/sport/awards" => 'sport/awards',
                //  "<lang:$langRegExp>/sport/team" => 'sport/team',
                //  "<lang:$langRegExp>/sport/calendar" => 'sport/calendar',
                //  "<lang:$langRegExp>/sport/albums" => 'sport/albums',
                //  "<lang:$langRegExp>/sport/album/<link:[^\/]+>" => 'sport/album',


                array(
                    'class' => 'NodeUrlRule',
                    'langVar' => 'lang',
                    'langExpression' => $langRegExp,
                    'rules' => array(
                        'textRoot' => array(
                            "/" => 'textRoot/index',
                        ),
                        'textSection' => array(
                            "/" => 'textSection/index',
                        ),
                        'textPage' => array(
                            "/" => 'textPage/index',
                        ),
                        'aboutRoot' => array(
                            "/" => 'about/index',
                        ),
                        'aboutSection' => array(
                            "/" => 'aboutSection/index',
                        ),
                        'aboutPage' => array(
                            "/" => 'aboutPage/index',
                        ),
                        'partnersSection' => array(
                            "/" => 'partnersSection/partners',
                            "/<link:[^\/]+>" => 'partnersSection/partner',
                        ),
                        'jobsSection' => array(
                            "/" => 'jobsSection/jobs',
                            "/<link:[^\/]+>" => 'jobsSection/job',
                        ),
                        'sportRoot' => array(
                            "/" => 'sport/index',
                            "/study" => 'sport/study',
                            "/awards" => 'sport/awards',
                            "/team" => 'sport/team',
                        ),
                        'sportSection'=>array(
                            "/" => 'sportSection/index',
                        ),
                        'sportPage'=>array(
                            "/" => 'sportPage/index',
                        ),
                        'albumsSection'=>array(
                            "/" => 'albumsSection/albums',
                            "/<link:[^\/]+>" => 'albumsSection/album',
                        ),
                        'calendarSection'=>array(
                            "/" => 'calendarSection/calendar',
                        ),
                        'warrantyRoot' => array(
                            '/' => 'warranty/index',
                        ),
                        'questionRoot' => array(
                            '/<category:[^\/]+>' => 'question/index',
                            '/' => 'question/index',
                        ),
                        'reviewsRoot' => array(
                            '/' => 'reviews/index',
                        ),
                        'workRoot' => array(
                            "/" => 'work/index',
                            "/<brand:[^\/]+>" => 'work/brand',
                            "/<brand:[^\/]+>/<model:[^\/]+>" => 'work/model',
                            "/<brand:[^\/]+>/<model:[^\/]+>/<set:[^\/]+>" => 'work/view',
                        ),
                        'tuningRoot' => array(
                            "/" => 'tuning/index',
                            "/services/<link:[^\/]+>" => 'tuning/service',
                            "/<brand:[^\/]+>" => 'tuning/brand',
                            "/<brand:[^\/]+>/<model:[^\/]+>" => 'tuning/model',
                            "/<brand:[^\/]+>/<model:[^\/]+>/<set:[^\/]+>" => 'tuning/view',
                        ),
                        'newsRoot' => array(
                            "/" => 'news/index',
//                            "/feed" => 'news/feed',
                            "/categories/<link:[^\/]+>" => 'news/category',
                            "/show/<link:[^\/]+>" => 'news/show',
                            "/view/<link:[^\/]+>" => 'news/view',
                            "/publications/<link:[^\/]+>" => 'news/publications',
                            "/publication/<link:[^\/]+>" => 'news/publication',
                        ),
                        'saleRoot' => array(
                            "/" => 'sale/index',
                            "/<link:[^\/]+>" => 'sale/view',
                        ),
                    )
                ),

                //sale section
                // "<lang:$langRegExp>/sale" => 'sale/index',
                // "<lang:$langRegExp>/sale/<link:[^\/]+>" => 'sale/view',


                //default routing rules
                "<lang:$langRegExp>/<controller:\w+>/" => '<controller>',
                "<lang:$langRegExp>/<controller:\w+>/<action:\w+>" => '<controller>/<action>',
                '<controller:\w+>/' => '<controller>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',


            ),
        ),


        'db' => require('db.php'),

        'errorHandler' => array(
            // use 'site/error' action to display errors
            'errorAction' => 'site/error',
        ),
        'log' => array(
            'class' => 'CLogRouter',
            'routes' => array(
                array(
                    'class' => 'CFileLogRoute',
                    'levels' => 'error, warning',
                ),
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'info',
                    'logFile'=>'waterMark.log',
                    'categories'=>'waterMark.*',
                ),
                // uncomment the following to show log messages on web pages
                /*
                    array(
                        'class'=>'CWebLogRoute',
                    ),
                    */
            ),
        ),
    ),

    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params' => array(
        'languages' => array(
            //  'uk',
            'ru',
            'en',
        ),
        'languageNames' => array(
            //  'uk' => 'Українська',
            'ru' => 'Русский',
            'en' => 'English',
        ),
        // this is used in contact page
        'adminEmail' => 'webmaster@example.com',
    ),
);