You are here

function openlayers_ui_object_list in Openlayers 6.2

Menu callback for Layers.

1 string reference to 'openlayers_ui_object_list'
openlayers_ui_menu in modules/openlayers_ui/openlayers_ui.module
Implementation of hook_menu

File

modules/openlayers_ui/openlayers_ui.module, line 375

Code

function openlayers_ui_object_list($type) {
  $rows = array();
  switch ($type) {
    case 'styles':
      $objects = openlayers_styles(TRUE);
      break;
    case 'layers':
      $objects = openlayers_layers_load(TRUE);
      break;
    case 'presets':
      $objects = openlayers_presets(TRUE);
      break;
  }

  // Make table of presets and actions
  if ($type == 'layers') {
    $header = array(
      t('Title'),
      t('Type'),
      t('Description'),
      t('Actions'),
    );
    $layer_types = openlayers_layer_types();
  }
  elseif ($type == 'presets') {
    $header = array(
      t('Title'),
      t('Layers'),
      t('Description'),
      t('Actions'),
    );
    $layers = openlayers_layers_load();
  }
  else {
    $header = array(
      t('Title'),
      t('Description'),
      t('Actions'),
    );
  }

  // Create table rows
  foreach ($objects as $object) {
    $row = array();
    $links = array();
    switch ($object->export_type) {
      case EXPORT_IN_DATABASE | EXPORT_IN_CODE:
        $row[] = filter_xss_admin($object->title) . ' <em><small>(' . t('Overridden') . ')</small></em>';
        break;
      case EXPORT_IN_DATABASE:
        $row[] = filter_xss_admin($object->title) . ' <em><small>(' . t('Normal') . ')</small></em>';
        break;
      case EXPORT_IN_CODE:
        $row[] = filter_xss_admin($object->title) . ' <em><small>(' . t('Default') . ')</small></em>';
        break;
    }
    if ($type == 'layers') {
      $row[] = filter_xss_admin($layer_types[$object->data['layer_type']]['title']);
    }
    elseif ($type == 'presets') {
      if (!empty($object->data['layers'])) {
        $layer_names = array();
        foreach ($object->data['layers'] as $layer) {
          $layer_names[] = empty($layers[$layer]->title) ? $layer : filter_xss_admin($layers[$layer]->title);
        }
        $row[] = '<small>' . implode(', ', $layer_names) . '</small>';
      }
      else {
        $row[] = '';
      }
    }
    $row[] = filter_xss_admin($object->description);

    // Check preset type and create links accordingly.
    if ($object->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
      $links[] = l(t('Edit'), "admin/build/openlayers/{$type}/{$object->name}/edit");
      $links[] = l(t('Revert'), "admin/build/openlayers/{$type}/{$object->name}/delete");
    }
    elseif ($object->export_type == EXPORT_IN_DATABASE) {
      $links[] = l(t('Edit'), "admin/build/openlayers/{$type}/{$object->name}/edit");
      $links[] = l(t('Delete'), "admin/build/openlayers/{$type}/{$object->name}/delete");
    }
    $links[] = l(t('Export'), "admin/build/openlayers/{$type}/{$object->name}/export");
    $links[] = l(t('Clone'), "admin/build/openlayers/{$type}/clone/{$object->name}");
    $row[] = implode(' | ', $links);
    $rows[] = $row;
  }

  // Output themed table
  $output = theme('table', $header, $rows);
  return $output;
}