<?php

$baseUrl = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');

// 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.
return array(
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => 'FlexCMS',
    // preloading 'log' component
    'preload' => array('log', 'options', 'booster',),
    'sourceLanguage' => 'en_us',
    'aliases' => array(
        'admin' => 'application.modules.admin',
        'editable' => 'ext.x-editable',
        'bootstrap' => 'ext.bootstrap',
        'shortcodes' => 'application.components.shortcodes',
        'xupload' => 'ext.xupload',
        'booster' => realpath(__DIR__ . '/../extensions/yiibooster'), /* change if necessary */
    ),
    // autoloading model and component classes
    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.controllers.questionnaire.*',
        'application.modules.admin.components.*',
        'application.modules.admin.models.*',
        'application.modules.admin.models.behaviors.*',
        'application.modules.admin.modules.fmenu.models.*',
        'application.modules.admin.modules.fslider.models.*',
        'application.modules.admin.modules.ftabber.models.*',
        'application.components.shortcodes.*',
        'application.modules.admin.modules.user.models.*',
        'application.modules.admin.modules.user.components.*',
        'application.modules.admin.modules.rights.*',
        'application.modules.admin.modules.rights.components.*',
        'application.modules.admin.modules.fmessage.components.*',
        'application.modules.admin.modules.fmessage.models.*',
        'application.modules.admin.modules.widgets.components.*',
        'application.modules.admin.modules.widgets.models.*',
        'application.modules.admin.modules.falbums.models.*',
        'application.modules.admin.modules.fnewsletter.models.*',
        'application.modules.admin.modules.currency.models.*',
        'application.modules.admin.modules.person.models.*',
        'application.modules.admin.modules.governorate.models.*',
        'application.modules.admin.modules.area.models.*',
        'application.modules.admin.modules.branch.models.*',
        'application.modules.admin.modules.prayTime.models.*',
        'editable.*',
        'booster.helpers.*',
        'bootstrap.helpers.TbHtml',
        'bootstrap.helpers.TbArray',
        'bootstrap.behaviors.TbWidget',
        'application.modules.admin.modules.poll.models.*',
        'application.modules.admin.modules.poll.components.*',
        'application.modules.admin.modules.googleMaps.models.*',
        'application.modules.admin.modules.questionnaire.models.*',
        'application.modules.admin.modules.FAQ.models.*',
        'application.modules.admin.modules.contact.models.*',
        'application.modules.admin.modules.suggestions.models.*',
        'application.modules.admin.modules.video.models.*',
        'application.modules.admin.modules.calculator.models.*',
        'application.modules.admin.modules.commission.models.*',
        'application.modules.admin.modules.certificates.models.*',
        'application.modules.admin.modules.related.models.*',


    ),
    'modules' => array(
        'admin' => array(
            'modules' => array(
                'fmenu',
                'FAQ',
                'fslider',
                'ftabber',
                'fmessage',
                'fnewsletter',
                'falbums',
                'formBuilder',
                'currency',
                'person',
                'governorate',
                'area',
                'branch',
                'prayTime',
                'contact',
                'widgets',
                'googleMaps',
                'questionnaire',
                'suggestions',
                'video',
                'calculator',
                'commission',
                'certificates',
                'related',
                'user' => array(
                    'hash' => 'md5', # encrypting method (php hash function)
                    'sendActivationMail' => false, # send activation email
                    'loginNotActiv' => false, # allow access for non-activated users
                    'activeAfterRegister' => false, # activate user on registration (only sendActivationMail = false)
                    'autoLogin' => true, # automatically login from registration
                    'registrationUrl' => array("/admin/user/registration"),
                    'recoveryUrl' => array("/admin/user/recovery/recovery"),
                    'loginUrl' => array("/admin/user/login"),
                    'logoutUrl' => array("/admin/user/logout"),
                    'profileUrl' => array("/admin/user/profile"),
                    'returnUrl' => array("/admin/user/profile"),
                    'returnLogoutUrl' => array("/admin/user/login"),
                ),
                'rights' => array(
                    'superuserName' => 'admin', // Name of the role with super user privileges. 
                    'authenticatedName' => 'Authenticated', // Name of the authenticated user role. 
                    'userIdColumn' => 'id', // Name of the user id column in the database. 
                    'userNameColumn' => 'username', // Name of the user name column in the database. 
                    'enableBizRule' => true, // Whether to enable authorization item business rules. 
                    'enableBizRuleData' => false, // Whether to enable data for business rules. 
                    'displayDescription' => true, // Whether to use item description instead of name. 
                    'flashSuccessKey' => 'success', // Key to use for setting success flash messages. 
                    'flashErrorKey' => 'error', // Key to use for setting error flash messages. 
                    'install' => true, // Whether to install rights. 
                    'baseUrl' => '/admin/rights/', // Base URL for Rights. Change if module is nested. 
                    'layout' => 'admin.views.layouts.main', // Layout to use for displaying Rights. 
                    'appLayout' => 'admin.views.layouts.main', // Application layout. 
                    'cssFile' => false, // Style sheet file to use for Rights. 
                    'install' => true, // Whether to enable installer. 
                    'debug' => true, // Whether to enable debug mode. 
                ),
                'poll' => array(
                    'forceVote' => TRUE, // Force users to vote before seeing results
                    'ipRestrict' => TRUE, // Restrict anonymous votes by IP address,otherwise it's tied only to user_id 
                    'allowGuestCancel' => TRUE, // Allow guests to cancel their votes,if ipRestrict is enabled
                ),
            ),
        ),
        'gii' => array(
            'class' => 'system.gii.GiiModule',
            'password' => false,
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters' => array('127.0.0.1', '::1'),
            'generatorPaths' => array('admin.gii'), // a path alias
        ),
    ),
    // application components
    'components' => array(
        'session' => array(
            'cookieParams' => array(
                'httponly' => true,
                'secure' => true,
                'samesite' => 'strict',
            ),
        ),
        'assetManager' => array(
            'newDirMode' => 755,
        ),
        'booster' => array('class' => 'booster.components.Booster'),
        'ImageHelper',

        'geoip' => array(
            'class' => 'application.extensions.geoip.CGeoIP',
            //            'filename' => dirname(__FILE__) . '/../extensions/geoip/data/GeoLiteCity.dat',
            'filename' => dirname(__FILE__) . '/../extensions/geoip/data/GeoIP.dat',
            // Choose MEMORY_CACHE or STANDARD mode
            'mode' => 'STANDARD',
        ),
        'image' => array(
            'class' => 'application.extensions.image.CImageComponent',
            'driver' => 'GD', // GD or ImageMagick
        ),
        'bootstrap' => array(
            'class' => 'bootstrap.components.TbApi',
        ),
        'messages' => array(
            //            'onMissingTranslation' => array('MessageSourceHandler', 'onMissingTranslation'),
            //            'class' => 'CDbMessageSource',
            //            'sourceMessageTable' => 'fmessage_sourcemessage',
            //            'translatedMessageTable' => 'fmessage_message'
        ),
        'coreMessages' => array(
            'basePath' => 'protected/messages',
            //            'onMissingTranslation' => array('MessageSourceHandler', 'onMissingTranslation'),
            //            'class' => 'CDbMessageSource',
            ////            'sourceMessageTable' => 'fmessage_sourcemessage',
            //            'translatedMessageTable' => 'fmessage_message'
        ),
        'options' => array(
            'class' => 'application.components.OptionsManager'
        ),
        'user' => array(
            // enable cookie-based authentication
            'class' => 'RWebUser',
            'allowAutoLogin' => true,
            'loginUrl' => array("/admin/user/login"),
        ),
        'editable' => array(
            'class' => 'editable.EditableConfig',
            'form' => 'bootstrap', //form style: 'bootstrap', 'jqueryui', 'plain' 
            'mode' => 'inline', //mode: 'popup' or 'inline'  
            'defaults' => array( //default settings for all editable elements
                'emptytext' => 'Click to edit',
                //'ajaxOptions' => array('dataType' => 'json') //usefull for json exchange with server
            )
        ),
        'authManager' => array(
            'class' => 'RDbAuthManager', // Provides support authorization item sorting. 
            'assignmentTable' => 'authassignment',
            'itemChildTable' => 'authitemchild',
            'itemTable' => 'authitem',
            'rightsTable' => 'rights',
            'defaultRoles' => array('Authenticated', 'Guest'),
        ),
        'urlManager' => array(
            //    'class' => 'application.extensions.urlManager.LangUrlManager',
            //    'languages' => array('ar', 'en'),
            //    'langParam' => 'lang',
            'urlFormat' => 'path',
            'showScriptName' => false,
            'rules' => array(
                'admin' => 'admin/default/index',
                'admin/<controller:\w+>/<action:\w+>' => 'admin/<controller>/<action>',
                '' => 'site/index',
                '<action:(index|search|contact)>' => 'site/<action>',
                // 
                '<controller:\w+>/<action:(category|view)>/<slug:[\w-]+>' => '<controller>/<action>',
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
                '<controller:(page|album|article)>/<slug:[\w-]+>' => '<controller>/view',
                '<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
            ),
        ),
        'clientScript' => array(
            'coreScriptUrl' => $baseUrl . '/js/core',
            'scriptMap' => array(
                'jquery-ui.css' => false,
            ),
        ),
        // 'cache' => array('class' => 'system.caching.CFileCache',),
        'db' => array(
            'connectionString' => 'mysql:host=localhost;dbname=albaraka_website_new',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'tablePrefix' => '',
            'enableParamLogging' => YII_DEBUG,
            'enableProfiling' => YII_DEBUG,
            'queryCacheID' => 'cache',
            'schemaCachingDuration' => YII_DEBUG ? 0 : 86400000, // 1000 days
        ),
        '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' => 'CWebLogRoute',
					'levels' => 'error, warning',
				),
				array(
					'class' => 'CWebLogRoute',
					'levels' => 'error, warning,trace',
					'categories' => 'system.db.CDbCommand',
				),
				*/
			),
        ),
		
    ),
    //  application-level parameters that can be accessed
    //  using Yii::app()->params['paramName']
    'params' => array(
        //  this is used in contact page
        'adminEmail' => 'admin@gmail.com',
        'uploadDir' => realpath(dirname(__FILE__) . '/../../uploads') . DIRECTORY_SEPARATOR,
        'uploadUrl' => $baseUrl . '/uploads/',
        'encryptionKey' => '^-b2zi~Ps@XhvFIDY=;JmXheVAdASTFj$xczk!8^+ne7Y(~<5%oC~pqxcFpXBwcS',
    ),
);
