Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions backup/moodle2/restore_format_onetopic_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

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

require_once($CFG->dirroot. '/course/format/topics/backup/moodle2/restore_format_topics_plugin.class.php');
require_once($CFG->dirroot . '/course/format/topics/backup/moodle2/restore_format_topics_plugin.class.php');

/**
* Specialised restore for format_onetopic
Expand All @@ -38,7 +38,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_format_onetopic_plugin extends restore_format_topics_plugin {

/**
* Executed after course restore is complete
*
Expand Down Expand Up @@ -69,8 +68,10 @@ public function after_restore_course() {
if ($this->step->get_task()->get_setting_value($key . '_included')) {
$sectionnum = (int)$section->title;
if ($sectionnum > $numsections && $sectionnum > $this->originalnumsections) {
$DB->execute("UPDATE {course_sections} SET visible = 0 WHERE course = ? AND section = ?",
[$this->step->get_task()->get_courseid(), $sectionnum]);
$DB->execute(
"UPDATE {course_sections} SET visible = 0 WHERE course = ? AND section = ?",
[$this->step->get_task()->get_courseid(), $sectionnum]
);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions changenumsections.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,13 @@
if (!$returnurl) {
$returnurl = course_get_url($course);
}

} else if (course_get_format($course)->uses_sections() && $insertsection !== null) {
if ($insertsection) {
// Inserting sections at any position except in the very end requires capability to move sections.
require_capability('moodle/course:movesections', context_course::instance($course->id));
}
$sections = [];
for ($i = 0; $i < max($numsections, 1); $i ++) {
for ($i = 0; $i < max($numsections, 1); $i++) {
$section = course_create_section($course, $insertsection);
$sections[] = $section;

Expand All @@ -104,8 +103,11 @@
}
}
if (!$returnurl) {
$returnurl = course_get_url($course, $sections[0]->section,
($sectionreturn !== null) ? ['sr' => $sectionreturn] : []);
$returnurl = course_get_url(
$course,
$sections[0]->section,
($sectionreturn !== null) ? ['sr' => $sectionreturn] : []
);
}
}

Expand Down
1 change: 0 additions & 1 deletion classes/courseformat/stateactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class stateactions extends stateactions_format_topics {

}
2 changes: 0 additions & 2 deletions classes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class footer implements \renderable, \templatable {

/**
* @var \format_onetopic
*/
Expand Down Expand Up @@ -72,5 +71,4 @@ public function export_for_template(\renderer_base $output) {

return $data;
}

}
65 changes: 30 additions & 35 deletions classes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class header implements \renderable, \templatable {

/**
* @var \format_onetopic
*/
Expand Down Expand Up @@ -73,8 +72,10 @@ public function export_for_template(\renderer_base $output) {
$secondtabslist = null;
$tabscssstyles = '';
$activetab = null;
if ($course->tabsview != \format_onetopic::TABSVIEW_COURSEINDEX &&
($format->show_editor() || !$course->hidetabsbar)) {
if (
$course->tabsview != \format_onetopic::TABSVIEW_COURSEINDEX &&
($format->show_editor() || !$course->hidetabsbar)
) {
$tabs = $this->get_tabs($format->get_modinfo(), $output);
$tabslist = $tabs->get_list();
$secondtabslist = $tabs->get_secondlist($firstsection ? $currentsection - 1 : $currentsection);
Expand Down Expand Up @@ -165,7 +166,6 @@ public function export_for_template(\renderer_base $output) {

// General section if non-empty and course_display is multiple.
if ($course->realcoursedisplay == COURSE_DISPLAY_MULTIPAGE) {

// Load the section 0 and export data for template.
$modinfo = $format->get_modinfo();
$section0 = $modinfo->get_section_info(0);
Expand All @@ -174,7 +174,6 @@ public function export_for_template(\renderer_base $output) {

$sectionoutput = new \format_onetopic\output\renderer($PAGE, null);
$initialsection = $section->export_for_template($sectionoutput);

}

$data->initialsection = $initialsection;
Expand Down Expand Up @@ -255,14 +254,13 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
$title = $sectionname;

if (!$thissection->visible || !$thissection->available) {
$title .= ': '. get_string('hiddenfromstudents');
$title .= ': ' . get_string('hiddenfromstudents');
}

$tabicons = [];
$customstyles = '';
$level = 0;
if (is_array($formatoptions)) {

if ($enablecustomstyles) {
if (!empty($formatoptions['fontcolor'])) {
$customstyles .= 'color: ' . $formatoptions['fontcolor'] . '; ';
Expand All @@ -278,7 +276,6 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for

$tabstyles = !empty($formatoptions['tabstyles']) ? @json_decode($formatoptions['tabstyles']) : null;
if (is_object($tabstyles)) {

$orderedtabs = new \stdClass();
foreach ($precedence as $type) {
if (property_exists($tabstyles, $type)) {
Expand All @@ -291,37 +288,36 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
$cssid = '#onetabid-' . $thissection->id . '';
$withunits = ['font-size', 'line-height', 'margin', 'padding', 'border-width', 'border-radius'];
foreach ($orderedtabs as $type => $styles) {

$important = false;
switch ($type) {
case 'active':
$onecss .= '#tabs-tree-start .nav-item' . $cssid . ' a.nav-link.active';
$important = true;
break;
break;
case 'parent':
$onecss .= '#tabs-tree-start .nav-item.haschilds' . $cssid . ' a.nav-link';
break;
break;
case 'highlighted':
$onecss .= '#tabs-tree-start .nav-item.marker' . $cssid . ' a.nav-link';
$important = true;
break;
break;
case 'disabled':
$onecss .= '#tabs-tree-start .nav-item.disabled' . $cssid . ' a.nav-link';
$important = true;
break;
break;
case 'hover':
$onecss .= '#tabs-tree-start .nav-item' . $cssid . ' a.nav-link:hover,';
$onecss .= '#tabs-tree-start .onetopic-tab-body' . $cssparentid
. ' .nav-item.subtopic a.nav-link:hover';
break;
break;
case 'childs':
$onecss .= '#tabs-tree-start .onetopic-tab-body' . $cssparentid
. ' .nav-item.subtopic a.nav-link';
break;
break;
case 'childindex':
$onecss .= '#tabs-tree-start .onetopic-tab-body' . $cssparentid . ' .nav-tabs' .
' .nav-item.subtopic.tab_initial a.nav-link';
break;
break;
default:
$onecss .= '#tabs-tree-start .nav-item' . $cssid . ' a.nav-link,';
$onecss .= '#tabs-tree-start .onetopic-tab-body' . $cssparentid . ' a.nav-link';
Expand All @@ -332,10 +328,8 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for

// Check if exist units for some rules.
foreach ($styles as $key => $value) {

// Check if the key start with the units prefix.
if (strpos($key, 'unit-') === 0) {

// Remove the prefix.
$ownerkey = str_replace('unit-', '', $key);
$units[$ownerkey] = $value;
Expand All @@ -347,7 +341,6 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
}

foreach ($styles as $key => $value) {

// If exist a unit for the rule, apply it.
if (isset($units[$key])) {
$value = $value . $units[$key];
Expand All @@ -369,7 +362,6 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
// Clean the CSS for html tags.
$csstabstyles .= preg_replace('/<[^>]*>/', '', $onecss);
}

}

if (isset($formatoptions['level']) && $localsection > $firstsection) {
Expand Down Expand Up @@ -408,8 +400,15 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
}
}

$newtab = new \format_onetopic\singletab($localsection, $sectionname, $url, $title,
$availablemessage, $customstyles, $specialclass);
$newtab = new \format_onetopic\singletab(
$localsection,
$sectionname,
$url,
$title,
$availablemessage,
$customstyles,
$specialclass
);
$newtab->active = !$inactivetab;
$newtab->id = $thissection->id;
$newtab->cssstyles = $csstabstyles;
Expand All @@ -420,21 +419,21 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
}

if (is_array($formatoptions) && isset($formatoptions['level'])) {

if ($formatoptions['level'] == 0 || $parenttab == null) {
$tabs->add($newtab);
$parenttab = $newtab;
} else {

if (!$parenttab->has_childs()) {
$specialclasstmp = str_replace('tab_level_0', 'tab_level_1', $parenttab->specialclass);
$indextab = new \format_onetopic\singletab($parenttab->section,
$parenttab->content,
$parenttab->link,
$parenttab->title,
$parenttab->availablemessage,
(empty($parenttab->cssstyles) ? $parenttab->customstyles : ''),
$specialclasstmp);
$indextab = new \format_onetopic\singletab(
$parenttab->section,
$parenttab->content,
$parenttab->link,
$parenttab->title,
$parenttab->availablemessage,
(empty($parenttab->cssstyles) ? $parenttab->customstyles : ''),
$specialclasstmp
);

$prevsectionindex = $localsection - 1;
do {
Expand Down Expand Up @@ -477,12 +476,10 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
}

if ($this->format->show_editor()) {

$maxsections = $this->format->get_max_sections();

// Only can add sections if it does not exceed the maximum amount.
if (count($sections) < $maxsections) {

$straddsection = get_string('increasesections', 'format_onetopic');
$icon = $output->pix_icon('t/switch_plus', s($straddsection));
$insertposition = $displaysection + 1;
Expand Down Expand Up @@ -516,11 +513,9 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
$url = new \moodle_url('/course/format/onetopic/changenumsections.php', $paramstotabs);
$newtab = new \format_onetopic\singletab('add', $icon, $url, s($straddsection));
$tabs->add($newtab);

}
}

return $tabs;
}

}
4 changes: 0 additions & 4 deletions classes/local/clilib.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class clilib {

/**
* List styles that need to be migrated.
*
Expand Down Expand Up @@ -65,7 +64,6 @@ public static function mstyles_list($limit = 100) {

$k = 0;
foreach ($rs as $record) {

if (isset($stylesnew[$record->sectionid])) {
// This section already has new styles, skip it.
continue;
Expand All @@ -76,7 +74,6 @@ public static function mstyles_list($limit = 100) {
"Style: {$record->stylename}, Value: {$record->stylevalue}\n";
}
$rs->close();

}

/**
Expand Down Expand Up @@ -138,7 +135,6 @@ public static function mstyles_migrate($limit = 100) {

$k = 0;
foreach ($sections as $sectionid => $section) {

if (CLI_VERBOSE) {
echo "Migrating style for Course ID: {$section->courseid}, Section ID: {$sectionid}\n";
}
Expand Down
11 changes: 5 additions & 6 deletions classes/local/formelement_background.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ public function to_html() {
$loadedcounter++;

$colorpickerid = 'colorpicker' . $loadedcounter;
$cp = new \admin_setting_configcolourpicker($colorpickerid,
get_string('colorpicker', 'format_onetopic'),
get_string('colorpicker_help', 'format_onetopic'),
'',
$cp = new \admin_setting_configcolourpicker(
$colorpickerid,
get_string('colorpicker', 'format_onetopic'),
get_string('colorpicker_help', 'format_onetopic'),
'',
);

$html = parent::toHtml();
Expand All @@ -104,7 +105,6 @@ public function to_html() {
$PAGE->requires->js_call_amd('format_onetopic/onetopicbackground', 'init', [$this->getAttribute('id')]);

return $html;

}

/**
Expand Down Expand Up @@ -148,5 +148,4 @@ public function validateSubmitValue($value) {

return;
}

}
12 changes: 6 additions & 6 deletions classes/local/formelement_tabstyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class format_onetopic_tabstyles_form_element extends MoodleQuickForm_textarea {

/**
* Constructor
*
Expand Down Expand Up @@ -134,9 +133,12 @@ public function to_html() {
$tabslist = $tabs->get_list();
$secondtabslist = $tabs->get_secondlist();

$cp = new \admin_setting_configcolourpicker('colorpicker',
get_string('colorpicker', 'format_onetopic'),
get_string('colorpicker_help', 'format_onetopic'), '');
$cp = new \admin_setting_configcolourpicker(
'colorpicker',
get_string('colorpicker', 'format_onetopic'),
get_string('colorpicker_help', 'format_onetopic'),
''
);

$csssizeoptions = range(0, 100);
$csssizeoptions[0] = '';
Expand Down Expand Up @@ -184,7 +186,6 @@ public function to_html() {
$PAGE->requires->js_call_amd('format_onetopic/tabstyles', 'init');

return $element;

}

/**
Expand Down Expand Up @@ -223,5 +224,4 @@ public function validateSubmitValue($value) {

return;
}

}
1 change: 0 additions & 1 deletion classes/local/hooks/output/before_http_headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class before_http_headers {

/**
* Moodle native lib/navigationlib.php calls this hook allowing us to override UI.
*
Expand Down
Loading