ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
24 protected $tabs;
25
29 protected $toolbar;
30
31 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id = 0, $a_pc_id = "")
32 {
33 global $DIC;
34
35 $this->tpl = $DIC["tpl"];
36 $this->lng = $DIC->language();
37 $this->tabs = $DIC->tabs();
38 $this->ctrl = $DIC->ctrl();
39 $this->toolbar = $DIC->toolbar();
40 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
41 }
42
46 public function executeCommand()
47 {
50 $ilTabs = $this->tabs;
51
52
53 // $this->getCharacteristicsOfCurrentStyle("media_cont"); // scorm-2004
54
55 // get next class that processes or forwards current command
56 $next_class = $this->ctrl->getNextClass($this);
57
58 // get current command
59 $cmd = $this->ctrl->getCmd();
60
61 if (is_object($this->content_obj)) {
62 $tpl->setTitleIcon(ilUtil::getImagePath("icon_mob.svg"));
63 $this->getTabs($this->tabs_gui);
64
65 /* $mob = $this->content_obj->getMediaObject();
66 if (is_object($mob))
67 {
68 $tpl->setVariable("HEADER", $lng->txt("mob").": ".
69 $this->content_obj->getMediaObject()->getTitle());
70 $mob_gui = new ilObjMediaObjectGUI("", $this->content_obj->getMediaObject()->getId(),false, false);
71 $mob_gui->setBackTitle($this->page_back_title);
72 $mob_gui->setEnabledMapAreas($this->getEnabledMapAreas());
73 $mob_gui->getTabs($this->tabs_gui);
74 }*/
75 } else {
76 }
77
78 switch ($next_class) {
79 // trigger editor
80 case "ilpciimtriggereditorgui":
81 require_once("./Services/COPage/classes/class.ilPCIIMTriggerEditorGUI.php");
82 $ilTabs->setTabActive("triggers");
83 $image_map_edit = new ilPCIIMTriggerEditorGUI(
84 $this->content_obj,
85 $this->pg_obj
86 );
87 $ret = $this->ctrl->forwardCommand($image_map_edit);
88 $tpl->setContent($ret);
89 break;
90
91 default:
92 $ret = $this->$cmd();
93 break;
94 }
95
96 return $ret;
97 }
98
105 public function getTabs(&$tab_gui, $a_create = false, $a_change_obj_ref = false)
106 {
108 $ilTabs = $this->tabs;
110
111 if (!$a_create) {
112 $ilTabs->setBackTarget(
113 $lng->txt("pg"),
114 $ilCtrl->getParentReturn($this)
115 );
116
117 $ilTabs->addTab(
118 "triggers",
119 $lng->txt("cont_active_areas"),
120 $ilCtrl->getLinkTargetByClass("ilpciimtriggereditorgui", "editMapAreas")
121 );
122
123 $ilTabs->addTab(
124 "list_overlays",
125 $lng->txt("cont_overlay_images"),
126 $ilCtrl->getLinkTarget($this, "listOverlayImages")
127 );
128
129 $ilTabs->addTab(
130 "content_popups",
131 $lng->txt("cont_content_popups"),
132 $ilCtrl->getLinkTarget($this, "listContentPopups")
133 );
134
135 $ilTabs->addTab(
136 "edit_base_image",
137 $lng->txt("cont_base_image") . " & " . $lng->txt("cont_caption"),
138 $ilCtrl->getLinkTarget($this, "editBaseImage")
139 );
140 }
141 }
142
146 public function insert($a_post_cmd = "edpost", $a_submit_cmd = "create_mob", $a_input_error = false)
147 {
148 $ilTabs = $this->tabs;
152
153 ilUtil::sendInfo($lng->txt("cont_iim_create_info"));
154
155 // $this->getTabs($ilTabs, true);
156 // $ilTabs->setSubTabActive("cont_new_mob");
157
158 if ($a_input_error) {
160 } else {
161 $form = $this->initForm("create");
162 }
163 $form->setFormAction($ilCtrl->getFormAction($this));
164
165 $this->displayValidationError();
166
167 $tpl->setContent($form->getHTML());
168 }
169
173 public function edit()
174 {
177
178 $ilCtrl->redirectByClass(array("ilpcinteractiveimagegui", "ilpciimtriggereditorgui"), "editMapAreas");
179 //$tpl->setContent("hh");
180 }
181
188 public function editBaseImage($a_form = null)
189 {
191 $ilTabs = $this->tabs;
193
194 $ilTabs->activateTab("edit_base_image");
195
196 $form = $this->initForm();
197 $tpl->setContent($form->getHTML());
198 }
199
200
206 public function initForm($a_mode = "edit")
207 {
210
211 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
212 $form = new ilPropertyFormGUI();
213
214 // image file
215 $fi = new ilImageFileInputGUI($lng->txt("cont_file"), "image_file");
216 $fi->setAllowDeletion(false);
217 if ($a_mode == "edit") {
218 $fi->setImage($this->content_obj->getBaseThumbnailTarget());
219 }
220 $form->addItem($fi);
221
222 if ($a_mode == "edit") {
223 // caption
224 $ti = new ilTextInputGUI($this->lng->txt("cont_caption"), "caption");
225 $ti->setMaxLength(200);
226 $ti->setSize(50);
227 $form->addItem($ti);
228 }
229
230 // save and cancel commands
231 if ($a_mode == "create") {
232 $form->setTitle($lng->txt("cont_ed_insert_iim"));
233 $form->addCommandButton("create_iim", $lng->txt("save"));
234 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
235 } else {
236 // get caption
237 $std_alias_item = new ilMediaAliasItem(
238 $this->dom,
239 $this->getHierId(),
240 "Standard",
241 $this->content_obj->getPcId(),
242 "InteractiveImage"
243 );
244 $ti->setValue($std_alias_item->getCaption());
245
246 $form->setTitle($lng->txt("cont_edit_base_image"));
247 $form->addCommandButton("update", $lng->txt("save"));
248 }
249
250 $form->setFormAction($ilCtrl->getFormAction($this));
251
252 return $form;
253 }
254
258 public function create()
259 {
262
263 $this->content_obj = new ilPCInteractiveImage($this->getPage());
264 $this->content_obj->createMediaObject();
265 $media_obj = $this->content_obj->getMediaObject();
266 $media_obj->setTitle($_FILES['image_file']['name']);
267 $media_obj->create();
268 $mob_dir = ilObjMediaObject::_getDirectory($media_obj->getId());
269 // $media_obj->setStandardType("File");
270 $media_obj->createDirectory();
271 $media_item = new ilMediaItem();
272 $media_obj->addMediaItem($media_item);
273 $media_item->setPurpose("Standard");
274
275 $file = $mob_dir . "/" . $_FILES['image_file']['name'];
276 ilUtil::moveUploadedFile(
277 $_FILES['image_file']['tmp_name'],
278 $_FILES['image_file']['name'],
279 $file
280 );
281
282 // get mime type
284 $location = $_FILES['image_file']['name'];
285
286 // set real meta and object data
287 $media_item->setFormat($format);
288 $media_item->setLocation($location);
289 $media_item->setLocationType("LocalFile");
290
292 $media_obj->update();
293
294 $this->content_obj->createAlias($this->pg_obj, $this->hier_id, $this->pc_id);
295 $this->updated = $this->pg_obj->update();
296 if ($this->updated === true) {
297 $this->pg_obj->stripHierIDs();
298 $this->pg_obj->addHierIDs();
299 $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
300 $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
301 $this->content_obj->setHierId($this->content_obj->readHierId());
302 $this->setHierId($this->content_obj->readHierId());
303 $this->content_obj->setPCId($this->content_obj->readPCId());
304 ilUtil::sendSuccess($lng->txt("cont_saved_interactive_image"), true);
305 $this->ctrl->redirectByClass("ilpcinteractiveimagegui", "edit");
306
307 //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
308 } else {
309 $this->insert();
310 }
311 }
312
316 public function update()
317 {
320
321 $mob = $this->content_obj->getMediaObject();
322 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
323 $std_item = $mob->getMediaItem("Standard");
324 $location = $_FILES['image_file']['name'];
325
326 if ($location != "" && is_file($_FILES['image_file']['tmp_name'])) {
327 $file = $mob_dir . "/" . $_FILES['image_file']['name'];
328 ilUtil::moveUploadedFile(
329 $_FILES['image_file']['tmp_name'],
330 $_FILES['image_file']['name'],
331 $file
332 );
333
334 // get mime type
336 $location = $_FILES['image_file']['name'];
337 $std_item->setFormat($format);
338 $std_item->setLocation($location);
339 $std_item->setLocationType("LocalFile");
340 $mob->setDescription($format);
341 $mob->update();
342 }
343
344 // set caption
345 $std_alias_item = new ilMediaAliasItem(
346 $this->dom,
347 $this->getHierId(),
348 "Standard",
349 $this->content_obj->getPcId(),
350 "InteractiveImage"
351 );
352 $std_alias_item->setCaption(ilUtil::stripSlashes($_POST["caption"]));
353 $_SESSION["il_pg_error"] = $this->pg_obj->update();
354 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
355
356 $ilCtrl->redirectByClass("ilpcinteractiveimagegui", "editBaseImage");
357 }
358
359
363 public function centerAlign()
364 {
365 $std_alias_item = new ilMediaAliasItem(
366 $this->dom,
367 $this->getHierId(),
368 "Standard",
369 $this->content_obj->getPcId(),
370 "InteractiveImage"
371 );
372 $std_alias_item->setHorizontalAlign("Center");
373 $_SESSION["il_pg_error"] = $this->pg_obj->update();
374 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
375 }
376
380 public function leftAlign()
381 {
382 $std_alias_item = new ilMediaAliasItem(
383 $this->dom,
384 $this->getHierId(),
385 "Standard",
386 $this->content_obj->getPcId(),
387 "InteractiveImage"
388 );
389 $std_alias_item->setHorizontalAlign("Left");
390 $_SESSION["il_pg_error"] = $this->pg_obj->update();
391 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
392 }
393
397 public function rightAlign()
398 {
399 $std_alias_item = new ilMediaAliasItem(
400 $this->dom,
401 $this->getHierId(),
402 "Standard",
403 $this->content_obj->getPcId(),
404 "InteractiveImage"
405 );
406 $std_alias_item->setHorizontalAlign("Right");
407 $_SESSION["il_pg_error"] = $this->pg_obj->update();
408 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
409 }
410
414 public function leftFloatAlign()
415 {
416 $std_alias_item = new ilMediaAliasItem(
417 $this->dom,
418 $this->getHierId(),
419 "Standard",
420 $this->content_obj->getPcId(),
421 "InteractiveImage"
422 );
423 $std_alias_item->setHorizontalAlign("LeftFloat");
424 $_SESSION["il_pg_error"] = $this->pg_obj->update();
425 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
426 }
427
431 public function rightFloatAlign()
432 {
433 $std_alias_item = new ilMediaAliasItem(
434 $this->dom,
435 $this->getHierId(),
436 "Standard",
437 $this->content_obj->getPcId(),
438 "InteractiveImage"
439 );
440 $std_alias_item->setHorizontalAlign("RightFloat");
441 $_SESSION["il_pg_error"] = $this->pg_obj->update();
442 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
443 }
444
448
455 public function listOverlayImages()
456 {
458 $ilToolbar = $this->toolbar;
460 $ilTabs = $this->tabs;
462
463 ilUtil::sendInfo($lng->txt("cont_iim_overlay_info"));
464
465 $ilTabs->setTabActive("list_overlays");
466
467 $ilToolbar->addButton(
468 $lng->txt("cont_add_images"),
469 $ilCtrl->getLinkTarget($this, "addOverlayImages")
470 );
471
472 include_once("./Services/COPage/classes/class.ilPCIIMOverlaysTableGUI.php");
474 $this,
475 "listOverlayImages",
476 $this->content_obj->getMediaObject()
477 );
478 $tpl->setContent($tab->getHTML());
479 }
480
484 public function addOverlayImages($a_form = null)
485 {
487
488 if ($a_form) {
489 $form = $a_form;
490 } else {
491 $form = $this->initAddOverlaysForm();
492 }
493
494 $tpl->setContent($form->getHTML());
495 }
496
503 public function initAddOverlaysForm()
504 {
507 $ilTabs = $this->tabs;
508
509 $ilTabs->setTabActive("list_overlays");
510
511 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
512 $form = new ilPropertyFormGUI();
513 $form->setTitle($lng->txt("cont_add_images"));
514 $form->setFormAction($ilCtrl->getFormAction($this));
515
516 // file input
517 include_once("./Services/Form/classes/class.ilFileWizardInputGUI.php");
518 $fi = new ilFileWizardInputGUI($lng->txt("file"), "ovfile");
519 $fi->setSuffixes(array("gif", "jpeg", "jpg", "png"));
520 $fi->setFilenames(array(0 => ''));
521 $fi->setRequired(true);
522 $form->addItem($fi);
523
524 $form->addCommandButton("uploadOverlayImages", $lng->txt("upload"));
525 $form->addCommandButton("listOverlayImages", $lng->txt("cancel"));
526
527 return $form;
528 }
529
530
537 public function uploadOverlayImages()
538 {
541
542 $form = $this->initAddOverlaysForm();
543 if ($form->checkInput()) {
544 if (is_array($_FILES["ovfile"]["name"])) {
545 foreach ($_FILES["ovfile"]["name"] as $k => $v) {
546 $name = $_FILES["ovfile"]["name"][$k];
547 $mime = $_FILES["ovfile"]["type"][$k];
548 $tmp_name = $_FILES["ovfile"]["tmp_name"][$k];
549 $size = $_FILES["ovfile"]["size"][$k];
550
551 $this->content_obj->getMediaObject()->uploadAdditionalFile(
552 $name,
553 $tmp_name,
554 "overlays"
555 );
556 $piname = pathinfo($name);
557 $this->content_obj->getMediaObject()->makeThumbnail(
558 "overlays/" . $name,
559 basename($name, "." . $piname['extension']) . ".png"
560 );
561 }
562 }
563 ilUtil::sendSuccess($lng->txt("msg_obj_modified"));
564 $ilCtrl->redirect($this, "listOverlayImages");
565 } else {
566 $form->setValuesByPost();
567 $this->addOverlayImages($form);
568 }
569 }
570
574 public function confirmDeleteOverlays()
575 {
579 $ilTabs = $this->tabs;
580
581 $ilTabs->setTabActive("list_overlays");
582
583 if (!is_array($_POST["file"]) || count($_POST["file"]) == 0) {
584 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
585 $ilCtrl->redirect($this, "listOverlayImages");
586 } else {
587 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
588 $cgui = new ilConfirmationGUI();
589 $cgui->setFormAction($ilCtrl->getFormAction($this));
590 $cgui->setHeaderText($lng->txt("cont_really_delete_overlays"));
591 $cgui->setCancel($lng->txt("cancel"), "listOverlayImages");
592 $cgui->setConfirm($lng->txt("delete"), "deleteOverlays");
593
594 foreach ($_POST["file"] as $i => $d) {
595 $cgui->addItem("file[]", $i, $i);
596 }
597
598 $tpl->setContent($cgui->getHTML());
599 }
600 }
601
605 public function deleteOverlays()
606 {
609
610 if (is_array($_POST["file"]) && count($_POST["file"]) != 0) {
611 foreach ($_POST["file"] as $f) {
612 $f = str_replace("..", "", ilUtil::stripSlashes($f));
613 $this->content_obj->getMediaObject()
614 ->removeAdditionalFile("overlays/" . $f);
615 }
616
617 ilUtil::sendSuccess($lng->txt("cont_overlays_have_been_deleted"), true);
618 }
619 $ilCtrl->redirect($this, "listOverlayImages");
620 }
621
622
626
630 public function listContentPopups()
631 {
633 $ilToolbar = $this->toolbar;
635 $ilTabs = $this->tabs;
637
638 ilUtil::sendInfo($lng->txt("cont_iim_content_popups_info"));
639
640 $ilTabs->setTabActive("content_popups");
641
642 $ilToolbar->addButton(
643 $lng->txt("cont_add_popup"),
644 $ilCtrl->getLinkTarget($this, "addPopup")
645 );
646
647 include_once("./Services/COPage/classes/class.ilPCIIMPopupTableGUI.php");
649 $this,
650 "listContentPopups",
651 $this->content_obj
652 );
653 $tpl->setContent($tab->getHTML());
654 }
655
662 public function addPopup()
663 {
666
667 $this->content_obj->addContentPopup();
668 $this->pg_obj->update();
669 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
670 $ilCtrl->redirect($this, "listContentPopups");
671 }
672
676 public function savePopups()
677 {
680
681 if (is_array($_POST["title"])) {
682 $titles = ilUtil::stripSlashesArray($_POST["title"]);
683 $this->content_obj->savePopUps($titles);
684 $this->pg_obj->update();
685 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
686 }
687 $ilCtrl->redirect($this, "listContentPopups");
688 }
689
693 public function confirmPopupDeletion()
694 {
698 $ilTabs = $this->tabs;
699
700 $ilTabs->setTabActive("content_popups");
701
702 if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0) {
703 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
704 $ilCtrl->redirect($this, "listContentPopups");
705 } else {
706 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
707 $cgui = new ilConfirmationGUI();
708 $cgui->setFormAction($ilCtrl->getFormAction($this));
709 $cgui->setHeaderText($lng->txt("cont_really_delete_popups"));
710 $cgui->setCancel($lng->txt("cancel"), "listContentPopups");
711 $cgui->setConfirm($lng->txt("delete"), "deletePopups");
712
713 foreach ($_POST["tid"] as $i => $d) {
714 $cgui->addItem("tid[]", $i, $_POST["title"][$i]);
715 }
716
717 $tpl->setContent($cgui->getHTML());
718 }
719 }
720
727 public function deletePopups()
728 {
731
732 if (is_array($_POST["tid"]) && count($_POST["tid"]) != 0) {
733 foreach ($_POST["tid"] as $id) {
734 $id = explode(":", $id);
735 $this->content_obj->deletePopup($id[0], $id[1]);
736 }
737 $this->pg_obj->update();
738 ilUtil::sendSuccess($lng->txt("cont_popups_have_been_deleted"), true);
739 }
740 $ilCtrl->redirect($this, "listContentPopups");
741 }
742}
$size
Definition: RandomTest.php:84
$location
Definition: buildRTE.php:44
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
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.
static getMimeType($a_file, $a_external=null)
get mime type for file
static _getDirectory($a_mob_id)
get directory for files of media object (static)
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="")
Constructor @access public.
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 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.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$i
Definition: disco.tpl.php:19
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
$format
Definition: metadata.php:141
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7