protected function setDefinition(ilADTDefinition $a_adt_def)
 {
     if ($this->isValidADTDefinition($a_adt_def)) {
         $this->adt = ilADTFactory::getInstance()->getInstanceByDefinition($a_adt_def);
         return;
     }
     throw new Exception('ilADTSearchBridge type mismatch.');
 }
 protected function initADTDefinition()
 {
     $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("Integer");
     $def->setMin($this->getMin());
     $def->setMax($this->getMax());
     $def->setSuffix($this->getSuffix());
     return $def;
 }
 protected function initADTDefinition()
 {
     $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("Enum");
     $def->setNumeric(false);
     $options = $this->getOptions();
     $def->setOptions(array_combine($options, $options));
     return $def;
 }
 public function update()
 {
     if (sizeof($this->confirmed_objects)) {
         // we need the "old" options for the search
         $def = $this->getADTDefinition();
         $def = clone $def;
         $def->setOptions(array_combine($this->old_options, $this->old_options));
         $search = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($def, false, false);
         ilADTFactory::initActiveRecordByType();
         foreach ($this->confirmed_objects as $old_option => $item_ids) {
             // get complete old values
             $old_values = array();
             foreach ($this->findBySingleValue($search, $old_option) as $item) {
                 $old_values[$item[0] . "_" . $item[1] . "_" . $item[2]] = $item[3];
             }
             foreach ($item_ids as $item => $new_option) {
                 $parts = explode("_", $item);
                 $obj_id = $parts[0];
                 $sub_type = $parts[1];
                 $sub_id = $parts[2];
                 if (!$new_option) {
                     // remove existing value
                     $primary = array("obj_id" => array("integer", $obj_id), "sub_type" => array("text", $sub_type), "sub_id" => array("integer", $sub_id), "field_id" => array("integer", $this->getFieldId()));
                     ilADTActiveRecordByType::deleteByPrimary("adv_md_values", $primary, "MultiEnum");
                 } else {
                     // update existing value (with changed option)
                     if (isset($old_values[$item])) {
                         // find changed option in old value
                         $old_value = explode(ilADTMultiEnumDBBridge::SEPARATOR, $old_values[$item]);
                         // remove separators
                         array_shift($old_value);
                         array_pop($old_value);
                         $old_idx = array_keys($old_value, $old_option);
                         if (sizeof($old_idx)) {
                             // switch option
                             $old_idx = array_pop($old_idx);
                             $old_value[$old_idx] = $new_option;
                             $new_value = array_unique($old_value);
                             // add separators
                             $new_value = ilADTMultiEnumDBBridge::SEPARATOR . implode(ilADTMultiEnumDBBridge::SEPARATOR, $new_value) . ilADTMultiEnumDBBridge::SEPARATOR;
                             $primary = array("obj_id" => array("integer", $obj_id), "sub_type" => array("text", $sub_type), "sub_id" => array("integer", $sub_id), "field_id" => array("integer", $this->getFieldId()));
                             ilADTActiveRecordByType::writeByPrimary("adv_md_values", $primary, "MultiEnum", $new_value);
                         }
                     }
                 }
                 if ($sub_type == "wpg") {
                     // #15763 - adapt advmd page lists
                     include_once "Modules/Wiki/classes/class.ilPCAMDPageList.php";
                     ilPCAMDPageList::migrateField($obj_id, $this->getFieldId(), $old_option, $new_option, true);
                 }
             }
         }
         $this->confirmed_objects = array();
     }
     parent::update();
 }
 protected function initADTDefinition()
 {
     $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("Text");
     $max = $this->getMaxLength();
     if (is_numeric($max)) {
         $def->setMaxLength($max);
     }
     // multi-line is presentation property
     return $def;
 }
 protected function initADTDefinition()
 {
     $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("MultiEnum");
     $def->setNumeric(false);
     $options = $this->getOptions();
     $def->setOptions(array_combine($options, $options));
     // see ilAdvancedMDValues::getActiveRecord()
     // using ilADTMultiEnumDBBridge::setFakeSingle()
     return $def;
 }
 protected function prepareElements()
 {
     if (sizeof($this->elements)) {
         return;
     }
     $this->elements = array();
     $factory = ilADTFactory::getInstance();
     // convert ADTs to presentation bridges
     foreach ($this->getADT()->getElements() as $name => $element) {
         $this->elements[$name] = $factory->getPresentationBridgeForInstance($element);
     }
 }
 protected function convertADTDefinitionToMulti(ilADTDefinition $a_adt_def)
 {
     if ($a_adt_def->getType() == "Enum") {
         $this->multi_source = false;
         $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("MultiEnum");
         $def->setNumeric($a_adt_def->isNumeric());
         $def->setOptions($a_adt_def->getOptions());
         return $def;
     } else {
         $this->multi_source = true;
         return $a_adt_def;
     }
 }
 protected function prepareElements()
 {
     if (sizeof($this->elements)) {
         return;
     }
     $this->elements = array();
     $factory = ilADTFactory::getInstance();
     // convert ADTs to DB bridges
     foreach ($this->getADT()->getElements() as $name => $element) {
         $this->elements[$name] = $factory->getDBBridgeForInstance($element);
         $this->elements[$name]->setElementId($name);
         $this->elements[$name]->setTable($this->getTable());
         $this->elements[$name]->setPrimary($this->getPrimary());
     }
 }
Beispiel #10
0
 protected function initProperties()
 {
     global $lng;
     // this could be generated from XML or code comments or whatever
     include_once "Services/ADT/classes/class.ilADTFactory.php";
     $factory = ilADTFactory::getInstance();
     $properties_def = $factory->getDefinitionInstanceByType("Group");
     $name = $factory->getDefinitionInstanceByType("Text");
     $name->setMaxLength(255);
     $properties_def->addElement("name", $name);
     $status = $factory->getDefinitionInstanceByType("Boolean");
     $properties_def->addElement("active", $status);
     // example options from ilLanguage
     $lng->loadLanguageModule("meta");
     $options = array();
     foreach ($lng->getInstalledLanguages() as $lang) {
         $options[$lang] = $lng->txt("meta_l_" . $lang);
     }
     $lang = $factory->getDefinitionInstanceByType("Enum");
     $lang->setNumeric(false);
     $lang->setOptions($options);
     $properties_def->addElement("lang", $lang);
     $age = $factory->getDefinitionInstanceByType("Integer");
     $age->setMin(0);
     $age->setMax(120);
     $properties_def->addElement("age", $age);
     $weight = $factory->getDefinitionInstanceByType("Float");
     $weight->setMin(0);
     $weight->setMax(500);
     $properties_def->addElement("weight", $weight);
     // null?
     $home = $factory->getDefinitionInstanceByType("Location");
     $properties_def->addElement("home", $home);
     $tags = $factory->getDefinitionInstanceByType("MultiText");
     $tags->setMaxLength(255);
     $tags->setMaxSize(5);
     $properties_def->addElement("tags", $tags);
     $options = array(self::INTERESTS_NONE => $lng->txt("test_interests_none"), self::INTERESTS_LANGUAGES => $lng->txt("test_interests_languages"), self::INTERESTS_IT => $lng->txt("test_interests_it"));
     $intr = $factory->getDefinitionInstanceByType("MultiEnum");
     $intr->setOptions($options);
     $properties_def->addElement("interests", $intr);
     $date = $factory->getDefinitionInstanceByType("Date");
     $properties_def->addElement("entry_date", $date);
     $dt = $factory->getDefinitionInstanceByType("DateTime");
     $properties_def->addElement("last_login", $dt);
     // convert ADT definitions to proper ADTs
     return $factory->getInstanceByDefinition($properties_def);
 }
 /**
  * Init ADT-based form
  * 
  * @return ilADTGroupFormBridge $a_form
  */
 protected function initForm()
 {
     global $tpl, $lng, $ilCtrl;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this->gui, "updateAction"));
     $adt_form = ilADTFactory::getInstance()->getFormBridgeForInstance($this->object->getProperties());
     // has to be done BEFORE prepareFormElements() ...
     $adt_form->setForm($form);
     $this->prepareFormElements($adt_form);
     $adt_form->addToForm();
     $adt_form->addJS($tpl);
     // :TODO:
     $form->addCommandButton("updateAction", $lng->txt("save"));
     return $adt_form;
 }
Beispiel #12
0
 protected function addElement($a_name, ilADTDefinition $a_def)
 {
     $this->elements[$a_name] = ilADTFactory::getInstance()->getInstanceByDefinition($a_def);
 }
 /**
  * Fill data section
  */
 function fillDataSection()
 {
     global $lng;
     $btpl = new ilTemplate("tpl.wiki_advmd_block.html", true, true, "Modules/Wiki");
     // see ilAdvancedMDRecordGUI::parseInfoPage()
     $old_dt = ilDatePresentation::useRelativeDates();
     ilDatePresentation::setUseRelativeDates(false);
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once 'Services/ADT/classes/class.ilADTFactory.php';
     $values = new ilAdvancedMDValues($this->record->getRecordId(), $this->obj_id, "wpg", $this->page_id);
     // this correctly binds group and definitions
     $values->read();
     $defs = $values->getDefinitions();
     foreach ($values->getADTGroup()->getElements() as $element_id => $element) {
         $btpl->setCurrentBlock("item");
         $btpl->setVariable("CAPTION", $defs[$element_id]->getTitle());
         if ($element->isNull()) {
             $value = "-";
         } else {
             $value = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element);
             if ($element instanceof ilADTLocation) {
                 $value->setSize("100%", "200px");
             }
             $value = $value->getHTML();
         }
         $btpl->setVariable("VALUE", $value);
         $btpl->parseCurrentBlock();
     }
     /*
     if ($this->isHidden())
     {
     	$btpl->setVariable("HIDDEN_INFO", $lng->txt("wiki_adv_md_hidden"));			
     }
     */
     $this->setDataSection($btpl->get());
     ilDatePresentation::setUseRelativeDates($old_dt);
     return;
 }
 protected function initADTDefinition()
 {
     return ilADTFactory::getInstance()->getDefinitionInstanceByType("Date");
 }
 /**
  * special handling for date(time) values 
  * and ECS dates
  * 
  * @param int $a_field_id field ID
  * @param array $a_values_records values
  * @access public
  * @return string parsed value
  * 
  */
 private function parseValue($a_field_id, $a_values_records)
 {
     global $ilUser;
     if ($this->type == 'crs' or $this->type == 'rcrs') {
         // Special handling for ECS fields
         // @FIXME
         /*
         if($a_field_id == self::$mappings->getMappingByECSName('begin') and
         	$end = self::$mappings->getMappingByECSName('end'))
         {
         	// Parse a duration
         	$start = in_array($a_field_id,$this->date_fields) ?
         		new ilDate($a_values[$a_field_id],IL_CAL_UNIX) :
         		new ilDateTime($a_values[$a_field_id],IL_CAL_UNIX);
         	$end = in_array($end,$this->date_fields) ?
         		new ilDate($a_values[$end],IL_CAL_UNIX) :
         		new ilDateTime($a_values[$end],IL_CAL_UNIX);
         	
         	include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
         	$weekday = ilCalendarUtil::_numericDayToString($start->get(IL_CAL_FKT_DATE,'w',$ilUser->getTimeZone()),false);
         	
         	ilDatePresentation::setUseRelativeDates(false);
         	$value = ilDatePresentation::formatPeriod($start,$end);
         	ilDatePresentation::setUseRelativeDates(true);
         	return $weekday.', '.$value;
         }
         */
     }
     foreach ($a_values_records as $a_values) {
         if ($a_values->getADTGroup()->hasElement($a_field_id)) {
             $element = $a_values->getADTGroup()->getElement($a_field_id);
             if (!$element->isNull()) {
                 return ilADTFactory::getInstance()->getPresentationBridgeForInstance($element)->getList();
             }
         }
     }
 }
 public function getFormElement($a_query, $a_field_name, ilPropertyFormGUI $a_form)
 {
     include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
     $a_post_name = 'query[' . $a_field_name . ']';
     switch ($a_field_name) {
         case 'general_offline':
             $offline_options = array('0' => $this->lng->txt('search_any'), self::ONLINE_QUERY => $this->lng->txt('search_option_online'), self::OFFLINE_QUERY => $this->lng->txt('search_option_offline'));
             $offline = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $offline->setOptions($offline_options);
             $offline->setValue($a_query['general_offline']);
             return $offline;
         case 'lom_content':
             $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $text->setSubmitFormOnEnter(true);
             $text->setValue($a_query['lom_content']);
             $text->setSize(30);
             $text->setMaxLength(255);
             return $text;
             // General
         // General
         case 'lom_language':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_language']);
             $select->setOptions(ilMDUtilSelect::_getLanguageSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_keyword':
             $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $text->setSubmitFormOnEnter(true);
             $text->setValue($a_query['lom_keyword']);
             $text->setSize(30);
             $text->setMaxLength(255);
             return $text;
         case 'lom_coverage':
             $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $text->setSubmitFormOnEnter(true);
             $text->setValue($a_query['lom_coverage']);
             $text->setSize(30);
             $text->setMaxLength(255);
             return $text;
         case 'lom_structure':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_structure']);
             $select->setOptions(ilMDUtilSelect::_getStructureSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Lifecycle
         // Lifecycle
         case 'lom_status':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_status']);
             $select->setOptions(ilMDUtilSelect::_getStatusSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_version':
             $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $text->setSubmitFormOnEnter(true);
             $text->setValue($a_query['lom_version']);
             $text->setSize(30);
             $text->setMaxLength(255);
             return $text;
         case 'lom_contribute':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], 'query[' . 'lom_role' . ']');
             $select->setValue($a_query['lom_role']);
             $select->setOptions(ilMDUtilSelect::_getRoleSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             $text = new ilTextInputGUI($this->lng->txt('meta_entry'), 'query[' . 'lom_role_entry' . ']');
             $text->setValue($a_query['lom_role_entry']);
             $text->setSize(30);
             $text->setMaxLength(255);
             $select->addSubItem($text);
             return $select;
             // Technical
         // Technical
         case 'lom_format':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_format']);
             $select->setOptions(ilMDUtilSelect::_getFormatSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_operating_system':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_operating_system']);
             $select->setOptions(ilMDUtilSelect::_getOperatingSystemSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_browser':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_browser']);
             $select->setOptions(ilMDUtilSelect::_getBrowserSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Education
         // Education
         case 'lom_interactivity':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_interactivity']);
             $select->setOptions(ilMDUtilSelect::_getInteractivityTypeSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_resource':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_resource']);
             $select->setOptions(ilMDUtilSelect::_getLearningResourceTypeSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_level':
             $range = new ilCustomInputGUI($this->active_fields[$a_field_name]);
             $html = $this->getRangeSelect($this->lng->txt('from'), ilMDUtilSelect::_getInteractivityLevelSelect($a_query['lom_level_start'], 'query[' . 'lom_level_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), ilMDUtilSelect::_getInteractivityLevelSelect($a_query['lom_level_end'], 'query[' . 'lom_level_end' . ']', array(0 => $this->lng->txt('search_any'))));
             $range->setHTML($html);
             return $range;
         case 'lom_density':
             $range = new ilCustomInputGUI($this->active_fields[$a_field_name]);
             $html = $this->getRangeSelect($this->lng->txt('from'), ilMDUtilSelect::_getSemanticDensitySelect($a_query['lom_density_start'], 'query[' . 'lom_density_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), ilMDUtilSelect::_getSemanticDensitySelect($a_query['lom_density_end'], 'query[' . 'lom_density_end' . ']', array(0 => $this->lng->txt('search_any'))));
             $range->setHTML($html);
             return $range;
         case 'lom_user_role':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_user_role']);
             $select->setOptions(ilMDUtilSelect::_getIntendedEndUserRoleSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_context':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_context']);
             $select->setOptions(ilMDUtilSelect::_getContextSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_difficulty':
             $range = new ilCustomInputGUI($this->active_fields[$a_field_name]);
             $html = $this->getRangeSelect($this->lng->txt('from'), ilMDUtilSelect::_getDifficultySelect($a_query['lom_difficulty_start'], 'query[' . 'lom_difficulty_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), ilMDUtilSelect::_getDifficultySelect($a_query['lom_difficulty_end'], 'query[' . 'lom_difficulty_end' . ']', array(0 => $this->lng->txt('search_any'))));
             $range->setHTML($html);
             return $range;
             // Rights
         // Rights
         case 'lom_costs':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_costs']);
             $select->setOptions(ilMDUtilSelect::_getCostsSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_copyright':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_copyright']);
             $select->setOptions(ilMDUtilSelect::_getCopyrightAndOtherRestrictionsSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Classification
         // Classification
         case 'lom_purpose':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_purpose']);
             $select->setOptions(ilMDUtilSelect::_getPurposeSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
         case 'lom_taxon':
             $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $text->setSubmitFormOnEnter(true);
             $text->setValue($a_query['lom_taxon']);
             $text->setSize(30);
             $text->setMaxLength(255);
             return $text;
         default:
             if (substr($a_field_name, 0, 3) != 'adv') {
                 break;
             }
             // Advanced meta data
             $field_id = substr($a_field_name, 4);
             include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
             $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
             $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
             $field_form->setForm($a_form);
             $field_form->setElementId($a_post_name);
             $field_form->setTitle($this->active_fields[$a_field_name]);
             $field_form->addToForm();
             // reload search values
             if (isset($a_query[$a_field_name])) {
                 $field_form->importFromPost($a_query);
                 $field_form->validate();
             }
             return;
     }
     return null;
 }
 /**
  * Query data for given object records
  *
  * @param
  * @return
  */
 public static function queryForRecords($a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, array $a_amet_filter = null)
 {
     $result = array();
     if (!is_array($a_obj_id)) {
         $a_obj_id = array($a_obj_id);
     }
     $sub_obj_ids = array();
     foreach ($a_records as $rec) {
         $sub_obj_ids[] = $rec[$a_obj_subid_key];
     }
     // preload adv data for object id(s)
     ilADTFactory::getInstance()->initActiveRecordByType();
     ilADTActiveRecordByType::preloadByPrimary("adv_md_values", array("obj_id" => array("integer", $a_obj_id), "sub_type" => array("text", $a_subtype), "sub_id" => array("integer", $sub_obj_ids)));
     $record_groups = array();
     foreach ($a_records as $rec) {
         $obj_id = $rec[$a_obj_id_key];
         $sub_id = $rec[$a_obj_subid_key];
         // only active amet records for glossary
         foreach (ilAdvancedMDRecord::_getSelectedRecordsByObject(ilObject::_lookupType($obj_id), $obj_id, $a_subtype) as $adv_record) {
             $record_id = $adv_record->getRecordId();
             if (!isset($record_groups[$record_id])) {
                 $defs = ilAdvancedMDFieldDefinition::getInstancesByRecordId($record_id);
                 $record_groups[$record_id] = ilAdvancedMDFieldDefinition::getADTGroupForDefinitions($defs);
                 $record_groups[$record_id] = ilADTFactory::getInstance()->getDBBridgeForInstance($record_groups[$record_id]);
                 $record_groups[$record_id]->setTable("adv_md_values");
             }
             // prepare ADT group for record id
             $record_groups[$record_id]->setPrimary(array("obj_id" => array("integer", $obj_id), "sub_type" => array("text", $a_subtype), "sub_id" => array("integer", $sub_id)));
             // multi-enum fakes single in adv md
             foreach ($record_groups[$record_id]->getElements() as $element) {
                 if ($element->getADT()->getType() == "MultiEnum") {
                     $element->setFakeSingle(true);
                 }
             }
             // read (preloaded) data
             $active_record = new ilADTActiveRecordByType($record_groups[$record_id]);
             $active_record->setElementIdColumn("field_id", "integer");
             $active_record->read();
             $adt_group = $record_groups[$record_id]->getADT();
             // filter against amet values
             if ($a_amet_filter) {
                 foreach ($a_amet_filter as $field_id => $element) {
                     if ($adt_group->hasElement($field_id)) {
                         if (!$element->isInCondition($adt_group->getElement($field_id))) {
                             continue 3;
                         }
                     }
                 }
             }
             // add amet values to glossary term record
             foreach ($adt_group->getElements() as $element_id => $element) {
                 if (!$element->isNull()) {
                     // we are reusing the ADT group for all $a_records, so we need to clone
                     $pb = ilADTFactory::getInstance()->getPresentationBridgeForInstance(clone $element);
                     $rec["md_" . $element_id] = $pb->getSortable();
                     $rec["md_" . $element_id . "_presentation"] = $pb;
                 } else {
                     $rec["md_" . $element_id] = null;
                 }
             }
         }
         $results[] = $rec;
     }
     return $results;
 }
 /**
  * Parse property for filter (table)
  *
  * @access private
  * 
  */
 private function parseFilter()
 {
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
     if ($this->getSelectedOnly()) {
         $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject($this->obj_type, $this->obj_id, $this->sub_type);
     } else {
         $recs = ilAdvancedMDRecord::_getActivatedRecordsByObjectType($this->obj_type, $this->sub_type);
     }
     $this->adt_search = array();
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     foreach ($recs as $record_obj) {
         $record_id = $record_obj->getRecordId();
         $defs = ilAdvancedMDFieldDefinition::getInstancesByRecordId($record_id);
         foreach ($defs as $def) {
             // :TODO: not all types supported yet
             if (!in_array($def->getType(), array(ilAdvancedMDFieldDefinition::TYPE_TEXT, ilAdvancedMDFieldDefinition::TYPE_SELECT, ilAdvancedMDFieldDefinition::TYPE_SELECT_MULTI, ilAdvancedMDFieldDefinition::TYPE_DATE, ilAdvancedMDFieldDefinition::TYPE_DATETIME))) {
                 continue;
             }
             /* :TODO:
             			if($this->handleECSDefinitions($def))
              			{
              				continue;
              			}
             			*/
             $this->adt_search[$def->getFieldId()] = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($def->getADTDefinition(), true, false);
             $this->adt_search[$def->getFieldId()]->setTableGUI($this->table_gui);
             $this->adt_search[$def->getFieldId()]->setTitle($def->getTitle());
             $this->adt_search[$def->getFieldId()]->setElementId('md_' . $def->getFieldId());
             $this->adt_search[$def->getFieldId()]->loadFilter();
             $this->adt_search[$def->getFieldId()]->addToForm();
         }
     }
 }
 /**
  * Init active record helper for current table, primary and properties
  * 
  * @return ilADTActiveRecord
  */
 protected function initActiveRecordInstance()
 {
     global $ilDB;
     if (!$this->hasPrimary()) {
         throw new Exception("ilADTBasedObject no primary");
     }
     $factory = ilADTFactory::getInstance();
     $this->adt_db = $factory->getDBBridgeForInstance($this->properties);
     $this->initDBBridge($this->adt_db);
     // use custom error handling
     include_once "Services/ADT/classes/class.ilADTDBException.php";
     $ilDB->exception = "ilADTDBException";
     return $factory->getActiveRecordInstance($this->adt_db);
 }
 protected function findPages($a_list_id)
 {
     global $ilDB;
     $list_values = $this->getFieldValues($a_list_id);
     $wiki_id = $this->getPage()->getWikiId();
     $found_result = array();
     // only search in active fields
     $found_ids = null;
     $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $wiki_id, "wpg");
     foreach ($recs as $record) {
         foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($record->getRecordId(), true) as $field) {
             if (isset($list_values[$field->getFieldId()])) {
                 $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
                 $field->setSearchValueSerialized($field_form, $list_values[$field->getFieldId()]);
                 $found_pages = $field->searchSubObjects($field_form, $wiki_id, "wpg");
                 if (is_array($found_ids)) {
                     $found_ids = array_intersect($found_ids, $found_pages);
                 } else {
                     $found_ids = $found_pages;
                 }
             }
         }
     }
     if (sizeof($found_ids)) {
         $sql = "SELECT id,title FROM il_wiki_page" . " WHERE " . $ilDB->in("id", $found_ids, "", "integer") . " ORDER BY title";
         $set = $ilDB->query($sql);
         while ($row = $ilDB->fetchAssoc($set)) {
             $found_result[$row["id"]] = $row["title"];
         }
     }
     return $found_result;
 }
 /**
  * Get ADT instance
  * 
  * @return ilADT
  */
 public function getADT()
 {
     if (!$this->adt instanceof ilADT) {
         $this->adt = ilADTFactory::getInstance()->getInstanceByDefinition($this->getADTDefinition());
     }
     return $this->adt;
 }
 /**
  * Add Advanced Meta Data Information to the Info Screen
  *
  * @param ilInfoScreenGUI $info
  */
 protected function parseInfoScreen(ilInfoScreenGUI $info)
 {
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
     include_once 'Services/ADT/classes/class.ilADTFactory.php';
     $type = $this->object->getOrgUnitType();
     if (!$type) {
         return;
     }
     $assigned_record_ids = $type->getAssignedAdvancedMDRecordIds();
     foreach (ilAdvancedMDValues::getInstancesForObjectId($this->object->getId(), 'orgu') as $record_id => $a_values) {
         // Skip record ids not assigned to the type
         if (!in_array($record_id, $assigned_record_ids)) {
             continue;
         }
         // Note that we have to do this because with the instances above the sub-type and sub-id are missing...
         $a_values = new ilAdvancedMDValues($record_id, $this->object->getId(), 'orgu_type', $this->object->getOrgUnitTypeId());
         // this correctly binds group and definitions
         $a_values->read();
         $info->addSection(ilAdvancedMDRecord::_lookupTitle($record_id));
         $defs = $a_values->getDefinitions();
         foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) {
             if (!$element->isNull()) {
                 $info->addProperty($defs[$element_id]->getTitle(), ilADTFactory::getInstance()->getPresentationBridgeForInstance($element)->getHTML());
             }
         }
     }
 }
 /**
  * Perform advanced meta data search
  *
  * @access private
  * @param obj result object
  * 
  */
 private function searchAdvancedMD($res)
 {
     $this->initFormSearch();
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     foreach (array_keys($this->options) as $key) {
         if (substr($key, 0, 3) != 'adv') {
             continue;
         }
         // :TODO: ?
         if (!$key) {
             continue;
         }
         $field_id = substr($key, 4);
         $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
         $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
         $field_form->setElementId("query[" . $key . "]");
         $field_form->setForm($this->form);
         // reload search values
         $field_form->importFromPost($this->options);
         $field_form->validate();
         $parser_value = $field->getSearchQueryParserValue($field_form);
         include_once 'Services/Search/classes/class.ilQueryParser.php';
         include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
         $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance(new ilQueryParser($parser_value));
         $adv_md_search->setFilter($this->filter);
         $adv_md_search->setDefinition($field);
         $adv_md_search->setSearchElement($field_form);
         $res_field = $adv_md_search->performSearch();
         if ($res_field instanceof ilSearchResult) {
             $this->__storeEntries($res, $res_field);
         }
     }
 }