private function isValidH5pData($h5pData, $library_name, $required, $optional) {
    $valid = $this->isValidRequiredH5pData($h5pData, $required, $library_name);
    $valid = $this->isValidOptionalH5pData($h5pData, $optional, $library_name) && $valid;

    // Check the library's required API version of Core.
    // If no requirement is set this implicitly means 1.0.
    if (isset($h5pData['coreApi']) && !empty($h5pData['coreApi'])) {
      if (($h5pData['coreApi']['majorVersion'] > H5PCore::$coreApi['majorVersion']) ||
          ( ($h5pData['coreApi']['majorVersion'] == H5PCore::$coreApi['majorVersion']) &&
            ($h5pData['coreApi']['minorVersion'] > H5PCore::$coreApi['minorVersion']) )) {

        $this->h5pF->setErrorMessage(
            $this->h5pF->t('The system was unable to install the <em>%component</em> component from the package, it requires a newer version of the H5P plugin. This site is currently running version %current, whereas the required version is %required or higher. You should consider upgrading and then try again.',
                array(
                  '%component' => (isset($h5pData['title']) ? $h5pData['title'] : $library_name),
                  '%current' => H5PCore::$coreApi['majorVersion'] . '.' . H5PCore::$coreApi['minorVersion'],
                  '%required' => $h5pData['coreApi']['majorVersion'] . '.' . $h5pData['coreApi']['minorVersion']
                )
            ),
            'api-version-unsupported'
        );

        $valid = false;
      }
    }

    return $valid;
  }
private function isValidH5pData($h5pData, $library_name, $required, $optional) {
    $valid = $this->isValidRequiredH5pData($h5pData, $required, $library_name);
    $valid = $this->isValidOptionalH5pData($h5pData, $optional, $library_name) && $valid;

    // Check the library's required API version of Core.
    // If no requirement is set this implicitly means 1.0.
    if (isset($h5pData['coreApi']) && !empty($h5pData['coreApi'])) {
      if (($h5pData['coreApi']['majorVersion'] > H5PCore::$coreApi['majorVersion']) ||
          ( ($h5pData['coreApi']['majorVersion'] == H5PCore::$coreApi['majorVersion']) &&
            ($h5pData['coreApi']['minorVersion'] > H5PCore::$coreApi['minorVersion']) )) {

        $this->h5pF->setErrorMessage(
            $this->h5pF->t('The system was unable to install the <em>%component</em> component from the package, it requires a newer version of the H5P plugin. This site is currently running version %current, whereas the required version is %required or higher. You should consider upgrading and then try again.',
                array(
                  '%component' => (isset($h5pData['title']) ? $h5pData['title'] : $library_name),
                  '%current' => H5PCore::$coreApi['majorVersion'] . '.' . H5PCore::$coreApi['minorVersion'],
                  '%required' => $h5pData['coreApi']['majorVersion'] . '.' . $h5pData['coreApi']['minorVersion']
                )
            ),
            'api-version-unsupported'
        );

        $valid = false;
      }
    }

    return $valid;
  }
private function isValidH5pData ( $ h5pData , $ library_name , $ required , $ optional ) { $ valid = $ this -> isValidRequiredH5pData ( $ h5pData , $ required , $ library_name ) ; $ valid = $ this -> isValidOptionalH5pData ( $ h5pData , $ optional , $ library_name ) && $ valid ; // Check the library's required API version of Core. // If no requirement is set this implicitly means 1.0. if ( isset ( $ h5pData [ 'coreApi' ] ) && ! empty ( $ h5pData [ 'coreApi' ] ) ) { if ( ( $ h5pData [ 'coreApi' ] [ 'majorVersion' ] > H5PCore :: $ coreApi [ 'majorVersion' ] ) || ( ( $ h5pData [ 'coreApi' ] [ 'majorVersion' ] == H5PCore :: $ coreApi [ 'majorVersion' ] ) && ( $ h5pData [ 'coreApi' ] [ 'minorVersion' ] > H5PCore :: $ coreApi [ 'minorVersion' ] ) ) ) { $ this -> h5pF -> setErrorMessage ( $ this -> h5pF -> t ( 'The system was unable to install the <em>%component</em> component from the package, it requires a newer version of the H5P plugin. This site is currently running version %current, whereas the required version is %required or higher. You should consider upgrading and then try again.' , array ( '%component' => ( isset ( $ h5pData [ 'title' ] ) ? $ h5pData [ 'title' ] : $ library_name ) , '%current' => H5PCore :: $ coreApi [ 'majorVersion' ] . '.' . H5PCore :: $ coreApi [ 'minorVersion' ] , '%required' => $ h5pData [ 'coreApi' ] [ 'majorVersion' ] . '.' . $ h5pData [ 'coreApi' ] [ 'minorVersion' ] ) ) , 'api-version-unsupported' ) ; $ valid = false ; } } return $ valid ; }
Validates h5p.json and library.json data

Error messages are triggered if the data isn't valid

@param array $h5pData
h5p data
@param string $library_name
Name of the library we are processing
@param array $required
Validation pattern for required properties
@param array $optional
Validation pattern for optional properties
@return boolean
TRUE if the $h5pData is valid
Validates h5p . json and library . json data