summaryrefslogtreecommitdiffstats
path: root/application/Bootstrap.php
blob: 35400b1a026b92bd7d9cc369bf9e4215aa6a3cb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoload()
    {
        $moduleLoader = new Zend_Application_Module_Autoloader(
        array(
				'namespace'	=> '',
				'basePath'	=> APPLICATION_PATH
        )
        );
        return $moduleLoader;
    }

    protected function _initDbSetup()
    {
        $logger = new Zend_Log();
        $w = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/debug.log');

        $logger->addWriter($w);

        $this->bootstrap('Db');
        $db = $this->getResource('Db');
        $tables = $db->listTables();
        if(empty($tables)) {
            $sql = file_get_contents(APPLICATION_PATH . '/configs/db.sql');
            $logger->info("Setup DB");
            $sqlcommands = explode(";\n",$sql);
            try{
                foreach($sqlcommands as $s) {
                    $db->getConnection()->exec($s);
                }
            }
            catch (Exception $e) {
                $logger->warn($e->getMessage());
            }
        } else {
            $logger->info("Skip DB setup");

        }
        return;
    }

    public function _initViewHelpers()
    {
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $view = $layout->getView();
        $view->doctype('XHTML1_STRICT');
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
        $view->headTitle()->setSeparator(' :: ');
        $view->headTitle('OpenSLX PBS');
    }

}