Fix compability with PHP <5.4

Big thanks to andyrandom at drupal.org for providing the fix.
JI-92-path-fix 1.13.0
Frode Petterson 2017-01-26 10:37:26 +01:00
parent 79fb0e310c
commit e02df35bb1
1 changed files with 6 additions and 4 deletions

View File

@ -2512,9 +2512,9 @@ class H5PCore {
* @return array * @return array
*/ */
public function getDisplayOptionsForEdit($disable = NULL) { public function getDisplayOptionsForEdit($disable = NULL) {
$display_options = []; $display_options = array();
$current_display_options = $disable === NULL ? [] : $this->getDisplayOptionsAsArray($disable); $current_display_options = $disable === NULL ? array() : $this->getDisplayOptionsAsArray($disable);
if ($this->h5pF->getOption(self::DISPLAY_OPTION_FRAME, TRUE)) { if ($this->h5pF->getOption(self::DISPLAY_OPTION_FRAME, TRUE)) {
$display_options[self::DISPLAY_OPTION_FRAME] = $display_options[self::DISPLAY_OPTION_FRAME] =
@ -3267,9 +3267,11 @@ class H5PContentValidator {
if (!in_array($value->library, $semantics->options)) { if (!in_array($value->library, $semantics->options)) {
$message = NULL; $message = NULL;
// Create an understandable error message: // Create an understandable error message:
$machineName = explode(' ', $value->library)[0]; $machineNameArray = explode(' ', $value->library);
$machineName = $machineNameArray[0];
foreach ($semantics->options as $semanticsLibrary) { foreach ($semantics->options as $semanticsLibrary) {
$semanticsMachineName = explode(' ', $semanticsLibrary)[0]; $semanticsMachineNameArray = explode(' ', $semanticsLibrary);
$semanticsMachineName = $semanticsMachineNameArray[0];
if ($machineName === $semanticsMachineName) { if ($machineName === $semanticsMachineName) {
// Using the wrong version of the library in the content // Using the wrong version of the library in the content
$message = $this->h5pF->t('The version of the H5P library %machineName used in this content is not valid. Content contains %contentLibrary, but it should be %semanticsLibrary.', array( $message = $this->h5pF->t('The version of the H5P library %machineName used in this content is not valid. Content contains %contentLibrary, but it should be %semanticsLibrary.', array(