Skip to content
disqus_migrate.module 2.41 KiB
Newer Older
David Kitchen's avatar
David Kitchen committed
<?php

/**
David Kitchen's avatar
David Kitchen committed
 * @file
 * Add functionality to export comments as XML
 */

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

/**
David Kitchen's avatar
David Kitchen committed
 * Implements hook_menu().
David Kitchen's avatar
David Kitchen committed
 */
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,
  );
David Kitchen's avatar
David Kitchen committed

David Kitchen's avatar
David Kitchen committed
  $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;

}

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

David Kitchen's avatar
David Kitchen committed
  $form['migrate']['disqus_migrate_base_url'] = array(
David Kitchen's avatar
David Kitchen committed
    '#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'])),
David Kitchen's avatar
David Kitchen committed
  );
}