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
00035 class ilInfoScreenGUI
00036 {
00037 var $ilias;
00038 var $lng;
00039 var $ctrl;
00040 var $gui_object;
00041 var $top_buttons = array();
00042 var $top_formbuttons = array();
00046 var $form_action;
00047
00054 function ilInfoScreenGUI($a_gui_object)
00055 {
00056 global $ilias, $ilCtrl, $lng,$ilTabs;
00057
00058 $this->ilias =& $ilias;
00059 $this->ctrl =& $ilCtrl;
00060 $this->lng =& $lng;
00061 $this->tabs_gui =& $ilTabs;
00062 $this->gui_object =& $a_gui_object;
00063 $this->sec_nr = 0;
00064 $this->private_notes_enabled = false;
00065 $this->feedback_enabled = false;
00066 $this->learning_progress_enabled = false;
00067 $this->form_action = "";
00068 $this->top_formbuttons = array();
00069 }
00070
00074 function &executeCommand()
00075 {
00076 global $rbacsystem;
00077
00078 $next_class = $this->ctrl->getNextClass($this);
00079
00080 $cmd = $this->ctrl->getCmd("showSummary");
00081
00082 $this->setTabs();
00083
00084 switch($next_class)
00085 {
00086 case "ilnotegui":
00087 $this->showSummary();
00088 break;
00089
00090 case "ilfeedbackgui":
00091
00092
00093
00094
00095
00096 break;
00097
00098 default:
00099 return $this->$cmd();
00100 break;
00101 }
00102 return true;
00103 }
00104
00108 function enablePrivateNotes($a_enable = true)
00109 {
00110 $this->private_notes_enabled = $a_enable;
00111 }
00112
00116 function enableLearningProgress($a_enable = true)
00117 {
00118 $this->learning_progress_enabled = $a_enable;
00119 }
00120
00121
00125 function enableFeedback($a_enable = true)
00126 {
00127 $this->feedback_enabled = $a_enable;
00128 }
00129
00133 function addSection($a_title)
00134 {
00135 $this->sec_nr++;
00136 $this->section[$this->sec_nr]["title"] = $a_title;
00137 }
00138
00142 function setFormAction($a_form_action)
00143 {
00144 $this->form_action = $a_form_action;
00145 }
00146
00150 function removeFormAction()
00151 {
00152 $this->form_action = "";
00153 }
00154
00158 function addProperty($a_name, $a_value)
00159 {
00160 $this->section[$this->sec_nr]["properties"][] =
00161 array("name" => $a_name, "value" => $a_value);
00162 }
00163
00167 function addPropertyCheckbox($a_name, $a_checkbox_name, $a_checkbox_value, $a_checkbox_label = "", $a_checkbox_checked = false)
00168 {
00169 $checkbox = "<input type=\"checkbox\" name=\"$a_checkbox_name\" value=\"$a_checkbox_value\" id=\"$a_checkbox_name$a_checkbox_value\"";
00170 if ($a_checkbox_checked)
00171 {
00172 $checkbox .= " checked=\"checked\"";
00173 }
00174 $checkbox .= " />";
00175 if (strlen($a_checkbox_label))
00176 {
00177 $checkbox .= " <label for=\"$a_checkbox_name$a_checkbox_value\">$a_checkbox_label</label>";
00178 }
00179 $this->section[$this->sec_nr]["properties"][] =
00180 array("name" => $a_name, "value" => $checkbox);
00181 }
00182
00186 function addButton($a_title, $a_link, $a_frame = "", $a_position = "top")
00187 {
00188 if ($a_position == "top")
00189 {
00190 $this->top_buttons[] =
00191 array("title" => $a_title,"link" => $a_link,"target" => $a_frame);
00192 }
00193 }
00194
00199 function addFormButton($a_command, $a_title, $a_position = "top")
00200 {
00201 if ($a_position == "top")
00202 {
00203 array_push($this->top_formbuttons,
00204 array("command" => $a_command, "title" => $a_title)
00205 );
00206 }
00207 }
00208
00212 function addMetaDataSections($a_rep_obj_id,$a_obj_id, $a_type)
00213 {
00214 global $lng;
00215
00216 $lng->loadLanguageModule("meta");
00217
00218 include_once("./Services/MetaData/classes/class.ilMD.php");
00219 $md = new ilMD($a_rep_obj_id,$a_obj_id, $a_type);
00220
00221 if ($md_gen = $md->getGeneral())
00222 {
00223
00224 foreach($md_gen->getDescriptionIds() as $id)
00225 {
00226 $md_des = $md_gen->getDescription($id);
00227 $description = $md_des->getDescription();
00228 break;
00229 }
00230
00231
00232 $langs = array();
00233 foreach($ids = $md_gen->getLanguageIds() as $id)
00234 {
00235 $md_lan = $md_gen->getLanguage($id);
00236 if ($md_lan->getLanguageCode() != "")
00237 {
00238 $langs[] = $lng->txt("meta_l_".$md_lan->getLanguageCode());
00239 }
00240 }
00241 $langs = implode($langs, ", ");
00242
00243
00244 $keywords = array();
00245 foreach($ids = $md_gen->getKeywordIds() as $id)
00246 {
00247 $md_key = $md_gen->getKeyword($id);
00248 $keywords[] = $md_key->getKeyword();
00249 }
00250 $keywords = implode($keywords, ", ");
00251 }
00252
00253
00254 if(is_object($lifecycle = $md->getLifecycle()))
00255 {
00256 $sep = $author = "";
00257 foreach(($ids = $lifecycle->getContributeIds()) as $con_id)
00258 {
00259 $md_con = $lifecycle->getContribute($con_id);
00260 if ($md_con->getRole() == "Author")
00261 {
00262 foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
00263 {
00264 $md_ent = $md_con->getEntity($ent_id);
00265 $author = $author.$sep.$md_ent->getEntity();
00266 $sep = ", ";
00267 }
00268 }
00269 }
00270 }
00271
00272
00273 $copyright = "";
00274 if(is_object($rights = $md->getRights()))
00275 {
00276 $copyright = $rights->getDescription();
00277 }
00278
00279
00280 #if(is_object($educational = $md->getEducational()))
00281 #{
00282 # $learning_time = $educational->getTypicalLearningTime();
00283 #}
00284 $learning_time = "";
00285 if(is_object($educational = $md->getEducational()))
00286 {
00287 if($seconds = $educational->getTypicalLearningTimeSeconds())
00288 {
00289 $learning_time = ilFormat::_secondsToString($seconds);
00290 }
00291 }
00292
00293
00294
00295
00296
00297 if ($description != "")
00298 {
00299 $this->addSection($lng->txt("description"));
00300 $this->addProperty("", nl2br($description));
00301 }
00302
00303
00304 $this->addSection($lng->txt("meta_general"));
00305 if ($langs != "")
00306 {
00307 $this->addProperty($lng->txt("language"),
00308 $langs);
00309 }
00310 if ($keywords != "")
00311 {
00312 $this->addProperty($lng->txt("keywords"),
00313 $keywords);
00314 }
00315 if ($author != "")
00316 {
00317 $this->addProperty($lng->txt("author"),
00318 $author);
00319 }
00320 if ($copyright != "")
00321 {
00322 $this->addProperty($lng->txt("meta_copyright"),
00323 $copyright);
00324 }
00325 if ($learning_time != "")
00326 {
00327 $this->addProperty($lng->txt("meta_typical_learning_time"),
00328 $learning_time);
00329 }
00330 }
00331
00335 function showSummary()
00336 {
00337 global $tpl, $ilAccess;
00338
00339 $tpl->setContent($this->getHTML());
00340 }
00341
00342
00346 function getHTML()
00347 {
00348 $tpl = new ilTemplate("tpl.infoscreen.html" ,true, true);
00349
00350
00351 if (count($this->top_buttons) > 0)
00352 {
00353 $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
00354
00355 foreach($this->top_buttons as $button)
00356 {
00357
00358 $tpl->setCurrentBlock("btn_cell");
00359 $tpl->setVariable("BTN_LINK", $button["link"]);
00360 $tpl->setVariable("BTN_TARGET", $button["target"]);
00361 $tpl->setVariable("BTN_TXT", $button["title"]);
00362 $tpl->parseCurrentBlock();
00363 }
00364 }
00365
00366
00367 if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0))
00368 {
00369 $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html");
00370
00371 foreach($this->top_formbuttons as $button)
00372 {
00373
00374 $tpl->setCurrentBlock("btn_submit_cell");
00375 $tpl->setVariable("BTN_COMMAND", $button["command"]);
00376 $tpl->setVariable("BTN_NAME", $button["title"]);
00377 $tpl->parseCurrentBlock();
00378 }
00379 }
00380
00381
00382 if (strlen($this->form_action) > 0)
00383 {
00384 $tpl->setCurrentBlock("formtop");
00385 $tpl->setVariable("FORMACTION", $this->form_action);
00386 $tpl->parseCurrentBlock();
00387 $tpl->touchBlock("formbottom");
00388 }
00389
00390 for($i = 1; $i <= $this->sec_nr; $i++)
00391 {
00392 if (is_array($this->section[$i]["properties"]))
00393 {
00394
00395 $tpl->setCurrentBlock("header_row");
00396 $tpl->setVariable("TXT_SECTION",
00397 $this->section[$i]["title"]);
00398 $tpl->parseCurrentBlock();
00399 $tpl->touchBlock("row");
00400
00401
00402 foreach($this->section[$i]["properties"] as $property)
00403 {
00404 if ($property["name"] != "")
00405 {
00406 $tpl->setCurrentBlock("property_row");
00407 $tpl->setVariable("TXT_PROPERTY", $property["name"]);
00408 $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
00409 $tpl->parseCurrentBlock();
00410 $tpl->touchBlock("row");
00411 }
00412 else
00413 {
00414 $tpl->setCurrentBlock("property_full_row");
00415 $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
00416 $tpl->parseCurrentBlock();
00417 $tpl->touchBlock("row");
00418 }
00419 }
00420 }
00421 }
00422
00423 if($this->learning_progress_enabled and $html = $this->showLearningProgress())
00424 {
00425 $tpl->setCurrentBlock("learning_progress");
00426 $tpl->setVariable("LP_TABLE",$html);
00427 $tpl->parseCurrentBlock();
00428 }
00429
00430
00431
00432 if ($this->private_notes_enabled)
00433 {
00434 $html = $this->showNotesSection();
00435 $tpl->setCurrentBlock("notes");
00436 $tpl->setVariable("NOTES", $html);
00437 $tpl->parseCurrentBlock();
00438 }
00439
00440 return $tpl->get();
00441 }
00442
00443 function showLearningProgress()
00444 {
00445 global $ilUser,$rbacsystem;
00446
00447 if(!$rbacsystem->checkAccess('read',$this->gui_object->object->getRefId()))
00448 {
00449 return false;
00450 }
00451 if($ilUser->getId() == ANONYMOUS_USER_ID)
00452 {
00453 return false;
00454 }
00455
00456 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
00457 if (!ilObjUserTracking::_enabledLearningProgress())
00458 {
00459 return false;
00460 }
00461
00462 include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
00463 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
00464
00465 if(ilLPObjSettings::_lookupMode($this->gui_object->object->getId()) != LP_MODE_MANUAL)
00466 {
00467 return false;
00468 }
00469
00470 $this->lng->loadLanguageModule('trac');
00471 $tpl = new ilTemplate("tpl.lp_edit_manual.html",true,true,'Services/Tracking');
00472
00473 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00474 $tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_trac.gif'));
00475 $tpl->setVariable("ALT_IMG",$this->lng->txt('learning_progress'));
00476 $tpl->setVariable("TXT_EDIT_PROGRESS",$this->lng->txt('trac_edit_progress'));
00477
00478 $tpl->setVariable("TXT_STATUS",$this->lng->txt('trac_status'));
00479
00480
00481 $tpl->setVariable("CHECK_EDITED",ilUtil::formSelect((int) ilLPMarks::_hasCompleted($ilUser->getId(),
00482 $this->gui_object->object->getId()),
00483 'lp_edit',
00484 array(0 => $this->lng->txt('trac_not_completed'),
00485 1 => $this->lng->txt('trac_completed')),
00486 false,
00487 true));
00488
00489
00490 $tpl->setVariable("INFO_EDITED",$this->lng->txt('trac_info_edited'));
00491
00492
00493 if($this->gui_object->object->getType() == 'lm')
00494 {
00495 $tpl->setCurrentBlock("lm_infos");
00496 $tpl->setVariable("TXT_LAST_ACCESS",$this->lng->txt('trac_last_access'));
00497
00498 include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
00499 $progress = ilLearningProgress::_getProgress($ilUser->getId(),$this->gui_object->object->getId());
00500 if($progress['access_time'])
00501 {
00502 $tpl->setVariable("LAST_ACCESS",date('Y-m-d H:i:s',$progress['access_time']));
00503 }
00504 else
00505 {
00506 $tpl->setVariable("LAST_ACCESS",$this->lng->txt('trac_not_accessed'));
00507 }
00508
00509 $tpl->setVariable("TXT_VISITS",$this->lng->txt('trac_visits'));
00510 $tpl->setVariable("VISITS",(int) $progress['visits']);
00511
00512 $tpl->setVariable("TXT_DURATION",$this->lng->txt('trac_spent_time'));
00513 $tpl->setVariable("DURATION",ilFormat::_secondsToString($progress['spent_time']));
00514
00515 $tpl->parseCurrentBlock();
00516 }
00517 $tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
00518
00519 return $tpl->get();
00520 }
00521
00522 function saveProgress()
00523 {
00524 global $ilUser;
00525
00526 include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
00527 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
00528
00529 $lp_marks = new ilLPMarks($this->gui_object->object->getId(),$ilUser->getId());
00530 $lp_marks->setCompleted((bool) $_POST['lp_edit']);
00531 $lp_marks->update();
00532
00533 $this->lng->loadLanguageModule('trac');
00534 sendInfo($this->lng->txt('trac_updated_status'));
00535
00536 $this->showSummary();
00537 }
00538
00539
00543 function showNotesSection()
00544 {
00545 $next_class = $this->ctrl->getNextClass($this);
00546 include_once("Services/Notes/classes/class.ilNoteGUI.php");
00547 $notes_gui = new ilNoteGUI($this->gui_object->object->getId(), 0,
00548 $this->gui_object->object->getType());
00549
00550 $notes_gui->enablePrivateNotes();
00551
00552
00553 if ($next_class == "ilnotegui")
00554 {
00555 $html = $this->ctrl->forwardCommand($notes_gui);
00556 }
00557 else
00558 {
00559 $html = $notes_gui->getNotesHTML();
00560 }
00561
00562 return $html;
00563 }
00564
00565 function setTabs()
00566 {
00567 global $tpl;
00568
00569 $this->getTabs($this->tabs_gui);
00570 }
00571
00575 function getTabs(&$tabs_gui)
00576 {
00577 global $rbacsystem;
00578
00579 $next_class = $this->ctrl->getNextClass($this);
00580 $force_active = ($next_class == "ilnotegui")
00581 ? true
00582 : false;
00583
00584 $tabs_gui->addSubTabTarget('summary',
00585 $this->ctrl->getLinkTarget($this, "showSummary"),
00586 array("showSummary", ""),
00587 get_class($this), "", $force_active);
00588
00589 if ($this->feedback_enabled)
00590 {
00591
00592 $tabs_gui->addSubTabTarget("feedback",
00593 $this->ctrl->getLinkTarget($this, "dummy"),
00594 "", "ilfeedbackgui");
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 }
00605 }
00606
00607 }
00608
00609 ?>