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 '
'. - '
'. - ''. - ''. - ''. - ''. - ''.$text.'
'; + return '
' . + '
' . + '' . + '' . + '' . + '' . + '' . $text . '
'; } /** @@ -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() { - + - +
'.'TODO:imgurl'.'' . 'TODO:imgurl' . '
 
'; 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 = '
' . + ' ' . + ' ' . + ' ' . + ' ' . + ' ' . + ' ' . ' 
'; @@ -101,16 +101,15 @@ public function process_form() { switch ($button) { case $this->strresize: $size = required_param('size', PARAM_INT); - list($width, $height) = explode('x', $this->resizeoptions[$size]); - break; + [$width, $height] = explode('x', $this->resizeoptions[$size]); + break; case $this->strscale: $scale = required_param('scale', PARAM_INT); $width = $this->lbgimage->width * ($scale / 100); $height = $this->lbgimage->height * ($scale / 100); - break; + break; } $this->image = $this->lbgimage->resize_image($width, $height); } - } diff --git a/edit/rotate/rotate.class.php b/edit/rotate/rotate.class.php index 613624e..52b76e7 100644 --- a/edit/rotate/rotate.class.php +++ b/edit/rotate/rotate.class.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class edit_rotate extends edit_base { - /** * Constructor. * @@ -42,14 +41,14 @@ public function __construct($gallery, $cm, $image, $tab) { * @throws coding_exception */ public function output() { - $result = get_string('selectrotation', 'lightboxgallery').'

'. - ''. - ''. - ''. - '

'; + $result = get_string('selectrotation', 'lightboxgallery') . '

' . + '' . + '' . + '' . + '

'; return $this->enclose_in_form($result); } @@ -67,5 +66,4 @@ public function process_form() { $angle = required_param('angle', PARAM_INT); $this->image = $this->lbgimage->rotate_image($angle); } - } diff --git a/edit/tag/import.php b/edit/tag/import.php index 651fddf..65175ff 100644 --- a/edit/tag/import.php +++ b/edit/tag/import.php @@ -22,8 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(__FILE__).'/../../../../config.php'); -require_once(dirname(__FILE__).'/../../lib.php'); +require_once(dirname(__FILE__) . '/../../../../config.php'); +require_once(dirname(__FILE__) . '/../../lib.php'); $id = required_param('id', PARAM_INT); $confirm = optional_param('confirm', 0, PARAM_INT); @@ -31,9 +31,11 @@ if (!$gallery = $DB->get_record('lightboxgallery', ['id' => $id])) { throw new \moodle_exception('invalidlightboxgalleryid', 'lightboxgallery'); } + if (!$course = $DB->get_record('course', ['id' => $gallery->course])) { throw new \moodle_exception('invalidcourseid'); } + if (!$cm = get_coursemodule_from_instance('lightboxgallery', $gallery->id, $course->id)) { throw new \moodle_exception('invalidcoursemodule'); } @@ -87,8 +89,9 @@ if (empty($tag)) { continue; } + $select = "gallery = :gallery AND image = :image - AND metatype = :metatype AND ".$DB->sql_compare_text('description', 100).' = :description'; + AND metatype = :metatype AND " . $DB->sql_compare_text('description', 100) . ' = :description'; $params = [ 'gallery' => $gallery->id, 'image' => $storedfile->get_filename(), @@ -106,6 +109,7 @@ } } } + error_reporting($errorlevel); } } @@ -118,10 +122,14 @@ notice(get_string('tagsimportfinish', 'lightboxgallery', $a), $galleryurl); } else { - $confirmurl = new moodle_url('/mod/lightboxgallery/edit/tag/import.php', - ['id' => $gallery->id, 'confirm' => 1, 'sesskey' => sesskey()]); - $cancelurl = new moodle_url('/mod/lightboxgallery/view.php', - ['id' => $cm->id, 'editing' => 1]); + $confirmurl = new moodle_url( + '/mod/lightboxgallery/edit/tag/import.php', + ['id' => $gallery->id, 'confirm' => 1, 'sesskey' => sesskey()] + ); + $cancelurl = new moodle_url( + '/mod/lightboxgallery/view.php', + ['id' => $cm->id, 'editing' => 1] + ); echo $OUTPUT->confirm(get_string('tagsimportconfirm', 'lightboxgallery'), $confirmurl, $cancelurl); } diff --git a/edit/tag/tag.class.php b/edit/tag/tag.class.php index 5556d4d..e2b5e10 100644 --- a/edit/tag/tag.class.php +++ b/edit/tag/tag.class.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class edit_tag extends edit_base { - /** * Constructor. * @@ -48,8 +47,8 @@ public function output() { $stradd = get_string('add'); - $manualform = '
'. - '
'; + $manualform = '
' . + '
'; $manualform = $this->enclose_in_form($manualform); $iptcform = ''; @@ -67,11 +66,12 @@ public function output() { $tag = core_text::strtolower($tag); $exists = ($tags && in_array($tag, array_values($tags))); $tag = htmlentities($tag); - $iptcform .= '
'; } + $iptcform .= ''; - $iptcform = ' ' . get_string('tagsiptc', 'lightboxgallery'). + $iptcform = ' ' . get_string('tagsiptc', 'lightboxgallery') . '' . $this->enclose_in_form($iptcform); } } @@ -82,12 +82,13 @@ public function output() { if ($tags = $this->lbgimage->get_tags()) { $deleteform = ''; foreach ($tags as $tag) { - $deleteform .= '
'; + $deleteform .= '
'; } + $deleteform .= ''; $deleteform = ' ' . get_string('tagscurrent', 'lightboxgallery') . '' - .$this->enclose_in_form($deleteform); + . $this->enclose_in_form($deleteform); } return $manualform . $iptcform . $deleteform; @@ -113,5 +114,4 @@ public function process_form() { } } } - } diff --git a/edit/thumbnail/thumbnail.class.php b/edit/thumbnail/thumbnail.class.php index 578b1f1..4e407ee 100644 --- a/edit/thumbnail/thumbnail.class.php +++ b/edit/thumbnail/thumbnail.class.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class edit_thumbnail extends edit_base { - /** * Constructor. * @@ -47,26 +46,27 @@ public function output() { $url = new moodle_url('/mod/lightboxgallery/index.php', ['id' => $this->gallery->course]); $helpbutton = $OUTPUT->help_icon('setasindex', 'lightboxgallery', true, $url); $result = ''.$helpbutton; + get_string('setasindex', 'lightboxgallery') . '" />' . $helpbutton; $result .= '

' . get_string('selectthumbpos', 'lightboxgallery') . '

'; if ($this->lbgimage->width < $this->lbgimage->height) { - $result .= ' '. - '