From d6317b575f3b9e11a4988be4ed812d431cb82822 Mon Sep 17 00:00:00 2001 From: Julen Pardo Date: Fri, 5 Feb 2016 01:18:55 +0100 Subject: [PATCH 1/2] feature: add setting to enable/disable link underlining, applying only for: - Books - Labels - Forum posts - Pages --- classes/toolbox.php | 12 ++++++++++++ lang/en/theme_essential.php | 3 +++ lib.php | 5 +++++ settings.php | 9 +++++++++ style/essential-settings.css | 13 +++++++++++++ 5 files changed, 42 insertions(+) diff --git a/classes/toolbox.php b/classes/toolbox.php index 6d2d76b2..a722dcab 100644 --- a/classes/toolbox.php +++ b/classes/toolbox.php @@ -552,6 +552,18 @@ static public function set_marketingimage($css, $marketingimage, $setting) { return $css; } + static public function set_underlinelinks($css, $underlinelinks, $setting) { + $tag = '[[setting:'.$setting.']]'; + $replacement = 'none'; + + if ($underlinelinks) { + $replacement = 'underline'; + } + $css = str_replace($tag, $replacement, $css); + + return $css; + } + static public function set_customcss($css, $customcss) { $tag = '[[setting:customcss]]'; $replacement = $customcss; diff --git a/lang/en/theme_essential.php b/lang/en/theme_essential.php index 6dd5d013..585e3690 100644 --- a/lang/en/theme_essential.php +++ b/lang/en/theme_essential.php @@ -738,3 +738,6 @@ // Incourse. $string['returntosection'] = 'Return to section {$a->section}'; +// Underline links. +$string['underlinelinks'] = 'Underline links'; +$string['underlinelinksdesc'] = 'Underline the links appearing in resources or activities (page, book, label, etc.).'; diff --git a/lib.php b/lib.php index 08218102..6608c922 100644 --- a/lib.php +++ b/lib.php @@ -422,6 +422,11 @@ function theme_essential_process_css($css, $theme) { $marketingimage = \theme_essential\toolbox::setting_file_url($setting, $setting); $css = \theme_essential\toolbox::set_marketingimage($css, $marketingimage, $setting); + // Set links underline. + $setting = 'underlinelinks'; + $underlinelinks = \theme_essential\toolbox::get_setting($setting); + $css = \theme_essential\toolbox::set_underlinelinks($css, $underlinelinks, $setting); + // Set custom CSS. $customcss = \theme_essential\toolbox::get_setting('customcss'); $css = \theme_essential\toolbox::set_customcss($css, $customcss); diff --git a/settings.php b/settings.php index ffb89ce3..2387fe35 100644 --- a/settings.php +++ b/settings.php @@ -144,6 +144,15 @@ $setting->set_updatedcallback('theme_reset_all_caches'); $temp->add($setting); + // Underline links. + $name = 'theme_essential/underlinelinks'; + $title = get_string('underlinelinks', 'theme_essential'); + $description = get_string('underlinelinksdesc', 'theme_essential'); + $default = false; + $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false); + $setting->set_updatedcallback('theme_reset_all_caches'); + $temp->add($setting); + // Custom CSS file. $name = 'theme_essential/customcss'; $title = get_string('customcss', 'theme_essential'); diff --git a/style/essential-settings.css b/style/essential-settings.css index 9bd2d274..e9ad8469 100644 --- a/style/essential-settings.css +++ b/style/essential-settings.css @@ -1403,3 +1403,16 @@ h6 span { } /* @end */ /* @end */ + +.forumpost .maincontent a{ + text-decoration: [[setting:underlinelinks]]; +} +.contentwithoutlink a{ + text-decoration: [[setting:underlinelinks]]; +} +.book_content a{ + text-decoration: [[setting:underlinelinks]]; +} +.generalbox a{ + text-decoration: [[setting:underlinelinks]]; +} \ No newline at end of file From b468f84e7a92fbaadb0c0d6c2a170a004765a1e5 Mon Sep 17 00:00:00 2001 From: Julen Pardo Date: Fri, 5 Feb 2016 12:19:55 +0100 Subject: [PATCH 2/2] feature-underlinelinks: add missing less file Created .less file with css, and added to theme-admin.less. --- less/essential/settings/theme-admin.less | 17 +++++++++++++++++ less/essential/underlinelinks.less | 16 ++++++++++++++++ style/essential-settings.css | 8 +++++--- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 less/essential/underlinelinks.less diff --git a/less/essential/settings/theme-admin.less b/less/essential/settings/theme-admin.less index a534dd28..87189699 100644 --- a/less/essential/settings/theme-admin.less +++ b/less/essential/settings/theme-admin.less @@ -497,4 +497,21 @@ h1, h2, h3, h4, h5, h6 { /* @end */ +/* @group Underlinelinks */ + +.forumpost .maincontent a{ + text-decoration: ~"[[setting:underlinelinks]]"; +} +.contentwithoutlink a{ + text-decoration: ~"[[setting:underlinelinks]]"; +} +.book_content a{ + text-decoration: ~"[[setting:underlinelinks]]"; +} +.generalbox a{ + text-decoration: ~"[[setting:underlinelinks]]"; +} + +/* @end */ + /* @end */ diff --git a/less/essential/underlinelinks.less b/less/essential/underlinelinks.less new file mode 100644 index 00000000..482b8a74 --- /dev/null +++ b/less/essential/underlinelinks.less @@ -0,0 +1,16 @@ +/* @group Underlinelinks */ + +.forumpost .maincontent a{ + text-decoration: underline; +} +.contentwithoutlink a{ + text-decoration: underline; +} +.book_content a{ + text-decoration: underline; +} +.generalbox a{ + text-decoration: underline; +} + +/* @end */ \ No newline at end of file diff --git a/style/essential-settings.css b/style/essential-settings.css index e9ad8469..11e7c0f2 100644 --- a/style/essential-settings.css +++ b/style/essential-settings.css @@ -1402,8 +1402,7 @@ h6 span { background-color: [[setting:themecolor]] !important; } /* @end */ -/* @end */ - +/* @group Underlinelinks */ .forumpost .maincontent a{ text-decoration: [[setting:underlinelinks]]; } @@ -1415,4 +1414,7 @@ h6 span { } .generalbox a{ text-decoration: [[setting:underlinelinks]]; -} \ No newline at end of file +} +/* @end */ + +/* @end */