feeds_ui.module 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * @file
  4. */
  5. /**
  6. * Implements hook_help().
  7. */
  8. function feeds_ui_help($path, $arg) {
  9. switch ($path) {
  10. case 'admin/structure/feeds':
  11. $output = '<p>' . t('Create one or more Feed importers for pulling content into Drupal. You can use these importers from the <a href="@import">Import</a> page or - if you attach them to a content type - simply by creating a node from that content type.', array('@import' => url('import'))) . '</p>';
  12. return $output;
  13. }
  14. }
  15. /**
  16. * Implements hook_menu().
  17. */
  18. function feeds_ui_menu() {
  19. $items = array();
  20. $items['admin/structure/feeds'] = array(
  21. 'title' => 'Feeds importers',
  22. 'description' => 'Configure one or more Feeds importers to aggregate RSS and Atom feeds, import CSV files or more.',
  23. 'page callback' => 'drupal_get_form',
  24. 'page arguments' => array('feeds_ui_overview_form'),
  25. 'access arguments' => array('administer feeds'),
  26. 'file' => 'feeds_ui.admin.inc',
  27. );
  28. $items['admin/structure/feeds/create'] = array(
  29. 'title' => 'Add importer',
  30. 'page callback' => 'drupal_get_form',
  31. 'page arguments' => array('feeds_ui_create_form'),
  32. 'access arguments' => array('administer feeds'),
  33. 'file' => 'feeds_ui.admin.inc',
  34. 'type' => MENU_LOCAL_ACTION,
  35. );
  36. $items['admin/structure/feeds/%feeds_importer'] = array(
  37. 'title callback' => 'feeds_ui_importer_title',
  38. 'title arguments' => array(3),
  39. 'page callback' => 'feeds_ui_edit_page',
  40. 'page arguments' => array(3),
  41. 'access arguments' => array('administer feeds'),
  42. 'file' => 'feeds_ui.admin.inc',
  43. );
  44. $items['admin/structure/feeds/%feeds_importer/edit'] = array(
  45. 'title' => 'Edit',
  46. 'page callback' => 'feeds_ui_edit_page',
  47. 'page arguments' => array(3),
  48. 'access arguments' => array('administer feeds'),
  49. 'file' => 'feeds_ui.admin.inc',
  50. 'type' => MENU_DEFAULT_LOCAL_TASK,
  51. 'weight' => 1,
  52. );
  53. $items['admin/structure/feeds/%feeds_importer/export'] = array(
  54. 'title' => 'Export',
  55. 'page callback' => 'drupal_get_form',
  56. 'page arguments' => array('feeds_ui_export_form', 3),
  57. 'access arguments' => array('administer feeds'),
  58. 'file' => 'feeds_ui.admin.inc',
  59. 'type' => MENU_LOCAL_TASK,
  60. 'weight' => 2,
  61. );
  62. $items['admin/structure/feeds/%feeds_importer/clone'] = array(
  63. 'title' => 'Clone',
  64. 'page callback' => 'drupal_get_form',
  65. 'page arguments' => array('feeds_ui_create_form', 3),
  66. 'access arguments' => array('administer feeds'),
  67. 'file' => 'feeds_ui.admin.inc',
  68. 'type' => MENU_LOCAL_TASK,
  69. 'weight' => 3,
  70. );
  71. $items['admin/structure/feeds/%feeds_importer/delete'] = array(
  72. 'title' => 'Delete',
  73. 'page callback' => 'drupal_get_form',
  74. 'page arguments' => array('feeds_ui_delete_form', 3),
  75. 'access arguments' => array('administer feeds'),
  76. 'file' => 'feeds_ui.admin.inc',
  77. 'type' => MENU_LOCAL_TASK,
  78. 'weight' => 4,
  79. );
  80. return $items;
  81. }
  82. /**
  83. * Implements hook_theme().
  84. */
  85. function feeds_ui_theme() {
  86. return array(
  87. 'feeds_ui_overview_form' => array(
  88. 'render element' => 'form',
  89. 'file' => 'feeds_ui.admin.inc',
  90. ),
  91. 'feeds_ui_mapping_form' => array(
  92. 'render element' => 'form',
  93. 'file' => 'feeds_ui.admin.inc',
  94. ),
  95. 'feeds_ui_edit_page' => array(
  96. 'variables' => array('info' => NULL, 'active' => NULL),
  97. 'file' => 'feeds_ui.admin.inc',
  98. ),
  99. 'feeds_ui_plugin_form' => array(
  100. 'render element' => 'form',
  101. 'file' => 'feeds_ui.admin.inc',
  102. ),
  103. 'feeds_ui_container' => array(
  104. 'variables' => array('container' => NULL),
  105. 'file' => 'feeds_ui.admin.inc',
  106. ),
  107. );
  108. }
  109. /**
  110. * Implements hook_admin_menu_map().
  111. */
  112. function feeds_ui_admin_menu_map() {
  113. // Add awareness to the administration menu of the various importers so they
  114. // are included in the dropdown menu.
  115. if (!user_access('administer feeds')) {
  116. return;
  117. }
  118. $map['admin/structure/feeds/%feeds_importer'] = array(
  119. 'parent' => 'admin/structure/feeds',
  120. 'arguments' => array(
  121. array('%feeds_importer' => feeds_enabled_importers()),
  122. ),
  123. );
  124. return $map;
  125. }
  126. /**
  127. * Title callback for importers.
  128. */
  129. function feeds_ui_importer_title($importer) {
  130. return t('@importer', array('@importer' => $importer->config['name']));
  131. }