diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php index b7c9be3..639375e 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php @@ -17,19 +17,19 @@ class DateFormatDeleteForm extends ConfirmFormBase { /** * The date format data to be deleted. * - * @var \array + * @var array */ protected $format; /** * The id of the date format to be deleted. * - * @var \string + * @var string */ protected $formatId; /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion(). + * Implements ConfirmFormBase::getQuestion(). */ protected function getQuestion() { return t('Are you sure you want to remove the format %name : %format?', array( @@ -39,14 +39,14 @@ protected function getQuestion() { } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). + * Overrides ConfirmFormBase::getConfirmText(). */ protected function getConfirmText() { return t('Remove'); } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). + * Implements ConfirmFormBase::getCancelPath(). */ protected function getCancelPath() { return 'admin/config/regional/date-time/formats'; @@ -60,7 +60,7 @@ public function getFormID() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * Overrides ConfirmFormBase::buildForm(). */ public function buildForm(array $form, array &$form_state, $format_id = NULL) { // We don't get the format id in the returned format array. @@ -79,4 +79,5 @@ public function submitForm(array &$form, array &$form_state) { $form_state['redirect'] = 'admin/config/regional/date-time/formats'; } + } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php index 7fb3e33..ce395c2 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php @@ -1,4 +1,5 @@ language = language_load($langcode); @@ -75,4 +83,5 @@ public function submitForm(array &$form, array &$form_state) { $form_state['redirect'] = 'admin/config/regional/date-time/locale'; } + } diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesInstallConfirmFrom.php b/core/modules/system/lib/Drupal/system/Form/ModulesInstallConfirmFrom.php new file mode 100644 index 0000000..644dc15 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Form/ModulesInstallConfirmFrom.php @@ -0,0 +1,88 @@ + 'value', '#value' => $modules); + $form['status']['#tree'] = TRUE; + + foreach ($storage['more_required'] as $info) { + $t_argument = array( + '@module' => $info['name'], + '@required' => implode(', ', $info['requires']), + ); + $items[] = format_plural(count($info['requires']), 'You must enable the @required module to install @module.', 'You must enable the @required modules to install @module.', $t_argument); + } + + foreach ($storage['missing_modules'] as $name => $info) { + $t_argument = array( + '@module' => $name, + '@depends' => implode(', ', $info['depends']), + ); + $items[] = format_plural(count($info['depends']), 'The @module module is missing, so the following module will be disabled: @depends.', 'The @module module is missing, so the following modules will be disabled: @depends.', $t_argument); + } + + $form['text'] = array('#theme' => 'item_list', '#items' => $items); + + return parent::buildForm($form, $form_state); + } + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + */ + public function submitForm(array &$form, array &$form_state) { + } + +} diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmFrom.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmFrom.php new file mode 100644 index 0000000..0b75edb --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmFrom.php @@ -0,0 +1,80 @@ + $value) { + $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info.yml'); + $uninstall[] = $info['name']; + $form['uninstall'][$module] = array('#type' => 'hidden', + '#value' => 1, + ); + } + + $form['#confirmed'] = TRUE; + $form['uninstall']['#tree'] = TRUE; + $form['modules'] = array('#markup' => '

' . t('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') . '

'); + $form['module_list'] = array('#theme' => 'item_list', '#items' => $uninstall); + + return parent::buildForm($form, $form_state); + } + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + */ + public function submitForm(array &$form, array &$form_state) { + } + +} diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index a5d6984..f031d52 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -9,6 +9,8 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\system\Form\ModulesInstallConfirmFrom; +use Drupal\system\Form\ModulesUninstallConfirmFrom; /** * Menu callback; Provide the administration overview page. @@ -815,7 +817,8 @@ function system_modules($form, $form_state = array()) { // filled, triggering a rebuild. In this case we need to display a // confirmation form. if (!empty($form_state['storage'])) { - return system_modules_confirm_form($visible_files, $form_state['storage']); + $confirm_form = new ModulesInstallConfirmFrom(); + return $confirm_form->buildForm($form, $form_state, $visible_files, $form_state['storage']); } // JS-only table filters. @@ -1071,53 +1074,6 @@ function _system_modules_build_row($info, $extra) { } /** - * Display confirmation form for required modules. - * - * @param $modules - * Array of module file objects as returned from system_rebuild_module_data(). - * @param $storage - * The contents of $form_state['storage']; an array with two - * elements: the list of required modules and the list of status - * form field values from the previous screen. - * @ingroup forms - */ -function system_modules_confirm_form($modules, $storage) { - $items = array(); - - $form['validation_modules'] = array('#type' => 'value', '#value' => $modules); - $form['status']['#tree'] = TRUE; - - foreach ($storage['more_required'] as $info) { - $t_argument = array( - '@module' => $info['name'], - '@required' => implode(', ', $info['requires']), - ); - $items[] = format_plural(count($info['requires']), 'You must enable the @required module to install @module.', 'You must enable the @required modules to install @module.', $t_argument); - } - - foreach ($storage['missing_modules'] as $name => $info) { - $t_argument = array( - '@module' => $name, - '@depends' => implode(', ', $info['depends']), - ); - $items[] = format_plural(count($info['depends']), 'The @module module is missing, so the following module will be disabled: @depends.', 'The @module module is missing, so the following modules will be disabled: @depends.', $t_argument); - } - - $form['text'] = array('#markup' => theme('item_list', array('items' => $items))); - - // Set some default form values - $form = confirm_form( - $form, - t('Some required modules must be enabled'), - 'admin/modules', - t('Would you like to continue with the above?'), - t('Continue'), - t('Cancel')); - - return $form; -} - -/** * Submit callback; handles modules form submission. */ function system_modules_submit($form, &$form_state) { @@ -1273,8 +1229,9 @@ function system_modules_uninstall($form, $form_state = NULL) { include_once DRUPAL_ROOT . '/core/includes/install.inc'; // Display the confirm form if any modules have been submitted. - if (!empty($form_state['storage']) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) { - return $confirm_form; + if (!empty($form_state['storage']['uninstall']) && $modules = array_filter($form_state['storage']['uninstall'])) { + $confirm_form = new ModulesUninstallConfirmFrom(); + return $confirm_form->buildForm($form, $form_state, $modules); } // Get a list of disabled, installed modules. @@ -1328,46 +1285,6 @@ function system_modules_uninstall($form, $form_state = NULL) { } /** - * Confirm uninstall of selected modules. - * - * @ingroup forms - * @param $storage - * An associative array of modules selected to be uninstalled. - * @return - * A form array representing modules to confirm. - */ -function system_modules_uninstall_confirm_form($storage) { - // Nothing to build. - if (empty($storage)) { - return; - } - - // Construct the hidden form elements and list items. - foreach (array_filter($storage['uninstall']) as $module => $value) { - $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info.yml'); - $uninstall[] = $info['name']; - $form['uninstall'][$module] = array('#type' => 'hidden', - '#value' => 1, - ); - } - - // Display a confirm form if modules have been selected. - if (isset($uninstall)) { - $form['#confirmed'] = TRUE; - $form['uninstall']['#tree'] = TRUE; - $form['modules'] = array('#markup' => '

' . t('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') . '

' . theme('item_list', array('items' => $uninstall))); - $form = confirm_form( - $form, - t('Confirm uninstall'), - 'admin/modules/uninstall', - t('Would you like to continue with uninstalling the above?'), - t('Uninstall'), - t('Cancel')); - return $form; - } -} - -/** * Validates the submitted uninstall form. */ function system_modules_uninstall_validate($form, &$form_state) {