Esempio n. 1
0
 /**
  * add standard meta data sections
  */
 function addMetaDataSections($a_rep_obj_id, $a_obj_id, $a_type)
 {
     global $lng;
     $lng->loadLanguageModule("meta");
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($a_rep_obj_id, $a_obj_id, $a_type);
     if ($md_gen = $md->getGeneral()) {
         // get first descrption
         // The description is shown on the top of the page.
         // Thus it is not necessary to show it again.
         foreach ($md_gen->getDescriptionIds() as $id) {
             $md_des = $md_gen->getDescription($id);
             $description = $md_des->getDescription();
             break;
         }
         // get language(s)
         $langs = array();
         foreach ($ids = $md_gen->getLanguageIds() as $id) {
             $md_lan = $md_gen->getLanguage($id);
             if ($md_lan->getLanguageCode() != "") {
                 $langs[] = $lng->txt("meta_l_" . $md_lan->getLanguageCode());
             }
         }
         $langs = implode($langs, ", ");
         // keywords
         $keywords = array();
         foreach ($ids = $md_gen->getKeywordIds() as $id) {
             $md_key = $md_gen->getKeyword($id);
             $keywords[] = $md_key->getKeyword();
         }
         $keywords = implode($keywords, ", ");
     }
     // authors
     if (is_object($lifecycle = $md->getLifecycle())) {
         $sep = $author = "";
         foreach ($ids = $lifecycle->getContributeIds() as $con_id) {
             $md_con = $lifecycle->getContribute($con_id);
             if ($md_con->getRole() == "Author") {
                 foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                     $md_ent = $md_con->getEntity($ent_id);
                     $author = $author . $sep . $md_ent->getEntity();
                     $sep = ", ";
                 }
             }
         }
     }
     // copyright
     $copyright = "";
     if (is_object($rights = $md->getRights())) {
         include_once 'Services/MetaData/classes/class.ilMDUtils.php';
         $copyright = ilMDUtils::_parseCopyright($rights->getDescription());
     }
     // learning time
     #if(is_object($educational = $md->getEducational()))
     #{
     #	$learning_time = $educational->getTypicalLearningTime();
     #}
     $learning_time = "";
     if (is_object($educational = $md->getEducational())) {
         if ($seconds = $educational->getTypicalLearningTimeSeconds()) {
             $learning_time = ilFormat::_secondsToString($seconds);
         }
     }
     // output
     // description
     if ($description != "") {
         $this->addSection($lng->txt("description"));
         $this->addProperty("", nl2br($description));
     }
     // general section
     $this->addSection($lng->txt("meta_general"));
     if ($langs != "") {
         $this->addProperty($lng->txt("language"), $langs);
     }
     if ($keywords != "") {
         $this->addProperty($lng->txt("keywords"), $keywords);
     }
     if ($author != "") {
         $this->addProperty($lng->txt("author"), $author);
     }
     if ($copyright != "") {
         $this->addProperty($lng->txt("meta_copyright"), $copyright);
     }
     if ($learning_time != "") {
         $this->addProperty($lng->txt("meta_typical_learning_time"), $learning_time);
     }
 }
 protected function updateTLT()
 {
     include_once "Services/MetaData/classes/class.ilMD.php";
     foreach ($_POST['tlt'] as $item_id => $item) {
         $md_obj = new ilMD($this->getObjId(), $item_id, 'st');
         if (!is_object($md_section = $md_obj->getEducational())) {
             $md_section = $md_obj->addEducational();
             $md_section->save();
         }
         $md_section->setPhysicalTypicalLearningTime((int) $item['mo'], (int) $item['d'], (int) $item['h'], (int) $item['m'], 0);
         $md_section->update();
     }
     // refresh learning progress
     include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
     ilLPStatusWrapper::_refreshStatus($this->getObjId());
     ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
     $this->ctrl->redirect($this, 'show');
 }