Skip to content

Commit

Permalink
Refactored DIP settings page, refs #13028
Browse files Browse the repository at this point in the history
Refactored DIP settings page to use settings editing parent class.
  • Loading branch information
mcantelon committed Jul 3, 2019
1 parent 3648d47 commit fc4ab2f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 114 deletions.
75 changes: 19 additions & 56 deletions apps/qubit/modules/settings/actions/dipUploadAction.class.php
Expand Up @@ -17,70 +17,33 @@
* along with Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>.
*/

/**
* DIP Upload settings
*
* @package AccesstoMemory
* @subpackage settings
*/

class SettingsDipUploadAction extends sfAction
class SettingsDipUploadAction extends SettingsEditAction
{
public function execute($request)
{
$this->dipUploadForm = new SettingsDipUploadForm;

// Handle POST data (form submit)
if ($request->isMethod('post'))
{
QubitCache::getInstance()->removePattern('settings:i18n:*');

// Handle DIP Upload form submission
if (null !== $request->dip_upload)
{
$this->dipUploadForm->bind($request->dip_upload);
if ($this->dipUploadForm->isValid())
{
// Do update and redirect to avoid repeat submit wackiness
$this->updateDipUploadSettings();

$notice = sfContext::getInstance()->i18n->__('DIP upload settings saved.');
$this->getUser()->setFlash('notice', $notice);
// Arrays not allowed in class constants
public static
$NAMES = array(
'stripExtensions');

$this->redirect('settings/dipUpload');
}
}
}

$this->populateDipUploadForm();
}

/**
* Populate the DIP Upload form
*/
protected function populateDipUploadForm()
public function earlyExecute()
{
$stripExtensions = QubitSetting::getByName('stripExtensions');
parent::earlyExecute();

$this->dipUploadForm->setDefaults(array(
'strip_extensions' => (isset($stripExtensions)) ? $stripExtensions->getValue(array('sourceCulture'=>true)) : 1
));
$this->updateMessage = $this->i18n->__('DIP upload settings saved.');

$this->settingDefaults = array(
'stripExtensions' => '0'
);
}

/**
* Update the DIP upload settings
*/
protected function updateDipUploadSettings()
protected function addField($name)
{
$thisForm = $this->dipUploadForm;

if (null !== $stripExtensions = $thisForm->getValue('strip_extensions'))
switch ($name)
{
$setting = QubitSetting::getByName('stripExtensions');
$setting->setValue($stripExtensions, array('sourceCulture' => true));
$setting->save();
}
case 'stripExtensions':
$this->form->setWidget($name, new sfWidgetFormSelectRadio(array('choices' => array(1 => 'yes', 0 => 'no')), array('class' => 'radio')));
$this->form->setValidator($name, new sfValidatorInteger(array('required' => false)));

return $this;
break;
}
}
}
5 changes: 4 additions & 1 deletion apps/qubit/modules/settings/templates/dipUploadSuccess.php
Expand Up @@ -26,7 +26,10 @@
</tr>
</thead>
<tbody>
<?php echo $dipUploadForm ?>
<tr>
<td><?php echo __('Strip file extensions from information object names') ?></td>
<td><?php echo $form->stripExtensions ?></td>
</tr>
</tbody>
</table>

Expand Down
57 changes: 0 additions & 57 deletions lib/form/SettingsDipUploadForm.class.php

This file was deleted.

0 comments on commit fc4ab2f

Please sign in to comment.