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

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

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


Revision 1.2 - (show annotations) (download) (as text)
Fri Dec 12 21:54:10 2008 UTC (11 months, 2 weeks ago) by darthclue
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC3, HEAD
Changes since 1.1: +5 -3 lines
File MIME type: text/x-php
#345865: Vocab depth is now configurable.
1 <?php
2 // $Id: taxonomy_dhtml.admin.inc,v 1.1 2008/10/01 08:25:08 darthclue Exp $
3
4 /**
5 * @file
6 * Administrative page callbacks for the taxonomy DHTML module.
7 */
8
9 /**
10 * Form Builder to manage settings for taxonomy DHTML.
11 *
12 * @ingroup forms
13 * @see taxonomy_dhtml_admin_submit()
14 * @see theme_taxonomy_dhtml_admin()
15 */
16 function taxonomy_dhtml_admin() {
17 $vocabularies = taxonomy_dhtml_get_vocabularies();
18 $form = array('#tree' => TRUE);
19 foreach ($vocabularies as $vocabulary) {
20 $types = array();
21 $form[$vocabulary->vid]['#vocabulary'] = (array)$vocabulary;
22 $form[$vocabulary->vid]['name'] = array('#value' => check_plain($vocabulary->name));
23 $form[$vocabulary->vid]['noi'] = array('#type' => 'textfield', '#size' => 3, '#maxlength' => 3, '#default_value' => (is_null($vocabulary->noi) ? 25 : $vocabulary->noi));
24 $form[$vocabulary->vid]['exposeBlock'] = array('#type' => 'checkbox', '#default_value' => is_null($vocabulary->expblock) ? FALSE : $vocabulary->expblock);
25 $form[$vocabulary->vid]['depth'] = array('#type' => 'select', '#default_value' => is_null($vocabulary->depth) ? 0 : $vocabulary->depth, '#options' => array('0' => t('None'), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => 'All'));
26 }
27
28 $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
29 return $form;
30 }
31
32 /**
33 * Theme the taxonomy dhtml admin as a sortable list of vocabularies.
34 *
35 * @ingroup themeable
36 * @see taxonomy_dhtml_admin()
37 */
38 function theme_taxonomy_dhtml_admin($form) {
39 $rows = array();
40 foreach (element_children($form) as $key) {
41 if (isset($form[$key]['name'])) {
42 $vocabulary = &$form[$key];
43
44 $row = array();
45 $row[] = drupal_render($vocabulary['name']);
46 $row[] = drupal_render($vocabulary['noi']);
47 $row[] = drupal_render($vocabulary['depth']);
48 $row[] = drupal_render($vocabulary['exposeBlock']);
49 $rows[] = array('data' => $row, 'class' => 'draggable');
50 }
51 }
52 if (empty($rows)) {
53 $rows[] = array(array('data' => t('No vocabularies available.'), 'colspan' => '3'));
54 }
55
56 $header = array(t('Name'), t('Number of items to display'), t('Depth'), t('Expose Block'));
57 return theme('table', $header, $rows, array('id' => 'taxonomy')) . drupal_render($form);
58 }
59
60 /**
61 * Submit handler for the taxonomy dhtml settings form.
62 *
63 *
64 * @see taxonomy_dhtml_admin()
65 */
66 function taxonomy_dhtml_admin_submit($form, &$form_state) {
67 foreach (array_keys($form_state['values']) as $ak) {
68 if (is_array($form_state['values'][$ak])) {
69 db_query("DELETE FROM {taxonomy_dhtml} WHERE vid=%d", $ak);
70 db_query("INSERT INTO {taxonomy_dhtml} (vid, noi, depth, expblock) VALUES (%d, %d, %d, %d)", $ak, $form_state['values'][$ak]['noi'], $form_state['values'][$ak]['depth'], $form_state['values'][$ak]['exposeBlock']);
71 }
72 }
73 cache_clear_all();
74 drupal_set_message('Taxonomy DHTML settings saved.');
75 }

  ViewVC Help
Powered by ViewVC 1.1.2