Commit 33dad8f7 authored by Liam Morland's avatar Liam Morland
Browse files

Coding standards

parent 693a5dcd
/*** uw_virtual_site_homepage form ***/
#uw-virtual-site-homepage-node-form #edit-options {
display: none;
display: none;
}
#edit-actions-top {
display: none;
display: none;
}
/* Biblio settings */
.citation-example-wrapper {
margin-top: 10px;
background-color: white;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
padding-right: 10px;
margin-top: 10px;
background-color: white;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
padding-right: 10px;
}
#edit-field-uw-homepage-banners .image-widget-data input[id*="remove-button"] {
display: none;
display: none;
}
/**
* @file
*/
(function ($) {
Drupal.behaviors.uw_virtual_site_homepage = {
......@@ -5,8 +9,8 @@
attach: function (context, settings) {
// RT#615890: Fixing extra space at the end of some names.
$(document).ready(function() {
$('.biblio-entry span.biblio-authors').each(function() {
$(document).ready(function () {
$('.biblio-entry span.biblio-authors').each(function () {
str = $(this).html();
str = str.replace(/\s*$/,"");
$(this).html(str);
......@@ -14,10 +18,10 @@
});
// Get all descriptions for the links in homepage banners.
$('#edit-field-uw-homepage-banners #field-uw-homepage-banners-values .field-name-field-uw-homepage-banners-link .description').each(function(index) {
$('#edit-field-uw-homepage-banners #field-uw-homepage-banners-values .field-name-field-uw-homepage-banners-link .description').each(function (index) {
// If we are on the Enter a link that you image will go to description, move it.
if($(this).html() == "Enter a link that your image will go to.") {
if ($(this).html() == "Enter a link that your image will go to.") {
// Move the div to under the URL link textbox.
$(this).appendTo($(this).parent().find('.link-field-url'));
......@@ -25,7 +29,7 @@
});
// If there is a biblio header remove the [ and ].
if($('#content #biblio-header').length > 0) {
if ($('#content #biblio-header').length > 0) {
// Remove the [ and ] from the biblio sort links.
var oldhtml = $('#content #biblio-header').html();
......@@ -34,19 +38,19 @@
$('#content #biblio-header').html(newhtml);
}
if($('.biblio-filter-status').length > 0) {
if ($('.biblio-filter-status').length > 0) {
$('#biblio-search-form').append($('.biblio-filter-status'));
}
// If there is a twitter feed in the sidebar, set the max-height to the height of the content, only if the content height is larger than the preset max-height.
if($('.twitter-sidebar-wrapper').length > 0) {
if($('#content').length > 0) {
if ($('.twitter-sidebar-wrapper').length > 0) {
if ($('#content').length > 0) {
if ($('#content').height() > $('.twitter-sidebar-wrapper').css('max-height').replace('px', '')) {
$('.twitter-sidebar-wrapper').css('max-height', $('#content').height() + 'px');
}
}
if($('.personal_frontpage_uw_scholar').length > 0) {
if ($('.personal_frontpage_uw_scholar').length > 0) {
if ($('.personal_frontpage_uw_scholar').height() > $('.twitter-sidebar-wrapper').css('max-height').replace('px', '')) {
$('.twitter-sidebar-wrapper').css('max-height', $('.personal_frontpage_uw_scholar').height() + 'px');
}
......@@ -54,4 +58,4 @@
}
}
};
})(jQuery);
\ No newline at end of file
})(jQuery);
<?php
/**
* @file
* uw_virtual_site_homepage.features.conditional_fields.inc
......
<?php
/**
* @file
* uw_virtual_site_homepage.features.field_base.inc
......
<?php
/**
* @file
* uw_virtual_site_homepage.features.field_instance.inc
......
<?php
/**
* @file
* uw_virtual_site_homepage.features.inc
......
<?php
/**
* @file
* uw_virtual_site_homepage.features.user_permission.inc
......
<?php
/**
* @file
* uw_virtual_site_homepage.field_group.inc
......
<?php
/*
/**
* @file
*/
/**
* Implements hook_update_dependencies().
*
* Setting the order of update hooks so that uw_virtual_site_homepage_update_7100 runs first.
*/
function uw_virtual_site_homepage_update_dependencies() {
// Indicate that the uw_virtual_site_homepage_update_7100() function provided by this module
// must run before the one of the os_profiles_update_N() function provided by the 'os_profiles' module.
$dependencies['os_profiles'][7045] = array(
'uw_virtual_site_homepage' => 7100,
);
......@@ -31,16 +35,15 @@ function uw_virtual_site_homepage_update_dependencies() {
/**
* Implements hook_update_N().
*
* Changing Office Hours field name and instance for virtual homepages.
*/
function uw_virtual_site_homepage_update_7100() {
// There is a conflict with os_profiles and uw_virtual_site_homepage for the field: field_office_hours.
// We are going to change our custom module: uw_virtual_site_homepage, to use a field with name: field_uw_office_hours.
// New field and instances will have to be created, all content migrated, all old instances removed.
// Set variables, changing the below fields for uw homepage virtual sites.
// Profile image, Site description, Faculty, Office location, Phone number, Extension, Email and Office hours.
$entity_type = 'node';
$bundle = 'uw_virtual_site_homepage';
......@@ -60,10 +63,10 @@ function uw_virtual_site_homepage_update_7100() {
// If this is the body, special new name, else insert uw into old field name.
if ($old_name == 'body') {
$new_name = 'field_uw_site_description';
$new_name = 'field_uw_site_description';
}
else {
$new_name = str_replace("field", "field_uw", $old_name);
$new_name = str_replace("field", "field_uw", $old_name);
}
// Get old fields' data.
......@@ -103,26 +106,26 @@ function uw_virtual_site_homepage_update_7100() {
}
// As long as not body, delete the old field.
if($old_name !== 'body') {
if ($old_name !== 'body') {
field_delete_field($old_name);
}
// If there is no new field, create the new field.
if(!db_table_exists('field_data_' . $new_name)) {
if (!db_table_exists('field_data_' . $new_name)) {
$new_field = _get_new_field($new_name);
field_create_field($new_field);
}
// Get the old instance.
$check_old_instance = db_select('field_config_instance', 'fc')
->fields('fc')
->condition('field_name', $old_name)
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->execute()->fetchAll();
->fields('fc')
->condition('field_name', $old_name)
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->execute()->fetchAll();
// If there is an old instance, delete it.
if(count($check_old_instance) > 0) {
if (count($check_old_instance) > 0) {
$instance['field_name'] = $old_name;
$instance['entity_type'] = $entity_type;
$instance['bundle'] = $bundle;
......@@ -130,28 +133,28 @@ function uw_virtual_site_homepage_update_7100() {
}
// Step through each of the old fields data and set it to the new fields data.
foreach($data_new as $data) {
foreach ($data_new as $data) {
// If there is a new field, insert the old data.
if(db_table_exists('field_data_' . $new_name)) {
if (db_table_exists('field_data_' . $new_name)) {
// Get the data from the new field.
$check_for_field = db_select('field_data_' . $new_name, 'data')
->fields('data');
foreach($data as $key => $value) {
->fields('data');
foreach ($data as $key => $value) {
$check_for_field->condition($key, $value);
}
$results = $check_for_field->execute();
// Check if there is data from the old field in the new field.
$insert = true;
while($record = $results->fetchAssoc()) {
$insert = false;
$insert = TRUE;
while ($record = $results->fetchAssoc()) {
$insert = FALSE;
break;
}
// If there is no data from old field in new field, insert the old field data into the new field.
if($insert) {
if ($insert) {
db_insert('field_data_' . $new_name)
->fields($data)
->execute();
......@@ -160,28 +163,28 @@ function uw_virtual_site_homepage_update_7100() {
}
// Step through each old revision and set it to the new revision.
foreach($revision_new as $revision) {
foreach ($revision_new as $revision) {
// If there is a new revision, insert the old revision.
if(db_table_exists('field_revision_' . $new_name)) {
if (db_table_exists('field_revision_' . $new_name)) {
// Get the data from the new revision.
$check_for_revision = db_select('field_revision_' . $new_name, 'data')
->fields('data');
foreach($revision as $key => $value) {
->fields('data');
foreach ($revision as $key => $value) {
$check_for_field->condition($key, $value);
}
$results = $check_for_field->execute();
// Check if there is data from the old revision in the new revision.
$insert = true;
if($record = $results->fetchAssoc()) {
$insert = false;
$insert = TRUE;
if ($record = $results->fetchAssoc()) {
$insert = FALSE;
break;
}
// If there is no old revision in the new revision, insert the old revision in the new revision.
if($insert) {
if ($insert) {
db_insert('field_revision_' . $new_name)
->fields($revision)
->execute();
......@@ -196,12 +199,13 @@ function uw_virtual_site_homepage_update_7100() {
/**
* Implements hook_update_N().
*
* Convert the value from field_uw_faculty to field_uw_faculty_list.
* Remove field_uw_faculty field.
*/
function uw_virtual_site_homepage_update_7101() {
// Revert fields
// Revert fields.
features_revert(array('uw_virtual_site_homepage' => array('field_base', 'field_instance')));
// Convert the value from field_data_field_uw_faculty table to field_data_field_uw_faculty_list table.
......@@ -264,24 +268,26 @@ function uw_virtual_site_homepage_update_7101() {
/**
* Implements hook_update_N().
*
* Perform feature revert.
*/
function uw_virtual_site_homepage_update_7102() {
// Perform feature revert to place new instances of fields.
features_revert_module('uw_virtual_site_homepage');
// Perform feature revert to place new instances of fields.
features_revert_module('uw_virtual_site_homepage');
}
/**
* Implements hook_update_N().
*
* Perform feature revert.
*/
function uw_virtual_site_homepage_update_7103() {
// Perform feature revert to place new instances of fields.
features_revert_module('uw_virtual_site_homepage');
// Perform feature revert to place new instances of fields.
features_revert_module('uw_virtual_site_homepage');
}
/**
* Helper function to get the value from field_uw_faculty
* Helper function to get the value from field_uw_faculty.
*/
function _get_faculty_list_value($field_uw_faculty) {
$faculty_name = strtolower($field_uw_faculty);
......@@ -333,285 +339,285 @@ function _get_faculty_list_value($field_uw_faculty) {
}
/**
* Helper function to get the new field information
* Helper function to get the new field information.
*/
function _get_new_field($name) {
switch($name) {
switch ($name) {
case "field_uw_email_homepage":
$new_field = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_email_homepage',
'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',
);
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_email_homepage',
'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',
);
return $new_field;
case "field_uw_email_homepage":
$new_field = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_email_homepage',
'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',
);
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_email_homepage',
'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',
);
return $new_field;
case "field_uw_extension":
$new_field = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_extension',
'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',
);
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_extension',
'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',
);
return $new_field;
case "field_uw_faculty":
$new_field = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_faculty',
'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',
);
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_faculty',
'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',
);
return $new_field;
case "field_uw_office_hours":
$new_field = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_office_hours',
'foreign keys' => array(
'format' => array(
'columns' => array(
'format' => 'format',
),
'table' => 'filter_format',
),
),
'indexes' => array(
'format' => array(
0 => 'format',
),
),
'locked' => 0,
'module' => 'text',
'settings' => array(),
'translatable' => 0,
'type' => 'text_long',
);
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_office_hours',
'foreign keys' => array(
'format' => array(
'columns' => array(
'format' => 'format',