Skip to content

Commit

Permalink
PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Apr 3, 2024
1 parent 3176fe3 commit f4720ff
Show file tree
Hide file tree
Showing 20 changed files with 134 additions and 63 deletions.
13 changes: 5 additions & 8 deletions backup/moodle2/backup_format_grid_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
* Grid format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2012 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* @author G J Barnard - {@link https://about.me/gjbarnard} and
* {@link https://moodle.org/user/profile.php?id=442195}
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
Expand All @@ -40,14 +38,13 @@ protected function define_course_plugin_structure() {

// This is so that we know the value of 'gnumsections' before its changed by the restore process and lost
// before it is needed.
$pluginwrapper = new backup_nested_element($this->get_recommended_name(), null, array('name', 'value'));
$pluginwrapper = new backup_nested_element($this->get_recommended_name(), null, ['name', 'value']);

// Connect the visible container ASAP.
$plugin->add_child($pluginwrapper);

// Set source to populate the data.
$pluginwrapper->set_source_table('course_format_options', array(
'courseid' => backup::VAR_PARENTID));
$pluginwrapper->set_source_table('course_format_options', ['courseid' => backup::VAR_PARENTID]);

// Don't need to annotate ids nor files.
return $plugin;
Expand Down
8 changes: 3 additions & 5 deletions backup/moodle2/restore_format_grid_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
* Grid Information
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2012 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* @author G J Barnard - {@link https://about.me/gjbarnard} and
* {@link https://moodle.org/user/profile.php?id=442195}
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/course/format/grid/lib.php');
Expand Down
7 changes: 3 additions & 4 deletions classes/admin_setting_information.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
* Grid Format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2022 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author G J Barnard - {@link https://about.me/gjbarnard} and
* {@link https://moodle.org/user/profile.php?id=442195}
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace format_grid;
Expand Down
7 changes: 3 additions & 4 deletions classes/admin_setting_markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
* Grid Format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2022 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author G J Barnard - {@link https://about.me/gjbarnard} and
* {@link https://moodle.org/user/profile.php?id=442195}
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace format_grid;
Expand Down
13 changes: 8 additions & 5 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
* Grid Format.
*
* @package format_grid
* @category event
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2017-onwards G J Barnard based upon work done by Marina Glancy.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @author G J Barnard - {@link https://about.me/gjbarnard} and
* {@link https://moodle.org/user/profile.php?id=442195}
* @author Based on code originally written by Paul Krix and Julian Ridden.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
Expand Down Expand Up @@ -62,6 +60,11 @@ public static function course_restored(\core\event\course_restored $event) {
}
}

/**
* Deletes the images for the given course.
*
* @param int $courseid Course id.
*/
protected static function delete_images($courseid) {
// Delete any images associated with the course.
\format_grid\toolbox::delete_images($courseid);
Expand Down
6 changes: 5 additions & 1 deletion classes/output/courseformat/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class content extends content_base {
/** @var array sectioncompletionpercentage */
private $sectioncompletionpercentage = [];
/** @var array sectioncompletionmarkup */
private $sectioncompletionmarkup = [];
/** @var array sectioncompletioncalculated */
private $sectioncompletioncalculated = [];

/**
Expand Down Expand Up @@ -193,7 +196,8 @@ public function export_for_template(\renderer_base $output) {
);
} else if (empty($sectionimages[$section->id]->imageerror)) {
$sectionimages[$section->id]->imageerror =
get_string('cannotconvertuploadedimagetodisplayedimage', 'format_grid', json_encode($sectionimages[$section->id]));
get_string('cannotconvertuploadedimagetodisplayedimage', 'format_grid',
json_encode($sectionimages[$section->id]));
}
} else {
// No.
Expand Down
6 changes: 6 additions & 0 deletions classes/output/courseformat/content/section.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class section extends section_base {
/** @var course_format the course format */
protected $format;

/**
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output typically, the renderer that's calling this function.
* @return array data context for a mustache template.
*/
public function export_for_template(\renderer_base $output): stdClass {
$format = $this->format;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* Contains the default section controls output class.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2022 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
Expand Down
5 changes: 2 additions & 3 deletions classes/output/courseformat/content/section/summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* Contains the default section summary (used for multipage format).
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2022 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
Expand Down Expand Up @@ -60,8 +59,8 @@ public function __construct(course_format $format, section_info $section) {
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output typically, the renderer that's calling this function
* @return array data context for a mustache template
* @param renderer_base $output typically, the renderer that's calling this function.
* @return array data context for a mustache template.
*/
public function export_for_template(\renderer_base $output): stdClass {

Expand Down
1 change: 0 additions & 1 deletion classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* Grid Format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2012 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
Expand Down
1 change: 0 additions & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*
* @package format_grid
* @category privacy
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2018-onwards G J Barnard based upon work done by Marina Glancy.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
Expand Down
19 changes: 12 additions & 7 deletions classes/toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* Grid Format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2021-onwards G J Barnard based upon work done by Marina Glancy.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
Expand All @@ -34,15 +33,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
class toolbox {
/**
* @var toolbox Singleton instance of us.
*/
/** @var toolbox $instance Singleton instance of us. */
protected static $instance = null;

// Width constants - 128, 192, 210, 256, 320, 384, 448, 512, 576, 640, 704 and 768:...
/** @var array $imagecontainerwidths Width constants - 128, 192, 210, 256, 320, 384, 448, 512, 576, 640, 704 and 768:... */
private static $imagecontainerwidths = [128 => '128', 192 => '192', 210 => '210', 256 => '256', 320 => '320',
384 => '384', 448 => '448', 512 => '512', 576 => '576', 640 => '640', 704 => '704', 768 => '768', ];
// Ratio constants - 3-2, 3-1, 3-3, 2-3, 1-3, 4-3 and 3-4:...
/** @var array $imagecontainerratios Ratio constants - 3-2, 3-1, 3-3, 2-3, 1-3, 4-3 and 3-4:... */
private static $imagecontainerratios = [
1 => '3-2', 2 => '3-1', 3 => '3-3', 4 => '2-3', 5 => '1-3', 6 => '4-3', 7 => '3-4', ];

Expand Down Expand Up @@ -638,6 +635,13 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei
return $data;
}

/**
* Decode the debug data.
*
* @param array $debugdata Debug data.
*
* @return string Debug information.
*/
private static function debugdata_decode($debugdata) {
$o = 'Files table id: ' . $debugdata['id'];
$o .= ', itemid: ' . $debugdata['itemid'];
Expand Down Expand Up @@ -699,7 +703,8 @@ private static function update_the_displayed_images($courseid = null) {
}
if (($lock instanceof \core\lock\lock) || (defined('BEHAT_SITE_RUNNING'))) {
try {
$files = $fs->get_area_files($coursecontext->id, 'format_grid', 'sectionimage', $coursesectionimage->sectionid);
$files = $fs->get_area_files($coursecontext->id, 'format_grid', 'sectionimage',
$coursesectionimage->sectionid);
foreach ($files as $file) {
if (!$file->is_directory()) {
$coursesectionimage = $toolbox->setup_displayed_image(
Expand Down
2 changes: 0 additions & 2 deletions db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* Grid Format.
*
* @package format_grid
* @category event
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2017-onwards G J Barnard based upon work done by Marina Glancy.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
Expand Down
6 changes: 5 additions & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
* Grid Format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2012 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @author Based on code originally written by Paul Krix and Julian Ridden.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Upgrade processes.
*
* @return bool Success.
*/
function xmldb_format_grid_upgrade($oldversion = 0) {
global $DB;

Expand Down
8 changes: 8 additions & 0 deletions form/sectionfilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

// phpcs:disable moodle.NamingConventions.ValidVariableName.VariableNameLowerCase
// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod

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

global $CFG;

require_once($CFG->dirroot . "/lib/form/filemanager.php");

/**
* Section file manager form.
*/
class MoodleQuickForm_sectionfilemanager extends MoodleQuickForm_filemanager implements templatable {
/** @var array $options The options */
private static $options = [
'maxfiles' => 1,
'subdirs' => 0,
Expand Down
7 changes: 3 additions & 4 deletions format.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
* Grid Format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2012 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @author G J Barnard - {@link https://about.me/gjbarnard} and
* {@link https://moodle.org/user/profile.php?id=442195}
* @copyright 2006 The Open University
* @author N.D.Freear@open.ac.uk, and others.
* @author Based on code originally written by Paul Krix and Julian Ridden.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();

Expand Down
9 changes: 5 additions & 4 deletions lang/en/format_grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
* Grid Format.
*
* @package format_grid
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2012 G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - {@link http://about.me/gjbarnard} and
* {@link http://moodle.org/user/profile.php?id=442195}
* @author G J Barnard - {@link https://about.me/gjbarnard} and
* {@link https://moodle.org/user/profile.php?id=442195}
* @author Based on code originally written by Paul Krix and Julian Ridden.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

// phpcs:disable moodle.Files.LangFilesOrdering

$string['topic'] = 'Section';
$string['topic0'] = 'General';

Expand Down
Loading

0 comments on commit f4720ff

Please sign in to comment.