/** * Creates the preview of the specified preview object. * * @param ilPreview $preview The preview object. * @param ilObject $obj The object to create a preview for. * @param bool $async true, if the rendering should be done asynchronously; otherwise, false. * @return bool true, if the preview was successfully rendered; otherwise, false. */ public final function render($preview, $obj, $async) { $preview->setRenderDate(ilUtil::now()); $preview->setRenderStatus(ilPreview::RENDER_STATUS_PENDING); $preview->save(); // TODO: this should be done in background if $async is true // the deriving renderer should deliver images require_once "./Services/Preview/classes/class.ilRenderedImage.php"; $images = $this->renderImages($obj); // process each image if (is_array($images) && count($images) > 0) { $success = false; foreach ($images as $idx => $image) { // create the ending preview image $success |= $this->createPreviewImage($image->getImagePath(), sprintf($preview->getFilePathFormat(), $idx + 1)); // if the image is temporary we can delete it if ($image->isTemporary()) { $image->delete(); } } $preview->setRenderDate(ilUtil::now()); $preview->setRenderStatus($success ? ilPreview::RENDER_STATUS_CREATED : ilPreview::RENDER_STATUS_FAILED); return $success; } else { $preview->setRenderDate(ilUtil::now()); $preview->setRenderStatus(ilPreview::RENDER_STATUS_FAILED); return false; } }