ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAdvancedMDSubstitution Class Reference
+ Collaboration diagram for ilAdvancedMDSubstitution:

Public Member Functions

 sortDefinitions ($a_definitions)
 Sort definitions.
 isActive ()
 Is substitution active.
 isDescriptionEnabled ()
 Is description enabled.
 enableDescription ($a_status)
 Enable description presentation.
 enabledFieldNames ()
 is field name enabled
 enableFieldNames ($a_status)
 enable field names
 getParsedSubstitutions ($a_ref_id, $a_obj_id)
 Substitute.
 resetSubstitutions ()
 set substitutions
 appendSubstitution ($a_field_id, $a_bold=false, $a_newline=false)
 append field to substitutions
 getSubstitutions ()
 get substitution string
 isSubstituted ($a_field_id)
 is substituted
 isBold ($a_field_id)
 is bold
 hasNewline ($a_field_id)
 has newline
 update ()
 update

Static Public Member Functions

static _getInstanceByObjectType ($a_type)
 Singleton: use this method to get an instance.

Protected Attributes

 $db
 $type
 $substitutions
 $bold = array()
 $newline = array()
 $enabled_desc = true
 $enabled_field_names = true
 $active = false
 $date_fields = array()
 $datetime_fields = array()
 $active_fields = array()

Private Member Functions

 __construct ($a_type)
 parseValue ($a_field_id, $a_values)
 special handling for date(time) values and ECS dates
 read ()
 Read db entries.
 initECSMappings ()
 init ECS mappings

Static Private Attributes

static $instances = null
static $mappings = null

Detailed Description

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

Definition at line 32 of file class.ilAdvancedMDSubstitution.php.

Constructor & Destructor Documentation

ilAdvancedMDSubstitution::__construct (   $a_type)
private

Definition at line 58 of file class.ilAdvancedMDSubstitution.php.

References initECSMappings(), and read().

{
global $ilDB;
$this->db = $ilDB;
$this->type = $a_type;
$this->initECSMappings();
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

static ilAdvancedMDSubstitution::_getInstanceByObjectType (   $a_type)
static

Singleton: use this method to get an instance.

Parameters
stringilias object type (3 or 4 characters) public

Definition at line 77 of file class.ilAdvancedMDSubstitution.php.

Referenced by ilObjCourseListGUI\init(), ilObjCategoryListGUI\init(), ilObjRemoteCategoryListGUI\init(), ilObjRemoteGlossaryListGUI\init(), ilObjRemoteTestListGUI\init(), ilObjRemoteGroupListGUI\init(), ilObjRemoteLearningModuleListGUI\init(), ilObjRemoteCourseListGUI\init(), ilObjRemoteFileListGUI\init(), ilObjRemoteWikiListGUI\init(), ilObjCourseReferenceListGUI\init(), ilObjCategoryReferenceListGUI\init(), ilAdvancedMDSettingsGUI\initFormSubstitutions(), and ilAdvancedMDSettingsGUI\updateSubstitutions().

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

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::appendSubstitution (   $a_field_id,
  $a_bold = false,
  $a_newline = false 
)

append field to substitutions

public

Parameters
intfield id

Definition at line 293 of file class.ilAdvancedMDSubstitution.php.

{
$this->substitutions[] = $a_field_id;
if($a_bold)
{
$this->bold[] = $a_field_id;
}
if($a_newline)
{
$this->newline[] = $a_field_id;
}
}
ilAdvancedMDSubstitution::enableDescription (   $a_status)

Enable description presentation.

public

Parameters
boolstatus description enabled

Definition at line 134 of file class.ilAdvancedMDSubstitution.php.

{
$this->enabled_desc = $a_status;
}
ilAdvancedMDSubstitution::enabledFieldNames ( )

is field name enabled

public

Definition at line 145 of file class.ilAdvancedMDSubstitution.php.

References $enabled_field_names.

Referenced by getParsedSubstitutions(), and update().

{
}

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::enableFieldNames (   $a_status)

enable field names

public

Parameters
boolenable/disable status

Definition at line 157 of file class.ilAdvancedMDSubstitution.php.

{
$this->enabled_field_names = $a_status;
}
ilAdvancedMDSubstitution::getParsedSubstitutions (   $a_ref_id,
  $a_obj_id 
)

Substitute.

public

Parameters
intref_id
intobj_id
stringdescription

Definition at line 171 of file class.ilAdvancedMDSubstitution.php.

References ilAdvancedMDValues\_getValuesByObjId(), enabledFieldNames(), getSubstitutions(), hasNewline(), isBold(), and parseValue().

{
if(!count($this->getSubstitutions()))
{
return array();
}
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
$counter = 0;
foreach($this->getSubstitutions() as $field_id)
{
if(!isset($this->active_fields[$field_id]))
{
continue;
}
if(!isset($values[$field_id]) or !$values[$field_id])
{
if($this->hasNewline($field_id) and $counter)
{
$substituted[$counter-1]['newline'] = true;
}
continue;
}
$value = $this->parseValue($field_id,$values);
$substituted[$counter]['name'] = $this->active_fields[$field_id];
$substituted[$counter]['value'] = $value;
$substituted[$counter]['bold'] = $this->isBold($field_id);
if($this->hasNewline($field_id))
{
$substituted[$counter]['newline'] = true;
}
else
{
$substituted[$counter]['newline'] = false;
}
$substituted[$counter]['show_field'] = $this->enabledFieldNames();
$counter++;
}
return $substituted ? $substituted : array();
}

+ Here is the call graph for this function:

ilAdvancedMDSubstitution::getSubstitutions ( )

get substitution string

public

Parameters

Definition at line 313 of file class.ilAdvancedMDSubstitution.php.

Referenced by getParsedSubstitutions(), and isSubstituted().

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

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::hasNewline (   $a_field_id)

has newline

public

Parameters
intfield_id

Definition at line 351 of file class.ilAdvancedMDSubstitution.php.

Referenced by getParsedSubstitutions(), and update().

{
return in_array($a_field_id,$this->newline);
}

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::initECSMappings ( )
private

init ECS mappings

private

Definition at line 468 of file class.ilAdvancedMDSubstitution.php.

References ilECSDataMappingSettings\_getInstance().

Referenced by __construct().

{
return true;
include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
if(isset(self::$mappings) and is_object(self::$mappings))
{
return true;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::isActive ( )

Is substitution active.

public

Definition at line 111 of file class.ilAdvancedMDSubstitution.php.

References $active.

{
return $this->active;
}
ilAdvancedMDSubstitution::isBold (   $a_field_id)

is bold

public

Parameters
intfield_id

Definition at line 337 of file class.ilAdvancedMDSubstitution.php.

Referenced by getParsedSubstitutions(), and update().

{
#var_dump("<pre>",$this->bold,$a_field_id,"</pre>");
return in_array($a_field_id,$this->bold);
}

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::isDescriptionEnabled ( )

Is description enabled.

public

Definition at line 122 of file class.ilAdvancedMDSubstitution.php.

References $enabled_desc.

Referenced by update().

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

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::isSubstituted (   $a_field_id)

is substituted

public

Parameters
intfield_id

Definition at line 325 of file class.ilAdvancedMDSubstitution.php.

References getSubstitutions().

{
return in_array($a_field_id,$this->getSubstitutions());
}

+ Here is the call graph for this function:

ilAdvancedMDSubstitution::parseValue (   $a_field_id,
  $a_values 
)
private

special handling for date(time) values and ECS dates

Parameters
int$a_field_idfield ID
array$a_valuesvalues public
Returns
string parsed value

Definition at line 227 of file class.ilAdvancedMDSubstitution.php.

References $ilUser, ilDatePresentation\formatDate(), and IL_CAL_UNIX.

Referenced by getParsedSubstitutions().

{
global $ilUser;
if($this->type == 'crs' or $this->type == 'rcrs')
{
// Special handling for ECS fields
// @FIXME
/*
if($a_field_id == self::$mappings->getMappingByECSName('begin') and
$end = self::$mappings->getMappingByECSName('end'))
{
// Parse a duration
$start = in_array($a_field_id,$this->date_fields) ?
new ilDate($a_values[$a_field_id],IL_CAL_UNIX) :
new ilDateTime($a_values[$a_field_id],IL_CAL_UNIX);
$end = in_array($end,$this->date_fields) ?
new ilDate($a_values[$end],IL_CAL_UNIX) :
new ilDateTime($a_values[$end],IL_CAL_UNIX);
include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
$weekday = ilCalendarUtil::_numericDayToString($start->get(IL_CAL_FKT_DATE,'w',$ilUser->getTimeZone()),false);
ilDatePresentation::setUseRelativeDates(false);
$value = ilDatePresentation::formatPeriod($start,$end);
ilDatePresentation::setUseRelativeDates(true);
return $weekday.', '.$value;
}
*/
}
if(in_array($a_field_id,$this->date_fields))
{
return $value = ilDatePresentation::formatDate(new ilDate((int) $a_values[$a_field_id],IL_CAL_UNIX));
}
elseif(in_array($a_field_id,$this->datetime_fields))
{
return $value = ilDatePresentation::formatDate(new ilDateTime((int) $a_values[$a_field_id],IL_CAL_UNIX));
}
else
{
return $value = $a_values[$a_field_id];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::read ( )
private

Read db entries.

private

Definition at line 395 of file class.ilAdvancedMDSubstitution.php.

References $query, $res, $row, ilAdvancedMDFieldDefinition\_lookupDateFields(), and DB_FETCHMODE_OBJECT.

Referenced by __construct().

{
global $ilDB;
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
$this->datetime_fields = ilAdvancedMDFieldDefinition::_lookupDatetimeFields();
// Check active status
$query = "SELECT active,field_id,amfd.title 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 = ".$this->db->quote($this->type ,'text')." ";
$res = $this->db->query($query);
$this->active = $res->numRows() ? true : false;
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->active_fields[$row->field_id] = $row->title;
}
$query = "SELECT * FROM adv_md_substitutions ".
"WHERE obj_type = ".$this->db->quote($this->type ,'text')." ";
$res = $this->db->query($query);
$this->substitutions = array();
$this->bold = array();
$this->newline = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_substitutions = unserialize($row->substitution);
if(is_array($tmp_substitutions))
{
foreach($tmp_substitutions as $substitution)
{
if($substitution['field_id'])
{
$this->substitutions[] = $substitution['field_id'];
}
if($substitution['bold'])
{
$this->bold[] = $substitution['field_id'];
}
if($substitution['newline'])
{
$this->newline[] = $substitution['field_id'];
}
}
}
$this->enabled_desc = !$row->hide_description;
$this->enabled_field_names = !$row->hide_field_names;
}
if($this->type == 'crs' or $this->type == 'rcrs')
{
// Handle ECS substitutions
/*
if($begin = self::$mappings->getMappingByECSName('begin') and
$end = self::$mappings->getMappingByECSName('end'))
{
// Show something like 'Monday, 30.12.2008 9:00 - 12:00'
unset($this->active_fields[$end]);
}
*/
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDSubstitution::resetSubstitutions ( )

set substitutions

public

Parameters
arrayarray of field definitions

Definition at line 279 of file class.ilAdvancedMDSubstitution.php.

{
$this->substitutions = array();
$this->bold = array();
$this->newline = array();
}
ilAdvancedMDSubstitution::sortDefinitions (   $a_definitions)

Sort definitions.

public

Parameters
arrayint field_id

Definition at line 93 of file class.ilAdvancedMDSubstitution.php.

{
$sorted = array();
foreach($this->substitutions as $field_id)
{
$sorted[] = $field_id;
$key = array_search($field_id,$a_definitions);
unset($a_definitions[$key]);
}
return array_merge($sorted,$a_definitions);
}
ilAdvancedMDSubstitution::update ( )

update

public

Definition at line 361 of file class.ilAdvancedMDSubstitution.php.

References $query, $res, $substitutions, enabledFieldNames(), hasNewline(), isBold(), and isDescriptionEnabled().

{
global $ilDB;
$counter = 0;
$substitutions = array();
foreach($this->substitutions as $field_id)
{
$substitutions[$counter]['field_id'] = $field_id;
$substitutions[$counter]['bold'] = $this->isBold($field_id);
$substitutions[$counter]['newline'] = $this->hasNewline($field_id);
$counter++;
}
$query = "DELETE FROM adv_md_substitutions WHERE obj_type = ".$ilDB->quote($this->type,'text');
$res = $ilDB->manipulate($query);
$values = array(
'obj_type' => array('text',$this->type),
'substitution' => array('clob',serialize($substitutions)),
'hide_description' => array('integer',!$this->isDescriptionEnabled()),
'hide_field_names' => array('integer',!$this->enabledFieldNames())
);
$ilDB->insert('adv_md_substitutions',$values);
}

+ Here is the call graph for this function:

Field Documentation

ilAdvancedMDSubstitution::$active = false
protected

Definition at line 46 of file class.ilAdvancedMDSubstitution.php.

Referenced by isActive().

ilAdvancedMDSubstitution::$active_fields = array()
protected

Definition at line 49 of file class.ilAdvancedMDSubstitution.php.

ilAdvancedMDSubstitution::$bold = array()
protected

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

ilAdvancedMDSubstitution::$date_fields = array()
protected

Definition at line 47 of file class.ilAdvancedMDSubstitution.php.

ilAdvancedMDSubstitution::$datetime_fields = array()
protected

Definition at line 48 of file class.ilAdvancedMDSubstitution.php.

ilAdvancedMDSubstitution::$db
protected

Definition at line 37 of file class.ilAdvancedMDSubstitution.php.

ilAdvancedMDSubstitution::$enabled_desc = true
protected

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

Referenced by isDescriptionEnabled().

ilAdvancedMDSubstitution::$enabled_field_names = true
protected

Definition at line 45 of file class.ilAdvancedMDSubstitution.php.

Referenced by enabledFieldNames().

ilAdvancedMDSubstitution::$instances = null
staticprivate

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

ilAdvancedMDSubstitution::$mappings = null
staticprivate

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

ilAdvancedMDSubstitution::$newline = array()
protected

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

ilAdvancedMDSubstitution::$substitutions
protected

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

Referenced by update().

ilAdvancedMDSubstitution::$type
protected

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


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