Social links and icons are now editables

This commit is contained in:
Manuel Cillero 2017-08-07 23:17:27 +02:00
parent ab55a69459
commit 7baa51d5a8
8 changed files with 89 additions and 33 deletions

View file

@ -1155,7 +1155,7 @@ function system_site_information_settings() {
$form['site_name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => variable_get('site_name', 'Drupal'),
'#default_value' => variable_get('site_name', 'SuiteDesk'),
'#description' => t('The name of this website.'),
'#required' => TRUE
);
@ -1178,6 +1178,36 @@ function system_site_information_settings() {
'#default_value' => variable_get('site_mission', ''),
'#description' => t("Your site's mission or focus statement (often prominently displayed on the front page).")
);
$form['site_twitter'] = array(
'#type' => 'textfield',
'#title' => t('Twitter URL'),
'#default_value' => variable_get('site_twitter', ''),
'#description' => t('URL address of your Twitter account.')
);
$form['site_facebook'] = array(
'#type' => 'textfield',
'#title' => t('Facebook URL'),
'#default_value' => variable_get('site_facebook', ''),
'#description' => t('URL address of your Facebook page.')
);
$form['site_linkedin'] = array(
'#type' => 'textfield',
'#title' => t('LinkedIn URL'),
'#default_value' => variable_get('site_linkedin', ''),
'#description' => t('URL address of your LinkedIn account.')
);
$form['site_contact'] = array(
'#type' => 'textfield',
'#title' => t('Web contact URL'),
'#default_value' => variable_get('site_contact', ''),
'#description' => t('URL address of your contact page.')
);
$form['site_rss'] = array(
'#type' => 'textfield',
'#title' => t('Feed URL'),
'#default_value' => variable_get('site_rss', ''),
'#description' => t('Source feed of your main website.')
);
$form['site_footer'] = array(
'#type' => 'textarea',
'#title' => t('Footer message'),
@ -1213,6 +1243,13 @@ function system_site_information_settings_validate($form, &$form_state) {
if ($error = user_validate_mail($form_state['values']['site_mail'])) {
form_set_error('site_mail', $error);
}
// Validate social links.
unset($_SESSION['socialmenu']);
_system_site_information_validate_url($form_state, 'site_twitter');
_system_site_information_validate_url($form_state, 'site_facebook');
_system_site_information_validate_url($form_state, 'site_linkedin');
_system_site_information_validate_url($form_state, 'site_contact');
_system_site_information_validate_url($form_state, 'site_rss');
// Validate front page path.
$item = array('link_path' => $form_state['values']['site_frontpage']);
$normal_path = drupal_get_normal_path($item['link_path']);
@ -1225,6 +1262,12 @@ function system_site_information_settings_validate($form, &$form_state) {
}
}
function _system_site_information_validate_url(&$form_state, $site_field) {
if (!empty($form_state['values'][$site_field]) && !valid_url($form_state['values'][$site_field], TRUE)) {
form_set_error($site_field, t("The path '@path' is not valid.", array('@path' => $form_state['values'][$site_field])));
}
}
/**
* Form builder; Configure error reporting settings.
*

View file

@ -1317,7 +1317,7 @@ function user_login(&$form_state) {
'#required' => TRUE,
);
$form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
$form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'SuiteDesk')));
$form['pass'] = array('#type' => 'password',
'#title' => t('Password'),
'#description' => t('Enter the password that accompanies your username.'),
@ -2184,7 +2184,7 @@ function user_mail_tokens($account, $language) {
global $base_url;
$tokens = array(
'!username' => $account->name,
'!site' => variable_get('site_name', 'Drupal'),
'!site' => variable_get('site_name', 'SuiteDesk'),
'!login_url' => user_pass_reset_url($account),
'!uri' => $base_url,
'!uri_brief' => preg_replace('!^https?://!', '', $base_url),