<?php

class IndexController extends Controller
{
    /**
     * Construct this object by extending the basic Controller class
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Handles what happens when user moves to URL/index/index
     * - or - as this is the default controller, also
     * when user moves to /index or enter your application at base level
     */
    public function index()
    {
        $status = InstallModel::checkInstallationComplete();
        if ($status['installed'] === true)
        {
            $this->View->render('index');
        }
        else
        {
            $installStatus = false;
            if (isset($status['db']) && $status['db'] != false)
            {
                InstallModel::init();
                $installStatus = InstallModel::install();
            }
            $this->View->renderInstall(array(
                'installStatus' => $installStatus
            ));
        }
    }
}
