ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAdvancedMDValues Class Reference
+ Collaboration diagram for ilAdvancedMDValues:

Public Member Functions

 __construct ($a_record_id, $a_obj_id, $a_sub_type="-", $a_sub_id=0)
 Constructor.
 getDefinitions ()
 Get record field definitions.
 getADTGroup ()
 Init ADT group for current record.
 isDisabled ($a_element_id)
 Is element disabled?
 read ()
 Get record values.
 write (array $a_additional_data=null)
 Write record values.

Static Public Member Functions

static getInstancesForObjectId ($a_obj_id, $a_obj_type=null)
 Get instances for given object id.
static findByObjectId ($a_obj_id)
 Find all entries for object (regardless of sub-type/sub-id)
static _deleteByFieldId ($a_field_id, ilADT $a_adt)
 Delete values by field_id.
static _deleteByObjId ($a_obj_id)
 Delete by objekt id.
static preloadByObjIds (array $a_obj_ids)
 Preload list gui data.
static preloadedRead ($a_type, $a_obj_id)
static _cloneValues ($a_source_id, $a_target_id, $a_sub_type=null, $a_source_sub_id=null, $a_target_sub_id=null)
 Clone Advanced Meta Data.
static _appendXMLByObjId (ilXmlWriter $a_xml_writer, $a_obj_id)
 Get xml of object values.
static queryForRecords ($a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, array $a_amet_filter=null)
 Query data for given object records.

Protected Member Functions

 getActiveRecord ()
 Init ADT DB Bridge (aka active record helper class)

Protected Attributes

 $record_id
 $obj_id
 $sub_id
 $sub_type
 $defs
 $adt_group
 $active_record
 $disabled

Static Protected Attributes

static $preload_obj_records

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 15 of file class.ilAdvancedMDValues.php.

Constructor & Destructor Documentation

ilAdvancedMDValues::__construct (   $a_record_id,
  $a_obj_id,
  $a_sub_type = "-",
  $a_sub_id = 0 
)

Constructor.

Parameters
int$a_record_id
string$a_obj_id
string$a_sub_type
int$a_sub_id
Returns
self

Definition at line 39 of file class.ilAdvancedMDValues.php.

{
$this->record_id = (int)$a_record_id;
$this->obj_id = (int)$a_obj_id;
$this->sub_type = $a_sub_type ? $a_sub_type : "-";
$this->sub_id = (int)$a_sub_id;
}

Member Function Documentation

static ilAdvancedMDValues::_appendXMLByObjId ( ilXmlWriter  $a_xml_writer,
  $a_obj_id 
)
static

Get xml of object values.

Parameters
ilXmlWriter$a_xml_writer
int$a_obj_id

Definition at line 360 of file class.ilAdvancedMDValues.php.

References $defs, ilObject\_lookupType(), preloadByObjIds(), preloadedRead(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by ilCourseXMLWriter\__buildAdvancedMetaData().

{
$a_xml_writer->xmlStartTag('AdvancedMetaData');
self::preloadByObjIds(array($a_obj_id));
$values_records = self::preloadedRead(ilObject::_lookupType($a_obj_id), $a_obj_id);
foreach($values_records as $values_record)
{
$defs = $values_record->getDefinitions();
foreach($values_record->getADTGroup()->getElements() as $element_id => $element)
{
$def = $defs[$element_id];
$value = null;
if(!$element->isNull())
{
$value = $def->getValueForXML($element);
}
$a_xml_writer->xmlElement(
'Value',
array('id' => $def->getImportId()),
$value
);
}
}
$a_xml_writer->xmlEndTag('AdvancedMetaData');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDValues::_cloneValues (   $a_source_id,
  $a_target_id,
  $a_sub_type = null,
  $a_source_sub_id = null,
  $a_target_sub_id = null 
)
static

Clone Advanced Meta Data.

Parameters
intsource obj_id
inttarget obj_id
stringsub_type (both source/target)
intsource sub_id
inttarget sub_id

Definition at line 312 of file class.ilAdvancedMDValues.php.

References $ilLog, ilADTActiveRecordByType\cloneByPrimary(), and ilADTFactory\getInstance().

Referenced by ilObject\cloneObject(), and ilObjWiki\createWikiPage().

{
global $ilLog;
$source_primary = array("obj_id"=>array("integer", $a_source_id));
$target_primary = array("obj_id"=>array("integer", $a_target_id));
// sub-type support
if($a_sub_type &&
$a_source_sub_id &&
$a_target_sub_id)
{
$source_primary["sub_type"] = array("text", $a_sub_type);
$source_primary["sub_id"] = array("integer", $a_source_sub_id);
$target_primary["sub_type"] = array("text", $a_sub_type);
$target_primary["sub_id"] = array("integer", $a_target_sub_id);
}
ilADTFactory::getInstance()->initActiveRecordByType();
"adv_md_values",
array(
"obj_id" => "integer",
"sub_type" => "text",
"sub_id" => "integer",
"field_id" => "integer"
),
$source_primary,
$target_primary,
array("disabled"=>"integer"));
if(!$has_cloned)
{
$ilLog->write(__METHOD__.': No advanced meta data found.');
}
else
{
$ilLog->write(__METHOD__.': Start cloning advanced meta data.');
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDValues::_deleteByFieldId (   $a_field_id,
ilADT  $a_adt 
)
static

Delete values by field_id.

Typically called after deleting a field

Parameters
int$a_field_id
ilADT$a_adt

Definition at line 222 of file class.ilAdvancedMDValues.php.

References ilADTActiveRecordByType\deleteByPrimary(), ilADTFactory\getInstance(), and ilADT\getType().

Referenced by ilAdvancedMDFieldDefinition\delete().

{
ilADTFactory::getInstance()->initActiveRecordByType();
"adv_md_values",
array("field_id"=>array("integer", $a_field_id)),
$a_adt->getType());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDValues::_deleteByObjId (   $a_obj_id)
static

Delete by objekt id.

Parameters
int$a_obj_id

Definition at line 236 of file class.ilAdvancedMDValues.php.

References ilADTActiveRecordByType\deleteByPrimary(), and ilADTFactory\getInstance().

Referenced by ilObject\delete().

{
ilADTFactory::getInstance()->initActiveRecordByType();
"adv_md_values",
array("obj_id"=>array("integer", $a_obj_id)));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDValues::findByObjectId (   $a_obj_id)
static

Find all entries for object (regardless of sub-type/sub-id)

Parameters
int$a_obj_id
Returns
array

Definition at line 152 of file class.ilAdvancedMDValues.php.

References ilADTFactory\initActiveRecordByType(), and ilADTActiveRecordByType\readByPrimary().

Referenced by ilAdvancedMetaDataExporter\getXmlRepresentation().

{
include_once "Services/ADT/classes/class.ilADTFactory.php";
return ilADTActiveRecordByType::readByPrimary("adv_md_values", array("obj_id"=>array("integer", $a_obj_id)));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDValues::getActiveRecord ( )
protected

Init ADT DB Bridge (aka active record helper class)

Returns
ilADTActiveRecordByType

Definition at line 113 of file class.ilAdvancedMDValues.php.

References $active_record, getADTGroup(), and ilADTFactory\getInstance().

Referenced by read(), and write().

{
if(!$this->active_record instanceof ilADTActiveRecordByType)
{
include_once "Services/ADT/classes/class.ilADTFactory.php";
$adt_group_db = $factory->getDBBridgeForInstance($this->getADTGroup());
$primary = array(
"obj_id" => array("integer", $this->obj_id),
"sub_type" => array("text", $this->sub_type),
"sub_id" => array("integer", $this->sub_id)
);
$adt_group_db->setPrimary($primary);
$adt_group_db->setTable("adv_md_values");
// multi-enum fakes single in adv md
foreach($adt_group_db->getElements() as $element)
{
if($element->getADT()->getType() == "MultiEnum")
{
$element->setFakeSingle(true);
}
}
$this->active_record = $factory->getActiveRecordByTypeInstance($adt_group_db);
$this->active_record->setElementIdColumn("field_id", "integer");
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDValues::getADTGroup ( )

Init ADT group for current record.

Returns
ilADTGroup

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

References $adt_group, ilAdvancedMDFieldDefinition\getADTGroupForDefinitions(), and getDefinitions().

Referenced by getActiveRecord().

{
if(!$this->adt_group instanceof ilADTGroup)
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDValues::getDefinitions ( )

Get record field definitions.

Returns
array

Definition at line 85 of file class.ilAdvancedMDValues.php.

References $defs, and ilAdvancedMDFieldDefinition\getInstancesByRecordId().

Referenced by getADTGroup().

{
if(!is_array($this->defs))
{
$this->defs = ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->record_id);
}
return $this->defs;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDValues::getInstancesForObjectId (   $a_obj_id,
  $a_obj_type = null 
)
static

Get instances for given object id.

Parameters
int$a_obj_id
string$a_obj_type
Returns
array

Definition at line 54 of file class.ilAdvancedMDValues.php.

References $ilDB, $query, $res, $row, and ilObject\_lookupType().

Referenced by ilECSUtils\getAdvancedMDValuesForObjId(), ilAdvancedMDValueParser\handlerBeginTag(), ilRemoteObjectBase\importMetadataFromJson(), ilAdvancedMDRecordGUI\parseInfoPage(), and ilObjOrgUnitGUI\parseInfoScreen().

{
global $ilDB;
$res = array();
if(!$a_obj_type)
{
$a_obj_type = ilObject::_lookupType($a_obj_id);
}
// get active records for object type
$query = "SELECT amro.record_id".
" FROM adv_md_record_objs amro".
" JOIN adv_md_record amr ON (amr.record_id = amro.record_id)".
" WHERE active = ".$ilDB->quote(1, "integer").
" AND obj_type = ".$ilDB->quote($a_obj_type, "text");
$set = $ilDB->query($query);
while($row = $ilDB->fetchAssoc($set))
{
$res[$row["record_id"]] = new self($row["record_id"], $a_obj_id);
}
return $res;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDValues::isDisabled (   $a_element_id)

Is element disabled?

Parameters
string$a_element_id
Returns
bool

Definition at line 172 of file class.ilAdvancedMDValues.php.

{
if(is_array($this->disabled))
{
return in_array($a_element_id, $this->disabled);
}
}
static ilAdvancedMDValues::preloadByObjIds ( array  $a_obj_ids)
static

Preload list gui data.

Parameters
array$a_obj_ids

Definition at line 255 of file class.ilAdvancedMDValues.php.

References $ilDB, $query, $row, ilADTFactory\getInstance(), and ilADTActiveRecordByType\preloadByPrimary().

Referenced by _appendXMLByObjId(), and ilObjectListGUIPreloader\preload().

{
global $ilDB;
// preload values
ilADTFactory::getInstance()->initActiveRecordByType();
"adv_md_values",
array("obj_id"=>array("integer", $a_obj_ids)));
// preload record ids for object types
self::$preload_obj_records = array();
// get active records for object types
$query = "SELECT amro.*".
" FROM adv_md_record_objs amro".
" JOIN adv_md_record amr ON (amr.record_id = amro.record_id)".
" WHERE active = ".$ilDB->quote(1, "integer");
$set = $ilDB->query($query);
while($row = $ilDB->fetchAssoc($set))
{
self::$preload_obj_records[$row["obj_type"]][] = $row["record_id"];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDValues::preloadedRead (   $a_type,
  $a_obj_id 
)
static

Definition at line 282 of file class.ilAdvancedMDValues.php.

References $record_id, and $res.

Referenced by _appendXMLByObjId(), and ilAdvancedMDSubstitution\getParsedSubstitutions().

{
$res = array();
if(isset(self::$preload_obj_records[$a_type]))
{
foreach(self::$preload_obj_records[$a_type] as $record_id)
{
$res[$record_id] = new self($record_id, $a_obj_id);
$res[$record_id]->read();
}
}
return $res;
}

+ Here is the caller graph for this function:

static ilAdvancedMDValues::queryForRecords (   $a_obj_id,
  $a_subtype,
  $a_records,
  $a_obj_id_key,
  $a_obj_subid_key,
array  $a_amet_filter = null 
)
static

Query data for given object records.

Parameters
@return

Definition at line 402 of file class.ilAdvancedMDValues.php.

References $active_record, $adt_group, $defs, $obj_id, $record_id, $result, $results, $sub_id, ilAdvancedMDRecord\_getSelectedRecordsByObject(), ilObject\_lookupType(), ilAdvancedMDFieldDefinition\getADTGroupForDefinitions(), ilADTFactory\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), and ilADTActiveRecordByType\preloadByPrimary().

Referenced by ilGlossaryTerm\getTermList().

{
$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();
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
{
$record_id = $adv_record->getRecordId();
if(!isset($record_groups[$record_id]))
{
$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;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDValues::read ( )

Get record values.

Definition at line 188 of file class.ilAdvancedMDValues.php.

References getActiveRecord().

Referenced by ilWikiAdvMetaDataBlockGUI\fillDataSection(), and ilObjOrgUnitGUI\parseInfoScreen().

{
$this->disabled = array();
$tmp = $this->getActiveRecord()->read(true);
if($tmp)
{
foreach($tmp as $element_id => $data)
{
if($data["disabled"])
{
$this->disabled[] = $element_id;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDValues::write ( array  $a_additional_data = null)

Write record values.

Parameters
array$a_additional_data

Definition at line 210 of file class.ilAdvancedMDValues.php.

References getActiveRecord().

{
$this->getActiveRecord()->write($a_additional_data);
}

+ Here is the call graph for this function:

Field Documentation

ilAdvancedMDValues::$active_record
protected

Definition at line 24 of file class.ilAdvancedMDValues.php.

Referenced by getActiveRecord(), and queryForRecords().

ilAdvancedMDValues::$adt_group
protected

Definition at line 23 of file class.ilAdvancedMDValues.php.

Referenced by getADTGroup(), and queryForRecords().

ilAdvancedMDValues::$defs
protected

Definition at line 22 of file class.ilAdvancedMDValues.php.

Referenced by _appendXMLByObjId(), getDefinitions(), and queryForRecords().

ilAdvancedMDValues::$disabled
protected

Definition at line 26 of file class.ilAdvancedMDValues.php.

ilAdvancedMDValues::$obj_id
protected

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

Referenced by queryForRecords().

ilAdvancedMDValues::$preload_obj_records
staticprotected

Definition at line 28 of file class.ilAdvancedMDValues.php.

ilAdvancedMDValues::$record_id
protected

Definition at line 17 of file class.ilAdvancedMDValues.php.

Referenced by preloadedRead(), and queryForRecords().

ilAdvancedMDValues::$sub_id
protected

Definition at line 19 of file class.ilAdvancedMDValues.php.

Referenced by queryForRecords().

ilAdvancedMDValues::$sub_type
protected

Definition at line 20 of file class.ilAdvancedMDValues.php.


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