tweak.module 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }
  62. function tweak_views_api() {
  63. $ret = array(
  64. 'api' => 2,
  65. 'path' => drupal_get_path('module', 'tweak') . '/views',
  66. );
  67. return $ret;
  68. }