data = $data;
    }
    public function apply()
    {
        $resourceConfig = array();
        if (isset($this->data['dbResourceConfig'])) {
            $dbConfig = $this->data['dbResourceConfig'];
            $resourceName = $dbConfig['name'];
            unset($dbConfig['name']);
            $resourceConfig[$resourceName] = $dbConfig;
        }
        if (isset($this->data['ldapResourceConfig'])) {
            $ldapConfig = $this->data['ldapResourceConfig'];
            $resourceName = $ldapConfig['name'];
            unset($ldapConfig['name']);
            $resourceConfig[$resourceName] = $ldapConfig;
        }
        try {
            Config::fromArray($resourceConfig)
                ->setConfigFile(Config::resolvePath('resources.ini'))
                ->saveIni();
        } catch (Exception $e) {
            $this->error = $e;
            return false;
        }
        $this->error = false;
        return true;
    }
    public function getSummary()
    {
        if (isset($this->data['dbResourceConfig']) && isset($this->data['ldapResourceConfig'])) {
            $pageTitle = '
' . mt('setup', 'Resources', 'setup.page.title') . '
';
        } else {
            $pageTitle = '' . mt('setup', 'Resource', 'setup.page.title') . '
';
        }
        if (isset($this->data['dbResourceConfig'])) {
            $dbTitle = '' . mt('setup', 'Database', 'setup.page.title') . '
';
            $dbHtml = ''
                . ''
                . ''
                . ''
                . '| ' . t('Resource Name') . ''
                . ' | ' . $this->data['dbResourceConfig']['name'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Database Type') . ''
                . ' | ' . $this->data['dbResourceConfig']['db'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Host') . ''
                . ' | ' . $this->data['dbResourceConfig']['host'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Port') . ''
                . ' | ' . $this->data['dbResourceConfig']['port'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Database Name') . ''
                . ' | ' . $this->data['dbResourceConfig']['dbname'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Username') . ''
                . ' | ' . $this->data['dbResourceConfig']['username'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Password') . ''
                . ' | ' . str_repeat('*', strlen($this->data['dbResourceConfig']['password'])) . ''
                . ' | 
'
                . ''
                . '
';
        }
        if (isset($this->data['ldapResourceConfig'])) {
            $ldapTitle = 'LDAP
';
            $ldapHtml = ''
                . ''
                . ''
                . ''
                . '| ' . t('Resource Name') . ''
                . ' | ' . $this->data['ldapResourceConfig']['name'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Host') . ''
                . ' | ' . $this->data['ldapResourceConfig']['hostname'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Port') . ''
                . ' | ' . $this->data['ldapResourceConfig']['port'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Root DN') . ''
                . ' | ' . $this->data['ldapResourceConfig']['root_dn'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Bind DN') . ''
                . ' | ' . $this->data['ldapResourceConfig']['bind_dn'] . ''
                . ' | 
'
                . ''
                . '| ' . t('Bind Password') . ''
                . ' | ' . str_repeat('*', strlen($this->data['ldapResourceConfig']['bind_pw'])) . ''
                . ' | 
'
                . ''
                . '
';
        }
        return $pageTitle . (isset($dbTitle) ? '' . $dbTitle . $dbHtml . '
' : '')
            . (isset($ldapTitle) ? '' . $ldapTitle . $ldapHtml . '
' : '');
    }
    public function getReport()
    {
        if ($this->error === false) {
            return array(sprintf(
                mt('setup', 'Resource configuration has been successfully written to: %s'),
                Config::resolvePath('resources.ini')
            ));
        } elseif ($this->error !== null) {
            return array(
                sprintf(
                    mt('setup', 'Resource configuration could not be written to: %s. An error occured:'),
                    Config::resolvePath('resources.ini')
                ),
                sprintf(mt('setup', 'ERROR: %s'), $this->error->getMessage())
            );
        }
    }
}