You are here

function media_gallery_contextual_links_view_alter in Media Gallery 7.2

Same name and namespace in other branches
  1. 7 media_gallery.module \media_gallery_contextual_links_view_alter()

Implements hook_contextual_links_view_alter().

File

./media_gallery.module, line 1267

Code

function media_gallery_contextual_links_view_alter(&$element, $items) {

  // Modify the contextual links on gallery blocks; we only want to allow
  // editing the gallery and configuring the block, and we want a more
  // descriptive title for the edit link.
  if (isset($element['#element']['#block']->module) && $element['#element']['#block']->module == 'media_gallery' && !empty($element['#links'])) {
    $links =& $element['#links'];
    foreach ($links as $key => &$link) {
      if ($key != 'node-edit' && $key != 'block-configure') {
        unset($links[$key]);
      }
      elseif ($key == 'node-edit') {
        $link['title'] = t('Edit gallery');
      }
    }
  }

  // Remove 'Edit' button provided by File Entity.
  if (isset($element['#links']['media-gallery-edit']) && isset($element['#links']['file-edit'])) {
    unset($element['#links']['file-edit']);
  }

  // Move 'Delete' button to the bottom of the list and modify label.
  if (isset($element['#links']['media-gallery-edit']) && isset($element['#links']['file-delete'])) {
    $delete = $element['#links']['file-delete'];
    unset($element['#links']['file-delete']);
    $element['#links']['file-delete'] = $delete;
    $element['#links']['file-delete']['title'] = 'Delete file';
  }
}