<?php

global $project;
$project = 'mysite';

LeftAndMain::setApplicationName('IDEA CMS', 'IDEA', 'http://www.idea.lt');
LeftAndMain::setLogo('/mysite/adminlogin/born_in_idea.png', 'width:129px;height:34px;');
LeftAndMain::set_loading_image('/mysite/adminlogin/born_in_idea.png');

Director::set_dev_servers(array(
	'localhost',
	'127.0.0.1',
	'starjobs.local'

));
Director::set_test_servers(array(
));

define('ENV', Director::get_environment_type());

DatabaseBrowser::$trusted_envs = array('test', 'dev');

global $databaseConfig;
$dbConfig['dev'] = array(

);
$dbConfig['test']  = array(
);
$dbConfig['live'] = array(
   "type" => 'MySQLDatabase',
	"server" => 'localhost',
	"username" => 'root', // 'biuro_lt',
	"password" => '', // '06dLhz',
	"database" => 'biuro_lt',
	"path" => '',
);
$databaseConfig = $dbConfig[ENV];
SS_Cache::set_cache_lifetime('any', 3600, 100);
switch (ENV) {
	case "dev":
		ini_set('display_errors', 1);
		error_reporting(E_ALL);
		SSViewer::flush_template_cache();
		//$_GET['flush'] = 1;
		Security::setDefaultAdmin('admin', 'admin');
		SS_Cache::set_cache_lifetime('any', -1, 100);
		break;
	case "test":

		SS_Log::add_writer(new SS_LogEmailWriter('neringa@idea.lt'), SS_Log::NOTICE, '<=');
		break;
	case "live":
		SS_Log::add_writer(new SS_LogEmailWriter('neringa@idea.lt'), SS_Log::ERR);
		DatabaseBrowser::$activated = false;
		DatabaseBrowser::hide_from_menu();
		break;
}

MySQLDatabase::set_connection_charset('utf8');


// This line set's the current theme. More themes can be
// downloaded from http://www.silverstripe.org/themes/
//SSViewer::set_theme('blackcandy');

SiteTree::enable_nested_urls();

// Set the site locale
//Translatable::enable();
i18n::set_locale('lt_LT');
Translatable::set_default_locale('lt_LT');

// http://www.silverstripe.org/installing-silverstripe/show/11983
// http://doc.silverstripe.org/sapphire/en/topics/translation#templates
// i18n
//i18n::enable();

// Define allowed locales overriding those present in i18n::$common_locales
$locales = array(
    'en_US' => array('EN', 'English'),
	'lt_LT' => array('LT', 'Lietuviškai'),
    'ru_RU' => array('RU', 'По-русски'),
    'de_DE' => array('DE', 'Deutsch'),
);
i18n::$common_locales = $locales;

Translatable::set_allowed_locales(array(
	'lt_LT', 'en_US', 'ru_RU', 'de_DE'
));
//Translatable::set_allowed_locales($common_locales);

Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');
Object::add_extension('Widget', 'Translatable');
Object::add_extension('WidgetArea', 'Translatable');

Validator::set_javascript_validation_handler('none');

/*
SS_Cache::add_backend(
		'primary_memcached',
		'Memcached',
		array(
		Ma	'host' => 'localhost',
			'port' => 11211,
			'persistent' => true,
			'weight' => 1,
			'timeout' => 5,
			'retry_interval' => 15,
			'status' => true,
			'failure_callback' => '' ));

SS_Cache::pick_backend('primary_memcached', 'any', 10);
// Aggregate needs a backend with tag support, which memcached doesn't provide
SS_Cache::pick_backend('default', 'aggregate', 20);*/

// enable nested URLs for this site (e.g. page/sub-page/)
//SiteTree::enable_nested_urls();

//Hide a main CMS Tab
//CMSMenu::remove_menu_item('CommentAdmin');

Object::add_extension('LeftAndMain', 'MyLeftAndMainDecorator');
DataObject::add_extension('SiteConfig', 'MySiteConfig');
Object::add_extension('Widget', 'WidgetExtension');

Object::useCustomClass('StringField', 'Extended_StringField', true);

FulltextSearchable::enable(array('SiteTree'));

GD::set_default_quality(100);
