View source
<?php
abstract class OpenlayersObjects extends ctools_export_ui {
public function edit_form_submit(&$form, &$form_state) {
parent::edit_form_submit($form, $form_state);
if (isset($form_state['values']['attachToMap'])) {
$form_state['item']->attachToMap = $form_state['values']['attachToMap'];
}
if (isset($form_state['values']['attachToLayer'])) {
$form_state['item']->attachToLayer = $form_state['values']['attachToLayer'];
}
}
public function list_form(&$form, &$form_state) {
parent::list_form($form, $form_state);
$form['top row'] += $form['bottom row'];
$form['filters'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Filters'),
);
$form['filters']['top row'] = $form['top row'];
unset($form['bottom row']);
unset($form['top row']);
}
public function list_table_header() {
$header = array();
if (!empty($this->plugin['export']['admin_title'])) {
$header[] = array(
'data' => t('Name'),
'class' => array(
'ctools-export-ui-title',
),
);
}
$header[] = array(
'data' => t('Machine name'),
'class' => array(
'ctools-export-ui-name',
),
);
$header[] = array(
'data' => t('Service'),
'class' => array(
'ctools-export-ui-service',
),
);
$header[] = array(
'data' => t('Storage'),
'class' => array(
'ctools-export-ui-storage',
),
);
$header[] = array(
'data' => t('Operations'),
'class' => array(
'ctools-export-ui-operations',
),
);
return $header;
}
public function list_build_row($item, &$form_state, $operations) {
$name = $item->{$this->plugin['export']['key']};
$schema = ctools_export_get_schema($this->plugin['schema']);
list($plugin_manager, $plugin_id) = explode(':', $item->factory_service);
list($module, $plugin_type) = explode('.', $plugin_manager);
switch ($form_state['values']['order']) {
case 'disabled':
$this->sorts[$name] = empty($item->disabled) . $name;
break;
case 'title':
$this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
break;
case 'name':
$this->sorts[$name] = $name;
break;
case 'class':
$this->sorts[$name] = $name;
break;
case 'storage':
$this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
break;
}
switch ($item->type) {
case t('Default'):
default:
$type = t('In code');
break;
case t('Normal'):
$type = t('In database');
break;
case t('Overridden'):
$type = t('Database overriding code');
}
$this->rows[$name]['data'] = array();
$this->rows[$name]['class'] = !empty($item->disabled) ? array(
'ctools-export-ui-disabled',
) : array(
'ctools-export-ui-enabled',
);
if (!empty($this->plugin['export']['admin_title'])) {
$this->rows[$name]['data'][] = array(
'data' => check_plain($item->{$this->plugin['export']['admin_title']}),
'class' => array(
'ctools-export-ui-title',
),
);
}
$this->rows[$name]['data'][] = array(
'data' => check_plain($name),
'class' => array(
'ctools-export-ui-name',
),
);
$this->rows[$name]['data'][] = array(
'data' => check_plain($item->factory_service),
'class' => array(
'ctools-export-ui-service',
),
);
$this->rows[$name]['data'][] = array(
'data' => $type,
'class' => array(
'ctools-export-ui-storage',
),
);
$ops = theme('links__ctools_dropbutton', array(
'links' => $operations,
'attributes' => array(
'class' => array(
'links',
'inline',
),
),
));
$this->rows[$name]['data'][] = array(
'data' => $ops,
'class' => array(
'ctools-export-ui-operations',
),
);
if (!empty($this->plugin['export']['admin_description'])) {
$this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
}
}
public function edit_execute_form(&$form_state) {
$output = parent::edit_execute_form($form_state);
if (!empty($form_state['executed'])) {
if ($form_state['clicked_button']['#name'] == 'saveandedit') {
$options = array();
if (!empty($_GET['destination'])) {
$options['query']['destination'] = $_GET['destination'];
unset($_GET['destination']);
}
$op = $form_state['op'];
$path = 'add' != $op ? current_path() : 'admin/structure/openlayers/' . $this->plugin['menu']['menu item'] . '/list/' . $form_state['item']->machine_name . '/edit/start';
$this->plugin['redirect'][$op] = array(
$path,
$options,
);
}
}
return $output;
}
}
function openlayers_objects_ui_form_wrapper($form, $form_state) {
if ($form_state['step'] != 'start') {
$form['buttons']['saveandedit'] = array(
'#name' => 'saveandedit',
'#type' => 'submit',
'#value' => t('Save & edit'),
'#wizard type' => 'finish',
'#weight' => 1,
);
$form['buttons']['cancel']['#weight'] = 20;
}
return $form;
}