MDL-76134 core: Provide a option to render initials bars smaller
This commit is contained in:
@@ -3182,6 +3182,11 @@ class initials_bar implements renderable, templatable {
|
||||
*/
|
||||
public $alpha;
|
||||
|
||||
/**
|
||||
* @var bool Omit links if we are doing a mini render.
|
||||
*/
|
||||
public $minirender;
|
||||
|
||||
/**
|
||||
* Constructor initials_bar with only the required params.
|
||||
*
|
||||
@@ -3191,14 +3196,16 @@ class initials_bar implements renderable, templatable {
|
||||
* @param string $urlvar URL parameter name for this initial.
|
||||
* @param string $url URL object.
|
||||
* @param array $alpha of letters in the alphabet.
|
||||
* @param bool $minirender Return a trimmed down view of the initials bar.
|
||||
*/
|
||||
public function __construct($current, $class, $title, $urlvar, $url, $alpha = null) {
|
||||
public function __construct($current, $class, $title, $urlvar, $url, $alpha = null, bool $minirender = false) {
|
||||
$this->current = $current;
|
||||
$this->class = $class;
|
||||
$this->title = $title;
|
||||
$this->urlvar = $urlvar;
|
||||
$this->url = $url;
|
||||
$this->alpha = $alpha;
|
||||
$this->minirender = $minirender;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3239,7 +3246,11 @@ class initials_bar implements renderable, templatable {
|
||||
}
|
||||
$groupletter = new stdClass();
|
||||
$groupletter->name = $letter;
|
||||
$groupletter->url = $this->url->out(false, array($this->urlvar => $letter));
|
||||
if (!$this->minirender) {
|
||||
$groupletter->url = $this->url->out(false, array($this->urlvar => $letter));
|
||||
} else {
|
||||
$groupletter->input = $letter;
|
||||
}
|
||||
if ($letter == $this->current) {
|
||||
$groupletter->selected = $this->current;
|
||||
}
|
||||
@@ -3251,7 +3262,11 @@ class initials_bar implements renderable, templatable {
|
||||
|
||||
$data->class = $this->class;
|
||||
$data->title = $this->title;
|
||||
$data->url = $this->url->out(false, array($this->urlvar => ''));
|
||||
if (!$this->minirender) {
|
||||
$data->url = $this->url->out(false, array($this->urlvar => ''));
|
||||
} else {
|
||||
$data->input = 'ALL';
|
||||
}
|
||||
$data->current = $this->current;
|
||||
$data->all = get_string('all');
|
||||
|
||||
|
||||
@@ -3165,10 +3165,11 @@ EOD;
|
||||
* @param string $urlvar URL parameter name for this initial.
|
||||
* @param string $url URL object.
|
||||
* @param array $alpha of letters in the alphabet.
|
||||
* @param bool $minirender Return a trimmed down view of the initials bar.
|
||||
* @return string the HTML to output.
|
||||
*/
|
||||
public function initials_bar($current, $class, $title, $urlvar, $url, $alpha = null) {
|
||||
$ib = new initials_bar($current, $class, $title, $urlvar, $url, $alpha);
|
||||
public function initials_bar($current, $class, $title, $urlvar, $url, $alpha = null, bool $minirender = false) {
|
||||
$ib = new initials_bar($current, $class, $title, $urlvar, $url, $alpha, $minirender);
|
||||
return $this->render($ib);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,15 +78,25 @@
|
||||
|
||||
<nav class="initialbargroups d-flex flex-wrap justify-content-center justify-content-md-start">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li class="initialbarall page-item{{^current}} active{{/current}}">
|
||||
<a data-initial="" class="page-link" href="{{url}}"{{^current}} aria-current="true"{{/current}}>{{all}}</a>
|
||||
<li id="{{class}}_page-item_{{all}}" class="initialbarall page-item {{^current}}active{{/current}}">
|
||||
{{#url}}
|
||||
<a data-initial="" class="page-link" href="{{url}}"{{^current}} aria-current="true"{{/current}}>{{all}}</a>
|
||||
{{/url}}
|
||||
{{#input}}
|
||||
<input class="page-link mr-1 rounded" {{^current}} aria-current="true"{{/current}} value="{{all}}" type="button">
|
||||
{{/input}}
|
||||
</li>
|
||||
</ul>
|
||||
{{#group}}
|
||||
<ul class="pagination pagination-sm">
|
||||
{{#letter}}
|
||||
<li data-initial="{{name}}" class="page-item {{name}}{{#selected}} active{{/selected}}">
|
||||
<a class="page-link" href="{{url}}"{{#selected}} aria-current="true"{{/selected}}>{{name}}</a>
|
||||
<li id="{{class}}_page-item_{{name}}" data-initial="{{name}}" class="page-item {{name}} {{#selected}}active{{/selected}}">
|
||||
{{#url}}
|
||||
<a class="page-link" href="{{url}}"{{#selected}} aria-current="true"{{/selected}}>{{name}}</a>
|
||||
{{/url}}
|
||||
{{#input}}
|
||||
<input class="page-link mr-1 rounded" {{#selected}} aria-current="true"{{/selected}} value="{{name}}" type="button">
|
||||
{{/input}}
|
||||
</li>
|
||||
{{/letter}}
|
||||
</ul>
|
||||
|
||||
@@ -18,6 +18,9 @@ information provided here is intended especially for developers.
|
||||
It only worked with http sites and did not officially support SSL, and is at risk of disappearing should Yahoo! decide
|
||||
to remove it.
|
||||
* New `properties_filter` method of persistent class for filtering properties of a record against persistent definition
|
||||
* In outputcomponents.php, initials_bar() can now be rendered in a smaller (mini) way. This provides purely the
|
||||
initials bar without the bootstrapping and form handling on each initials bar. If you use this mini render,
|
||||
you'll need to implement your own form handling. Example usage can be found within the grader report.
|
||||
|
||||
=== 4.1 ===
|
||||
|
||||
|
||||
@@ -74,6 +74,53 @@ class core_user_renderer extends plugin_renderer_base {
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a partial user search that'll require form handling implemented by the caller.
|
||||
* This allows the developer to have an initials bar setup that does not automatically redirect.
|
||||
*
|
||||
* @param string $url the url to return to, complete with any parameters needed for the return
|
||||
* @param string $firstinitial the first initial of the firstname
|
||||
* @param string $lastinitial the first initial of the lastname
|
||||
* @param bool $minirender Return a trimmed down view of the initials bar.
|
||||
* @return string html output
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function partial_user_search(String $url, String $firstinitial, String $lastinitial, Bool $minirender = false): String {
|
||||
|
||||
$content = '';
|
||||
|
||||
if ($firstinitial !== 'all') {
|
||||
set_user_preference('ifirst', $firstinitial);
|
||||
}
|
||||
if ($lastinitial !== 'all') {
|
||||
set_user_preference('ilast', $lastinitial);
|
||||
}
|
||||
|
||||
// Initials bar.
|
||||
$prefixfirst = 'sifirst';
|
||||
$prefixlast = 'silast';
|
||||
$content .= $this->output->initials_bar(
|
||||
$firstinitial,
|
||||
'firstinitial',
|
||||
get_string('firstname'),
|
||||
$prefixfirst,
|
||||
$url,
|
||||
null,
|
||||
$minirender
|
||||
);
|
||||
$content .= $this->output->initials_bar(
|
||||
$lastinitial,
|
||||
'lastinitial',
|
||||
get_string('lastname'),
|
||||
$prefixlast,
|
||||
$url,
|
||||
null,
|
||||
$minirender
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the list of tagged users
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user