pasteformat.module in Paste Format (filter, clean-up pasted text) 7
Same filename and directory in other branches
Main file for Paste Format module.
File
pasteformat.moduleView source
<?php
/**
* @file
* Main file for Paste Format module.
*/
/**
* Implements hook_permission().
*/
function pasteformat_permission() {
return array(
'use pasteformat' => array(
'title' => t('Use Paste Format'),
'description' => t('Protects Paste Format AJAX callback that filters the pasted content.'),
),
);
}
/**
* Implements hook_menu().
*/
function pasteformat_menu() {
$items = array(
'admin/config/content/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;
}
/**
* Menu callback to cleanup POSTed text.
*/
function pasteformat_cleanup() {
$output = array(
'text' => check_markup($_POST['html'], variable_get('pasteformat_cleanup_format', filter_fallback_format()), '', FALSE),
// 'text' => $_POST['html'],
'alert' => variable_get('pasteformat_message_success', '') ? variable_get('pasteformat_message_success', '') : '',
);
drupal_json_output($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,
),
);
}
}
Functions
Name![]() |
Description |
---|---|
pasteformat_ckeditor_plugin | Implements hook_ckeditor_plugin(). |
pasteformat_cleanup | Menu callback to cleanup POSTed text. |
pasteformat_menu | Implements hook_menu(). |
pasteformat_permission | Implements hook_permission(). |
pasteformat_wysiwyg_plugin | Implements hook_wysiwyg_plugin(). |