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