Skip to content

Commit

Permalink
Coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-csg committed Aug 30, 2024
1 parent 6aeb63c commit de2d0da
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 22 deletions.
1 change: 0 additions & 1 deletion backup/moodle2/backup_floatingbutton_block_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_floatingbutton_block_task extends backup_block_task {

/**
* Does nothing.
*
Expand Down
3 changes: 1 addition & 2 deletions backup/moodle2/restore_floatingbutton_block_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_floatingbutton_block_task extends restore_block_task {

/**
* Does nothing.
*
Expand Down Expand Up @@ -110,7 +109,7 @@ public function after_restore() {
}

foreach ($config->cmid as $key => $url) {
list($type, $id) = explode('=', $url);
[$type, $id] = explode('=', $url);
if ($type == 'cmid') {
$moduleid = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'course_module', $id);
if ($moduleid) {
Expand Down
18 changes: 10 additions & 8 deletions block_floatingbutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ public function get_special_links(): array {
*/
public function get_content(): stdClass {
global $OUTPUT, $CFG;
$dummy = new stdClass;
$dummy = new stdClass();
$dummy->text = '';
if ($this->content !== null) {
return $dummy;
}

$this->content = new stdClass;
$context = new stdClass;
$this->content = new stdClass();
$context = new stdClass();

if ($this->page->course) {
$context->courseid = $this->page->course->id;
Expand Down Expand Up @@ -171,7 +171,7 @@ public function get_content(): stdClass {
// Skip empty internal links (this could happen, when a course module that is referenced by an icon
// is not included in backup).
if (!is_null($this->config->cmid[$i])) {
list($type, $id) = explode('=', $this->config->cmid[$i]);
[$type, $id] = explode('=', $this->config->cmid[$i]);
switch ($type) {
case 'cmid':
if (in_array($id, array_keys($modinfo->get_cms()))) {
Expand Down Expand Up @@ -251,8 +251,9 @@ public function get_content(): stdClass {
break;
case 'back_to_main_page':
$url = (new moodle_url(
'/course/view.php',
['id' => $context->courseid])
'/course/view.php',
['id' => $context->courseid]
)
)->out();
$name = get_string('back_to_main_page', 'block_floatingbutton');
break;
Expand All @@ -266,8 +267,9 @@ public function get_content(): stdClass {
break;
case 'change_editor':
$url = (new moodle_url(
'/user/editor.php',
['course' => $context->courseid])
'/user/editor.php',
['course' => $context->courseid]
)
)->out();
$name = get_string('editorpreferences');
break;
Expand Down
2 changes: 1 addition & 1 deletion classes/autoupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class autoupdate {
* @param \core\event\base $event
* @return void
*/
public static function update_from_delete_event(\core\event\base $event) : void {
public static function update_from_delete_event(\core\event\base $event): void {
global $DB;
$data = $event->get_data();
if (isset($data['courseid']) && $data['courseid'] > 0) {
Expand Down
2 changes: 1 addition & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class provider implements \core_privacy\local\metadata\null_provider {
*
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
9 changes: 6 additions & 3 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ public function definition_after_data(): void {
$this->set_value($mform, 'text', 'config_textcolor[' . $i . ']', $data['config_defaulttextcolor'], true);
}
if (!isset($data['config_backgroundcolor'][$i]) || $data['config_backgroundcolor'][$i] == '') {
$this->set_value($mform,
$this->set_value(
$mform,
'text',
'config_backgroundcolor[' . $i . ']',
$data['config_defaultbackgroundcolor'],
Expand Down Expand Up @@ -404,9 +405,11 @@ public function validation($data, $files): array {
$errors = [];
if (!empty($data['config_name'])) {
for ($i = 0; $i < count($data['config_name']); $i++) {
if (isset($data['config_type'][$i]) &&
if (
isset($data['config_type'][$i]) &&
$data['config_type'][$i] == 'external' &&
empty($data['config_externalurl'][$i])) {
empty($data['config_externalurl'][$i])
) {
$errors['config_externalurl[' . $i . ']'] = get_string('missing_externalurl', 'block_floatingbutton');
}
}
Expand Down
4 changes: 2 additions & 2 deletions lang/en/block_floatingbutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
$string['icon_help'] = 'FontAwesome abbreviation of the icon';
$string['icon_missing'] = 'You have to choose an icon';
$string['iconsearch'] = 'Search icons';
$string['left'] = 'Left';
$string['internalurl'] = 'Section or activity';
$string['internalurl_help'] = 'Section or activity the button should link to';
$string['left'] = 'Left';
$string['missing_externalurl'] = 'External URL cannot be empty';
$string['name'] = 'Title';
$string['name_help'] = 'Title of the button, shown when hovering';
Expand All @@ -63,10 +63,10 @@
$string['top'] = 'Top';
$string['turn_editing_on'] = 'Turn editing on/off';
$string['type'] = 'Link type';
$string['type_external'] = 'External link';
$string['type_help'] = 'There are three types of links availabile:<br/>
- Internal links, referencing activities or sections in your course<br/>
- External links<br/>
- Links to moodle functions (e.g. turn edition off/on)';
$string['type_internal'] = 'Internal link';
$string['type_external'] = 'External link';
$string['type_special'] = 'Link to moodle functions';
8 changes: 4 additions & 4 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
get_string('defaulttextcolor', 'block_floatingbutton'),
'',
'#1C1D2F',
PARAM_TEXT)
);
PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'block_floatingbutton/defaultbackgroundcolor',
get_string('defaultbackgroundcolor', 'block_floatingbutton'),
'',
'#A4A5AC',
PARAM_TEXT)
);
PARAM_TEXT
));
}

0 comments on commit de2d0da

Please sign in to comment.