00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00037 class ilInfoScreenGUI
00038 {
00039 var $ilias;
00040 var $lng;
00041 var $ctrl;
00042 var $gui_object;
00043 var $top_buttons = array();
00044 var $top_formbuttons = array();
00045 var $hiddenelements = array();
00049 var $form_action;
00050
00057 function ilInfoScreenGUI($a_gui_object)
00058 {
00059 global $ilias, $ilCtrl, $lng,$ilTabs;
00060
00061 $this->ilias =& $ilias;
00062 $this->ctrl =& $ilCtrl;
00063 $this->lng =& $lng;
00064 $this->tabs_gui =& $ilTabs;
00065 $this->gui_object =& $a_gui_object;
00066 $this->sec_nr = 0;
00067 $this->private_notes_enabled = false;
00068 $this->feedback_enabled = false;
00069 $this->learning_progress_enabled = false;
00070 $this->form_action = "";
00071 $this->top_formbuttons = array();
00072 $this->hiddenelements = array();
00073 }
00074
00078 function &executeCommand()
00079 {
00080 global $rbacsystem;
00081 global $tpl;
00082 global $lng;
00083
00084
00085 $lng->loadLanguageModule("barometer");
00086
00087 $next_class = $this->ctrl->getNextClass($this);
00088
00089 $cmd = $this->ctrl->getCmd("showSummary");
00090
00091 $this->setTabs();
00092
00093 switch($next_class)
00094 {
00095 case "ilnotegui":
00096 $this->showSummary();
00097 break;
00098
00099 case "ilfeedbackgui":
00100 include_once("Services/Feedback/classes/class.ilFeedbackGUI.php");
00101 $fb_gui = new ilFeedbackGUI();
00102 $this->ctrl->setParameterByClass("ilFeedbackGUI","obj_id",$this->gui_object->object->getId());
00103 $this->ctrl->setParameterByClass("ilFeedbackGUI","ref_id",$_GET['ref_id']);
00104 $html = $this->ctrl->forwardCommand($fb_gui);
00105 $tpl->setContent($html);
00106 break;
00107
00108 default:
00109 return $this->$cmd();
00110 break;
00111 }
00112 return true;
00113 }
00114
00118 function enablePrivateNotes($a_enable = true)
00119 {
00120 $this->private_notes_enabled = $a_enable;
00121 }
00122
00126 function enableLearningProgress($a_enable = true)
00127 {
00128 $this->learning_progress_enabled = $a_enable;
00129 }
00130
00131
00135 function enableFeedback($a_enable = true)
00136 {
00137 $this->feedback_enabled = $a_enable;
00138 }
00139
00143 function addSection($a_title)
00144 {
00145 $this->sec_nr++;
00146 $this->section[$this->sec_nr]["title"] = $a_title;
00147 }
00148
00152 function setFormAction($a_form_action)
00153 {
00154 $this->form_action = $a_form_action;
00155 }
00156
00160 function removeFormAction()
00161 {
00162 $this->form_action = "";
00163 }
00164
00172 function addProperty($a_name, $a_value, $a_link = "")
00173 {
00174 $this->section[$this->sec_nr]["properties"][] =
00175 array("name" => $a_name, "value" => $a_value,
00176 "link" => $a_link);
00177 }
00178
00182 function addPropertyCheckbox($a_name, $a_checkbox_name, $a_checkbox_value, $a_checkbox_label = "", $a_checkbox_checked = false)
00183 {
00184 $checkbox = "<input type=\"checkbox\" name=\"$a_checkbox_name\" value=\"$a_checkbox_value\" id=\"$a_checkbox_name$a_checkbox_value\"";
00185 if ($a_checkbox_checked)
00186 {
00187 $checkbox .= " checked=\"checked\"";
00188 }
00189 $checkbox .= " />";
00190 if (strlen($a_checkbox_label))
00191 {
00192 $checkbox .= " <label for=\"$a_checkbox_name$a_checkbox_value\">$a_checkbox_label</label>";
00193 }
00194 $this->section[$this->sec_nr]["properties"][] =
00195 array("name" => $a_name, "value" => $checkbox);
00196 }
00197
00201 function addPropertyTextinput($a_name, $a_input_name, $a_input_value = "", $a_input_size = "", $direct_button_command = "", $direct_button_label = "")
00202 {
00203 $input = "<input type=\"text\" name=\"$a_input_name\" id=\"$a_input_name\"";
00204 if (strlen($a_input_value))
00205 {
00206 $input .= " value=\"" . ilUtil::prepareFormOutput($a_input_value) . "\"";
00207 }
00208 if (strlen($a_input_size))
00209 {
00210 $input .= " size=\"" . $a_input_size . "\"";
00211 }
00212 $input .= " />";
00213 if (strlen($direct_button_command) && strlen($direct_button_label))
00214 {
00215 $input .= " <input type=\"submit\" class=\"submit\" name=\"cmd[$direct_button_command]\" value=\"$direct_button_label\" />";
00216 }
00217 $this->section[$this->sec_nr]["properties"][] =
00218 array("name" => "<label for=\"$a_input_name\">$a_name</label>", "value" => $input);
00219 }
00220
00224 function addButton($a_title, $a_link, $a_frame = "", $a_position = "top")
00225 {
00226 if ($a_position == "top")
00227 {
00228 $this->top_buttons[] =
00229 array("title" => $a_title,"link" => $a_link,"target" => $a_frame);
00230 }
00231 }
00232
00237 function addFormButton($a_command, $a_title, $a_position = "top")
00238 {
00239 if ($a_position == "top")
00240 {
00241 array_push($this->top_formbuttons,
00242 array("command" => $a_command, "title" => $a_title)
00243 );
00244 }
00245 }
00246
00247 function addHiddenElement($a_name, $a_value)
00248 {
00249 array_push($this->hiddenelements, array("name" => $a_name, "value" => $a_value));
00250 }
00251
00255 function addMetaDataSections($a_rep_obj_id,$a_obj_id, $a_type)
00256 {
00257 global $lng;
00258
00259 $lng->loadLanguageModule("meta");
00260
00261 include_once("./Services/MetaData/classes/class.ilMD.php");
00262 $md = new ilMD($a_rep_obj_id,$a_obj_id, $a_type);
00263
00264 if ($md_gen = $md->getGeneral())
00265 {
00266
00267 foreach($md_gen->getDescriptionIds() as $id)
00268 {
00269 $md_des = $md_gen->getDescription($id);
00270 $description = $md_des->getDescription();
00271 break;
00272 }
00273
00274
00275 $langs = array();
00276 foreach($ids = $md_gen->getLanguageIds() as $id)
00277 {
00278 $md_lan = $md_gen->getLanguage($id);
00279 if ($md_lan->getLanguageCode() != "")
00280 {
00281 $langs[] = $lng->txt("meta_l_".$md_lan->getLanguageCode());
00282 }
00283 }
00284 $langs = implode($langs, ", ");
00285
00286
00287 $keywords = array();
00288 foreach($ids = $md_gen->getKeywordIds() as $id)
00289 {
00290 $md_key = $md_gen->getKeyword($id);
00291 $keywords[] = $md_key->getKeyword();
00292 }
00293 $keywords = implode($keywords, ", ");
00294 }
00295
00296
00297 if(is_object($lifecycle = $md->getLifecycle()))
00298 {
00299 $sep = $author = "";
00300 foreach(($ids = $lifecycle->getContributeIds()) as $con_id)
00301 {
00302 $md_con = $lifecycle->getContribute($con_id);
00303 if ($md_con->getRole() == "Author")
00304 {
00305 foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
00306 {
00307 $md_ent = $md_con->getEntity($ent_id);
00308 $author = $author.$sep.$md_ent->getEntity();
00309 $sep = ", ";
00310 }
00311 }
00312 }
00313 }
00314
00315
00316 $copyright = "";
00317 if(is_object($rights = $md->getRights()))
00318 {
00319 $copyright = $rights->getDescription();
00320 }
00321
00322
00323 #if(is_object($educational = $md->getEducational()))
00324 #{
00325 # $learning_time = $educational->getTypicalLearningTime();
00326 #}
00327 $learning_time = "";
00328 if(is_object($educational = $md->getEducational()))
00329 {
00330 if($seconds = $educational->getTypicalLearningTimeSeconds())
00331 {
00332 $learning_time = ilFormat::_secondsToString($seconds);
00333 }
00334 }
00335
00336
00337
00338
00339
00340 if ($description != "")
00341 {
00342 $this->addSection($lng->txt("description"));
00343 $this->addProperty("", nl2br($description));
00344 }
00345
00346
00347 $this->addSection($lng->txt("meta_general"));
00348 if ($langs != "")
00349 {
00350 $this->addProperty($lng->txt("language"),
00351 $langs);
00352 }
00353 if ($keywords != "")
00354 {
00355 $this->addProperty($lng->txt("keywords"),
00356 $keywords);
00357 }
00358 if ($author != "")
00359 {
00360 $this->addProperty($lng->txt("author"),
00361 $author);
00362 }
00363 if ($copyright != "")
00364 {
00365 $this->addProperty($lng->txt("meta_copyright"),
00366 $copyright);
00367 }
00368 if ($learning_time != "")
00369 {
00370 $this->addProperty($lng->txt("meta_typical_learning_time"),
00371 $learning_time);
00372 }
00373 }
00374
00378 function showSummary()
00379 {
00380 global $tpl, $ilAccess;
00381
00382 $tpl->setContent($this->getHTML());
00383 }
00384
00385
00389 function getHTML()
00390 {
00391 $tpl = new ilTemplate("tpl.infoscreen.html" ,true, true);
00392
00393
00394 if (count($this->top_buttons) > 0)
00395 {
00396 $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
00397
00398 foreach($this->top_buttons as $button)
00399 {
00400
00401 $tpl->setCurrentBlock("btn_cell");
00402 $tpl->setVariable("BTN_LINK", $button["link"]);
00403 $tpl->setVariable("BTN_TARGET", $button["target"]);
00404 $tpl->setVariable("BTN_TXT", $button["title"]);
00405 $tpl->parseCurrentBlock();
00406 }
00407 }
00408
00409
00410 if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0))
00411 {
00412 $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html");
00413
00414 foreach($this->top_formbuttons as $button)
00415 {
00416
00417 $tpl->setCurrentBlock("btn_submit_cell");
00418 $tpl->setVariable("BTN_COMMAND", $button["command"]);
00419 $tpl->setVariable("BTN_NAME", $button["title"]);
00420 $tpl->parseCurrentBlock();
00421 }
00422 }
00423
00424
00425 if (strlen($this->form_action) > 0)
00426 {
00427 $tpl->setCurrentBlock("formtop");
00428 $tpl->setVariable("FORMACTION", $this->form_action);
00429 $tpl->parseCurrentBlock();
00430 $tpl->touchBlock("formbottom");
00431 }
00432
00433 if (count($this->hiddenelements))
00434 {
00435 foreach ($this->hiddenelements as $hidden)
00436 {
00437 $tpl->setCurrentBlock("hidden_element");
00438 $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
00439 $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
00440 $tpl->parseCurrentBlock();
00441 }
00442 }
00443
00444 for($i = 1; $i <= $this->sec_nr; $i++)
00445 {
00446 if (is_array($this->section[$i]["properties"]))
00447 {
00448
00449 $tpl->setCurrentBlock("header_row");
00450 $tpl->setVariable("TXT_SECTION",
00451 $this->section[$i]["title"]);
00452 $tpl->parseCurrentBlock();
00453 $tpl->touchBlock("row");
00454
00455
00456 foreach($this->section[$i]["properties"] as $property)
00457 {
00458 if ($property["name"] != "")
00459 {
00460 if ($property["link"] == "")
00461 {
00462 $tpl->setCurrentBlock("pv");
00463 $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
00464 $tpl->parseCurrentBlock();
00465 }
00466 else
00467 {
00468 $tpl->setCurrentBlock("lpv");
00469 $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
00470 $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
00471 $tpl->parseCurrentBlock();
00472 }
00473 $tpl->setCurrentBlock("property_row");
00474 $tpl->setVariable("TXT_PROPERTY", $property["name"]);
00475 $tpl->parseCurrentBlock();
00476 $tpl->touchBlock("row");
00477 }
00478 else
00479 {
00480 $tpl->setCurrentBlock("property_full_row");
00481 $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
00482 $tpl->parseCurrentBlock();
00483 $tpl->touchBlock("row");
00484 }
00485 }
00486 }
00487 }
00488
00489
00490 if (is_object($this->gui_object->object))
00491 {
00492
00493 $tpl->setCurrentBlock("header_row");
00494 $tpl->setVariable("TXT_SECTION",
00495 $this->lng->txt("additional_info"));
00496 $tpl->parseCurrentBlock();
00497 $tpl->touchBlock("row");
00498
00499
00500 $type = $this->gui_object->object->getType();
00501 $ref_id = $this->gui_object->object->getRefId();
00502 $href = ILIAS_HTTP_PATH.
00503 "/goto.php?target=".$type."_".$ref_id."&client_id=".CLIENT_ID;
00504 $tpl->setCurrentBlock("property_row");
00505 $tpl->setVariable("TXT_PROPERTY", $this->lng->txt("perma_link"));
00506 $tpl->setVariable("TXT_PROPERTY_VALUE",
00507 '<a class="small" href="'.$href.'" target="_top">'.$href.'</a>');
00508 $tpl->parseCurrentBlock();
00509 $tpl->touchBlock("row");
00510 }
00511
00512
00513
00514 if($this->learning_progress_enabled and $html = $this->showLearningProgress())
00515 {
00516 $tpl->setCurrentBlock("learning_progress");
00517 $tpl->setVariable("LP_TABLE",$html);
00518 $tpl->parseCurrentBlock();
00519 }
00520
00521
00522
00523 if ($this->private_notes_enabled)
00524 {
00525 $html = $this->showNotesSection();
00526 $tpl->setCurrentBlock("notes");
00527 $tpl->setVariable("NOTES", $html);
00528 $tpl->parseCurrentBlock();
00529 }
00530
00531 return $tpl->get();
00532 }
00533
00534 function showLearningProgress()
00535 {
00536 global $ilUser,$rbacsystem;
00537
00538 if(!$rbacsystem->checkAccess('read',$this->gui_object->object->getRefId()))
00539 {
00540 return false;
00541 }
00542 if($ilUser->getId() == ANONYMOUS_USER_ID)
00543 {
00544 return false;
00545 }
00546
00547 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
00548 if (!ilObjUserTracking::_enabledLearningProgress())
00549 {
00550 return false;
00551 }
00552
00553 include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
00554 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
00555
00556 if(ilLPObjSettings::_lookupMode($this->gui_object->object->getId()) != LP_MODE_MANUAL)
00557 {
00558 return false;
00559 }
00560
00561 $this->lng->loadLanguageModule('trac');
00562 $tpl = new ilTemplate("tpl.lp_edit_manual.html",true,true,'Services/Tracking');
00563
00564 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00565 $tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_trac.gif'));
00566 $tpl->setVariable("ALT_IMG",$this->lng->txt('learning_progress'));
00567 $tpl->setVariable("TXT_EDIT_PROGRESS",$this->lng->txt('trac_edit_progress'));
00568
00569 $tpl->setVariable("TXT_STATUS",$this->lng->txt('trac_status'));
00570
00571
00572 $tpl->setVariable("CHECK_EDITED",ilUtil::formSelect((int) ilLPMarks::_hasCompleted($ilUser->getId(),
00573 $this->gui_object->object->getId()),
00574 'lp_edit',
00575 array(0 => $this->lng->txt('trac_not_completed'),
00576 1 => $this->lng->txt('trac_completed')),
00577 false,
00578 true));
00579
00580
00581 $tpl->setVariable("INFO_EDITED",$this->lng->txt('trac_info_edited'));
00582
00583
00584 if($this->gui_object->object->getType() == 'lm' ||
00585 $this->gui_object->object->getType() == 'htlm')
00586 {
00587 $tpl->setCurrentBlock("lm_infos");
00588 $tpl->setVariable("TXT_LAST_ACCESS",$this->lng->txt('trac_last_access'));
00589
00590 include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
00591 $progress = ilLearningProgress::_getProgress($ilUser->getId(),$this->gui_object->object->getId());
00592 if($progress['access_time'])
00593 {
00594 $tpl->setVariable("LAST_ACCESS",date('Y-m-d H:i:s',$progress['access_time']));
00595 }
00596 else
00597 {
00598 $tpl->setVariable("LAST_ACCESS",$this->lng->txt('trac_not_accessed'));
00599 }
00600
00601 $tpl->setVariable("TXT_VISITS",$this->lng->txt('trac_visits'));
00602 $tpl->setVariable("VISITS",(int) $progress['visits']);
00603
00604 if($this->gui_object->object->getType() == 'lm')
00605 {
00606 $tpl->setVariable("TXT_DURATION",$this->lng->txt('trac_spent_time'));
00607 $tpl->setVariable("DURATION",ilFormat::_secondsToString($progress['spent_time']));
00608 }
00609
00610 $tpl->parseCurrentBlock();
00611 }
00612 $tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
00613
00614 return $tpl->get();
00615 }
00616
00617 function saveProgress()
00618 {
00619 global $ilUser;
00620
00621 include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
00622 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
00623
00624 $lp_marks = new ilLPMarks($this->gui_object->object->getId(),$ilUser->getId());
00625 $lp_marks->setCompleted((bool) $_POST['lp_edit']);
00626 $lp_marks->update();
00627
00628 $this->lng->loadLanguageModule('trac');
00629 sendInfo($this->lng->txt('trac_updated_status'));
00630
00631 $this->showSummary();
00632 }
00633
00634
00638 function showNotesSection()
00639 {
00640 $next_class = $this->ctrl->getNextClass($this);
00641 include_once("Services/Notes/classes/class.ilNoteGUI.php");
00642 $notes_gui = new ilNoteGUI($this->gui_object->object->getId(), 0,
00643 $this->gui_object->object->getType());
00644
00645 $notes_gui->enablePrivateNotes();
00646
00647
00648 if ($next_class == "ilnotegui")
00649 {
00650 $html = $this->ctrl->forwardCommand($notes_gui);
00651 }
00652 else
00653 {
00654 $html = $notes_gui->getNotesHTML();
00655 }
00656
00657 return $html;
00658 }
00659
00660 function setTabs()
00661 {
00662 global $tpl;
00663
00664 $this->getTabs($this->tabs_gui);
00665 }
00666
00670 function getTabs(&$tabs_gui)
00671 {
00672 global $rbacsystem,$ilUser,$ilAccess;
00673
00674 $next_class = $this->ctrl->getNextClass($this);
00675 $force_active = ($next_class == "ilnotegui")
00676 ? true
00677 : false;
00678
00679 $tabs_gui->addSubTabTarget('summary',
00680 $this->ctrl->getLinkTarget($this, "showSummary"),
00681 array("showSummary", ""),
00682 get_class($this), "", $force_active);
00683
00684 if ($this->feedback_enabled)
00685 {
00686 $show_feedback_tab=false;
00687 if($ilAccess->checkAccess('write','edit',$_GET['ref_id']))
00688 {
00689 $show_feedback_tab=true;
00690 }
00691 else
00692 {
00693
00694
00695
00696 include_once('Services/Feedback/classes/class.ilFeedback.php');
00697 $feedback = new ilFeedback();
00698 $feedback->setRefId($_GET['ref_id']);
00699 $barometers = $feedback->getAllBarometer(0);
00700 if(count($barometers))
00701 {
00702 foreach ($barometers as $barometer)
00703 {
00704 if($barometer->canVote($ilUser->getId(),$barometer->getId())==1)
00705 {
00706 $show_feedback_tab=true;
00707 break;
00708 }
00709 }
00710 }
00711 }
00712 if ($show_feedback_tab)
00713 {
00714 $tabs_gui->addSubTabTarget("feedback",
00715 $this->ctrl->getLinkTargetByClass("ilfeedbackgui", "fbList"),
00716 "", "ilfeedbackgui");
00717 }
00718
00719
00720
00721
00722
00723 }
00724 }
00725
00726 }
00727
00728 ?>