<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	/****************************************************************************/
	/****************************************************************************/
	/**
     *  _initConfig
     *  
     *  registration namespace MyWeb_
     *  setting display warning and error
     *  @return Zend_Config_Ini
     */
    protected function _initConfig()
    {
    	
    	
    	$autoloader=Zend_Loader_Autoloader::getInstance();
    	$autoloader->getRegisteredNamespaces("MyWeb_");
    	$autoloader->suppressNotFoundWarnings(true);
        $autoloader->setFallbackAutoloader(true);
        $autoloader->suppressNotFoundWarnings();
		
        
        $router     = new Zend_Controller_Router_Rewrite();
         
        
        //$controller = Zend_Controller_Front::getInstance();
        //$controller	->	setControllerDirectory('./application/controllers')
        //			->	setRouter($router)
        //			->	setBaseUrl('eclipse/MyHome/public'); // set the base url!
       	//$router->setRewriteBase('eclipse/MyHome/public');
        //$response   = $controller->dispatch();
        
        //$front = Zend_Controller_Front::getInstance();
        //$front->setBaseUrl('/MyHome/public');
        
        $config = $this->getOptions();
        Zend_Registry::set('config', $config);
        return $config;
        
    }
    
    
    
	protected function _initLog()
	{
		MyWeb_Log_ApplicationLogger::setPathLogFile('../data/Logs/log.txt');
		MyWeb_Log_ApplicationLogger::setPathNameMethodFile('../library/MyWeb/Log/nameMethods.txt');
		MyWeb_Log_ApplicationLogger::setPathTextLogFile('../library/MyWeb/Log/textLog.txt');
		MyWeb_Log_ApplicationLogger::deleteLogFile();
		//MyWeb_Log_ApplicationLogger::stopLog();
	}
	
	/**
	 * Inicializace zend_local a zend_translate
	 * Enter description here ...
	 */
	protected function _initTrabslate()
	{
		Zend_Registry::set('Zend_Locale', new Zend_Locale());
		
		$languageFile = APPLICATION_PATH . '/languages/';
		$languageFile .= Zend_Registry::get('Zend_Locale')->getLanguage() . '.php';
		
		$translate = new Zend_Translate('array',$languageFile);
		Zend_Registry::set('Zend_Translate', $translate);
	}
    /****************************************************************************/
	/****************************************************************************/
    
	
	
	
	protected function _initAutoCreator()
	{
		$autoCreateFiles = FALSE;//FALSE//TRUE
		if ($autoCreateFiles){
		$dsn = array(
						'host' => 'localhost',
						'username' => 'root',
						'password' => 'root',
						'dbname' => 'MyWeb'
					);
		
					
					
		$allTable = array(	'article',
							'article_has_subject',
							'comment',
							'file',
							'namestate',
							'role',
							'state',
							'state_has_state',
							'subject',
							'subject_has_subject',
							'subjectlevel',
							'tabledatabase',
							'typefile',
							'user',
							'user_has_role'
						);
		
		$dbTables = MyWeb_DbTable_CreatorDbTable::loadDbTables(array('article'), $dsn);
		
		
		$path_form_ini = '../application/forms/';//na konci cesty mus� b�t lom�tko
		$path_form_php = '../application/models/Form/';//na konci cesty mus� b�t lom�tko
		$path_modelphp = '../application/models/';//na konci cesty mus� b�t lom�tko
		
		
		$path_model_table_php	=	'../application/models/DbTable/';//model
		$path_controller_php	=	'../application/controllers/';//cesta ke controllers
		$path_view_php			=	'../application/views/scripts/';//cesta ke views
		
		//$dbTables[1]['params']['viewList']=null;
		//$dbTables[1]['params']['viewList2']=null;
		//$dbTables[1]['params']['modelTable']=null;
		//$dbTables[1]['params']['model']=null;
		
		//$dbTables[0]['params']['viewList']=null;
		//$dbTables[0]['params']['viewList2']=null;
		//$dbTables[0]['params']['viewNew']=null;
		//$dbTables[0]['params']['viewEdit']=null;
		//$dbTables[0]['params']['viewSearch']=null;
		//$dbTables[0]['params']['viewIndex']=null;
		
		
		
		//$dbTables[0]['params']['controller']=null;
		//$dbTables[0]['params']['modelTable']=null;
		//$dbTables[0]['params']['model']=null;
		
		//$dbTables[0]['params']['formNewIni']=null;
		//$dbTables[0]['params']['formEditIni']=null;
		//$dbTables[0]['params']['formSearchIni']=null;
		
		//$dbTables[0]['params']['formNewPhp']=null;
		//$dbTables[0]['params']['formEditPhp']= null;//'../application/models/Form/testGenerate/';
		//$dbTables[0]['params']['formSearchPhp']=null;
		
		
		
		//*** login logout
		//$dbTables[0]['params']['formLoginPhp']=null;
		//$dbTables[0]['params']['formLogoutPhp']=null;
		
		//$dbTables[0]['params']['viewLogin']=null;
		//$dbTables[0]['params']['viewLogout']=null;
		
		//$dbTables[0]['params']['formSearchIni']=null;
		//$dbTables[0]['params']['formLoginIni']=null;
		
			//$files = MyWeb_File_CreatorFile::createFiles($dbTables);
    	}
	}
	
	protected function _initJQuery()
	{
    	$this->bootstrap("view");
    	$view = $this->getResource("view");
 		$view -> addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
 		$view -> addHelperPath("MyWeb/Sozfo/View/Helper", "MyWeb_Sozfo_View_Helper");
    	
    	ZendX_JQuery::enableView($view);
    	return $view->jQuery();
	}
	
	protected function _initViewHelpers()
	{
		//Zend_Layout::startMvc();
		$this->bootstrap('layout');
		$layout = $this->getResource('layout');
		$view = $layout->getView();
		$view->doctype('XHTML1_STRICT');
		$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
	}	
	
	/**
	 * used for handling top-level navigation
	 * @return Zend_Navigation
	 */
	protected function _initNavigation()
	{
		/*
		 * nacteni vytvoreneho xml je nutne pro vytvoreni drobeckove navigace
		 */
			$this->bootstrap('layout');
        	$layout = $this->getResource('layout');
        	$view = $layout->getView();		
        	$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
			
			$container = new Zend_Navigation($config);
			
			$view->navigation($container);
	}
	
}

