diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml
index 8fe68a4..e845a4d 100644
--- a/.github/workflows/moodle-plugin-ci.yml
+++ b/.github/workflows/moodle-plugin-ci.yml
@@ -8,7 +8,7 @@ jobs:
services:
postgres:
- image: postgres:14
+ image: postgres:15
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
@@ -49,6 +49,12 @@ jobs:
- php: 8.2
moodle-branch: MOODLE_500_STABLE
database: pgsql
+ - php: 8.2
+ moodle-branch: MOODLE_501_STABLE
+ database: mariadb
+ - php: 8.2
+ moodle-branch: MOODLE_501_STABLE
+ database: pgsql
- php: 8.3
moodle-branch: MOODLE_405_STABLE
database: mariadb
@@ -61,12 +67,24 @@ jobs:
- php: 8.3
moodle-branch: MOODLE_500_STABLE
database: pgsql
+ - php: 8.3
+ moodle-branch: MOODLE_501_STABLE
+ database: mariadb
+ - php: 8.3
+ moodle-branch: MOODLE_501_STABLE
+ database: pgsql
- php: 8.4
moodle-branch: MOODLE_500_STABLE
database: mariadb
- php: 8.4
moodle-branch: MOODLE_500_STABLE
database: pgsql
+ - php: 8.4
+ moodle-branch: MOODLE_501_STABLE
+ database: mariadb
+ - php: 8.4
+ moodle-branch: MOODLE_501_STABLE
+ database: pgsql
steps:
- name: Check out repository code
diff --git a/backup/moodle2/backup_lightboxgallery_activity_task.class.php b/backup/moodle2/backup_lightboxgallery_activity_task.class.php
index 2101524..82530ee 100644
--- a/backup/moodle2/backup_lightboxgallery_activity_task.class.php
+++ b/backup/moodle2/backup_lightboxgallery_activity_task.class.php
@@ -32,7 +32,6 @@
* @package mod_lightboxgallery
*/
class backup_lightboxgallery_activity_task extends backup_activity_task {
-
/**
* Define (add) particular settings this activity can have
*/
@@ -60,11 +59,11 @@ public static function encode_content_links($content) {
$base = preg_quote($CFG->wwwroot, "/");
// Link to the list of pages.
- $search = "/(".$base."\/mod\/lightboxgallery\/index.php\?id\=)([0-9]+)/";
+ $search = "/(" . $base . "\/mod\/lightboxgallery\/index.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@LIGHTBOXGALLERYINDEX*$2@$', $content);
// Link to page view by moduleid.
- $search = "/(".$base."\/mod\/lightboxgallery\/view.php\?id\=)([0-9]+)/";
+ $search = "/(" . $base . "\/mod\/lightboxgallery\/view.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@LIGHTBOXGALLERYVIEWBYID*$2@$', $content);
return $content;
diff --git a/backup/moodle2/backup_lightboxgallery_stepslib.php b/backup/moodle2/backup_lightboxgallery_stepslib.php
index 76f115b..9c8725a 100644
--- a/backup/moodle2/backup_lightboxgallery_stepslib.php
+++ b/backup/moodle2/backup_lightboxgallery_stepslib.php
@@ -31,7 +31,6 @@
* Define the complete lightboxgallery structure for backup, with file and id annotations
*/
class backup_lightboxgallery_activity_structure_step extends backup_activity_structure_step {
-
/**
* Define the backup structure for this activity
*
diff --git a/backup/moodle2/restore_lightboxgallery_activity_task.class.php b/backup/moodle2/restore_lightboxgallery_activity_task.class.php
index 2bbe9e9..c295160 100644
--- a/backup/moodle2/restore_lightboxgallery_activity_task.class.php
+++ b/backup/moodle2/restore_lightboxgallery_activity_task.class.php
@@ -32,7 +32,6 @@
* complete restore of the activity
*/
class restore_lightboxgallery_activity_task extends restore_activity_task {
-
/**
* Define (add) particular settings this activity can have
*/
@@ -68,7 +67,6 @@ public static function define_decode_rules() {
$rules[] = new restore_decode_rule('LIGHTBOXGALLERYINDEX', '/mod/lightboxgallery/index.php?id=$1', 'course');
return $rules;
-
}
/**
diff --git a/backup/moodle2/restore_lightboxgallery_stepslib.php b/backup/moodle2/restore_lightboxgallery_stepslib.php
index 5ad8fbe..2af386a 100644
--- a/backup/moodle2/restore_lightboxgallery_stepslib.php
+++ b/backup/moodle2/restore_lightboxgallery_stepslib.php
@@ -31,7 +31,6 @@
* Structure step to restore one lightboxgallery activity
*/
class restore_lightboxgallery_activity_structure_step extends restore_activity_structure_step {
-
/**
* Define (add) particular settings this activity can have
*
@@ -96,6 +95,7 @@ protected function process_lightboxgallery_comment($data) {
if (isset($data->comment)) {
$data->commenttext = $data->comment;
}
+
$DB->insert_record('lightboxgallery_comments', $data);
}
diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php
index 6d479bb..d67704b 100644
--- a/classes/event/course_module_instance_list_viewed.php
+++ b/classes/event/course_module_instance_list_viewed.php
@@ -35,4 +35,3 @@
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
// No code required here as the parent class handles it all.
}
-
diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php
index 7336a13..e7dd5a6 100644
--- a/classes/event/course_module_viewed.php
+++ b/classes/event/course_module_viewed.php
@@ -41,7 +41,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_viewed extends \core\event\course_module_viewed {
-
/**
* Init method.
*
@@ -68,5 +67,4 @@ public function get_url() {
public static function get_objectid_mapping() {
return ['db' => 'lightboxgallery', 'restore' => 'lightboxgallery'];
}
-
}
diff --git a/classes/event/gallery_searched.php b/classes/event/gallery_searched.php
index 2dfde3f..b95282f 100644
--- a/classes/event/gallery_searched.php
+++ b/classes/event/gallery_searched.php
@@ -40,7 +40,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gallery_searched extends \core\event\base {
-
/**
* Init method.
*
@@ -58,7 +57,7 @@ protected function init() {
*/
public function get_description() {
$searchterm = s($this->other['searchterm']);
- return "The user with id '$this->userid' has searched the lightboxgallery with id '{$this->other['lightboxgalleryid']}'".
+ return "The user with id '$this->userid' has searched the lightboxgallery with id '{$this->other['lightboxgalleryid']}'" .
" for lightboxgallery images containing \"{$searchterm}\".";
}
@@ -77,8 +76,10 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/lightboxgallery/search.php',
- ['id' => $this->courseid, 'gallery' => $this->other['lightboxgalleryid'], 'search' => $this->other['searchterm']]);
+ return new \moodle_url(
+ '/mod/lightboxgallery/search.php',
+ ['id' => $this->courseid, 'gallery' => $this->other['lightboxgalleryid'], 'search' => $this->other['searchterm']]
+ );
}
/**
@@ -106,6 +107,4 @@ protected function validate_data() {
public static function get_other_mapping() {
return [];
}
-
}
-
diff --git a/classes/gallery_page.php b/classes/gallery_page.php
index fc3d4f6..8507959 100644
--- a/classes/gallery_page.php
+++ b/classes/gallery_page.php
@@ -26,13 +26,12 @@
defined('MOODLE_INTERNAL') || die();
-require_once(dirname(__FILE__).'/../imageclass.php');
+require_once(dirname(__FILE__) . '/../imageclass.php');
/**
* This class is used to display a page of images in the gallery.
*/
class gallery_page {
-
/**
* Sort by filename.
*/
@@ -115,10 +114,17 @@ public function __construct($cm, $gallery, $editing = false, $page = 0) {
public function display_images() {
$html = '';
foreach ($this->pagefiles as $filename => $file) {
- $image = new \lightboxgallery_image($file, $this->gallery, $this->cm,
- $this->metadata[$filename], $this->pagethumbs[$filename], $this->gallery->extinfo);
+ $image = new \lightboxgallery_image(
+ $file,
+ $this->gallery,
+ $this->cm,
+ $this->metadata[$filename],
+ $this->pagethumbs[$filename],
+ $this->gallery->extinfo
+ );
$html .= $image->get_image_display_html($this->editing);
}
+
return $html;
}
@@ -155,7 +161,7 @@ protected function load_metadata() {
return;
}
- list ($insql, $params) = $DB->get_in_or_equal($filenames, SQL_PARAMS_NAMED);
+ [$insql, $params] = $DB->get_in_or_equal($filenames, SQL_PARAMS_NAMED);
$params['gallery'] = $this->gallery->id;
$select = "gallery = :gallery AND image $insql";
$metadata = $DB->get_records_select('lightboxgallery_image_meta', $select, $params);
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index 9678332..26298dc 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -39,13 +39,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
- // This plugin stores personal data.
- \core_privacy\local\metadata\provider,
- \core_privacy\local\request\core_userlist_provider,
-
- // This plugin is a core_user_data_provider.
- \core_privacy\local\request\plugin\provider {
-
+ \core_privacy\local\request\core_userlist_provider,
+ \core_privacy\local\metadata\provider,
+ \core_privacy\local\request\plugin\provider {
/**
* Return the fields which contain personal data.
*
@@ -108,7 +104,7 @@ public static function export_user_data(approved_contextlist $contextlist) {
$user = $contextlist->get_user();
- list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
+ [$contextsql, $contextparams] = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
$sql = "SELECT cm.id AS cmid,
lbgc.commenttext,
@@ -138,14 +134,17 @@ public static function export_user_data(approved_contextlist $contextlist) {
$context = \context_module::instance($lastcmid);
self::export_lightboxgallery_data_for_user($commentdata, $context, $user);
}
+
$commentdata = [];
}
+
$commentdata['comments'][] = [
'commenttext' => $comment->commenttext,
'timemodified' => \core_privacy\local\request\transform::datetime($comment->timemodified),
];
$lastcmid = $comment->cmid;
}
+
$lbgcomments->close();
// 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) {
}
// Prepare the SQL we'll need below.
- list($insql, $inparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
+ [$insql, $inparams] = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
$sql = "gallery = :instanceid AND userid {$insql}";
$params = array_merge($inparams, ['instanceid' => $instanceid]);
@@ -279,6 +278,7 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
if (!$context instanceof \context_module) {
continue;
}
+
$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
$DB->delete_records('lightboxgallery_comments', ['gallery' => $instanceid, 'userid' => $userid]);
}
diff --git a/comment.php b/comment.php
index d76f7c9..b19fe1a 100644
--- a/comment.php
+++ b/comment.php
@@ -23,9 +23,9 @@
*/
-require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
-require_once(dirname(__FILE__).'/locallib.php');
-require_once(dirname(__FILE__).'/comment_form.php');
+require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
+require_once(dirname(__FILE__) . '/locallib.php');
+require_once(dirname(__FILE__) . '/comment_form.php');
$id = required_param('id', PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
@@ -34,7 +34,8 @@
if (!$gallery = $DB->get_record('lightboxgallery', ['id' => $id])) {
throw new \moodle_exception('invalidlightboxgalleryid', 'lightboxgallery');
}
-list($course, $cm) = get_course_and_cm_from_instance($gallery, 'lightboxgallery');
+
+[$course, $cm] = get_course_and_cm_from_instance($gallery, 'lightboxgallery');
if ($delete && ! $comment = $DB->get_record('lightboxgallery_comments', ['gallery' => $gallery->id, 'id' => $delete])) {
throw new \moodle_exception('Invalid comment ID');
@@ -49,7 +50,7 @@
$context = context_module::instance($cm->id);
-$galleryurl = $CFG->wwwroot.'/mod/lightboxgallery/view.php?id='.$cm->id;
+$galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id;
if ($delete && has_capability('mod/lightboxgallery:edit', $context)) {
if ($confirm && confirm_sesskey()) {
@@ -61,9 +62,11 @@
echo('
');
$paramsyes = ['id' => $gallery->id, 'delete' => $comment->id, 'sesskey' => sesskey(), 'confirm' => 1];
$paramsno = ['id' => $cm->id];
- echo $OUTPUT->confirm(get_string('commentdelete', 'lightboxgallery'),
- new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes),
- new moodle_url('/mod/lightboxgallery/view.php', $paramsno));
+ echo $OUTPUT->confirm(
+ get_string('commentdelete', 'lightboxgallery'),
+ new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes),
+ new moodle_url('/mod/lightboxgallery/view.php', $paramsno)
+ );
echo $OUTPUT->footer();
die();
}
@@ -80,7 +83,7 @@
if ($mform->is_cancelled()) {
redirect($galleryurl);
} else if ($formadata = $mform->get_data()) {
- $newcomment = new stdClass;
+ $newcomment = new stdClass();
$newcomment->gallery = $gallery->id;
$newcomment->userid = $USER->id;
$newcomment->commenttext = $formadata->comment['text'];
diff --git a/comment_form.php b/comment_form.php
index 39dd5c2..5a69e74 100644
--- a/comment_form.php
+++ b/comment_form.php
@@ -24,13 +24,12 @@
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/formslib.php');
+require_once($CFG->libdir . '/formslib.php');
/**
* Form for adding comments on a gallery
*/
class mod_lightboxgallery_comment_form extends moodleform {
-
/**
* Form definition
*
@@ -53,6 +52,5 @@ public function definition() {
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(true, $straddcomment);
-
}
}
diff --git a/db/upgrade.php b/db/upgrade.php
index dabe96d..7a06489 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -82,6 +82,7 @@ function xmldb_lightboxgallery_upgrade($oldversion = 0) {
$dbman->create_table($table);
}
+
upgrade_mod_savepoint(true, 2007111400, 'lightboxgallery');
}
@@ -117,6 +118,7 @@ function xmldb_lightboxgallery_upgrade($oldversion = 0) {
$dbman->create_table($table);
}
+
upgrade_mod_savepoint(true, 2007121700, 'lightboxgallery');
}
@@ -150,8 +152,16 @@ function xmldb_lightboxgallery_upgrade($oldversion = 0) {
$dbman->rename_field($table, $field, 'description');
}
- $field = new xmldb_field('metatype',
- XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, ['caption', 'tag'], 'caption', 'image');
+ $field = new xmldb_field(
+ 'metatype',
+ XMLDB_TYPE_CHAR,
+ '20',
+ null,
+ XMLDB_NOTNULL,
+ ['caption', 'tag'],
+ 'caption',
+ 'image'
+ );
if ($dbman->table_exists($table) && !$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
@@ -169,6 +179,7 @@ function xmldb_lightboxgallery_upgrade($oldversion = 0) {
if ($dbman->field_exists($table, $field)) {
$dbman->rename_field($table, $field, 'ispublic');
}
+
upgrade_mod_savepoint(true, 2009051200, 'lightboxgallery');
}
@@ -188,6 +199,7 @@ function xmldb_lightboxgallery_upgrade($oldversion = 0) {
if (!$cm = get_coursemodule_from_instance('lightboxgallery', $gallery->id, $gallery->course, false)) {
continue;
}
+
$context = context_module::instance($cm->id);
$coursecontext = context_course::instance($gallery->course);
@@ -195,15 +207,19 @@ function xmldb_lightboxgallery_upgrade($oldversion = 0) {
$fs = get_file_storage();
if ($storedfiles = $fs->get_area_files($coursecontext->id, 'course', 'legacy')) {
foreach ($storedfiles as $file) {
- $path = '/'.$gallery->folder;
+ $path = '/' . $gallery->folder;
if ($gallery->folder != '') {
$path .= '/';
}
- if (substr($file->get_mimetype(), 0, 6) != 'image/' ||
+
+ if (
+ substr($file->get_mimetype(), 0, 6) != 'image/' ||
substr($file->get_filepath(), -8, 8) == '/_thumb/' ||
- $file->get_filepath() != $path) {
+ $file->get_filepath() != $path
+ ) {
continue;
}
+
// Insert as lightbox file.
$settings = new stdClass();
$settings->contextid = $context->id;
@@ -215,6 +231,7 @@ function xmldb_lightboxgallery_upgrade($oldversion = 0) {
}
}
}
+
upgrade_mod_savepoint(true, 2011040800, 'lightboxgallery');
}
diff --git a/edit/base.class.php b/edit/base.class.php
index a5653cf..7c76509 100644
--- a/edit/base.class.php
+++ b/edit/base.class.php
@@ -22,7 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_base {
-
/**
* @var lightboxgallery_image $imageobj The image object
*/
@@ -97,13 +96,13 @@ public function processing() {
public function enclose_in_form($text) {
global $CFG, $USER;
- return '
';
+ return '';
}
/**
@@ -112,7 +111,6 @@ public function enclose_in_form($text) {
* @return void
*/
public function output() {
-
}
/**
@@ -121,7 +119,5 @@ public function output() {
* @return void
*/
public function process_form() {
-
}
-
}
diff --git a/edit/caption/caption.class.php b/edit/caption/caption.class.php
index 2dba792..5b3de24 100644
--- a/edit/caption/caption.class.php
+++ b/edit/caption/caption.class.php
@@ -22,7 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_caption extends edit_base {
-
/**
* Constructor.
*
@@ -43,8 +42,8 @@ public function __construct($gallery, $cm, $image, $tab) {
* @throws coding_exception
*/
public function output($captiontext = '') {
- $result = '
'.
- '';
+ $result = '
' .
+ '';
return $this->enclose_in_form($result);
}
@@ -59,5 +58,4 @@ public function process_form() {
$caption = required_param('caption', PARAM_NOTAGS);
$this->lbgimage->set_caption($caption);
}
-
}
diff --git a/edit/crop/crop.class.php b/edit/crop/crop.class.php
index 77738c6..287fb17 100644
--- a/edit/crop/crop.class.php
+++ b/edit/crop/crop.class.php
@@ -16,7 +16,7 @@
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/gdlib.php');
+require_once($CFG->libdir . '/gdlib.php');
/**
* The crop plugin class.
@@ -26,7 +26,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_crop extends edit_base {
-
/**
* Constructor.
*
@@ -53,8 +52,8 @@ function onEndCrop( coords, dimensions ) {
$( \'y1\' ).value = coords.y1;
$( \'x2\' ).value = coords.x2;
$( \'y2\' ).value = coords.y2;
- $( \'cropInfo\' ).innerHTML = \''.get_string('from').': \' + coords.x1 + \'x\' + coords.y1 + \', '.
- get_string('size').': \' + dimensions.width + \'x\' + dimensions.height;
+ $( \'cropInfo\' ).innerHTML = \'' . get_string('from') . ': \' + coords.x1 + \'x\' + coords.y1 + \', ' .
+ get_string('size') . ': \' + dimensions.width + \'x\' + dimensions.height;
}
Event.observe(
window,
@@ -75,13 +74,13 @@ function() {
';
return $this->enclose_in_form($result);
@@ -108,5 +107,4 @@ public function process_form() {
$this->imageobj->save_image($cropped);
}
}
-
}
diff --git a/edit/delete/delete.class.php b/edit/delete/delete.class.php
index 6b5b04c..599381f 100644
--- a/edit/delete/delete.class.php
+++ b/edit/delete/delete.class.php
@@ -22,7 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_delete extends edit_base {
-
/**
* Constructor.
*
@@ -43,9 +42,9 @@ public function __construct($gallery, $cm, $image, $tab) {
*/
public function output() {
global $page;
- $result = get_string('deletecheck', '', $this->image).'
';
- $result .= '';
- $result .= '';
+ $result = get_string('deletecheck', '', $this->image) . '
';
+ $result .= '';
+ $result .= '';
return $this->enclose_in_form($result);
}
@@ -59,7 +58,6 @@ public function output() {
public function process_form() {
global $CFG, $page;
$this->lbgimage->delete_file();
- redirect($CFG->wwwroot.'/mod/lightboxgallery/view.php?id='.$this->cm->id.'&page='.$page.'&editing=1');
+ redirect($CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $this->cm->id . '&page=' . $page . '&editing=1');
}
-
}
diff --git a/edit/flip/flip.class.php b/edit/flip/flip.class.php
index 99247ef..3095d38 100644
--- a/edit/flip/flip.class.php
+++ b/edit/flip/flip.class.php
@@ -39,7 +39,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_flip extends edit_base {
-
/**
* Constructor
*
@@ -59,13 +58,13 @@ public function __construct($gallery, $cm, $image, $tab) {
* @throws coding_exception
*/
public function output() {
- $result = get_string('selectflipmode', 'lightboxgallery').'
'.
- '
'.
- ''.
- '
';
+ $result = get_string('selectflipmode', 'lightboxgallery') . '
' .
+ '
' .
+ '' .
+ '
';
return $this->enclose_in_form($result);
}
@@ -83,7 +82,7 @@ public function process_form() {
if ($mode & FLIP_HORIZONTAL) {
$flip = 'horizontal';
}
+
$this->image = $this->lbgimage->flip_image($flip);
}
-
}
diff --git a/edit/resize/resize.class.php b/edit/resize/resize.class.php
index 22a92c4..728bfb1 100644
--- a/edit/resize/resize.class.php
+++ b/edit/resize/resize.class.php
@@ -22,7 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_resize extends edit_base {
-
/**
* @var lang_string|string
*/
@@ -63,23 +62,24 @@ public function output() {
$storedfile = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image);
$image = new lightboxgallery_image($storedfile, $this->gallery, $this->cm);
- $currentsize = sprintf('%s: %dx%d', get_string('currentsize', 'lightboxgallery'), $image->width, $image->height).
+ $currentsize = sprintf('%s: %dx%d', get_string('currentsize', 'lightboxgallery'), $image->width, $image->height) .
'
';
$sizeselect = '
';
- $scaleselect = '
' .
+ ' ';
return $this->enclose_in_form($result);
@@ -117,5 +117,4 @@ public function process_form() {
$this->lbgimage->create_thumbnail($offsetx, $offsety);
}
}
-
}
diff --git a/imageadd.php b/imageadd.php
index 6642075..cd4a4b3 100644
--- a/imageadd.php
+++ b/imageadd.php
@@ -22,13 +22,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
-require_once(dirname(__FILE__).'/imageadd_form.php');
-require_once(dirname(__FILE__).'/imageclass.php');
+require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
+require_once(dirname(__FILE__) . '/imageadd_form.php');
+require_once(dirname(__FILE__) . '/imageclass.php');
$id = required_param('id', PARAM_INT);
-list($course, $cm) = get_course_and_cm_from_cmid($id, 'lightboxgallery');
+[$course, $cm] = get_course_and_cm_from_cmid($id, 'lightboxgallery');
$gallery = $DB->get_record('lightboxgallery', ['id' => $cm->instance], '*', MUST_EXIST);
require_login($course, true, $cm);
@@ -44,13 +44,20 @@
$mform = new mod_lightboxgallery_imageadd_form(null, ['id' => $cm->id, 'gallery' => $gallery]);
if ($mform->is_cancelled()) {
- redirect($CFG->wwwroot.'/mod/lightboxgallery/view.php?id='.$cm->id);
-
+ redirect($CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id);
} else if (($formdata = $mform->get_data()) && confirm_sesskey()) {
$fs = get_file_storage();
$draftid = file_get_submitted_draft_itemid('image');
- if (!$files = $fs->get_area_files(
- context_user::instance($USER->id)->id, 'user', 'draft', $draftid, 'id DESC', false)) {
+ if (
+ !$files = $fs->get_area_files(
+ context_user::instance($USER->id)->id,
+ 'user',
+ 'draft',
+ $draftid,
+ 'id DESC',
+ false
+ )
+ ) {
redirect($PAGE->url);
}
@@ -63,7 +70,7 @@
}
lightboxgallery_add_images($files, $context, $cm, $gallery, $resize);
- redirect($CFG->wwwroot.'/mod/lightboxgallery/view.php?id='.$cm->id);
+ redirect($CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id);
}
echo $OUTPUT->header();
diff --git a/imageadd_form.php b/imageadd_form.php
index 999084e..9129ee0 100644
--- a/imageadd_form.php
+++ b/imageadd_form.php
@@ -16,9 +16,9 @@
defined('MOODLE_INTERNAL') || die();
-require_once(dirname(__FILE__).'/locallib.php');
-require_once($CFG->libdir.'/formslib.php');
-require_once(dirname(__FILE__).'/imageclass.php');
+require_once(dirname(__FILE__) . '/locallib.php');
+require_once($CFG->libdir . '/formslib.php');
+require_once(dirname(__FILE__) . '/imageclass.php');
/**
* Prints a particular instance of lightboxgallery
@@ -29,7 +29,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_lightboxgallery_imageadd_form extends moodleform {
-
/**
* Form definition.
*
@@ -54,15 +53,24 @@ public function definition() {
'image/jpeg',
'image/png',
];
- $mform->addElement('filemanager', 'image', get_string('file'), '0',
- ['maxbytes' => $COURSE->maxbytes, 'accepted_types' => $acceptedtypes]);
+ $mform->addElement(
+ 'filemanager',
+ 'image',
+ get_string('file'),
+ '0',
+ ['maxbytes' => $COURSE->maxbytes, 'accepted_types' => $acceptedtypes]
+ );
$mform->addRule('image', get_string('required'), 'required', null, 'client');
$mform->addHelpButton('image', 'addimage', 'lightboxgallery');
if ($this->can_resize()) {
$resizegroup = [];
- $resizegroup[] = &$mform->createElement('select', 'resize', get_string('edit_resize', 'lightboxgallery'),
- lightboxgallery_resize_options());
+ $resizegroup[] = &$mform->createElement(
+ 'select',
+ 'resize',
+ get_string('edit_resize', 'lightboxgallery'),
+ lightboxgallery_resize_options()
+ );
$resizegroup[] = &$mform->createElement('checkbox', 'resizedisabled', null, get_string('disable'));
$mform->setType('resize', PARAM_INT);
$mform->addGroup($resizegroup, 'resizegroup', get_string('edit_resize', 'lightboxgallery'), ' ', false);
@@ -75,7 +83,6 @@ public function definition() {
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(true, get_string('addimage', 'lightboxgallery'));
-
}
/**
@@ -106,6 +113,7 @@ public function validation($data, $files) {
if ($file->get_mimetype() == 'image/svg+xml') {
$errors['image'] = get_string('svgzunsupported', 'mod_lightboxgallery', $file->get_filename());
}
+
// Better delete current file, it is not usable anyway.
$fs->delete_area_files($usercontext->id, 'user', 'draft', $data['image']);
}
diff --git a/imageclass.php b/imageclass.php
index adcd05a..3170356 100644
--- a/imageclass.php
+++ b/imageclass.php
@@ -16,7 +16,7 @@
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/gdlib.php');
+require_once($CFG->libdir . '/gdlib.php');
/**
*
@@ -47,7 +47,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class lightboxgallery_image {
-
/**
* The course module object.
*
@@ -139,20 +138,24 @@ public function __construct($storedfile, $gallery, $cm, $metadata = null, $thumb
$this->cmid = $cm->id;
$this->context = context_module::instance($cm->id);
- $this->imageurl = moodle_url::make_pluginfile_url($this->context->id,
+ $this->imageurl = moodle_url::make_pluginfile_url(
+ $this->context->id,
'mod_lightboxgallery',
'gallery_images',
$this->storedfile->get_itemid(),
$this->storedfile->get_filepath(),
- $this->storedfile->get_filename());
+ $this->storedfile->get_filename()
+ );
$this->imageurl->param('mtime', $this->storedfile->get_timemodified());
- $this->thumburl = moodle_url::make_pluginfile_url($this->context->id,
+ $this->thumburl = moodle_url::make_pluginfile_url(
+ $this->context->id,
'mod_lightboxgallery',
'gallery_thumbs',
0,
$this->storedfile->get_filepath(),
- $this->storedfile->get_filename().'.png');
+ $this->storedfile->get_filename() . '.png'
+ );
if ($this->storedfile->get_mimetype() == 'image/svg+xml') {
$this->thumburl = $this->imageurl;
@@ -170,6 +173,7 @@ public function __construct($storedfile, $gallery, $cm, $metadata = null, $thumb
if (!$thumbnail && (!$this->thumbnail = $this->get_thumbnail())) {
$this->thumbnail = $this->create_thumbnail();
}
+
if ($this->thumbnail) {
$this->thumburl->param('mtime', $this->thumbnail->get_timemodified());
}
@@ -206,8 +210,10 @@ public function add_tag($tag) {
* @throws stored_file_creation_exception
*/
public function create_thumbnail($offsetx = 0, $offsety = 0) {
- if ($this->storedfile->get_mimetype() == 'image/svg+xml'
- || $this->width === null || $this->height === null) {
+ if (
+ $this->storedfile->get_mimetype() == 'image/svg+xml'
+ || $this->width === null || $this->height === null
+ ) {
// We can't resize SVG or files we don't know the dimensions of.
return $this->storedfile;
}
@@ -218,7 +224,7 @@ public function create_thumbnail($offsetx = 0, $offsety = 0) {
'filearea' => 'gallery_thumbs',
'itemid' => 0,
'filepath' => $this->storedfile->get_filepath(),
- 'filename' => $this->storedfile->get_filename().'.png', ];
+ 'filename' => $this->storedfile->get_filename() . '.png', ];
ob_start();
imagepng($this->get_image_resized(THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH, $offsetx, $offsety));
@@ -247,7 +253,7 @@ public function create_index() {
'filepath' => '/',
'filename' => 'index.png', ];
- $base = imagecreatefrompng($CFG->dirroot.'/mod/lightboxgallery/pix/index.png');
+ $base = imagecreatefrompng($CFG->dirroot . '/mod/lightboxgallery/pix/index.png');
$transparent = imagecolorat($base, 0, 0);
$shrunk = imagerotate($this->get_image_resized(48, 48, 0, 0), 351, $transparent);
@@ -384,17 +390,18 @@ private function get_editing_options_form() {
$options = $this->get_editing_options();
- $html = ''.
- ''.
- ''.
- ''.
- '' .
'';
return $html;
@@ -418,8 +425,16 @@ public function get_image_caption() {
}
}
- if ($imagemeta = $DB->get_record('lightboxgallery_image_meta',
- ['gallery' => $this->gallery->id, 'image' => $this->storedfile->get_filename(), 'metatype' => 'caption'])) {
+ if (
+ $imagemeta = $DB->get_record(
+ 'lightboxgallery_image_meta',
+ [
+ 'gallery' => $this->gallery->id,
+ 'image' => $this->storedfile->get_filename(),
+ 'metatype' => 'caption',
+ ]
+ )
+ ) {
$caption = $imagemeta->description;
}
@@ -440,6 +455,7 @@ public function get_image_display_html($editing = false) {
} else {
$caption = lightboxgallery_resize_text($this->get_image_caption(), MAX_IMAGE_LABEL);
}
+
$timemodified = userdate($this->storedfile->get_timemodified(), get_string('strftimedatetimeshort', 'langconfig'));
$filesize = round($this->storedfile->get_filesize() / 100) / 10;
@@ -447,31 +463,33 @@ public function get_image_display_html($editing = false) {
if ($this->gallery->captionpos == LIGHTBOXGALLERY_POS_HID) {
$caption = ''; // Hide by cleaning the content (looks better than cleaning the whole div).
}
+
$posclass = ($this->gallery->captionpos == LIGHTBOXGALLERY_POS_TOP) ? 'top' : 'bottom';
$captiondiv = html_writer::tag('div', $caption, ['class' => "lightbox-gallery-image-caption $posclass"]);
- $html = ''.
- '
'.
+ $html = '
' .
+ '
' .
'
';
if ($this->gallery->captionpos == LIGHTBOXGALLERY_POS_TOP) {
$html .= $captiondiv;
}
- $html .= '
';
+
+ $html .= '
';
if ($this->gallery->captionpos == LIGHTBOXGALLERY_POS_BOT || $this->gallery->captionpos == LIGHTBOXGALLERY_POS_HID) {
$html .= $captiondiv;
}
- $html .= $this->gallery->extinfo ? '
'.$timemodified.
- '
'.$filesize.'KB '.$this->width.'x'.$this->height.'px
' : '';
+
+ $html .= $this->gallery->extinfo ? '
' . $timemodified .
+ '
' . $filesize . 'KB ' . $this->width . 'x' . $this->height . 'px
' : '';
$html .= ($editing ? $this->get_editing_options_form() : '');
- $html .= '
'.
- '
'.
+ $html .= '
' .
+ '
' .
'
';
return $html;
-
}
/**
@@ -500,7 +518,6 @@ private function get_image_flipped($direction) {
}
return $flipped;
-
}
/**
@@ -540,7 +557,6 @@ private function get_image_resized($height = THUMBNAIL_HEIGHT, $width = THUMBNAI
imagecopyresampled($resized, $image, 0, 0, $srcx, $srcy, $width, $height, $srcw, $srch);
return $resized;
-
}
/**
@@ -586,8 +602,10 @@ public function get_tags() {
}
}
} else {
- $tags = $DB->get_records('lightboxgallery_image_meta',
- ['image' => $this->storedfile->get_filename(), 'metatype' => 'tag']);
+ $tags = $DB->get_records(
+ 'lightboxgallery_image_meta',
+ ['image' => $this->storedfile->get_filename(), 'metatype' => 'tag']
+ );
}
return $this->tags = $tags;
@@ -601,8 +619,16 @@ public function get_tags() {
private function get_thumbnail() {
$fs = get_file_storage();
- if ($thumbnail = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_thumbs', '0', '/',
- $this->storedfile->get_filename().'.png')) {
+ if (
+ $thumbnail = $fs->get_file(
+ $this->context->id,
+ 'mod_lightboxgallery',
+ 'gallery_thumbs',
+ '0',
+ '/',
+ $this->storedfile->get_filename() . '.png'
+ )
+ ) {
return $thumbnail;
}
@@ -630,6 +656,7 @@ protected function output_by_mimetype($gdcall) {
} else {
$imgfunc = 'imagejpeg';
}
+
$imgfunc($gdcall);
if ($this->storedfile->get_mimetype() == 'image/png') {
return preg_replace('/\..+$/', '.png', $this->storedfile->get_filename());
@@ -723,8 +750,16 @@ public function set_caption($caption) {
$imagemeta->metatype = 'caption';
$imagemeta->description = $caption;
- if ($meta = $DB->get_record('lightboxgallery_image_meta', ['gallery' => $this->cm->instance,
- 'image' => $this->storedfile->get_filename(), 'metatype' => 'caption', ])) {
+ if (
+ $meta = $DB->get_record(
+ 'lightboxgallery_image_meta',
+ [
+ 'gallery' => $this->cm->instance,
+ 'image' => $this->storedfile->get_filename(),
+ 'metatype' => 'caption',
+ ],
+ )
+ ) {
$imagemeta->id = $meta->id;
return $DB->update_record('lightboxgallery_image_meta', $imagemeta);
} else {
diff --git a/imageedit.php b/imageedit.php
index f6e036d..7dda35f 100644
--- a/imageedit.php
+++ b/imageedit.php
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-use core\output\tabobject;
-
/**
* Image editing page
*
@@ -24,10 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
-require_once(dirname(__FILE__).'/locallib.php');
-require_once(dirname(__FILE__).'/edit/base.class.php');
-require_once(dirname(__FILE__).'/imageclass.php');
+use core\output\tabobject;
+
+require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
+require_once(dirname(__FILE__) . '/locallib.php');
+require_once(dirname(__FILE__) . '/edit/base.class.php');
+require_once(dirname(__FILE__) . '/imageclass.php');
global $DB;
@@ -57,14 +57,17 @@
if (!$storedfile = $fs->get_file($context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $image)) {
throw new \moodle_exception(get_string('errornofile', 'lightboxgallery', $image));
}
+
$imageclass = new lightboxgallery_image($storedfile, $gallery, $cm);
$edittypes = lightboxgallery_edit_types(false, $imageclass);
$tabs = [];
foreach ($edittypes as $type => $name) {
- $editurl = new moodle_url('/mod/lightboxgallery/imageedit.php',
- ['id' => $cm->id, 'image' => $image, 'page' => $page, 'tab' => $type]);
+ $editurl = new moodle_url(
+ '/mod/lightboxgallery/imageedit.php',
+ ['id' => $cm->id, 'image' => $image, 'page' => $page, 'tab' => $type]
+ );
$tabs[] = new tabobject($type, $editurl, $name);
}
@@ -77,8 +80,8 @@
}
}
-require($CFG->dirroot.'/mod/lightboxgallery/edit/'.$tab.'/'.$tab.'.class.php');
-$editclass = 'edit_'.$tab;
+require($CFG->dirroot . '/mod/lightboxgallery/edit/' . $tab . '/' . $tab . '.class.php');
+$editclass = 'edit_' . $tab;
$editinstance = new $editclass($gallery, $cm, $image, $tab);
if ($editinstance->processing() && confirm_sesskey()) {
@@ -96,7 +99,8 @@
$event->trigger();
$editinstance->process_form();
- redirect($CFG->wwwroot.'/mod/lightboxgallery/imageedit.php?id='.$cm->id.'&image='.$editinstance->image.'&tab='.$tab);
+ redirect($CFG->wwwroot . '/mod/lightboxgallery/imageedit.php?id=' . $cm->id . '&image=' . $editinstance->image . '&tab=' .
+ $tab);
}
$table = new html_table();
@@ -106,9 +110,9 @@
$table->attributes = ['style' => 'margin-left:auto;margin-right:auto;'];
$table->align = ['center', 'center'];
$table->size = ['*', '*'];
- $table->data[] = ['.
- ')
'.
- $image->get_image_caption().'', $editinstance->output($image->get_image_caption()), ];
+ $table->data[] = [' .
+ ')
' .
+ $image->get_image_caption() . '', $editinstance->output($image->get_image_caption()), ];
} else {
$table->align = ['center'];
$table->size = ['*'];
diff --git a/index.php b/index.php
index 574eaf3..0c457d5 100644
--- a/index.php
+++ b/index.php
@@ -22,9 +22,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
-require_once(dirname(__FILE__).'/locallib.php');
-require_once($CFG->libdir.'/rsslib.php');
+require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
+require_once(dirname(__FILE__) . '/locallib.php');
+require_once($CFG->libdir . '/rsslib.php');
$id = required_param('id', PARAM_INT);
@@ -46,7 +46,7 @@
if (! $galleries = get_all_instances_in_course('lightboxgallery', $course)) {
echo $OUTPUT->heading(get_string('thereareno', 'moodle', $strgalleries), 2);
- echo $OUTPUT->continue_button('view.php?id='.$course->id);
+ echo $OUTPUT->continue_button('view.php?id=' . $course->id);
echo $OUTPUT->footer();
die();
}
@@ -60,7 +60,7 @@
$table->align = ['center', 'center', 'left', 'left', 'center'];
$table->width = '*';
-$fobj = new stdClass;
+$fobj = new stdClass();
$fobj->para = false;
$prevsection = '';
@@ -87,13 +87,14 @@
$imagecount++;
}
}
+
$commentcount = $DB->count_records('lightboxgallery_comments', ['gallery' => $gallery->id]);
$viewurl = new moodle_url('/mod/lightboxgallery/view.php', ['id' => $gallery->coursemodule]);
$table->data[] = [($printsection ? $gallery->section : ''),
lightboxgallery_index_thumbnail($course->id, $gallery),
- html_writer::link($viewurl, $gallery->name).
- '
'.get_string('imagecounta', 'lightboxgallery', $imagecount).' '.
+ html_writer::link($viewurl, $gallery->name) .
+ '
' . get_string('imagecounta', 'lightboxgallery', $imagecount) . ' ' .
get_string('commentcount', 'lightboxgallery', $commentcount),
format_text($gallery->intro, FORMAT_MOODLE, $fobj),
(isset($rss) ? $rss : get_string('norssfeedavailable', 'lightboxgallery')), ];
@@ -104,4 +105,3 @@
echo $OUTPUT->heading(get_string('modulenameplural', 'lightboxgallery'), 2);
echo html_writer::table($table);
echo $OUTPUT->footer();
-
diff --git a/lib.php b/lib.php
index 7b16e12..e2faa92 100644
--- a/lib.php
+++ b/lib.php
@@ -30,8 +30,8 @@
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/filelib.php');
-require_once(dirname(__FILE__).'/locallib.php');
+require_once($CFG->libdir . '/filelib.php');
+require_once(dirname(__FILE__) . '/locallib.php');
/**
* This function returns if the module supports a feature
@@ -40,7 +40,7 @@
* @return bool|int|string|null
*/
function lightboxgallery_supports($feature) {
- switch($feature) {
+ switch ($feature) {
case FEATURE_MOD_ARCHETYPE:
return MOD_ARCHETYPE_RESOURCE;
case FEATURE_GROUPS:
@@ -90,8 +90,12 @@ function lightboxgallery_add_instance($gallery) {
$gallery->id = $DB->insert_record('lightboxgallery', $gallery);
$completiontimeexpected = !empty($gallery->completionexpected) ? $gallery->completionexpected : null;
- \core_completion\api::update_completion_date_event($gallery->coursemodule, 'lightboxgallery', $gallery->id,
- $completiontimeexpected);
+ \core_completion\api::update_completion_date_event(
+ $gallery->coursemodule,
+ 'lightboxgallery',
+ $gallery->id,
+ $completiontimeexpected
+ );
return $gallery->id;
}
@@ -117,8 +121,12 @@ function lightboxgallery_update_instance($gallery) {
lightboxgallery_set_sizing($gallery);
$completiontimeexpected = !empty($gallery->completionexpected) ? $gallery->completionexpected : null;
- \core_completion\api::update_completion_date_event($gallery->coursemodule, 'lightboxgallery', $gallery->id,
- $completiontimeexpected);
+ \core_completion\api::update_completion_date_event(
+ $gallery->coursemodule,
+ 'lightboxgallery',
+ $gallery->id,
+ $completiontimeexpected
+ );
return $DB->update_record('lightboxgallery', $gallery);
}
@@ -162,7 +170,7 @@ function lightboxgallery_delete_instance($id) {
$fs->delete_area_files($context->id, 'mod_lightboxgallery');
// Delete all the records and fields.
- $DB->delete_records('lightboxgallery_comments', ['gallery' => $gallery->id] );
+ $DB->delete_records('lightboxgallery_comments', ['gallery' => $gallery->id]);
$DB->delete_records('lightboxgallery_image_meta', ['gallery' => $gallery->id]);
// Delete the instance itself.
@@ -227,7 +235,7 @@ function lightboxgallery_get_extra_capabilities() {
* @throws dml_exception
* @throws moodle_exception
*/
-function lightboxgallery_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0) {
+function lightboxgallery_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0) {
global $DB, $COURSE;
if ($COURSE->id == $courseid) {
@@ -253,6 +261,7 @@ function lightboxgallery_get_recent_mod_activity(&$activities, &$index, $timesta
if ($userid) {
$params[] = $userid;
}
+
if ($comments = $DB->get_records_sql($sql, $params)) {
foreach ($comments as $comment) {
$display = lightboxgallery_resize_text(trim(strip_tags($comment->commenttext)), MAX_COMMENT_PREVIEW);
@@ -276,13 +285,14 @@ function lightboxgallery_get_recent_mod_activity(&$activities, &$index, $timesta
if ($field == 'id') {
continue;
}
+
$activity->user->$field = $comment->$field;
}
$activities[$index++] = $activity;
-
}
}
+
return true;
}
@@ -301,19 +311,21 @@ function lightboxgallery_print_recent_mod_activity($activity, $courseid, $detail
global $CFG, $OUTPUT;
$userviewurl = new moodle_url('/user/view.php', ['id' => $activity->user->id, 'course' => $courseid]);
- echo ''.
- '| '.$OUTPUT->user_picture($activity->user, ['courseid' => $courseid]).
- ' | '.
- ''.
- ' '.
- html_writer::link($userviewurl, fullname($activity->user, $viewfullnames)).
- ' - '.userdate($activity->timestamp).
- ' '.
+ echo '' .
+ '| ' . $OUTPUT->user_picture($activity->user, ['courseid' => $courseid]) .
+ ' | ' .
+ '' .
+ ' ' .
+ html_writer::link($userviewurl, fullname($activity->user, $viewfullnames)) .
+ ' - ' . userdate($activity->timestamp) .
+ ' ' .
' | ';
return true;
@@ -344,28 +356,27 @@ function lightboxgallery_print_recent_activity($course, $viewfullnames, $timesta
$params = [$timestart, $course->id];
if ($comments = $DB->get_records_sql($sql, $params)) {
- echo $OUTPUT->heading(get_string('newgallerycomments', 'lightboxgallery').':', 3);
+ echo $OUTPUT->heading(get_string('newgallerycomments', 'lightboxgallery') . ':', 3);
echo '';
foreach ($comments as $comment) {
$display = lightboxgallery_resize_text(trim(strip_tags($comment->commenttext)), MAX_COMMENT_PREVIEW);
- $output = '- '.
- '
'.
- ' '.userdate($comment->timemodified, get_string('strftimerecent')).' '.
- ' '.fullname($comment, $viewfullnames).' - '.format_string($comment->name).' '.
- ' '.
- ' '.
+ $output = ' - ' .
+ '
' .
+ ' ' . userdate($comment->timemodified, get_string('strftimerecent')) . ' ' .
+ ' ' . fullname($comment, $viewfullnames) . ' - ' . format_string($comment->name) . ' ' .
+ ' ' .
+ ' ' .
' ';
echo $output;
}
echo ' ';
-
}
return true;
@@ -422,7 +433,7 @@ function lightboxgallery_get_post_actions() {
function lightboxgallery_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
global $CFG, $DB;
- require_once($CFG->libdir.'/filelib.php');
+ require_once($CFG->libdir . '/filelib.php');
$gallery = $DB->get_record('lightboxgallery', ['id' => $cm->instance]);
if (!$gallery->ispublic) {
@@ -430,7 +441,7 @@ function lightboxgallery_pluginfile($course, $cm, $context, $filearea, $args, $f
}
$relativepath = implode('/', $args);
- $fullpath = '/'.$context->id.'/mod_lightboxgallery/'.$filearea.'/'.$relativepath;
+ $fullpath = '/' . $context->id . '/mod_lightboxgallery/' . $filearea . '/' . $relativepath;
$fs = get_file_storage();
if ((!$file = $fs->get_file_by_hash(sha1($fullpath))) || ($file->is_directory())) {
@@ -440,7 +451,6 @@ function lightboxgallery_pluginfile($course, $cm, $context, $filearea, $args, $f
send_stored_file($file, null, 0, true); // Download MUST be forced - security!
return;
-
}
@@ -489,10 +499,19 @@ function lightboxgallery_get_file_info($browser, $areas, $course, $cm, $context,
}
require_once("$CFG->dirroot/mod/lightboxgallery/locallib.php");
- $urlbase = $CFG->wwwroot.'/pluginfile.php';
-
- return new lightboxgallery_content_file_info($browser, $context, $storedfile, $urlbase, $areas[$filearea],
- true, true, false, false);
+ $urlbase = $CFG->wwwroot . '/pluginfile.php';
+
+ return new lightboxgallery_content_file_info(
+ $browser,
+ $context,
+ $storedfile,
+ $urlbase,
+ $areas[$filearea],
+ true,
+ true,
+ false,
+ false
+ );
}
return null;
@@ -523,20 +542,20 @@ function lightboxgallery_print_comment($comment, $context) {
$deleteurl = new moodle_url('/mod/lightboxgallery/comment.php', ['id' => $comment->gallery, 'delete' => $comment->id]);
- echo ' |