|
| 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 | +} |
0 commit comments