feeds_ui.module 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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/import'] = array(
  37. 'title' => 'Import importer',
  38. 'page callback' => 'drupal_get_form',
  39. 'page arguments' => array('feeds_ui_importer_import'),
  40. 'access callback' => 'feeds_importer_import_access',
  41. 'file' => 'feeds_ui.admin.inc',
  42. 'type' => MENU_LOCAL_ACTION,
  43. );
  44. $items['admin/structure/feeds/%feeds_importer'] = array(
  45. 'title callback' => 'feeds_ui_importer_title',
  46. 'title arguments' => array(3),
  47. 'page callback' => 'feeds_ui_edit_page',
  48. 'page arguments' => array(3),
  49. 'access arguments' => array('administer feeds'),
  50. 'file' => 'feeds_ui.admin.inc',
  51. );
  52. $items['admin/structure/feeds/%feeds_importer/edit'] = array(
  53. 'title' => 'Edit',
  54. 'page callback' => 'feeds_ui_edit_page',
  55. 'page arguments' => array(3),
  56. 'access arguments' => array('administer feeds'),
  57. 'file' => 'feeds_ui.admin.inc',
  58. 'type' => MENU_DEFAULT_LOCAL_TASK,
  59. 'weight' => 1,
  60. );
  61. $items['admin/structure/feeds/%feeds_importer/export'] = array(
  62. 'title' => 'Export',
  63. 'page callback' => 'drupal_get_form',
  64. 'page arguments' => array('feeds_ui_export_form', 3),
  65. 'access arguments' => array('administer feeds'),
  66. 'file' => 'feeds_ui.admin.inc',
  67. 'type' => MENU_LOCAL_TASK,
  68. 'weight' => 2,
  69. );
  70. $items['admin/structure/feeds/%feeds_importer/clone'] = array(
  71. 'title' => 'Clone',
  72. 'page callback' => 'drupal_get_form',
  73. 'page arguments' => array('feeds_ui_create_form', 3),
  74. 'access arguments' => array('administer feeds'),
  75. 'file' => 'feeds_ui.admin.inc',
  76. 'type' => MENU_LOCAL_TASK,
  77. 'weight' => 3,
  78. );
  79. $items['admin/structure/feeds/%feeds_importer/delete'] = array(
  80. 'title' => 'Delete',
  81. 'page callback' => 'drupal_get_form',
  82. 'page arguments' => array('feeds_ui_delete_form', 3),
  83. 'access arguments' => array('administer feeds'),
  84. 'file' => 'feeds_ui.admin.inc',
  85. 'type' => MENU_LOCAL_TASK,
  86. 'weight' => 4,
  87. );
  88. return $items;
  89. }
  90. /**
  91. * Implements hook_theme().
  92. */
  93. function feeds_ui_theme() {
  94. return array(
  95. 'feeds_ui_overview_form' => array(
  96. 'render element' => 'form',
  97. 'file' => 'feeds_ui.admin.inc',
  98. ),
  99. 'feeds_ui_mapping_form' => array(
  100. 'render element' => 'form',
  101. 'file' => 'feeds_ui.admin.inc',
  102. ),
  103. 'feeds_ui_edit_page' => array(
  104. 'variables' => array('info' => NULL, 'active' => NULL),
  105. 'file' => 'feeds_ui.admin.inc',
  106. ),
  107. 'feeds_ui_plugin_form' => array(
  108. 'render element' => 'form',
  109. 'file' => 'feeds_ui.admin.inc',
  110. ),
  111. 'feeds_ui_container' => array(
  112. 'variables' => array('container' => NULL),
  113. 'file' => 'feeds_ui.admin.inc',
  114. ),
  115. );
  116. }
  117. /**
  118. * Implements hook_admin_menu_map().
  119. */
  120. function feeds_ui_admin_menu_map() {
  121. // Add awareness to the administration menu of the various importers so they
  122. // are included in the dropdown menu.
  123. if (!user_access('administer feeds')) {
  124. return;
  125. }
  126. $map['admin/structure/feeds/%feeds_importer'] = array(
  127. 'parent' => 'admin/structure/feeds',
  128. 'arguments' => array(
  129. array('%feeds_importer' => feeds_enabled_importers()),
  130. ),
  131. );
  132. return $map;
  133. }
  134. /**
  135. * Title callback for importers.
  136. */
  137. function feeds_ui_importer_title($importer) {
  138. return t('@importer', array('@importer' => $importer->config['name']));
  139. }