Skip to content

Commit 93f017d

Browse files
committed
Add filemanager for uploaded snippets
1 parent 8268182 commit 93f017d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lang/en/theme_boost_union.php

+9
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@
11311131
$string['snippetssnippets'] = 'CSS snippets';
11321132
$string['snippetssource'] = 'Source';
11331133
$string['snippetssourcetheme_boost_union'] = 'Boost Union built-in';
1134+
$string['snippetssourceuploaded'] = 'Upload';
11341135
$string['snippetstitle'] = 'Title';
11351136
$string['snippetsusagenote'] = 'Usage note';
11361137

@@ -1141,6 +1142,14 @@
11411142
// ... ... Setting: Enable built-in snippets.
11421143
$string['enablebuiltinsnippets'] = 'Enable built-in snippets';
11431144
$string['enablebuiltinsnippets_desc'] = 'With this setting, you can enable or disable the built-in CSS snippets which are shipped with Boost Union. If you disable this setting, all built-in CSS snippets are ignored and never added to the SCSS stack.';
1145+
// ... Section: Uploaded snippets.
1146+
$string['snippetsuploadedsnippetsheading'] = 'Uploaded snippets';
1147+
// ... ... Setting: Enable uploaded snippets.
1148+
$string['enableuploadedsnippets'] = 'Enable uploaded snippets';
1149+
$string['enableuploadedsnippets_desc'] = 'With this setting, you can enable or disable uploading of CSS snippets within the Boost Union settings. If you disable this setting, uploading CSS snippets is not possible and all previously uploaded CSS snippets are ignored and never added to the SCSS stack.';
1150+
// ... ... Setting: Upload snippets.
1151+
$string['uploadedsnippets'] = 'Upload snippets';
1152+
$string['uploadedsnippets_desc'] = 'Here, you can upload CSS snippets to be used in this Moodle instance. You can find the structure and syntax of the CSS snippets in our <a href="{$a->url}" target="_blank"">community snippet repository</a>.';
11441153

11451154
// Settings: Smart menus page.
11461155
$string['smartmenus'] = 'Smart menus';

settings.php

+30
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use theme_boost_union\admin_setting_configtext_url;
2828
use theme_boost_union\admin_settingspage_tabs_with_external;
2929
use theme_boost_union\admin_externalpage_in_tab;
30+
use theme_boost_union\snippets;
3031
use core\di;
3132
use core\hook\manager as hook_manager;
3233

@@ -2858,6 +2859,35 @@
28582859
$setting->set_updatedcallback('theme_reset_all_caches');
28592860
$tab->add($setting);
28602861

2862+
// Create uploaded snippets heading.
2863+
$name = 'theme_boost_union/uploadedsnippetsheading';
2864+
$title = get_string('snippetsuploadedsnippetsheading', 'theme_boost_union', null, true);
2865+
$setting = new admin_setting_heading($name, $title, null);
2866+
$tab->add($setting);
2867+
2868+
// Setting: Enable uploaded snippets.
2869+
$name = 'theme_boost_union/enableuploadedsnippets';
2870+
$title = get_string('enableuploadedsnippets', 'theme_boost_union', null, true);
2871+
$description = get_string('enableuploadedsnippets_desc', 'theme_boost_union', null, true);
2872+
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
2873+
$setting->set_updatedcallback('theme_reset_all_caches');
2874+
$tab->add($setting);
2875+
2876+
// Setting: Uploaded snippets.
2877+
$name = 'theme_boost_union/uploadedsnippets';
2878+
$title = get_string('uploadedsnippets', 'theme_boost_union', null, true);
2879+
$snippetrepourl = 'https://github.com/moodle-an-hochschulen/moodle-theme_boost_union_snippets';
2880+
$description = get_string('uploadedsnippets_desc', 'theme_boost_union', ['url' => $snippetrepourl], true);
2881+
$uploadedsnippetsextensions = array_map(function($item) {
2882+
return '.'.$item;
2883+
}, snippets::ALLOWED_PREVIEW_FILE_EXTENSIONS);;
2884+
$uploadedsnippetsextensions[] = '.scss';
2885+
$setting = new admin_setting_configstoredfile($name, $title, $description, 'snippets', 0,
2886+
['maxfiles' => -1, 'subdirs' => 0, 'accepted_types' => $uploadedsnippetsextensions]);
2887+
$tab->add($setting);
2888+
$page->hide_if('theme_boost_union/uploadedsnippets', 'theme_boost_union/enableuploadedsnippets', 'neq',
2889+
THEME_BOOST_UNION_SETTING_SELECT_YES);
2890+
28612891
// Add tab to settings page.
28622892
$page->add($tab);
28632893

0 commit comments

Comments
 (0)