|
1 | 1 | <?php
|
2 |
| - |
3 | 2 | /**
|
4 |
| - * @file ding_library.admin.inc |
| 3 | + * @file |
5 | 4 | * Admin forms, page callbacks and related functions.
|
6 | 5 | *
|
7 | 6 | * Much of this stuff is a taken from the scaffolding example module.
|
@@ -166,115 +165,3 @@ function theme_ding_library_admin_ordering_form($form) {
|
166 | 165 | return $output;
|
167 | 166 | }
|
168 | 167 |
|
169 |
| -/** |
170 |
| - * Slug editing form. |
171 |
| - */ |
172 |
| -function ding_library_admin_slugs_form(&$form_state) { |
173 |
| - // Confirmation form for changing existing slugs. The storage array |
174 |
| - // is set by the submit handler, and as long as it is non-empty, we're |
175 |
| - // returned to the form. |
176 |
| - if (!empty($form_state['storage']['slug_changes'])) { |
177 |
| - $changes_text = array(); |
178 |
| - foreach ($form_state['storage']['slug_changes'] as $change) { |
179 |
| - $changes_text[] = t('Change slug for %library from !old to !new', array( |
180 |
| - '%library' => $change['title'], |
181 |
| - '!old' => '<tt>' . check_plain($change['old_slug']) . '</tt>', |
182 |
| - '!new' => '<tt>' . check_plain($change['new_slug']) . '</tt>', |
183 |
| - )); |
184 |
| - } |
185 |
| - |
186 |
| - return confirm_form(array(), t('Please confirm these slug changes'), $_GET['q'], theme('item_list', $changes_text), t('Confirm'), t('Cancel')); |
187 |
| - } |
188 |
| - |
189 |
| - // Grab all the library nodes with their weight. |
190 |
| - $query = db_query(" |
191 |
| - SELECT n.nid, n.title, p.value AS slug FROM {node} AS n |
192 |
| - LEFT JOIN {purl} AS p ON (p.id = n.nid AND provider = 'ding_library') |
193 |
| - WHERE n.type = 'library' |
194 |
| - ORDER BY n.title; |
195 |
| - "); |
196 |
| - |
197 |
| - $existing = array(); |
198 |
| - $form = array(); |
199 |
| - |
200 |
| - $form['warning'] = array( |
201 |
| - '#prefix' => '<div class="warning">', |
202 |
| - '#value' => t("Here you can edit the identifying part of a library's URL, called “slugs”. Be aware that changing the existing slugs will URLs to change, resulting in dead links."), |
203 |
| - '#suffix' => '</div>', |
204 |
| - ); |
205 |
| - |
206 |
| - $form['records']['#tree'] = TRUE; |
207 |
| - while ($row = db_fetch_object($query)) { |
208 |
| - $form['records'][$row->nid] = array( |
209 |
| - '#type' => 'textfield', |
210 |
| - '#title' => $row->title, |
211 |
| - '#default_value' => $row->slug, |
212 |
| - ); |
213 |
| - // Add the existing slugs to an array, so we'll be able to detect |
214 |
| - // overwriting in the validation. |
215 |
| - if (!empty($row->slug)) { |
216 |
| - $existing[$row->nid] = $row->slug; |
217 |
| - } |
218 |
| - } |
219 |
| - |
220 |
| - $form['existing_slugs'] = array( |
221 |
| - '#type' => 'value', |
222 |
| - '#value' => $existing, |
223 |
| - ); |
224 |
| - |
225 |
| - $form['submit'] = array( |
226 |
| - '#type' => 'submit', |
227 |
| - '#value' => t('Save changes'), |
228 |
| - ); |
229 |
| - |
230 |
| - return $form; |
231 |
| -} |
232 |
| - |
233 |
| -/** |
234 |
| - * Submit handler for the slug editing form. |
235 |
| - */ |
236 |
| -function ding_library_admin_slugs_form_submit($form, &$form_state) { |
237 |
| - // If the there's slug changes in the storage array, it means that |
238 |
| - // we've been through the confirmation form, and should now proceeed |
239 |
| - // to change the slugs in the database. |
240 |
| - if (isset($form_state['storage']['slug_changes'])) { |
241 |
| - foreach ($form_state['storage']['slug_changes'] as $change) { |
242 |
| - purl_save(array( |
243 |
| - 'id' => $change['nid'], |
244 |
| - 'provider' => 'ding_library', |
245 |
| - 'value' => $change['new_slug'], |
246 |
| - )); |
247 |
| - |
248 |
| - // Unset the storage, so we'll won't get the confirmation page again. |
249 |
| - unset($form_state['storage']); |
250 |
| - return; |
251 |
| - } |
252 |
| - } |
253 |
| - |
254 |
| - $slug_changes = array(); |
255 |
| - |
256 |
| - foreach ($form_state['values']['records'] as $nid => $slug) { |
257 |
| - if (!empty($slug)) { |
258 |
| - if (isset($form_state['values']['existing_slugs'][$nid]) && $form_state['values']['existing_slugs'][$nid] != $slug) { |
259 |
| - // Existing slug is being changed, store the changes so we can |
260 |
| - // create a confirmation form with it. |
261 |
| - $slug_changes[$nid] = array( |
262 |
| - 'nid' => $nid, |
263 |
| - 'title' => $form['records'][$nid]['#title'], |
264 |
| - 'old_slug' => $form_state['values']['existing_slugs'][$nid], |
265 |
| - 'new_slug' => ding_library_slugify($slug), |
266 |
| - ); |
267 |
| - } |
268 |
| - else { |
269 |
| - // Save the newly added slug via PURL. |
270 |
| - purl_save(array( |
271 |
| - 'id' => $nid, |
272 |
| - 'provider' => 'ding_library', |
273 |
| - 'value' => ding_library_slugify($slug), |
274 |
| - )); |
275 |
| - } |
276 |
| - } |
277 |
| - } |
278 |
| - $form_state['storage']['slug_changes'] = $slug_changes; |
279 |
| -} |
280 |
| - |
0 commit comments