array( 'title' => t('Add an area'), 'href' => 'admin/structure/taxonomy/farm_areas/add', 'paths' => array( 'farm/areas', ), ), ); return $actions; } /** * Generate area links, sorted by weight. * * @param $id * The area id. * @param $separator * Characters to use as a separator between links in the returned string. * * @return string * Returns a string of links. */ function farm_area_get_links($id, $separator = ' | ') { // Call out to modules that want to provide links. $area_links = module_invoke_all('farm_area_links', check_plain($id)); // Build an index of links and their weights. $weight_index = array(); foreach ($area_links as $key => $link) { // Default the weight to zero if it hasn't been set. if (!isset($link['weight'])) { $link['weight'] = 0; } // Assign the weight to the index, based on it's key in the original array. $weight_index[$key] = $link['weight']; } // Sort the index by weight. asort($weight_index); // Rebuild the array of links based on their weights. $sorted_area_links = array(); foreach ($weight_index as $key => $weight) { $sorted_area_links[] = $area_links[$key]; } // Generate an array of Drupal links. $links = array(); foreach ($sorted_area_links as $link) { if (!empty($link['title']) && !empty($link['href'])) { $links[] = l($link['title'], $link['href']); } } // Convert to a string with a separator and return. return implode($separator, $links); } /** * Implements hook_openlayers_map_preprocess_alter(). */ function farm_area_openlayers_map_preprocess_alter(&$map = array()) { // Define the layer we are going to add. $layer = 'farm_area_data_all'; // Add the 'All Areas' layer to Farm Geofield Map. if (!empty($map['map_name']) && $map['map_name'] == 'farm_map_geofield') { // Add the farm_soil_nrcs layer. $map['layers'] += array($layer => $layer); // Activate the layer by default. $map['layer_activated'] += array($layer => $layer); // Show the layer in the switcher. $map['layer_switcher'] += array($layer => $layer); // Set the layer style to Farm Grey. $map['layer_styles'] += array($layer => 'farm_grey'); // Set the layer weight so that it is on the bottom. $map['layer_weight'] += array($layer => 100); // Zoom to the "All areas" layer. if (!empty($map['behaviors']['openlayers_behavior_zoomtolayer'])) { $map['behaviors']['openlayers_behavior_zoomtolayer']['zoomtolayer'][$layer] = $layer; } } }