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

Static Public Member Functions

static _getValuesByObjId ($a_obj_id)
 Get all values of an object.
static _cloneValues ($a_source_id, $a_target_id)
 Clone Advanced Meta Data.
static _appendXMLByObjId (ilXmlWriter $xml_writer, $a_obj_id)
 Get xml of object values.
static _preloadValuesByObjIds ($obj_ids)
 preload object values
static _deleteByFieldId ($a_field_id)
 Delete values by field_id.
static _deleteByObjId ($a_obj_id)
 Delete by objekt id.
static _getValuesByObjIdAndSubtype ($a_obj_id, $a_subtype)
 Get all values of an object per subtype Uses internal cache.
static queryForRecords ($a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, $a_amet_filter="")
 Query data for given object records.

Static Private Attributes

static $cached_values = array()

Detailed Description

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

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

Member Function Documentation

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

Get xml of object values.

public

Parameters
objectinstance of ilXmlWriter
int$a_obj_id

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

References $query, $res, $row, ilAdvancedMDValue\_getInstance(), ilObject\_lookupType(), DB_FETCHMODE_OBJECT, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by ilCourseXMLWriter\__buildAdvancedMetaData().

{
global $ilDB;
$type = ilObject::_lookupType($a_obj_id);
// Get active field_definitions
$query = "SELECT field_id FROM adv_md_record amr ".
"JOIN adv_md_record_objs amro ON amr.record_id = amro.record_id ".
"JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id ".
"WHERE active = 1 ".
"AND obj_type = ".$ilDB->quote($type ,'text')." ";
$xml_writer->xmlStartTag('AdvancedMetaData');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
$value = ilAdvancedMDValue::_getInstance($a_obj_id,$row->field_id);
$value->appendXML($xml_writer);
}
$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 
)
static

Clone Advanced Meta Data.

public

Parameters
intsource obj_id
inttarget obj_id

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

References $ilLog, ilAdvancedMDFieldDefinition\_getActiveDefinitionsByObjType(), and ilObject\_lookupType().

Referenced by ilObject\cloneObject().

{
global $ilLog;
include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
{
$ilLog->write(__METHOD__.': No advanced meta data found.');
return true;
}
$ilLog->write(__METHOD__.': Start cloning advanced meta data.');
foreach(self::_getValuesByObjId($a_source_id) as $field_id => $value)
{
if(!in_array($field_id,$defs))
{
continue;
}
$new_value = new ilAdvancedMDValue($field_id,$a_target_id);
$new_value->setValue($value);
$new_value->save();
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDValues::_deleteByFieldId (   $a_field_id)
static

Delete values by field_id.

Typically called after deleting a field

public

Parameters
intfield id

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

References $query, and $res.

Referenced by ilAdvancedMDFieldDefinition\_deleteByRecordId(), and ilAdvancedMDFieldDefinition\delete().

{
global $ilDB;
$query = "DELETE FROM adv_md_values ".
"WHERE field_id = ".$ilDB->quote($a_field_id ,'integer')." ";
$res = $ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

static ilAdvancedMDValues::_deleteByObjId (   $a_obj_id)
static

Delete by objekt id.

public

Parameters
intobj_id

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

References $query, and $res.

{
global $ilDB;
$query = "DELETE FROM adv_md_values ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
$res = $ilDB->manipulate($query);
}
static ilAdvancedMDValues::_getValuesByObjId (   $a_obj_id)
static

Get all values of an object.

Uses internal cache.

public

Parameters
intobj_id

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

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilECSObjectSettings\addMetadataToJson(), ilECSSettingsGUI\exportImported(), ilECSSettingsGUI\exportReleased(), ilECSReleasedContentTableGUI\fillRow(), ilECSImportedContentTableGUI\fillRow(), and ilAdvancedMDSubstitution\getParsedSubstitutions().

{
global $ilDB;
if(isset(self::$cached_values[$a_obj_id]))
{
return self::$cached_values[$a_obj_id];
}
$query = "SELECT field_id,value FROM adv_md_values ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer');
$res = $ilDB->query($query);
self::$cached_values[$a_obj_id] = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
self::$cached_values[$a_obj_id][$row->field_id] = $row->value;
}
return self::$cached_values[$a_obj_id];
}

+ Here is the caller graph for this function:

static ilAdvancedMDValues::_getValuesByObjIdAndSubtype (   $a_obj_id,
  $a_subtype 
)
static

Get all values of an object per subtype Uses internal cache.

public

Parameters
intobj_id

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

References $result.

Referenced by queryForRecords().

{
global $ilDB;
$result = array();
$set = $ilDB->query($q = "SELECT field_id, value, sub_type, sub_id FROM adv_md_values ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id,'integer')." ".
"AND sub_type = ".$ilDB->quote($a_subtype,'text')
);
while ($rec = $ilDB->fetchAssoc($set))
{
$result[] = $rec;
}
return $result;
}

+ Here is the caller graph for this function:

static ilAdvancedMDValues::_preloadValuesByObjIds (   $obj_ids)
static

preload object values

public

Parameters
arrayobj_ids

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

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

{
global $ilDB;
$query = "SELECT obj_id,field_id,value FROM adv_md_values ".
"WHERE ".$ilDB->in('obj_id',$obj_ids,false,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
self::$cached_values[$row->obj_id][$row->field_id] = $row->value;
}
return true;
}
static ilAdvancedMDValues::queryForRecords (   $a_obj_id,
  $a_subtype,
  $a_records,
  $a_obj_id_key,
  $a_obj_subid_key,
  $a_amet_filter = "" 
)
static

Query data for given object records.

Parameters
@return

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

References $result, $results, _getValuesByObjIdAndSubtype(), ilAdvancedMDFieldDefinition\_lookupFieldType(), IL_CAL_DATE, IL_CAL_UNIX, ilAdvancedMDFieldDefinition\TYPE_DATE, and ilAdvancedMDFieldDefinition\TYPE_DATETIME.

Referenced by ilGlossaryTerm\getTermList().

{
$result = $val = array();
if (!is_array($a_obj_id))
{
$a_obj_id = array($a_obj_id);
}
// read amet data
foreach ($a_obj_id as $obj_id)
{
$values = self::_getValuesByObjIdAndSubtype($obj_id, $a_subtype);
foreach ($values as $v)
{
$val[$obj_id][$v["sub_id"]][$v["field_id"]] = $v;
}
}
//var_dump($a_amet_filter);
// add amet data to records
foreach ($a_records as $rec)
{
// check filter
$skip = false;
if (is_array($a_amet_filter))
{
foreach ($a_amet_filter as $fk => $fv)
{
if (!$skip && substr($fk, 0, 3) == "md_")
{
$fka = explode("_", $fk);
$fka = $fka[1];
if (is_array($fv))
{
// #12511 - currently supports only date/datetime
array_key_exists("from", $fv) &&
array_key_exists("to", $fv) &&
($fv["from"] !== null || $fv["to"] !== null))
{
if (!isset($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka]["value"]))
{
$skip = true;
}
else
{
$from = $fv["from"];
$to = $fv["to"];
$md_val = $val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka]["value"];
{
$from = $from ? $from->get(IL_CAL_UNIX) : null;
$to = $to ? $to->get(IL_CAL_UNIX) : null;
}
else
{
$from = $from ? $from->get(IL_CAL_DATE) : null;
$to = $to ? $to->get(IL_CAL_DATE) : null;
$md_val = date("Y-m-d", $md_val);
}
if($from && $to)
{
if($md_val < $from || $md_val > $to)
{
$skip = true;
}
}
else if($from)
{
if($md_val < $from)
{
$skip = true;
}
}
else
{
if($md_val > $to)
{
$skip = true;
}
}
}
}
}
else if($fv != "")
{
if (!isset($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka]["value"]))
{
$skip = true;
}
else
{
$md_val = $val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka]["value"];
if (trim($md_val) != trim($fv))
{
$skip = true;
}
}
}
}
}
}
if ($skip)
{
continue;
}
if (is_array($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]]))
{
foreach ($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]] as $k => $v)
{
$rec["md_".$k] = $v["value"];
}
}
$results[] = $rec;
}
return $results;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilAdvancedMDValues::$cached_values = array()
staticprivate

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


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