2007-08-30 16:27:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
2014-04-25 22:26:53 +00:00
|
|
|
* Administrative page callbacks for Menu UI module.
|
2007-08-30 16:27:12 +00:00
|
|
|
*/
|
|
|
|
|
2014-07-30 12:04:04 +00:00
|
|
|
use Drupal\Component\Utility\SafeMarkup;
|
2014-03-31 17:37:55 +00:00
|
|
|
use Drupal\Core\Render\Element;
|
|
|
|
|
2007-08-30 16:27:12 +00:00
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for the menu overview form into a table.
|
|
|
|
*
|
2014-07-30 12:04:04 +00:00
|
|
|
* @param array $variables
|
2010-04-13 15:23:03 +00:00
|
|
|
* An associative array containing:
|
|
|
|
* - form: A render element representing the form.
|
2007-12-06 09:58:34 +00:00
|
|
|
*
|
2014-07-30 12:04:04 +00:00
|
|
|
* @return string
|
|
|
|
* The themed HTML.
|
|
|
|
*
|
2007-12-06 09:58:34 +00:00
|
|
|
* @ingroup themeable
|
2007-08-30 16:27:12 +00:00
|
|
|
*/
|
2009-10-09 01:00:08 +00:00
|
|
|
function theme_menu_overview_form($variables) {
|
|
|
|
$form = $variables['form'];
|
|
|
|
|
2007-11-20 10:18:43 +00:00
|
|
|
$header = array(
|
2009-03-20 19:18:11 +00:00
|
|
|
t('Menu link'),
|
2009-08-22 14:34:23 +00:00
|
|
|
array('data' => t('Enabled'), 'class' => array('checkbox')),
|
2007-11-20 10:18:43 +00:00
|
|
|
t('Weight'),
|
2012-10-09 19:49:07 +00:00
|
|
|
t('Operations'),
|
2007-11-20 10:18:43 +00:00
|
|
|
);
|
|
|
|
|
2007-11-09 22:14:41 +00:00
|
|
|
$rows = array();
|
2014-07-30 12:04:04 +00:00
|
|
|
foreach (Element::children($form) as $id) {
|
|
|
|
if (isset($form[$id]['#item'])) {
|
|
|
|
$element = &$form[$id];
|
2007-11-09 22:14:41 +00:00
|
|
|
|
2007-11-20 10:18:43 +00:00
|
|
|
// Add special classes to be used for tabledrag.js.
|
2014-07-30 12:04:04 +00:00
|
|
|
$element['parent']['#attributes']['class'] = array('menu-parent');
|
|
|
|
$element['id']['#attributes']['class'] = array('menu-id');
|
2009-08-22 14:34:23 +00:00
|
|
|
$element['weight']['#attributes']['class'] = array('menu-weight');
|
2007-11-20 10:18:43 +00:00
|
|
|
|
2014-07-30 12:04:04 +00:00
|
|
|
// Change the parent field to a hidden. This allows any value but hides
|
|
|
|
// the field.
|
|
|
|
$element['parent']['#type'] = 'hidden';
|
2007-11-20 10:18:43 +00:00
|
|
|
|
2013-06-14 22:56:38 +00:00
|
|
|
$indent = array(
|
|
|
|
'#theme' => 'indentation',
|
2014-07-30 12:04:04 +00:00
|
|
|
'#size' => $element['#item']->depth - 1,
|
2013-06-14 22:56:38 +00:00
|
|
|
);
|
|
|
|
|
2007-11-09 22:14:41 +00:00
|
|
|
$row = array();
|
2014-07-30 12:04:04 +00:00
|
|
|
$row[] = SafeMarkup::set(drupal_render($indent) . drupal_render($element['title']));
|
|
|
|
$row[] = array('data' => drupal_render($element['enabled']), 'class' => array('checkbox', 'menu-enabled'));
|
|
|
|
$row[] = SafeMarkup::set(drupal_render($element['weight']) . drupal_render($element['parent']) . drupal_render($element['id']));
|
2012-10-09 19:49:07 +00:00
|
|
|
$row[] = drupal_render($element['operations']);
|
2007-08-30 16:27:12 +00:00
|
|
|
|
2007-11-09 22:14:41 +00:00
|
|
|
$row = array_merge(array('data' => $row), $element['#attributes']);
|
2009-08-22 14:34:23 +00:00
|
|
|
$row['class'][] = 'draggable';
|
2007-11-09 22:14:41 +00:00
|
|
|
$rows[] = $row;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$output = '';
|
2009-06-27 23:49:19 +00:00
|
|
|
if (empty($rows)) {
|
|
|
|
$rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '7'));
|
2007-11-09 22:14:41 +00:00
|
|
|
}
|
2013-06-14 22:56:38 +00:00
|
|
|
|
|
|
|
$table = array(
|
2013-12-20 12:05:47 +00:00
|
|
|
'#type' => 'table',
|
2013-06-14 22:56:38 +00:00
|
|
|
'#header' => $header,
|
|
|
|
'#rows' => $rows,
|
|
|
|
'#attributes' => array(
|
|
|
|
'id' => 'menu-overview',
|
|
|
|
),
|
2013-12-20 12:05:47 +00:00
|
|
|
'#tabledrag' => array(
|
|
|
|
array(
|
|
|
|
'action' => 'match',
|
|
|
|
'relationship' => 'parent',
|
2014-07-30 12:04:04 +00:00
|
|
|
'group' => 'menu-parent',
|
|
|
|
'subgroup' => 'menu-parent',
|
|
|
|
'source' => 'menu-id',
|
2013-12-20 12:05:47 +00:00
|
|
|
'hidden' => TRUE,
|
2014-07-30 12:04:04 +00:00
|
|
|
'limit' => \Drupal::menuTree()->maxDepth() - 1,
|
2013-12-20 12:05:47 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'action' => 'order',
|
|
|
|
'relationship' => 'sibling',
|
|
|
|
'group' => 'menu-weight',
|
|
|
|
),
|
|
|
|
),
|
2013-06-14 22:56:38 +00:00
|
|
|
);
|
|
|
|
|
2013-02-01 16:21:13 +00:00
|
|
|
$output .= drupal_render($form['inline_actions']);
|
2013-06-14 22:56:38 +00:00
|
|
|
$output .= drupal_render($table);
|
2009-02-03 18:55:32 +00:00
|
|
|
$output .= drupal_render_children($form);
|
2007-11-09 22:14:41 +00:00
|
|
|
return $output;
|
2007-08-30 16:27:12 +00:00
|
|
|
}
|