View source
<?php
function popup_filter_menu() {
$path = drupal_get_path('module', 'popup_filter');
return array(
'ajax/popup-filter/getnode' => array(
'access arguments' => array(
'administer popup elements',
),
'file' => 'popup_filter.admin.inc',
'file path' => $path . '/includes',
'page callback' => 'popup_filter_ajax_getnode',
'page arguments' => array(
3,
),
'type' => MENU_CALLBACK,
),
'ajax/popup-filter/getdeltas' => array(
'access arguments' => array(
'administer popup elements',
),
'file' => 'popup_filter.admin.inc',
'file path' => $path . '/includes',
'page callback' => 'popup_filter_ajax_getdeltas',
'type' => MENU_CALLBACK,
),
'ajax/popup-filter/getdisplays' => array(
'access arguments' => array(
'administer popup elements',
),
'file' => 'popup_filter.admin.inc',
'file path' => $path . '/includes',
'page callback' => 'popup_filter_ajax_getdisplays',
'type' => MENU_CALLBACK,
),
);
}
function popup_filter_filter_info() {
$filters['popup_tags'] = array(
'title' => t('Popup filter'),
'description' => t('Replaces [popup filter tags] with popup content. Administrator use only!'),
'process callback' => 'popup_filter_eval',
'cache' => FALSE,
);
return $filters;
}
function popup_filter_form_alter(&$form, &$form_state, $form_id) {
$block_form = in_array($form_id, array(
'block_add_block_form',
'block_admin_configure',
));
$node_form = preg_match('/node_form$/', $form_id);
if (user_access('administer popup elements') && ($block_form || $node_form)) {
module_load_include('inc', 'popup', 'includes/popup.api');
module_load_include('inc', 'popup_filter', 'includes/popup_filter.admin');
$attributes = array(
'activate' => 'click',
'class' => 'popup-filter-admin-form',
'close' => TRUE,
'effect' => 'slide-down-fade',
'expand' => 'bottom-left',
'origin' => 'bottom-right',
'width' => 650,
);
$popup_form = popup_filter_insert_form();
$popup_form = popup_element(t('Insert popup element'), $popup_form, $attributes);
if ($block_form) {
if (isset($form['settings']['body_field'])) {
$form['settings']['body_field']['#prefix'] = isset($form['settings']['body_field']['#prefix']) ? $form['settings']['body_field']['#prefix'] . $popup_form : $popup_form;
}
}
else {
if (isset($form['body'])) {
$form['body']['#prefix'] = isset($form['body']['#prefix']) ? $form['body']['#prefix'] . $popup_form : $popup_form;
}
}
}
}
function popup_filter_eval($text) {
module_load_include('inc', 'popup_filter', 'includes/popup_filter.processing');
return popup_filter_process_text($text);
}