You are here

openlayers_presets_ui.module in Openlayers 6

Main OpenLayers Preset UI Hook Implemntations

This file holds the main Drupal hook functions, for the OpenLayers Preset UI module.

File

modules/openlayers_presets_ui/openlayers_presets_ui.module
View source
<?php

/**
 * @file
 * Main OpenLayers Preset UI Hook Implemntations
 *
 * This file holds the main Drupal hook functions,
 * for the OpenLayers Preset UI module.
 *
 * @ingroup openlayers
 */

/**
 * Implementation of hook_help().
 */
function openlayers_presets_ui_help($path, $arg) {
  $output = '';
  switch ($path) {
    case 'admin/help#openlayers_presets_ui':
      $output = '<p>' . t('The OpenLayers Preset UI module provides a User Interface to create map presets.') . '</p>';
      return $output;
  }
}

/**
 * Implementation of hook_theme().
 */
function openlayers_presets_ui_theme($existing, $type, $theme, $path) {
  return array(
    'openlayers_presets_ui_form_layer_description' => array(
      'arguments' => array(
        'layer_title' => '',
        'layer_description' => '',
      ),
      'file' => 'includes/openlayers_presets_ui.theme.inc',
    ),
    'openlayers_presets_ui_form_projection_description' => array(
      'arguments' => array(
        'projection_title' => '',
        'available_layers' => array(),
        'layers' => array(),
      ),
      'file' => 'includes/openlayers_presets_ui.theme.inc',
    ),
  );
}

/**
 * Implementation of hook_menu().
 */
function openlayers_presets_ui_menu() {
  $items = array();
  $items['admin/settings/openlayers/presets'] = array(
    'title' => 'Presets',
    'description' => 'Create OpenLayers map presets.',
    'page callback' => 'openlayers_presets_ui_presets_manage_list',
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_presets_ui.ui.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/settings/openlayers/presets/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );
  $items['admin/settings/openlayers/presets/add'] = array(
    'title' => 'Add',
    'description' => 'Add OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_presets_ui_presets_manage_add',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_presets_ui.ui.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/settings/openlayers/presets/add/%openlayers_presets_ui_preset_name'] = array(
    'title' => 'Clone Preset',
    'description' => 'Add OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_presets_ui_presets_manage_add',
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_presets_ui.ui.inc',
    'type' => MENU_NORMAL_ITEM,
    'weight' => -10,
  );
  $items['admin/settings/openlayers/presets/%openlayers_presets_ui_preset_name/%openlayers_presets_ui_preset_action'] = array(
    'title' => 'Manage Preset',
    'description' => 'Manage OpenLayers map preset.',
    'page callback' => 'openlayers_presets_ui_presets_manage',
    'page arguments' => array(
      4,
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_presets_ui.ui.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/settings/openlayers/presets/import'] = array(
    'title' => 'Import',
    'description' => 'Import OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_presets_ui_presets_import',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_presets_ui.ui.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 0,
  );
  $items['openlayers/ahah/preset'] = array(
    'title' => 'OpenLayers AHAH',
    'page callback' => 'openlayers_presets_ui_preset_ahah',
    'access callback' => TRUE,
    'file' => 'includes/openlayers_presets_ui.ui.inc',
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Menu wildcard loader for preset id
 */
function openlayers_presets_ui_preset_name_load($preset_name = '') {

  // Attempt to get preset
  $preset = openlayers_get_preset($preset_name, TRUE);

  // Check Preset
  if (empty($preset)) {
    drupal_set_message(t('The specified preset was not found.'), 'error');
    drupal_goto('admin/settings/openlayers/presets');
  }
  return $preset;
}

/**
 * Menu wildcard loader for preset action
 */
function openlayers_presets_ui_preset_action_load($action = '') {
  $allowed_actions = array(
    'edit',
    'delete',
    'export',
  );

  // Check action
  if (in_array($action, $allowed_actions)) {
    return $action;
  }
  else {
    return FALSE;
  }
}

Related topics

Functions

Namesort descending Description
openlayers_presets_ui_help Implementation of hook_help().
openlayers_presets_ui_menu Implementation of hook_menu().
openlayers_presets_ui_preset_action_load Menu wildcard loader for preset action
openlayers_presets_ui_preset_name_load Menu wildcard loader for preset id
openlayers_presets_ui_theme Implementation of hook_theme().