MDL-73274 theme_boost: add block/activity styling

This commit is contained in:
Bas Brands 2021-12-15 09:46:26 +01:00
parent 508fe3937e
commit a8b6912e44
14 changed files with 63 additions and 86 deletions

View file

@ -4900,6 +4900,36 @@ EOD;
return $CFG->release;
}
}
/**
* Generate the add block button when editing mode is turned on and the user can edit blocks.
*
* @param string $region where new blocks should be added.
* @return string html for the add block button.
*/
public function addblockbutton($region = ''): string {
$addblockbutton = '';
if (isset($this->page->theme->addblockposition) &&
$this->page->user_is_editing() &&
$this->page->user_can_edit_blocks() &&
$this->page->pagelayout !== 'mycourses'
) {
$params = ['bui_addblock' => '', 'sesskey' => sesskey()];
if (!empty($region)) {
$params['bui_blockregion'] = $region;
}
$url = new moodle_url($this->page->url, $params);
$addblockbutton = $this->render_from_template('core/add_block_button',
[
'link' => $url->out(false),
'escapedlink' => "?{$url->get_query_string(false)}",
'pageType' => $this->page->pagetype,
'pageLayout' => $this->page->pagelayout,
]
);
}
return $addblockbutton;
}
}
/**

View file

@ -28,10 +28,11 @@
}
}}
<a href="{{link}}" id="addblock-{{uniqid}}" class="btn btn-link block-add text-left" data-key="addblock" data-url="{{escapedlink}}">
{{#str}}addblock{{/str}}
<i class="fa fa-plus-square pull-right py-1" aria-hidden="true"></i>
</a>
<div class="add_block_button">
<a href="{{link}}" id="addblock-{{uniqid}}" class="btn btn-link block-add text-left mb-3" data-key="addblock" data-url="{{escapedlink}}">
<i class="fa fa-plus py-2 mr-3" aria-hidden="true"></i>{{#str}}addblock{{/str}}
</a>
</div>
{{#js}}
// Initialise the JS for the modal window which displays the blocks available to add.