ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPageEditorGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
5 
28 {
32  protected $tabs_gui;
33 
37  protected $help;
38 
42  protected $user;
43 
47  protected $access;
48 
49  public $tpl;
50  public $lng;
51  public $ctrl;
53  public $page;
56  public $header;
57  public $tabs;
58  public $cont_obj;
61 
65  protected $log;
66 
73  public function __construct(&$a_page_object, &$a_page_object_gui)
74  {
75  global $DIC;
76 
77  $this->help = $DIC["ilHelp"];
78  $this->user = $DIC->user();
79  $this->access = $DIC->access();
80  $tpl = $DIC["tpl"];
81  $lng = $DIC->language();
82  $objDefinition = $DIC["objDefinition"];
83  $ilCtrl = $DIC->ctrl();
84  $ilTabs = $DIC->tabs();
85 
86  $this->log = ilLoggerFactory::getLogger('copg');
87 
88  // initiate variables
89  $this->ctrl = $ilCtrl;
90  $this->tpl = $tpl;
91  $this->lng = $lng;
92  $this->objDefinition = $objDefinition;
93  $this->tabs_gui = $ilTabs;
94  $this->page = $a_page_object;
95  $this->page_gui = $a_page_object_gui;
96 
97  $this->ctrl->saveParameter($this, array("hier_id", "pc_id"));
98  }
99 
100 
106  public function setHeader($a_header)
107  {
108  $this->header = $a_header;
109  }
110 
116  public function getHeader()
117  {
118  return $this->header;
119  }
120 
126  public function setLocator(&$a_locator)
127  {
128  $this->locator = $a_locator;
129  }
130 
134  public function returnToContext()
135  {
136  $this->ctrl->returnToParent($this);
137  }
138 
139  public function setIntLinkReturn($a_return)
140  {
141  $this->int_link_return = $a_return;
142  }
143 
144 
145  public function setPageBackTitle($a_title)
146  {
147  $this->page_back_title = $a_title;
148  }
149 
153  public function executeCommand()
154  {
156  $ilHelp = $this->help;
157 
158  $this->log->debug("ilPageEditorGUI: executeCommand begin");
159 
160  $cmd = $this->ctrl->getCmd("displayPage");
161  //echo "-$cmd-"; exit;
162  $cmdClass = strtolower($this->ctrl->getCmdClass());
163 
164  $hier_id = $_GET["hier_id"];
165  $pc_id = $_GET["pc_id"];
166  if (isset($_POST["new_hier_id"])) {
167  $hier_id = $_POST["new_hier_id"];
168  }
169  //echo "GEThier_id:".$_GET["hier_id"]."<br>";
170  //$this->ctrl->debug("hier_id:".$hier_id);
171 
172  $new_type = (isset($_GET["new_type"]))
173  ? $_GET["new_type"]
174  : $_POST["new_type"];
175 
176  //echo "-$cmd-";
177  //var_dump($_GET); var_dump($_POST); exit;
178  /*array
179  'target' =>
180  array
181  0 => string '' (length=0)
182  'commandpg' => string 'insertJS' (length=8)
183  'cmd' =>
184  array
185  'exec_pg:' => string 'Ok' (length=2)
186  'ajaxform_content' => string '<div class=\"ilc_text_block_Standard\">sdfsdfsd sd</div>' (length=56)
187  'ajaxform_char' => string '' (length=0)*/
188  /*array
189  'usedwsiwygeditor' => string '0' (length=1)
190  'par_characteristic' => string 'Standard' (length=8)
191  'par_content' => string 'adasdaasda a
192 
193  ' (length=14)
194  'par_language' => string 'en' (length=2)
195  'cmd' =>
196  array
197  'create_par' => string 'Save' (length=4)*/
198 
199  if (substr($cmd, 0, 5) == "exec_") {
200  //echo ":".key($_POST["cmd"]).":";
201  // check whether pc id is given
202  $pca = explode(":", key($_POST["cmd"]));
203  $pc_id = $pca[1];
204  //echo "<br />exec_pc_id:-$pc_id-";
205  $cmd = explode("_", $pca[0]);
206  unset($cmd[0]);
207  $hier_id = implode($cmd, "_");
208  $cmd = $_POST["command" . $hier_id];
209  }
210  //echo "<br>cmd:$cmd:";exit;
211  // strip "c" "r" of table ids from hierarchical id
212  $first_hier_character = substr($hier_id, 0, 1);
213  if ($first_hier_character == "c" ||
214  $first_hier_character == "r" ||
215  $first_hier_character == "g" ||
216  $first_hier_character == "i") {
217  $hier_id = substr($hier_id, 1);
218  }
219  $this->page->buildDom();
220  $this->page->addHierIDs();
221 
222 
223  // determine command and content object
224  if ($cmdClass != "ilfilesystemgui") {
225  $com = explode("_", $cmd);
226  $cmd = $com[0];
227  }
228 
229 
230  $next_class = $this->ctrl->getNextClass($this);
231  $this->log->debug("next class: " . $next_class);
232 
233  // special case: placeholders from preview mode come without hier_id
234  if ($next_class == "ilpcplaceholdergui" && $hier_id == "" && $_GET["pl_pc_id"] != "") {
235  $hid = $this->page->getHierIdsForPCIds(array($_GET["pl_pc_id"]));
236  $hier_id = $hid[$_GET["pl_pc_id"]];
237  }
238 
239  // determine content type
240  if ($com[0] == "insert" || $com[0] == "create") {
241  $cmd = $com[0];
242  $ctype = $com[1];
243  $add_type = $com[2];
244  if ($ctype == "mob") {
245  $ctype = "media";
246  }
247  } else {
248  // setting cmd and cmdclass for editing of linked media
249  if ($cmd == "editLinkedMedia") {
250  $this->ctrl->setCmd("edit");
251  $cmd = "edit";
252  $_GET["pgEdMediaMode"] = "editLinkedMedia";
253  $_GET["mob_id"] = $_POST["mob_id"];
254  }
255  if ($_GET["pgEdMediaMode"] == "editLinkedMedia") {
256  $this->ctrl->setParameter($this, "pgEdMediaMode", "editLinkedMedia");
257  $this->ctrl->setParameter($this, "mob_id", $_GET["mob_id"]);
258  if ($cmdClass != "ilinternallinkgui" && $cmdClass != "ilmdeditorgui"
259  && $cmdClass != "ilimagemapeditorgui" && $cmdClass != "ilfilesystemgui") {
260  $this->ctrl->setCmdClass("ilobjmediaobjectgui");
261  $cmdClass = "ilobjmediaobjectgui";
262  }
263  }
264  if (false) {
265  var_dump($_POST);
266  var_dump($_GET);
267  echo ";$cmd;" . $next_class . ";";
268  echo "-$pc_id-";
269  echo "-$cmd-" . $this->ctrl->getCmd() . "-";
270  exit;
271  }
272 
273  //var_dump($_POST);
274  // note: ilinternallinkgui for page: no cont_obj is received
275  // ilinternallinkgui for mob: cont_obj is received
276  if ($cmd != "insertFromClipboard" && $cmd != "pasteFromClipboard" &&
277  $cmd != "setMediaMode" && $cmd != "copyLinkedMediaToClipboard" &&
278  $cmd != "activatePage" && $cmd != "deactivatePage" &&
279  $cmd != "copyLinkedMediaToMediaPool" && $cmd != "showSnippetInfo" &&
280  $cmd != "deleteSelected" && $cmd != "paste" &&
281  $cmd != "cancelDeleteSelected" && $cmd != "confirmedDeleteSelected" &&
282  $cmd != "copySelected" && $cmd != "cutSelected" &&
283  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "" || $_POST["imagemap_x"] != "") &&
284  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "") &&
285  $cmd != "activateSelected" && $cmd != "assignCharacteristicForm" &&
286  $cmd != "assignCharacteristic" &&
287  $cmdClass != "ilrepositoryselector2inputgui" &&
288  $cmd != "cancelCreate" && $cmd != "popup" &&
289  $cmdClass != "ileditclipboardgui" && $cmd != "addChangeComment" &&
290  ($cmdClass != "ilinternallinkgui" || ($next_class == "ilpcmediaobjectgui"))) {
291  if ($_GET["pgEdMediaMode"] != "editLinkedMedia") {
292  //$this->ctrl->debug("gettingContentObject (no linked media)");
293  //echo $hier_id."-".$pc_id;
294  $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
295  if (!is_object($cont_obj)) {
296  $this->log->debug("ilPageEditorGUI: ...returnToParent (cmdClass: $cmdClass, nextClass: $next_class" .
297  ", hier_id: " . $hier_id . ", pc_id: " . $pc_id . ")");
298  $ilCtrl->returnToParent($this);
299  }
300  $ctype = $cont_obj->getType();
301  }
302  }
303  }
304 
305  //$this->ctrl->debug("+ctype:".$ctype."+");
306  // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
307  // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
308 
309  if ($ctype != "media" || !is_object($cont_obj)) {
310  if ($this->getHeader() != "") {
311  $this->tpl->setTitle($this->getHeader());
312  }
313  $this->displayLocator();
314  }
315 
316  $this->cont_obj = $cont_obj;
317 
318 
319  // special command / command class handling
320  $this->ctrl->setParameter($this, "hier_id", $hier_id);
321  $this->ctrl->setParameter($this, "pc_id", $pc_id);
322  $this->ctrl->setCmd($cmd);
323  //$next_class = $this->ctrl->getNextClass($this);
324  //$this->ctrl->debug("+next_class:".$next_class."+");
325  //echo("+next_class:".$next_class."+".$ctype."+"); exit;
326 
327  $this->log->debug("(2) next class: " . $next_class . ", ctype: " . $ctype);
328 
329  if ($next_class == "") {
330  include_once("./Services/COPage/classes/class.ilCOPagePCDef.php");
331  $pc_def = ilCOPagePCDef::getPCDefinitionByType($ctype);
332  if (is_array($pc_def)) {
333  $this->ctrl->setCmdClass($pc_def["pc_gui_class"]);
334  }
335  $next_class = $this->ctrl->getNextClass($this);
336  }
337 
338  // do not do this while imagemap editing is ongoing
339  if ($cmd == "displayPage" && $_POST["editImagemapForward_x"] == "" && $_POST["imagemap_x"] == "") {
340  $next_class = "";
341  }
342 
343  //echo "hier_id:$hier_id:type:$type:cmd:$cmd:ctype:$ctype:next_class:$next_class:<br>"; exit;
344  $this->log->debug("ilPageEditorGUI: ... next_class:" . $next_class . ", pc_id:" . $pc_id .
345  ", hier_id:" . $hier_id . ", ctype:" . $ctype . ", cmd:" . $cmd);
346  switch ($next_class) {
347  case "ilinternallinkgui":
348  $link_gui = new ilInternalLinkGUI(
349  $this->page_gui->getPageConfig()->getIntLinkHelpDefaultType(),
350  $this->page_gui->getPageConfig()->getIntLinkHelpDefaultId(),
351  $this->page_gui->getPageConfig()->getIntLinkHelpDefaultIdIsRef()
352  );
353  $link_gui->setFilterWhiteList(
354  $this->page_gui->getPageConfig()->getIntLinkFilterWhiteList()
355  );
356  foreach ($this->page_gui->getPageConfig()->getIntLinkFilters() as $filter) {
357  $link_gui->filterLinkType($filter);
358  }
359  $link_gui->setReturn($this->int_link_return);
360 
361  $ret = $this->ctrl->forwardCommand($link_gui);
362  break;
363 
364  // PC Media Object
365  case "ilpcmediaobjectgui":
366  include_once("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
367 
368  $this->tabs_gui->clearTargets();
369  $this->tabs_gui->setBackTarget(
370  $this->page_gui->page_back_title,
371  $ilCtrl->getLinkTarget($this->page_gui, "edit")
372  );
373  $pcmob_gui = new ilPCMediaObjectGUI($this->page, $cont_obj, $hier_id, $pc_id);
374  $pcmob_gui->setStyleId($this->page_gui->getStyleId());
375  $pcmob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
376  $ret = $this->ctrl->forwardCommand($pcmob_gui);
377  $ilHelp->setScreenIdComponent("copg_media");
378  break;
379 
380  // only for "linked" media
381  case "ilobjmediaobjectgui":
382  $this->tabs_gui->clearTargets();
383  $this->tabs_gui->setBackTarget(
384  $this->lng->txt("back"),
385  $ilCtrl->getParentReturn($this)
386  );
387  $mob_gui = new ilObjMediaObjectGUI("", $_GET["mob_id"], false, false);
388  $mob_gui->getTabs();
389  $mob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
390  $this->tpl->setTitle($this->lng->txt("mob") . ": " .
391  ilObject::_lookupTitle($_GET["mob_id"]));
392  $ret = $this->ctrl->forwardCommand($mob_gui);
393  break;
394 
395  // Question
396  case "ilpcquestiongui":
397  include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
398  $pc_question_gui = new ilPCQuestionGUI($this->page, $cont_obj, $hier_id, $pc_id);
399  $pc_question_gui->setSelfAssessmentMode($this->page_gui->getPageConfig()->getEnableSelfAssessment());
400  $pc_question_gui->setPageConfig($this->page_gui->getPageConfig());
401 
402  if ($this->page_gui->getPageConfig()->getEnableSelfAssessment()) {
403  $this->tabs_gui->clearTargets();
404  $ilHelp->setScreenIdComponent("copg_pcqst");
405  $this->tabs_gui->setBackTarget(
406  $this->lng->txt("back"),
407  $ilCtrl->getParentReturn($this)
408  );
409  $ret = $this->ctrl->forwardCommand($pc_question_gui);
410  } else {
411  $cmd = $this->ctrl->getCmd();
412  $pc_question_gui->$cmd();
413  $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($cont_obj)), "editQuestion");
414  }
415  break;
416 
417  // Plugged Component
418  case "ilpcpluggedgui":
419  $this->tabs_gui->clearTargets();
420  include_once("./Services/COPage/classes/class.ilPCPluggedGUI.php");
421  $plugged_gui = new ilPCPluggedGUI(
422  $this->page,
423  $cont_obj,
424  $hier_id,
425  $add_type,
426  $pc_id
427  );
428  $ret = $this->ctrl->forwardCommand($plugged_gui);
429  break;
430 
431  default:
432 
433  // generic calls to gui classes
434  include_once("./Services/COPage/classes/class.ilCOPagePCDef.php");
435  if (ilCOPagePCDef::isPCGUIClassName($next_class, true)) {
436  $pc_def = ilCOPagePCDef::getPCDefinitionByGUIClassName($next_class);
437  $this->tabs_gui->clearTargets();
438  $this->tabs_gui->setBackTarget(
439  $this->page_gui->page_back_title,
440  $ilCtrl->getLinkTarget($this->page_gui, "edit")
441  );
442  $ilHelp->setScreenIdComponent("copg_" . $pc_def["pc_type"]);
444  $gui_class_name = $pc_def["pc_gui_class"];
445  $pc_gui = new $gui_class_name($this->page, $cont_obj, $hier_id, $pc_id);
446  if ($pc_def["style_classes"]) {
447  $pc_gui->setStyleId($this->page_gui->getStyleId());
448  }
449  $pc_gui->setPageConfig($this->page_gui->getPageConfig());
450  $ret = $this->ctrl->forwardCommand($pc_gui);
451  } else {
452  // cmd belongs to ilPageEditorGUI
453 
454  if ($cmd == "pasteFromClipboard") {
455  $ret = $this->pasteFromClipboard($hier_id);
456  } elseif ($cmd == "paste") {
457  $ret = $this->paste($hier_id);
458  } else {
459  $ret = $this->$cmd();
460  }
461  }
462  break;
463 
464  }
465 
466  $this->log->debug("ilPageEditorGUI: executeCommand end");
467 
468  return $ret;
469  }
470 
475  public static function _doJSEditing()
476  {
477  global $DIC;
478 
479  $ilUser = $DIC->user();
480 
481  if ($ilUser->getPref("ilPageEditor_JavaScript") != "disable"
483  return true;
484  }
485  return false;
486  }
487 
491  public static function _isBrowserJSEditCapable()
492  {
493  return true;
494  }
495 
496  public function activatePage()
497  {
498  $this->page_gui->activatePage();
499  }
500 
501  public function deactivatePage()
502  {
503  $this->page_gui->deactivatePage();
504  }
505 
509  public function setMediaMode()
510  {
512 
513  $ilUser->writePref("ilPageEditor_MediaMode", $_POST["media_mode"]);
514  $ilUser->writePref("ilPageEditor_HTMLMode", $_POST["html_mode"]);
515  if ($ilUser->getPref("ilPageEditor_JavaScript") != $_POST["js_mode"]) {
516  // not nice, should be solved differently in the future
517  if ($this->page->getParentType() == "lm") {
518  $this->ctrl->setParameterByClass("illmpageobjectgui", "reloadTree", "y");
519  }
520  }
521  $ilUser->writePref("ilPageEditor_JavaScript", $_POST["js_mode"]);
522 
523  // again not so nice...
524  if ($this->page->getParentType() == "lm") {
525  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
526  } else {
527  $this->ctrl->returnToParent($this);
528  }
529  }
530 
534  public function copyLinkedMediaToClipboard()
535  {
537 
538  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
539  $ilUser->addObjectToClipboard($_POST["mob_id"], "mob", ilObject::_lookupTitle($_POST["mob_id"]));
540  $this->ctrl->returnToParent($this);
541  }
542 
546  public function copyLinkedMediaToMediaPool()
547  {
549 
550  $this->ctrl->setParameterByClass("ilmediapooltargetselector", "mob_id", $_POST["mob_id"]);
551  $this->ctrl->redirectByClass("ilmediapooltargetselector", "listPools");
552  }
553 
557  public function addChangeComment()
558  {
559  include_once("./Services/History/classes/class.ilHistory.php");
561  $this->page->getId(),
562  "update",
563  "",
564  $this->page->getParentType() . ":pg",
565  ilUtil::stripSlashes($_POST["change_comment"]),
566  true
567  );
568  ilUtil::sendSuccess($this->lng->txt("cont_added_comment"), true);
569  $this->ctrl->returnToParent($this);
570  }
571 
575  public function deleteSelected()
576  {
578  $tpl = $this->tpl;
579  $lng = $this->lng;
580 
581  $targets = explode(";", $_POST["target"][0]);
582 
583  if (count($targets) == 0) {
584  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
585  $this->ctrl->returnToParent($this);
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("copg_confirm_el_deletion"));
591  $cgui->setCancel($lng->txt("cancel"), "cancelDeleteSelected");
592  $cgui->setConfirm($lng->txt("confirm"), "confirmedDeleteSelected");
593  $cgui->addHiddenItem("target", $_POST["target"][0]);
594 
595  $tpl->setContent($cgui->getHTML());
596  }
597  }
598 
605  public function cancelDeleteSelected()
606  {
607  $this->ctrl->returnToParent($this);
608  }
609 
610 
614  public function confirmedDeleteSelected()
615  {
616  $targets = explode(";", $_POST["target"]);
617  if (count($targets) > 0) {
618  $updated = $this->page->deleteContents(
619  $targets,
620  true,
621  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
622  );
623  if ($updated !== true) {
624  $_SESSION["il_pg_error"] = $updated;
625  } else {
626  unset($_SESSION["il_pg_error"]);
627  }
628  }
629  $this->ctrl->returnToParent($this);
630  }
631 
635  public function copySelected()
636  {
637  $lng = $this->lng;
638 
639  if (is_int(strpos($_POST["target"][0], ";"))) {
640  $_POST["target"] = explode(";", $_POST["target"][0]);
641  }
642  if (is_array($_POST["target"])) {
643  $this->page->copyContents($_POST["target"]);
644  ilUtil::sendSuccess($lng->txt("cont_sel_el_copied_use_paste"), true);
645  }
646  $this->ctrl->returnToParent($this);
647  }
648 
652  public function cutSelected()
653  {
654  $lng = $this->lng;
655 
656  if (is_int(strpos($_POST["target"][0], ";"))) {
657  $_POST["target"] = explode(";", $_POST["target"][0]);
658  }
659  if (is_array($_POST["target"])) {
660  $updated = $this->page->cutContents($_POST["target"]);
661  if ($updated !== true) {
662  $_SESSION["il_pg_error"] = $updated;
663  } else {
664  unset($_SESSION["il_pg_error"]);
665  }
666  ilUtil::sendSuccess($lng->txt("cont_sel_el_cut_use_paste"), true);
667  }
668  $this->ctrl->returnToParent($this);
669  }
670 
674  public function paste($a_hier_id)
675  {
677  $this->page->pasteContents($a_hier_id, $this->page_gui->getPageConfig()->getEnableSelfAssessment());
678  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
679  //ilEditClipboard::setAction("");
680  $this->ctrl->returnToParent($this);
681  }
682 
686  public function activateSelected()
687  {
688  if (is_int(strpos($_POST["target"][0], ";"))) {
689  $_POST["target"] = explode(";", $_POST["target"][0]);
690  }
691  if (is_array($_POST["target"])) {
692  $updated = $this->page->switchEnableMultiple(
693  $_POST["target"],
694  true,
695  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
696  );
697  if ($updated !== true) {
698  $_SESSION["il_pg_error"] = $updated;
699  } else {
700  unset($_SESSION["il_pg_error"]);
701  }
702  }
703  $this->ctrl->returnToParent($this);
704  }
705 
709  public function assignCharacteristicForm()
710  {
711  $tpl = $this->tpl;
712  $lng = $this->lng;
713 
714  if (is_int(strpos($_POST["target"][0], ";"))) {
715  $_POST["target"] = explode(";", $_POST["target"][0]);
716  }
717  if (is_array($_POST["target"])) {
718  $types = array();
719 
720  // check what content element types have been selected
721  foreach ($_POST["target"] as $t) {
722  $tarr = explode(":", $t);
723  $cont_obj = $this->page->getContentObject($tarr[0], $tarr[1]);
724  if (is_object($cont_obj) && $cont_obj->getType() == "par") {
725  $types["par"] = "par";
726  }
727  if (is_object($cont_obj) && $cont_obj->getType() == "sec") {
728  $types["sec"] = "sec";
729  }
730  }
731 
732  if (count($types) == 0) {
733  ilUtil::sendFailure($lng->txt("cont_select_par_or_section"), true);
734  $this->ctrl->returnToParent($this);
735  } else {
736  $this->initCharacteristicForm($_POST["target"], $types);
737  $tpl->setContent($this->form->getHTML());
738  }
739  } else {
740  $this->ctrl->returnToParent($this);
741  }
742  }
743 
747  public function initCharacteristicForm($a_target, $a_types)
748  {
750  $lng = $this->lng;
751 
752 
753  // edit form
754  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
755  $this->form = new ilPropertyFormGUI();
756  $this->form->setTitle($this->lng->txt("cont_choose_characteristic"));
757 
758  if ($a_types["par"] == "par") {
759  $select_prop = new ilSelectInputGUI(
760  $this->lng->txt("cont_choose_characteristic_text"),
761  "char_par"
762  );
763  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
764  $options = ilPCParagraphGUI::_getCharacteristics($this->page_gui->getStyleId());
765  $select_prop->setOptions($options);
766  $this->form->addItem($select_prop);
767  }
768  if ($a_types["sec"] == "sec") {
769  $select_prop = new ilSelectInputGUI(
770  $this->lng->txt("cont_choose_characteristic_section"),
771  "char_sec"
772  );
773  include_once("./Services/COPage/classes/class.ilPCSectionGUI.php");
774  $options = ilPCSectionGUI::_getCharacteristics($this->page_gui->getStyleId());
775  $select_prop->setOptions($options);
776  $this->form->addItem($select_prop);
777  }
778 
779  foreach ($a_target as $t) {
780  $hidden = new ilHiddenInputGUI("target[]");
781  $hidden->setValue($t);
782  $this->form->addItem($hidden);
783  }
784 
785  $this->form->setFormAction($ilCtrl->getFormAction($this));
786  $this->form->addCommandButton("assignCharacteristic", $lng->txt("save"));
787  $this->form->addCommandButton("showPage", $lng->txt("cancel"));
788  }
789 
793  public function assignCharacteristic()
794  {
795  $char_par = ilUtil::stripSlashes($_POST["char_par"]);
796  $char_sec = ilUtil::stripSlashes($_POST["char_sec"]);
797  if (is_array($_POST["target"])) {
798  foreach ($_POST["target"] as $t) {
799  $tarr = explode(":", $t);
800  $cont_obj = $this->page->getContentObject($tarr[0], $tarr[1]);
801  if (is_object($cont_obj) && $cont_obj->getType() == "par") {
802  $cont_obj->setCharacteristic($char_par);
803  }
804  if (is_object($cont_obj) && $cont_obj->getType() == "sec") {
805  $cont_obj->setCharacteristic($char_sec);
806  }
807  }
808  $updated = $this->page->update();
809  if ($updated !== true) {
810  $_SESSION["il_pg_error"] = $updated;
811  } else {
812  unset($_SESSION["il_pg_error"]);
813  }
814  }
815  $this->ctrl->returnToParent($this);
816  }
817 
821  public function pasteFromClipboard($a_hier_id)
822  {
824  //var_dump($a_hier_id);
825  $ilCtrl->setParameter($this, "hier_id", $a_hier_id);
826  $ilCtrl->setParameterByClass(
827  "ilEditClipboardGUI",
828  "returnCommand",
829  rawurlencode($ilCtrl->getLinkTarget(
830  $this,
831  "insertFromClipboard",
832  "",
833  false,
834  false
835  ))
836  );
837  //echo ":".$ilCtrl->getLinkTarget($this, "insertFromClipboard").":";
838  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
839  }
840 
844  public function insertFromClipboard()
845  {
846  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
848  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
849  if ($ids != "") {
850  foreach ($ids as $id2) {
851  $id = explode(":", $id2);
852  $type = $id[0];
853  $id = $id[1];
854  if ($type == "mob") {
855  $this->content_obj = new ilPCMediaObject($this->page);
856  $this->content_obj->readMediaObject($id);
857  $this->content_obj->createAlias($this->page, $_GET["hier_id"]);
858  $this->updated = $this->page->update();
859  }
860  if ($type == "incl") {
861  include_once("./Services/COPage/classes/class.ilPCContentInclude.php");
862  $this->content_obj = new ilPCContentInclude($this->page);
863  $this->content_obj->create($this->page, $_GET["hier_id"]);
864  $this->content_obj->setContentType("mep");
865  $this->content_obj->setContentId($id);
866  $this->updated = $this->page->update();
867  }
868  }
869  }
870  $this->ctrl->returnToParent($this);
871  }
872 
876  public function displayPage()
877  {
878  $this->ctrl->returnToParent($this);
879  }
880 
884  public function displayLocator()
885  {
886  /*if(is_object($this->locator))
887  {
888  $this->locator->display();
889  }*/
890  }
891 
895  public function showSnippetInfo()
896  {
897  $tpl = $this->tpl;
898  $lng = $this->lng;
899  $ilAccess = $this->access;
901 
902  $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "Services/COPage");
903 
904  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
905  $mep_pools = ilMediaPoolItem::getPoolForItemId($_POST["ci_id"]);
906  foreach ($mep_pools as $mep_id) {
907  $ref_ids = ilObject::_getAllReferences($mep_id);
908  $edit_link = false;
909  foreach ($ref_ids as $rid) {
910  if (!$edit_link && $ilAccess->checkAccess("write", "", $rid)) {
911  $stpl->setCurrentBlock("edit_link");
912  $stpl->setVariable("TXT_EDIT", $lng->txt("edit"));
913  $stpl->setVariable(
914  "HREF_EDIT",
915  "./goto.php?target=mep_" . $rid
916  );
917  $stpl->parseCurrentBlock();
918  }
919  }
920  $stpl->setCurrentBlock("pool");
921  $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep"));
922  $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id));
923  $stpl->parseCurrentBlock();
924  }
925 
926  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
927  $stpl->setVariable("TXT_TITLE", $lng->txt("title"));
928  $stpl->setVariable("VAL_TITLE", ilMediaPoolPage::lookupTitle($_POST["ci_id"]));
929  $stpl->setVariable("TXT_BACK", $lng->txt("back"));
930  $stpl->setVariable(
931  "HREF_BACK",
932  $ilCtrl->getLinkTarget($this->page_gui, "edit")
933  );
934  $tpl->setContent($stpl->get());
935  }
936 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _isBrowserJSEditCapable()
checks wether browser is javascript editing capable
static isPCGUIClassName($a_class_name, $a_lower_case=false)
Is given class name a pc gui class?
static getPoolForItemId($a_id)
Get media pools for item id.
returnToContext()
redirect to parent context
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
displayLocator()
display locator
This class represents a property form user interface.
setMediaMode()
set media and editing mode
$type
cutSelected()
Cut selected items.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
showSnippetInfo()
Show snippet info.
Class ilPCPluggedGUI.
static getPCDefinitionByGUIClassName($a_gui_class_name)
Get PC definition by name.
if(!array_key_exists('StateId', $_REQUEST)) $id
confirmedDeleteSelected()
Delete selected items.
assignCharacteristicForm()
Assign characeristic to text blocks/sections.
displayPage()
Default for POST reloads and missing.
static _getCharacteristics($a_style_id)
Get characteristics.
setFilterWhiteList($a_white_list)
Set filter list as white list (per detault it is a black list)
static _lookupTitle($a_id)
lookup object title
Class ilInternalLinkGUI.
paste($a_hier_id)
paste from clipboard (redirects to clipboard)
executeCommand()
execute command
setLocator(&$a_locator)
set locator object
static lookupTitle($a_page_id)
Lookup title.
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
__construct(&$a_page_object, &$a_page_object_gui)
Constructor.
Class ilPCMediaObjectGUI.
Page Editor GUI class.
global $ilCtrl
Definition: ilias.php:18
copySelected()
Copy selected items.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilPCQuestionGUI.
initCharacteristicForm($a_target, $a_types)
Init map creation/update form.
copyLinkedMediaToClipboard()
copy linked media object to clipboard
This class represents a hidden form property in a property form.
Class ilPCContentInclude.
static _getCharacteristics($a_style_id)
Get characteristics.
assignCharacteristic()
Assign characteristic.
insertFromClipboard()
insert object from clipboard
copyLinkedMediaToMediaPool()
copy linked media object to media pool
activateSelected()
(de-)activate selected items
special template class to simplify handling of ITX/PEAR
static _doJSEditing()
checks if current user has activated js editing and if browser is js capable
$ilUser
Definition: imgupload.php:18
setHeader($a_header)
set header title
addChangeComment()
add change comment to history
Add a drawing to the header
Definition: 04printing.php:69
cancelDeleteSelected()
Cancel deletion.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilObjMediaObjectGUI.
static requirePCGUIClassByName($a_name)
Get instance.
$ret
Definition: parser.php:6
static getLogger($a_component_id)
Get component logger.
Class ilPCMediaObject.
static getPCDefinitionByType($a_pc_type)
Get PC definition by type.
$_POST["username"]
pasteFromClipboard($a_hier_id)
paste from clipboard (redirects to clipboard)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Confirmation screen class.
getHeader()
get header title