Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
New #433.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Jan 17, 2015
1 parent b2a2194 commit ba6fb02
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.txt
Expand Up @@ -171,6 +171,7 @@ New in 2.8.1.1
- FIX: Apply MDL-45930.
- FIX: Apply MDL-44907.
- NEW: Issue #428: Add setting to customise header background image. Thanks to Jerome Charaoui (https://github.com/jcharaoui) for this.
- NEW: Issue #433: Add a 'This Course' dropdown menu. Thanks to ActionJONA (https://github.com/ActionJONA) for the ported BCU theme code.

New in 2.8.1
============
Expand Down
2 changes: 2 additions & 0 deletions lang/en/theme_essential.php
Expand Up @@ -208,6 +208,8 @@
$string['allmodules'] = 'All modules';
$string['allclasses'] = 'All classes';
$string['noenrolments'] = 'You have no current enrolments';
$string['thiscourse'] = 'This course';
$string['people'] = 'People';

$string['helplinktype'] = 'Enable help link in menu';
$string['helplinktypedesc'] = 'Choose whether you want to enable a help option in the user menu, you can choose to either provide an URL that will be opened in a new window or an email address.';
Expand Down
3 changes: 3 additions & 0 deletions layout/includes/header.php
Expand Up @@ -157,6 +157,9 @@
<div id="custom_menu">
<?php echo $OUTPUT->custom_menu(); ?>
</div>
<div id="custom_menu_activitystream">
<?php echo $OUTPUT->custom_menu_activitystream(); ?>
</div>
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions less/essential/navigation.less
Expand Up @@ -45,12 +45,14 @@
#custom_menu_language,
#custom_menu_courses,
#custom_menu_themecolours,
#custom_menu_activitystream,
#custom_menu {
display: inline-block;
vertical-align: top;
}

#custom_menu_courses,
#custom_menu_activitystream,
#custom_menu_language {
ul.dropdown-menu {
max-height: 384px;
Expand Down
1 change: 1 addition & 0 deletions less/essential/responsive.less
Expand Up @@ -49,6 +49,7 @@
#custom_menu_language,
#custom_menu_courses,
#custom_menu_themecolours,
#custom_menu_activitystream,
#custom_menu {
vertical-align: top;
float: left;
Expand Down
72 changes: 72 additions & 0 deletions renderers/core_renderer.php
Expand Up @@ -330,6 +330,78 @@ public function custom_menu_themecolours()
return $this->render_custom_menu($colourmenu);
}

/**
* Outputs the Activity Stream menu
* @return custom_menu object
*/
public function custom_menu_activitystream() {
if ($this->page->pagelayout != 'course') {
return '';
}

if (!isguestuser()) {
if (isset($this->page->course->id) && $this->page->course->id > 1) {
$activitystreammenu = new custom_menu();
$branchtitle = get_string('thiscourse', 'theme_essential');
$branchlabel = '<i class="fa fa-book"></i>'.$branchtitle;
$branchurl = new moodle_url('#');
$branch = $activitystreammenu->add($branchlabel, $branchurl, $branchtitle, 10002);
$branchtitle = get_string('people', 'theme_essential');
$branchlabel = '<i class="fa fa-users"></i>'.$branchtitle;
$branchurl = new moodle_url('/user/index.php', array('id' => $this->page->course->id));
$branch->add($branchlabel, $branchurl, $branchtitle, 100003);
$branchtitle = get_string('grades');
$branchlabel = '<i class="fa fa-list-alt icon"></i>'.$branchtitle;
$branchurl = new moodle_url('/grade/report/index.php', array('id' => $this->page->course->id));
$branch->add($branchlabel, $branchurl, $branchtitle, 100004);

$data = $this->get_course_activities();
foreach ($data as $modname => $modfullname) {
if ($modname === 'resources') {
$icon = $this->pix_icon('icon', '', 'mod_page', array('class' => 'icon'));
$branch->add($icon.$modfullname, new moodle_url('/course/resources.php', array('id' => $this->page->course->id)));
} else {
$icon = '<img src="'.$this->pix_url('icon', $modname) . '" class="icon" alt="" />';
$branch->add($icon.$modfullname, new moodle_url('/mod/'.$modname.'/index.php', array('id' => $this->page->course->id)));
}
}
return $this->render_custom_menu($activitystreammenu);
}
}
return '';
}

private function get_course_activities() {
// A copy of block_activity_modules.
$course = $this->page->course;
$content = new stdClass();
$modinfo = get_fast_modinfo($course);
$modfullnames = array();
$archetypes = array();
foreach ($modinfo->cms as $cm) {
// Exclude activities which are not visible or have no link (=label).
if (!$cm->uservisible or !$cm->has_view()) {
continue;
}
if (array_key_exists($cm->modname, $modfullnames)) {
continue;
}
if (!array_key_exists($cm->modname, $archetypes)) {
$archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
}
if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) {
if (!array_key_exists('resources', $modfullnames)) {
$modfullnames['resources'] = get_string('resources');
}
} else {
$modfullnames[$cm->modname] = $cm->modplural;
}
}
core_collator::asort($modfullnames);

return $modfullnames;
}

/**
* Outputs the messages menu
* @return custom_menu object
Expand Down
3 changes: 3 additions & 0 deletions style/essential-rtl.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions style/essential.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ba6fb02

Please sign in to comment.