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

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

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


Revision 1.2 - (show annotations) (download) (as text)
Mon May 18 19:59:49 2009 UTC (6 months, 1 week ago) by sutharsan
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +5 -5 lines
File MIME type: text/x-php
#330656 by Sutharsan: Improved description texts on various forms.
1 <?php
2 // $Id: headerimage.admin.inc,v 1.1 2008/04/07 07:46:01 sutharsan Exp $
3
4 /**
5 * @file headerimage.admin.inc
6 * @see headerimage.module
7 */
8
9 /**
10 * Overview of all image blocks
11 */
12 function headerimage_settings_block_add() {
13 $blocks = headerimage_get_blocks();
14
15 // Table of image sets
16 $rows = array();
17 foreach ($blocks as $delta => $block) {
18 $rows[] = array(
19 'name' => check_plain($block),
20 'edit' => l(t('Edit'), "admin/settings/headerimage/edit/$delta"),
21 'delete' => l(t('Delete'), "admin/settings/headerimage/delete/$delta"),
22 'block' => l(t('Configure block'), "admin/build/block/configure/headerimage/$delta"),
23 );
24 }
25 if (empty($rows)) {
26 $rows[] = array(array('data' => t('No Header Image blocks available.'), 'colspan' => '4'));
27 }
28 $header = array(t('Name'), array('data' => t('Operation'), 'colspan' => '3'));
29 $output = theme('table', $header, $rows, array('id' => 'imageblock'));
30
31 $form = array();
32 $form['list'] = array(
33 '#type' => 'fieldset',
34 '#title' => t('Header Image blocks'),
35 );
36 $form['list']['table'] = array(
37 '#prefix' => '<div>',
38 '#value' => $output,
39 '#suffix' => '</div>',
40 );
41 $form['block'] = array(
42 '#type' => 'fieldset',
43 '#title' => t('Add Header Image block'),
44 );
45 $form['block']['title'] = array(
46 '#type' => 'textfield',
47 '#title' => t('Block title'),
48 '#description' => t('A block with this same name will be created. Header Image nodes assigned to this block will be displayed in it.'),
49 '#default_value' => '',
50 '#required' => true,
51 );
52 $form['block']['op'] = array(
53 '#type' => 'submit',
54 '#value' => t('Add block'),
55 );
56
57 return $form;
58 }
59
60 function headerimage_settings_block_add_validate($form, &$form_state) {
61 $blocks = headerimage_get_blocks();
62
63 if (!empty($blocks)) {
64 // Check if name is unique
65 if (in_array($form_state['values']['title'], $blocks)) {
66 form_set_error('', t('Header Image block %s already exists. Please use a different name.', array('%s' => $form_state['values']['title'])));
67 }
68 }
69 }
70
71 function headerimage_settings_block_add_submit($form, &$form_state) {
72 db_query("INSERT INTO {headerimage_block} (title) VALUES ('%s')", $form_state['values']['title']);
73
74 drupal_set_message(t('Header Image block %s added.', array('%s' => $form_state['values']['title'])));
75 }
76
77 /**
78 * Header Image settings form
79 */
80 function headerimage_settings_form() {
81 $form = array();
82 $nodes = node_get_types();
83 foreach ($nodes as $node) {
84 $nodetype[$node->type] = check_plain($node->name);
85 }
86
87 $form['headerimage_node_type'] = array(
88 '#type' => 'checkboxes',
89 '#title' => t('Content type'),
90 '#description' => t('The selected content type(s) can be displayed in a Header Image block.'),
91 '#default_value' => variable_get('headerimage_node_type', array()),
92 '#options' => $nodetype,
93 '#multiple' => true,
94 '#required' => true,
95 );
96
97 $form['headerimage_condition_types'] = array(
98 '#type' => 'checkboxes',
99 '#title' => t('Condition types'),
100 '#description' => t('These conditions can be used to contol the display of the content type(s) selected above.'),
101 '#default_value' => variable_get('headerimage_condition_types', array('nid')),
102 '#options' => headerimage_get_condition_types(),
103 '#required' => true,
104 );
105
106 $form['headerimage_teaser'] = array(
107 '#type' => 'checkbox',
108 '#title' => t('Teaser'),
109 '#description' => t('When checked the Header Image content types will be displayed as teaser, if not selected it will be displayed as full node.'),
110 '#default_value' => variable_get('headerimage_teaser', true),
111 );
112
113 return system_settings_form($form);
114 }
115
116 /**
117 * Delete block form
118 */
119 function headerimage_block_confirm_delete(&$form_state, $delta) {
120 $blocks = headerimage_get_blocks();
121 $form['delta'] = array('#type' => 'value', '#value' => $delta);
122 $form['#redirect'] = 'admin/settings/headerimage';
123 return confirm_form(
124 $form,
125 t('Are you sure you want to delete the block %title?', array('%title' => $blocks[$delta])),
126 'admin/settings/headerimage',
127 t('All Header Image assignments to this block will be deleted, the nodes will not be deleted. This action cannot be undone.'),
128 t('Delete'), t('Cancel')
129 );
130 }
131
132 function headerimage_block_confirm_delete_submit($form, &$form_state) {
133 db_query("DELETE from {headerimage_block} WHERE delta = %d", $form_state['values']['delta']);
134 db_query("DELETE from {headerimage} WHERE block = %d", $form_state['values']['delta']);
135
136 drupal_set_message(t('Header Image block deleted'));
137 return 'admin/settings/headerimage';
138 }
139
140
141 ?>

  ViewVC Help
Powered by ViewVC 1.1.2