Regenerate export if missing on view

Thanks to paravibe on Drupal.org for contributing.
pull/28/head
Frode Petterson 2016-09-23 10:52:40 +02:00
parent 263a987eeb
commit 1c5b9707e5
3 changed files with 23 additions and 1 deletions

View File

@ -151,6 +151,17 @@ class H5PDefaultStorage implements \H5PFileStorage {
} }
} }
/**
* Check if the given export file exists
*
* @param string $filename
* @return boolean
*/
public function hasExport($filename) {
$target = "{$this->path}/exports/{$filename}";
return file_exists($target);
}
/** /**
* Will concatenate all JavaScrips and Stylesheets into two files in order * Will concatenate all JavaScrips and Stylesheets into two files in order
* to improve page performance. * to improve page performance.

View File

@ -90,6 +90,14 @@ interface H5PFileStorage {
*/ */
public function deleteExport($filename); public function deleteExport($filename);
/**
* Check if the given export file exists
*
* @param string $filename
* @return boolean
*/
public function hasExport($filename);
/** /**
* Will concatenate all JavaScrips and Stylesheets into two files in order * Will concatenate all JavaScrips and Stylesheets into two files in order
* to improve page performance. * to improve page performance.

View File

@ -1812,7 +1812,10 @@ class H5PCore {
* @return Object NULL on failure. * @return Object NULL on failure.
*/ */
public function filterParameters(&$content) { public function filterParameters(&$content) {
if (isset($content['filtered']) && $content['filtered'] !== '') { if (!empty($content['filtered']) &&
(!$this->exportEnabled ||
($content['slug'] &&
$this->fs->hasExport($content['slug'] . '-' . $content['id'] . '.h5p')))) {
return $content['filtered']; return $content['filtered'];
} }