Beispiel #1
0
 /**
  * Creates the preview.
  * 
  * @param ilObject $a_obj The object to create the preview for.
  * @param bool $a_force true, to force the creation of the preview; false, to create the preview only if needed.
  * @return bool true, if the preview was created; otherwise, false.
  */
 public function create($a_obj, $a_force = false)
 {
     if (!ilPreviewSettings::isPreviewEnabled()) {
         return false;
     }
     // get renderer for preview
     require_once "./Services/Preview/classes/class.ilRendererFactory.php";
     $renderer = ilRendererFactory::getRenderer($this);
     // no renderer available?
     if ($renderer == null) {
         return false;
     }
     // exists, but still pending?
     if ($this->getRenderStatus() == self::RENDER_STATUS_PENDING) {
         return false;
     }
     // not forced? check if update really needed
     if ($this->getRenderStatus() == self::RENDER_STATUS_CREATED && !$a_force) {
         // check last modified against last render date
         if ($a_obj->getLastUpdateDate() <= $this->getRenderDate()) {
             return false;
         }
     }
     // re-create the directory to store the previews
     $this->getStorage()->delete();
     $this->getStorage()->create();
     // let the renderer create the preview
     $renderer->render($this, $a_obj, true);
     // save to database
     $this->save();
     return true;
 }
 /**
  * Edit preview settings.
  */
 public function editPreviewSettings()
 {
     global $rbacsystem, $ilErr, $tpl, $lng;
     $this->tabs_gui->setTabActive('preview_settings');
     if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
         $ilErr->raiseError($lng->txt("no_permission"), $ilErr->WARNING);
     }
     // set warning if ghostscript not installed
     if (!is_file(PATH_TO_GHOSTSCRIPT)) {
         ilUtil::sendInfo($lng->txt("ghostscript_not_configured"));
     }
     // get form
     $form = $this->initPreviewSettingsForm();
     // set current values
     require_once "Services/Preview/classes/class.ilPreviewSettings.php";
     $val = array();
     $val["enable_preview"] = ilPreviewSettings::isPreviewEnabled();
     $val["max_previews_per_object"] = ilPreviewSettings::getMaximumPreviews();
     $form->setValuesByArray($val);
     $html = $form->getHTML();
     // build renderer HTML
     require_once "Services/Preview/classes/class.ilRendererFactory.php";
     require_once "Services/Preview/classes/class.ilRendererTableGUI.php";
     $renderers = ilRendererFactory::getRenderers();
     $table = new ilRendererTableGUI($this, array("editPreviewSettings", "view"));
     $table->setMaxCount(sizeof($renderers));
     $table->setData($renderers);
     $html .= "<br/>" . $table->getHTML();
     // set content
     $tpl->setContent($html);
 }