tweak.module 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @file
  4. * Drupal Tweaking library
  5. *
  6. * @copyright Copyright 2011 Ouest Systèmes Informatiques SARL
  7. *
  8. * Licensed under the General Public License version 2 or later.
  9. */
  10. /**
  11. * Implements hook_form_system_modules_alter().
  12. *
  13. * Add the D7 "help/permissions/configure" options to the module listing page.
  14. */
  15. function tweak_form_system_modules_alter(&$form, &$form_state) {
  16. if (!isset($form['#theme']) || $form['#theme'] != 'confirm_form') {
  17. $actions = array(
  18. 'help' => t('Help'),
  19. 'permissions' => t('Permissions'),
  20. 'configure' => t('Configure'),
  21. );
  22. foreach ($form['validation_modules']['#value'] as $name => $module) {
  23. $info = $module->info;
  24. $description = isset($info['description'])
  25. ? $info['description']
  26. : '';
  27. $links = array();
  28. foreach ($actions as $action_name => $action_title) {
  29. if (!empty($info[$action_name])) {
  30. $offset = strpos($info[$action_name], '#');
  31. if ($offset === FALSE) {
  32. $options = array();
  33. $path = $info[$action_name];
  34. }
  35. else {
  36. $options = array(
  37. 'fragment' => drupal_substr($info[$action_name], $offset + 1), // +1 to skip #
  38. );
  39. $path = drupal_substr($info[$action_name], 0, $offset);
  40. }
  41. $class = "about-module about-module-$action_name";
  42. $options += array(
  43. 'attributes' => array('class' => $class),
  44. );
  45. $links[$action_name] = l($action_title, $path, $options);
  46. }
  47. }
  48. if (!empty($links)) {
  49. $form['description'][$name]['#value'] .= '<br />' . implode('', $links);
  50. }
  51. }
  52. }
  53. }
  54. /**
  55. * Implements hook_init().
  56. *
  57. * Add module CSS.
  58. */
  59. function tweak_init() {
  60. drupal_add_css(drupal_get_path('module', 'tweak') . '/theme/tweak.css');
  61. }