Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #7163
- Loading branch information
Johannes Meyer
committed
Sep 29, 2014
1 parent
b1c32b1
commit 61f0ce6
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Form\Setup; | ||
|
||
use Icinga\Web\Form; | ||
use Icinga\Application\Platform; | ||
|
||
/** | ||
* Wizard page to choose a preference backend | ||
*/ | ||
class PreferencesPage extends Form | ||
{ | ||
/** | ||
* Initialize this page | ||
*/ | ||
public function init() | ||
{ | ||
$this->setName('setup_preferences_type'); | ||
} | ||
|
||
/** | ||
* Pre-select "db" as preference backend and add a hint to the select element | ||
* | ||
* @return self | ||
*/ | ||
public function showDatabaseNote() | ||
{ | ||
$this->getElement('type') | ||
->setValue('db') | ||
->setDescription( | ||
t('Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.') | ||
); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @see Form::createElements() | ||
*/ | ||
public function createElements(array $formData) | ||
{ | ||
$this->addElement( | ||
'note', | ||
'description', | ||
array( | ||
'value' => t('Please choose how Icinga Web 2 should store user preferences.') | ||
) | ||
); | ||
|
||
$storageTypes = array(); | ||
$storageTypes['ini'] = t('File System (INI Files)'); | ||
if (Platform::extensionLoaded('pdo') && (Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql') | ||
|| Platform::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql'))) | ||
{ | ||
$storageTypes['db'] = t('Database'); | ||
} | ||
$storageTypes['null'] = t('Don\'t Store Preferences'); | ||
|
||
$this->addElement( | ||
'select', | ||
'type', | ||
array( | ||
'required' => true, | ||
'label' => t('User Preference Storage Type'), | ||
'multiOptions' => $storageTypes | ||
) | ||
); | ||
} | ||
} |