/** * Filter marker URL * @example <code>$entity->getIconURL('marker');</code> * * @param string $hook Equals 'entity:icon:url' * @param string $type Equals 'user', 'object', 'group' * @param string $return Current icon URL * @param array $params Additional params * @return string Filtered icon URL */ function get_marker_url($hook, $type, $return, $params) { $entity = elgg_extract('entity', $params); $size = elgg_extract('size', $params); if (!elgg_instanceof($entity) || $size !== 'marker') { return $return; } $icon_url = get_marker_icons_path(true) . "default.png"; if ($entity->mapicon) { $icon_url = $entity->mapicon; } else { if ($entity->markertype) { $marker = $entity->markertype; } else { $marker = $entity->getType(); if ($type == 'object') { $marker = $entity->getSubtype(); } } } if ($marker && in_array($marker, get_marker_types_defaults())) { $icon_url = get_marker_icons_path(true) . "{$marker}.png"; } return $icon_url; }
echo '<label>' . elgg_echo("maps:settings:params[{$s}]") . '</label>'; echo '<div class="elgg-text-help">' . elgg_echo("maps:settings:hint:{$s}") . '</div>'; echo elgg_view('input/dropdown', array('name' => "params[{$s}]", 'value' => $entity->{$s}, 'options_values' => array(0 => elgg_echo('disable'), 1 => elgg_echo('enable')))); echo '</div>'; } $registered_entities = elgg_get_config('registered_entities'); foreach ($registered_entities['object'] as $subtype) { $subtype_options[elgg_echo("item:object:{$subtype}")] = $subtype; } echo '<div>'; echo '<label>' . elgg_echo('maps:settings:params[mapptable_subtypes]') . '</label>'; echo '<div class="elgg-text-help">' . elgg_echo('maps:settings:hint:mappable_subtypes') . '</div>'; echo elgg_view('input/checkboxes', array('name' => 'params[mappable_subtypes]', 'value' => $entity->mappable_subtypes ? unserialize($entity->mappable_subtypes) : array(), 'options' => $subtype_options, 'multiple' => true)); echo '</div>'; echo '<div>'; echo '<label>' . elgg_echo('maps:settings:params[icons_path]') . '</label>'; echo '<div class="elgg-text-help">' . elgg_echo('maps:settings:hint:icons_path') . '</div>'; echo elgg_view('input/text', array('name' => 'params[icons_path]', 'value' => $entity->icons_path)); echo '</div>'; $markertypes = get_marker_types_options(); echo '<div>'; echo '<label>' . elgg_echo('maps:settings:params[markertypes]') . '</label>'; echo '<div class="elgg-text-help">' . elgg_echo('maps:settings:hint:markertypes') . '</div>'; $defaults = get_marker_types_defaults(); echo '<ul class="elgg-checkboxes elgg-horizontal">'; foreach ($defaults as $mt) { $icon = elgg_view('output/img', array('src' => get_marker_icons_path(true) . "{$mt}.png", 'width' => 25)); echo '<li><label class="mam">' . elgg_view('input/checkbox', array('name' => 'params[markertypes][]', 'value' => $mt, 'checked' => array_key_exists($mt, $markertypes))) . $icon . elgg_echo("maps:marker:type:{$mt}") . '</label></li>'; } echo '</ul>'; echo '</div>';
/** * Get a list of available marker types * @return array */ function get_marker_types_defaults() { $markers = array_diff(scandir(get_marker_icons_path()), array('..', '.')); foreach ($markers as $marker) { if (strtolower(pathinfo($marker, PATHINFO_EXTENSION)) == 'png') { $options[] = pathinfo($marker, PATHINFO_FILENAME); } } return $options; }