<?php

/*
 * index.php
 *
 * Main controller for Nachlass-DB-Frontend
 *
 * (c) 2013-2021 daniel.burckhardt@sur-gmbh.ch
 *
 * Version: 2021-11-14 dbu
 *
 * Changes:
 *
 */

require_once 'setup.inc.php';

class FrontendApplication extends Zend_Application
{
    public $container; // Symfony DIC set by Bootstrap

    public function run()
    {
        // get the base page and view for the frontend
        $inc_path = INC_PATH . '/content';

        if (defined('DISPLAY_OVERRIDE_PATH')
            && file_exists(DISPLAY_OVERRIDE_PATH . '/frontendpage.inc.php')) {
            // site specific override of frontendpage to adjust $SITE_DESCRIPTION
            $inc_path = DISPLAY_OVERRIDE_PATH;
        }

        require_once $inc_path . '/frontendpage.inc.php';

        require_once INC_PATH . '/content/frontenddisplay.inc.php';

        $page = new FrontendPage($SITE_DESCRIPTION, $this->container);

        // the following method includes the actual view and registers for display
        $page->init(array_key_exists('pn', $_REQUEST) ? $_REQUEST['pn'] : null);

        $page->display();
    }
}

$application = new FrontendApplication(APPLICATION_ENV, [
    'bootstrap' => [
        'path' => INC_PATH . '/Bootstrap.php',
        'class' => 'Bootstrap',
    ],
]);
$application->bootstrap();
$application->run();
