Example #1
0
 /**
  * Initializes the preview and loads the needed javascripts and styles.
  */
 private static function initPreview()
 {
     if (self::$initialized) {
         return;
     }
     global $tpl, $lng, $ilCtrl;
     // jquery
     include_once "./Services/jQuery/classes/class.iljQueryUtil.php";
     iljQueryUtil::initjQuery();
     // load qtip
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     ilTooltipGUI::initLibrary();
     // needed scripts & styles
     $tpl->addJavaScript("./Services/Preview/js/jquery.mousewheel.js");
     $tpl->addJavaScript("./Services/Preview/js/ilPreview.js");
     $tpl->addCss(ilUtil::getStyleSheetLocation("filesystem", "preview.css", "Services/Preview"));
     // create loading template
     $tmpl = new ilTemplate("tpl.preview.html", true, true, "Services/Preview");
     $tmpl->setCurrentBlock("no_preview");
     $tmpl->setVariable("TXT_NO_PREVIEW", "%%0%%");
     $tmpl->parseCurrentBlock();
     $initialHtml = str_replace(array("\r\n", "\r"), "\n", $tmpl->get());
     $lines = explode("\n", $initialHtml);
     $new_lines = array();
     foreach ($lines as $i => $line) {
         if (!empty($line)) {
             $new_lines[] = trim($line);
         }
     }
     $initialHtml = implode($new_lines);
     // add default texts and values
     include_once "./Services/JSON/classes/class.ilJsonUtil.php";
     $tpl->addOnLoadCode("il.Preview.texts.preview = \"" . self::jsonSafeString($lng->txt("preview")) . "\";");
     $tpl->addOnLoadCode("il.Preview.texts.showPreview = \"" . self::jsonSafeString($lng->txt("preview_show")) . "\";");
     $tpl->addOnLoadCode("il.Preview.texts.close = \"" . self::jsonSafeString($lng->txt("close")) . "\";");
     $tpl->addOnLoadCode("il.Preview.previewSize = " . ilPreviewSettings::getImageSize() . ";");
     $tpl->addOnLoadCode("il.Preview.initialHtml = " . ilJsonUtil::encode($initialHtml) . ";");
     $tpl->addOnLoadCode("il.Preview.highlightClass = \"ilContainerListItemOuterHighlight\";");
     $tpl->addOnLoadCode("il.Preview.init();");
     self::$initialized = true;
 }
 /**
  * insert item title
  *
  * @access	private
  * @param	object		$a_tpl		template object
  * @param	string		$a_title	item title
  */
 public function insertTitle()
 {
     if ($this->restrict_to_goto) {
         $this->default_command = array("frame" => "", "link" => $this->buildGotoLink());
     }
     // begin-patch lok
     if (!$this->default_command || !$this->getCommandsStatus() && !$this->restrict_to_goto || $this->title_link_disabled) {
         $this->tpl->setCurrentBlock("item_title");
         $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
         $this->tpl->parseCurrentBlock();
     } else {
         $this->default_command['link'] = $this->modifyTitleLink($this->default_command['link']);
         $this->default_command["link"] = $this->modifySAHSlaunch($this->default_command["link"], $this->default_command["frame"]);
         if ($this->default_command["frame"] != "") {
             $this->tpl->setCurrentBlock("title_linked_frame");
             $this->tpl->setVariable("TARGET_TITLE_LINKED", $this->default_command["frame"]);
             $this->tpl->parseCurrentBlock();
         }
         // workaround for repository frameset
         #var_dump("<pre>",$this->default_command['link'],"</pre>");
         $this->default_command["link"] = $this->appendRepositoryFrameParameter($this->default_command["link"]);
         #var_dump("<pre>",$this->default_command['link'],"</pre>");
         // the default command is linked with the title
         $this->tpl->setCurrentBlock("item_title_linked");
         $this->tpl->setVariable("TXT_TITLE_LINKED", $this->getTitle());
         $this->tpl->setVariable("HREF_TITLE_LINKED", $this->default_command["link"]);
         // has preview?
         include_once "./Services/Preview/classes/class.ilPreview.php";
         if (ilPreview::hasPreview($this->obj_id, $this->type)) {
             include_once "./Services/Preview/classes/class.ilPreviewGUI.php";
             // get context for access checks later on
             $access_handler = null;
             $context;
             switch ($this->context) {
                 case self::CONTEXT_WORKSPACE:
                 case self::CONTEXT_WORKSPACE_SHARING:
                     $context = ilPreviewGUI::CONTEXT_WORKSPACE;
                     include_once "./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
                     $access_handler = new ilWorkspaceAccessHandler();
                     break;
                 default:
                     global $ilAccess;
                     $context = ilPreviewGUI::CONTEXT_REPOSITORY;
                     $access_handler = $ilAccess;
                     break;
             }
             $preview = new ilPreviewGUI($this->ref_id, $context, $this->obj_id, $access_handler);
             $preview_status = ilPreview::lookupRenderStatus($this->obj_id);
             $preview_status_class = "";
             $preview_text_topic = "preview_show";
             if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
                 $preview_status_class = "ilPreviewStatusNone";
                 $preview_text_topic = "preview_none";
             }
             $this->tpl->setCurrentBlock("item_title_linked");
             $this->tpl->setVariable("PREVIEW_STATUS_CLASS", $preview_status_class);
             $this->tpl->setVariable("SRC_PREVIEW_ICON", ilUtil::getImagePath("preview.png", "Services/Preview"));
             $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt($preview_text_topic));
             $this->tpl->setVariable("SCRIPT_PREVIEW_CLICK", $preview->getJSCall($this->getUniqueItemId(true)));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->parseCurrentBlock();
     }
     if ($this->bold_title == true) {
         $this->tpl->touchBlock('bold_title_start');
         $this->tpl->touchBlock('bold_title_end');
     }
 }
Example #3
0
 /**
  * show information screen
  */
 function infoScreenForward()
 {
     global $ilTabs, $ilErr, $ilToolbar;
     $ilTabs->activateTab("id_info");
     if (!$this->checkPermissionBool("visible")) {
         $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
     }
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     if ($this->checkPermissionBool("read", "sendfile")) {
         // #9876
         $this->lng->loadLanguageModule("file");
         // #14378
         include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
         $button = ilLinkButton::getInstance();
         $button->setCaption("file_download");
         $button->setPrimary(true);
         // get permanent download link for repository
         if ($this->id_type == self::REPOSITORY_NODE_ID) {
             $button->setUrl(ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
         } else {
             $button->setUrl($this->ctrl->getLinkTarget($this, "sendfile"));
         }
         $ilToolbar->addButtonInstance($button);
     }
     $info->enablePrivateNotes();
     if ($this->checkPermissionBool("read")) {
         $info->enableNews();
     }
     // no news editing for files, just notifications
     $info->enableNewsEditing(false);
     if ($this->checkPermissionBool("write")) {
         $news_set = new ilSetting("news");
         $enable_internal_rss = $news_set->get("enable_rss_for_internal");
         if ($enable_internal_rss) {
             $info->setBlockProperty("news", "settings", true);
             $info->setBlockProperty("news", "public_notifications_option", true);
         }
     }
     // standard meta data
     $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
     $info->addSection($this->lng->txt("file_info"));
     $info->addProperty($this->lng->txt("filename"), $this->object->getFileName());
     // BEGIN WebDAV Guess file type.
     $info->addProperty($this->lng->txt("type"), $this->object->guessFileType());
     // END WebDAV Guess file type.
     $info->addProperty($this->lng->txt("size"), ilFormat::formatSize(ilObjFile::_lookupFileSize($this->object->getId()), 'long'));
     $info->addProperty($this->lng->txt("version"), $this->object->getVersion());
     // using getVersions function instead of ilHistory direct
     $uploader = $this->object->getVersions();
     $uploader = array_shift($uploader);
     $uploader = $uploader["user_id"];
     $this->lng->loadLanguageModule("file");
     include_once "Services/User/classes/class.ilUserUtil.php";
     $info->addProperty($this->lng->txt("file_uploaded_by"), ilUserUtil::getNamePresentation($uploader));
     // download link added in repository
     if ($this->id_type == self::REPOSITORY_NODE_ID && $this->checkPermissionBool("read", "sendfile")) {
         $tpl = new ilTemplate("tpl.download_link.html", true, true, "Modules/File");
         $tpl->setVariable("LINK", ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
         $info->addProperty($this->lng->txt("download_link"), $tpl->get());
     }
     if ($this->id_type == self::WORKSPACE_NODE_ID) {
         $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
     }
     // display previews
     include_once "./Services/Preview/classes/class.ilPreview.php";
     if (!$this->ctrl->isAsynch() && ilPreview::hasPreview($this->object->getId(), $this->object->getType()) && $this->checkPermissionBool("read")) {
         include_once "./Services/Preview/classes/class.ilPreviewGUI.php";
         // get context for access checks later on
         $context;
         switch ($this->id_type) {
             case self::WORKSPACE_NODE_ID:
             case self::WORKSPACE_OBJECT_ID:
                 $context = ilPreviewGUI::CONTEXT_WORKSPACE;
                 break;
             default:
                 $context = ilPreviewGUI::CONTEXT_REPOSITORY;
                 break;
         }
         $preview = new ilPreviewGUI($this->node_id, $context, $this->object->getId(), $this->access_handler);
         $info->addProperty($this->lng->txt("preview"), $preview->getInlineHTML());
     }
     // forward the command
     // $this->ctrl->setCmd("showSummary");
     // $this->ctrl->setCmdClass("ilinfoscreengui");
     $this->ctrl->forwardCommand($info);
 }
 /**
  * function parses stored value in database to a html output for eg. the record list gui.
  *
  * @param                             $value
  * @param ilDataCollectionRecordField $record_field
  *
  * @return mixed
  */
 public function parseHTML($value, ilDataCollectionRecordField $record_field, $link = true)
 {
     global $ilAccess, $ilCtrl, $lng;
     switch ($this->id) {
         case self::INPUTFORMAT_DATETIME:
             $html = ilDatePresentation::formatDate(new ilDate($value, IL_CAL_DATETIME));
             break;
         case self::INPUTFORMAT_FILE:
             if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
                 $html = "";
                 break;
             }
             $file_obj = new ilObjFile($value, false);
             $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "record_id", $record_field->getRecord()->getId());
             $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "field_id", $record_field->getField()->getId());
             $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordlistgui", "sendFile") . '">' . $file_obj->getFileName() . '</a>';
             if (ilPreview::hasPreview($file_obj->getId())) {
                 ilPreview::createPreview($file_obj);
                 // Create preview if not already existing
                 $preview = new ilPreviewGUI((int) $_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $ilAccess);
                 $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
                 $preview_status_class = "";
                 $preview_text_topic = "preview_show";
                 if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
                     $preview_status_class = "ilPreviewStatusNone";
                     $preview_text_topic = "preview_none";
                 }
                 $wrapper_html_id = 'record_field_' . $record_field->getId();
                 $script_preview_click = $preview->getJSCall($wrapper_html_id);
                 $preview_title = $lng->txt($preview_text_topic);
                 $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
                 $html = '<div id="' . $wrapper_html_id . '">' . $html;
                 $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="' . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon . '" height="16" width="16"></a></span></div>';
             }
             break;
         case self::INPUTFORMAT_MOB:
             $mob = new ilObjMediaObject($value, false);
             $med = $mob->getMediaItem('Standard');
             if (!$med->location) {
                 $html = "";
                 break;
             }
             $arr_properties = $record_field->getField()->getProperties();
             $is_linked_field = $arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_MOB];
             $has_view = ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId());
             if (in_array($med->getSuffix(), array('jpg', 'jpeg', 'png', 'gif'))) {
                 // Image
                 $dir = ilObjMediaObject::_getDirectory($mob->getId());
                 $width = (int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
                 $height = (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
                 $html = ilUtil::img($dir . "/" . $med->location, '', $width, $height);
                 if ($is_linked_field and $has_view and $link) {
                     $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
                     $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $html . '</a>';
                 }
             } else {
                 // Video/Audio
                 $mpl = new ilMediaPlayerGUI($med->getId(), '');
                 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
                 $mpl->setMimeType($med->getFormat());
                 $mpl->setDisplayWidth((int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH] . 'px');
                 $mpl->setDisplayHeight((int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT] . 'px');
                 $mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
                 $html = $mpl->getPreviewHtml();
                 if ($is_linked_field and $has_view) {
                     global $lng;
                     $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
                     $html = $html . '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $lng->txt('details') . '</a>';
                 }
             }
             break;
         case self::INPUTFORMAT_BOOLEAN:
             switch ($value) {
                 case 0:
                     $im = ilUtil::getImagePath('icon_not_ok.svg');
                     break;
                 case 1:
                     $im = ilUtil::getImagePath('icon_ok.svg');
                     break;
             }
             $html = "<img src='" . $im . "'>";
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_TEXT:
             //Property URL
             $arr_properties = $record_field->getField()->getProperties();
             if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) {
                 $link = $value;
                 if (preg_match("/^[a-z0-9!#\$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i", $value)) {
                     $value = "mailto:" . $value;
                 } elseif (!preg_match('~(^(news|(ht|f)tp(s?)\\://){1}\\S+)~i', $value)) {
                     return $link;
                 }
                 $link = $this->shortenLink($link);
                 $html = "<a target='_blank' href='" . $value . "'>" . $link . "</a>";
             } elseif ($arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_TEXT] and $link and ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId())) {
                 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
                 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $value . '</a>';
             } else {
                 $html = $value;
             }
             break;
         default:
             $html = $value;
             break;
     }
     return $html;
 }