You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
209 lines
9.5 KiB
209 lines
9.5 KiB
3 years ago
|
<?php
|
||
|
/**
|
||
|
* @file
|
||
|
* Extra Functions for Edu X theme.
|
||
|
*/
|
||
|
use Drupal\file\Entity\File;
|
||
|
/**
|
||
|
* Sanitise input urls.
|
||
|
*/
|
||
|
function santise_val_url($url) {
|
||
|
if ($url != '') {
|
||
|
|
||
|
// Sanitise (remove all illegal characters) from url.
|
||
|
$url = filter_var($url, FILTER_SANITIZE_URL);
|
||
|
|
||
|
// Validate url.
|
||
|
if (filter_var($url, FILTER_VALIDATE_URL) == TRUE) {
|
||
|
$url = $url;
|
||
|
} else {
|
||
|
$url = '#';
|
||
|
}
|
||
|
return $url;
|
||
|
}
|
||
|
}
|
||
|
function rdm_preprocess_page(array &$variables) {
|
||
|
// theme path
|
||
|
$variables['page_rdm_path'] = drupal_get_path('theme', 'rdm');
|
||
|
|
||
|
// Layout
|
||
|
$variables['container_width'] = theme_get_setting('container_width');
|
||
|
$variables['header_width'] = theme_get_setting('header_width');
|
||
|
$variables['main_width'] = theme_get_setting('main_width');
|
||
|
$variables['footer_width'] = theme_get_setting('footer_width');
|
||
|
|
||
|
// homepage slider
|
||
|
$variables['slider_show'] = theme_get_setting('slider_show');
|
||
|
$variables['slider_code'] = theme_get_setting('slider_code');
|
||
|
$variables['slider_image'] = theme_get_setting('slider_image', 'rdm');
|
||
|
$slider_image_id = theme_get_setting('slider_image', 'rdm');
|
||
|
if(!empty($slider_image_file)) {
|
||
|
$imageuri = $slider_image_file->getFileUri();
|
||
|
$variables['slider_image_path'] = file_create_url($imageuri);
|
||
|
};
|
||
|
$variables['slider_image_bg'] = theme_get_setting('slider_image_bg', 'rdm');
|
||
|
|
||
|
// Header
|
||
|
$variables['header_main_default'] = theme_get_setting('header_main_default');
|
||
|
$variables['header_main_padding_top'] = theme_get_setting('header_main_padding_top');
|
||
|
$variables['header_main_padding_bottom'] = theme_get_setting('header_main_padding_bottom');
|
||
|
$variables['header_page_default'] = theme_get_setting('header_page_default');
|
||
|
$variables['header_page_padding_top'] = theme_get_setting('header_page_padding_top');
|
||
|
$variables['header_page_padding_bottom'] = theme_get_setting('header_page_padding_bottom');
|
||
|
$variables['header_page_content_position'] = theme_get_setting('header_page_content_position');
|
||
|
$variables['header_login_links'] = theme_get_setting('header_login_links');
|
||
|
|
||
|
// Sidebar
|
||
|
$variables['front_sidebar'] = theme_get_setting('front_sidebar');
|
||
|
$variables['sidebar_width_default'] = theme_get_setting('sidebar_width_default');
|
||
|
$variables['sidebar_width_left'] = theme_get_setting('sidebar_width_left');
|
||
|
$variables['sidebar_width_right'] = theme_get_setting('sidebar_width_right');
|
||
|
$variables['sidebar_block_default'] = theme_get_setting('sidebar_block_default');
|
||
|
$variables['sidebar_padding'] = theme_get_setting('sidebar_padding');
|
||
|
$variables['sidebar_radius'] = theme_get_setting('sidebar_radius');
|
||
|
$variables['sidebar_margin'] = theme_get_setting('sidebar_margin');
|
||
|
$variables['sidebar_title_font_size'] = theme_get_setting('sidebar_title_font_size');
|
||
|
$variables['sidebar_title_transform'] = theme_get_setting('sidebar_title_transform');
|
||
|
|
||
|
// Footer
|
||
|
$variables['copyright_text'] = theme_get_setting('copyright_text');
|
||
|
|
||
|
// content
|
||
|
$variables['rtl'] = theme_get_setting('rtl');
|
||
|
|
||
|
// Social
|
||
|
$variables['all_icons_show'] = theme_get_setting('all_icons_show');
|
||
|
$variables['facebook_url'] = santise_val_url(theme_get_setting('facebook_url'));
|
||
|
$variables['twitter_url'] = santise_val_url(theme_get_setting('twitter_url'));
|
||
|
$variables['instagram_url'] = santise_val_url(theme_get_setting('instagram_url'));
|
||
|
$variables['linkedin_url'] = santise_val_url(theme_get_setting('linkedin_url'));
|
||
|
$variables['youtube_url'] = santise_val_url(theme_get_setting('youtube_url'));
|
||
|
$variables['vimeo_url'] = santise_val_url(theme_get_setting('vimeo_url'));
|
||
|
$variables['telegram_url'] = santise_val_url(theme_get_setting('telegram_url'));
|
||
|
$variables['whatsapp_url'] = santise_val_url(theme_get_setting('whatsapp_url'));
|
||
|
$variables['github_url'] = santise_val_url(theme_get_setting('github_url'));
|
||
|
$variables['vk_url'] = santise_val_url(theme_get_setting('vk_url'));
|
||
|
|
||
|
// Typography
|
||
|
$variables['body_font_size'] = theme_get_setting('body_font_size');
|
||
|
$variables['body_line_height'] = theme_get_setting('body_line_height');
|
||
|
$variables['paragraph_bottom'] = theme_get_setting('paragraph_bottom');
|
||
|
$variables['headings_default'] = theme_get_setting('headings_default');
|
||
|
$variables['h1_size'] = theme_get_setting('h1_size');
|
||
|
$variables['h1_weight'] = theme_get_setting('h1_weight');
|
||
|
$variables['h1_transform'] = theme_get_setting('h1_transform');
|
||
|
$variables['h1_height'] = theme_get_setting('h1_height');
|
||
|
$variables['h2_size'] = theme_get_setting('h2_size');
|
||
|
$variables['h2_weight'] = theme_get_setting('h2_weight');
|
||
|
$variables['h2_transform'] = theme_get_setting('h2_transform');
|
||
|
$variables['h2_height'] = theme_get_setting('h2_height');
|
||
|
$variables['h3_size'] = theme_get_setting('h3_size');
|
||
|
$variables['h3_weight'] = theme_get_setting('h3_weight');
|
||
|
$variables['h3_transform'] = theme_get_setting('h3_transform');
|
||
|
$variables['h3_height'] = theme_get_setting('h3_height');
|
||
|
$variables['h4_size'] = theme_get_setting('h4_size');
|
||
|
$variables['h4_weight'] = theme_get_setting('h4_weight');
|
||
|
$variables['h4_transform'] = theme_get_setting('h4_transform');
|
||
|
$variables['h4_height'] = theme_get_setting('h4_height');
|
||
|
$variables['h5_size'] = theme_get_setting('h5_size');
|
||
|
$variables['h5_weight'] = theme_get_setting('h5_weight');
|
||
|
$variables['h5_transform'] = theme_get_setting('h5_transform');
|
||
|
$variables['h5_height'] = theme_get_setting('h5_height');
|
||
|
$variables['h6_size'] = theme_get_setting('h6_size');
|
||
|
$variables['h6_weight'] = theme_get_setting('h6_weight');
|
||
|
$variables['h6_transform'] = theme_get_setting('h6_transform');
|
||
|
$variables['h6_height'] = theme_get_setting('h6_height');
|
||
|
|
||
|
// Element -> Logo
|
||
|
$variables['logo_default'] = theme_get_setting('logo_default');
|
||
|
$variables['site_name_size'] = theme_get_setting('site_name_size');
|
||
|
$variables['site_name_weight'] = theme_get_setting('site_name_weight');
|
||
|
$variables['site_name_transform'] = theme_get_setting('site_name_transform');
|
||
|
$variables['site_name_height'] = theme_get_setting('site_name_height');
|
||
|
$variables['slogan_size'] = theme_get_setting('slogan_size');
|
||
|
$variables['slogan_transform'] = theme_get_setting('slogan_transform');
|
||
|
$variables['slogan_height'] = theme_get_setting('slogan_height');
|
||
|
$variables['slogan_style'] = theme_get_setting('slogan_style');
|
||
|
$variables['main_menu_default'] = theme_get_setting('main_menu_default');
|
||
|
$variables['main_menu_top_size'] = theme_get_setting('main_menu_top_size');
|
||
|
$variables['main_menu_top_weight'] = theme_get_setting('main_menu_top_weight');
|
||
|
$variables['main_menu_top_transform'] = theme_get_setting('main_menu_top_transform');
|
||
|
$variables['main_menu_sub_size'] = theme_get_setting('main_menu_sub_size');
|
||
|
$variables['main_menu_sub_weight'] = theme_get_setting('main_menu_sub_weight');
|
||
|
$variables['main_menu_sub_transform'] = theme_get_setting('main_menu_sub_transform');
|
||
|
|
||
|
// Element -> Page title
|
||
|
$variables['page_title_default'] = theme_get_setting('page_title_default');
|
||
|
$variables['page_title_size_desktop'] = theme_get_setting('page_title_size_desktop');
|
||
|
$variables['page_title_size_mobile'] = theme_get_setting('page_title_size_mobile');
|
||
|
$variables['page_title_transform'] = theme_get_setting('page_title_transform');
|
||
|
|
||
|
// Element -> Button
|
||
|
$variables['button_default'] = theme_get_setting('button_default');
|
||
|
$variables['button_padding'] = theme_get_setting('button_padding');
|
||
|
$variables['button_radius'] = theme_get_setting('button_radius');
|
||
|
|
||
|
// Components -> Font icons
|
||
|
$variables['fontawesome_four'] = theme_get_setting('fontawesome_four');
|
||
|
$variables['fontawesome_five'] = theme_get_setting('fontawesome_five');
|
||
|
|
||
|
// Components -> scroll to top
|
||
|
$variables['scrolltotop_on'] = theme_get_setting('scrolltotop_on');
|
||
|
$variables['scrolltotop_default'] = theme_get_setting('scrolltotop_default');
|
||
|
$variables['scrolltotop_icon_style'] = theme_get_setting('scrolltotop_icon_style');
|
||
|
$variables['scrolltotop_icon_size'] = theme_get_setting('scrolltotop_icon_size');
|
||
|
$variables['scrolltotop_position'] = theme_get_setting('scrolltotop_position');
|
||
|
$variables['scrolltotop_bottom'] = theme_get_setting('scrolltotop_bottom');
|
||
|
$variables['scrolltotop_icon_radius'] = theme_get_setting('scrolltotop_icon_radius');
|
||
|
|
||
|
// Comment
|
||
|
$variables['highlight_author_comment'] = theme_get_setting('highlight_author_comment');
|
||
|
}
|
||
|
|
||
|
function rdm_preprocess_html(&$variables) {
|
||
|
$variables['base_path'] = base_path();
|
||
|
$variables['rdm_path'] = drupal_get_path('theme', 'rdm');
|
||
|
$variables['font_src'] = theme_get_setting('font_src');
|
||
|
$variables['styling'] = theme_get_setting('styling');
|
||
|
$variables['styling_code'] = theme_get_setting('styling_code');
|
||
|
$variables['slider_speed'] = theme_get_setting('slider_speed');
|
||
|
}
|
||
|
/**
|
||
|
* Node preprocess.
|
||
|
*/
|
||
|
function rdm_preprocess_node(array &$variables) {
|
||
|
$variables['node_author_pic'] = theme_get_setting('node_author_pic');
|
||
|
$variables['node_tags'] = theme_get_setting('node_tags');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Comment preprocess.
|
||
|
*/
|
||
|
function rdm_preprocess_comment(array &$variables) {
|
||
|
$variables['comment_user_pic'] = theme_get_setting('comment_user_pic');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Breadcrumb preprocess.
|
||
|
*/
|
||
|
function rdm_preprocess_breadcrumb(&$variables) {
|
||
|
$variables['breadcrumb_icon_style'] = theme_get_setting('breadcrumb_icon_style');
|
||
|
}
|
||
|
/**
|
||
|
* Implements hook_theme_suggestions_HOOK_alter().
|
||
|
*/
|
||
|
function rdm_theme_suggestions_page_alter(array &$suggestions, array $variables) {
|
||
|
|
||
|
if ($node = \Drupal::routeMatch()->getParameter('node')) {
|
||
|
$content_type = $node->bundle();
|
||
|
$suggestions[] = 'page__'.$content_type;
|
||
|
}
|
||
|
}
|
||
|
function rdm_theme_suggestions_html_alter(array &$suggestions, array $variables) {
|
||
|
|
||
|
if ($node = \Drupal::routeMatch()->getParameter('node')) {
|
||
|
$content_type = $node->bundle();
|
||
|
$suggestions[] = 'html__'.$content_type;
|
||
|
}
|
||
|
}
|