4require_once(
"./Services/Preview/classes/class.ilPreviewSettings.php");
 
    5require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
   37        public function __construct($a_node_id = 
null, $a_context = self::CONTEXT_REPOSITORY, $a_obj_id = 
null, $a_access_handler = 
null) 
 
   42                if (strtolower(
$_GET[
"baseClass"]) == 
"ilpreviewgui")
 
   44                        $this->node_id = (int)
$_GET[
"node_id"];
 
   45                        $this->context = (int)
$_GET[
"context"];
 
   46            $a_obj_id = (int)
$_GET[
'obj_id'];
 
   50                        $this->node_id = $a_node_id;
 
   51                        $this->context = $a_context;
 
   59                if ($a_access_handler == 
null)
 
   61                        if ($this->context == self::CONTEXT_WORKSPACE)
 
   63                                include_once(
"./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php");
 
   68                                $a_access_handler = $ilAccess;
 
   71                $this->access_handler = $a_access_handler;
 
   74                if ($a_obj_id == 
null)
 
   76                        if ($this->context == self::CONTEXT_WORKSPACE)
 
   77                                $a_obj_id = $this->access_handler->getTree()->lookupObjectId($this->node_id);
 
   81                $this->obj_id = $a_obj_id;
 
   84                $this->preview = 
new ilPreview($this->obj_id);
 
   96                $cmd = $this->ctrl->getCmd(
"getPreviewHTML");
 
   97                $next_class = $this->ctrl->getNextClass($this);
 
  102                                return $this->
$cmd();
 
  114                $status = $this->preview->getRenderStatus();
 
  120                return "il.Preview.toggle(event, { id: '{$this->node_id}', htmlId: '{$a_html_id}', url: '$link', status: '$status', loadingText: '$loading_text' });";  
 
  130                $tmpl = 
new ilTemplate(
"tpl.preview.html", 
true, 
true, 
"Services/Preview");
 
  131                $tmpl->setVariable(
"PREVIEW_ID", $this->
getHtmlId());
 
  134                $preview_status = $this->preview->getRenderStatus();
 
  137                if ($this->access_handler->checkAccess(
"read", 
"", $this->node_id))
 
  140                        $images = $this->preview->getImages();
 
  141                        if (count($images) > 0)
 
  143                                foreach ($images as $image)
 
  145                                        $tmpl->setCurrentBlock(
"preview_item");
 
  146                                        $tmpl->setVariable(
"IMG_URL", $image[
"url"]);
 
  147                                        $tmpl->setVariable(
"WIDTH", $image[
"width"]);
 
  148                                        $tmpl->setVariable(
"HEIGHT", $image[
"height"]);
 
  149                                        $tmpl->parseCurrentBlock();
 
  155                                $tmpl->setCurrentBlock(
"no_preview");
 
  156                                switch ($preview_status)
 
  159                                                $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"preview_status_pending"));
 
  163                                                $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"preview_status_failed"));
 
  167                                                $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"preview_status_missing"));
 
  170                                $tmpl->parseCurrentBlock();
 
  176                        $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"no_access_item"));
 
  180                if ($this->ctrl->isAsynch())
 
  182                        include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
 
  184                        $response = 
new stdClass();     
 
  185                        $response->html = $tmpl->get();
 
  186                        $response->status = $preview_status;
 
  189                        header(
'Vary: Accept');
 
  190                        header(
'Content-type: text/plain');
 
  208                $tmpl = 
new ilTemplate(
"tpl.preview_inline.html", 
true, 
true, 
"Services/Preview");
 
  212                if ($this->access_handler->checkAccess(
"read", 
"", $this->node_id))
 
  218                                "preview_status_creating",
 
  223                if ($this->access_handler->checkAccess(
"write", 
"", $this->node_id))
 
  229                                "preview_status_deleting",
 
  244        private function renderCommand($tmpl, $a_cmd, $btn_topic, $loading_topic, $a_display_status)
 
  247                $preview_status = $this->preview->getRenderStatus();
 
  250                $link = $this->
buildUrl($a_cmd . 
"Preview");
 
  251                $script_args = 
"event, { id: '{$this->node_id}', htmlId: '$preview_html_id', url: '$link', loadingText: '$loading_text' }";
 
  254                if (!is_array($a_display_status) || !in_array($preview_status, $a_display_status))
 
  255                        $action_class = 
"ilPreviewActionHidden";
 
  257                $tmpl->setCurrentBlock(
"preview_action");
 
  258                $tmpl->setVariable(
"CLICK_ACTION", 
"il.Preview.$a_cmd($script_args);");
 
  259                $tmpl->setVariable(
"ACTION_CLASS", 
"$action_class");
 
  260                $tmpl->setVariable(
"ACTION_ID", 
"preview_{$a_cmd}_" . $this->node_id);
 
  261                $tmpl->setVariable(
"TXT_ACTION", $this->lng->txt($btn_topic));
 
  262                $tmpl->parseCurrentBlock();
 
  272                if ($this->access_handler->checkAccess(
"read", 
"", $this->node_id))
 
  276                        $this->preview->create($obj);
 
  289                if ($this->access_handler->checkAccess(
"write", 
"", $this->node_id))
 
  292                        require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
  293                        $this->preview->delete();
 
  314        private function buildUrl($a_cmd = 
"", $a_async = 
true)
 
  316                $link = 
"ilias.php?baseClass=ilPreviewGUI&node_id={$this->node_id}&context={$this->context}&obj_id={$this->obj_id}";
 
  319                        $link .= 
"&cmdMode=asynch";
 
  322                        $link .= 
"&cmd=$a_cmd";
 
  332                if (self::$initialized)
 
  339                include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
 
  343                include_once(
"./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
 
  347                $tpl->addJavaScript(
"./Services/Preview/js/jquery.mousewheel.js");
 
  348                $tpl->addJavaScript(
"./Services/Preview/js/ilPreview.js");
 
  352                $tmpl = 
new ilTemplate(
"tpl.preview.html", 
true, 
true, 
"Services/Preview");
 
  353                $tmpl->setCurrentBlock(
"no_preview");
 
  354                $tmpl->setVariable(
"TXT_NO_PREVIEW", 
"%%0%%");
 
  355                $tmpl->parseCurrentBlock();
 
  357                $initialHtml = str_replace(array(
"\r\n", 
"\r"), 
"\n", $tmpl->get());
 
  358                $lines = explode(
"\n", $initialHtml);
 
  359                $new_lines = array();
 
  360                foreach ($lines as $i => $line) 
 
  363                                $new_lines[] = trim($line);
 
  365                $initialHtml = implode($new_lines);             
 
  368                include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
 
  369                $tpl->addOnLoadCode(
"il.Preview.texts.preview = \"" . self::jsonSafeString(
$lng->txt(
"preview")) . 
"\";");
 
  370                $tpl->addOnLoadCode(
"il.Preview.texts.showPreview = \"" . self::jsonSafeString(
$lng->txt(
"preview_show")) . 
"\";");
 
  374                $tpl->addOnLoadCode(
"il.Preview.highlightClass = \"ilContainerListItemOuterHighlight\";");
 
  375                $tpl->addOnLoadCode(
"il.Preview.init();");
 
  377                self::$initialized = 
true;
 
  388                if (!is_string($text))
 
  391                $text = htmlentities($text, ENT_COMPAT | ENT_HTML401, 
"UTF-8");
 
  392                $text = str_replace(
"'", 
"'", $text);
 
static encode($mixed, $suppress_native=false)
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjId($a_id)
getInlineHTML()
Gets the HTML that is used for displaying the preview inline.
renderPreview()
Renders the preview and returns the HTML code that displays the preview.
static jsonSafeString($text)
Makes the specified string safe for JSON.
deletePreview()
Deletes the preview and returns the HTML code that displays the preview.
getHtmlId()
Gets the HTML id for the preview.
getPreviewHTML()
Gets the HTML that displays the preview.
& executeCommand()
execute command
static initPreview()
Initializes the preview and loads the needed javascripts and styles.
__construct($a_node_id=null, $a_context=self::CONTEXT_REPOSITORY, $a_obj_id=null, $a_access_handler=null)
Creates a new preview GUI.
getJSCall($a_html_id)
Gets the JavaScript code to show the preview.
renderCommand($tmpl, $a_cmd, $btn_topic, $loading_topic, $a_display_status)
Renders a command to the specified template.
buildUrl($a_cmd="", $a_async=true)
Builds the URL to call the preview GUI.
static getImageSize()
Gets the size of the preview images in pixels.
const RENDER_STATUS_FAILED
const RENDER_STATUS_CREATED
const RENDER_STATUS_PENDING
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
Access handler for personal workspace.
static initjQuery($a_tpl=null)
Init jQuery.