00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once ("content/classes/Pages/class.ilPageEditorGUI.php");
00025 include_once("./content/classes/Pages/class.ilPageObject.php");
00026 include_once("./content/classes/class.ilEditClipboardGUI.php");
00027
00028 include_once("./classes/class.ilDOMUtil.php");
00029
00030
00044 class ilPageObjectGUI
00045 {
00046 var $ilias;
00047 var $tpl;
00048 var $lng;
00049 var $ctrl;
00050 var $obj;
00051 var $output_mode;
00052 var $output_submode;
00053 var $presentation_title;
00054 var $target_script;
00055 var $return_location;
00056 var $target_var;
00057 var $template_output_var;
00058 var $output2template;
00059 var $link_params;
00060 var $bib_id;
00061 var $citation;
00062 var $sourcecode_download_script;
00063 var $change_comments;
00064
00069 function ilPageObjectGUI(&$a_page_object)
00070 {
00071 global $ilias, $tpl, $lng, $ilCtrl;
00072
00073 $this->ctrl =& $ilCtrl;
00074
00075 $this->ilias =& $ilias;
00076 $this->tpl =& $tpl;
00077 $this->ctrl =& $ilCtrl;
00078 $this->lng =& $lng;
00079 $this->obj =& $a_page_object;
00080 $this->output_mode = "presentation";
00081 $this->setPageObject($a_page_object);
00082 $this->output2template = true;
00083 $this->question_xml = "";
00084
00085
00086 $this->template_output_var = "PAGE_CONTENT";
00087 $this->citation = false;
00088 $this->change_comments = false;
00089 }
00090
00096 function _forwards()
00097 {
00098 return array("ilPageEditorGUI");
00099 }
00100
00101
00102 function setBibId($a_id)
00103 {
00104
00105 $this->bib_id = $a_id;
00106 }
00107
00108 function getBibId()
00109 {
00110 return $this->bib_id ? $this->bib_id : 0;
00111 }
00112
00113 function setPageObject(&$a_pg_obj)
00114 {
00115 $this->obj =& $a_pg_obj;
00116 }
00117
00118 function &getPageObject()
00119 {
00120 return $this->obj;
00121 }
00122
00126 function setOutputMode($a_mode = "presentation")
00127 {
00128 $this->output_mode = $a_mode;
00129 }
00130
00131 function getOutputMode()
00132 {
00133 return $this->output_mode;
00134 }
00135
00136 function setTemplateOutput($a_output = true)
00137 {
00138 $this->output2template = $a_output;
00139 }
00140
00141 function outputToTemplate()
00142 {
00143 return $this->output2template;
00144 }
00145
00146 function setPresentationTitle($a_title = "")
00147 {
00148 $this->presentation_title = $a_title;
00149 }
00150
00151 function getPresentationTitle()
00152 {
00153 return $this->presentation_title;
00154 }
00155
00156 function setHeader($a_title = "")
00157 {
00158 $this->header = $a_title;
00159 }
00160
00161 function getHeader()
00162 {
00163 return $this->header;
00164 }
00165
00166 function setLinkParams($l_params = "")
00167 {
00168 $this->link_params = $l_params;
00169 }
00170
00171 function getLinkParams()
00172 {
00173 return $this->link_params;
00174 }
00175
00176 function setLinkFrame($l_frame = "")
00177 {
00178 $this->link_frame = $l_frame;
00179 }
00180
00181 function getLinkFrame()
00182 {
00183 return $this->link_frame;
00184 }
00185
00186 function setLinkXML($link_xml)
00187 {
00188 $this->link_xml = $link_xml;
00189 }
00190
00191 function getLinkXML()
00192 {
00193 return $this->link_xml;
00194 }
00195
00196 function setQuestionXML($question_xml)
00197 {
00198 $this->question_xml = $question_xml;
00199 }
00200
00201 function getQuestionXML()
00202 {
00203 return $this->question_xml;
00204 }
00205
00206 function setTemplateTargetVar($a_variable)
00207 {
00208 $this->target_var = $a_variable;
00209 }
00210
00211 function getTemplateTargetVar()
00212 {
00213 return $this->target_var;
00214 }
00215
00216 function setTemplateOutputVar($a_value)
00217 {
00218
00219 $this->template_output_var = $a_value;
00220 }
00221
00222 function getTemplateOutputVar()
00223 {
00224 return $this->template_output_var;
00225 }
00226
00227 function setOutputSubmode($a_mode)
00228 {
00229
00230 $this->output_submode = $a_mode;
00231 }
00232
00233 function getOutputSubmode()
00234 {
00235 return $this->output_submode;
00236 }
00237
00238
00239 function setSourcecodeDownloadScript ($script_name) {
00240 $this->sourcecode_download_script = $script_name;
00241 }
00242
00243 function getSourcecodeDownloadScript () {
00244 return $this->sourcecode_download_script;
00245 }
00246
00247 function enableCitation($a_enabled)
00248 {
00249 $this->citation = $a_enabled;
00250 }
00251
00252 function isEnabledCitation()
00253 {
00254 return $this->citation;
00255 }
00256
00257 function setLocator(&$a_locator)
00258 {
00259 $this->locator =& $a_locator;
00260 }
00261
00262 function setTabs($a_tabs)
00263 {
00264 $this->tabs = $a_tabs;
00265 }
00266
00267 function setFileDownloadLink($a_download_link)
00268 {
00269 $this->file_download_link = $a_download_link;
00270 }
00271
00272 function getFileDownloadLink()
00273 {
00274 return $this->file_download_link;
00275 }
00276
00277 function setFullscreenLink($a_fullscreen_link)
00278 {
00279 $this->fullscreen_link = $a_fullscreen_link;
00280 }
00281
00282 function getFullscreenLink()
00283 {
00284 return $this->fullscreen_link;
00285 }
00286
00287 function setIntLinkHelpDefault($a_type, $a_id)
00288 {
00289 $this->int_link_def_type = $a_type;
00290 $this->int_link_def_id = $a_id;
00291 }
00292
00293 function enableChangeComments($a_enabled)
00294 {
00295 $this->change_comments = $a_enabled;
00296 }
00297
00298 function isEnabledChangeComments()
00299 {
00300 return $this->change_comments;
00301 }
00302
00309 function setViewPageLink($a_link, $a_target = "")
00310 {
00311 $this->view_page_link = $a_link;
00312 $this->view_page_target = $a_target;
00313 }
00314
00318 function getViewPageLink()
00319 {
00320 return $this->view_page_link;
00321 }
00322
00326 function getViewPageTarget()
00327 {
00328 return $this->view_page_target;
00329 }
00330
00334 function &executeCommand()
00335 {
00336 $next_class = $this->ctrl->getNextClass($this);
00337
00338 $cmd = $this->ctrl->getCmd();
00339 $this->ctrl->addTab("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
00340 , "view", "ilEditClipboardGUI");
00341
00342 switch($next_class)
00343 {
00344 case "ileditclipboardgui":
00345
00346 $clip_gui = new ilEditClipboardGUI();
00347
00348 $ret =& $this->ctrl->forwardCommand($clip_gui);
00349 break;
00350
00351 case "ilpageeditorgui":
00352 $page_editor =& new ilPageEditorGUI($this->getPageObject());
00353 $page_editor->setLocator($this->locator);
00354 $page_editor->setHeader($this->getHeader());
00355 $page_editor->setIntLinkHelpDefault($this->int_link_def_type,
00356 $this->int_link_def_id);
00357
00358 $ret =& $this->ctrl->forwardCommand($page_editor);
00359 break;
00360
00361 case "ilmediapooltargetselector":
00362 include_once("content/classes/class.ilMediaPoolTargetSelector.php");
00363 $target_sel =& new ilMediaPoolTargetSelector();
00364 $ret =& $this->ctrl->forwardCommand($target_sel);
00365 break;
00366
00367 default:
00368 $ret =& $this->$cmd();
00369 break;
00370 }
00371 }
00372
00373
00374
00375
00376
00377 function showPage()
00378 {
00379 global $tree, $ilUser, $ilias;
00380
00381
00382 if($this->outputToTemplate())
00383 {
00384 if($this->getOutputMode() == "edit")
00385 {
00386
00387 $this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "content");
00388
00389
00390 if ($this->isEnabledChangeComments())
00391 {
00392 $this->tpl->setCurrentBlock("change_comment");
00393 $this->tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment"));
00394 $this->tpl->parseCurrentBlock();
00395 $this->tpl->setCurrentBlock("adm_content");
00396 }
00397
00398 $this->tpl->setVariable("TXT_INSERT_BEFORE", $this->lng->txt("cont_set_before"));
00399 $this->tpl->setVariable("TXT_INSERT_AFTER", $this->lng->txt("cont_set_after"));
00400 $this->tpl->setVariable("TXT_INSERT_CANCEL", $this->lng->txt("cont_set_cancel"));
00401 $this->tpl->setVariable("TXT_CONFIRM_DELETE", $this->lng->txt("cont_confirm_delete"));
00402 $this->tpl->setVariable("JS_DRAGDROP", ILIAS_HTTP_PATH."/content/js/wz_dragdrop.js");
00403 $this->tpl->setVariable("IMG_DRAGDROP",
00404 ilUtil::getImagePath("ilias_logo.png"));
00405
00406 if (!ilPageEditorGUI::_isBrowserJSEditCapable())
00407 {
00408 $this->tpl->setVariable("TXT_JAVA_SCRIPT_CAPABLE", "<br />".$this->lng->txt("cont_browser_not_js_capable"));
00409 }
00410 $this->tpl->setVariable("TXT_CHANGE_EDIT_MODE", $this->lng->txt("cont_set_edit_mode"));
00411
00412 $med_mode = array("enable" => $this->lng->txt("cont_enable_media"),
00413 "disable" => $this->lng->txt("cont_disable_media"));
00414 $sel_media_mode = ($ilUser->getPref("ilPageEditor_MediaMode") == "disable")
00415 ? "disable"
00416 : "enable";
00417
00418
00419
00420 $js_mode = array("enable" => $this->lng->txt("cont_enable_js"),
00421 "disable" => $this->lng->txt("cont_disable_js"));
00422
00423
00424
00425
00426
00427
00428 $this->tpl->setVariable("SEL_MEDIA_MODE",
00429 ilUtil::formSelect($sel_media_mode, "media_mode", $med_mode, false, true));
00430
00431 if ($this->getViewPageLink() != "")
00432 {
00433 $this->tpl->setCurrentBlock("view_link");
00434 $this->tpl->setVariable("LINK_VIEW_PAGE",
00435 $this->getViewPageLink());
00436 $this->tpl->setVariable("TARGET_VIEW_PAGE",
00437 $this->getViewPageTarget());
00438 $this->tpl->setVariable("TXT_VIEW_PAGE", $this->lng->txt("view"));
00439 $this->tpl->parseCurrentBlock();
00440 }
00441
00442
00443 $sel_js_mode = "disable";
00444 if($ilias->getSetting("enable_js_edit"))
00445 {
00446 $sel_js_mode = (ilPageEditorGUI::_doJSEditing())
00447 ? "enable"
00448 : "disable";
00449 $this->tpl->setVariable("SEL_JAVA_SCRIPT",
00450 ilUtil::formSelect($sel_js_mode, "js_mode", $js_mode, false, true));
00451 }
00452 }
00453 else
00454 {
00455 if($this->getOutputSubmode() == 'translation')
00456 {
00457 $this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_translation_content.html", "content");
00458 }
00459 else
00460 {
00461 $this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_content.html", "content");
00462 }
00463 }
00464 if ($this->getOutputMode() != "presentation" &&
00465 $this->getOutputMode() != "offline" &&
00466 $this->getOutputMode() != "print")
00467 {
00468 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui"));
00469 }
00470
00471
00472 if($this->getOutputMode() == "edit")
00473 {
00474 $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType().":pg",
00475 $this->obj->getId());
00476 $mob_links = array();
00477 foreach($links as $link)
00478 {
00479 if ($link["type"] == "mob")
00480 {
00481 $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"])." [".$link["id"]."]";
00482 }
00483 }
00484
00485 if (count($mob_links) > 0)
00486 {
00487 $this->tpl->setCurrentBlock("med_link");
00488 $this->tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs"));
00489 $this->tpl->setVariable("SEL_MED_LINKS",
00490 ilUtil::formSelect(0, "mob_id", $mob_links, false, true));
00491 $this->tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob"));
00492 $this->tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard"));
00493
00494 $this->tpl->parseCurrentBlock();
00495 }
00496 }
00497
00498 if ($_GET["reloadTree"] == "y")
00499 {
00500 $this->tpl->setCurrentBlock("reload_tree");
00501 if ($this->obj->getParentType() == "dbk")
00502 {
00503 $this->tpl->setVariable("LINK_TREE",
00504 $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer"));
00505 }
00506 else
00507 {
00508 $this->tpl->setVariable("LINK_TREE",
00509 $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer"));
00510 }
00511 $this->tpl->parseCurrentBlock();
00512 }
00513
00514 }
00515
00516
00517 $builded = $this->obj->buildDom();
00518 $this->obj->addFileSizes();
00519
00520
00521 if($this->getOutputMode() == "edit")
00522 {
00523 $this->obj->addHierIDs();
00524
00525 $hids = $this->obj->getHierIds();
00526 $row1_ids = $this->obj->getFirstRowIds();
00527 $col1_ids = $this->obj->getFirstColumnIds();
00528 $litem_ids = $this->obj->getListItemIds();
00529 $fitem_ids = $this->obj->getFileItemIds();
00530
00531
00532 $hids = $this->obj->getHierIds();
00533 foreach($hids as $hid)
00534 {
00535 $this->tpl->setCurrentBlock("add_dhtml");
00536 $this->tpl->setVariable("CONTEXTMENU", "contextmenu_".$hid);
00537 $this->tpl->parseCurrentBlock();
00538 }
00539
00540
00541 foreach($col1_ids as $hid)
00542 {
00543 $this->tpl->setCurrentBlock("add_dhtml");
00544 $this->tpl->setVariable("CONTEXTMENU", "contextmenu_r".$hid);
00545 $this->tpl->parseCurrentBlock();
00546 }
00547
00548
00549 foreach($row1_ids as $hid)
00550 {
00551 $this->tpl->setCurrentBlock("add_dhtml");
00552 $this->tpl->setVariable("CONTEXTMENU", "contextmenu_c".$hid);
00553 $this->tpl->parseCurrentBlock();
00554 }
00555
00556
00557 foreach($litem_ids as $hid)
00558 {
00559 $this->tpl->setCurrentBlock("add_dhtml");
00560 $this->tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
00561 $this->tpl->parseCurrentBlock();
00562 }
00563
00564
00565 foreach($fitem_ids as $hid)
00566 {
00567 $this->tpl->setCurrentBlock("add_dhtml");
00568 $this->tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
00569 $this->tpl->parseCurrentBlock();
00570 }
00571 }
00572
00573 $this->obj->addSourceCodeHighlighting($this->getOutputMode());
00574
00575
00576 $content = $this->obj->getXMLFromDom(false, true, true,
00577 $this->getLinkXML().$this->getQuestionXML());
00578
00579
00580 if($builded !== true)
00581 {
00582 $this->displayValidationError($builded);
00583 }
00584 else
00585 {
00586 $this->displayValidationError($_SESSION["il_pg_error"]);
00587 }
00588 unset($_SESSION["il_pg_error"]);
00589
00590 if(isset($_SESSION["citation_error"]))
00591 {
00592 sendInfo($this->lng->txt("cont_citation_selection_not_valid"));
00593 session_unregister("citation_error");
00594 unset($_SESSION["citation_error"]);
00595 }
00596
00597
00598 $pg_title = $this->getPresentationTitle();
00599
00600
00601
00602
00603 $xsl = file_get_contents("./content/page.xsl");
00604 $args = array( '/_xml' => $content, '/_xsl' => $xsl );
00605 $xh = xslt_create();
00606
00607
00608
00609
00610
00611 $add_path = ilUtil::getImagePath("add.gif");
00612 $col_path = ilUtil::getImagePath("col.gif");
00613 $row_path = ilUtil::getImagePath("row.gif");
00614 $item_path = ilUtil::getImagePath("item.gif");
00615 $med_disabled_path = ilUtil::getImagePath("media_disabled.gif");
00616
00617 if ($this->getOutputMode() != "offline")
00618 {
00619 $enlarge_path = ilUtil::getImagePath("enlarge.gif");
00620 $wb_path = ilUtil::getWebspaceDir("output");
00621 }
00622 else
00623 {
00624 $enlarge_path = "images/enlarge.gif";
00625 $wb_path = ".";
00626 }
00627 $pg_title_class = ($this->getOutputMode() == "print")
00628 ? "ilc_PrintPageTitle"
00629 : "";
00630
00631
00632
00633 $enable_split_new = ($this->obj->getParentType() == "lm" ||
00634 $this->obj->getParentType() == "dbk")
00635 ? "y"
00636 : "n";
00637
00638
00639
00640 if (($this->obj->getParentType() == "lm" ||
00641 $this->obj->getParentType() == "dbk") &&
00642 ilObjContentObject::hasSuccessorPage($this->obj->getParentId(),
00643 $this->obj->getId()))
00644 {
00645 $enable_split_next = "y";
00646 }
00647 else
00648 {
00649 $enable_split_next = "n";
00650 }
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662 $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline");
00663
00664
00665
00666
00667
00668 $params = array ('mode' => $this->getOutputMode(), 'pg_title' => $pg_title,
00669 'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class,
00670 'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path,
00671 'img_add' => $add_path,
00672 'img_col' => $col_path,
00673 'img_row' => $row_path,
00674 'img_item' => $item_path,
00675 'enable_split_new' => $enable_split_new,
00676 'enable_split_next' => $enable_split_next,
00677 'link_params' => $this->link_params,
00678 'file_download_link' => $this->getFileDownloadLink(),
00679 'fullscreen_link' => $this->getFullscreenLink(),
00680 'med_disabled_path' => $med_disabled_path,
00681 'img_path' => $img_path,
00682 'parent_id' => $this->obj->getParentId(),
00683 'download_script' => $this->sourcecode_download_script,
00684 'encoded_download_script' => urlencode($this->sourcecode_download_script),
00685 'bib_id' => $this->getBibId(),'citation' => (int) $this->isEnabledCitation(),
00686 'media_mode' => $ilUser->getPref("ilPageEditor_MediaMode"),
00687 'javascript' => $sel_js_mode);
00688
00689 if($this->link_frame != "")
00690 $params["pg_frame"] = $this->link_frame;
00691
00692 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
00693
00694 xslt_free($xh);
00695
00696
00697 $output = str_replace("<","<",$output);
00698 $output = str_replace(">",">",$output);
00699 $output = str_replace("&", "&", $output);
00700
00701
00702
00703
00704 $output = str_replace("{", "{", $output);
00705 $output = str_replace("}", "}", $output);
00706
00707
00708
00709
00710 $output = str_replace("\n", "", $output);
00711
00712
00713 if($this->outputToTemplate())
00714 {
00715 $this->tpl->setVariable($this->getTemplateOutputVar(), $output);
00716 return $output;
00717 }
00718 else
00719 {
00720 return $output;
00721 }
00722 }
00723
00724
00725
00726
00727 function preview()
00728 {
00729 global $tree;
00730 $this->setOutputMode("preview");
00731 return $this->showPage();
00732 }
00733
00734
00735
00736
00737 function view()
00738 {
00739 global $tree;
00740 $this->setOutputMode("edit");
00741 return $this->showPage();
00742 }
00743
00744
00745
00746
00747 function presentation($mode = "presentation")
00748 {
00749 global $tree;
00750 $this->setOutputMode($mode);
00751 return $this->showPage();
00752 }
00753
00754
00758 function showMediaFullscreen($a_style_id = 0)
00759 {
00760 $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "content");
00761 $this->tpl->setCurrentBlock("ContentStyle");
00762 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", 0);
00763 $this->tpl->parseCurrentBlock();
00764
00765 $this->tpl->setVariable("PAGETITLE", " - ".ilObject::_lookupTitle($_GET["mob_id"]));
00766 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00767 $this->tpl->setCurrentBlock("ilMedia");
00768
00769 require_once("content/classes/Media/class.ilObjMediaObject.php");
00770 $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
00771 if (!empty ($_GET["pg_id"]))
00772 {
00773 require_once("content/classes/Pages/class.ilPageObject.php");
00774 $pg_obj =& new ilPageObject($this->obj->getParentType(), $_GET["pg_id"]);
00775 $pg_obj->buildDom();
00776
00777 $xml = "<dummy>";
00778
00779
00780 $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
00781 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
00782 $xml.="</dummy>";
00783 }
00784 else
00785 {
00786 $xml = "<dummy>";
00787 $xml.= $media_obj->getXML(IL_MODE_ALIAS);
00788 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
00789 $xml.="</dummy>";
00790 }
00791
00792
00793
00794 $xsl = file_get_contents("./content/page.xsl");
00795 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
00796 $xh = xslt_create();
00797
00798
00799
00800
00801 $wb_path = ilUtil::getWebspaceDir("output");
00802
00803 $mode = "fullscreen";
00804 $params = array ('mode' => $mode, 'webspace_path' => $wb_path);
00805 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
00806 echo xslt_error($xh);
00807 xslt_free($xh);
00808
00809
00810 $this->tpl->setVariable("MEDIA_CONTENT", $output);
00811 }
00812
00818 function displayValidationError($a_error)
00819 {
00820 if(is_array($a_error))
00821 {
00822 $error_str = "<b>Validation Error(s):</b><br>";
00823 foreach ($a_error as $error)
00824 {
00825 $err_mess = implode($error, " - ");
00826 if (!is_int(strpos($err_mess, ":0:")))
00827 {
00828 $error_str .= htmlentities($err_mess)."<br />";
00829 }
00830 }
00831 $this->tpl->setVariable("MESSAGE", $error_str);
00832 }
00833 }
00834
00835 }
00836 ?>