Skip to content

Commit 2efe966

Browse files
authored
Merge pull request #256 from davidherney/tk_new_verticalall_view
Tk new verticalall view
2 parents 9de6743 + e13506e commit 2efe966

File tree

10 files changed

+143
-8
lines changed

10 files changed

+143
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Download zip package, extract the onetopic folder and upload this folder into co
1919
### 2024050909:
2020
* New responsive tab display: switch to collapsed menu
2121
* The icon in the tabs with children was hidden. It may be removed in the future.
22+
* New tabs view: Vertically including childs
2223

2324
### 2024050907:
2425
* New feature: Subsection display mode.

classes/header.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public function export_for_template(\renderer_base $output) {
8989
case \format_onetopic::TABSVIEW_COURSEINDEX:
9090
$tabsview = 'verticaltabs';
9191
break;
92+
case \format_onetopic::TABSVIEW_VERTICALALL:
93+
$tabsview = 'verticaltabs verticalalltabs';
94+
break;
9295
case \format_onetopic::TABSVIEW_ONELINE:
9396
$tabsview = 'onelinetabs';
9497
break;
@@ -106,11 +109,29 @@ public function export_for_template(\renderer_base $output) {
106109
$format->hastopictabs = count($tabslist) > 0;
107110

108111
$courseindex = '';
112+
$hassubtabs = false;
109113
if ($course->tabsview == \format_onetopic::TABSVIEW_COURSEINDEX) {
110114
$renderer = $format->get_renderer($PAGE);
111115
$courseindex = $renderer->render_from_template('core_courseformat/local/courseindex/drawer', []);
112116
$hassecondrow = false;
113117
$hastopictabs = true;
118+
} else if ($course->tabsview == \format_onetopic::TABSVIEW_VERTICALALL) {
119+
$hastopictabs = $format->hastopictabs;
120+
$hassecondrow = false;
121+
$hassubtabs = true;
122+
123+
foreach ($tabslist as $tab) {
124+
if (isset($tab->secondrow) && is_array($tab->secondrow)) {
125+
foreach ($tab->secondrow as $skey => $secondtab) {
126+
if (!$secondtab->id) {
127+
// Remove the index to avoid conflicts with the main tabs.
128+
unset($tab->secondrow[$skey]);
129+
}
130+
}
131+
132+
$tab->secondrow = array_values($tab->secondrow);
133+
}
134+
}
114135
} else {
115136
$hastopictabs = $format->hastopictabs;
116137
$hassecondrow = is_object($secondtabslist) && count($secondtabslist->tabs) > 0;
@@ -158,6 +179,7 @@ public function export_for_template(\renderer_base $output) {
158179
'tabs' => $tabslist,
159180
'activetab' => $activetab,
160181
'hassecondrow' => $hassecondrow,
182+
'hassubtabs' => $hassubtabs,
161183
'secondrow' => $secondtabslist,
162184
'tabsviewclass' => $tabsview,
163185
'hasformatmsgs' => count(\format_onetopic::$formatmsgs) > 0,

classes/output/courseformat/content/section/controlmenu.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ public function section_control_items() {
6666

6767
$movecontrols = [];
6868
if ($section->section && !$isstealth && has_capability('moodle/course:movesections', $coursecontext, $USER)) {
69-
$horizontal = !$course->hidetabsbar && $course->tabsview != \format_onetopic::TABSVIEW_VERTICAL;
69+
$horizontal = !$course->hidetabsbar && (
70+
$course->tabsview != \format_onetopic::TABSVIEW_VERTICAL &&
71+
$course->tabsview != \format_onetopic::TABSVIEW_VERTICALALL
72+
);
7073
$rtl = right_to_left();
7174

7275
// Legacy move up and down links.

lang/en/format_onetopic.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@
186186
$string['tabsview_default'] = 'By default';
187187
$string['tabsview_help'] = 'By default: is the traditional view.<br />
188188
Vertically: show tabs in vertical direction. Tabs on the left and content on the right.<br />
189+
Vertically including childs: show tabs in vertical direction, including the child tabs. Tabs on the left and content on the right.<br />
189190
One single line: all tabs are displayed in a single line with horizontal scroll. Useful if too many tabs are used.';
190191
$string['tabsview_oneline'] = 'Only one line';
191192
$string['tabsview_vertical'] = 'Vertically';
193+
$string['tabsview_verticalall'] = 'Vertically including childs';
192194
$string['templatetopic'] = 'Use topic summary as template';
193195
$string['templatetopic_help'] = 'This option is used in order to use the summary topic as a template. If it is used as template, you can include the resources in the content, not only as tradicional moodle\'s lists. <br />In order to include a resource, write the resource name between double brackets, for example: [[News forum]]. This functionality is similar to activity name filter, however, it is different because the user can chose if included the resource icon and decide than activities are be included.';
194196
$string['templatetopic_icons'] = 'Show icon in resource links in summary';

lib.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class format_onetopic extends core_courseformat\base {
6767
/** @var int Embedded course index */
6868
const TABSVIEW_COURSEINDEX = 3;
6969

70+
/** @var int Vertical all view */
71+
const TABSVIEW_VERTICALALL = 4;
72+
7073
/** @var int Only if theme not support "usescourseindex" */
7174
const SECTIONSNAVIGATION_SUPPORT = 1;
7275

@@ -286,8 +289,11 @@ public function uses_course_index() {
286289

287290
$course = $this->get_course();
288291

289-
if ($course->tabsview == self::TABSVIEW_COURSEINDEX) {
290-
return false;
292+
if (in_array($course->tabsview, [self::TABSVIEW_COURSEINDEX, self::TABSVIEW_VERTICALALL])) {
293+
global $PAGE;
294+
if ($PAGE->pagetype == 'course-view-onetopic') {
295+
return false;
296+
}
291297
}
292298

293299
if ($this->show_editor()) {
@@ -657,6 +663,7 @@ public function course_format_options($foreditform = false) {
657663
[
658664
self::TABSVIEW_DEFAULT => new lang_string('tabsview_default', 'format_onetopic'),
659665
self::TABSVIEW_VERTICAL => new lang_string('tabsview_vertical', 'format_onetopic'),
666+
self::TABSVIEW_VERTICALALL => new lang_string('tabsview_verticalall', 'format_onetopic'),
660667
self::TABSVIEW_ONELINE => new lang_string('tabsview_oneline', 'format_onetopic'),
661668
],
662669
],

settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
$options = [
113113
\format_onetopic::TABSVIEW_DEFAULT => new lang_string('tabsview_default', 'format_onetopic'),
114114
\format_onetopic::TABSVIEW_VERTICAL => new lang_string('tabsview_vertical', 'format_onetopic'),
115+
\format_onetopic::TABSVIEW_VERTICALALL => new lang_string('tabsview_verticalall', 'format_onetopic'),
115116
\format_onetopic::TABSVIEW_ONELINE => new lang_string('tabsview_oneline', 'format_onetopic'),
116117
];
117118
$settings->add(

styles.css

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
padding-right: 1.3rem;
1616
}
1717

18-
.format-onetopic ul.nav-tabs.format_onetopic-tabs li.marker a {
18+
.format-onetopic ul.nav-tabs.format_onetopic-tabs li.marker > a {
1919
font-weight: bold;
2020
}
2121

22-
.format-onetopic ul.nav-tabs.format_onetopic-tabs li.dimmed a {
22+
.format-onetopic ul.nav-tabs.format_onetopic-tabs li.dimmed > a {
2323
color: #999;
2424
opacity: 0.5;
2525
}
@@ -113,7 +113,7 @@
113113
border-right: 1px solid #dee2e6;
114114
}
115115

116-
.format-onetopic .tabs-wrapper .format_onetopic-tabs .nav-link > i.icon {
116+
.format-onetopic .tabs-wrapper .format_onetopic-tabs .nav-link > i.icon:not(.fa-plus) {
117117
display: none;
118118
}
119119

@@ -133,6 +133,33 @@
133133
margin-right: -1px;
134134
}
135135

136+
.format-onetopic .verticalalltabs .format_onetopic-tabs > .nav-item > .nav-link {
137+
background-color: var(--primary);
138+
color: var(--white);
139+
text-align: center;
140+
margin-bottom: 0;
141+
}
142+
143+
.format-onetopic .verticalalltabs .format_onetopic-tabs > .nav-item > .nav-link.active,
144+
.format-onetopic .verticalalltabs .format_onetopic-tabs > .nav-item > .nav-link:active,
145+
.format-onetopic .verticalalltabs .format_onetopic-tabs > .nav-item > .nav-link:hover {
146+
border: 1px solid transparent;
147+
opacity: 0.9;
148+
}
149+
150+
.format-onetopic .verticalalltabs .format_onetopic-subtabs {
151+
margin-left: 10px;
152+
margin-right: 3px;
153+
}
154+
155+
.format-onetopic .verticalalltabs .format_onetopic-subtabs .subtopic {
156+
font-size: 100%;
157+
}
158+
159+
.format-onetopic .verticalalltabs .course-section {
160+
margin-top: 0;
161+
}
162+
136163
.format-onetopic .onetopic-subtabs_body {
137164
padding: 0 15px;
138165
}
@@ -614,7 +641,9 @@
614641
top: 45px;
615642
left: 0;
616643
right: 0;
617-
background-color: var(--secondary, #6c757d)
644+
background-color: var(--secondary, #6c757d);
645+
box-shadow: 5px 5px 5px #aaa;
646+
padding: 0;
618647
}
619648

620649
.format-onetopic .tabs-menu-toggle:checked ~ .tabs-menu-overlay .tabs-menu-expand {
@@ -629,6 +658,10 @@
629658
margin-left: 0;
630659
}
631660

661+
.format-onetopic .tabs-menu-toggle:checked ~ .nav-tabs .format_onetopic-subtabs {
662+
display: block;
663+
}
664+
632665
.format-onetopic .verticaltabs {
633666
display: block;
634667
}
@@ -658,6 +691,10 @@
658691
max-width: unset;
659692
}
660693

694+
.format-onetopic .verticalalltabs .format_onetopic-subtabs {
695+
margin: 0;
696+
}
697+
661698
.format-onetopic .course-content .section-navigation {
662699
flex-direction: column;
663700
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{{!
2+
This file is part of Moodle - http://moodle.org/
3+
4+
Moodle is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
Moodle is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
}}
17+
{{!
18+
@template format_onetopic/courseformat/tabsubtree
19+
20+
Tab tree.
21+
22+
Example context (json):
23+
{
24+
"secondrow": [{
25+
"active": "true",
26+
"inactive": "false",
27+
"link": [{
28+
"link": "http://moodle.org"
29+
}],
30+
"title": "Moodle.org",
31+
"text": "Moodle community",
32+
"styles": "color: #ff00ff"
33+
}]
34+
}
35+
}}
36+
<ul class="nav nav-tabs format_onetopic-subtabs">
37+
{{#secondrow}}
38+
<li class="nav-item {{specialclass}}" {{#id}}id="onetabid-{{.}}"{{/id}}>
39+
<a class="nav-link{{#active}} active{{/active}}{{#inactive}} disabled{{/inactive}}" {{#link}}href="{{{link}}}"{{/link}} title="{{title}}" style="{{styles}}">
40+
<span class="tabicon {{^icons}}hidden{{/icons}}">
41+
{{#icons}}
42+
<span class="tabicon-{{state}}{{^visible}} hidden{{/visible}}">{{{icon}}}</span>
43+
{{/icons}}
44+
</span>{{{text}}}
45+
46+
{{#availablemessage}}
47+
<span class="iconhelp" data-infoid="format_onetopic_winfo_{{uniqueid}}">
48+
{{#pix}} e/help, core, {{#str}} info {{/str}} {{/pix}}
49+
</span>
50+
<div id="format_onetopic_winfo_{{uniqueid}}" class="availability_info_box" style="display: none;">
51+
{{{availablemessage}}}
52+
</div>
53+
{{/availablemessage}}
54+
</a>
55+
</li>
56+
{{/secondrow}}
57+
</ul>

templates/courseformat/tabtree.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
</div>
5353
{{/availablemessage}}
5454
</a>
55+
{{#hassubtabs}}
56+
{{#haschilds}}
57+
{{>format_onetopic/courseformat/tabsubtree}}
58+
{{/haschilds}}
59+
{{/hassubtabs}}
5560
</li>
5661
{{/tabs}}
5762
</ul>

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
defined('MOODLE_INTERNAL') || die();
3535

36-
$plugin->version = 2024050908.02; // The current plugin version (Date: YYYYMMDDXX).
36+
$plugin->version = 2024050908.03; // The current plugin version (Date: YYYYMMDDXX).
3737
$plugin->requires = 2024041600; // Requires this Moodle version.
3838
$plugin->component = 'format_onetopic'; // Full name of the plugin (used for diagnostics).
3939
$plugin->maturity = MATURITY_BETA;

0 commit comments

Comments
 (0)