module_filter.pages.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @file
  4. */
  5. /**
  6. * Wrapper function for update_status().
  7. *
  8. * @see update_status().
  9. */
  10. function module_filter_update_status() {
  11. module_load_include('inc', 'update', 'update.report');
  12. $update_report = update_status();
  13. return array(
  14. 'module_filter' => drupal_get_form('module_filter_update_status_form'),
  15. 'update_report' => array(
  16. '#markup' => $update_report,
  17. ),
  18. );
  19. }
  20. /**
  21. * Form builder for the module filter form.
  22. */
  23. function module_filter_update_status_form($form, &$form_state) {
  24. $form['module_filter'] = array(
  25. '#type' => 'module_filter',
  26. '#attached' => array(
  27. 'css' => array(
  28. drupal_get_path('module', 'module_filter') . '/css/update_status.css',
  29. ),
  30. 'js' => array(
  31. drupal_get_path('module', 'module_filter') . '/js/update_status.js',
  32. ),
  33. ),
  34. );
  35. $form['module_filter']['show'] = array(
  36. '#type' => 'radios',
  37. '#default_value' => (isset($_GET['show']) && in_array($_GET['show'], array('all', 'updates', 'security', 'unknown'))) ? $_GET['show'] : 'all',
  38. '#options' => array('all' => t('All'), 'updates' => t('Update available'), 'security' => t('Security update'), 'unknown' => t('Unknown')),
  39. '#prefix' => '<div id="module-filter-show-wrapper">',
  40. '#suffix' => '</div>',
  41. );
  42. if (module_exists('update_advanced')) {
  43. $options = $form['module_filter']['show']['#options'];
  44. $form['module_filter']['show']['#options'] = array_slice($options, 0, 2);
  45. $form['module_filter']['show']['#options']['ignore'] = t('Ignored from settings');
  46. $form['module_filter']['show']['#options'] = array_merge($form['module_filter']['show']['#options'], array_slice($options, 2));
  47. }
  48. return $form;
  49. }