mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-37864 lib: corrections to help icon in tables
This commit is contained in:
parent
3fed76e4df
commit
edbea936c5
@ -430,16 +430,17 @@ class flexible_table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called after {@link define_headers()}.
|
||||
* Defines a help icon for the header
|
||||
*
|
||||
* Always use this function if you need to create header with sorting and help icon.
|
||||
*
|
||||
* @param int $index of header.
|
||||
* @param string $identifier the keyword that defines a help page.
|
||||
* @param string $component component name.
|
||||
* @param string|bool $linktext true means use $title as link text, string means link text value.
|
||||
*/
|
||||
public function define_help_for_header($index, $identifier, $component = 'moodle', $linktext = '') {
|
||||
global $OUTPUT;
|
||||
$this->helpforheaders[$index] = $OUTPUT->help_icon($identifier, $component, $linktext);
|
||||
$this->helpforheaders[$index] = new help_icon($identifier, $component, $linktext);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1260,15 +1261,15 @@ class flexible_table {
|
||||
// Done this way for the possibility of more than two sortable full name display fields.
|
||||
$this->headers[$index] = '';
|
||||
foreach ($requirednames as $name) {
|
||||
$helpicon = '';
|
||||
if (isset($this->helpforheaders[$index])) {
|
||||
$helpicon = $this->helpforheaders[$index];
|
||||
}
|
||||
$sortname = $this->sort_link(get_string($name),
|
||||
$name, $primarysortcolumn === $name, $primarysortorder, $helpicon);
|
||||
$name, $primarysortcolumn === $name, $primarysortorder);
|
||||
$this->headers[$index] .= $sortname . ' / ';
|
||||
}
|
||||
$this->headers[$index] = substr($this->headers[$index], 0, -3);
|
||||
$helpicon = '';
|
||||
if (isset($this->helpforheaders[$index])) {
|
||||
$helpicon = $OUTPUT->render($this->helpforheaders[$index]);
|
||||
}
|
||||
$this->headers[$index] = substr($this->headers[$index], 0, -3). $helpicon;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1281,10 +1282,10 @@ class flexible_table {
|
||||
if ($this->is_sortable($column)) {
|
||||
$helpicon = '';
|
||||
if (isset($this->helpforheaders[$index])) {
|
||||
$helpicon = $this->helpforheaders[$index];
|
||||
$helpicon = $OUTPUT->render($this->helpforheaders[$index]);
|
||||
}
|
||||
$this->headers[$index] = $this->sort_link($this->headers[$index],
|
||||
$column, $primarysortcolumn == $column, $primarysortorder, $helpicon);
|
||||
$column, $primarysortcolumn == $column, $primarysortorder) . $helpicon;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1302,7 +1303,7 @@ class flexible_table {
|
||||
}
|
||||
$helpicon = '';
|
||||
if (isset($this->helpforheaders[$index]) && !$this->is_sortable($column)) {
|
||||
$helpicon = $this->helpforheaders[$index];
|
||||
$helpicon = $OUTPUT->render($this->helpforheaders[$index]);
|
||||
}
|
||||
$content = $this->headers[$index] . $helpicon . html_writer::tag('div',
|
||||
$icon_hide, array('class' => 'commands'));
|
||||
@ -1357,15 +1358,14 @@ class flexible_table {
|
||||
* @param string $column the column name, may be a fake column like 'firstname' or a real one.
|
||||
* @param bool $isprimary whether the is column is the current primary sort column.
|
||||
* @param int $order SORT_ASC or SORT_DESC
|
||||
* @param string $helpicon if the header contains helpicon must be used exactly this param.
|
||||
* @return string HTML fragment.
|
||||
*/
|
||||
protected function sort_link($text, $column, $isprimary, $order, $helpicon = '') {
|
||||
protected function sort_link($text, $column, $isprimary, $order) {
|
||||
return html_writer::link($this->baseurl->out(false,
|
||||
array($this->request[TABLE_VAR_SORT] => $column)),
|
||||
$text . get_accesshide(get_string('sortby') . ' ' .
|
||||
$text . ' ' . $this->sort_order_name($isprimary, $order))) . ' ' .
|
||||
$helpicon . ' ' . $this->sort_icon($isprimary, $order);
|
||||
$this->sort_icon($isprimary, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user