Esempio n. 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;
 }
 /**
  * Gets the size of the preview images in pixels.
  * 
  * @return int The current value
  */
 protected final function getImageSize()
 {
     return ilPreviewSettings::getImageSize();
 }