ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAdvancedMDFieldDefinitionSelect Class Reference

AMD field type select. More...

+ Inheritance diagram for ilAdvancedMDFieldDefinitionSelect:
+ Collaboration diagram for ilAdvancedMDFieldDefinitionSelect:

Public Member Functions

 getType ()
 Get type.
 setOptions (array $a_values=null)
 Set options.
 getOptions ()
 Get options.
 getFieldDefinitionForTableGUI ()
 Parse properties for table gui.
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, $a_disabled=false)
 Add input elements to definition form.
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form)
 Import custom post values from definition form.
 importDefinitionFormPostValuesNeedsConfirmation ()
 prepareCustomDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 update ()
 Update field entry.
 importXMLProperty ($a_key, $a_value)
 Import property from XML.
 getValueForXML (ilADT $element)
 Parse ADT value for xml (export)
 importValueFromXML ($a_cdata)
 Import value from xml.
- Public Member Functions inherited from ilAdvancedMDFieldDefinition
 __construct ($a_field_id=null)
 Constructor.
 getTypeTitle ()
 Get type title (lang id)
 getADTDefinition ()
 Get ADT definition instance.
 getADT ()
 Get ADT instance.
 getFieldId ()
 Get field_id.
 setRecordId ($a_id)
 Set record id.
 getRecordId ()
 Get record id.
 setImportId ($a_id_string)
 Set import id.
 getImportId ()
 Get import id.
 setPosition ($a_pos)
 Set position.
 getPosition ()
 Get position.
 setTitle ($a_title)
 Get title.
 getTitle ()
 Get title.
 setDescription ($a_desc)
 Set description.
 getDescription ()
 Get description.
 setSearchable ($a_status)
 Toggle searchable.
 isSearchable ()
 Is searchable.
 setRequired ($a_status)
 Toggle required.
 isRequired ()
 Is required field.
 addToFieldDefinitionForm (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
 Add input elements to definition form.
 importDefinitionFormPostValues (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
 Import post values from definition form.
 prepareDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 save ()
 Create new field entry.
 delete ()
 Delete field entry.
 toXML (ilXmlWriter $a_writer)
 To Xml.
 importFromECS ($a_ecs_type, $a_value, $a_sub_id)
 Import meta data from ECS.
 prepareElementForEditor (ilADTFormBridge $a_bridge)
 Prepare editor form elements.
 getSearchQueryParserValue (ilADTSearchBridge $a_adt_search)
 Get value for search query parser.
 getSearchValueSerialized (ilADTSearchBridge $a_adt_search)
 Get value for search persistence.
 setSearchValueSerialized (ilADTSearchBridge $a_adt_search, $a_value)
 Set value from search persistence.
 searchSubObjects (ilADTSearchBridge $a_adt_search, $a_obj_id, $sub_obj_type)
 searchObjects (ilADTSearchBridge $a_adt_search, ilQueryParser $a_parser, array $a_object_types, $a_locate, $a_search_type)
 Search objects.
 getLuceneSearchString ($a_value)
 Get search string in lucene syntax.
 prepareElementForSearch (ilADTSearchBridge $a_bridge)
 Prepare search form elements.

Protected Member Functions

 initADTDefinition ()
 Init adt instance.
 importFieldDefinition (array $a_def)
 Import (type-specific) field definition from DB.
 getFieldDefinition ()
 Get (type-specific) field definition.
 buildConfirmedObjects (ilPropertyFormGUI $a_form)
 Process custom post values from definition form.
 addPropertiesToXML (ilXmlWriter $a_writer)
 Add (type-specific) properties to xml export.
- Protected Member Functions inherited from ilAdvancedMDFieldDefinition
 init ()
 Init properties.
 setADT (ilADT $a_adt)
 Set ADT instance.
 setFieldId ($a_id)
 Set field_id.
 getLastPosition ()
 Get last position of record.
 generateImportId ($a_field_id)
 Generate unique record id.
 getDBProperties ()
 Get all definition properties for DB.
 import (array $a_data)
 Import from DB.
 read ($a_field_id)
 Read field definition.
 parseSearchObjects (array $a_records, array $a_object_types)
 Add object-data needed for global search to AMD search results.

Protected Attributes

 $options = array()
 $confirm_objects
 $confirmed_objects
- Protected Attributes inherited from ilAdvancedMDFieldDefinition
 $field_id
 $record_id
 $import_id
 $position
 $title
 $description
 $searchable
 $required
 $adt_def
 $adt

Additional Inherited Members

- Static Public Member Functions inherited from ilAdvancedMDFieldDefinition
static getInstance ($a_field_id, $a_type=null)
 Get definition instance by type.
static getInstanceByTypeString ($a_type)
 Get instance by type string (used by import)
static getInstancesByRecordId ($a_record_id, $a_only_searchable=false)
 Get definitions by record id.
static getInstancesByObjType ($a_obj_type, $a_active_only=true)
static getInstanceByImportId ($a_import_id)
 Get definition instance by import id.
static getSearchableDefinitionIds ()
 Get searchable definition ids (performance is key)
static getADTGroupForDefinitions (array $a_defs)
 Init ADTGroup for definitions.
static getValidTypes ()
 Get all valid types.
static isValidType ($a_type)
 Is given type valid.
- Data Fields inherited from ilAdvancedMDFieldDefinition
const TYPE_SELECT = 1
const TYPE_TEXT = 2
const TYPE_DATE = 3
const TYPE_DATETIME = 4
const TYPE_INTEGER = 5
const TYPE_FLOAT = 6
const TYPE_LOCATION = 7
const TYPE_SELECT_MULTI = 8
- Static Protected Member Functions inherited from ilAdvancedMDFieldDefinition
static getTypeString ($a_type)
 Get type string.

Detailed Description

AMD field type select.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 14 of file class.ilAdvancedMDFieldDefinitionSelect.php.

Member Function Documentation

ilAdvancedMDFieldDefinitionSelect::addCustomFieldToDefinitionForm ( ilPropertyFormGUI  $a_form,
  $a_disabled = false 
)

Add input elements to definition form.

Parameters
ilPropertyFormGUI$a_form
bool$a_disabled

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 112 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $lng, $options, ilPropertyFormGUI\addItem(), getOptions(), and ilFormPropertyGUI\setRequired().

{
global $lng;
$field = new ilTextInputGUI($lng->txt("options"), "opts");
$field->setRequired(true);
$field->setMulti(true);
$field->setMaxLength(255); // :TODO:
$a_form->addItem($field);
$options = $this->getOptions();
{
$field->setMultiValues($options);
$field->setValue(array_shift($options));
}
if($a_disabled)
{
$field->setDisabled(true);
}
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::addPropertiesToXML ( ilXmlWriter  $a_writer)
protected

Add (type-specific) properties to xml export.

Parameters
ilXmlWriter$a_writer

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 357 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References getOptions(), and ilXmlWriter\xmlElement().

{
foreach($this->getOptions() as $value)
{
$a_writer->xmlElement('FieldValue',null,$value);
}
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::buildConfirmedObjects ( ilPropertyFormGUI  $a_form)
protected

Process custom post values from definition form.

Parameters
ilPropertyFormGUI$a_form

Definition at line 140 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $res, ilAdvancedMDFieldDefinition\getFieldId(), and ilPropertyFormGUI\getInput().

Referenced by ilAdvancedMDFieldDefinitionSelectMulti\importCustomDefinitionFormPostValues(), and importCustomDefinitionFormPostValues().

{
// #15719
$recipes = $a_form->getInput("conf_det");
if(is_array($recipes[$this->getFieldId()]))
{
$recipes = $recipes[$this->getFieldId()];
$sum = $a_form->getInput("conf_det_act");
$sum = $sum[$this->getFieldId()];
$sgl = $a_form->getInput("conf");
$sgl = $sgl[$this->getFieldId()];
$res = array();
foreach($recipes as $old_option => $recipe)
{
$sum_act = $sum[$old_option];
$sgl_act = $sgl[$old_option];
if($recipe == "sum")
{
foreach(array_keys($sgl_act) as $obj_idx)
{
$res[$old_option][$obj_idx] = $sum_act;
}
}
else
{
$res[$old_option] = $sgl_act;
}
}
return $res;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDFieldDefinitionSelect::getFieldDefinition ( )
protected

Get (type-specific) field definition.

Returns
array

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 94 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $options.

{
}
ilAdvancedMDFieldDefinitionSelect::getFieldDefinitionForTableGUI ( )

Parse properties for table gui.

Returns
array

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 99 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $lng, and getOptions().

{
global $lng;
return array($lng->txt("options") => implode(",", $this->getOptions()));
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::getType ( )

Get type.

Returns
int

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionSelectMulti.

Definition at line 25 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\TYPE_SELECT.

{
}
ilAdvancedMDFieldDefinitionSelect::getValueForXML ( ilADT  $element)

Parse ADT value for xml (export)

Parameters
ilADT$element
Returns
string

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionSelectMulti.

Definition at line 375 of file class.ilAdvancedMDFieldDefinitionSelect.php.

{
return $element->getSelection();
}
ilAdvancedMDFieldDefinitionSelect::importCustomDefinitionFormPostValues ( ilPropertyFormGUI  $a_form)

Import custom post values from definition form.

Parameters
ilPropertyFormGUI$a_form

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionSelectMulti.

Definition at line 180 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References buildConfirmedObjects(), ilAdvancedMDFieldDefinition\getFieldId(), ilPropertyFormGUI\getInput(), getOptions(), ilADTFactory\initActiveRecordByType(), ilADTActiveRecordByType\readByPrimary(), setOptions(), and ilADTActiveRecordByType\SINGLE_COLUMN_NAME.

{
$old = $this->getOptions();
$new = $a_form->getInput("opts");
$missing = array_diff($old, $new);
if(sizeof($missing))
{
$this->confirmed_objects = $this->buildConfirmedObjects($a_form);
if(!is_array($this->confirmed_objects))
{
$primary = array(
"field_id" => array("integer", $this->getFieldId()),
);
$in_use = ilADTActiveRecordByType::readByPrimary("adv_md_values", $primary, "Enum");
if($in_use)
{
$this->confirm_objects = array();
foreach($in_use as $item)
{
$this->confirm_objects[$item[ilADTActiveRecordByType::SINGLE_COLUMN_NAME]][] = array($item["obj_id"], $item["sub_type"], $item["sub_id"]);
}
}
}
}
$this->setOptions($new);
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::importDefinitionFormPostValuesNeedsConfirmation ( )

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 211 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $confirm_objects.

{
return sizeof($this->confirm_objects);
}
ilAdvancedMDFieldDefinitionSelect::importFieldDefinition ( array  $a_def)
protected

Import (type-specific) field definition from DB.

Parameters
array$a_def

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 89 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References setOptions().

{
$this->setOptions($a_def);
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::importValueFromXML (   $a_cdata)

Import value from xml.

Parameters
string$a_cdata

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionSelectMulti.

Definition at line 380 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\getADT().

{
$this->getADT()->setSelection($a_cdata);
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::importXMLProperty (   $a_key,
  $a_value 
)

Import property from XML.

Parameters
string$a_key
string$a_value

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 365 of file class.ilAdvancedMDFieldDefinitionSelect.php.

{
$this->options[] = $a_value;
}
ilAdvancedMDFieldDefinitionSelect::initADTDefinition ( )
protected

Init adt instance.

Returns
ilADTDefinition

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionSelectMulti.

Definition at line 35 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $options, ilAdvancedMDFieldDefinition\getInstance(), and getOptions().

{
$def = ilADTFactory::getInstance()->getDefinitionInstanceByType("Enum");
$def->setNumeric(false);
$options = $this->getOptions();
$def->setOptions(array_combine($options, $options));
return $def;
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::prepareCustomDefinitionFormConfirmation ( ilPropertyFormGUI  $a_form)

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 216 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $lng, $options, ilAdvancedMDFieldDefinition\$title, ilObject\_lookupType(), ilPropertyFormGUI\addItem(), ilPropertyFormGUI\getInput(), and ilPropertyFormGUI\getItemByPostVar().

{
global $lng, $objDefinition;
$a_form->getItemByPostVar("opts")->setDisabled(true);
if(sizeof($this->confirm_objects))
{
$new_options = $a_form->getInput("opts");
$sec = new ilFormSectionHeaderGUI();
$sec->setTitle($lng->txt("md_adv_confirm_definition_select_section"));
$a_form->addItem($sec);
foreach($this->confirm_objects as $old_option => $items)
{
$details = new ilRadioGroupInputGUI($lng->txt("md_adv_confirm_definition_select_option").': "'.$old_option.'"', "conf_det[".$this->getFieldId()."][".$old_option."]");
$details->setRequired(true);
$details->setValue("sum");
$a_form->addItem($details);
$sum = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_all"), "sum");
$details->addOption($sum);
$sel = new ilSelectInputGUI($lng->txt("md_adv_confirm_definition_select_option_all_action"),
"conf_det_act[".$this->getFieldId()."][".$old_option."]");
$options = array(""=>$lng->txt("md_adv_confirm_definition_select_option_remove"));
foreach($new_options as $new_option)
{
$options[$new_option] = $lng->txt("md_adv_confirm_definition_select_option_overwrite").': "'.$new_option.'"';
}
$sel->setOptions($options);
$sum->addSubItem($sel);
$single = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_single"), "sgl");
$details->addOption($single);
foreach($items as $item)
{
$obj_id = $item[0];
$sub_type = $item[1];
$sub_id = $item[2];
$item_id = $obj_id."_".$sub_type."_".$sub_id;
$type = ilObject::_lookupType($obj_id);
$type_title = $lng->txt("obj_".$type);
$title = ' "'.ilObject::_lookupTitle($obj_id).'"';
if($sub_id)
{
$class = "ilObj".$objDefinition->getClassName($type);
$class_path = $objDefinition->getLocation($type);
include_once $class_path."/class.".$class.".php";
if(class_implements($class, ilAdvancedMetaDataSubItem))
{
$sub_title = $class::getAdvMDSubItemTitle($obj_id, $sub_type, $sub_id);
if($sub_title)
{
$title .= ' ('.$sub_title.')';
}
}
}
$sel = new ilSelectInputGUI($type_title.' '.$title,
"conf[".$this->getFieldId()."][".$old_option."][".$item_id."]");
$options = array(""=>$lng->txt("md_adv_confirm_definition_select_option_remove"));
foreach($new_options as $new_option)
{
$options[$new_option] = $lng->txt("md_adv_confirm_definition_select_option_overwrite").': "'.$new_option.'"';
}
$sel->setOptions($options);
$single->addSubItem($sel);
}
}
}
}

+ Here is the call graph for this function:

ilAdvancedMDFieldDefinitionSelect::setOptions ( array  $a_values = null)

Set options.

Parameters
array$a_values

Definition at line 56 of file class.ilAdvancedMDFieldDefinitionSelect.php.

Referenced by ilAdvancedMDFieldDefinitionSelectMulti\importCustomDefinitionFormPostValues(), importCustomDefinitionFormPostValues(), and importFieldDefinition().

{
if($a_values !== null)
{
foreach($a_values as $idx => $value)
{
$a_values[$idx] = trim($value);
if(!$a_values[$idx])
{
unset($a_values[$idx]);
}
}
$a_values = array_unique($a_values);
// sort($a_values);
}
$this->options = $a_values;
}

+ Here is the caller graph for this function:

ilAdvancedMDFieldDefinitionSelect::update ( )

Update field entry.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionSelectMulti.

Definition at line 302 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilADTActiveRecordByType\deleteByPrimary(), ilAdvancedMDFieldDefinition\getFieldId(), ilADTFactory\initActiveRecordByType(), ilPCAMDPageList\migrateField(), and ilADTActiveRecordByType\writeByPrimary().

{
if(sizeof($this->confirmed_objects))
{
foreach($this->confirmed_objects as $old_option => $item_ids)
{
foreach($item_ids as $item => $new_option)
{
$item = explode("_", $item);
$obj_id = $item[0];
$sub_type = $item[1];
$sub_id = $item[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, "Enum");
}
else
{
// update 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::writeByPrimary("adv_md_values", $primary, "Enum", $new_option);
}
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);
}
}
}
}
}

+ Here is the call graph for this function:

Field Documentation

ilAdvancedMDFieldDefinitionSelect::$confirm_objects
protected
ilAdvancedMDFieldDefinitionSelect::$confirmed_objects
protected

Definition at line 18 of file class.ilAdvancedMDFieldDefinitionSelect.php.


The documentation for this class was generated from the following file: