summaryrefslogtreecommitdiffstats
path: root/disqus_migrate.module
blob: 3b626d3f5266d944e78fd6fa64db0ecedebda64c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

/**
 * @file
 * Add functionality to export comments as XML
 */

/**
 * Implements hook_help().
 */
function disqus_migrate_help($path, $arg) {
  switch ($path) {
    case 'admin/config/services/disqus/export':
      return '<p>' . t(
        'When you are ready to perform an export, visit !thispage.',
        array(
          '!thispage' => l(t('this page'), 'admin/content/comment/disqus_export'),
        )
      ) . '</p>';
    case 'admin/content/comment/disqus_export':
      return '<p>' . t(
        'Exporting via XML will just gather all of your websites comments and format them for importing manually into Disqus.',
        array(
          '!exportsettings' => l(t('export settings'), 'admin/settings/disqus/export'),
          '!mainsettings' => l(t('main settings'), 'admin/settings/disqus'),
        )
      ) . '</p>';
  }
}

/**
 * Implements hook_menu().
 */
function disqus_migrate_menu() {
  $items = array();
  $items['admin/config/services/disqus/export'] = array(
    'title' => 'Export',
    'description' => 'Settings for exporting comments from Drupal into Disqus',
    'access arguments' => array('administer disqus'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('disqus_migrate_admin_export_settings'),
    'file' => 'include/disqus_migrate.export.inc',
    'type' => MENU_LOCAL_TASK,
  );

  $items['admin/content/comment/disqus_export'] = array(
    'title' => 'Disqus Export',
    'description' => 'Export comments from the Drupal to Disqus.',
    'access arguments' => array('administer disqus'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('disqus_migrate_admin_export'),
    'file' => 'include/disqus_migrate.export.inc',
    'type' => MENU_LOCAL_TASK,
  );
  return $items;

}

/**
 * Implements hook_form_disqus_admin_settings_alter().
 */
function disqus_migrate_form_disqus_admin_settings_alter(&$form, &$form_state, $form_id) {
  $form['migrate'] = array(
    '#type' => 'fieldset',
    '#title' => t('Migrate'),
    '#group' => 'settings',
  );

  $form['migrate']['disqus_migrate_base_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Overide base URL'),
    '#default_value' => variable_get('disqus_migrate_base_url'),
    '#description' => t('Overide the base URL. Usefull if generating XML file for a different domain from current (http://%s). Use the full base url eg. http://www.somesite.co.uk', array('%s' => $_SERVER['HTTP_HOST'])),
  );
}