MDL-85981 forum: Remove stringmanager from overview page

This commit is contained in:
Sara Arjona
2025-08-25 12:52:47 +02:00
parent 6509b43b4c
commit e5191f1dd4
@@ -16,13 +16,13 @@
namespace mod_forum\courseformat;
use action_link;
use cm_info;
use core\url;
use action_link;
use core_calendar\output\humandate;
use core_courseformat\local\overview\overviewitem;
use core\output\local\properties\button;
use core\output\local\properties\text_align;
use core_courseformat\local\overview\overviewitem;
/**
* Forum overview integration.
@@ -44,15 +44,12 @@ class overview extends \core_courseformat\activityoverviewbase {
*
* @param cm_info $cm the course module instance.
* @param \core\output\renderer_helper $rendererhelper the renderer helper.
* @param \core_string_manager $stringmanager the string manager.
* @param \moodle_database $db the database helper.
*/
public function __construct(
cm_info $cm,
/** @var \core\output\renderer_helper $rendererhelper the renderer helper */
protected readonly \core\output\renderer_helper $rendererhelper,
/** @var \core_string_manager $stringmanager the string manager */
protected readonly \core_string_manager $stringmanager,
/** @var \moodle_database The database instance */
protected readonly \moodle_database $db,
) {
@@ -83,13 +80,13 @@ class overview extends \core_courseformat\activityoverviewbase {
if (empty($duedate)) {
return new overviewitem(
name: $this->stringmanager->get_string('duedate', 'mod_forum'),
name: get_string('duedate', 'mod_forum'),
value: null,
content: '-',
);
}
return new overviewitem(
name: $this->stringmanager->get_string('duedate', 'mod_forum'),
name: get_string('duedate', 'mod_forum'),
value: $duedate,
content: humandate::create_from_timestamp($duedate),
);
@@ -126,7 +123,7 @@ class overview extends \core_courseformat\activityoverviewbase {
}, 0); // The '0' is the initial value of $sum.
$totalreplies += $totaldiscussions; // Add the discussions to the replies count.
$alertlabel = $this->stringmanager->get_string('unreadposts', 'mod_forum');
$alertlabel = get_string('unreadposts', 'mod_forum');
$badge = '';
$unread = forum_tp_count_forum_unread_posts($this->cm, $this->course);
@@ -145,7 +142,7 @@ class overview extends \core_courseformat\activityoverviewbase {
);
return new overviewitem(
name: $this->stringmanager->get_string('posts', 'mod_forum'),
name: get_string('posts', 'mod_forum'),
value: $totalreplies ? : '0',
content: $content,
alertcount: $unread,
@@ -167,7 +164,7 @@ class overview extends \core_courseformat\activityoverviewbase {
$allforumtypesnames = forum_get_forum_types_all();
return new overviewitem(
name: $this->stringmanager->get_string('forumtype', 'mod_forum'),
name: get_string('forumtype', 'mod_forum'),
value: $this->forum->type,
content: $allforumtypesnames[$this->forum->type],
);
@@ -188,30 +185,30 @@ class overview extends \core_courseformat\activityoverviewbase {
(intval($this->forum->trackingtype) == FORUM_TRACKING_FORCED)
&& ($CFG->forum_allowforcedreadtracking)
) {
$label = $this->stringmanager->get_string(
$label = get_string(
'labelvalue',
'core',
[
'label' => $this->stringmanager->get_string('trackforum', 'mod_forum'),
'value' => $this->stringmanager->get_string('trackingon', 'mod_forum'),
'label' => get_string('trackforum', 'mod_forum'),
'value' => get_string('trackingon', 'mod_forum'),
],
);
$disabled = true;
$tracked = true;
} else if (intval($this->forum->trackingtype) === FORUM_TRACKING_OFF) {
$label = $this->stringmanager->get_string(
$label = get_string(
'labelvalue',
'core',
[
'label' => $this->stringmanager->get_string('trackforum', 'mod_forum'),
'value' => $this->stringmanager->get_string('trackingoff', 'mod_forum'),
'label' => get_string('trackforum', 'mod_forum'),
'value' => get_string('trackingoff', 'mod_forum'),
],
);
$disabled = true;
} else if (forum_tp_can_track_forums($this->forum)) {
$tracked = forum_tp_is_tracked($this->forum);
$disabled = false;
$label = $this->stringmanager->get_string('trackforum', 'mod_forum');
$label = get_string('trackforum', 'mod_forum');
}
$renderer = $this->rendererhelper->get_renderer('mod_forum');
@@ -240,7 +237,7 @@ class overview extends \core_courseformat\activityoverviewbase {
);
return new overviewitem(
name: $this->stringmanager->get_string('tracking', 'mod_forum'),
name: get_string('tracking', 'mod_forum'),
value: $label,
content: $content,
);
@@ -259,22 +256,22 @@ class overview extends \core_courseformat\activityoverviewbase {
if (\mod_forum\subscriptions::is_forcesubscribed($this->forum)) {
$disabled = true;
$subscribed = true;
$label = $this->stringmanager->get_string('subscribed', 'mod_forum');
$label = get_string('subscribed', 'mod_forum');
} else if (
\mod_forum\subscriptions::subscription_disabled($this->forum)
&& !has_capability('mod/forum:managesubscriptions', $this->context)
) {
$disabled = true;
$label = $this->stringmanager->get_string('unsubscribed', 'mod_forum');
$label = get_string('unsubscribed', 'mod_forum');
} else if (!is_enrolled($this->context, $this->user, '', true)) {
$disabled = true;
$label = $this->stringmanager->get_string('unsubscribed', 'mod_forum');
$label = get_string('unsubscribed', 'mod_forum');
} else {
$subscribed = \mod_forum\subscriptions::is_subscribed($this->user->id, $this->forum);
if ($subscribed) {
$label = $this->stringmanager->get_string('unsubscribe', 'mod_forum');
$label = get_string('unsubscribe', 'mod_forum');
} else {
$label = $this->stringmanager->get_string('subscribe', 'mod_forum');
$label = get_string('subscribe', 'mod_forum');
}
}
@@ -304,7 +301,7 @@ class overview extends \core_courseformat\activityoverviewbase {
);
return new overviewitem(
name: $this->stringmanager->get_string('subscribed', 'mod_forum'),
name: get_string('subscribed', 'mod_forum'),
value: $label,
content: $content,
);
@@ -331,7 +328,7 @@ class overview extends \core_courseformat\activityoverviewbase {
$options = forum_get_user_digest_options();
return new overviewitem(
name: $this->stringmanager->get_string('digesttype', 'mod_forum'),
name: get_string('digesttype', 'mod_forum'),
value: $options[$this->forum->maildigest] ?? '-',
content: $content ?? '-',
);
@@ -347,7 +344,7 @@ class overview extends \core_courseformat\activityoverviewbase {
$totaldiscussions = forum_count_discussions($this->forum, $this->cm, $this->course);
return new overviewitem(
name: $this->stringmanager->get_string('discussions', 'mod_forum'),
name: get_string('discussions', 'mod_forum'),
value: $totaldiscussions,
content: $totaldiscussions,
textalign: text_align::END,