Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
wcms-openscholar
uw_virtual_site_homepage
Commits
33dad8f7
Commit
33dad8f7
authored
Oct 05, 2017
by
Liam Morland
Browse files
Coding standards
parent
693a5dcd
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
469 additions
and
443 deletions
+469
-443
css/uw_virtual_site_homepage.css
css/uw_virtual_site_homepage.css
+9
-9
js/uw_virtual_site_homepage.js
js/uw_virtual_site_homepage.js
+14
-10
uw_virtual_site_homepage.features.conditional_fields.inc
uw_virtual_site_homepage.features.conditional_fields.inc
+1
-0
uw_virtual_site_homepage.features.field_base.inc
uw_virtual_site_homepage.features.field_base.inc
+1
-0
uw_virtual_site_homepage.features.field_instance.inc
uw_virtual_site_homepage.features.field_instance.inc
+1
-0
uw_virtual_site_homepage.features.inc
uw_virtual_site_homepage.features.inc
+1
-0
uw_virtual_site_homepage.features.user_permission.inc
uw_virtual_site_homepage.features.user_permission.inc
+1
-0
uw_virtual_site_homepage.field_group.inc
uw_virtual_site_homepage.field_group.inc
+1
-0
uw_virtual_site_homepage.install
uw_virtual_site_homepage.install
+277
-271
uw_virtual_site_homepage.module
uw_virtual_site_homepage.module
+161
-153
uw_virtual_site_homepage.strongarm.inc
uw_virtual_site_homepage.strongarm.inc
+1
-0
uw_virtual_site_homepage.views_default.inc
uw_virtual_site_homepage.views_default.inc
+1
-0
No files found.
css/uw_virtual_site_homepage.css
View file @
33dad8f7
js/uw_virtual_site_homepage.js
View file @
33dad8f7
/**
* @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
'
);
}
...
...
uw_virtual_site_homepage.features.conditional_fields.inc
View file @
33dad8f7
<?php
/**
* @file
* uw_virtual_site_homepage.features.conditional_fields.inc
...
...
uw_virtual_site_homepage.features.field_base.inc
View file @
33dad8f7
<?php
/**
* @file
* uw_virtual_site_homepage.features.field_base.inc
...
...
uw_virtual_site_homepage.features.field_instance.inc
View file @
33dad8f7
<?php
/**
* @file
* uw_virtual_site_homepage.features.field_instance.inc
...
...
uw_virtual_site_homepage.features.inc
View file @
33dad8f7
<?php
/**
* @file
* uw_virtual_site_homepage.features.inc
...
...
uw_virtual_site_homepage.features.user_permission.inc
View file @
33dad8f7
<?php
/**
* @file
* uw_virtual_site_homepage.features.user_permission.inc
...
...
uw_virtual_site_homepage.field_group.inc
View file @
33dad8f7
<?php
/**
* @file
* uw_virtual_site_homepage.field_group.inc
...
...
uw_virtual_site_homepage.install
View file @
33dad8f7
<?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'
;
...
...
@@ -103,12 +106,12 @@ 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
);
}
...
...
@@ -122,7 +125,7 @@ function uw_virtual_site_homepage_update_7100() {
->
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
)
{
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
)
{
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,6 +268,7 @@ function uw_virtual_site_homepage_update_7101() {
/**
* Implements hook_update_N().
*
* Perform feature revert.
*/
function
uw_virtual_site_homepage_update_7102
()
{
...
...
@@ -273,6 +278,7 @@ function uw_virtual_site_homepage_update_7102() {
/**
* Implements hook_update_N().
*
* Perform feature revert.
*/
function
uw_virtual_site_homepage_update_7103
()
{
...
...
@@ -281,7 +287,7 @@ function uw_virtual_site_homepage_update_7103() {
}
/**
* 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,10 +339,10 @@ 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
,
...
...
uw_virtual_site_homepage.module
View file @
33dad8f7
<?php
/**
* @file
* Code for the UW Virtual Site Homepage feature.
...
...
@@ -8,12 +9,12 @@ include_once 'uw_virtual_site_homepage.features.inc';
/**
* Implements hook_module_implements_alter().
*
* Remove the os_publications query_biblio_alter.
*/
function
uw_virtual_site_homepage_module_implements_alter
(
&
$implementations
,
$hook
)
{
// If we are on the query_biblio_alter hook, unset os_publications and place uw_virtual_site_homepage last.
if
(
$hook
==
"query_biblio_alter"
)
{
if
(
$hook
==
"query_biblio_alter"
)
{
// Move uw_virtual_site_homepage's query_biblio_alter to be done last.
$group
=
$implementations
[
'uw_virtual_site_homepage'
];
unset
(
$implementations
[
'uw_virtual_site_homepage'
]);
...
...
@@ -26,6 +27,7 @@ function uw_virtual_site_homepage_module_implements_alter(&$implementations, $ho
/**
* Implements hook query_TAG_alter().
*
* TAG: biblio.
* Set the searching and sorting options for the biblio query and add the space.
*/
...
...
@@ -38,7 +40,7 @@ function uw_virtual_site_homepage_query_biblio_alter(QueryAlterableInterface $qu
_os_publications_filter_by_term
(
$query
);
//
t
his has to be separate because of scoping.
//
T
his has to be separate because of scoping.
if
(
$space
->
type
==
'og'
)
{
$query
->
innerJoin
(
'og_membership'
,
'ogm'
,
'n.nid = ogm.etid'
);
$query
->
condition
(
'ogm.entity_type'
,
'node'
);
...
...
@@ -49,17 +51,17 @@ function uw_virtual_site_homepage_query_biblio_alter(QueryAlterableInterface $qu
$item
=
menu_get_item
();
// Checking for search_node alter tag.
if
(
!
isset
(
$query
->
alterTags
))
{
if
(
!
isset
(
$query
->
alterTags
))
{
// Check if we have a search_node alter tag.
if
(
!
isset
(
$query
->
alterTags
[
'search_node'
]))
{
if
(
!
isset
(
$query
->
alterTags
[
'search_node'
]))
{
// Check the sort order for biblio.
// If we're sorting by year, we want to sort by date as well to replicate D6
// sorting.
if
(
variable_get
(
'biblio_sort'
,
'year'
)
==
'year'
)
{
// Get their sort order.
$biblio_year_sort
=
$space
->
controllers
->
variable
->
get
(
'biblio_order'
,
'space'
);
$biblio_year_sort
=
$space
->
controllers
->
variable
->
get
(
'biblio_order'
,
'space'
);
$order
=
&
$query
->
getOrderBy
();
// Don't wipe the non-default sort order, this will let users still toggle asc/desc sorting by year.
...
...
@@ -67,7 +69,7 @@ function uw_virtual_site_homepage_query_biblio_alter(QueryAlterableInterface $qu
$biblio_year_sort
=
$order
[
'biblio_year'
];
}
// Rebuild the array to our defaults only when the user is NOT searching. When the user is searching, use their selections
// Rebuild the array to our defaults only when the user is NOT searching. When the user is searching, use their selections
.
if
(
isset
(
$_GET
[
's'
])
&&
in_array
(
$_GET
[
's'
],
array
(
'author'
,
'title'
,
'type'
)))
{
$s
=
current
(
array_keys
(
$order
));
$o
=
current
(
$order
);
...
...
@@ -109,15 +111,16 @@ function uw_virtual_site_homepage_query_biblio_alter(QueryAlterableInterface $qu
}
}
/*
/*
*
* Implements hook_field_widget_form_alter().
*
* Adding process to image types to change title to caption for homepage banners.
*/
function
uw_virtual_site_homepage_field_widget_form_alter
(
&
$element
,
&
$form_state
,
$context
)
{
if
(
$context
[
'field'
][
'type'
]
==
'image'
)
{
foreach
(
element_children
(
$element
)
as
$key
=>
$child
)
{
if
(
$element
[
$key
][
'#description'
]
==
'Provide banner images for virtual site homepages on Scholar at Waterloo sites.'
)
{
if
(
$context
[
'field'
][
'type'
]
==
'image'
)
{
foreach
(
element_children
(
$element
)
as
$key
=>
$child
)
{
if
(
$element
[
$key
][
'#description'
]
==
'Provide banner images for virtual site homepages on Scholar at Waterloo sites.'
)
{
$element
[
$key
][
'#process'
][]
=
'uw_virtual_site_homepage_image_field_widget_process'
;
}
}
...
...
@@ -126,19 +129,20 @@ function uw_virtual_site_homepage_field_widget_form_alter(&$element, &$form_stat
/**
* Implements hook_image_field_widget_process().
*
* Processing images to change title to caption for homepage banners.
*/
function
uw_virtual_site_homepage_image_field_widget_process
(
$element
,
&
$form_state
,
$form
)
{
// Set the title to be the caption and the description.
//$element['title']['#title'] = 'Caption';
$element
[
'title'
][
'#description'
]
=
'The title is display with the picture.'
;
// Return the altered element
// Return the altered element
.
return
$element
;
}
/**
* Implements hook_page_alter().
*
* Placing homepage banners on the virtual site homepage.
*/
function
uw_virtual_site_homepage_page_alter
(
&
$page
)
{
...
...
@@ -146,9 +150,9 @@ function uw_virtual_site_homepage_page_alter(&$page) {
// Setting the variables to be used in homepage banners.
$index
=
0
;
$continue
=
true
;
$continue
=
TRUE
;
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_faculty_list_logo'
][
0
][
'#markup'
]))
{
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_faculty_list_logo'
][
0
][
'#markup'
]))
{
$site_links
=
_uw_virtual_site_homepage_get_site_links
();
if
(
isset
(
$site_links
[
$page
[
'uw-virtual-site-homepage'
][
'field_uw_faculty_list_logo'
][
0
][
'#markup'
]]))
{
$site_link
=
$site_links
[
$page
[
'uw-virtual-site-homepage'
][
'field_uw_faculty_list_logo'
][
0
][
'#markup'
]];
...
...
@@ -157,9 +161,9 @@ function uw_virtual_site_homepage_page_alter(&$page) {
}
// If there are banners, process them.
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
]))
{
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
]))
{
//
html
divs in homepage banners.
//
HTML
divs in homepage banners.
$html
=
'<div class="field-name-field-uw-home-page-banners">'
;
$html
.
=
'<div class="field-items">'
;
...
...
@@ -168,15 +172,15 @@ function uw_virtual_site_homepage_page_alter(&$page) {
$num_of_images
=
0
;
// Get the number of images in the homepage banners.
foreach
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
]
as
$key
=>
$value
)
{
if
(
is_int
(
$key
))
{
foreach
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
]
as
$key
=>
$value
)
{
if
(
is_int
(
$key
))
{
$num_of_images
++
;
}
}
// While there is a continue, process the homepage banners.
while
(
$continue
)
{
foreach
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
]
as
$key
=>
$value
)
{
while
(
$continue
)
{
foreach
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
]
as
$key
=>
$value
)
{
$fc_id
=
$key
;
break
;
}
...
...
@@ -194,20 +198,20 @@ function uw_virtual_site_homepage_page_alter(&$page) {
$pagenumber
++
;
// Set the image.
if
(
$pagenumber
==
1
)
{
if
(
$pagenumber
==
1
)
{
$html
.
=
'<figure class="field-item uw-homepage-banners-figure element-selected">'
;
}
else
{
$html
.
=
'<figure class="field-item uw-homepage-banners-figure element-invisible">'
;
}
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_link'
][
'#items'
][
0
][
'url'
]))
{
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_link'
][
'#items'
][
0
][
'url'
]))
{
$html
.
=
'<a href="'
.
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_link'
][
'#items'
][
0
][
'url'
]
.
'">'
;
}
// Set the picture using the picture tag.
$html
.
=
'<picture>
<source srcset="'
.
$banner_xl
.
'" media="(min-width: 1280px)">
<source srcset="'
.
$banner_xl
.
'" media="(min-width: 1280px)">
<source srcset="'
.
$banner_med
.
'" media="(min-width: 1024px)">
<source srcset="'
.
$banner_large
.
'" media="(min-width: 769px)">
<source srcset="'
.
$banner_square
.
'" media="(min-width: 480px)">
...
...
@@ -217,15 +221,15 @@ function uw_virtual_site_homepage_page_alter(&$page) {
$html
.
=
'</picture>'
;
// If there is a title, double check, and then set the caption.
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'title'
]))
{
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'title'
]))
{
// If there is a title, set the caption.
// If there is not title, check that there is a title for the link and use that.
if
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'title'
]
!==
""
)
{
if
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'title'
]
!==
""
)
{
$html
.
=
'<div class="banner-caption-wrapper">'
;
$html
.
=
'<div class="banner-caption">'
;
$html
.
=
'<h2>'
.
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'title'
]
.
'</h2>'
;
if
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'image_field_caption'
][
'value'
])
{
if
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'image_field_caption'
][
'value'
])
{
$html
.
=
'<span>'
.
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_image'
][
0
][
'#item'
][
'image_field_caption'
][
'value'
]
.
'</span>'
;
}
$html
.
=
'</div>'
;
...
...
@@ -240,7 +244,7 @@ function uw_virtual_site_homepage_page_alter(&$page) {
}
}
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_link'
][
'#items'
][
0
][
'url'
]))
{
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
][
'entity'
][
'field_collection_item'
][
$fc_id
][
'field_uw_homepage_banners_link'
][
'#items'
][
0
][
'url'
]))
{
$html
.
=
'</a>'
;
}
...
...
@@ -248,12 +252,12 @@ function uw_virtual_site_homepage_page_alter(&$page) {
$index
++
;
// If there are not any more homepage banners, stop processing the homepage banners.
if
(
!
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
])))
{
$continue
=
false
;
if
(
!
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_homepage_banners'
][
$index
])))
{
$continue
=
FALSE
;
}
// If there is more than one image add the paginator blocks.
if
(
$num_of_images
>
1
)
{
if
(
$num_of_images
>
1
)
{
// More html.
$html
.
=
'<div class="banner-controls">'
;
...
...
@@ -265,20 +269,20 @@ function uw_virtual_site_homepage_page_alter(&$page) {
$html
.
=
'</div>'
;
$html
.
=
'</figure>'
;
if
(
$pagenumber
==
1
)
{
$boxes
.
=
'<li><a href="" title="display banner #'
.
$pagenumber
.
'" class="hpb_selected" data-pagenumber="'
.
$pagenumber
.
'"><span class="element-invisible">Display banner #</span>'
.
$pagenumber
.
'</a></li>'
;
if
(
$pagenumber
==
1
)
{
$boxes
.
=
'<li><a href="" title="display banner #'
.
$pagenumber
.
'" class="hpb_selected" data-pagenumber="'
.
$pagenumber
.
'"><span class="element-invisible">Display banner #</span>'
.
$pagenumber
.
'</a></li>'
;
}
else
{
$boxes
.
=
'<li><a href="" title="display banner #'
.
$pagenumber
.
'" data-pagenumber="'
.
$pagenumber
.
'"><span class="element-invisible">Display banner #</span>'
.
$pagenumber
.
'</a></li>'
;
$boxes
.
=
'<li><a href="" title="display banner #'
.
$pagenumber
.
'" data-pagenumber="'
.
$pagenumber
.
'"><span class="element-invisible">Display banner #</span>'
.
$pagenumber
.
'</a></li>'
;
}
}
else
{
else
{
$html
.
=
'</figure>'
;
}
}
// If there is more than one image, add the Play/Pause button.
if
(
$num_of_images
>
1
)
{
if
(
$num_of_images
>
1
)
{
// Final closing html and play/pause button.
$html
.
=
'</div>'
;
$html
.
=
'<button class="slideshow-control pause" title="Pause">'
;
...
...
@@ -290,8 +294,8 @@ function uw_virtual_site_homepage_page_alter(&$page) {
$html
.
=
'</ul>'
;
$html
.
=
'</div>'
;
}
else
{
//
c
lose the opening
html
divs in homepage banners. if single image in banner
else
{
//
C
lose the opening
HTML
divs in homepage banners. if single image in banner
.
$html
.
=
'</div>'
;
$html
.
=
'</div>'
;
}
...
...
@@ -301,11 +305,11 @@ 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'
]))
{
if
(
isset
(
$page
[
'header_second'
][
'boxes_site_info'
][
'content'
][
'#markup'
]))
{
if
(
isset
(
$page
[
'uw-virtual-site-homepage'
][
'field_uw_credentials'
]))
{
if
(
isset
(
$page
[
'header_second'
][
'boxes_site_info'
][
'content'
][
'#markup'
]))
{
$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'
]);
}
else
if
(
$page
[
'header_second'
][
'boxes_site_info'
][
'#markup'
])
{
elseif
(
$page
[
'header_second'
][
'boxes_site_info'
][
'#markup'
])
{
$page
[
'header_second'
][
'boxes_site_info'
][
'#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'
][
'#markup'
]);
}
}
...
...
@@ -313,17 +317,18 @@ function uw_virtual_site_homepage_page_alter(&$page) {
/**
* Implement hook_form_alter
*
* Form ID: _os_link_external_form
* Hide target option field.
*/
function
uw_virtual_site_homepage_form_alter
(
&
$form
,
&
$form_state
,
$form_id
)
{
if
(
$form_id
==
"biblio_search_form"
)
{
if
(
$form_id
==
"biblio_search_form"
)
{
$form
[
'search_form'
][
'#collapsed'
]
=
FALSE
;
$form
[
'search_form'
][
'#collapsible'
]
=
FALSE
;
if
(
isset
(
$form
[
'search_form'
][
'filterform'
][
'filters'
][
'current'
][
0
][
'#markup'
]))
{
if
(
$form
[
'search_form'
][
'filterform'
][
'filters'
][
'current'
][
0
][
'#markup'
]
!==
""
)
{
if
(
isset
(
$form
[
'search_form'
][
'filterform'
][
'filters'
][
'current'
][
0
][
'#markup'
]))
{
if
(
$form
[
'search_form'
][
'filterform'
][
'filters'
][
'current'
][
0
][
'#markup'
]
!==
""
)
{
$form
[
'search_form'
][
'filterform'
][
'filters'
][
'#collapsed'
]
=
FALSE
;
}
}
...
...
@@ -335,6 +340,7 @@ function uw_virtual_site_homepage_form_alter(&$form, &$form_state, $form_id) {
/**
* Implements hook_FORMID_form_alter().
*
* Removing options and placing data on the form for setting the virtual homepage.
*/
function
uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter
(
&
$form
,
&
$form_state
,
$form_id
)
{
...
...
@@ -344,17 +350,17 @@ function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(
$url
=
request_uri
();
// Ensure that we don't replace all the slashes if just at top root.
if
(
$base_path
!==
'/'
)
{
if
(
$base_path
!==
'/'
)
{
// Ensure that we are at the very base.
$url
=
str_replace
(
$base_path
,
''
,
$url
);
}
// Break U
rl
into its parts
// Break U
RL
into its parts
.
$url_parts
=
explode
(
'/'
,
$url
);
// The username should be the first element in the url_parts array, set it to username.
// If the first element is blank use the second element.
if
(
$url_parts
[
0
]
==
''
)
{
if
(
$url_parts
[
0
]
==
''
)
{
$username
=
$url_parts
[
1
];
}
else
{
...
...
@@ -395,11 +401,11 @@ function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(
'#default_value'
=>
$node
->
title
,
'#description'
=>
t
(
'Enter your name as the title of your site. This will appear at the top of every page (for example: Dr John Doe).'
),
'#size'
=>
60
,
'#required'
=>
true
,
'#required'
=>
TRUE
,
);
// Ensuring that we are getting a default value.
if
(
isset
(
$node
->
field_site_description
[
LANGUAGE_NONE
][
0
][
'value'
]))
{
if
(
isset
(
$node
->
field_site_description
[
LANGUAGE_NONE
][
0
][
'value'
]))
{
$default_value
=
$node
->
field_site_description
[
LANGUAGE_