-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildmodes.module
108 lines (97 loc) · 2.76 KB
/
buildmodes.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
// $Id$
/**
* Implementation of hook_menu()
*/
function buildmodes_menu() {
$items = array();
$items['admin/build/buildmodes'] = array(
'title' => 'Build modes',
'description' => 'List, edit, or add build modes to your nodes',
'page callback' => 'buildmodes_overview',
'access arguments' => array('administer buildmodes'),
'file' => 'buildmodes.admin.inc',
);
$items['admin/build/buildmodes/list'] = array(
'title' => 'List',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/build/buildmodes/add'] = array(
'title' => 'Add build mode',
'description' => 'Add a new build mode',
'page callback' => 'drupal_get_form',
'page arguments' => array('buildmodes_form'),
'access arguments' => array('administer buildmodes'),
'type' => MENU_LOCAL_TASK,
'file' => 'buildmodes.admin.inc',
);
$items['admin/build/buildmodes/%buildmode/edit'] = array(
'title' => 'Edit build mode',
'description' => 'Edit a build mode',
'page callback' => 'drupal_get_form',
'page arguments' => array('buildmodes_form', 3),
'access arguments' => array('administer buildmodes'),
'file' => 'buildmodes.admin.inc',
);
$items['admin/build/buildmodes/%buildmode/delete'] = array(
'title' => 'Delete build mode',
'description' => 'Delete a build mode',
'page callback' => 'drupal_get_form',
'page arguments' => array('buildmodes_delete_confirm', 3),
'access arguments' => array('administer buildmodes'),
'file' => 'buildmodes.admin.inc',
);
return $items;
}
/**
* Implementation of hook_content_build_modes()
* from content.module (CCK)
*/
function buildmodes_content_build_modes() {
$buildmodes = array(
'buildmodes' => array(
'title' => t('Build modes'),
),
);
$buildmodes['buildmodes']['build modes'] = buildmodes_list_modes();
return $buildmodes;
}
/**
* Returns the list of user defined build modes
*
* @param $reset
* (optional) Refresh the static variable?
* @return
* Array TODO
*/
function buildmodes_list_modes($reset = FALSE) {
static $buildmodes;
if ($reset || !isset($buildmodes)) {
$buildmodes = variable_get('buildmodes_modes', array());
// For convinience prupose we sort by alpha keys
ksort($buildmodes);
}
return $buildmodes;
}
/**
* Loads a single buildmode based on a system name
*/
function buildmode_load($name) {
$buildmodes = buildmodes_list_modes();
if ($buildmodes[$name]) {
$buildmodes[$name]['name'] = $name;
return $buildmodes[$name];
}
else {
return FALSE;
}
}
/**
* Preprocess function for template suggestions
*/
function buildmodes_preprocess_node(&$vars) {
if ($vars['build_mode']) {
$vars['template_files'][] = 'node-'. $vars['type'] .'-'. $vars['build_mode'];
}
}