Skip to content

Commit

Permalink
Issue #7: Codechecker fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gthomas2 committed Jan 21, 2018
1 parent c26d60d commit 2fdd37d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions classes/componentsupport/base_component.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

defined('MOODLE_INTERNAL') || die;

// We need to ignore all the unused vars in all functions in this class because they are stubs.
// @codingStandardsIgnoreStart
abstract class base_component {
/**
* Get the image file for the specified file path components.
Expand Down Expand Up @@ -47,5 +49,6 @@ public static function get_optimised_src(\stored_file $file, $originalsrc) {
return null;
}
}
// @codingStandardsIgnoreEnd


4 changes: 2 additions & 2 deletions classes/componentsupport/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function get_optimised_path(array $pathcomponents, $maxwidth) {
} else {
return null;
}
$pathcomponents[count($pathcomponents)-1] = 'imageopt/'.$maxwidth.'/'.$pathcomponents[count($pathcomponents)-1];
$pathcomponents[count($pathcomponents) - 1] = 'imageopt/'.$maxwidth.'/'.$pathcomponents[count($pathcomponents) - 1];
$optimisedpath = implode('/', $pathcomponents);
if (substr($optimisedpath, 0, 1) !== '/') {
$optimisedpath = '/'.$optimisedpath;
Expand All @@ -73,7 +73,7 @@ public static function get_optimised_src(\stored_file $file, $originalsrc) {
array_splice($urlpathcomponents, 6, 0, ['imageopt', $maxwidth]);

$opturl = new \moodle_url($CFG->wwwroot.'/pluginfile.php/'.implode('/', $urlpathcomponents));

return $opturl;
}
}
2 changes: 1 addition & 1 deletion classes/local.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function get_optimised_path($filepath, $asfilepath = true) {
}
}

$pathcomps[count($pathcomps)-1] = 'imageopt/'.$maxwidth.'/'.$pathcomps[count($pathcomps)-1];
$pathcomps[count($pathcomps) - 1] = 'imageopt/'.$maxwidth.'/'.$pathcomps[count($pathcomps) - 1];
$optimisedpath = implode('/', $pathcomps);
if (substr($optimisedpath, 0, 1) !== '/') {
$optimisedpath = '/'.$optimisedpath;
Expand Down
6 changes: 4 additions & 2 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ private function process_img_tag(array $match) {
* @param bool $optimisedavailable
* @return string
*/
private function apply_loadonvisible(array $match, stored_file $file, $originalsrc, $optimisedsrc, $optimisedavailable = false) {
private function apply_loadonvisible(array $match, stored_file $file, $originalsrc, $optimisedsrc,
$optimisedavailable = false) {
global $PAGE;

static $jsloaded = false;
Expand Down Expand Up @@ -253,7 +254,8 @@ private function apply_loadonvisible(array $match, stored_file $file, $originals

$optimisedavailable = $optimisedavailable ? 1 : 0;

$img = str_ireplace('<img ', '<img data-loadonvisible="'.$loadonvisible.'" data-optimised="'.$optimisedavailable.'" ', $img);
$img = str_ireplace('<img ',
'<img data-loadonvisible="'.$loadonvisible.'" data-optimised="'.$optimisedavailable.'" ', $img);
$img = str_ireplace($match[1], 'src="data:image/svg+xml;utf8,'.s($this->empty_image($width, $height)).'"', $img);

return ($img);
Expand Down

0 comments on commit 2fdd37d

Please sign in to comment.