ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAdvancedMDRecord Class Reference
+ Collaboration diagram for ilAdvancedMDRecord:

Public Member Functions

 __construct ($a_record_id=0)
 Singleton constructor To create an array of new records (without saving them) call the constructor directly.
 delete ()
 Delete.
 save ()
 save
 update ()
 update
 validate ()
 Validate settings Write error message to ilErr.
 getRecordId ()
 Get record id.
 setActive ($a_active)
 Set active.
 isActive ()
 Check if record is active.
 setTitle ($a_title)
 Set title.
 getTitle ()
 get title
 setDescription ($a_description)
 set description
 getDescription ()
 get description
 setImportId ($a_id_string)
 set import id
 getImportId ()
 get import id
 setAssignedObjectTypes ($a_obj_types)
 Set assigned object types.
 appendAssignedObjectType ($a_obj_type)
 append assigned object types
 getAssignedObjectTypes ()
 Get assigned object types.
 toXML (ilXmlWriter $writer)
 To Xml.
 __destruct ()
 Destructor.

Static Public Member Functions

static _getInstanceByRecordId ($a_record_id)
 Get instance by record id.
static _getActiveSearchableRecords ()
 Get active searchable records.
static _lookupTitle ($a_record_id)
 Lookup title.
static _lookupRecordIdByImportId ($a_ilias_id)
 Lookup record Id by import id.
static _getAssignableObjectTypes ()
 Get assignable object type.
static _getActivatedObjTypes ()
 get activated obj types
static _getRecords ()
 Get records.
static _getAllRecordsByObjectType ()
 Get records by obj_type.
static _getActivatedRecordsByObjectType ($a_obj_type)
 Get activated records by object type.
static _delete ($a_record_id)
 Delete record and all related data.

Protected Member Functions

 generateImportId ()
 generate unique record id

Protected Attributes

 $record_id
 $import_id
 $active
 $title
 $description
 $obj_types = array()
 $db = null

Private Member Functions

 read ()
 read record and assiged object types

Static Private Attributes

static $instances = array()

Detailed Description

Definition at line 34 of file class.ilAdvancedMDRecord.php.

Constructor & Destructor Documentation

ilAdvancedMDRecord::__construct (   $a_record_id = 0)

Singleton constructor To create an array of new records (without saving them) call the constructor directly.

Otherwise call getInstance...

public

Parameters
intrecord id

Definition at line 55 of file class.ilAdvancedMDRecord.php.

References $ilDB, getRecordId(), and read().

{
global $ilDB;
$this->record_id = $a_record_id;
$this->db = $ilDB;
if($this->getRecordId())
{
$this->read();
}
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::__destruct ( )

Destructor.

public

Definition at line 613 of file class.ilAdvancedMDRecord.php.

References getRecordId().

{
unset(self::$instances[$this->getRecordId()]);
}

+ Here is the call graph for this function:

Member Function Documentation

static ilAdvancedMDRecord::_delete (   $a_record_id)
static

Delete record and all related data.

public

Parameters
intrecord id

Definition at line 272 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, and ilAdvancedMDFieldDefinition\_deleteByRecordId().

Referenced by delete().

{
global $ilDB;
// Delete fields
$query = "DELETE FROM adv_md_record ".
"WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
$res = $ilDB->manipulate($query);
$query = "DELETE FROM adv_md_record_objs ".
"WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
$res = $ilDB->manipulate($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getActivatedObjTypes ( )
static

get activated obj types

public

Parameters
stringobj types

Definition at line 176 of file class.ilAdvancedMDRecord.php.

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

Referenced by ilAdvancedSearchGUI\__setSearchOptions(), ilObjCategoryGUI\getSubTabs(), ilAdvancedSearchGUI\initAdvancedMetaDataForm(), and ilAdvancedMDSettingsGUI\updateSubstitutions().

{
global $ilDB;
$query = "SELECT DISTINCT(obj_type) FROM adv_md_record_objs amo ".
"JOIN adv_md_record amr ON amo.record_id = amr.record_id ".
"WHERE active = 1 ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$obj_types[] = $row->obj_type;
}
return $obj_types ? $obj_types : array();
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getActivatedRecordsByObjectType (   $a_obj_type)
static

Get activated records by object type.

public

Parameters
stringobj_type

Definition at line 243 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, $row, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilSoapAdministration\getNIC(), ilAdvancedMDRecordGUI\parseEditor(), and ilAdvancedMDRecordGUI\parseInfoPage().

{
global $ilDB;
$records = array();
$query = "SELECT amro.record_id record_id FROM adv_md_record_objs amro ".
"JOIN adv_md_record amr ON amr.record_id = amro.record_id ".
"WHERE active = 1 ".
"AND obj_type = ".$ilDB->quote($a_obj_type ,'text')." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$records[] = self::_getInstanceByRecordId($row->record_id);
}
return $records;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getActiveSearchableRecords ( )
static

Get active searchable records.

public

Definition at line 92 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, $row, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDRecordGUI\parseSearch().

{
global $ilDB;
$query = "SELECT DISTINCT(amr.record_id) FROM adv_md_record amr ".
"JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id ".
"WHERE searchable = 1 AND active = 1 ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$records[] = self::_getInstanceByRecordId($row->record_id);
}
return $records ? $records : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getAllRecordsByObjectType ( )
static

Get records by obj_type.

public

Parameters

Definition at line 220 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, $row, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions().

{
global $ilDB;
$records = array();
$query = "SELECT * FROM adv_md_record_objs ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$records[$row->obj_type][] = self::_getInstanceByRecordId($row->record_id);
}
return $records;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getAssignableObjectTypes ( )
static

Get assignable object type.

public

Definition at line 163 of file class.ilAdvancedMDRecord.php.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilAdvancedMDRecordTableGUI\fillRow(), ilSoapAdministration\getNIC(), and ilAdvancedMDSettingsGUI\initForm().

{
return array('cat','crs','rcrs');
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getInstanceByRecordId (   $a_record_id)
static

Get instance by record id.

public

Parameters
intrecord id

Definition at line 76 of file class.ilAdvancedMDRecord.php.

Referenced by _getActivatedRecordsByObjectType(), _getActiveSearchableRecords(), _getAllRecordsByObjectType(), _getRecords(), ilAdvancedMDSettingsGUI\confirmDeleteRecords(), ilAdvancedMDSettingsGUI\deleteRecords(), ilAdvancedMDRecordParser\initRecordObject(), and ilAdvancedMDSettingsGUI\initRecordObject().

{
if(isset(self::$instances[$a_record_id]))
{
return self::$instances[$a_record_id];
}
return self::$instances[$a_record_id] = new ilAdvancedMDRecord($a_record_id);
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getRecords ( )
static

Get records.

public

Parameters
arrayarray of record objects

Definition at line 199 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, $row, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilLuceneAdvancedSearchFields\getFields(), and ilAdvancedMDSettingsGUI\getRecordObjects().

{
global $ilDB;
$query = "SELECT record_id FROM adv_md_record ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
}
return $records ? $records : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_lookupRecordIdByImportId (   $a_ilias_id)
static

Lookup record Id by import id.

public

Parameters
stringilias id

Definition at line 143 of file class.ilAdvancedMDRecord.php.

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

Referenced by ilAdvancedMDRecordParser\extractRecordId().

{
global $ilDB;
$query = "SELECT record_id FROM adv_md_record ".
"WHERE import_id = ".$ilDB->quote($a_ilias_id ,'text')." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->record_id;
}
return 0;
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_lookupTitle (   $a_record_id)
static

Lookup title.

public

Parameters
intrecord_id

Definition at line 116 of file class.ilAdvancedMDRecord.php.

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

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions(), ilECSSettingsGUI\prepareFieldSelection(), and ilLuceneAdvancedSearchFields\readSections().

{
static $title_cache = array();
if(isset($title_cache[$a_record_id]))
{
return $title_cache[$a_record_id];
}
global $ilDB;
$query = "SELECT title FROM adv_md_record ".
"WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
$res = $ilDB->query($query);
return $title_cache[$a_record_id] = $row->title;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::appendAssignedObjectType (   $a_obj_type)

append assigned object types

public

Parameters
stringilias object type

Definition at line 521 of file class.ilAdvancedMDRecord.php.

{
$this->obj_types[] = $a_obj_type;
}
ilAdvancedMDRecord::delete ( )

Delete.

public

Definition at line 295 of file class.ilAdvancedMDRecord.php.

References _delete(), and getRecordId().

+ Here is the call graph for this function:

ilAdvancedMDRecord::generateImportId ( )
protected

generate unique record id

protected

Returns

Definition at line 602 of file class.ilAdvancedMDRecord.php.

References getRecordId().

Referenced by save(), and toXML().

{
return 'il_'.IL_INST_ID.'_adv_md_record_'.$this->getRecordId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getAssignedObjectTypes ( )

Get assigned object types.

public

Definition at line 532 of file class.ilAdvancedMDRecord.php.

Referenced by save(), toXML(), and update().

{
return $this->obj_types ? $this->obj_types : array();
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getDescription ( )

get description

public

Definition at line 474 of file class.ilAdvancedMDRecord.php.

References $description.

Referenced by save(), toXML(), and update().

{
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getImportId ( )

get import id

public

Definition at line 497 of file class.ilAdvancedMDRecord.php.

References $import_id.

Referenced by save().

{
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getRecordId ( )

Get record id.

public

Definition at line 405 of file class.ilAdvancedMDRecord.php.

References $record_id.

Referenced by __construct(), __destruct(), delete(), generateImportId(), read(), save(), toXML(), and update().

{
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getTitle ( )

get title

public

Definition at line 451 of file class.ilAdvancedMDRecord.php.

References $title.

Referenced by save(), toXML(), update(), and validate().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::isActive ( )

Check if record is active.

public

Definition at line 428 of file class.ilAdvancedMDRecord.php.

References $active.

Referenced by save(), toXML(), and update().

{
return (bool) $this->active;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::read ( )
private

read record and assiged object types

private

Parameters

Definition at line 573 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, getRecordId(), setActive(), setDescription(), setImportId(), and setTitle().

Referenced by __construct().

{
global $ilDB;
$query = "SELECT * FROM adv_md_record ".
"WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setImportId($row->import_id);
$this->setActive($row->active);
$this->setTitle($row->title);
$this->setDescription($row->description);
}
$query = "SELECT * FROM adv_md_record_objs ".
"WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->obj_types[] = $row->obj_type;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecord::save ( )

save

public

Definition at line 306 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, generateImportId(), getAssignedObjectTypes(), getDescription(), getImportId(), getRecordId(), getTitle(), and isActive().

{
global $ilDB;
// Save import id if given
$next_id = $ilDB->nextId('adv_md_record');
$query = "INSERT INTO adv_md_record (record_id,import_id,active,title,description) ".
"VALUES(".
$ilDB->quote($next_id,'integer').", ".
$this->db->quote($this->getImportId(),'text').", ".
$this->db->quote($this->isActive() ,'integer').", ".
$this->db->quote($this->getTitle() ,'text').", ".
$this->db->quote($this->getDescription() ,'text')." ".
")";
$res = $ilDB->manipulate($query);
$this->record_id = $next_id;
if(!strlen($this->getImportId()))
{
// set import id to default value
$query = "UPDATE adv_md_record ".
"SET import_id = ".$this->db->quote($this->generateImportId() ,'text')." ".
"WHERE record_id = ".$this->db->quote($this->record_id ,'integer')." ";
$res = $ilDB->manipulate($query);
}
foreach($this->getAssignedObjectTypes() as $type)
{
global $ilDB;
$query = "INSERT INTO adv_md_record_objs (record_id,obj_type) ".
"VALUES( ".
$this->db->quote($this->getRecordId() ,'integer').", ".
$this->db->quote($type ,'text')." ".
")";
$res = $ilDB->manipulate($query);
}
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::setActive (   $a_active)

Set active.

public

Parameters

Definition at line 417 of file class.ilAdvancedMDRecord.php.

Referenced by read().

{
$this->active = $a_active;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::setAssignedObjectTypes (   $a_obj_types)

Set assigned object types.

public

Parameters
arrayarray(string) array of object types. E.g array('crs','crsl')

Definition at line 509 of file class.ilAdvancedMDRecord.php.

{
$this->obj_types = $a_obj_types;
}
ilAdvancedMDRecord::setDescription (   $a_description)

set description

public

Parameters
stringdescription

Definition at line 463 of file class.ilAdvancedMDRecord.php.

Referenced by read().

{
$this->description = $a_description;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::setImportId (   $a_id_string)

set import id

public

Parameters
stringimport id

Definition at line 486 of file class.ilAdvancedMDRecord.php.

Referenced by read().

{
$this->import_id = $a_id_string;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::setTitle (   $a_title)

Set title.

public

Parameters
stringtitle

Definition at line 440 of file class.ilAdvancedMDRecord.php.

Referenced by read().

{
$this->title = $a_title;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::toXML ( ilXmlWriter  $writer)

To Xml.

This method writes only the subset Record (including all fields) Use class.ilAdvancedMDRecordXMLWriter to generate a complete xml presentation.

public

Parameters
objectilXmlWriter

Definition at line 546 of file class.ilAdvancedMDRecord.php.

References ilAdvancedMDFieldDefinition\_getDefinitionsByRecordId(), generateImportId(), getAssignedObjectTypes(), getDescription(), getRecordId(), getTitle(), isActive(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

{
$writer->xmlStartTag('Record',array('active' => $this->isActive() ? 1 : 0,
'id' => $this->generateImportId()));
$writer->xmlElement('Title',null,$this->getTitle());
$writer->xmlElement('Description',null,$this->getDescription());
foreach($this->getAssignedObjectTypes() as $obj_type)
{
$writer->xmlElement('ObjectType',null,$obj_type);
}
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
{
$definition->toXML($writer);
}
$writer->xmlEndTag('Record');
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::update ( )

update

public

Definition at line 352 of file class.ilAdvancedMDRecord.php.

References $ilDB, $query, $res, getAssignedObjectTypes(), getDescription(), getRecordId(), getTitle(), and isActive().

{
global $ilDB;
$query = "UPDATE adv_md_record ".
"SET active = ".$this->db->quote($this->isActive() ,'integer').", ".
"title = ".$this->db->quote($this->getTitle() ,'text').", ".
"description = ".$this->db->quote($this->getDescription() ,'text')." ".
"WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
$res = $ilDB->manipulate($query);
// Delete assignments
$query = "DELETE FROM adv_md_record_objs ".
"WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
$res = $ilDB->manipulate($query);
// Insert assignments
foreach($this->getAssignedObjectTypes() as $type)
{
$query = "INSERT INTO adv_md_record_objs (record_id,obj_type) ".
"VALUES ( ".
$this->db->quote($this->getRecordId() ,'integer').", ".
$this->db->quote($type ,'text')." ".
")";
$res = $ilDB->manipulate($query);
}
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::validate ( )

Validate settings Write error message to ilErr.

public

Definition at line 387 of file class.ilAdvancedMDRecord.php.

References $ilErr, $lng, and getTitle().

{
global $ilErr,$lng;
if(!strlen($this->getTitle()))
{
$ilErr->setMessage('fill_out_all_required_fields');
return false;
}
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilAdvancedMDRecord::$active
protected

Definition at line 40 of file class.ilAdvancedMDRecord.php.

Referenced by isActive().

ilAdvancedMDRecord::$db = null
protected

Definition at line 44 of file class.ilAdvancedMDRecord.php.

ilAdvancedMDRecord::$description
protected

Definition at line 42 of file class.ilAdvancedMDRecord.php.

Referenced by getDescription().

ilAdvancedMDRecord::$import_id
protected

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

Referenced by getImportId().

ilAdvancedMDRecord::$instances = array()
staticprivate

Definition at line 36 of file class.ilAdvancedMDRecord.php.

ilAdvancedMDRecord::$obj_types = array()
protected

Definition at line 43 of file class.ilAdvancedMDRecord.php.

Referenced by _getActivatedObjTypes().

ilAdvancedMDRecord::$record_id
protected

Definition at line 38 of file class.ilAdvancedMDRecord.php.

Referenced by getRecordId().

ilAdvancedMDRecord::$title
protected

Definition at line 41 of file class.ilAdvancedMDRecord.php.

Referenced by getTitle().


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