diff --git a/block_hshcourselist.php b/block_hshcourselist.php index 49f451e506391b552daeef71ccdebf2e059208bc..227cc550c261f8bee0fc224f3e20861d3a9af65d 100644 --- a/block_hshcourselist.php +++ b/block_hshcourselist.php @@ -25,7 +25,7 @@ class block_hshcourselist extends block_base { } public function get_content() { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $this->page->requires->js('/blocks/hshcourselist/javascript/jquery-3.2.0.min.js'); $this->page->requires->js('/blocks/hshcourselist/javascript/listselect.js'); @@ -39,8 +39,14 @@ class block_hshcourselist extends block_base { $context_block = context_block::instance($this->instance->id); $search = optional_param('hshcoursesearch', '', PARAM_TEXT); $hshcoursesubmit = optional_param('hshcoursesubmit', false, PARAM_TEXT); + // set placeholder + if($this->config->placeholder) { + $placeholder = $this->config->placeholder; + } else { + $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')); @@ -56,12 +62,20 @@ class block_hshcourselist extends block_base { 'name' => 'hshcourselistsearch', 'id' => 'hshcourselistsearch', 'class' => 'form-control', - 'value' => $search + 'value' => $search, + 'placeholder' => $placeholder ); $input = html_writer::empty_tag('input', $inputattrs); + $questionattrs = array( + 'src' => $OUTPUT->image_url('help', 'moodle'), + 'class' => 'hshcoursehelpclass', + 'id' => 'hshcoursehelpid' + ); + $question = html_writer::empty_tag('img', $questionattrs); + $progressattrs = array( - 'src' => $this->page->theme->pix_url('i/loading_small', 'moodle'), + 'src' => $OUTPUT->image_url('i/loading_small', 'moodle'), 'class' => 'hshcourseprogress', 'id' => 'hshcourseprogress', 'alt' => get_string('loading', 'block_hshcourselist') @@ -69,18 +83,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.$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.$input.$question.$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) { @@ -104,6 +118,17 @@ class block_hshcourselist extends block_base { } } + if(!isset($this->config->orderbysemester)) { + $orderbysemester = false; + } else { + $orderbysemester = $this->config->orderbysemester; + } + if(!isset($this->config->displaymode)) { + $displaymode = 2; + } else { + $displaymode = $this->config->displaymode; + } + $list = html_writer::tag('ul', $list_contents, array('id' => 'hshcourselistul')); $this->content->text = $anchor.$form.$list; $jsmodule = array( @@ -119,8 +144,8 @@ class block_hshcourselist extends block_base { Notice: Trying to get property of non-object in C:\Dev\xampp\htdocs\moodle\blocks\hshcourselist\block_hshcourselist.php on line 118 (123) */ - 'displaymode' => $this->config->displaymode, - 'orderbysemester' => $this->config->orderbysemester, + 'displaymode' => $displaymode, + 'orderbysemester' => $orderbysemester, 'contextid' => $this->page->context->id ); $this->page->requires->js_call_amd('block_hshcourselist/jmodule', 'init', array($jsdata)); @@ -157,7 +182,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 ?'; @@ -183,6 +208,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/edit_form.php b/edit_form.php index 82b970302716bb7225e011951039cee5188cb4e3..c0bc59d481d24ef9a6ce4da55aab0666673b3f1c 100644 --- a/edit_form.php +++ b/edit_form.php @@ -11,6 +11,12 @@ class block_hshcourselist_edit_form extends block_edit_form { $mform->setDefault('config_title', get_string('default_blocktitle', 'block_hshcourselist')); $mform->setType('config_title', PARAM_TEXT); + //Placeholder Text + $mform->addElement('header', 'placeholdersettings',get_string('placeholder_settings', 'block_hshcourselist')); + $mform->addElement('text', 'config_placeholder', get_string('placeholder', 'block_hshcourselist')); + $mform->setDefault('config_placeholder', ""); + $mform->setType('config_placeholder', PARAM_TEXT); + // Displaysettings $mform->addElement('header', 'displaysettings', get_string('blocksettings_display', 'block_hshcourselist')); $selectoptions = array(0 => get_string('displayZero', 'block_hshcourselist'), diff --git a/lang/en/block_hshcourselist.php b/lang/en/block_hshcourselist.php index 02572d6b2985921315df7ee3fb6c60d7116a4a18..f237bbed7ebb2b81f038522a8398bddcd9253104 100644 --- a/lang/en/block_hshcourselist.php +++ b/lang/en/block_hshcourselist.php @@ -15,7 +15,7 @@ $string['blocksettings_footer'] = 'Footersettings'; $string['enablefooter'] = 'Enable Footer'; $string['blockfooter'] = 'Blockfooter'; -$string['headerconfig'] = 'Headerconfig'; +$string['headerconfig'] = 'Headerconfig'; $string['descconfig'] = 'Descconfig'; $string['displaymode'] = 'Displaymethod'; @@ -27,4 +27,7 @@ $string['orderbysemester'] = 'Order by semester'; $string['loading'] = 'LOADING...'; -$string['idSearchingLabel'] = ">> Es wird nur nach Kurs-ID's gesucht. <<"; \ No newline at end of file +$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 diff --git a/style.css b/style.css index 2f82d86e8f925dc99da5653cd0b018270956bf9c..9f98cb9791b2bf53b6b6c80118ca067c325dde93 100644 --- a/style.css +++ b/style.css @@ -14,6 +14,15 @@ color: white; } +#hshcoursehelpid, .hshcoursehelpclass { + margin-top: -61px; + margin-left: 98%; +} + +#hshcourselistsearch { + width: 97% !important; +} + /* * Aus Bootstrap 4 (Einheitliches Design wird "erzwungen", auch in Bootstrap 3 Themes) */ diff --git a/version.php b/version.php index e15363af41f210b37e55aad41369d7f6831d1198..535b56cb3606ee33a4e9692902268b219428e442 100644 --- a/version.php +++ b/version.php @@ -1,4 +1,4 @@ <?php $plugin->component = 'block_hshcourselist'; -$plugin->version = 2018081001; // YYYYMMDDHH +$plugin->version = 2018082401; // YYYYMMDDHH $plugin->requires = 2016112900; // YYYYMMDDHH