Skip to content

Commit 8d70945

Browse files
committed
Comply to coding standard.
1 parent 2e35dee commit 8d70945

37 files changed

+485
-357
lines changed

backup/moodle2/backup_lightboxgallery_activity_task.class.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @package mod_lightboxgallery
3333
*/
3434
class backup_lightboxgallery_activity_task extends backup_activity_task {
35-
3635
/**
3736
* Define (add) particular settings this activity can have
3837
*/
@@ -60,11 +59,11 @@ public static function encode_content_links($content) {
6059
$base = preg_quote($CFG->wwwroot, "/");
6160

6261
// Link to the list of pages.
63-
$search = "/(".$base."\/mod\/lightboxgallery\/index.php\?id\=)([0-9]+)/";
62+
$search = "/(" . $base . "\/mod\/lightboxgallery\/index.php\?id\=)([0-9]+)/";
6463
$content = preg_replace($search, '$@LIGHTBOXGALLERYINDEX*$2@$', $content);
6564

6665
// Link to page view by moduleid.
67-
$search = "/(".$base."\/mod\/lightboxgallery\/view.php\?id\=)([0-9]+)/";
66+
$search = "/(" . $base . "\/mod\/lightboxgallery\/view.php\?id\=)([0-9]+)/";
6867
$content = preg_replace($search, '$@LIGHTBOXGALLERYVIEWBYID*$2@$', $content);
6968

7069
return $content;

backup/moodle2/backup_lightboxgallery_stepslib.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
* Define the complete lightboxgallery structure for backup, with file and id annotations
3232
*/
3333
class backup_lightboxgallery_activity_structure_step extends backup_activity_structure_step {
34-
3534
/**
3635
* Define the backup structure for this activity
3736
*

backup/moodle2/restore_lightboxgallery_activity_task.class.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* complete restore of the activity
3333
*/
3434
class restore_lightboxgallery_activity_task extends restore_activity_task {
35-
3635
/**
3736
* Define (add) particular settings this activity can have
3837
*/
@@ -68,7 +67,6 @@ public static function define_decode_rules() {
6867
$rules[] = new restore_decode_rule('LIGHTBOXGALLERYINDEX', '/mod/lightboxgallery/index.php?id=$1', 'course');
6968

7069
return $rules;
71-
7270
}
7371

7472
/**

backup/moodle2/restore_lightboxgallery_stepslib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
* Structure step to restore one lightboxgallery activity
3232
*/
3333
class restore_lightboxgallery_activity_structure_step extends restore_activity_structure_step {
34-
3534
/**
3635
* Define (add) particular settings this activity can have
3736
*
@@ -96,6 +95,7 @@ protected function process_lightboxgallery_comment($data) {
9695
if (isset($data->comment)) {
9796
$data->commenttext = $data->comment;
9897
}
98+
9999
$DB->insert_record('lightboxgallery_comments', $data);
100100
}
101101

classes/event/course_module_instance_list_viewed.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@
3535
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
3636
// No code required here as the parent class handles it all.
3737
}
38-

classes/event/course_module_viewed.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4242
*/
4343
class course_module_viewed extends \core\event\course_module_viewed {
44-
4544
/**
4645
* Init method.
4746
*
@@ -68,5 +67,4 @@ public function get_url() {
6867
public static function get_objectid_mapping() {
6968
return ['db' => 'lightboxgallery', 'restore' => 'lightboxgallery'];
7069
}
71-
7270
}

classes/event/gallery_searched.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4141
*/
4242
class gallery_searched extends \core\event\base {
43-
4443
/**
4544
* Init method.
4645
*
@@ -58,7 +57,7 @@ protected function init() {
5857
*/
5958
public function get_description() {
6059
$searchterm = s($this->other['searchterm']);
61-
return "The user with id '$this->userid' has searched the lightboxgallery with id '{$this->other['lightboxgalleryid']}'".
60+
return "The user with id '$this->userid' has searched the lightboxgallery with id '{$this->other['lightboxgalleryid']}'" .
6261
" for lightboxgallery images containing \"{$searchterm}\".";
6362
}
6463

@@ -77,8 +76,10 @@ public static function get_name() {
7776
* @return \moodle_url
7877
*/
7978
public function get_url() {
80-
return new \moodle_url('/mod/lightboxgallery/search.php',
81-
['id' => $this->courseid, 'gallery' => $this->other['lightboxgalleryid'], 'search' => $this->other['searchterm']]);
79+
return new \moodle_url(
80+
'/mod/lightboxgallery/search.php',
81+
['id' => $this->courseid, 'gallery' => $this->other['lightboxgalleryid'], 'search' => $this->other['searchterm']]
82+
);
8283
}
8384

8485
/**
@@ -106,6 +107,4 @@ protected function validate_data() {
106107
public static function get_other_mapping() {
107108
return [];
108109
}
109-
110110
}
111-

classes/gallery_page.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727
defined('MOODLE_INTERNAL') || die();
2828

29-
require_once(dirname(__FILE__).'/../imageclass.php');
29+
require_once(dirname(__FILE__) . '/../imageclass.php');
3030

3131
/**
3232
* This class is used to display a page of images in the gallery.
3333
*/
34-
class gallery_page {
35-
34+
class gallery_page
35+
{
3636
/**
3737
* Sort by filename.
3838
*/
@@ -115,10 +115,17 @@ public function __construct($cm, $gallery, $editing = false, $page = 0) {
115115
public function display_images() {
116116
$html = '';
117117
foreach ($this->pagefiles as $filename => $file) {
118-
$image = new \lightboxgallery_image($file, $this->gallery, $this->cm,
119-
$this->metadata[$filename], $this->pagethumbs[$filename], $this->gallery->extinfo);
118+
$image = new \lightboxgallery_image(
119+
$file,
120+
$this->gallery,
121+
$this->cm,
122+
$this->metadata[$filename],
123+
$this->pagethumbs[$filename],
124+
$this->gallery->extinfo
125+
);
120126
$html .= $image->get_image_display_html($this->editing);
121127
}
128+
122129
return $html;
123130
}
124131

@@ -155,7 +162,7 @@ protected function load_metadata() {
155162
return;
156163
}
157164

158-
list ($insql, $params) = $DB->get_in_or_equal($filenames, SQL_PARAMS_NAMED);
165+
[$insql, $params] = $DB->get_in_or_equal($filenames, SQL_PARAMS_NAMED);
159166
$params['gallery'] = $this->gallery->id;
160167
$select = "gallery = :gallery AND image $insql";
161168
$metadata = $DB->get_records_select('lightboxgallery_image_meta', $select, $params);

classes/privacy/provider.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@
3939
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4040
*/
4141
class provider implements
42-
// This plugin stores personal data.
43-
\core_privacy\local\metadata\provider,
44-
\core_privacy\local\request\core_userlist_provider,
45-
46-
// This plugin is a core_user_data_provider.
47-
\core_privacy\local\request\plugin\provider {
48-
42+
\core_privacy\local\request\core_userlist_provider,
43+
\core_privacy\local\metadata\provider,
44+
\core_privacy\local\request\plugin\provider {
4945
/**
5046
* Return the fields which contain personal data.
5147
*
@@ -108,7 +104,7 @@ public static function export_user_data(approved_contextlist $contextlist) {
108104

109105
$user = $contextlist->get_user();
110106

111-
list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
107+
[$contextsql, $contextparams] = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
112108

113109
$sql = "SELECT cm.id AS cmid,
114110
lbgc.commenttext,
@@ -138,14 +134,17 @@ public static function export_user_data(approved_contextlist $contextlist) {
138134
$context = \context_module::instance($lastcmid);
139135
self::export_lightboxgallery_data_for_user($commentdata, $context, $user);
140136
}
137+
141138
$commentdata = [];
142139
}
140+
143141
$commentdata['comments'][] = [
144142
'commenttext' => $comment->commenttext,
145143
'timemodified' => \core_privacy\local\request\transform::datetime($comment->timemodified),
146144
];
147145
$lastcmid = $comment->cmid;
148146
}
147+
149148
$lbgcomments->close();
150149

151150
// The data for the last activity won't have been written yet, so make sure to write it now!
@@ -243,7 +242,7 @@ public static function delete_data_for_users(approved_userlist $userlist) {
243242
}
244243

245244
// Prepare the SQL we'll need below.
246-
list($insql, $inparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
245+
[$insql, $inparams] = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
247246
$sql = "gallery = :instanceid AND userid {$insql}";
248247
$params = array_merge($inparams, ['instanceid' => $instanceid]);
249248

@@ -279,6 +278,7 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
279278
if (!$context instanceof \context_module) {
280279
continue;
281280
}
281+
282282
$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
283283
$DB->delete_records('lightboxgallery_comments', ['gallery' => $instanceid, 'userid' => $userid]);
284284
}

comment.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424

2525

26-
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
27-
require_once(dirname(__FILE__).'/locallib.php');
28-
require_once(dirname(__FILE__).'/comment_form.php');
26+
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
27+
require_once(dirname(__FILE__) . '/locallib.php');
28+
require_once(dirname(__FILE__) . '/comment_form.php');
2929

3030
$id = required_param('id', PARAM_INT);
3131
$delete = optional_param('delete', 0, PARAM_INT);
@@ -34,7 +34,8 @@
3434
if (!$gallery = $DB->get_record('lightboxgallery', ['id' => $id])) {
3535
throw new \moodle_exception('invalidlightboxgalleryid', 'lightboxgallery');
3636
}
37-
list($course, $cm) = get_course_and_cm_from_instance($gallery, 'lightboxgallery');
37+
38+
[$course, $cm] = get_course_and_cm_from_instance($gallery, 'lightboxgallery');
3839

3940
if ($delete && ! $comment = $DB->get_record('lightboxgallery_comments', ['gallery' => $gallery->id, 'id' => $delete])) {
4041
throw new \moodle_exception('Invalid comment ID');
@@ -49,7 +50,7 @@
4950

5051
$context = context_module::instance($cm->id);
5152

52-
$galleryurl = $CFG->wwwroot.'/mod/lightboxgallery/view.php?id='.$cm->id;
53+
$galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id;
5354

5455
if ($delete && has_capability('mod/lightboxgallery:edit', $context)) {
5556
if ($confirm && confirm_sesskey()) {
@@ -61,9 +62,11 @@
6162
echo('<br />');
6263
$paramsyes = ['id' => $gallery->id, 'delete' => $comment->id, 'sesskey' => sesskey(), 'confirm' => 1];
6364
$paramsno = ['id' => $cm->id];
64-
echo $OUTPUT->confirm(get_string('commentdelete', 'lightboxgallery'),
65-
new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes),
66-
new moodle_url('/mod/lightboxgallery/view.php', $paramsno));
65+
echo $OUTPUT->confirm(
66+
get_string('commentdelete', 'lightboxgallery'),
67+
new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes),
68+
new moodle_url('/mod/lightboxgallery/view.php', $paramsno)
69+
);
6770
echo $OUTPUT->footer();
6871
die();
6972
}
@@ -80,7 +83,7 @@
8083
if ($mform->is_cancelled()) {
8184
redirect($galleryurl);
8285
} else if ($formadata = $mform->get_data()) {
83-
$newcomment = new stdClass;
86+
$newcomment = new stdClass();
8487
$newcomment->gallery = $gallery->id;
8588
$newcomment->userid = $USER->id;
8689
$newcomment->commenttext = $formadata->comment['text'];

0 commit comments

Comments
 (0)