You are here

function views_admin_link in Admin 6

Implementation of hook_admin_link() on behalf of the views module.

File

./admin.module, line 344

Code

function views_admin_link($type, $object) {
  $links = array();
  $view_name = '';
  if (user_access('administer views')) {
    switch ($type) {
      case 'block':

        // If this is a Views block and not a special (exposed filter, etc.) block...
        if ($object->module == 'views' && strpos($object->delta, '-') !== 0) {
          $split = explode('-', $object->delta);
          $view_name = array_shift($split);
        }
        break;
      case 'views':

        // Bail on block/attachment views or views using the node row plugin to prevent collisions.
        if ($object->display_handler
          ->get_option('row_plugin') != 'node' && !in_array(get_class($object->display_handler), array(
          'views_plugin_display_attachment',
          'views_plugin_display_block',
        ))) {
          $view_name = $object->name;
        }
        break;
    }
    if (!empty($view_name)) {
      $links['views-edit'] = array(
        'title' => t('Edit view'),
        'href' => "admin/build/views/edit/{$view_name}",
        'attributes' => array(
          'class' => 'icon-edit',
        ),
        'query' => array(
          'destination' => $_GET['q'],
        ),
      );
      if ($display_id = $object->display_handler->display->id) {
        $links['views-edit']['fragment'] = 'views-tab-' . $display_id;
      }
    }
  }
  return $links;
}