-
Notifications
You must be signed in to change notification settings - Fork 0
/
asc_footer.module
145 lines (128 loc) · 3.48 KB
/
asc_footer.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
<?php
/**
* @file
* Module to supply footer icons for ASC Sites.
*/
/**
* @defgroup asc_footer
* Module to supple field to add OPIC image.
*
* And finally, our module defines the widet in
* opic_field_widget_info() and field_example_field_widget_form().
* The widget is the form element used to receive input from the user
* when the field is being populated.
*
* @see field_types
* @see field
*/
/**
* Implements hook_menu().
*
* Provides a simple user interface that tells the developer where to go.
*/
function asc_footer_menu() {
$items['admin/config/asc_footer'] = array(
'title' => 'ASC Footer',
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('asc_footer_form'),
'access arguments' => array('administer asc_footer'),
);
return $items;
}
/*
* Implements hook_permission()
*/
function asc_footer_permission() {
return array(
'administer asc_footer' => array(
'title' => t('Administer ASC Footer'),
'description' => t('Update sitewide footer.'),
),
);
}
/**
* Admin form for asc footer.
*/
function asc_footer_form($form_state) {
$form = array();
$fields = asc_footer_get_fields();
foreach ($fields as $field => $value) {
$form[$field] = array(
'#title' => $field,
'#description' => $field,
'#type' => 'textfield',
'#default_value' => $value,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
function asc_footer_get_fields() {
$prefix = 'asc_footer_';
$fields = array(
'Address_1' => variable_get($prefix . 'Address_1'),
'Address_2' => variable_get($prefix . 'Address_2'),
'City' => variable_get($prefix . 'City'),
'State' => variable_get($prefix . 'State'),
'Zip' => variable_get($prefix . 'Zip'),
'Phone' => variable_get($prefix . 'Phone'),
'Fax' => variable_get($prefix . 'Fax'),
'E_mail' => variable_get($prefix . 'E_mail'),
'Link_1_Text' => variable_get($prefix . 'Link_1_Text'),
'Link_1_Description' => variable_get($prefix . 'Link_1_Desc'),
'Link_1_URL' => variable_get($prefix . 'Link_1_URL'),
'Link_2_Text' => variable_get($prefix . 'Link_2_Text'),
'Link_2_Description' => variable_get($prefix . 'Link_2_Desc'),
'Link_2_URL' => variable_get($prefix . 'Link_2_URL'),
'Link_3_Text' => variable_get($prefix . 'Link_3_Text'),
'Link_3_Description' => variable_get($prefix . 'Link_3_Desc'),
'Link_3_URL' => variable_get($prefix . 'Link_3_URL'),
);
return $fields;
}
/**
* Form submission
*/
function asc_footer_form_submit(&$form, &$form_state){
$fields = asc_footer_get_fields();
foreach ($fields as $field => $value) {
variable_set('asc_footer_' . $field, $form_state['values'][$field]);
}
drupal_set_message('Your settings have been saved.');
}
/*
* Implements hook_block_info
*/
function asc_footer_block_info() {
$blocks['asc_footer'] = array(
'info' => 'ASC Footer',
'weight' => '-10',
'region' => 'footer_first',
'status' => 'true',
'cache' => DRUPAL_CACHE_GLOBAL,
);
return $blocks;
}
/*
* Implements hook_block_view
*/
function asc_footer_block_view($delta = '') {
$block['subject'] = '';
$fields = asc_footer_get_fields();
$block['content'] = theme('asc_footer_block', $fields);
return $block;
}
/*
* Implements hook_theme
*/
function asc_footer_theme() {
return array(
'asc_footer_block' => array(
'template' => 'asc_footer_block',
),
);
}