You are here

pasteformat.module in Paste Format (filter, clean-up pasted text) 6

Same filename and directory in other branches
  1. 7 pasteformat.module

File

pasteformat.module
View source
<?php

/**
 * Implements hook_perm().
 */
function pasteformat_perm() {
  return array(
    'use pasteformat',
  );
}

/**
 * Implements hook_menu().
 */
function pasteformat_menu() {
  $items = array(
    'admin/settings/pasteformat' => array(
      'title' => 'Paste Format',
      'description' => 'Configure Paste Format settings.',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'pasteformat_settings_form',
      ),
      'access callback' => 'user_access',
      'access arguments' => array(
        'administer site configuration',
      ),
      'file' => 'pasteformat.admin.inc',
      'type' => MENU_NORMAL_ITEM,
    ),
    'pasteformat/ajax/pasteformat_cleanup' => array(
      'page callback' => 'pasteformat_cleanup',
      'access callback' => 'user_access',
      'access arguments' => array(
        'use pasteformat',
      ),
      'type' => MENU_CALLBACK,
    ),
  );
  return $items;
}
function pasteformat_cleanup() {
  $output = array(
    'text' => check_markup($_POST['html'], variable_get('pasteformat_cleanup_format', FILTER_FORMAT_DEFAULT), FALSE),
    //'text' => $_POST['html'],
    'alert' => variable_get('pasteformat_message_success', '') ? variable_get('pasteformat_message_success', '') : '',
  );
  drupal_json($output);
  exit;
}

/**
 * Implements hook_ckeditor_plugin().
 */
function pasteformat_ckeditor_plugin() {
  return array(
    'pasteformat' => array(
      'name' => 'pasteformat',
      'desc' => t('Paste Format: Plugin to cleanup pasted text'),
      'path' => drupal_get_path('module', 'pasteformat') . '/plugins/pasteformat/',
    ),
  );
}

/**
 * Implements hook_wysiwyg_plugin().
 */
function pasteformat_wysiwyg_plugin($editor, $version) {
  if ($editor == 'ckeditor') {
    return array(
      'pasteformat' => array(
        'url' => 'http://drupal.org/project/pasteformat',
        'path' => drupal_get_path('module', 'pasteformat') . '/plugins/pasteformat/',
        'file' => 'plugin.js',
        'extensions' => array(
          'pasteformat' => t('Paste Format'),
        ),
        'load' => TRUE,
      ),
    );
  }
}