/[drupal]/contributions/modules/relations/relations.admin.inc
ViewVC logotype

Contents of /contributions/modules/relations/relations.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Mon Aug 31 15:46:21 2009 UTC (2 months, 4 weeks ago) by arto
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA1, HEAD
Changes since 1.6: +26 -0 lines
File MIME type: text/x-php
Implemented new UI settings for hiding the 'Relations' node tab or the 'Related content' fieldset.
1 <?php
2 // $Id$
3
4 //////////////////////////////////////////////////////////////////////////////
5 // Relations API settings form
6
7 function relations_admin_settings() {
8 $form = array();
9
10 // Content type settings
11 $form['node_types'] = array(
12 '#type' => 'fieldset',
13 '#title' => t('Content type settings'),
14 '#collapsible' => TRUE,
15 '#collapsed' => FALSE,
16 );
17 $form['node_types']['relations_node_types'] = array(
18 '#type' => 'checkboxes',
19 '#title' => t('Enabled content types'),
20 '#default_value' => relations_get_node_types(),
21 '#options' => array_combine(array_keys(node_get_types('names')), array_fill(0, count(node_get_types('names')), '')),
22 '#description' => t('Select the content types for which to enable relationship functionality.'),
23 );
24
25 // User interface settings
26 $form['ui_settings'] = array(
27 '#type' => 'fieldset',
28 '#title' => t('User interface settings'),
29 '#collapsible' => TRUE,
30 '#collapsed' => FALSE,
31 );
32 $form['ui_settings']['relations_ui_node_tab'] = array(
33 '#type' => 'checkbox',
34 '#title' => t('Enable the "Relations" tab for the content types configured above'),
35 '#default_value' => variable_get('relations_ui_node_tab', '1'),
36 '#description' => t('Access to this functionality is subject to the <code>view node relations</code> <a href="@permissions">permission</a>. Note: you may need to clear Drupal\'s menu cache for changes to this setting to take effect.', array('@permissions' => url('admin/user/permissions', array('fragment' => 'module-relations')))),
37 );
38 $form['ui_settings']['relations_ui_node_edit'] = array(
39 '#type' => 'checkbox',
40 '#title' => t('Enable the embedded "Related content" fieldset on content creation/editing forms'),
41 '#default_value' => variable_get('relations_ui_node_edit', '1'),
42 '#description' => t('Access to this functionality is subject to the <code>create node relations</code> <a href="@permissions">permission</a>.', array('@permissions' => url('admin/user/permissions', array('fragment' => 'module-relations')))),
43 );
44
45 // Relationship types
46 $form['predicates'] = array(
47 '#type' => 'fieldset',
48 '#title' => t('Relationship types'),
49 '#collapsible' => TRUE,
50 '#collapsed' => FALSE,
51 );
52 $form['predicates']['relations_predicate'] = array(
53 '#type' => 'radios',
54 '#title' => t('Default relationship type'),
55 '#default_value' => relations_get_predicate(),
56 '#options' => relations_get_predicates('keys'),
57 '#description' => t(''),
58 );
59
60 $form['#submit'][] = 'relations_admin_settings_submit';
61 return array_merge_recursive(system_settings_form($form), array('#theme' => 'relations_admin_settings', 'buttons' => array('#weight' => 99)));
62 }
63
64 function theme_relations_admin_settings($form) {
65 $enabled_types = relations_get_node_types();
66
67 // Content type settings
68 $head = array(t('Enabled'), t('Content type'), t('Block title'), array('data' => t('Operations'), 'colspan' => '1'));
69 $rows = array();
70 foreach (node_get_types('names') as $node_type => $title) {
71 $block_title = db_result(db_query("SELECT title FROM {blocks} WHERE module = 'relations' AND delta = '%s' AND theme = '%s'", $node_type, variable_get('theme_default', 'garland')));
72 $block_title = !empty($block_title) ? $block_title : t('Relations: !type', array('!type' => $title));
73 $rows[] = array(
74 drupal_render($form['node_types']['relations_node_types'][$node_type]),
75 t($title),
76 isset($enabled_types[$node_type]) ? $block_title : '',
77 isset($enabled_types[$node_type]) ? l(t('configure block'), 'admin/build/block/configure/relations/'. $node_type) : '',
78 );
79 }
80
81 $form['node_types']['#value'] = theme('table', $head, $rows, array('class' => 'relations node-types'));
82 unset($form['node_types']['relations_node_types']);
83
84 // Relationship types
85 $head = array(t('Default'), t('Title'), t('RDF URI'), t('Kind'));
86 $rows = array();
87 foreach (relations_get_predicates() as $predicate) {
88 $rows[] = array(
89 drupal_render($form['predicates']['relations_predicate'][$predicate->uri]),
90 $predicate->title,
91 l($predicate->uri, $predicate->uri),
92 !empty($predicate->bidirectional) ? t('Bidirectional') : t('Unidirectional'),
93 );
94 }
95
96 $form['predicates']['#value'] = theme('table', $head, $rows, array('class' => 'relations predicates'));
97 unset($form['predicates']['relations_predicate']);
98
99 return drupal_render($form);
100 }
101
102 function relations_admin_settings_submit($form, &$form_state) {
103 extract($form_state['values'], EXTR_SKIP | EXTR_REFS);
104 menu_rebuild();
105 }

  ViewVC Help
Powered by ViewVC 1.1.2