From 4a48a4a061e19976131820d2efb644d5e572961d Mon Sep 17 00:00:00 2001
From: Alexander Bias <alexander.bias@uni-ulm.de>
Date: Tue, 6 Mar 2018 20:21:04 +0100
Subject: [PATCH] pix_url() is deprecated in Moodle 3.3, change to pix_icon()
 and fontawesome icons

---
 CHANGES.md                       |   1 +
 block_course_overview_campus.php |  32 +++++++-------------------
 lib.php                          |  37 +++++++++++++++++++++++++++++++
 pix/collapsed.png                | Bin 0 -> 134 bytes
 pix/collapsed.svg                |   3 +++
 pix/expanded.png                 | Bin 0 -> 136 bytes
 pix/expanded.svg                 |   3 +++
 pix/hide.png                     | Bin 0 -> 185 bytes
 pix/hide.svg                     |   3 +++
 pix/show.png                     | Bin 0 -> 201 bytes
 pix/show.svg                     |   3 +++
 styles.css                       |   8 +++++--
 version.php                      |   2 +-
 13 files changed, 65 insertions(+), 27 deletions(-)
 create mode 100644 lib.php
 create mode 100644 pix/collapsed.png
 create mode 100644 pix/collapsed.svg
 create mode 100644 pix/expanded.png
 create mode 100644 pix/expanded.svg
 create mode 100644 pix/hide.png
 create mode 100644 pix/hide.svg
 create mode 100644 pix/show.png
 create mode 100644 pix/show.svg

diff --git a/CHANGES.md b/CHANGES.md
index ba39284..d967dbb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,7 @@ Changes
 
 ### Unreleased
 
+* 2018-03-06 - pix_url() is deprecated in Moodle 3.3, change to pix_icon() and fontawesome icons.
 * 2017-12-12 - Prepare compatibility for Moodle 3.3, no functionality change.
 
 ### v3.2-r6
diff --git a/block_course_overview_campus.php b/block_course_overview_campus.php
index 804a8dd..d040c81 100644
--- a/block_course_overview_campus.php
+++ b/block_course_overview_campus.php
@@ -1213,23 +1213,15 @@ class block_course_overview_campus extends block_base {
                         // If course news are hidden.
                         if ($c->hidenews == false) {
                             echo '<div class="hidenewsicon">
-                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => $c->id, 'coc-shownews' => '')).'" id="coc-hidenewsicon-'.$c->id.'" title="'.get_string('hidenews', 'block_course_overview_campus').'">
-                                        <img src="'.$OUTPUT->pix_url('t/expanded').'" alt="'.get_string('hidenews', 'block_course_overview_campus').'" />
-                                    </a>
-                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => '', 'coc-shownews' => $c->id)).'" id="coc-shownewsicon-'.$c->id.'" class="coc-hidden" title="'.get_string('shownews', 'block_course_overview_campus').'">
-                                        <img src="'.$OUTPUT->pix_url('t/collapsed').'" alt="'.get_string('shownews', 'block_course_overview_campus').'" />
-                                    </a>
+                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => $c->id, 'coc-shownews' => '')).'" id="coc-hidenewsicon-'.$c->id.'" title="'.get_string('hidenews', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('expanded', get_string('hidenews', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
+                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => '', 'coc-shownews' => $c->id)).'" id="coc-shownewsicon-'.$c->id.'" class="coc-hidden" title="'.get_string('shownews', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('collapsed', get_string('shownews', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
                                 </div>';
                         }
                         // If course news are visible.
                         else {
                             echo '<div class="hidenewsicon">
-                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => $c->id, 'coc-shownews' => '')).'" id="coc-hidenewsicon-'.$c->id.'" class="coc-hidden" title="'.get_string('hidenews', 'block_course_overview_campus').'">
-                                        <img src="'.$OUTPUT->pix_url('t/expanded').'" alt="'.get_string('hidenews', 'block_course_overview_campus').'" />
-                                    </a>
-                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => '', 'coc-shownews' => $c->id)).'" id="coc-shownewsicon-'.$c->id.'" title="'.get_string('shownews', 'block_course_overview_campus').'">
-                                        <img src="'.$OUTPUT->pix_url('t/collapsed').'" alt="'.get_string('shownews', 'block_course_overview_campus').'" />
-                                    </a>
+                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => $c->id, 'coc-shownews' => '')).'" id="coc-hidenewsicon-'.$c->id.'" class="coc-hidden" title="'.get_string('hidenews', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('expanded', get_string('hidenews', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
+                                    <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidenews' => '', 'coc-shownews' => $c->id)).'" id="coc-shownewsicon-'.$c->id.'" title="'.get_string('shownews', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('collapsed', get_string('shownews', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
                                 </div>';
                         }
                     }
@@ -1240,23 +1232,15 @@ class block_course_overview_campus extends block_base {
                     // If course is hidden.
                     if (block_course_overview_campus_course_hidden_by_hidecourses($c, 0) == false) { // We can't rely on $c->hidecourse here because otherwise the icon would always be t/show.
                         echo '<div class="hidecourseicon">
-                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => $c->id, 'coc-showcourse' => '')).'" id="coc-hidecourseicon-'.$c->id.'" title="'.get_string('hidecourse', 'block_course_overview_campus').'">
-                                    <img src="'.$OUTPUT->pix_url('t/hide').'" class="icon" alt="'.get_string('hidecourse', 'block_course_overview_campus').'" />
-                                </a>
-                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => '', 'coc-showcourse' => $c->id)).'" id="coc-showcourseicon-'.$c->id.'" class="coc-hidden" title="'.get_string('showcourse', 'block_course_overview_campus').'">
-                                    <img src="'.$OUTPUT->pix_url('t/show').'" class="icon" alt="'.get_string('showcourse', 'block_course_overview_campus').'" />
-                                </a>
+                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => $c->id, 'coc-showcourse' => '')).'" id="coc-hidecourseicon-'.$c->id.'" title="'.get_string('hidecourse', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('hide', get_string('hidecourse', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
+                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => '', 'coc-showcourse' => $c->id)).'" id="coc-showcourseicon-'.$c->id.'" class="coc-hidden" title="'.get_string('showcourse', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('show', get_string('showcourse', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
                             </div>';
                     }
                     // If course is visible.
                     else {
                         echo '<div class="hidecourseicon">
-                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => $c->id, 'coc-showcourse' => '')).'" id="coc-hidecourseicon-'.$c->id.'" class="coc-hidden" title="'.get_string('hidecourse', 'block_course_overview_campus').'">
-                                    <img src="'.$OUTPUT->pix_url('t/hide').'" class="icon" alt="'.get_string('hidecourse', 'block_course_overview_campus').'" />
-                                </a>
-                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => '', 'coc-showcourse' => $c->id)).'" id="coc-showcourseicon-'.$c->id.'" title="'.get_string('showcourse', 'block_course_overview_campus').'">
-                                    <img src="'.$OUTPUT->pix_url('t/show').'" class="icon" alt="'.get_string('showcourse', 'block_course_overview_campus').'" />
-                                </a>
+                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => $c->id, 'coc-showcourse' => '')).'" id="coc-hidecourseicon-'.$c->id.'" class="coc-hidden" title="'.get_string('hidecourse', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('hide', get_string('hidecourse', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
+                                <a href="'.$CFG->wwwroot.$PAGE->url->out_as_local_url(true, array('coc-manage' => $param_manage, 'coc-hidecourse' => '', 'coc-showcourse' => $c->id)).'" id="coc-showcourseicon-'.$c->id.'" title="'.get_string('showcourse', 'block_course_overview_campus').'">'.$OUTPUT->pix_icon('show', get_string('showcourse', 'block_course_overview_campus'), 'block_course_overview_campus').'</a>
                             </div>';
                     }
                 }
diff --git a/lib.php b/lib.php
new file mode 100644
index 0000000..cd4a072
--- /dev/null
+++ b/lib.php
@@ -0,0 +1,37 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Block "course overview (campus)" - library
+ *
+ * @package    block_course_overview_campus
+ * @copyright  2013 Alexander Bias, Ulm University <alexander.bias@uni-ulm.de>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Get icon mapping for font-awesome.
+ */
+function block_course_overview_campus_get_fontawesome_icon_map() {
+    return [
+            'block_course_overview_campus:expanded' => 'fa-minus-square',
+            'block_course_overview_campus:collapsed' => 'fa-plus-square',
+            'block_course_overview_campus:hide' => 'fa-toggle-on fa-lg',
+            'block_course_overview_campus:show' => 'fa-toggle-off fa-lg',
+    ];
+}
diff --git a/pix/collapsed.png b/pix/collapsed.png
new file mode 100644
index 0000000000000000000000000000000000000000..d971d4f15af2ddada7254e9128915bbdebe7a636
GIT binary patch
literal 134
zcmeAS@N?(olHy`uVBq!ia0y~yU=RRdCT0c(hNQXTpBNYzcmjMvTp1V`X2QUer&;G1
z7#NsKg8YIR4Bm^j@*ZJeU{LdPaSW+oOm<+>QaB{!a>J5=^Eao$BhHQ=jA{?=a2lvi
e3&`bQU~ur};7q!<=obS61B0ilpUXO@geCy3m?aSa

literal 0
HcmV?d00001

diff --git a/pix/collapsed.svg b/pix/collapsed.svg
new file mode 100644
index 0000000..77c4295
--- /dev/null
+++ b/pix/collapsed.svg
@@ -0,0 +1,3 @@
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+	<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="-5 -2.1 16 16" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M.7.2C.3-.2 0 0 0 .5v10.8c0 .5.3.7.7.3l5-5c.4-.4.4-1 0-1.4l-5-5z" fill="#999"/></svg>
\ No newline at end of file
diff --git a/pix/expanded.png b/pix/expanded.png
new file mode 100644
index 0000000000000000000000000000000000000000..fb0550a6632d6c80e4c86edef4852d271120bd65
GIT binary patch
literal 136
zcmeAS@N?(olHy`uVBq!ia0y~yU=RRdCT0c(hNQXTpBNYzcmjMvTp1V`X2QUer&;G1
z7#NsKg8YIR4Bm^j@*ZJeV9@Y%aSW+oOg_N5<NyEq0|&nS|Ifm9?C*aW35iejOsq@i
hGjML>+)>KNaEgtqa+`{49|HpegQu&X%Q~loCII~-D)s;X

literal 0
HcmV?d00001

diff --git a/pix/expanded.svg b/pix/expanded.svg
new file mode 100644
index 0000000..2f7e463
--- /dev/null
+++ b/pix/expanded.svg
@@ -0,0 +1,3 @@
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+	<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="-2.1 -5 16 16" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M.5 0C0 0-.2.3.2.7l5 5c.4.4 1 .4 1.4 0l5-5c.4-.4.3-.7-.3-.7H.5z" fill="#999"/></svg>
\ No newline at end of file
diff --git a/pix/hide.png b/pix/hide.png
new file mode 100644
index 0000000000000000000000000000000000000000..290685e8a2f0a18f3dba5e5dec7be434d97bae1e
GIT binary patch
literal 185
zcmeAS@N?(olHy`uVBq!ia0y~yVBi5^7G?$ph9%LCR~Q%=R04cLTp1V`W)cFI((Vf|
zFfeeJ1o;Is7&s&pH1yA3fBt^-*X{)j3=Ec@E{-7;jL8kmimn2gTdTh(v9W!->kx2Y
z!rtOz?{40fD4V|JUD<u!C1uQ-3m)VxPzd34VGgn8VPJ^hk(xIr&!CQhfq}u()z4*}
HQ$iB}z7#_p

literal 0
HcmV?d00001

diff --git a/pix/hide.svg b/pix/hide.svg
new file mode 100644
index 0000000..1b717f7
--- /dev/null
+++ b/pix/hide.svg
@@ -0,0 +1,3 @@
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+	<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+]><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 -1.8 12 12" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M6 0C2.8 0 0 2.6 0 4.2s2.8 4.2 6 4.2 6-2.6 6-4.2S9.2 0 6 0zM2 4.2c.2-.4 1.4-1.6 3-2-.8.3-1.3 1.1-1.3 2 0 .9.5 1.7 1.3 2.1-1.6-.4-2.8-1.6-3-2.1zm3.1-.1c-.4 0-.8-.3-.8-.8s.3-.8.8-.8.8.3.8.8-.4.8-.8.8zM7 6.3c.8-.4 1.3-1.2 1.3-2.1 0-.9-.5-1.7-1.3-2.1 1.6.5 2.8 1.7 3 2.1-.2.5-1.4 1.7-3 2.1z" fill="#999"/></svg>
\ No newline at end of file
diff --git a/pix/show.png b/pix/show.png
new file mode 100644
index 0000000000000000000000000000000000000000..ed3fb4bb02b3443307203bf87d73636b1207ac64
GIT binary patch
literal 201
zcmeAS@N?(olHy`uVBq!ia0y~yVBi5^7G?$ph9%LCR~Q%=R04cLTp1V`W)cFI((Vf|
zFfeeJ1o;Is7&s&pH1yA3fBt^-*X{)j3=E#0E{-7_vaAO;@-`@lI2^owaW`Z32@eyA
z7c1@_JaXw6=O4v<%l8ZljL~U_)~#2$x?r6*zs&N$f{f|AdOl6ua{EEwCx=a`32X=W
XcdV0L_~*g*7zU83u6{1-oD!M<|2|M_

literal 0
HcmV?d00001

diff --git a/pix/show.svg b/pix/show.svg
new file mode 100644
index 0000000..c794d67
--- /dev/null
+++ b/pix/show.svg
@@ -0,0 +1,3 @@
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+	<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+]><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M11.5 4.7c.3.5.5.9.5 1.3 0 1.6-2.8 4.2-6 4.2l5.5-5.5zM12 0v2.8L2.8 12H0l2.7-2.7C1.1 8.4 0 7 0 6c0-1.6 2.8-4.2 6-4.2 1.2 0 2.3.4 3.3.9L12 0zM7.1 3.9c.2.1.4.3.5.5l.2-.2c-.2-.1-.5-.2-.7-.3zm-2 .4c-.4 0-.8.3-.8.8s.3.8.8.8.8-.3.8-.8-.4-.8-.8-.8zm-.9 3.5l.2-.2c-.5-.4-.7-1-.7-1.6 0-.9.5-1.7 1.3-2.1-1.6.4-2.8 1.6-3 2.1.2.4 1 1.3 2.2 1.8z" fill="#999"/></svg>
\ No newline at end of file
diff --git a/styles.css b/styles.css
index f2c7462..f1dc8f3 100644
--- a/styles.css
+++ b/styles.css
@@ -8,6 +8,10 @@
     float: left;
 }
 
+.block_course_overview_campus a:first-of-type > .icon {
+    margin-left: inherit; /* Get rid of a unneeded Moodle core behaviour here */
+}
+
 
 /* Used for hiding courses and news in courselist */
 .coc-hidden {
@@ -40,7 +44,7 @@
 /* Course list appearance */
 #coc-courselist .coursebox h3 {
     margin: 0; /* Remove standard margin from h3 heading*/
-    padding: 0 0 0 20px; /* Add left padding to place the course news icon there */
+    padding: 0 0 0 30px; /* Add left padding to place the course news icon there */
 }
 
 #coc-courselist .coc-metainfo {
@@ -53,7 +57,7 @@
 /* Course news appearance */
 #coc-courselist .coc-coursenews {
     border-left: 1px dashed lightgrey;
-    margin: 10px 0 0 30px;
+    margin: 10px 0 0 40px;
     padding: 0 0 0 10px;
 }
 
diff --git a/version.php b/version.php
index 2a34afb..1cf97eb 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 $plugin->component = 'block_course_overview_campus';
-$plugin->version = 2017063000;
+$plugin->version = 2018030600;
 $plugin->release = 'v3.2-r6';
 $plugin->requires = 2017051500;
 $plugin->maturity = MATURITY_STABLE;
-- 
GitLab