View source
<?php
finder_inc('common', 'finder_ui');
function finder_ui_item_page($finder, $item_key, $js) {
ctools_include('modal');
ctools_include('ajax');
ctools_include('object-cache');
finder_inc('finder', 'finder_ui');
$finder = ctools_object_cache_get('finder', $finder->name);
$finder_ui = finder_ui($finder);
$title = $finder_ui['items'][$item_key]['#item']['#title'];
$item = $finder_ui['items'][$item_key];
$form_state = array(
'title' => $title,
'ajax' => $js,
'finder' => $finder,
'item_key' => $item_key,
'item' => $item,
);
$output = ctools_modal_form_wrapper('finder_ui_item_form', $form_state);
if ($form_state['executed'] && $js) {
if ($form_state['triggering_element']['#parents'][1] == 'submit') {
$finder = ctools_object_cache_get('finder', $finder->name);
foreach ($form_state['values'] as $key => $value) {
if ($key != 'settings') {
$finder->{$key} = $value;
}
}
foreach ($form_state['values']['settings'] as $key => $value) {
$finder->settings[$key] = $value;
}
ctools_object_cache_set('finder', $finder->name, $finder);
$finder_ui = finder_ui($finder);
$item = $finder_ui['items'][$item_key];
$commands = array();
$output = finder_ui_item($finder, $item_key, $item);
$commands[] = ajax_command_html('#finder-ui-item-' . $item_key, $output);
$commands[] = ajax_command_css('#edit-changed', array(
'display' => 'block',
));
}
$commands[] = ctools_modal_command_dismiss();
print ajax_render($commands);
exit;
}
if ($js) {
print ajax_render($output);
exit;
}
return $output;
}
function finder_ui_item_form($form, &$form_state) {
ctools_include('dependent');
$form['#tree'] = TRUE;
$form = array_merge($form, $form_state['item']['#form']);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Apply'),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
);
$form['#pre_render'] = array(
'finder_ui_modal_form_pre_render',
);
return $form;
}
function finder_ui_item_form_submit($form, &$form_state) {
}
function finder_ui_item($finder, $item_key, $item) {
$output = $item['#item']['#title'] ? '<span class="label">' . $item['#item']['#title'] . ':</span>' : '';
$value = strip_tags($item['#item']['#value']);
if (!$item['#item']['#value']) {
$value = '<em>' . t('empty') . '</em>';
}
elseif (!trim($value)) {
$value = t('Yes');
}
$output .= finder_ui_modal_link($value, 'admin/structure/finder/list/' . $finder->name . '/item/' . $item_key . '/nojs', t('Edit'), 'ctools-modal-finder-modal-style');
if (!empty($item['#item']['#extra'])) {
$output .= '<span class="extra">' . $item['#item']['#extra'] . '</span>';
}
$getq = explode('/', $_GET['q']);
if (end($getq) == 'ajax' && !empty($item['#item']['#refresh'])) {
$output .= '<div class="finder-ui-needs-reload"></div>';
}
return $output;
}