Commit bd540954 authored by Eric Bremner's avatar Eric Bremner
Browse files

FDSU-1804: Adding credentials to the virtual site header.

parent f9bcb2a4
......@@ -10,6 +10,35 @@
function uw_virtual_site_homepage_field_default_field_bases() {
$field_bases = array();
// Exported field_base: 'field_uw_credentials'
$field_bases['field_uw_credentials'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_credentials',
'foreign keys' => array(
'format' => array(
'columns' => array(
'format' => 'format',
),
'table' => 'filter_format',
),
),
'indexes' => array(
'format' => array(
0 => 'format',
),
),
'locked' => 0,
'module' => 'text',
'settings' => array(
'max_length' => 255,
),
'translatable' => 0,
'type' => 'text',
);
// Exported field_base: 'field_uw_email_homepage'
$field_bases['field_uw_email_homepage'] = array(
'active' => 1,
......
......@@ -10,6 +10,76 @@
function uw_virtual_site_homepage_field_default_field_instances() {
$field_instances = array();
// Exported field_instance: 'node-uw_virtual_site_homepage-field_uw_credentials'
$field_instances['node-uw_virtual_site_homepage-field_uw_credentials'] = array(
'bundle' => 'uw_virtual_site_homepage',
'default_value' => NULL,
'deleted' => 0,
'description' => 'Enter your credentials. This will appear under the site title at the top of every page. (i.e. PhD Computer Science). Leave blank if not to be displayed.',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
'weight' => 11,
),
'links' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'no_image_teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'sidebar_teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'slide_teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'title' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'field_uw_credentials',
'label' => 'Credentials',
'required' => 0,
'settings' => array(
'text_processing' => 0,
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'text',
'settings' => array(
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 1,
),
);
// Exported field_instance: 'node-uw_virtual_site_homepage-field_uw_email_homepage'
$field_instances['node-uw_virtual_site_homepage-field_uw_email_homepage'] = array(
'bundle' => 'uw_virtual_site_homepage',
......@@ -76,7 +146,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 7,
'weight' => 8,
),
);
......@@ -146,7 +216,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 6,
'weight' => 7,
),
);
......@@ -216,7 +286,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 3,
'weight' => 4,
),
);
......@@ -286,7 +356,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'rows' => 5,
),
'type' => 'text_textarea',
'weight' => 8,
'weight' => 9,
),
);
......@@ -356,7 +426,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 4,
'weight' => 5,
),
);
......@@ -426,7 +496,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 5,
'weight' => 6,
),
);
......@@ -526,7 +596,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'progress_indicator' => 'throbber',
),
'type' => 'image_image',
'weight' => 1,
'weight' => 2,
),
);
......@@ -601,7 +671,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'summary_rows' => 5,
),
'type' => 'text_textarea_with_summary',
'weight' => 2,
'weight' => 3,
),
);
......@@ -689,7 +759,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'module' => 'og',
'settings' => array(),
'type' => 'og_complex',
'weight' => 12,
'weight' => 10,
),
);
......@@ -757,14 +827,16 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'module' => 'og_vocab',
'settings' => array(),
'type' => 'og_vocab_complex',
'weight' => 31,
'weight' => 13,
),
);
// Translatables
// Included for use with string extractors like potx.
t('Credentials');
t('Email');
t('Enter the location of your office (i.e., NH 101).');
t('Enter your credentials. This will appear under the site title at the top of every page. (i.e. PhD Computer Science). Leave blank if not to be displayed.');
t('Enter your email address (i.e., john.doe@uwaterloo.ca).');
t('Enter your faculty or department.');
t('Enter your office hours. (i.e., Mondays, Wednesday and Fridays 10:30 am to 11:45 am).');
......
......@@ -21,6 +21,7 @@ dependencies[] = vsite_vocab
features[ctools][] = strongarm:strongarm:1
features[ctools][] = views:views_default:3.0
features[features_api][] = api:2
features[field_base][] = field_uw_credentials
features[field_base][] = field_uw_email_homepage
features[field_base][] = field_uw_extension
features[field_base][] = field_uw_faculty
......@@ -29,6 +30,7 @@ features[field_base][] = field_uw_office_location
features[field_base][] = field_uw_phone_number
features[field_base][] = field_uw_profile_image
features[field_base][] = field_uw_site_description
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_credentials
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_email_homepage
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_extension
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_faculty
......
......@@ -6,6 +6,10 @@
include_once 'uw_virtual_site_homepage.features.inc';
/**
* Implements hook_form_FORM_ID_alter().
* FORM_ID = uw_virtual_site_homepage_node_form (edit virtual site homepage).
*/
function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(&$form, &$form_state, $form_id) {
global $base_path;
......@@ -62,7 +66,7 @@ function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(
// Adding the site title to the form. This is at the top of every page.
$form['site_info']['site_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#title' => t('Name'),
'#default_value' => $node->title,
'#description' => t('Enter your name as the title of your site. This will appear at the top of every page (i.e., Dr John Doe).'),
'#size' => 60,
......@@ -80,12 +84,15 @@ function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(
// Adding the site description to the page. This is just below the site title and on every page.
$form['site_info']['descrip'] = array(
'#type' => 'textfield',
'#title' => t('Subtitle'),
'#title' => t('Title'),
'#default_value' => $default_value,
'#description' => t('Enter your academic role, position or title. This will appear under the site title at the top of every page. (i.e., Professor of Economics).'),
'#size' => 60,
);
$form['site_info']['field_uw_credentials'] = $form['field_uw_credentials'];
unset($form['field_uw_credentials']);
// Adding the site information submit callback.
$form['actions']['submit']['#submit'][] = 'uw_vitual_site_homepage_site_information_form_submit';
......@@ -93,6 +100,18 @@ function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(
$form['actions']['submit']['#submit'][] = 'uw_virtual_site_homepage_node_form_redirect';
}
/**
* Implements hook_page_alter().
* Add credentials to header if present.
*/
function uw_virtual_site_homepage_page_alter(&$page) {
// If there is credentials in the virutal site homepage settings, add it to the header.
if(isset($page['uw-virtual-site-homepage']['field_uw_credentials'])) {
$page['header_second']['boxes_site_info']['content']['#markup'] = preg_replace('/<p>(.*)<a(.*)<\/a>/s', '<h2>' . $page['uw-virtual-site-homepage']['field_uw_credentials'][0]['#markup'] . '</h2>', $page['header_second']['boxes_site_info']['content']['#markup']);
}
}
/**
* Submit callback.
* Saves site title and site description.
......@@ -112,6 +131,11 @@ function uw_vitual_site_homepage_site_information_form_submit($form, &$form_stat
'format' => NULL,
);
$node->field_uw_credentials[LANGUAGE_NONE][0] = array(
'value' => $form_state['value']['field_uw_credentials'],
'format' => NULL,
);
// Ensuring that we get a save of the node which is the users vsite.
try {
node_save($node);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment