forked from islandora-deprecated/islandora_form_builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora_form_builder.module
167 lines (154 loc) · 4.68 KB
/
islandora_form_builder.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
// $Id$
/**
* @file
*
*/
module_load_include('inc', 'islandora_form_builder', 'Utilities');
/**
* Respond to menu hook.
*
* This hook is invoked from hook_menu().
*
* @ingroup menu_api_hooks
* @ingroup hooks
*/
function islandora_form_builder_menu() {
$items = array();
$items['formbuilder/ingest'] = array(// Discuss urls at a later date.
'title' => t('Ingest Form'),
'page callback' => 'islandora_form_builder_ingest',
'type' => MENU_CALLBACK,
'access arguments' => array('add fedora datastreams')
);
$items['formbuilder/edit'] = array(// Discuss urls at a later date.
'title' => t('Edit Form'),
'page callback' => 'islandora_form_builder_edit',
'type' => MENU_CALLBACK,
'access arguments' => array('edit fedora meta data')
);
return $items;
}
/**
*
* @param <type> $collection_pid
* @param <type> $collection_label
* @param <type> $content_model
* @return <type>
*/
function islandora_form_builder_ingest($collection_pid = NULL, $collection_label = NULL) {
$collection_pid = islandora_form_builder_validate_url_argument_collection_pid($collection_pid);
if ($collection_pid !== FALSE) {
islandora_form_builder_set_bread_crumbs($collection_pid);
return drupal_get_form('islandora_form_builder_ingest_form', $collection_pid, $collection_label);
}
}
/**
*
* @param <type> $form_state
* @param <type> $collection_pid
* @param <type> $collection_label
* @return <type>
*/
function islandora_form_builder_ingest_form(&$form_state, $collection_pid, $collection_label = NULL) {
module_load_include('inc', 'islandora_form_builder', 'IngestFormBuilder');
$ingest_form_builder = new IngestFormBuilder($form_state, $collection_pid, $collection_label);
$form = $ingest_form_builder->createForm();
return $form;
}
/**
*
* @param <type> $form
* @param <type> $form_state
* @return <type>
*/
function islandora_form_builder_ingest_form_validate(&$form, &$form_state) {
/*
* Only validate the form if the submit button was pressed
* (other buttons may be used for AHAH)
*/
if ($form_state['clicked_button']['#id'] != 'edit-submit')
return;
module_load_include('inc', 'islandora_form_builder', 'IngestFormBuilder');
$ingest_form_builder = new IngestFormBuilder($form_state);
$ingest_form_builder->validateForm($form);
}
/**
*
* @param <type> $form
* @param <type> $form_state
* @return <type>
*/
function islandora_form_builder_ingest_form_submit(&$form, &$form_state) {
/*
* Only submit the form if the submit button was pressed
* (other buttons may be used for AHAH)
*/
if ($form_state['clicked_button']['#id'] != 'edit-submit')
return;
module_load_include('inc', 'islandora_form_builder', 'IngestFormBuilder');
$ingest_form_builder = new IngestFormBuilder($form_state);
$ingest_form_builder->submitForm($form);
}
/**
* Menu Callback for the edit form.
*
* @param string $pid
* Object PID.
*
* @return array
* A drupal form, used to edit the object $pid and the datastream $dsid.
*/
function islandora_form_builder_edit($pid = NULL, $form_name = NULL) {
if (islandora_form_builder_check_edit_form_arguments_and_permissions($pid, $form_name)) {
islandora_form_builder_set_bread_crumbs($pid);
return drupal_get_form('islandora_form_builder_edit_form', $pid, $form_name);
}
}
/**
*
* @param <type> $form_state
* @param <type> $pid
* @param <type> $dsid
* @return <type>
*/
function islandora_form_builder_edit_form(&$form_state, $pid, $form_name) {
module_load_include('inc', 'islandora_form_builder', 'EditFormBuilder');
$edit_form_builder = new EditFormBuilder($form_state, $pid, $form_name);
$form = $edit_form_builder->createForm();
return $form;
}
/**
*
* @param <type> $form
* @param <type> $form_state
* @return <type>
*/
function islandora_form_builder_ingest_edit_form_validate(&$form, &$form_state) {
/*
* Only validate the form if the submit button was pressed
* (other buttons may be used for AHAH)
*/
if ($form_state['clicked_button']['#id'] != 'edit-submit')
return;
module_load_include('inc', 'islandora_form_builder', 'EditFormBuilder');
$edit_form_builder = new EditFormBuilder($form_state);
$edit_form_builder->validateForm($form);
}
/**
*
* @param <type> $form
* @param <type> $form_state
* @return <type>
*/
function islandora_form_builder_ingest_edit_form_submit(&$form, &$form_state) {
/*
* Only submit the form if the submit button was pressed
* (other buttons may be used for AHAH)
*/
if ($form_state['clicked_button']['#id'] != 'edit-submit')
return;
module_load_include('inc', 'islandora_form_builder', 'EditFormBuilder');
$edit_form_builder = new EditFormBuilder($form_state);
$edit_form_builder->submitForm($form);
}