ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPCInteractiveImageGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once ("./Services/COPage/classes/class.ilPageContentGUI.php");
6require_once ("./Services/COPage/classes/class.ilPCInteractiveImage.php");
7include_once("./Services/COPage/classes/class.ilMediaAliasItem.php");
8
20{
21 function __construct($a_pg_obj, $a_content_obj, $a_hier_id = 0, $a_pc_id = "")
22 {
23 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
24 }
25
29 function &executeCommand()
30 {
31 global $tpl, $lng, $ilTabs;
32
33
34// $this->getCharacteristicsOfCurrentStyle("media_cont"); // scorm-2004
35
36 // get next class that processes or forwards current command
37 $next_class = $this->ctrl->getNextClass($this);
38
39 // get current command
40 $cmd = $this->ctrl->getCmd();
41
42 if (is_object ($this->content_obj))
43 {
44 $tpl->setTitleIcon(ilUtil::getImagePath("icon_mob.svg"));
45 $this->getTabs($this->tabs_gui);
46
47/* $mob = $this->content_obj->getMediaObject();
48 if (is_object($mob))
49 {
50 $tpl->setVariable("HEADER", $lng->txt("mob").": ".
51 $this->content_obj->getMediaObject()->getTitle());
52 $mob_gui =& new ilObjMediaObjectGUI("", $this->content_obj->getMediaObject()->getId(),false, false);
53 $mob_gui->setBackTitle($this->page_back_title);
54 $mob_gui->setEnabledMapAreas($this->getEnabledMapAreas());
55 $mob_gui->getTabs($this->tabs_gui);
56 }*/
57 }
58 else
59 {
60 }
61
62 switch($next_class)
63 {
64 // trigger editor
65 case "ilpciimtriggereditorgui":
66 require_once("./Services/COPage/classes/class.ilPCIIMTriggerEditorGUI.php");
67 $ilTabs->setTabActive("triggers");
68 $image_map_edit = new ilPCIIMTriggerEditorGUI($this->content_obj,
69 $this->pg_obj);
70 $ret = $this->ctrl->forwardCommand($image_map_edit);
71 $tpl->setContent($ret);
72 break;
73
74 default:
75 $ret =& $this->$cmd();
76 break;
77 }
78
79 return $ret;
80 }
81
88 function getTabs(&$tab_gui, $a_create = false, $a_change_obj_ref = false)
89 {
90 global $ilCtrl, $ilTabs, $lng;
91
92 if (!$a_create)
93 {
94
95 $ilTabs->setBackTarget($lng->txt("pg"),
96 $ilCtrl->getParentReturn($this)
97 );
98
99 $ilTabs->addTab("triggers",
100 $lng->txt("cont_active_areas"),
101 $ilCtrl->getLinkTargetByClass("ilpciimtriggereditorgui", "editMapAreas")
102 );
103
104 $ilTabs->addTab("list_overlays",
105 $lng->txt("cont_overlay_images"),
106 $ilCtrl->getLinkTarget($this, "listOverlayImages")
107 );
108
109 $ilTabs->addTab("content_popups",
110 $lng->txt("cont_content_popups"),
111 $ilCtrl->getLinkTarget($this, "listContentPopups")
112 );
113
114 $ilTabs->addTab("edit_base_image",
115 $lng->txt("cont_base_image")." & ".$lng->txt("cont_caption"),
116 $ilCtrl->getLinkTarget($this, "editBaseImage")
117 );
118
119 }
120 }
121
125 function insert($a_post_cmd = "edpost", $a_submit_cmd = "create_mob", $a_input_error = false)
126 {
127 global $ilTabs, $tpl, $ilCtrl, $lng;
128
129 ilUtil::sendInfo($lng->txt("cont_iim_create_info"));
130
131// $this->getTabs($ilTabs, true);
132// $ilTabs->setSubTabActive("cont_new_mob");
133
134 if ($a_input_error)
135 {
136 $form = $this->form;
137 }
138 else
139 {
140 $form = $this->initForm("create");
141 }
142 $form->setFormAction($ilCtrl->getFormAction($this));
143
144 $this->displayValidationError();
145
146 $tpl->setContent($form->getHTML());
147 }
148
152 function edit()
153 {
154 global $tpl, $ilCtrl;
155
156 $ilCtrl->redirectByClass(array("ilpcinteractiveimagegui", "ilpciimtriggereditorgui"), "editMapAreas");
157 //$tpl->setContent("hh");
158 }
159
166 function editBaseImage($a_form = null)
167 {
168 global $tpl, $ilTabs, $lng;
169
170 $ilTabs->activateTab("edit_base_image");
171
172 $form = $this->initForm();
173 $tpl->setContent($form->getHTML());
174 }
175
176
182 public function initForm($a_mode = "edit")
183 {
184 global $lng, $ilCtrl;
185
186 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
187 $form = new ilPropertyFormGUI();
188
189 // image file
190 $fi = new ilImageFileInputGUI($lng->txt("cont_file"), "image_file");
191 $fi->setAllowDeletion(false);
192 if ($a_mode == "edit")
193 {
194 $fi->setImage($this->content_obj->getBaseThumbnailTarget());
195 }
196 $form->addItem($fi);
197
198 if ($a_mode == "edit")
199 {
200 // caption
201 $ti = new ilTextInputGUI($this->lng->txt("cont_caption"), "caption");
202 $ti->setMaxLength(200);
203 $ti->setSize(50);
204 $form->addItem($ti);
205 }
206
207 // save and cancel commands
208 if ($a_mode == "create")
209 {
210 $form->setTitle($lng->txt("cont_ed_insert_iim"));
211 $form->addCommandButton("create_iim", $lng->txt("save"));
212 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
213 }
214 else
215 {
216 // get caption
217 $std_alias_item = new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
218 $this->content_obj->getPcId(), "InteractiveImage");
219 $ti->setValue($std_alias_item->getCaption());
220
221 $form->setTitle($lng->txt("cont_edit_base_image"));
222 $form->addCommandButton("update", $lng->txt("save"));
223 }
224
225 $form->setFormAction($ilCtrl->getFormAction($this));
226
227 return $form;
228 }
229
233 function create()
234 {
235 global $ilCtrl, $lng;
236
237 $this->content_obj = new ilPCInteractiveImage($this->getPage());
238 $this->content_obj->createMediaObject();
239 $media_obj = $this->content_obj->getMediaObject();
240 $media_obj->setTitle($_FILES['image_file']['name']);
241 $media_obj->create();
242 $mob_dir = ilObjMediaObject::_getDirectory($media_obj->getId());
243// $media_obj->setStandardType("File");
244 $media_obj->createDirectory();
245 $media_item = new ilMediaItem();
246 $media_obj->addMediaItem($media_item);
247 $media_item->setPurpose("Standard");
248
249 $file = $mob_dir."/".$_FILES['image_file']['name'];
250 ilUtil::moveUploadedFile($_FILES['image_file']['tmp_name'],
251 $_FILES['image_file']['name'], $file);
252
253 // get mime type
255 $location = $_FILES['image_file']['name'];
256
257 // set real meta and object data
258 $media_item->setFormat($format);
259 $media_item->setLocation($location);
260 $media_item->setLocationType("LocalFile");
261
263 $media_obj->update();
264
265 $this->content_obj->createAlias($this->pg_obj, $this->hier_id, $this->pc_id);
266 $this->updated = $this->pg_obj->update();
267 if ($this->updated === true)
268 {
269 $this->pg_obj->stripHierIDs();
270 $this->pg_obj->addHierIDs();
271 $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
272 $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
273 $this->content_obj->setHierId($this->content_obj->readHierId());
274 $this->setHierId($this->content_obj->readHierId());
275 $this->content_obj->setPCId($this->content_obj->readPCId());
276 ilUtil::sendSuccess($lng->txt("cont_saved_interactive_image"), true);
277 $this->ctrl->redirectByClass("ilpcinteractiveimagegui", "edit");
278
279 //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
280 }
281 else
282 {
283 $this->insert();
284 }
285 }
286
290 function update()
291 {
292 global $ilCtrl, $lng;
293
294 $mob = $this->content_obj->getMediaObject();
295 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
296 $std_item = $mob->getMediaItem("Standard");
297 $location = $_FILES['image_file']['name'];
298
299 if ($location != "" && is_file($_FILES['image_file']['tmp_name']))
300 {
301 $file = $mob_dir."/".$_FILES['image_file']['name'];
302 ilUtil::moveUploadedFile($_FILES['image_file']['tmp_name'],
303 $_FILES['image_file']['name'], $file);
304
305 // get mime type
307 $location = $_FILES['image_file']['name'];
308 $std_item->setFormat($format);
309 $std_item->setLocation($location);
310 $std_item->setLocationType("LocalFile");
311 $mob->setDescription($format);
312 $mob->update();
313 }
314
315 // set caption
316 $std_alias_item = new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
317 $this->content_obj->getPcId(), "InteractiveImage");
318 $std_alias_item->setCaption(ilUtil::stripSlashes($_POST["caption"]));
319 $_SESSION["il_pg_error"] = $this->pg_obj->update();
320 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
321
322 $ilCtrl->redirectByClass("ilpcinteractiveimagegui", "editBaseImage");
323 }
324
325
329 function centerAlign()
330 {
331 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
332 $this->content_obj->getPcId(), "InteractiveImage");
333 $std_alias_item->setHorizontalAlign("Center");
334 $_SESSION["il_pg_error"] = $this->pg_obj->update();
335 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
336 }
337
341 function leftAlign()
342 {
343 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
344 $this->content_obj->getPcId(), "InteractiveImage");
345 $std_alias_item->setHorizontalAlign("Left");
346 $_SESSION["il_pg_error"] = $this->pg_obj->update();
347 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
348 }
349
353 function rightAlign()
354 {
355 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
356 $this->content_obj->getPcId(), "InteractiveImage");
357 $std_alias_item->setHorizontalAlign("Right");
358 $_SESSION["il_pg_error"] = $this->pg_obj->update();
359 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
360 }
361
365 function leftFloatAlign()
366 {
367 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
368 $this->content_obj->getPcId(), "InteractiveImage");
369 $std_alias_item->setHorizontalAlign("LeftFloat");
370 $_SESSION["il_pg_error"] = $this->pg_obj->update();
371 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
372 }
373
378 {
379 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
380 $this->content_obj->getPcId(), "InteractiveImage");
381 $std_alias_item->setHorizontalAlign("RightFloat");
382 $_SESSION["il_pg_error"] = $this->pg_obj->update();
383 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
384 }
385
389
397 {
398 global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
399
400 ilUtil::sendInfo($lng->txt("cont_iim_overlay_info"));
401
402 $ilTabs->setTabActive("list_overlays");
403
404 $ilToolbar->addButton($lng->txt("cont_add_images"),
405 $ilCtrl->getLinkTarget($this, "addOverlayImages"));
406
407 include_once("./Services/COPage/classes/class.ilPCIIMOverlaysTableGUI.php");
408 $tab = new ilPCIIMOverlaysTableGUI($this, "listOverlayImages",
409 $this->content_obj->getMediaObject());
410 $tpl->setContent($tab->getHTML());
411 }
412
416 function addOverlayImages($a_form = null)
417 {
418 global $tpl;
419
420 if ($a_form)
421 {
422 $form = $a_form;
423 }
424 else
425 {
426 $form = $this->initAddOverlaysForm();
427 }
428
429 $tpl->setContent($form->getHTML());
430 }
431
439 {
440 global $lng, $ilCtrl, $ilTabs;
441
442 $ilTabs->setTabActive("list_overlays");
443
444 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
445 $form = new ilPropertyFormGUI();
446 $form->setTitle($lng->txt("cont_add_images"));
447 $form->setFormAction($ilCtrl->getFormAction($this));
448
449 // file input
450 include_once("./Services/Form/classes/class.ilFileWizardInputGUI.php");
451 $fi = new ilFileWizardInputGUI($lng->txt("file"), "ovfile");
452 $fi->setSuffixes(array("gif", "jpeg", "jpg", "png"));
453 $fi->setFilenames(array(0 => ''));
454 $fi->setRequired(true);
455 $form->addItem($fi);
456
457 $form->addCommandButton("uploadOverlayImages", $lng->txt("upload"));
458 $form->addCommandButton("listOverlayImages", $lng->txt("cancel"));
459
460 return $form;
461 }
462
463
471 {
472 global $lng, $ilCtrl;
473
474 $form = $this->initAddOverlaysForm();
475 if ($form->checkInput())
476 {
477 if (is_array($_FILES["ovfile"]["name"]))
478 {
479 foreach ($_FILES["ovfile"]["name"] as $k => $v)
480 {
481 $name = $_FILES["ovfile"]["name"][$k];
482 $mime = $_FILES["ovfile"]["type"][$k];
483 $tmp_name = $_FILES["ovfile"]["tmp_name"][$k];
484 $size = $_FILES["ovfile"]["size"][$k];
485
486 $this->content_obj->getMediaObject()->uploadAdditionalFile($name,
487 $tmp_name, "overlays");
488 $piname = pathinfo($name);
489 $this->content_obj->getMediaObject()->makeThumbnail("overlays/".$name,
490 basename($name, ".".$piname['extension']).".png");
491 }
492 }
493 ilUtil::sendSuccess($lng->txt("msg_obj_modified"));
494 $ilCtrl->redirect($this, "listOverlayImages");
495 }
496 else
497 {
498 $form->setValuesByPost();
499 $this->addOverlayImages($form);
500 }
501 }
502
507 {
508 global $ilCtrl, $tpl, $lng, $ilTabs;
509
510 $ilTabs->setTabActive("list_overlays");
511
512 if (!is_array($_POST["file"]) || count($_POST["file"]) == 0)
513 {
514 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
515 $ilCtrl->redirect($this, "listOverlayImages");
516 }
517 else
518 {
519 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
520 $cgui = new ilConfirmationGUI();
521 $cgui->setFormAction($ilCtrl->getFormAction($this));
522 $cgui->setHeaderText($lng->txt("cont_really_delete_overlays"));
523 $cgui->setCancel($lng->txt("cancel"), "listOverlayImages");
524 $cgui->setConfirm($lng->txt("delete"), "deleteOverlays");
525
526 foreach ($_POST["file"] as $i => $d)
527 {
528 $cgui->addItem("file[]", $i, $i);
529 }
530
531 $tpl->setContent($cgui->getHTML());
532 }
533 }
534
538 function deleteOverlays()
539 {
540 global $ilCtrl, $lng;
541
542 if (is_array($_POST["file"]) && count($_POST["file"]) != 0)
543 {
544 foreach ($_POST["file"] as $f)
545 {
546 $f = str_replace("..", "", ilUtil::stripSlashes($f));
547 $this->content_obj->getMediaObject()
548 ->removeAdditionalFile("overlays/".$f);
549 }
550
551 ilUtil::sendSuccess($lng->txt("cont_overlays_have_been_deleted"), true);
552 }
553 $ilCtrl->redirect($this, "listOverlayImages");
554 }
555
556
560
565 {
566 global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
567
568 ilUtil::sendInfo($lng->txt("cont_iim_content_popups_info"));
569
570 $ilTabs->setTabActive("content_popups");
571
572 $ilToolbar->addButton($lng->txt("cont_add_popup"),
573 $ilCtrl->getLinkTarget($this, "addPopup"));
574
575 include_once("./Services/COPage/classes/class.ilPCIIMPopupTableGUI.php");
576 $tab = new ilPCIIMPopupTableGUI($this, "listContentPopups",
577 $this->content_obj);
578 $tpl->setContent($tab->getHTML());
579 }
580
587 function addPopup()
588 {
589 global $ilCtrl, $lng;
590
591 $this->content_obj->addContentPopup();
592 $this->pg_obj->update();
593 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
594 $ilCtrl->redirect($this, "listContentPopups");
595 }
596
600 function savePopups()
601 {
602 global $ilCtrl, $lng;
603
604 if (is_array($_POST["title"]))
605 {
606 $titles = ilUtil::stripSlashesArray($_POST["title"]);
607 $this->content_obj->savePopUps($titles);
608 $this->pg_obj->update();
609 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
610 }
611 $ilCtrl->redirect($this, "listContentPopups");
612 }
613
618 {
619 global $ilCtrl, $tpl, $lng, $ilTabs;
620
621 $ilTabs->setTabActive("content_popups");
622
623 if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
624 {
625 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
626 $ilCtrl->redirect($this, "listContentPopups");
627 }
628 else
629 {
630 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
631 $cgui = new ilConfirmationGUI();
632 $cgui->setFormAction($ilCtrl->getFormAction($this));
633 $cgui->setHeaderText($lng->txt("cont_really_delete_popups"));
634 $cgui->setCancel($lng->txt("cancel"), "listContentPopups");
635 $cgui->setConfirm($lng->txt("delete"), "deletePopups");
636
637 foreach ($_POST["tid"] as $i => $d)
638 {
639 $cgui->addItem("tid[]", $i, $_POST["title"][$i]);
640 }
641
642 $tpl->setContent($cgui->getHTML());
643 }
644 }
645
652 function deletePopups()
653 {
654 global $lng, $ilCtrl;
655
656 if (is_array($_POST["tid"]) && count($_POST["tid"]) != 0)
657 {
658 foreach ($_POST["tid"] as $id)
659 {
660 $id = explode(":", $id);
661 $this->content_obj->deletePopup($id[0], $id[1]);
662 }
663 $this->pg_obj->update();
664 ilUtil::sendSuccess($lng->txt("cont_popups_have_been_deleted"), true);
665 }
666 $ilCtrl->redirect($this, "listContentPopups");
667 }
668
669}
670?>
print $file
$size
Definition: RandomTest.php:79
$location
Definition: buildRTE.php:44
$_SESSION["AccountId"]
Confirmation screen class.
This class represents a file wizard property in a property form.
This class represents an image file property in a property form.
Class ilMediaAliasItem.
Class ilMediaItem.
_getDirectory($a_mob_id)
get directory for files of media object (static)
static getMimeType($a_file, $a_external=false)
get mime type for file
TableGUI class for interactive image overlays.
TableGUI class for content popup.
User interface class for page content map editor.
User interface class for interactive images.
confirmPopupDeletion()
Confirm popup deletion.
editBaseImage($a_form=null)
Edit base image.
rightFloatAlign()
align media object to right, floating text
leftAlign()
align media object to left
__construct($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
initAddOverlaysForm()
Init add overlays form.
insert($a_post_cmd="edpost", $a_submit_cmd="create_mob", $a_input_error=false)
Insert new media object form.
leftFloatAlign()
align media object to left, floating text
uploadOverlayImages()
Upload overlay images.
create()
Create new content element.
initForm($a_mode="edit")
Init creation/base image form.
getTabs(&$tab_gui, $a_create=false, $a_change_obj_ref=false)
Add tabs to ilTabsGUI object.
centerAlign()
Align media object to center.
confirmDeleteOverlays()
Confirm overlay deletion.
addOverlayImages($a_form=null)
Add overlay images.
rightAlign()
align media object to right
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getHierId()
get hierarchical id in dom object
displayValidationError()
display validation errors
setHierId($a_hier_id)
get hierarchical id in dom object
This class represents a property form user interface.
This class represents a text property in a property form.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35