public function get_current_top_level_catetgory() { $catid = false; if (is_array($this->page->categories)) { $catids = array_keys($this->page->categories); if (!empty($catids)) { // The last entry in the array is the top level category. $catid = $catids[count($catids) - 1]; } } else { if (!empty(${$this}->page->course->category)) { $catid = $this->page->course->category; // See if the course category is a top level one. if (!array_key_exists($key, theme_campus_get_top_level_categories())) { $catid = false; } } } return $catid; }
/** * Extra LESS code to inject. * * This will generate some LESS code from the settings used by the user. We cannot use * the {@link theme_more_less_variables()} here because we need to create selectors or * alter existing ones. * * @param theme_config $theme The theme config object. * @return string Raw LESS code. */ function theme_campus_extra_less($theme) { global $CFG, $OUTPUT; if (file_exists("{$CFG->dirroot}/theme/campus/campus-lib.php")) { include_once $CFG->dirroot . '/theme/campus/campus-lib.php'; } else { if (!empty($CFG->themedir) && file_exists("{$CFG->themedir}/campus/campus-lib.php")) { include_once $CFG->themedir . '/campus/campus-lib.php'; } } $campuscategorytree = theme_campus_get_top_level_categories(); $content = '@import "' . $CFG->dirroot . '/theme/bootstrapbase/less/moodle";'; $content .= '@import "variables-campus";'; $content .= '@import "bootstrapchanges";'; $content .= '@import "moodlechanges";'; $content .= '@import "campuschanges";'; $content .= '@import "campuscustom";'; // Front page. if (!empty($theme->settings->frontpagelogo) && !empty($theme->settings->frontpagebackgroundimage)) { if (!empty($theme->settings->frontpageresponsivelogo) && !empty($theme->settings->frontpageresponsivebackgroundimage)) { if ($dimensions = theme_campus_get_image_dimensions($theme, 'frontpageresponsivelogo', 'frontpageresponsivelogo')) { if ($backgrounddimensions = theme_campus_get_image_dimensions($theme, 'frontpageresponsivebackgroundimage', 'frontpageresponsivebackgroundimage')) { $backgroundwidth = $backgrounddimensions['width']; $backgroundheight = $backgrounddimensions['height']; } else { $backgroundwidth = 960; // Fallback, where 960 is the value of @navbarCollapseWidth. $backgroundheight = $dimensions['height']; } $totalwidth = $dimensions['width'] + $backgroundwidth; $fplogowidth = $dimensions['width'] / $totalwidth * 100; $fpabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $fpflexpaddingbottom = $dimensions['height'] / $totalwidth * 100; $fpbackgroundwidth = 100 - $fplogowidth; /* .fpresponsiveheaderlogo(@frontpageMixinLogoWidth; @frontpageAbsoluteMixinPaddingBottom; @frontpageFlexMixinPaddingBottom; @frontpageMixinBackgroundWidth) */ $content .= '.fpresponsiveheaderlogo(' . $fplogowidth . '%; ' . $fpabsolutepaddingbottom . '%; ' . $fpflexpaddingbottom . '%; ' . $fpbackgroundwidth . '%);'; } } } else { // Theme responsive images fall back. if (($logoresponsivedetails = theme_campus_get_theme_responsive_logo()) && ($backgroundresponsivedetails = theme_campus_get_theme_responsive_background())) { if ($logoresponsivedetails['fullname'] && ($dimensions = getimagesize($logoresponsivedetails['fullname']))) { // http://php.net/manual/en/function.getimagesize.php - index 0 = width and index 1 = height. if ($backgroundresponsivedetails['fullname'] && ($backgrounddimensions = getimagesize($backgroundresponsivedetails['fullname']))) { $backgroundwidth = $backgrounddimensions[0]; $backgroundheight = $backgrounddimensions[1]; } else { $backgroundwidth = 960; // Fallback, where 960 is the value of @navbarCollapseWidth. $backgroundheight = $dimensions[1]; } $totalwidth = $dimensions[0] + $backgroundwidth; $fplogowidth = $dimensions[0] / $totalwidth * 100; $fpabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $fpflexpaddingbottom = $dimensions[1] / $totalwidth * 100; $fpbackgroundwidth = 100 - $fplogowidth; /* .fpresponsiveheaderlogo(@frontpageMixinLogoWidth; @frontpageAbsoluteMixinPaddingBottom; @frontpageFlexMixinPaddingBottom; @frontpageMixinBackgroundWidth) */ $content .= '.fpresponsiveheaderlogo(' . $fplogowidth . '%; ' . $fpabsolutepaddingbottom . '%; ' . $fpflexpaddingbottom . '%; ' . $fpbackgroundwidth . '%);'; } } } // Course catetgory. foreach ($campuscategorytree as $key => $value) { $categorylogoused = false; $cchavecustomsetting = 'coursecategoryhavecustomheader' . $key; $ccsetting = 'coursecategorylogo' . $key; $ccbsetting = 'coursecategorybackgroundimage' . $key; if (!empty($theme->settings->{$cchavecustomsetting}) && !empty($theme->settings->{$ccsetting}) && !empty($theme->settings->{$ccbsetting})) { if ($dimensions = theme_campus_get_image_dimensions($theme, $ccsetting, $ccsetting)) { if ($backgrounddimensions = theme_campus_get_image_dimensions($theme, $ccbsetting, $ccbsetting)) { $backgroundwidth = $backgrounddimensions['width']; $backgroundheight = $backgrounddimensions['height']; } else { if (!empty($theme->settings->pagewidthmax)) { $backgroundwidth = $theme->settings->pagewidthmax; // Fallback, default max px of #page unless a percentage. if ($backgroundwidth == 100) { // Percentage value, cannot use in calculation! $backgroundwidth = 1680; // Fallback, where 1680 is the default max px of #page. } } else { $backgroundwidth = 1680; // Fallback, where 1680 is the default max px of #page. } $backgroundheight = $dimensions['height']; } $totalwidth = $dimensions['width'] + $backgroundwidth; $cclogowidth = $dimensions['width'] / $totalwidth * 100; $ccabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $ccflexpaddingbottom = $dimensions['height'] / $totalwidth * 100; $ccbackgroundwidth = 100 - $cclogowidth; /* ccheaderlogo(@courseCategoryKey; @courseCategoryMixinLogoWidth; @courseCategoryMixinAbsolutePaddingBottom; @courseCategoryMixinFlexPaddingBottom; @courseCategoryMixinBackgroundWidth) */ $content .= '.ccheaderlogo(' . $key . '; ' . $cclogowidth . '%; ' . $ccabsolutepaddingbottom . '%; ' . $ccflexpaddingbottom . '%; ' . $ccbackgroundwidth . '%);'; $ccsetting = 'coursecategoryresponsivelogo' . $key; $ccbsetting = 'coursecategoryresponsivebackgroundimage' . $key; if (!empty($theme->settings->{$ccsetting}) && !empty($theme->settings->{$ccbsetting})) { if ($dimensions = theme_campus_get_image_dimensions($theme, $ccsetting, $ccsetting)) { if ($backgrounddimensions = theme_campus_get_image_dimensions($theme, $ccbsetting, $ccbsetting)) { $backgroundwidth = $backgrounddimensions['width']; $backgroundheight = $backgrounddimensions['height']; } else { $backgroundwidth = 960; // Fallback, where 960 is the value of @navbarCollapseWidth. $backgroundheight = $dimensions['height']; } $totalwidth = $dimensions['width'] + $backgroundwidth; $cclogowidth = $dimensions['width'] / $totalwidth * 100; $ccabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $ccflexpaddingbottom = $dimensions['height'] / $totalwidth * 100; $ccbackgroundwidth = 100 - $cclogowidth; /* .ccresponsiveheaderlogo(@courseCategoryKey; @courseCategoryMixinLogoWidth; @courseCategoryMixinAbsolutePaddingBottom; @courseCategoryMixinFlexPaddingBottom; @courseCategoryMixinBackgroundWidth) */ $content .= '.ccresponsiveheaderlogo(' . $key . '; ' . $cclogowidth . '%; ' . $ccabsolutepaddingbottom . '%; ' . $ccflexpaddingbottom . '%; ' . $ccbackgroundwidth . '%);'; } } $categorylogoused = true; } } else { if (!empty($theme->settings->frontpagelogo) && !empty($theme->settings->frontpagebackgroundimage)) { // Front page fall back. if ($dimensions = theme_campus_get_image_dimensions($theme, 'frontpagelogo', 'frontpagelogo')) { // Front page campus desktop images. if ($backgrounddimensions = theme_campus_get_image_dimensions($theme, 'frontpagebackgroundimage', 'frontpagebackgroundimage')) { $backgroundwidth = $backgrounddimensions['width']; $backgroundheight = $backgrounddimensions['height']; } else { if (!empty($theme->settings->pagewidthmax)) { $backgroundwidth = $theme->settings->pagewidthmax; // Fallback, default max px of #page unless a percentage. if ($backgroundwidth == 100) { // Percentage value, cannot use in calculation! $backgroundwidth = 1680; // Fallback, where 1680 is the default max px of #page. } } else { $backgroundwidth = 1680; // Fallback, where 1680 is the default max px of #page. } $backgroundheight = $dimensions['height']; } $totalwidth = $dimensions['width'] + $backgroundwidth; $cclogowidth = $dimensions['width'] / $totalwidth * 100; $ccabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $ccflexpaddingbottom = $dimensions['height'] / $totalwidth * 100; $ccbackgroundwidth = 100 - $cclogowidth; /* ccheaderlogo(@courseCategoryKey; @courseCategoryMixinLogoWidth; @courseCategoryMixinAbsolutePaddingBottom; @courseCategoryMixinFlexPaddingBottom; @courseCategoryMixinBackgroundWidth) */ $content .= '.ccheaderlogo(' . $key . '; ' . $cclogowidth . '%; ' . $ccabsolutepaddingbottom . '%; ' . $ccflexpaddingbottom . '%; ' . $ccbackgroundwidth . '%);'; if (!empty($theme->settings->frontpageresponsivelogo) && !empty($theme->settings->frontpageresponsivebackgroundimage)) { if ($dimensions = theme_campus_get_image_dimensions($theme, 'frontpageresponsivelogo', 'frontpageresponsivelogo')) { if ($backgrounddimensions = theme_campus_get_image_dimensions($theme, 'frontpageresponsivebackgroundimage', 'frontpageresponsivebackgroundimage')) { $backgroundwidth = $backgrounddimensions['width']; $backgroundheight = $backgrounddimensions['height']; } else { $backgroundwidth = 960; // Fallback, where 960 is the value of @navbarCollapseWidth. $backgroundheight = $dimensions['height']; } $totalwidth = $dimensions['width'] + $backgroundwidth; $cclogowidth = $dimensions['width'] / $totalwidth * 100; $ccabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $ccflexpaddingbottom = $dimensions['height'] / $totalwidth * 100; $ccbackgroundwidth = 100 - $cclogowidth; /* ccheaderlogo(@courseCategoryKey; @courseCategoryMixinLogoWidth; @courseCategoryMixinAbsolutePaddingBottom; @courseCategoryMixinFlexPaddingBottom; @courseCategoryMixinBackgroundWidth) */ $content .= '.ccresponsiveheaderlogo(' . $key . '; ' . $cclogowidth . '%; ' . $ccabsolutepaddingbottom . '%; ' . $ccflexpaddingbottom . '%; ' . $ccbackgroundwidth . '%);'; } } // Using front page, so use those settings. if (!empty($theme->settings->frontpagelogoposition)) { switch ($theme->settings->frontpagelogoposition) { /* .ccheaderlogoposition(@courseCategoryKey; @courseCategoryMixinLogoPosition; @courseCategoryMixinSitenamePositionLeft; @courseCategoryMixinSitenamePositionRight) */ case 1: $content .= '.ccheaderlogoposition(' . $key . '; left; auto; 50px);'; break; case 2: $content .= '.ccheaderlogoposition(' . $key . '; right; 50px; auto);'; break; } } } } else { if ($logodetails = theme_campus_get_theme_logo()) { // Theme images fall back. if ($logodetails['fullname'] && ($dimensions = getimagesize($logodetails['fullname']))) { // http://php.net/manual/en/function.getimagesize.php - index 0 = width and index 1 = height. $backgrounddetails = theme_campus_get_theme_background(); if ($backgrounddetails['fullname'] && ($backgrounddimensions = getimagesize($backgrounddetails['fullname']))) { $backgroundwidth = $backgrounddimensions[0]; $backgroundheight = $backgrounddimensions[1]; } else { if (!empty($theme->settings->pagewidthmax)) { $backgroundwidth = $theme->settings->pagewidthmax; // Fallback, default max px of #page unless a percentage. if ($backgroundwidth == 100) { // Percentage value, cannot use in calculation! $backgroundwidth = 1680; // Fallback, where 1680 is the default max px of #page. } } else { $backgroundwidth = 1680; // Fallback, where 1680 is the default max px of #page. } $backgroundheight = $dimensions[1]; } $totalwidth = $dimensions[0] + $backgroundwidth; $cclogowidth = $dimensions[0] / $totalwidth * 100; $ccabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $ccflexpaddingbottom = $dimensions[1] / $totalwidth * 100; $ccbackgroundwidth = 100 - $cclogowidth; /* ccheaderlogo(@courseCategoryKey; @courseCategoryMixinLogoWidth; @courseCategoryMixinAbsolutePaddingBottom; @courseCategoryMixinFlexPaddingBottom; @courseCategoryMixinBackgroundWidth) */ $content .= '.ccheaderlogo(' . $key . '; ' . $cclogowidth . '%; ' . $ccabsolutepaddingbottom . '%; ' . $ccflexpaddingbottom . '%; ' . $ccbackgroundwidth . '%);'; // Theme responsive images fall back. if (($logoresponsivedetails = theme_campus_get_theme_responsive_logo()) && ($backgroundresponsivedetails = theme_campus_get_theme_responsive_background())) { if ($logoresponsivedetails['fullname'] && ($dimensions = getimagesize($logoresponsivedetails['fullname']))) { // http://php.net/manual/en/function.getimagesize.php - index 0 = width and index 1 = height. if ($backgroundresponsivedetails['fullname'] && ($backgrounddimensions = getimagesize($backgroundresponsivedetails['fullname']))) { $backgroundwidth = $backgrounddimensions[0]; $backgroundheight = $backgrounddimensions[1]; } else { $backgroundwidth = 960; // Fallback, where 960 is the value of @navbarCollapseWidth. $backgroundheight = $dimensions[1]; } $totalwidth = $dimensions[0] + $backgroundwidth; $cclogowidth = $dimensions[0] / $totalwidth * 100; $ccabsolutepaddingbottom = $backgroundheight / $backgroundwidth * 100; $ccflexpaddingbottom = $dimensions[1] / $totalwidth * 100; $ccbackgroundwidth = 100 - $cclogowidth; /* ccheaderlogo(@courseCategoryKey; @courseCategoryMixinLogoWidth; @courseCategoryMixinAbsolutePaddingBottom; @courseCategoryMixinFlexPaddingBottom; @courseCategoryMixinBackgroundWidth) */ $content .= '.ccresponsiveheaderlogo(' . $key . '; ' . $cclogowidth . '%; ' . $ccabsolutepaddingbottom . '%; ' . $ccflexpaddingbottom . '%; ' . $ccbackgroundwidth . '%);'; } } $content .= '.ccheaderlogoposition(' . $key . '; left; auto; 50px);'; // Theme layout uses logo on left. } } } } if ($categorylogoused == true) { $ccsetting = 'coursecategorybgcolour' . $key; if (!empty($theme->settings->{$ccsetting})) { /* .ccheaderbackgroundcolour(@courseCategoryKey; @courseCategoryMixinBackgroundColour) */ $content .= '.ccheaderbackgroundcolour(' . $key . '; ' . $theme->settings->{$ccsetting} . ');'; } $ccsetting = 'coursecategorylogoposition' . $key; if (!empty($theme->settings->{$ccsetting})) { switch ($theme->settings->{$ccsetting}) { /* .ccheaderlogoposition(@courseCategoryKey; @courseCategoryMixinLogoPosition; @courseCategoryMixinSitenamePositionLeft; @courseCategoryMixinSitenamePositionRight) */ case 1: $content .= '.ccheaderlogoposition(' . $key . '; left; auto; 50px);'; break; case 2: $content .= '.ccheaderlogoposition(' . $key . '; right; 50px; auto);'; break; } } } } // Header toggle. if (!empty($theme->settings->showheadertoggle)) { // NOTE: If @navbarCollapseWidth changes in the variables-campus.less file, then change this. // .headertogglesetup(@screenWidth) $content .= '.headertogglesetup(961px);'; // .headertogglemenuhide(@screenWidth) $content .= '.headertogglemenuhide(960px);'; // .headertogglemenuhidenofancy(@screenWidth) $content .= '.headertogglemenuhidenofancy(960px);'; } return $content; }
$settingpage->add($setting); // Link target. $name = 'theme_campus/frontpage' . $i . 'linktarget'; $title = get_string('slidelinktarget', 'theme_campus'); $description = get_string('slidelinktargetdesc', 'theme_campus'); $default = 1; $choices = array('_self' => new lang_string('slidelinktargetself', 'theme_campus'), '_blank' => new lang_string('slidelinktargetblank', 'theme_campus')); $setting = new admin_setting_configselect($name, $title, $description, $default, $choices); // No CSS change, so no need to reset caches. $settingpage->add($setting); } $ADMIN->add('theme_campus', $settingpage); // Course category carousel settings. $settingpage = new admin_settingpage('theme_campus_category_carousel', get_string('coursecategorycarouselsettings', 'theme_campus')); $settingpage->add(new admin_setting_heading('theme_campus_carousel_coursecategory', null, format_text(get_string('coursecategorycarouselsettings_desc', 'theme_campus'), FORMAT_MARKDOWN))); $campuscategorytree = theme_campus_get_top_level_categories(); foreach ($campuscategorytree as $key => $value) { $name = 'theme_campus/coursecategoryheading' . $key; $heading = get_string('coursecategoryheading', 'theme_campus', array('categoryname' => $value)); $information = ''; $setting = new admin_setting_heading($name, $heading, $information); // No CSS change, so no need to reset caches. $settingpage->add($setting); // Status. $name = 'theme_campus/coursecategorycarouselstatus' . $key; $title = get_string('carouselstatus', 'theme_campus'); $description = get_string('carouselstatus_desc', 'theme_campus'); $default = 1; $choices = array(1 => new lang_string('draft', 'theme_campus'), 2 => new lang_string('published', 'theme_campus')); $setting = new admin_setting_configselect($name, $title, $description, $default, $choices); // No CSS change, so no need to reset caches.