Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit cef4eb4

Browse files
committed
Merge pull request #5454 from DFurnes/global-footer
Global footer
2 parents 6f44672 + d9c51f3 commit cef4eb4

File tree

4 files changed

+80
-43
lines changed

4 files changed

+80
-43
lines changed

lib/modules/dosomething/dosomething_global/dosomething_global.module

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function _dosomething_global_get_regional_roles() {
163163
}
164164

165165
/**
166-
* Returns the user's langauge based on the role.
166+
* Returns the user's language based on the role.
167167
*
168168
* @param Object $user
169169
* Optional - A specified user to check
@@ -214,6 +214,19 @@ function dosomething_global_get_user_language($user = NULL) {
214214
return $countries;
215215
}
216216

217+
/**
218+
* Returns the session's country code, or `global` if it's not
219+
* one of our whitelisted global countries.
220+
*/
221+
function dosomething_global_get_country() {
222+
$country_code = dosomething_settings_get_geo_country_code();
223+
if (in_array($country_code, dosomething_global_get_countries())) {
224+
return $country_code;
225+
}
226+
227+
return 'global';
228+
}
229+
217230
/**
218231
* Gets the country from a given language.
219232
*

lib/themes/dosomething/paraneue_dosomething/includes/preprocess.inc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,29 @@ function paraneue_dosomething_preprocess_page(&$vars) {
181181
* Global Page Footer
182182
*/
183183

184+
$country = dosomething_global_get_country();
184185
$columns = array('first', 'second', 'third');
185186
$footer_links = array();
186187

187188
foreach($columns as $column) {
188-
$prefix = "footer_links_" . $column . "_column_";
189+
$prefix = "footer_links_" . $country . '_' . $column . "_column_";
189190
$footer_links[$column] = array();
190-
$footer_links[$column]['heading'] = theme_get_setting($prefix . "heading");
191191

192-
$links = explode("\n", trim(theme_get_setting($prefix . "links")));
192+
// Get new country code setting if it exists, if not fallback to old setting.
193+
// @TODO: Remove this after we've updated theme settings everywhere.
194+
$heading_setting = theme_get_setting($prefix . 'heading');
195+
if(!$heading_setting === NULL) {
196+
$heading_setting = theme_get_setting('footer_links_' . $column . '_column_heading');
197+
}
198+
$footer_links[$column]['heading'] = $heading_setting;
199+
200+
// Get new country code setting if it exists, if not fallback to old setting.
201+
// @TODO: Remove this after we've updated theme settings everywhere.
202+
$links_setting = theme_get_setting($prefix . 'links');
203+
if(!$links_setting === NULL) {
204+
$links_setting = theme_get_setting('footer_links_' . $column . '_column_links');
205+
}
206+
$links = explode("\n", trim($links_setting));
193207
$links = array_filter($links); // Remove empty items
194208

195209
foreach($links as &$link) {

lib/themes/dosomething/paraneue_dosomething/paraneue_dosomething.info

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ settings[footer_links_first_column_heading] = 'Help'
4747
settings[footer_links_first_column_links] = 'Contact Us|node/516
4848
Hotlines|node/518
4949
FAQs|node/1052'
50-
settings[footer_links_first_column_class] = 'help'
5150
settings[footer_links_second_column_heading] = 'Get to Know Us'
5251
settings[footer_links_second_column_links] = 'Partners|node/532
5352
Donate|node/539
5453
TMI Agency|http://www.tmiagency.org'
55-
settings[footer_links_second_column_class] = 'knowus'
5654
settings[footer_links_third_column_heading] = 'About'
5755
settings[footer_links_third_column_links] = 'What is DoSomething.org?|node/538
5856
Our Team|node/1044
@@ -61,7 +59,6 @@ Internships|node/940
6159
Old People|node/329
6260
Sexy Financials|node/540
6361
International|node/523'
64-
settings[footer_links_third_column_class] = 'about'
6562

6663
; User
6764
settings[user_validate_js_postcode] = 1

lib/themes/dosomething/paraneue_dosomething/theme-settings.php

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -272,46 +272,59 @@ function _paraneue_dosomething_theme_settings_footer(&$form, $form_state) {
272272
);
273273

274274
$links = &$form['footer']['links'];
275-
$columns = array('first', 'second', 'third');
276-
foreach ($columns as $column) {
277-
$prefix = 'footer_links_' . $column;
278275

279-
$links[$prefix] = array(
276+
// Set up theme settings for each country's footer
277+
$countries = dosomething_global_get_countries();
278+
foreach($countries as $country) {
279+
$links[$country. '_links'] = [
280280
'#type' => 'fieldset',
281-
'#title' => t(ucwords($column) .' column'),
281+
'#title' => t('@country Links', ['@country' => $country]),
282282
'#collapsible' => TRUE,
283-
'#collapsed' => TRUE
284-
);
285-
286-
$link_column = &$links[$prefix];
287-
288-
$link_column[$prefix . '_column_heading'] = array(
289-
'#type' => 'textfield',
290-
'#title' => t(ucwords($column) . ' Column Heading'),
291-
'#default_value' => theme_get_setting('footer_links_' . $column . '_column_heading')
292-
);
293-
294-
$link_column[$prefix . '_column_links'] = array(
295-
'#type' => 'textarea',
296-
'#title' => t(ucwords($column) . ' Column Links'),
297-
'#default_value' => theme_get_setting('footer_links_' . $column . '_column_links')
298-
);
299-
300-
$link_column[$prefix. '_advanced'] = array(
301-
'#type' => 'fieldset',
302-
'#title' => t('Advanced options'),
303-
'#collapsible' => TRUE,
304-
'#collapsed' => TRUE
305-
);
306-
307-
$link_column[$prefix . '_advanced'][$prefix . '_column_class'] = array(
308-
'#type' => 'textfield',
309-
'#title' => t(ucwords($column) . ' Column Class'),
310-
'#default_value' => theme_get_setting('footer_links_' . $column . '_column_class')
311-
);
283+
'#collapsed' => TRUE,
284+
];
285+
286+
// Set up theme settings for each of the three columns
287+
$columns = ['first', 'second', 'third'];
288+
foreach ($columns as $column) {
289+
$prefix = 'footer_links_' . $country . '_' . $column;
290+
291+
$links[$country. '_links'][$prefix] = [
292+
'#type' => 'fieldset',
293+
'#title' => t(ucwords($column) .' column'),
294+
'#collapsible' => TRUE,
295+
'#collapsed' => TRUE,
296+
];
297+
298+
$link_column = &$links[$country. '_links'][$prefix];
299+
300+
// Get new country code setting if it exists, if not fallback to old setting.
301+
// @TODO: Remove this after we've updated theme settings everywhere.
302+
$heading_default = theme_get_setting('footer_links_' . $country . '_' . $column . '_column_heading');
303+
if(!$heading_default === NULL) {
304+
$heading_default = theme_get_setting('footer_links_' . $column . '_column_heading');
305+
}
306+
307+
$link_column[$prefix . '_column_heading'] = [
308+
'#type' => 'textfield',
309+
'#title' => t(ucwords($country) . ' ' . ucwords($column) . ' Column Heading'),
310+
'#default_value' => $heading_default,
311+
];
312+
313+
// Get new country code setting if it exists, if not fallback to old setting.
314+
// @TODO: Remove this after we've updated theme settings everywhere.
315+
$links_default = theme_get_setting('footer_links_' . $country . '_' . $column . '_column_links');
316+
if(!$links_default === NULL) {
317+
$links_default = theme_get_setting('footer_links_' . $column . '_column_links');
318+
}
319+
320+
$link_column[$prefix . '_column_links'] = [
321+
'#type' => 'textarea',
322+
'#title' => t(ucwords($country) . ' ' . ucwords($column) . ' Column Links'),
323+
'#default_value' => $links_default,
324+
];
325+
}
312326

313327
}
314-
315328
}
316329

317330
function _paraneue_dosomething_theme_settings_user(&$form, $form_state) {
@@ -321,7 +334,7 @@ function _paraneue_dosomething_theme_settings_user(&$form, $form_state) {
321334
);
322335
$form_user = &$form['user'];
323336

324-
// Validaions.
337+
// Validations.
325338
$form_user['validations'] = array(
326339
'#type' => 'fieldset',
327340
'#title' => t('JS Validations'),

0 commit comments

Comments
 (0)