mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
96 lines
2.4 KiB
Text
96 lines
2.4 KiB
Text
<?php
|
|
/**
|
|
* @file
|
|
* Code for the Farm MapKnitter module.
|
|
*/
|
|
|
|
/**
|
|
* Implements hook_permission().
|
|
*/
|
|
function farm_mapknitter_permission() {
|
|
$perms = array(
|
|
'administer farm_mapknitter module' => array(
|
|
'title' => t('Administer farm MapKnitter module'),
|
|
),
|
|
);
|
|
return $perms;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_access_perms().
|
|
*/
|
|
function farm_mapknitter_farm_access_perms($role) {
|
|
$perms = array();
|
|
|
|
// Grant administer permission to Farm Managers.
|
|
if ($role == 'Farm Manager') {
|
|
$perms[] = 'administer farm_mapknitter module';
|
|
}
|
|
|
|
return $perms;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_menu().
|
|
*/
|
|
function farm_mapknitter_menu() {
|
|
$items = array();
|
|
|
|
$items['admin/config/farm/mapknitter'] = array(
|
|
'title' => 'MapKnitter',
|
|
'description' => 'Include a MapKnitter layer in your farm maps.',
|
|
'page callback' => 'drupal_get_form',
|
|
'page arguments' => array('farm_mapknitter_form'),
|
|
'access arguments' => array('administer farm_mapknitter module'),
|
|
);
|
|
|
|
return $items;
|
|
}
|
|
|
|
/**
|
|
* MapKnitter configuration form.
|
|
*/
|
|
function farm_mapknitter_form($form, &$form_state) {
|
|
|
|
// MapKnitter layer title.
|
|
$form['farm_mapknitter_title'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('MapKnitter layer title'),
|
|
'#description' => t('Give your MapKnitter layer a name. This will be used in the layer switcher '),
|
|
'#default_value' => variable_get('farm_mapknitter_title', ''),
|
|
);
|
|
|
|
// MapKnitter slug.
|
|
$form['farm_mapknitter_slug'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('MapKnitter Slug'),
|
|
'#description' => t('Enter the unique MapKnitter slug. This would be the [map-slug] part in your MapKnitter map URL: http://mapknitter.org/maps/[map-slug]'),
|
|
'#default_value' => variable_get('farm_mapknitter_slug', ''),
|
|
);
|
|
|
|
$form['#submit'][] = 'farm_mapknitter_form_submit';
|
|
|
|
return system_settings_form($form);
|
|
}
|
|
|
|
/**
|
|
* Farm MapKnitter form submit function.
|
|
*/
|
|
function farm_mapknitter_form_submit($form, &$form_state) {
|
|
drupal_flush_all_caches();
|
|
}
|
|
|
|
/**
|
|
* Implements hook_ctools_plugin_api().
|
|
*/
|
|
function farm_mapknitter_ctools_plugin_api($module = NULL, $api = NULL) {
|
|
if ($module == "openlayers" && $api == "default_openlayers_layers") {
|
|
return array("version" => "1");
|
|
}
|
|
if ($module == "openlayers" && $api == "default_openlayers_maps") {
|
|
return array("version" => "1");
|
|
}
|
|
if ($module == "openlayers" && $api == "default_openlayers_sources") {
|
|
return array("version" => "1");
|
|
}
|
|
}
|