1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Administrative page callbacks for the External Links module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Page callback: Form constructor for a form to list and reorder external link templates.
|
10
|
*
|
11
|
* @ingroup forms
|
12
|
* @see ext_links_menu()
|
13
|
* @see ext_links_admin_overview_submit()
|
14
|
*/
|
15
|
function ext_links_admin_overview($form) {
|
16
|
|
17
|
$link_templates = ext_links_templates();
|
18
|
|
19
|
$form['#tree'] = TRUE;
|
20
|
foreach ($link_templates as $id => $link_template) {
|
21
|
$form['link_templates'][$id]['title'] = array('#markup' => check_plain($link_template->title));
|
22
|
$form['link_templates'][$id]['link'] = array('#markup' => check_plain($link_template->link));
|
23
|
$form['link_templates'][$id]['glue'] = array('#markup' => check_plain($link_template->glue));
|
24
|
$form['link_templates'][$id]['category'] = array('#markup' => check_plain($link_template->category));
|
25
|
$form['link_templates'][$id]['configure'] = array('#type' => 'link', '#title' => t('configure'), '#href' => 'admin/config/content/link_templates/' . $id);
|
26
|
$form['link_templates'][$id]['disable'] = array('#type' => 'link', '#title' => t('disable'), '#href' => 'admin/config/content/link_templates/' . $id . '/disable', '#access' => !$form['link_templates'][$id]['#is_fallback']);
|
27
|
$form['link_templates'][$id]['weight'] = array(
|
28
|
'#type' => 'weight',
|
29
|
'#title' => t('Weight for @title', array('@title' => $link_template->name)),
|
30
|
'#title_display' => 'invisible',
|
31
|
'#default_value' => $link_template->weight,
|
32
|
);
|
33
|
}
|
34
|
$form['actions'] = array('#type' => 'actions');
|
35
|
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save changes'));
|
36
|
return $form;
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* Form submission handler for filter_admin_overview().
|
41
|
*/
|
42
|
function ext_links_admin_overview_submit($form, &$form_state) {
|
43
|
foreach ($form_state['values']['formats'] as $id => $data) {
|
44
|
if (is_array($data) && isset($data['weight'])) {
|
45
|
// Only update if this is a form element with weight.
|
46
|
db_update('filter_format')
|
47
|
->fields(array('weight' => $data['weight']))
|
48
|
->condition('format', $id)
|
49
|
->execute();
|
50
|
}
|
51
|
}
|
52
|
filter_formats_reset();
|
53
|
drupal_set_message(t('The text format ordering has been saved.'));
|
54
|
}
|
55
|
|
56
|
|
57
|
/**
|
58
|
* Returns HTML for the text format administration overview form.
|
59
|
*
|
60
|
* @param $variables
|
61
|
* An associative array containing:
|
62
|
* - form: A render element representing the form.
|
63
|
*
|
64
|
* @ingroup themeable
|
65
|
*/
|
66
|
function theme_ext_links_admin_overview($variables) {
|
67
|
$form = $variables['form'];
|
68
|
|
69
|
$rows = array();
|
70
|
foreach (element_children($form['link_templates']) as $id) {
|
71
|
$form['link_templates'][$id]['weight']['#attributes']['class'] = array('text-format-order-weight');
|
72
|
$rows[] = array(
|
73
|
'data' => array(
|
74
|
drupal_render($form['link_templates'][$id]['title']),
|
75
|
drupal_render($form['link_templates'][$id]['link']),
|
76
|
drupal_render($form['link_templates'][$id]['glue']),
|
77
|
drupal_render($form['link_templates'][$id]['category']),
|
78
|
drupal_render($form['link_templates'][$id]['weight']),
|
79
|
drupal_render($form['link_templates'][$id]['configure']),
|
80
|
drupal_render($form['link_templates'][$id]['disable']),
|
81
|
),
|
82
|
'class' => array('draggable'),
|
83
|
);
|
84
|
}
|
85
|
$header = array(t('Title'), t('Link'), t('Glue'), t('Weight'), t('Category'), array('data' => t('Operations'), 'colspan' => 2));
|
86
|
$output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'text-format-order')));
|
87
|
$output .= drupal_render_children($form);
|
88
|
|
89
|
drupal_add_tabledrag('text-format-order', 'order', 'sibling', 'text-format-order-weight');
|
90
|
|
91
|
return $output;
|
92
|
}
|