From 6ffa3e85b80332bb434ff866e1c0d7bc7360587c Mon Sep 17 00:00:00 2001
From: Tobias Baden <tobias.baden@stud.hs-hannover.de>
Date: Tue, 28 Aug 2018 20:52:40 +0200
Subject: [PATCH] New Version - Courselist - Added Help-Icon with help-text -
 Added the h5 icon - Changed the language file (default_blocktitle and
 orderbysemester)

---
 block_hshcourselist.php         | 60 +++++++++++++++++++++++----------
 lang/en/block_hshcourselist.php | 15 ++++++---
 style.css                       |  6 ++++
 version.php                     |  2 +-
 4 files changed, 60 insertions(+), 23 deletions(-)

diff --git a/block_hshcourselist.php b/block_hshcourselist.php
index 227cc55..2c10558 100644
--- a/block_hshcourselist.php
+++ b/block_hshcourselist.php
@@ -1,7 +1,6 @@
 <?php
 
 defined('MOODLE_INTERNAL') || die();
-
 class block_hshcourselist extends block_base {
     private $globalconf;
 
@@ -46,7 +45,7 @@ class block_hshcourselist extends block_base {
             $placeholder = "";
         }
         $list_contents = '';
-        $anchor = html_writer::tag('a', '', array('name' => 'hshcourselistanchor'));
+        $anchor = html_writer::tag('a', '', array('name' => 'hshcourselistanchor')); 
 
         $ordercheckbox = html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => 'orderbysemestercheckbox', 'id' => 'orderbysemestercheckbox_id'));
         $ordercheckbox .= html_writer::start_tag('label', array('for' => 'orderbysemestercheckbox_id'));
@@ -68,11 +67,36 @@ class block_hshcourselist extends block_base {
         $input = html_writer::empty_tag('input', $inputattrs);
 
         $questionattrs = array(
-            'src' => $OUTPUT->image_url('help', 'moodle'),
-            'class' => 'hshcoursehelpclass',
-            'id' => 'hshcoursehelpid'
+            'class' => 'icon fa fa-question-circle text-info fa-fw',
+            'title' => 'Hilfe für HsH Kurssuche',
+            'aria-label' => 'Hilfe für HsH Kurssuche',
+            'aria-hidden' => 'true'
+        );
+
+        $atagparams = array(
+            'class'=>'btn btn-link p-0',
+            'role'=>'button',
+            'data-container'=>'body',
+            'data-toggle'=>'popover',
+            'data-placement'=>'right',
+            'data-content'=>"<div class='no-overflow'><p>Die Kurssuche ist eine Volltextsuche in der Sie auch mehrere Suchbegriffe (mit Leerzeichen getrennt) eingeben können.<br/>
+               Verschiedene Suchbegriffe werden einzeln in den Kursnamen gesucht und dann eine vollständige Liste angezeigt.<br/>
+                Bsp: WiSe Programmieren => zeigt Ihnen alle Kurse, dessen Kursname oder Kurskurzname 'WiSe' <i>ODER</i> 'Programmieren' enthalten.</p>
+                <p>Kurzsuche: Möchten Sie einen Kurs schnell über die <i>'id'</i> finden, so können Sie dies durch das Voranstellen einer Raute <i>'#'</i> erreichen.<br/>
+                Bsp: <i>#3303</i> zeigt Ihnen den Kurs <i>'Moodle Demo-Kurs, ELC'</i></p>",
+            'data-html'=>'true',
+            'tabindex'=>'0',
+            'data-trigger'=>'focus',
+            'data-original-title'=>'',
+            'title'=>''
         );
-        $question = html_writer::empty_tag('img', $questionattrs);
+
+        $questionhsh = html_writer::start_span("helpbutton");
+            $questionhsh .= html_writer::start_tag('a', $atagparams);
+                $questionhsh .= html_writer::start_tag('i', $questionattrs);
+                $questionhsh .= html_writer::end_tag('i');
+            $questionhsh .= html_writer::end_tag('a');
+        $questionhsh .= html_writer::end_span();
 
         $progressattrs = array(
             'src' => $OUTPUT->image_url('i/loading_small', 'moodle'),
@@ -83,18 +107,18 @@ class block_hshcourselist extends block_base {
         $progress = html_writer::empty_tag('img', $progressattrs);
 
         $formattrs = array(
-            'id' => 'hshcourseform',
-            'method' => 'post',
-            'name' => 'hshcourselistform',
-            //'action' => $this->page->url->out().'#hshcourselistanchor'
-            'action' => new moodle_url('/')
-        );
-
-        $form = html_writer::tag('form', $idSearchinglabel.$ordercheckbox.$input.$question.$progress, $formattrs);
+                'id' => 'hshcourseform',
+                'method' => 'post',
+                'name' => 'hshcourselistform',
+                //'action' => $this->page->url->out().'#hshcourselistanchor'
+                'action' => new moodle_url('/')
+            );
+
+        $form = html_writer::tag('form', $idSearchinglabel.$ordercheckbox.$questionhsh.$input.$progress, $formattrs);
         if (!empty($hshcoursesubmit)) {
             $courses = self::get_courses($search, $context_block, $this->globalconf->splitterms,
-                $this->globalconf->restrictcontext, $this->page->context,
-                $this->globalconf->idSearching, $this->config->orderbysemester);
+                                        $this->globalconf->restrictcontext, $this->page->context,
+                                        $this->globalconf->idSearching, $this->config->orderbysemester);
 
             if (!empty($courses)) {
                 foreach ($courses as $course) {
@@ -182,7 +206,7 @@ class block_hshcourselist extends block_base {
             if($idSearch) {
                 $params = array_merge($params, array($search));
                 $where .= 'id = ?';
-                //                $where .= 'idnumber LIKE ?'; --- Bei Postgres nur "id"
+//                $where .= 'idnumber LIKE ?'; --- Bei Postgres nur "id"
             } else {
                 $params = array_merge($params, array("%$search%", "%$search%"));
                 $where .= 'shortname ILIKE ? OR fullname ILIKE ?';
@@ -208,6 +232,6 @@ class block_hshcourselist extends block_base {
 
         $fields = 'id, idnumber, shortname, fullname';
         $courses = $DB->get_recordset_select('course', $where, $params, $order, $fields);
-        return $courses;
+    return $courses;
     }
 }
diff --git a/lang/en/block_hshcourselist.php b/lang/en/block_hshcourselist.php
index f237bbe..06657f1 100644
--- a/lang/en/block_hshcourselist.php
+++ b/lang/en/block_hshcourselist.php
@@ -9,13 +9,13 @@ $string['blocksettings_display'] = 'Displaysettings';
 $string['blocksettings_title'] = 'Titlesettings';
 $string['enablecustomheader'] = 'Enable custom title';
 $string['blocktitle'] = 'Blocktitel';
-$string['default_blocktitle'] = 'HsH-Kurssuche';
+$string['default_blocktitle'] = 'Kurssuche';
 
 $string['blocksettings_footer'] = 'Footersettings';
 $string['enablefooter'] = 'Enable Footer';
 $string['blockfooter'] = 'Blockfooter';
 
-$string['headerconfig'] = 'Headerconfig';
+$string['headerconfig'] = 'Headerconfig';   
 $string['descconfig'] = 'Descconfig';
 
 $string['displaymode'] = 'Displaymethod';
@@ -23,11 +23,18 @@ $string['displayZero'] = 'Course Shortname';
 $string['displayOne'] = 'Course Fullname';
 $string['displayTwo'] = 'Course Shortname + Fullname';
 
-$string['orderbysemester'] = 'Order by semester';
+$string['orderbysemester'] = 'Aktuelle Kurse oben anzeigen';
 
 $string['loading'] = 'LOADING...';
 
 $string['idSearchingLabel'] = ">> Es wird nur nach Kurs-ID's gesucht. <<";
 
 $string['placeholder'] = "Placeholder for the searching field";
-$string['placeholder_settings'] = "Placeholder settings";
\ No newline at end of file
+$string['placeholder_settings'] = "Placeholder settings";
+
+$string["hsh_search"] = "HsH Kurssuche";
+$string["hsh_search_help"] = 'Die Kurssuche ist eine Volltextsuche in der Sie auch mehrere Suchbegriffe (mit Leerzeichen getrennt) eingeben können.
+Verschiedene Suchbegriffe werden einzeln in den Kursnamen gesucht und dann eine vollständige Liste angezeigt.
+Bsp: WiSe Programmieren => zeigt Ihnen alle Kurse, dessen Kursname oder Kurskurzname "WiSe" ODER "Programmieren" enthalten.
+Kurzsuche: Möchten Sie einen Kurs schnell über die "id" finden, so können Sie dies durch das Voranstellen einer Raute "#" erreichen.
+Bsp: #3303 zeigt Ihnen den Kurs "Moodle Demo-Kurs, ELC"';
\ No newline at end of file
diff --git a/style.css b/style.css
index 9f98cb9..2f9b937 100644
--- a/style.css
+++ b/style.css
@@ -19,6 +19,12 @@
     margin-left: 98%;
 }
 
+.block_hshcourselist {
+	h5::before {
+        content: "\f002" !important;
+    }
+}
+
 #hshcourselistsearch {
     width: 97% !important;
 }
diff --git a/version.php b/version.php
index 535b56c..2712447 100644
--- a/version.php
+++ b/version.php
@@ -1,4 +1,4 @@
 <?php
 $plugin->component = 'block_hshcourselist';
-$plugin->version = 2018082401;  // YYYYMMDDHH
+$plugin->version = 2018082800;  // YYYYMMDDHH
 $plugin->requires = 2016112900; // YYYYMMDDHH
-- 
GitLab