openlayers_filters.module in Openlayers 6
Same filename and directory in other branches
This file holds the main Drupal hook functions and private functions for the openlayers_filters module.
File
modules/openlayers_filters/openlayers_filters.moduleView source
<?php
/**
* @file
* This file holds the main Drupal hook functions
* and private functions for the openlayers_filters module.
*
* @ingroup openlayers
*/
/**
* Implementation of hook_help().
*/
function openlayers_filters_help($path, $arg) {
$output = '';
switch ($path) {
case 'admin/help#openlayers_filters':
$output = '<p>' . t('The OpenLayers Filters module provides input filters to allow for inline maps.') . '</p>';
return $output;
}
}
/**
* Implementation of hook_filter().
*/
function openlayers_filters_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) {
// Check op for list
if ($op == 'list') {
return array(
0 => t('Inline OpenLayers Maps'),
);
}
// Check delta
switch ($delta) {
case 0:
switch ($op) {
case 'no cache':
// No caching
return TRUE;
case 'description':
return t('Substitutes a macro text like !macro_example into a the appropriate rendered OpenLayers map.', array(
'!macro_example' => '[openlayers preset_name]',
));
case 'prepare':
return $text;
case 'process':
$matches = array();
preg_match_all('/\\[(openlayers[^\\]]*)\\]/', $text, $matches);
// Check for found
if (is_array($matches[1]) && count($matches[1]) > 0) {
foreach ($matches[1] as $i => $match) {
$exploded = explode(' ', $match);
// Check for openlayers prefix
if ($exploded[0] == 'openlayers') {
// Check for preset name
if ($preset = check_plain($exploded[1])) {
$map = openlayers_get_map($preset);
}
else {
$map = openlayers_get_default_map();
}
// Check map
if (!empty($map)) {
// Render map
$rendered = openlayers_render_map($map);
// Replace text
$text = str_replace($matches[0][$i], $rendered['themed'], $text);
}
}
}
}
return $text;
}
break;
}
}
/**
* Implementation of hook_filter_tips().
*/
function openlayers_filters_filter_tips($delta, $format, $long = FALSE) {
switch ($delta) {
case 0:
if ($long) {
// @@TODO: Make better description for long text
return t('Substitutes a macro text like !macro_example into a the appropriate rendered OpenLayers map.', array(
'!macro_example' => '[openlayers preset_name]',
));
}
else {
return t('Substitutes a macro text like !macro_example into a the appropriate rendered OpenLayers map.', array(
'!macro_example' => '[openlayers preset_name]',
));
}
break;
}
}
Functions
Name | Description |
---|---|
openlayers_filters_filter | Implementation of hook_filter(). |
openlayers_filters_filter_tips | Implementation of hook_filter_tips(). |
openlayers_filters_help | Implementation of hook_help(). |