ILIAS  release_4-4 Revision
ilAdvancedMDValue Class Reference
+ Collaboration diagram for ilAdvancedMDValue:

Public Member Functions

 __construct ($a_field_id, $a_obj_id=0, $a_sub_type="", $a_sub_id=0)
 Singleton constructor. More...
 
 __toString ()
 To string method. More...
 
 setObjId ($a_obj_id)
 set object id More...
 
 setSubType ($a_val)
 Set sub type. More...
 
 getSubType ()
 Get sub type. More...
 
 setSubId ($a_val)
 Set sub id. More...
 
 getSubId ()
 Get sub id. More...
 
 appendXML ($xml_writer)
 append value xml More...
 
 setValue ($a_value)
 Set value. More...
 
 getValue ()
 get value More...
 
 isDisabled ()
 Check if value is imported and therefore disabled. More...
 
 toggleDisabledStatus ($a_status)
 Toggle disabled status. More...
 
 delete ()
 Delete value. More...
 
 save ()
 Save data. More...
 

Static Public Member Functions

static _getInstance ($a_obj_id, $a_field_id, $a_sub_type="", $a_sub_id=0)
 Get instance. More...
 

Protected Attributes

 $db
 

Private Member Functions

 read ()
 Read data. More...
 

Private Attributes

 $obj_id
 
 $field_id
 
 $value
 
 $disabled = false
 

Static Private Attributes

static $instances = 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.ilAdvancedMDValue.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDValue::__construct (   $a_field_id,
  $a_obj_id = 0,
  $a_sub_type = "",
  $a_sub_id = 0 
)

Singleton constructor.

private

Parameters
intfield_id
intobj_id

Definition at line 33 of file class.ilAdvancedMDValue.php.

References read(), setSubId(), and setSubType().

34  {
35  global $ilDB;
36 
37  $this->db = $ilDB;
38 
39  $this->obj_id = $a_obj_id;
40  $this->setSubType($a_sub_type);
41  $this->setSubId($a_sub_id);
42  $this->field_id = $a_field_id;
43 
44  $this->read();
45  }
setSubType($a_val)
Set sub type.
setSubId($a_val)
Set sub id.
+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

ilAdvancedMDValue::__toString ( )

To string method.

public

Definition at line 74 of file class.ilAdvancedMDValue.php.

References $value.

75  {
76  return $this->value;
77  }

◆ _getInstance()

static ilAdvancedMDValue::_getInstance (   $a_obj_id,
  $a_field_id,
  $a_sub_type = "",
  $a_sub_id = 0 
)
static

Get instance.

public

Parameters

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

Referenced by ilAdvancedMDValues\_appendXMLByObjId(), ilRemoteObjectBase\importMetadataFromJson(), ilAdvancedMDRecordGUI\loadECSDurationPost(), ilAdvancedMDRecordGUI\loadFromPost(), ilAdvancedMDRecordGUI\parseEditor(), ilAdvancedMDRecordGUI\parseInfoPage(), and ilAdvancedMDRecordGUI\showECSStart().

56  {
57  if ($a_sub_type == "")
58  {
59  $a_sub_type = "-";
60  }
61  if(isset(self::$instances[$a_obj_id][$a_field_id][$a_sub_type][$a_sub_id]))
62  {
63  return self::$instances[$a_obj_id][$a_field_id][$a_sub_type][$a_sub_id];
64  }
65  return self::$instances[$a_obj_id][$a_field_id][$a_sub_type][$a_sub_id] = new ilAdvancedMDValue($a_field_id,$a_obj_id, $a_sub_type, $a_sub_id);
66  }
+ Here is the caller graph for this function:

◆ appendXML()

ilAdvancedMDValue::appendXML (   $xml_writer)

append value xml

public

Parameters
objectinstance of ilXmlWriter

Definition at line 142 of file class.ilAdvancedMDValue.php.

References ilAdvancedMDFieldDefinition\_lookupImportId(), and getValue().

143  {
144  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
145 
146  $xml_writer->xmlElement('Value',
147  array('id' => ilAdvancedMDFieldDefinition::_lookupImportId($this->field_id)),
148  $this->getValue());
149  }
static _lookupImportId($a_field_id)
Lookup import id.
+ Here is the call graph for this function:

◆ delete()

ilAdvancedMDValue::delete ( )

Delete value.

public

Definition at line 205 of file class.ilAdvancedMDValue.php.

References $query, $res, getSubId(), and getSubType().

206  {
207  global $ilDB;
208 
209  $query = "DELETE FROM adv_md_values ".
210  "WHERE obj_id = ".$this->db->quote($this->obj_id ,'integer')." ".
211  "AND sub_type = ".$this->db->quote($this->getSubType() ,'text')." ".
212  "AND sub_id = ".$this->db->quote($this->getSubId() ,'integer')." ".
213  "AND field_id = ".$this->db->quote($this->field_id ,'integer');
214  $res = $ilDB->manipulate($query);
215  }
+ Here is the call graph for this function:

◆ getSubId()

ilAdvancedMDValue::getSubId ( )

Get sub id.

Returns
integer sub object id

Definition at line 130 of file class.ilAdvancedMDValue.php.

Referenced by delete(), and read().

131  {
132  return $this->sub_id;
133  }
+ Here is the caller graph for this function:

◆ getSubType()

ilAdvancedMDValue::getSubType ( )

Get sub type.

Returns
string sub type

Definition at line 110 of file class.ilAdvancedMDValue.php.

Referenced by delete(), read(), and save().

111  {
112  return $this->sub_type;
113  }
+ Here is the caller graph for this function:

◆ getValue()

ilAdvancedMDValue::getValue ( )

get value

public

Definition at line 169 of file class.ilAdvancedMDValue.php.

References $value.

Referenced by appendXML(), and save().

170  {
171  return $this->value;
172  }
+ Here is the caller graph for this function:

◆ isDisabled()

ilAdvancedMDValue::isDisabled ( )

Check if value is imported and therefore disabled.

This is the case for imported course links.

public

Parameters

Definition at line 182 of file class.ilAdvancedMDValue.php.

References $disabled.

Referenced by save().

183  {
184  return (bool) $this->disabled;
185  }
+ Here is the caller graph for this function:

◆ read()

ilAdvancedMDValue::read ( )
private

Read data.

private

Definition at line 246 of file class.ilAdvancedMDValue.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, getSubId(), getSubType(), setValue(), and toggleDisabledStatus().

Referenced by __construct().

247  {
248  global $ilDB;
249 
250  if(!$this->obj_id or !$this->field_id)
251  {
252  return;
253  }
254 
255  $query = "SELECT * FROM adv_md_values ".
256  "WHERE obj_id = ".$this->db->quote($this->obj_id ,'integer')." ".
257  "AND sub_type = ".$this->db->quote($this->getSubType() ,'text')." ".
258  "AND sub_id = ".$this->db->quote($this->getSubId() ,'integer')." ".
259  "AND field_id = ".$this->db->quote($this->field_id ,'integer')." ";
260  $res = $this->db->query($query);
261  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
262  {
263  $this->setValue($row->value);
264  $this->toggleDisabledStatus((bool) $row->disabled);
265  }
266  return true;
267  }
toggleDisabledStatus($a_status)
Toggle disabled status.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setValue($a_value)
Set value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAdvancedMDValue::save ( )

Save data.

public

Definition at line 223 of file class.ilAdvancedMDValue.php.

References $query, $res, getSubType(), getValue(), and isDisabled().

224  {
225  global $ilDB;
226 
227  $this->delete();
228 
229  $query = "INSERT INTO adv_md_values (obj_id,field_id,sub_type, sub_id, value,disabled) ".
230  "VALUES( ".
231  $this->db->quote($this->obj_id ,'integer').", ".
232  $this->db->quote($this->field_id ,'integer').", ".
233  $this->db->quote($this->getSubType() ,'text').", ".
234  $this->db->quote($this->getSubid() ,'integer').", ".
235  $this->db->quote($this->getValue() ,'text').", ".
236  $ilDB->quote($this->isDisabled(),'integer')." ".
237  ")";
238  $res = $ilDB->manipulate($query);
239  }
isDisabled()
Check if value is imported and therefore disabled.
+ Here is the call graph for this function:

◆ setObjId()

ilAdvancedMDValue::setObjId (   $a_obj_id)

set object id

public

Parameters
intobj_id

Definition at line 86 of file class.ilAdvancedMDValue.php.

87  {
88  $this->obj_id = $a_obj_id;
89  }

◆ setSubId()

ilAdvancedMDValue::setSubId (   $a_val)

Set sub id.

Parameters
integer$a_valsub object id

Definition at line 120 of file class.ilAdvancedMDValue.php.

Referenced by __construct().

121  {
122  $this->sub_id = (int) $a_val;
123  }
+ Here is the caller graph for this function:

◆ setSubType()

ilAdvancedMDValue::setSubType (   $a_val)

Set sub type.

Parameters
string$a_valsub type

Definition at line 96 of file class.ilAdvancedMDValue.php.

Referenced by __construct().

97  {
98  if ($a_val == "")
99  {
100  $a_val = "-";
101  }
102  $this->sub_type = $a_val;
103  }
+ Here is the caller graph for this function:

◆ setValue()

ilAdvancedMDValue::setValue (   $a_value)

Set value.

public

Parameters
stringvalue

Definition at line 159 of file class.ilAdvancedMDValue.php.

Referenced by read().

160  {
161  $this->value = $a_value;
162  }
+ Here is the caller graph for this function:

◆ toggleDisabledStatus()

ilAdvancedMDValue::toggleDisabledStatus (   $a_status)

Toggle disabled status.

public

Parameters
booldisabled status

Definition at line 194 of file class.ilAdvancedMDValue.php.

Referenced by read().

195  {
196  $this->disabled = (bool) $a_status;
197  }
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilAdvancedMDValue::$db
protected

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

◆ $disabled

ilAdvancedMDValue::$disabled = false
private

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

Referenced by isDisabled().

◆ $field_id

ilAdvancedMDValue::$field_id
private

Definition at line 21 of file class.ilAdvancedMDValue.php.

◆ $instances

ilAdvancedMDValue::$instances = array()
staticprivate

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

◆ $obj_id

ilAdvancedMDValue::$obj_id
private

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

◆ $value

ilAdvancedMDValue::$value
private

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

Referenced by __toString(), and getValue().


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