Skip to content

Commit 55f4ce5

Browse files
committed
dummy class for composing the snippets table
1 parent 74a851a commit 55f4ce5

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

classes/snippets.php

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
namespace theme_boost_union;
18+
19+
/**
20+
* Class snippets
21+
*
22+
* @package theme_boost_union
23+
* @copyright 2024 University of Graz
24+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25+
*/
26+
class snippets {
27+
/**
28+
* Definition of builtin snippets.
29+
* @var array
30+
*/
31+
const SNIPPETS = [
32+
'fix_border' => [
33+
'domain' => 'theme_boost_union',
34+
'title' => 'Fix Borders',
35+
'description' => 'Those borders are annoying',
36+
'scope' => 'global',
37+
'goal' => 'bug fix',
38+
'css' => '.border {radius: 4px;}',
39+
],
40+
'fix_font_color' => [
41+
'domain' => 'theme_boost_union',
42+
'title' => 'Fix font color',
43+
'scope' => 'login',
44+
'goal' => 'eye candy',
45+
'description' => 'Those borders are annoying',
46+
'css' => 'body {color: 4px;}',
47+
],
48+
'bigger_title' => [
49+
'domain' => 'theme_boost_union',
50+
'title' => 'Bigger title',
51+
'scope' => 'course',
52+
'description' => 'Make the course titles finally big enough!',
53+
'goal' => 'eye candy',
54+
'css' => 'h1 {font-size: 70px;}',
55+
],
56+
];
57+
58+
/**
59+
* Compose snippets data.
60+
* @param mixed $snippets
61+
* @return void
62+
*/
63+
public static function compose_snippets_data($snippets) {
64+
foreach ($snippets as $row => $snippet) {
65+
if ('code' === $snippet->source) {
66+
$snippet->title = self::SNIPPETS[$snippet->key]['title'];
67+
$snippet->description = self::SNIPPETS[$snippet->key]['description'];
68+
$snippet->goal = self::SNIPPETS[$snippet->key]['goal'];
69+
$snippet->scope = self::SNIPPETS[$snippet->key]['scope'];
70+
} else {
71+
unset($snippets[$row]);
72+
}
73+
}
74+
return $snippets;
75+
}
76+
}

classes/table/snippets_overview.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
namespace theme_boost_union\table;
2828

29+
use theme_boost_union\snippets;
30+
2931
defined('MOODLE_INTERNAL') || die();
3032

3133
// Require table library.
@@ -235,7 +237,9 @@ public function query_db($pagesize, $useinitialsbar = true) {
235237
ORDER BY sort';
236238

237239
// Get records.
238-
$this->rawdata = $DB->get_recordset_sql($sql);
240+
$data = $DB->get_recordset_sql($sql);
241+
242+
$this->rawdata = snippets::compose_snippets_data( $data );
239243
}
240244

241245
/**

0 commit comments

Comments
 (0)