You are here

function panels_flexible_render_item_links in Panels 7.3

Same name and namespace in other branches
  1. 6.3 plugins/layouts/flexible/flexible.inc \panels_flexible_render_item_links()

Render the dropdown links for an item.

4 calls to panels_flexible_render_item_links()
panels_ajax_flexible_edit_add in plugins/layouts/flexible/flexible.inc
AJAX responder to add a new row, column or region to a flexible layout.
panels_ajax_flexible_edit_remove in plugins/layouts/flexible/flexible.inc
Panels remove AJAX responder.
panels_ajax_flexible_edit_settings in plugins/layouts/flexible/flexible.inc
AJAX responder to edit flexible settings for an item.
panels_flexible_render_item in plugins/layouts/flexible/flexible.inc
Render a column in the flexible layout.

File

plugins/layouts/flexible/flexible.inc, line 676
Flexible layout plugin.

Code

function panels_flexible_render_item_links($renderer, $id, $item) {
  $links = array();
  $remove = '';
  $add = '';
  if ($item['type'] == 'column') {
    $title = t('Column');
    $settings = t('Column settings');
    if (empty($item['children'])) {
      $remove = t('Remove column');
      $add = t('Add row');
    }
    else {
      $add = t('Add row to top');
      $add2 = t('Add row to bottom');
    }
  }
  elseif ($item['type'] == 'row') {
    if ($id == 'canvas') {
      $title = t('Canvas');
      $settings = t('Canvas settings');
    }
    else {
      $title = t('Row');
      $settings = t('Row settings');
    }
    if (empty($item['children'])) {
      if ($id != 'canvas') {
        $remove = t('Remove row');
      }
      $add = $item['contains'] == 'region' ? t('Add region') : t('Add column');
    }
    else {
      $add = $item['contains'] == 'region' ? t('Add region to left') : t('Add column to left');
      $add2 = $item['contains'] == 'region' ? t('Add region to right') : t('Add column to right');
    }
  }
  elseif ($item['type'] == 'region') {
    $title = t('Region');
    $settings = t('Region settings');
    $remove = t('Remove region');
  }
  if (!empty($settings)) {
    $links[] = array(
      'title' => $settings,
      'href' => $renderer->handler
        ->get_url('layout', 'settings', $id),
      'attributes' => array(
        'class' => array(
          'ctools-use-modal',
        ),
      ),
    );
  }
  if ($add) {
    $links[] = array(
      'title' => $add,
      'href' => $renderer->handler
        ->get_url('layout', 'add', $id),
      'attributes' => array(
        'class' => array(
          'ctools-use-modal',
        ),
      ),
    );
  }
  if (isset($add2)) {
    $links[] = array(
      'title' => $add2,
      'href' => $renderer->handler
        ->get_url('layout', 'add', $id, 'right'),
      'attributes' => array(
        'class' => array(
          'ctools-use-modal',
        ),
      ),
    );
  }
  if ($remove) {
    $links[] = array(
      'title' => $remove,
      'href' => $renderer->handler
        ->get_url('layout', 'remove', $id),
      'attributes' => array(
        'class' => array(
          'use-ajax',
        ),
      ),
    );
  }
  return theme('ctools_dropdown', array(
    'title' => $title,
    'links' => $links,
    'class' => 'flexible-layout-only flexible-links flexible-title flexible-links-' . $id,
  ));
}