Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #30 #31

Open
wants to merge 3 commits into
base: release_8
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions classes/class.ilOpencastPageComponentPluginGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,20 +525,24 @@ protected function setStyleFromProps(ilTemplate $tpl, array $properties)
$tpl->setVariable('RATIO', $ratio);
$tpl->setVariable('MAX-WIDTH', $properties[self::PROP_WIDTH]);
$tpl->setVariable('MAX-HEIGHT', $properties[self::PROP_HEIGHT]);
if ($properties[self::PROP_RESPONSIVE] != false) {
$tpl->setVariable('WIDTH', 'width:100%;');
if (array_key_exists(self::PROP_RESPONSIVE, $properties)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use a Null Coalescing Operator:

if ((bool)($properties[self::PROP_RESPONSIVE] ?? false) === true) {
    $tpl->setVariable('WIDTH', 'width:100%;');
}

as well as a more strict type handling, and last but not least turning the logic from != false to === true which is more readable.

if ($properties[self::PROP_RESPONSIVE] != false) {
$tpl->setVariable('WIDTH', 'width:100%;');
}
}
switch ($properties[self::PROP_POSITION]) {
case self::POSITION_CENTER:
$tpl->setVariable('CONTAINER_STYLE', 'text-align:center;');
break;
case self::POSITION_RIGHT:
$tpl->setVariable('CONTAINER_STYLE', 'text-align:right;');
break;
case self::POSITION_LEFT:
default:
$tpl->setVariable('CONTAINER_STYLE', 'text-align:left;');
break;
if (array_key_exists(self::PROP_POSITION, $properties)) {
switch ($properties[self::PROP_POSITION]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, instead of using array_key_exists you can just use

switch ($properties[self::PROP_POSITION] ?? null) {

case self::POSITION_CENTER:
$tpl->setVariable('CONTAINER_STYLE', 'text-align:center;');
break;
case self::POSITION_RIGHT:
$tpl->setVariable('CONTAINER_STYLE', 'text-align:right;');
break;
case self::POSITION_LEFT:
default:
$tpl->setVariable('CONTAINER_STYLE', 'text-align:left;');
break;
}
}
}

Expand Down