|
| renderCommand ($tmpl, $a_cmd, $btn_topic, $loading_topic, $a_display_status) |
| Renders a command to the specified template. More...
|
|
| getHtmlId () |
| Gets the HTML id for the preview. More...
|
|
| buildUrl ($a_cmd="", $a_async=true) |
| Builds the URL to call the preview GUI. More...
|
|
Definition at line 15 of file class.ilPreviewGUI.php.
◆ __construct()
ilPreviewGUI::__construct |
( |
|
$a_node_id = null , |
|
|
|
$a_context = self::CONTEXT_REPOSITORY , |
|
|
|
$a_obj_id = null , |
|
|
|
$a_access_handler = null |
|
) |
| |
Creates a new preview GUI.
- Parameters
-
int | $a_node_id | The node id. |
int | $a_context | The context of the preview. |
int | $a_obj_id | The object id. |
object | $a_access_handler | The access handler to use. |
Definition at line 61 of file class.ilPreviewGUI.php.
References $_GET, $ilCtrl, $lng, ilObject\_lookupObjId(), and initPreview().
66 if (strtolower(
$_GET[
"baseClass"]) ==
"ilpreviewgui")
68 $this->node_id = (int)
$_GET[
"node_id"];
69 $this->context = (int)
$_GET[
"context"];
70 $a_obj_id = (int)
$_GET[
'obj_id'];
74 $this->node_id = $a_node_id;
75 $this->context = $a_context;
83 if ($a_access_handler == null)
85 if ($this->context == self::CONTEXT_WORKSPACE)
87 include_once(
"./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php");
92 $a_access_handler = $ilAccess;
95 $this->access_handler = $a_access_handler;
98 if ($a_obj_id == null)
100 if ($this->context == self::CONTEXT_WORKSPACE)
101 $a_obj_id = $this->access_handler->getTree()->lookupObjectId($this->node_id);
105 $this->obj_id = $a_obj_id;
108 $this->preview =
new ilPreview($this->obj_id);
111 if (!$ilCtrl->isAsynch())
Access handler for personal workspace.
static _lookupObjId($a_id)
static initPreview()
Initializes the preview and loads the needed javascripts and styles.
◆ buildUrl()
ilPreviewGUI::buildUrl |
( |
|
$a_cmd = "" , |
|
|
|
$a_async = true |
|
) |
| |
|
private |
Builds the URL to call the preview GUI.
- Parameters
-
$a_cmd | string The command to call. |
$a_async | bool true, to create a URL to call asynchronous; otherwise, false. |
- Returns
- string The created URL.
Definition at line 339 of file class.ilPreviewGUI.php.
Referenced by getJSCall(), and renderCommand().
341 $link =
"ilias.php?baseClass=ilPreviewGUI&node_id={$this->node_id}&context={$this->context}&obj_id={$this->obj_id}";
344 $link .=
"&cmdMode=asynch";
347 $link .=
"&cmd=$a_cmd";
◆ deletePreview()
ilPreviewGUI::deletePreview |
( |
| ) |
|
Deletes the preview and returns the HTML code that displays the preview.
- Returns
- string The HTML code that displays the preview.
Definition at line 311 of file class.ilPreviewGUI.php.
References getPreviewHTML().
314 if ($this->access_handler->checkAccess(
"write",
"", $this->node_id))
317 require_once(
"./Services/Preview/classes/class.ilPreview.php");
318 $this->preview->delete();
getPreviewHTML()
Gets the HTML that displays the preview.
◆ executeCommand()
ilPreviewGUI::executeCommand |
( |
| ) |
|
execute command
Definition at line 118 of file class.ilPreviewGUI.php.
References $cmd.
120 $cmd = $this->ctrl->getCmd(
"getPreviewHTML");
121 $next_class = $this->ctrl->getNextClass($this);
126 return $this->
$cmd();
◆ getHtmlId()
ilPreviewGUI::getHtmlId |
( |
| ) |
|
|
private |
◆ getInlineHTML()
ilPreviewGUI::getInlineHTML |
( |
| ) |
|
Gets the HTML that is used for displaying the preview inline.
- Returns
- string The HTML that is used for displaying the preview inline.
Definition at line 231 of file class.ilPreviewGUI.php.
References array, getPreviewHTML(), ilPreview\RENDER_STATUS_CREATED, ilPreview\RENDER_STATUS_FAILED, ilPreview\RENDER_STATUS_NONE, and renderCommand().
233 $tmpl =
new ilTemplate(
"tpl.preview_inline.html",
true,
true,
"Services/Preview");
237 if ($this->access_handler->checkAccess(
"read",
"", $this->node_id))
243 "preview_status_creating",
248 if ($this->access_handler->checkAccess(
"write",
"", $this->node_id))
254 "preview_status_deleting",
const RENDER_STATUS_FAILED
getPreviewHTML()
Gets the HTML that displays the preview.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
const RENDER_STATUS_CREATED
renderCommand($tmpl, $a_cmd, $btn_topic, $loading_topic, $a_display_status)
Renders a command to the specified template.
◆ getJSCall()
ilPreviewGUI::getJSCall |
( |
|
$a_html_id | ) |
|
Gets the JavaScript code to show the preview.
- Parameters
-
$a_html_id | string The id of the HTML element that contains the preview. |
- Returns
- string The JavaScript code to show the preview.
Definition at line 136 of file class.ilPreviewGUI.php.
References buildUrl(), and ilPreview\RENDER_STATUS_NONE.
138 $status = $this->preview->getRenderStatus();
140 $loading_text = self::jsonSafeString($this->lng->txt($status ==
ilPreview::RENDER_STATUS_NONE ?
"preview_status_creating" :
"preview_loading"));
144 return "il.Preview.toggle(event, { id: '{$this->node_id}', htmlId: '{$a_html_id}', url: '$link', status: '$status', loadingText: '$loading_text' });";
buildUrl($a_cmd="", $a_async=true)
Builds the URL to call the preview GUI.
◆ getPreviewHTML()
ilPreviewGUI::getPreviewHTML |
( |
| ) |
|
Gets the HTML that displays the preview.
- Returns
- string The HTML that displays the preview.
Definition at line 151 of file class.ilPreviewGUI.php.
References ilJsonUtil\encode(), exit, getHtmlId(), header, ilPreview\RENDER_STATUS_FAILED, ilPreview\RENDER_STATUS_PENDING, and ilWACSignedPath\signFile().
Referenced by deletePreview(), getInlineHTML(), and renderPreview().
153 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
155 $tmpl =
new ilTemplate(
"tpl.preview.html",
true,
true,
"Services/Preview");
156 $tmpl->setVariable(
"PREVIEW_ID", $this->
getHtmlId());
159 $preview_status = $this->preview->getRenderStatus();
162 if ($this->access_handler->checkAccess(
"read",
"", $this->node_id))
165 $images = $this->preview->getImages();
166 if (count($images) > 0)
168 foreach ($images as $image)
170 $tmpl->setCurrentBlock(
"preview_item");
172 $tmpl->setVariable(
"WIDTH", $image[
"width"]);
173 $tmpl->setVariable(
"HEIGHT", $image[
"height"]);
174 $tmpl->parseCurrentBlock();
180 $tmpl->setCurrentBlock(
"no_preview");
181 switch ($preview_status)
184 $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"preview_status_pending"));
188 $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"preview_status_failed"));
192 $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"preview_status_missing"));
195 $tmpl->parseCurrentBlock();
201 $tmpl->setVariable(
"TXT_NO_PREVIEW", $this->lng->txt(
"no_access_item"));
205 if ($this->ctrl->isAsynch())
207 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
209 $response =
new stdClass();
210 $response->html = $tmpl->get();
211 $response->status = $preview_status;
215 header(
'Content-type: text/plain');
const RENDER_STATUS_FAILED
const RENDER_STATUS_PENDING
static encode($mixed, $suppress_native=false)
special template class to simplify handling of ITX/PEAR
Add a drawing to the header
static signFile($path_to_file)
getHtmlId()
Gets the HTML id for the preview.
◆ initPreview()
static ilPreviewGUI::initPreview |
( |
| ) |
|
|
staticprivate |
Initializes the preview and loads the needed javascripts and styles.
Definition at line 355 of file class.ilPreviewGUI.php.
References $ilCtrl, $lng, $tpl, array, ilJsonUtil\encode(), ilPreviewSettings\getImageSize(), ilUtil\getStyleSheetLocation(), iljQueryUtil\initjQuery(), ilTooltipGUI\initLibrary(), and ilUtil\prepareFormOutput().
Referenced by __construct().
357 if (self::$initialized)
364 include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
368 include_once(
"./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
372 $tpl->addJavaScript(
"./Services/Preview/js/jquery.mousewheel.js");
373 $tpl->addJavaScript(
"./Services/Preview/js/ilPreview.js");
377 $tmpl =
new ilTemplate(
"tpl.preview.html",
true,
true,
"Services/Preview");
378 $tmpl->setCurrentBlock(
"no_preview");
379 $tmpl->setVariable(
"TXT_NO_PREVIEW",
"%%0%%");
380 $tmpl->parseCurrentBlock();
382 $initialHtml = str_replace(
array(
"\r\n",
"\r"),
"\n", $tmpl->get());
383 $lines = explode(
"\n", $initialHtml);
384 $new_lines =
array();
385 foreach ($lines as $i => $line)
388 $new_lines[] = trim($line);
390 $initialHtml = implode($new_lines);
393 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
394 $tpl->addOnLoadCode(
"il.Preview.texts.preview = \"" . self::jsonSafeString($lng->txt(
"preview")) .
"\";");
395 $tpl->addOnLoadCode(
"il.Preview.texts.showPreview = \"" . self::jsonSafeString($lng->txt(
"preview_show")) .
"\";");
398 $tpl->addOnLoadCode(
"il.Preview.initialHtml = " .
ilJsonUtil::encode($initialHtml) .
";");
399 $tpl->addOnLoadCode(
"il.Preview.highlightClass = \"ilContainerListItemOuterHighlight\";");
400 $tpl->addOnLoadCode(
"il.Preview.init();");
402 self::$initialized =
true;
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static encode($mixed, $suppress_native=false)
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
static getImageSize()
Gets the size of the preview images in pixels.
static initjQuery($a_tpl=null)
Init jQuery.
◆ jsonSafeString()
static ilPreviewGUI::jsonSafeString |
( |
|
$text | ) |
|
|
staticprivate |
Makes the specified string safe for JSON.
- Parameters
-
string | $text | The text to make JSON safe. |
- Returns
- The JSON safe text.
Definition at line 411 of file class.ilPreviewGUI.php.
References $text.
413 if (!is_string(
$text))
416 $text = htmlentities(
$text, ENT_COMPAT | ENT_HTML401,
"UTF-8");
◆ renderCommand()
ilPreviewGUI::renderCommand |
( |
|
$tmpl, |
|
|
|
$a_cmd, |
|
|
|
$btn_topic, |
|
|
|
$loading_topic, |
|
|
|
$a_display_status |
|
) |
| |
|
private |
Renders a command to the specified template.
- Parameters
-
$tmpl | object The template. |
$a_cmd | string The command to create. |
$btn_topic | string The topic to get the button text. |
$loading_topic | string The topic to get the loading text. |
$a_display_status | array An array containing the statuses when the command should be visible. |
Definition at line 269 of file class.ilPreviewGUI.php.
References buildUrl(), and getHtmlId().
Referenced by getInlineHTML().
272 $preview_status = $this->preview->getRenderStatus();
273 $loading_text = self::jsonSafeString($this->lng->txt($loading_topic));
275 $link = $this->
buildUrl($a_cmd .
"Preview");
276 $script_args =
"event, { id: '{$this->node_id}', htmlId: '$preview_html_id', url: '$link', loadingText: '$loading_text' }";
279 if (!is_array($a_display_status) || !in_array($preview_status, $a_display_status))
280 $action_class =
"ilPreviewActionHidden";
282 $tmpl->setCurrentBlock(
"preview_action");
283 $tmpl->setVariable(
"CLICK_ACTION",
"il.Preview.$a_cmd($script_args);");
284 $tmpl->setVariable(
"ACTION_CLASS",
"$action_class");
285 $tmpl->setVariable(
"ACTION_ID",
"preview_{$a_cmd}_" . $preview_html_id);
286 $tmpl->setVariable(
"TXT_ACTION", $this->lng->txt($btn_topic));
287 $tmpl->parseCurrentBlock();
buildUrl($a_cmd="", $a_async=true)
Builds the URL to call the preview GUI.
getHtmlId()
Gets the HTML id for the preview.
◆ renderPreview()
ilPreviewGUI::renderPreview |
( |
| ) |
|
Renders the preview and returns the HTML code that displays the preview.
- Returns
- string The HTML code that displays the preview.
Definition at line 294 of file class.ilPreviewGUI.php.
References ilObjectFactory\getInstanceByObjId(), and getPreviewHTML().
297 if ($this->access_handler->checkAccess(
"read",
"", $this->node_id))
301 $this->preview->create($obj);
getPreviewHTML()
Gets the HTML that displays the preview.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
◆ $access_handler
ilPreviewGUI::$access_handler = null |
|
private |
◆ $context
ilPreviewGUI::$context = null |
|
private |
◆ $ctrl
ilPreviewGUI::$ctrl = null |
|
private |
◆ $initialized
ilPreviewGUI::$initialized = false |
|
staticprivate |
◆ $lng
ilPreviewGUI::$lng = null |
|
private |
◆ $node_id
ilPreviewGUI::$node_id = null |
|
private |
◆ $obj_id
ilPreviewGUI::$obj_id = null |
|
private |
◆ $preview
ilPreviewGUI::$preview = null |
|
private |
◆ CONTEXT_REPOSITORY
const ilPreviewGUI::CONTEXT_REPOSITORY = 1 |
◆ CONTEXT_WORKSPACE
const ilPreviewGUI::CONTEXT_WORKSPACE = 2 |
The documentation for this class was generated from the following file: