From 536f0460331fe3b257557a77e68d4de9cb158c40 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 15 Jul 2016 17:02:22 +0800 Subject: [PATCH] MDL-55402 theme_noname: Convert bootstrapbase to bs4 All moodle less files are converted to sass with layouts etc written as mustache templates. Bootstrap 4 sass files are imported to scss/bootstrap. Part of MDL-55071 --- lib/outputrenderers.php | 18 +- lib/outputrequirementslib.php | 11 +- lib/templates/skip_links.mustache | 10 + theme/noname/classes/output/core_renderer.php | 260 + theme/noname/config.php | 129 +- theme/noname/layout/columns1.php | 29 + theme/noname/layout/columns2.php | 30 + theme/noname/layout/columns3.php | 32 + theme/noname/layout/default.php | 91 - theme/noname/layout/embedded.php | 29 + theme/noname/layout/maintenance.php | 29 + theme/noname/layout/secure.php | 32 + theme/noname/readme_moodle.txt | 14 + theme/noname/scss/bootstrap/LICENSE | 22 + theme/noname/scss/bootstrap/_alert.scss | 56 + theme/noname/scss/bootstrap/_animation.scss | 27 + theme/noname/scss/bootstrap/_breadcrumb.scss | 38 + .../noname/scss/bootstrap/_button-group.scss | 234 + theme/noname/scss/bootstrap/_buttons.scss | 176 + theme/noname/scss/bootstrap/_card.scss | 321 + theme/noname/scss/bootstrap/_carousel.scss | 253 + theme/noname/scss/bootstrap/_close.scss | 31 + theme/noname/scss/bootstrap/_code.scss | 57 + .../noname/scss/bootstrap/_custom-forms.scss | 265 + theme/noname/scss/bootstrap/_custom.scss | 4 + theme/noname/scss/bootstrap/_dropdown.scss | 179 + theme/noname/scss/bootstrap/_forms.scss | 364 + theme/noname/scss/bootstrap/_grid.scss | 39 + theme/noname/scss/bootstrap/_images.scss | 52 + theme/noname/scss/bootstrap/_input-group.scss | 188 + theme/noname/scss/bootstrap/_jumbotron.scss | 20 + theme/noname/scss/bootstrap/_list-group.scss | 123 + theme/noname/scss/bootstrap/_media.scss | 89 + theme/noname/scss/bootstrap/_mixins.scss | 54 + theme/noname/scss/bootstrap/_modal.scss | 132 + theme/noname/scss/bootstrap/_nav.scss | 157 + theme/noname/scss/bootstrap/_navbar.scss | 258 + theme/noname/scss/bootstrap/_normalize.scss | 424 + theme/noname/scss/bootstrap/_pagination.scss | 73 + theme/noname/scss/bootstrap/_popover.scss | 147 + theme/noname/scss/bootstrap/_print.scss | 116 + theme/noname/scss/bootstrap/_progress.scss | 145 + theme/noname/scss/bootstrap/_reboot.scss | 393 + .../scss/bootstrap/_responsive-embed.scss | 39 + theme/noname/scss/bootstrap/_tables.scss | 198 + theme/noname/scss/bootstrap/_tags.scss | 77 + theme/noname/scss/bootstrap/_tooltip.scss | 87 + theme/noname/scss/bootstrap/_type.scss | 150 + theme/noname/scss/bootstrap/_utilities.scss | 9 + theme/noname/scss/bootstrap/_variables.scss | 829 + .../noname/scss/bootstrap/bootstrap-flex.scss | 8 + .../noname/scss/bootstrap/bootstrap-grid.scss | 23 + .../scss/bootstrap/bootstrap-reboot.scss | 11 + theme/noname/scss/bootstrap/bootstrap.scss | 54 + .../noname/scss/bootstrap/mixins/_alert.scss | 14 + .../bootstrap/mixins/_background-variant.scss | 13 + .../scss/bootstrap/mixins/_border-radius.scss | 35 + .../scss/bootstrap/mixins/_breakpoints.scss | 86 + .../scss/bootstrap/mixins/_buttons.scss | 113 + .../noname/scss/bootstrap/mixins/_cards.scss | 44 + .../scss/bootstrap/mixins/_clearfix.scss | 7 + .../noname/scss/bootstrap/mixins/_forms.scss | 92 + .../scss/bootstrap/mixins/_gradients.scss | 43 + .../bootstrap/mixins/_grid-framework.scss | 70 + theme/noname/scss/bootstrap/mixins/_grid.scss | 84 + .../noname/scss/bootstrap/mixins/_hover.scss | 60 + .../noname/scss/bootstrap/mixins/_image.scss | 34 + .../scss/bootstrap/mixins/_list-group.scss | 30 + .../noname/scss/bootstrap/mixins/_lists.scss | 7 + .../scss/bootstrap/mixins/_nav-divider.scss | 10 + .../scss/bootstrap/mixins/_navbar-align.scss | 9 + .../scss/bootstrap/mixins/_pagination.scss | 21 + .../scss/bootstrap/mixins/_progress.scss | 23 + .../noname/scss/bootstrap/mixins/_pulls.scss | 6 + .../scss/bootstrap/mixins/_reset-filter.scss | 8 + .../scss/bootstrap/mixins/_reset-text.scss | 17 + .../noname/scss/bootstrap/mixins/_resize.scss | 6 + .../scss/bootstrap/mixins/_screen-reader.scss | 32 + theme/noname/scss/bootstrap/mixins/_size.scss | 6 + .../scss/bootstrap/mixins/_tab-focus.scss | 9 + .../scss/bootstrap/mixins/_table-row.scss | 30 + theme/noname/scss/bootstrap/mixins/_tag.scss | 11 + .../scss/bootstrap/mixins/_text-emphasis.scss | 12 + .../scss/bootstrap/mixins/_text-hide.scss | 8 + .../scss/bootstrap/mixins/_text-truncate.scss | 8 + .../scss/bootstrap/utilities/_background.scss | 21 + .../scss/bootstrap/utilities/_clearfix.scss | 3 + .../scss/bootstrap/utilities/_display.scss | 13 + .../scss/bootstrap/utilities/_flex.scss | 37 + .../scss/bootstrap/utilities/_pulls.scss | 13 + .../bootstrap/utilities/_screenreaders.scss | 11 + .../scss/bootstrap/utilities/_spacing.scss | 43 + .../scss/bootstrap/utilities/_text.scss | 51 + .../scss/bootstrap/utilities/_visibility.scss | 57 + theme/noname/scss/moodle.scss | 34 + theme/noname/scss/moodle/admin.scss | 787 + theme/noname/scss/moodle/backup-restore.scss | 233 + theme/noname/scss/moodle/blocks.scss | 240 + theme/noname/scss/moodle/buttons.scss | 114 + theme/noname/scss/moodle/calendar.scss | 385 + theme/noname/scss/moodle/chat.scss | 83 + theme/noname/scss/moodle/core.scss | 2141 +++ theme/noname/scss/moodle/course.scss | 1141 ++ theme/noname/scss/moodle/debug.scss | 101 + theme/noname/scss/moodle/dock.scss | 135 + theme/noname/scss/moodle/editor.scss | 5 + theme/noname/scss/moodle/expendable.scss | 89 + theme/noname/scss/moodle/filemanager.scss | 1122 ++ theme/noname/scss/moodle/forms.scss | 604 + theme/noname/scss/moodle/grade.scss | 348 + theme/noname/scss/moodle/message.scss | 359 + theme/noname/scss/moodle/modules.scss | 584 + theme/noname/scss/moodle/question.scss | 527 + theme/noname/scss/moodle/reports.scss | 14 + theme/noname/scss/moodle/responsive.scss | 700 + theme/noname/scss/moodle/search.scss | 48 + theme/noname/scss/moodle/tables.scss | 6 + theme/noname/scss/moodle/templates.scss | 12 + theme/noname/scss/moodle/undo.scss | 198 + theme/noname/scss/moodle/user.scss | 238 + theme/noname/style/bootstrap.css | 6211 +++++++ theme/noname/style/build.css | 15464 ++++++++++++++++ theme/noname/style/build.css.map | 7 + theme/noname/templates/columns1.mustache | 58 + theme/noname/templates/columns2.mustache | 59 + theme/noname/templates/columns3.mustache | 62 + .../noname/templates/core/skip_links.mustache | 5 + theme/noname/templates/embedded.mustache | 20 + theme/noname/templates/maintenance.mustache | 32 + theme/noname/templates/secure.mustache | 53 + theme/noname/thirdpartylibs.xml | 10 + 131 files changed, 39940 insertions(+), 122 deletions(-) create mode 100644 lib/templates/skip_links.mustache create mode 100644 theme/noname/classes/output/core_renderer.php create mode 100644 theme/noname/layout/columns1.php create mode 100644 theme/noname/layout/columns2.php create mode 100644 theme/noname/layout/columns3.php delete mode 100644 theme/noname/layout/default.php create mode 100644 theme/noname/layout/embedded.php create mode 100644 theme/noname/layout/maintenance.php create mode 100644 theme/noname/layout/secure.php create mode 100644 theme/noname/readme_moodle.txt create mode 100644 theme/noname/scss/bootstrap/LICENSE create mode 100644 theme/noname/scss/bootstrap/_alert.scss create mode 100644 theme/noname/scss/bootstrap/_animation.scss create mode 100644 theme/noname/scss/bootstrap/_breadcrumb.scss create mode 100644 theme/noname/scss/bootstrap/_button-group.scss create mode 100644 theme/noname/scss/bootstrap/_buttons.scss create mode 100644 theme/noname/scss/bootstrap/_card.scss create mode 100644 theme/noname/scss/bootstrap/_carousel.scss create mode 100644 theme/noname/scss/bootstrap/_close.scss create mode 100644 theme/noname/scss/bootstrap/_code.scss create mode 100644 theme/noname/scss/bootstrap/_custom-forms.scss create mode 100644 theme/noname/scss/bootstrap/_custom.scss create mode 100644 theme/noname/scss/bootstrap/_dropdown.scss create mode 100644 theme/noname/scss/bootstrap/_forms.scss create mode 100644 theme/noname/scss/bootstrap/_grid.scss create mode 100644 theme/noname/scss/bootstrap/_images.scss create mode 100644 theme/noname/scss/bootstrap/_input-group.scss create mode 100644 theme/noname/scss/bootstrap/_jumbotron.scss create mode 100644 theme/noname/scss/bootstrap/_list-group.scss create mode 100644 theme/noname/scss/bootstrap/_media.scss create mode 100644 theme/noname/scss/bootstrap/_mixins.scss create mode 100644 theme/noname/scss/bootstrap/_modal.scss create mode 100644 theme/noname/scss/bootstrap/_nav.scss create mode 100644 theme/noname/scss/bootstrap/_navbar.scss create mode 100644 theme/noname/scss/bootstrap/_normalize.scss create mode 100644 theme/noname/scss/bootstrap/_pagination.scss create mode 100644 theme/noname/scss/bootstrap/_popover.scss create mode 100644 theme/noname/scss/bootstrap/_print.scss create mode 100644 theme/noname/scss/bootstrap/_progress.scss create mode 100644 theme/noname/scss/bootstrap/_reboot.scss create mode 100644 theme/noname/scss/bootstrap/_responsive-embed.scss create mode 100644 theme/noname/scss/bootstrap/_tables.scss create mode 100644 theme/noname/scss/bootstrap/_tags.scss create mode 100644 theme/noname/scss/bootstrap/_tooltip.scss create mode 100644 theme/noname/scss/bootstrap/_type.scss create mode 100644 theme/noname/scss/bootstrap/_utilities.scss create mode 100644 theme/noname/scss/bootstrap/_variables.scss create mode 100644 theme/noname/scss/bootstrap/bootstrap-flex.scss create mode 100644 theme/noname/scss/bootstrap/bootstrap-grid.scss create mode 100644 theme/noname/scss/bootstrap/bootstrap-reboot.scss create mode 100644 theme/noname/scss/bootstrap/bootstrap.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_alert.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_background-variant.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_border-radius.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_breakpoints.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_buttons.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_cards.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_clearfix.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_forms.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_gradients.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_grid-framework.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_grid.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_hover.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_image.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_list-group.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_lists.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_nav-divider.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_navbar-align.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_pagination.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_progress.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_pulls.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_reset-filter.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_reset-text.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_resize.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_screen-reader.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_size.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_tab-focus.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_table-row.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_tag.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_text-emphasis.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_text-hide.scss create mode 100644 theme/noname/scss/bootstrap/mixins/_text-truncate.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_background.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_clearfix.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_display.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_flex.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_pulls.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_screenreaders.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_spacing.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_text.scss create mode 100644 theme/noname/scss/bootstrap/utilities/_visibility.scss create mode 100644 theme/noname/scss/moodle.scss create mode 100644 theme/noname/scss/moodle/admin.scss create mode 100644 theme/noname/scss/moodle/backup-restore.scss create mode 100644 theme/noname/scss/moodle/blocks.scss create mode 100644 theme/noname/scss/moodle/buttons.scss create mode 100644 theme/noname/scss/moodle/calendar.scss create mode 100644 theme/noname/scss/moodle/chat.scss create mode 100644 theme/noname/scss/moodle/core.scss create mode 100644 theme/noname/scss/moodle/course.scss create mode 100644 theme/noname/scss/moodle/debug.scss create mode 100644 theme/noname/scss/moodle/dock.scss create mode 100644 theme/noname/scss/moodle/editor.scss create mode 100644 theme/noname/scss/moodle/expendable.scss create mode 100644 theme/noname/scss/moodle/filemanager.scss create mode 100644 theme/noname/scss/moodle/forms.scss create mode 100644 theme/noname/scss/moodle/grade.scss create mode 100644 theme/noname/scss/moodle/message.scss create mode 100644 theme/noname/scss/moodle/modules.scss create mode 100644 theme/noname/scss/moodle/question.scss create mode 100644 theme/noname/scss/moodle/reports.scss create mode 100644 theme/noname/scss/moodle/responsive.scss create mode 100644 theme/noname/scss/moodle/search.scss create mode 100644 theme/noname/scss/moodle/tables.scss create mode 100644 theme/noname/scss/moodle/templates.scss create mode 100644 theme/noname/scss/moodle/undo.scss create mode 100644 theme/noname/scss/moodle/user.scss create mode 100644 theme/noname/style/bootstrap.css create mode 100644 theme/noname/style/build.css.map create mode 100644 theme/noname/templates/columns1.mustache create mode 100644 theme/noname/templates/columns2.mustache create mode 100644 theme/noname/templates/columns3.mustache create mode 100644 theme/noname/templates/core/skip_links.mustache create mode 100644 theme/noname/templates/embedded.mustache create mode 100644 theme/noname/templates/maintenance.mustache create mode 100644 theme/noname/templates/secure.mustache create mode 100644 theme/noname/thirdpartylibs.xml diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 97b954323b3..91a3ebca38b 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -610,7 +610,7 @@ class core_renderer extends renderer_base { */ public function standard_top_of_body_html() { global $CFG; - $output = $this->page->requires->get_top_of_body_code(); + $output = $this->page->requires->get_top_of_body_code($this); if ($this->page->pagelayout !== 'embedded' && !empty($CFG->additionalhtmltopofbody)) { $output .= "\n".$CFG->additionalhtmltopofbody; } @@ -4245,6 +4245,22 @@ EOD; return $this->render_context_header($contextheader); } + /** + * Renders the skip links for the page. + * + * @param array $links List of skip links. + * @return string HTML for the skip links. + */ + public function render_skip_links($links) { + $context = [ 'links' => []]; + + foreach ($links as $url => $text) { + $context['links'][] = [ 'url' => $url, 'text' => $text]; + } + + return $this->render_from_template('core/skip_links', $context); + } + /** * Renders the header bar. * diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 8ef740532ab..ed868fa1b4b 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -1531,17 +1531,12 @@ class page_requirements_manager { * Normally, this method is called automatically by the code that prints the * tag. You should not normally need to call it in your own code. * + * @param renderer_base $renderer * @return string the HTML code to go at the start of the tag. */ - public function get_top_of_body_code() { + public function get_top_of_body_code(renderer_base $renderer) { // First the skip links. - $links = ''; - $attributes = array('class' => 'skip'); - foreach ($this->skiplinks as $url => $text) { - $links .= html_writer::link('#'.$url, $text, $attributes); - } - $output = html_writer::tag('div', $links, array('class'=>'skiplinks')) . "\n"; - $this->js_init_call('M.util.init_skiplink'); + $output = $renderer->render_skip_links($this->skiplinks); // YUI3 JS needs to be loaded early in the body. It should be cached well by the browser. $output .= $this->get_yui3lib_headcode(); diff --git a/lib/templates/skip_links.mustache b/lib/templates/skip_links.mustache new file mode 100644 index 00000000000..b0ad3e89959 --- /dev/null +++ b/lib/templates/skip_links.mustache @@ -0,0 +1,10 @@ + +{{#js}} +require(['core/yui'], function(Y) { + M.util.init_skiplink(Y); +}); +{{/js}} \ No newline at end of file diff --git a/theme/noname/classes/output/core_renderer.php b/theme/noname/classes/output/core_renderer.php new file mode 100644 index 00000000000..7cd8268e3a9 --- /dev/null +++ b/theme/noname/classes/output/core_renderer.php @@ -0,0 +1,260 @@ +. + +namespace theme_noname\output; + +use html_writer; +use tabobject; +use tabtree; +use custom_menu_item; +use custom_menu; + +defined('MOODLE_INTERNAL') || die; + +/** + * Renderers to align Moodle's HTML with that expected by Bootstrap + * + * @package theme_noname + * @copyright 2012 Bas Brands, www.basbrands.nl + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +class core_renderer extends \core_renderer { + + /** @var custom_menu_item language The language menu if created */ + protected $language = null; + + /** + * The standard tags that should be included in the tag + * including a meta description for the front page + * + * @return string HTML fragment. + */ + public function standard_head_html() { + global $SITE, $PAGE; + + $output = parent::standard_head_html(); + if ($PAGE->pagelayout == 'frontpage') { + $summary = s(strip_tags(format_text($SITE->summary, FORMAT_HTML))); + if (!empty($summary)) { + $output .= "\n"; + } + } + + return $output; + } + + /* + * This renders the navbar. + * Uses bootstrap compatible html. + */ + public function navbar() { + $items = $this->page->navbar->get_items(); + if (empty($items)) { + return ''; + } + + $breadcrumbs = array(); + foreach ($items as $item) { + $item->hideicon = true; + $breadcrumbs[] = $this->render($item); + } + $list_items = '
  • '.join("
  • ", $breadcrumbs).'
  • '; + $title = ''.get_string('pagepath').''; + return $title . ''; + } + + /* + * Overriding the custom_menu function ensures the custom menu is + * always shown, even if no menu items are configured in the global + * theme settings page. + */ + public function custom_menu($custommenuitems = '') { + global $CFG; + + if (empty($custommenuitems) && !empty($CFG->custommenuitems)) { + $custommenuitems = $CFG->custommenuitems; + } + $custommenu = new custom_menu($custommenuitems, current_language()); + return $this->render_custom_menu($custommenu); + } + + /* + * This renders the bootstrap top menu. + * + * This renderer is needed to enable the Bootstrap style navigation. + */ + protected function render_custom_menu(custom_menu $menu) { + global $CFG; + + $langs = get_string_manager()->get_list_of_translations(); + $haslangmenu = $this->lang_menu() != ''; + + if (!$menu->has_children() && !$haslangmenu) { + return ''; + } + + if ($haslangmenu) { + $strlang = get_string('language'); + $currentlang = current_language(); + if (isset($langs[$currentlang])) { + $currentlang = $langs[$currentlang]; + } else { + $currentlang = $strlang; + } + $this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000); + foreach ($langs as $langtype => $langname) { + $this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname); + } + } + + $content = ''; + } + + /* + * This code renders the custom menu items for the + * bootstrap dropdown menu. + */ + protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0 ) { + static $submenucount = 0; + + $content = ''; + if ($menunode->has_children()) { + + if ($level == 1) { + $class = 'dropdown'; + } else { + $class = 'dropdown-submenu'; + } + + if ($menunode === $this->language) { + $class .= ' langmenu'; + } + $content = html_writer::start_tag('li', array('class' => $class)); + // If the child has menus render it as a sub menu. + $submenucount++; + if ($menunode->get_url() !== null) { + $url = $menunode->get_url(); + } else { + $url = '#cm_submenu_'.$submenucount; + } + $content .= html_writer::start_tag('a', array('href'=>$url, 'class'=>'dropdown-toggle', 'data-toggle'=>'dropdown', 'title'=>$menunode->get_title())); + $content .= $menunode->get_text(); + if ($level == 1) { + $content .= ''; + } + $content .= ''; + $content .= ''; + } else { + // The node doesn't have children so produce a final menuitem. + // Also, if the node's text matches '####', add a class so we can treat it as a divider. + if (preg_match("/^#+$/", $menunode->get_text())) { + // This is a divider. + $content = '
  •  
  • '; + } else { + $content = '
  • '; + if ($menunode->get_url() !== null) { + $url = $menunode->get_url(); + } else { + $url = '#'; + } + $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title())); + $content .= '
  • '; + } + } + return $content; + } + + /** + * This code renders the navbar button to control the display of the custom menu + * on smaller screens. + * + * Do not display the button if the menu is empty. + * + * @return string HTML fragment + */ + public function navbar_button() { + global $CFG; + + if (empty($CFG->custommenuitems) && $this->lang_menu() == '') { + return ''; + } + + $iconbar = html_writer::tag('span', '', array('class' => 'icon-bar')); + $button = html_writer::tag('a', $iconbar . "\n" . $iconbar. "\n" . $iconbar, array( + 'class' => 'btn btn-navbar', + 'data-toggle' => 'collapse', + 'data-target' => '.nav-collapse' + )); + return $button; + } + + /** + * Renders tabtree + * + * @param tabtree $tabtree + * @return string + */ + protected function render_tabtree(tabtree $tabtree) { + if (empty($tabtree->subtree)) { + return ''; + } + $firstrow = $secondrow = ''; + foreach ($tabtree->subtree as $tab) { + $firstrow .= $this->render($tab); + if (($tab->selected || $tab->activated) && !empty($tab->subtree) && $tab->subtree !== array()) { + $secondrow = $this->tabtree($tab->subtree); + } + } + return html_writer::tag('ul', $firstrow, array('class' => 'nav nav-tabs')) . $secondrow; + } + + /** + * Renders tabobject (part of tabtree) + * + * This function is called from {@link core_renderer::render_tabtree()} + * and also it calls itself when printing the $tabobject subtree recursively. + * + * @param tabobject $tabobject + * @return string HTML fragment + */ + protected function render_tabobject(tabobject $tab) { + if (($tab->selected and (!$tab->linkedwhenselected)) or $tab->activated) { + return html_writer::tag('li', html_writer::tag('a', $tab->text), array('class' => 'active')); + } else if ($tab->inactive) { + return html_writer::tag('li', html_writer::tag('a', $tab->text), array('class' => 'disabled')); + } else { + if (!($tab->link instanceof moodle_url)) { + // backward compartibility when link was passed as quoted string + $link = "link\" title=\"$tab->title\">$tab->text"; + } else { + $link = html_writer::link($tab->link, $tab->text, array('title' => $tab->title)); + } + $params = $tab->selected ? array('class' => 'active') : null; + return html_writer::tag('li', $link, $params); + } + } +} diff --git a/theme/noname/config.php b/theme/noname/config.php index c4506adafc8..0cb80e8b5b8 100644 --- a/theme/noname/config.php +++ b/theme/noname/config.php @@ -29,29 +29,114 @@ $THEME->sheets = ['build']; $THEME->editor_sheets = ['editor']; $THEME->layouts = [ - 'standard' => [ - 'file' => 'default.php', - 'regions' => ['side-pre', 'side-post'], - ], + // Most backwards compatible layout without the blocks - this is the layout used by default. + 'base' => array( + 'file' => 'columns1.php', + 'regions' => array(), + ), + // Standard layout with blocks, this is recommended for most pages with general information. + 'standard' => array( + 'file' => 'columns3.php', + 'regions' => array('side-pre', 'side-post'), + 'defaultregion' => 'side-pre', + ), + // Main course page. + 'course' => array( + 'file' => 'columns3.php', + 'regions' => array('side-pre', 'side-post'), + 'defaultregion' => 'side-pre', + 'options' => array('langmenu' => true), + ), + 'coursecategory' => array( + 'file' => 'columns3.php', + 'regions' => array('side-pre', 'side-post'), + 'defaultregion' => 'side-pre', + ), + // Part of course, typical for modules - default page layout if $cm specified in require_login(). + 'incourse' => array( + 'file' => 'columns3.php', + 'regions' => array('side-pre', 'side-post'), + 'defaultregion' => 'side-pre', + ), + // The site home page. + 'frontpage' => array( + 'file' => 'columns3.php', + 'regions' => array('side-pre', 'side-post'), + 'defaultregion' => 'side-pre', + 'options' => array('nonavbar' => true), + ), + // Server administration scripts. + 'admin' => array( + 'file' => 'columns2.php', + 'regions' => array('side-pre'), + 'defaultregion' => 'side-pre', + ), + // My dashboard page. + 'mydashboard' => array( + 'file' => 'columns3.php', + 'regions' => array('side-pre', 'side-post'), + 'defaultregion' => 'side-pre', + 'options' => array('langmenu' => true), + ), + // My public page. + 'mypublic' => array( + 'file' => 'columns2.php', + 'regions' => array('side-pre'), + 'defaultregion' => 'side-pre', + ), + 'login' => array( + 'file' => 'columns1.php', + 'regions' => array(), + 'options' => array('langmenu' => true), + ), - // 'course' => [], - // 'coursecategory' => [], - // 'incourse' => [], - // 'frontpage' => [], - // 'admin' => [], - // 'mydashboard' => [], - // 'mypublic' => [], - // 'report' => [], - // 'login' => [], - - // General purpose. - // 'embedded' => [], - // 'frametop' => [], - // 'maintenance' => [], - // 'popup' => [], - // 'print' => [], - // 'redirect' => [], - // 'secure' => [], + // Pages that appear in pop-up windows - no navigation, no blocks, no header. + 'popup' => array( + 'file' => 'columns1.php', + 'regions' => array(), + 'options' => array('nofooter' => true, 'nonavbar' => true), + ), + // No blocks and minimal footer - used for legacy frame layouts only! + 'frametop' => array( + 'file' => 'columns1.php', + 'regions' => array(), + 'options' => array('nofooter' => true, 'nocoursefooter' => true), + ), + // Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible. + 'embedded' => array( + 'file' => 'embedded.php', + 'regions' => array() + ), + // Used during upgrade and install, and for the 'This site is undergoing maintenance' message. + // This must not have any blocks, links, or API calls that would lead to database or cache interaction. + // Please be extremely careful if you are modifying this layout. + 'maintenance' => array( + 'file' => 'maintenance.php', + 'regions' => array(), + ), + // Should display the content and basic headers only. + 'print' => array( + 'file' => 'columns1.php', + 'regions' => array(), + 'options' => array('nofooter' => true, 'nonavbar' => false), + ), + // The pagelayout used when a redirection is occuring. + 'redirect' => array( + 'file' => 'embedded.php', + 'regions' => array(), + ), + // The pagelayout used for reports. + 'report' => array( + 'file' => 'columns2.php', + 'regions' => array('side-pre'), + 'defaultregion' => 'side-pre', + ), + // The pagelayout used for safebrowser and securewindow. + 'secure' => array( + 'file' => 'secure.php', + 'regions' => array('side-pre', 'side-post'), + 'defaultregion' => 'side-pre' + ) ]; // $THEME->javascripts = array(); diff --git a/theme/noname/layout/columns1.php b/theme/noname/layout/columns1.php new file mode 100644 index 00000000000..db5a05ff36c --- /dev/null +++ b/theme/noname/layout/columns1.php @@ -0,0 +1,29 @@ +. + +/** + * A one column layout for the noname theme. + * + * @package theme_noname + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +$templatecontext = [ + 'sitename' => format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))), + 'output' => $OUTPUT +]; + +echo $OUTPUT->render_from_template('theme_noname/columns1', $templatecontext); \ No newline at end of file diff --git a/theme/noname/layout/columns2.php b/theme/noname/layout/columns2.php new file mode 100644 index 00000000000..1b74703e0d2 --- /dev/null +++ b/theme/noname/layout/columns2.php @@ -0,0 +1,30 @@ +. + +/** + * A two column layout for the noname theme. + * + * @package theme_noname + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +$templatecontext = [ + 'sitename' => format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))), + 'output' => $OUTPUT, + 'sidepreblocks' => $OUTPUT->blocks('side-pre', 'col-md-3 col-md-pull-9'), +]; + +echo $OUTPUT->render_from_template('theme_noname/columns2', $templatecontext); \ No newline at end of file diff --git a/theme/noname/layout/columns3.php b/theme/noname/layout/columns3.php new file mode 100644 index 00000000000..b2426d63736 --- /dev/null +++ b/theme/noname/layout/columns3.php @@ -0,0 +1,32 @@ +. + +/** + * A three column layout for the noname theme. + * + * @package theme_noname + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +$templatecontext = [ + 'sitename' => format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))), + 'output' => $OUTPUT, + 'sidepreblocks' => $OUTPUT->blocks('side-pre', 'col-md-4 col-md-pull-8 col-lg-3 col-lg-pull-9'), + 'sidepostblocks' => $OUTPUT->blocks('side-post', 'col-md-3') +]; + +echo $OUTPUT->render_from_template('theme_noname/columns3', $templatecontext); + diff --git a/theme/noname/layout/default.php b/theme/noname/layout/default.php deleted file mode 100644 index 5347c9973ad..00000000000 --- a/theme/noname/layout/default.php +++ /dev/null @@ -1,91 +0,0 @@ -. - -/** - * Default layout. - * - * @package theme_noname - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$regionmain = 'span9 pull-right'; -$sidepre = 'span3 desktop-first-column'; -if (right_to_left()) { - $regionmain = 'span9'; - $sidepre = 'span3 pull-right'; -} - -echo $OUTPUT->doctype() ?> -htmlattributes(); ?>> - - <?php echo $OUTPUT->page_title(); ?> - - standard_head_html() ?> - - - -body_attributes('two-column'); ?>> - -standard_top_of_body_html() ?> - - - -
    - full_header(); ?> -
    -
    - course_content_header(); - echo $OUTPUT->main_content(); - echo $OUTPUT->course_content_footer(); - ?> -
    - blocks('side-pre', $sidepre); ?> -
    - -
    - - - login_info(); - echo $OUTPUT->home_link(); - echo $OUTPUT->standard_footer_html(); - ?> -
    - - standard_end_of_body_html() ?> - -
    - - diff --git a/theme/noname/layout/embedded.php b/theme/noname/layout/embedded.php new file mode 100644 index 00000000000..44bfee4eafa --- /dev/null +++ b/theme/noname/layout/embedded.php @@ -0,0 +1,29 @@ +. + +/** + * An embedded layout for the noname theme. + * + * @package theme_noname + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +$templatecontext = [ + 'sitename' => format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))), + 'output' => $OUTPUT +]; + +echo $OUTPUT->render_from_template('theme_noname/embedded', $templatecontext); \ No newline at end of file diff --git a/theme/noname/layout/maintenance.php b/theme/noname/layout/maintenance.php new file mode 100644 index 00000000000..03cac5471e1 --- /dev/null +++ b/theme/noname/layout/maintenance.php @@ -0,0 +1,29 @@ +. + +/** + * A maintenance layout for the noname theme. + * + * @package theme_noname + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +$templatecontext = [ + 'sitename' => format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))), + 'output' => $OUTPUT +]; + +echo $OUTPUT->render_from_template('theme_noname/maintenance', $templatecontext); \ No newline at end of file diff --git a/theme/noname/layout/secure.php b/theme/noname/layout/secure.php new file mode 100644 index 00000000000..c88eb6051f9 --- /dev/null +++ b/theme/noname/layout/secure.php @@ -0,0 +1,32 @@ +. + +/** + * A three column layout for the noname theme. + * + * @package theme_noname + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +$templatecontext = [ + 'sitename' => format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))), + 'output' => $OUTPUT, + 'sidepreblocks' => $OUTPUT->blocks('side-pre', 'col-md-4 col-md-pull-8 col-lg-3 col-lg-pull-9'), + 'sidepostblocks' => $OUTPUT->blocks('side-post', 'col-md-3') +]; + +echo $OUTPUT->render_from_template('theme_noname/secure', $templatecontext); + diff --git a/theme/noname/readme_moodle.txt b/theme/noname/readme_moodle.txt new file mode 100644 index 00000000000..71a4419bb14 --- /dev/null +++ b/theme/noname/readme_moodle.txt @@ -0,0 +1,14 @@ +Description of Twitter bootstrap import into Moodle + +Twitter bootstrap +----------------- +This theme uses the original unmodified version 4.0.0-alpha-3 Twitter bootstrap sass files. +The bootstrap repository is available on: + +https://github.com/twitter/bootstrap.git + +To update to the latest release of twitter bootstrap: +* remove all files from scss/bootstrap, +* download the new scss files and store them in scss/bootstrap +* update ./thirdpartylibs.xml + diff --git a/theme/noname/scss/bootstrap/LICENSE b/theme/noname/scss/bootstrap/LICENSE new file mode 100644 index 00000000000..4e32163c07f --- /dev/null +++ b/theme/noname/scss/bootstrap/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2011-2016 Twitter, Inc. +Copyright (c) 2011-2016 The Bootstrap Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/theme/noname/scss/bootstrap/_alert.scss b/theme/noname/scss/bootstrap/_alert.scss new file mode 100644 index 00000000000..55fc101dc27 --- /dev/null +++ b/theme/noname/scss/bootstrap/_alert.scss @@ -0,0 +1,56 @@ +// +// Base styles +// + +.alert { + padding: $alert-padding; + margin-bottom: $spacer-y; + border: $alert-border-width solid transparent; + @include border-radius($alert-border-radius); +} + +// Headings for larger alerts +.alert-heading { + // Specified to prevent conflicts of changing $headings-color + color: inherit; +} + +// Provide class for links that match alerts +.alert-link { + font-weight: $alert-link-font-weight; +} + + +// Dismissible alerts +// +// Expand the right padding and account for the close button's positioning. + +.alert-dismissible { + padding-right: ($alert-padding + 20px); + + // Adjust close link position + .close { + position: relative; + top: -2px; + right: -21px; + color: inherit; + } +} + + +// Alternate styles +// +// Generate contextual modifier classes for colorizing the alert. + +.alert-success { + @include alert-variant($alert-success-bg, $alert-success-border, $alert-success-text); +} +.alert-info { + @include alert-variant($alert-info-bg, $alert-info-border, $alert-info-text); +} +.alert-warning { + @include alert-variant($alert-warning-bg, $alert-warning-border, $alert-warning-text); +} +.alert-danger { + @include alert-variant($alert-danger-bg, $alert-danger-border, $alert-danger-text); +} diff --git a/theme/noname/scss/bootstrap/_animation.scss b/theme/noname/scss/bootstrap/_animation.scss new file mode 100644 index 00000000000..edd7147e51e --- /dev/null +++ b/theme/noname/scss/bootstrap/_animation.scss @@ -0,0 +1,27 @@ +.fade { + opacity: 0; + transition: opacity .15s linear; + + &.in { + opacity: 1; + } +} + +.collapse { + display: none; + + &.in { + display: block; + } + // tr&.in { display: table-row; } + // tbody&.in { display: table-row-group; } +} + +.collapsing { + position: relative; + height: 0; + overflow: hidden; + transition-timing-function: ease; + transition-duration: .35s; + transition-property: height; +} diff --git a/theme/noname/scss/bootstrap/_breadcrumb.scss b/theme/noname/scss/bootstrap/_breadcrumb.scss new file mode 100644 index 00000000000..1a09bba20a9 --- /dev/null +++ b/theme/noname/scss/bootstrap/_breadcrumb.scss @@ -0,0 +1,38 @@ +.breadcrumb { + padding: $breadcrumb-padding-y $breadcrumb-padding-x; + margin-bottom: $spacer-y; + list-style: none; + background-color: $breadcrumb-bg; + @include border-radius($border-radius); + @include clearfix; +} + +.breadcrumb-item { + float: left; + + // The separator between breadcrumbs (by default, a forward-slash: "/") + + .breadcrumb-item::before { + display: inline-block; // Suppress underlining of the separator in modern browsers + padding-right: $breadcrumb-item-padding; + padding-left: $breadcrumb-item-padding; + color: $breadcrumb-divider-color; + content: "#{$breadcrumb-divider}"; + } + + // IE9-11 hack to properly handle hyperlink underlines for breadcrumbs built + // without `