Skip to content

Commit 43a3d57

Browse files
committed
Add source column to admin table
1 parent 111b282 commit 43a3d57

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

classes/snippets.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function compose_snippets_data($snippetrecordset) {
5151
$snippets = [];
5252

5353
foreach ($snippetrecordset as $snippetrecord) {
54-
if ('code' === $snippetrecord->source) {
54+
if ('theme_boost_union' === $snippetrecord->source) {
5555
// Get snippet file content.
5656
if ($snippetcontent = self::get_snippet($snippetrecord->key, $snippetrecord->domain)) {
5757
// Compose snippet file data.

classes/table/snippets_overview.php

+32-4
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ public function __construct() {
6767
// Define the headers and columns.
6868
$headers[] = get_string('snippetstitle', 'theme_boost_union');
6969
$headers[] = get_string('snippetsdescription', 'theme_boost_union');
70+
$headers[] = get_string('snippetssource', 'theme_boost_union');
7071
$headers[] = get_string('snippetsscope', 'theme_boost_union');
7172
$headers[] = get_string('snippetsgoal', 'theme_boost_union');
7273
$headers[] = get_string('up') .'/'. get_string('down');
7374
$headers[] = get_string('actions');
7475
$columns[] = 'title';
7576
$columns[] = 'description';
77+
$columns[] = 'source';
7678
$columns[] = 'scope';
7779
$columns[] = 'goal';
7880
$columns[] = 'updown';
@@ -141,6 +143,24 @@ public function col_updown($data) {
141143
return $updown;
142144
}
143145

146+
/**
147+
* Source column.
148+
*
149+
* @param \stdClass $data
150+
* @return mixed
151+
*/
152+
public function col_source($data) {
153+
// Get the string for the given scope from the language pack.
154+
$string = get_string('snippetssource'.$data->source, 'theme_boost_union');
155+
156+
// Output Bootstrap label, if a string was found.
157+
if (!empty($string)) {
158+
return \html_writer::tag('span', $string, ['class' => 'badge bg-primary text-light']);
159+
} else {
160+
return '';
161+
}
162+
}
163+
144164
/**
145165
* Scope column.
146166
*
@@ -151,8 +171,12 @@ public function col_scope($data) {
151171
// Get the string for the given scope from the language pack.
152172
$string = get_string('snippetsscope'.$data->scope, 'theme_boost_union');
153173

154-
// Output Bootstrap label.
155-
return \html_writer::tag('span', $string, ['class' => 'badge bg-primary text-light']);
174+
// Output Bootstrap label, if a string was found.
175+
if (!empty($string)) {
176+
return \html_writer::tag('span', $string, ['class' => 'badge bg-primary text-light']);
177+
} else {
178+
return '';
179+
}
156180
}
157181

158182
/**
@@ -165,8 +189,12 @@ public function col_goal($data) {
165189
// Get the string for the given goal from the language pack.
166190
$string = get_string('snippetsgoal'.$data->goal, 'theme_boost_union');
167191

168-
// Output Bootstrap label.
169-
return \html_writer::tag('span', $string, ['class' => 'badge bg-primary text-light']);
192+
// Output Bootstrap label, if a string was found.
193+
if (!empty($string)) {
194+
return \html_writer::tag('span', $string, ['class' => 'badge bg-primary text-light']);
195+
} else {
196+
return '';
197+
}
170198
}
171199

172200
/**

lang/en/theme_boost_union.php

+2
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@
11141114
$string['snippetsgoal'] = 'Goal';
11151115
$string['snippetsgoaleyecandy'] = 'Eye candy';
11161116
$string['snippetsgoalbugfix'] = 'Bugfix';
1117+
$string['snippetssource'] = 'Source';
1118+
$string['snippetssourcetheme_boost_union'] = 'Boost Union built-in';
11171119
$string['snippetssnippets'] = 'CSS snippets';
11181120
$string['snippetsnothingtodisplay'] = 'There aren\'t any CSS snippets which can be used.';
11191121
$string['snippetsoverview_desc'] = '<p>Boost Union\'s CSS snipppets offer a possibility to add small (or slightly larger) amounts of CSS to the Moodle site. This can be particularly handy for fixing small visual glitches in Moodle core or for adding eye candy to your Moodle site.</p>Please note that the CSS snippets are added to the SCSS stack one after another. Thus, the order of the snippets on this page is key.</p><p>Please note as well that after each change which you make on this page, the theme cache is purged. This is necessary to make sure that the compiled SCSS code which is shipped to the browser is up-to-date.</p>';

0 commit comments

Comments
 (0)