'Test Format',
'page callback' => 'format_manager_test_page',
'page arguments' => array(3),
'access arguments' => array('administer filters'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
return $items;
}
/**
* Menu callback; display form for ordering filters for a format.
*/
function format_manager_test_page($format) {
drupal_set_title(t("Test Input Format: %format", array('%format' => $format->name)));
$output = _format_manager_list_format_filters($format->format);
$output .= drupal_get_form('format_manager_test_form', $format);
return $output;
}
function format_manager_test_form(&$form_state, $format = NULL) {
// drupal_set_message("Format: " . dpr($format, TRUE));
// $filters = filter_list_format($format->format);
$content = variable_get('format_manager_test_content', '');
$form['label'] = array('#type' => 'markup', '#value' => 'TEST CONTENT
');
$form['test_content'] = array('#type' => 'textarea', '#default_value' => $content);
$markup = check_markup($content, $format->format);
$form['label2'] = array('#type' => 'markup', '#value' => 'FILTERED CONTENT
');
$form['markup'] = array('#type' => 'textarea', '#default_value' => $markup);
$form['html'] = array('#type' => 'markup', '#value' => 'RENDERED CONTENT
'. $markup);
$form['label3'] = array('#type' => 'markup', '#value' => '
');
$form['submit'] = array('#type' => 'submit', '#value' => t('Test Format'));
return $form;
}
function format_manager_test_form_submit(&$form, $form_state) {
variable_set('format_manager_test_content', $form_state['values']['test_content']);
}
/**
* Implementation of hook_form_alter() for form filter_admin_overview.
*/
function format_manager_form_filter_admin_overview_alter(&$form, $form_state) {
foreach ($form as $title => $element) {
if (is_array($element['id'])) {
$id = $element['id']['#value'];
$options = array('query' => array('destination' => 'admin/settings/filters'));
$form[$title]['edit format'] = array('#value' => l('edit format', "admin/settings/filters/$id", $options));
$form[$title]['edit filters'] = array('#value' => l('edit filters', "admin/settings/filters/$id/configure", $options));
$form[$title]['reorder filters'] = array('#value' => l('reorder filters', "admin/settings/filters/$id/order", $options));
$form[$title]['test'] = array('#value' => l('test', "admin/settings/filters/$id/test"));
$form[$title]['filters'] = array('#value' => _format_manager_list_format_filters($id));
}
}
$form['#theme'] = 'format_manager_admin_overview';
}
function _format_manager_list_format_filters($fid) {
$filters = filter_list_format($fid);
$list = array();
foreach ($filters as $key => $filter) {
$list[] = $filter->name;
}
return implode(', ', $list);
}
/**
* Implementation of hook_popups().
*/
function format_manager_popups() {
return array(
'admin/settings/filters' => array(
'a[href*=admin/settings/filters/]' => array(
'additionalJavascript' => array('misc/tabledrag.js', 'misc/collapse.js'),
),
),
);
}
/**
* Implementation of hook_theme().
*/
function format_manager_theme() {
return array(
'format_manager_admin_overview' => array(
'arguments' => array('form' => NULL),
),
);
}
/**
* Theme the admin overview form.
*
* @ingroup themeable
*/
function theme_format_manager_admin_overview($form) {
$rows = array();
foreach ($form as $name => $element) {
if (isset($element['roles']) && is_array($element['roles'])) {
$rows[] = array(
drupal_render($form['default'][$element['id']['#value']]),
array('data' => check_plain($name), 'header' => TRUE),
drupal_render($element['roles']),
drupal_render($element['filters']),
drupal_render($element['edit format']),
drupal_render($element['edit filters']),
drupal_render($element['reorder filters']),
drupal_render($element['test']),
drupal_render($element['delete']),
);
unset($form[$name]);
}
}
$header = array(t('Default'), t('Name'), t('Roles'), t('Filters'), array('data' => t('Operations'), 'colspan' => 4));
$output = theme('table', $header, $rows);
$output .= drupal_render($form);
return $output;
}