function saveKeywordsForm()
 {
     global $ilUser;
     $form = $this->initKeywordsForm();
     if ($form->checkInput()) {
         $keywords = $form->getInput("keywords");
         if (is_array($keywords)) {
             // language is not "used" anywhere
             $ulang = $ilUser->getLanguage();
             $keywords = array($ulang => $keywords);
             include_once "./Services/MetaData/classes/class.ilMDKeyword.php";
             ilMDKeyword::updateKeywords($this->getMDSection(), $keywords);
         }
         $this->ctrl->redirect($this, "preview");
     }
     $form->setValuesByPost();
     $this->editKeywords($form);
 }
Example #2
0
 public function updateKeywords(array $keywords)
 {
     global $ilUser;
     // language is not "used" anywhere
     $ulang = $ilUser->getLanguage();
     $keywords = array($ulang => $keywords);
     include_once "./Services/MetaData/classes/class.ilMDKeyword.php";
     ilMDKeyword::updateKeywords($this->getMDSection(), $keywords);
 }
 /**
  * update quick edit properties
  */
 function updateQuickEdit()
 {
     include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
     if (!trim($_POST['gen_title'])) {
         ilUtil::sendFailure($this->lng->txt('title_required'));
         $this->listQuickEdit();
         return false;
     }
     // General values
     $this->md_section = $this->md_obj->getGeneral();
     $this->md_section->setTitle(ilUtil::stripSlashes($_POST['gen_title']));
     //		$this->md_section->setTitleLanguage(new ilMDLanguageItem($_POST['gen_title_language']));
     $this->md_section->update();
     // Language
     if (is_array($_POST['gen_language'])) {
         foreach ($_POST['gen_language'] as $id => $data) {
             if ($id > 0) {
                 $md_lan = $this->md_section->getLanguage($id);
                 $md_lan->setLanguage(new ilMDLanguageItem($data['language']));
                 $md_lan->update();
             } else {
                 $md_lan = $this->md_section->addLanguage();
                 $md_lan->setLanguage(new ilMDLanguageItem($data['language']));
                 $md_lan->save();
             }
         }
     }
     // Description
     if (is_array($_POST['gen_description'])) {
         foreach ($_POST['gen_description'] as $id => $data) {
             $md_des = $this->md_section->getDescription($id);
             $md_des->setDescription(ilUtil::stripSlashes($data['description']));
             //				$md_des->setDescriptionLanguage(new ilMDLanguageItem($data['language']));
             $md_des->update();
         }
     }
     // Keyword
     if (is_array($_POST["keywords"]["value"])) {
         include_once "./Services/MetaData/classes/class.ilMDKeyword.php";
         ilMDKeyword::updateKeywords($this->md_section, $_POST["keywords"]["value"]);
     }
     $this->callListeners('General');
     // Copyright
     //if($_POST['copyright_id'] or $_POST['rights_copyright'])
     if ($_POST['copyright']['sel'] || $_POST['copyright']['ta']) {
         if (!is_object($this->md_section = $this->md_obj->getRights())) {
             $this->md_section = $this->md_obj->addRights();
             $this->md_section->save();
         }
         if ($_POST['copyright']['sel']) {
             $this->md_section->setCopyrightAndOtherRestrictions("Yes");
             $this->md_section->setDescription('il_copyright_entry__' . IL_INST_ID . '__' . (int) $_POST['copyright']['sel']);
         } else {
             $this->md_section->setCopyrightAndOtherRestrictions("Yes");
             $this->md_section->setDescription(ilUtil::stripSlashes($_POST['copyright']['ta']));
         }
         $this->md_section->update();
     } else {
         if (is_object($this->md_section = $this->md_obj->getRights())) {
             $this->md_section->setCopyrightAndOtherRestrictions("No");
             $this->md_section->setDescription("");
             $this->md_section->update();
         }
     }
     $this->callListeners('Rights');
     //Educational...
     // Typical Learning Time
     if ($_POST['tlt']['mo'] or $_POST['tlt']['d'] or $_POST["tlt"]['h'] or $_POST['tlt']['m'] or $_POST['tlt']['s']) {
         if (!is_object($this->md_section = $this->md_obj->getEducational())) {
             $this->md_section = $this->md_obj->addEducational();
             $this->md_section->save();
         }
         $this->md_section->setPhysicalTypicalLearningTime((int) $_POST['tlt']['mo'], (int) $_POST['tlt']['d'], (int) $_POST['tlt']['h'], (int) $_POST['tlt']['m'], (int) $_POST['tlt']['s']);
         $this->md_section->update();
     } else {
         if (is_object($this->md_section = $this->md_obj->getEducational())) {
             $this->md_section->setPhysicalTypicalLearningTime(0, 0, 0, 0, 0);
             $this->md_section->update();
         }
     }
     $this->callListeners('Educational');
     //Lifecycle...
     // Authors
     if ($_POST["life_authors"] != "") {
         if (!is_object($this->md_section = $this->md_obj->getLifecycle())) {
             $this->md_section = $this->md_obj->addLifecycle();
             $this->md_section->save();
         }
         // determine all entered authors
         $auth_arr = explode($this->md_settings->getDelimiter(), $_POST["life_authors"]);
         for ($i = 0; $i < count($auth_arr); $i++) {
             $auth_arr[$i] = trim($auth_arr[$i]);
         }
         $md_con_author = "";
         // update existing author entries (delete if not entered)
         foreach ($ids = $this->md_section->getContributeIds() as $con_id) {
             $md_con = $this->md_section->getContribute($con_id);
             if ($md_con->getRole() == "Author") {
                 foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                     $md_ent = $md_con->getEntity($ent_id);
                     // entered author already exists
                     if (in_array($md_ent->getEntity(), $auth_arr)) {
                         unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
                     } else {
                         $md_ent->delete();
                     }
                 }
                 $md_con_author = $md_con;
             }
         }
         // insert enterd, but not existing authors
         if (count($auth_arr) > 0) {
             if (!is_object($md_con_author)) {
                 $md_con_author = $this->md_section->addContribute();
                 $md_con_author->setRole("Author");
                 $md_con_author->save();
             }
             foreach ($auth_arr as $auth) {
                 $md_ent = $md_con_author->addEntity();
                 $md_ent->setEntity(ilUtil::stripSlashes($auth));
                 $md_ent->save();
             }
         }
     } else {
         if (is_object($this->md_section = $this->md_obj->getLifecycle())) {
             foreach ($ids = $this->md_section->getContributeIds() as $con_id) {
                 $md_con = $this->md_section->getContribute($con_id);
                 if ($md_con->getRole() == "Author") {
                     $md_con->delete();
                 }
             }
         }
     }
     $this->callListeners('Lifecycle');
     // Redirect here to read new title and description
     // Otherwise ('Lifecycle' 'technical' ...) simply call listSection()
     ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
     $this->ctrl->redirect($this, 'listSection');
 }