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

Public Member Functions

 __construct ($a_mode, $a_obj_type= '', $a_obj_id= '')
 Constructor.
 setPropertyForm ($form)
 set property form object
 setSearchValues ($a_values)
 Set values for search form.
 setInfoObject ($info)
 get info sections
 parse ()
 Get HTML.
 loadFromPost ()
 Load values from post.
 saveValues ()
 Save values.

Data Fields

const MODE_EDITOR = 1
const MODE_SEARCH = 2
const MODE_INFO = 3

Protected Member Functions

 loadECSDurationPost ()
 load ecs duration post
 parseDuration ($u_start, $u_end)
 parse hours and minutes from duration

Protected Attributes

 $lng

Private Member Functions

 parseEditor ()
 Parse property form in editor mode.
 parseSearch ()
 Parse search.
 parseInfoPage ()
 toUnixTime ($date, $time=array())
 convert input array to unix time
 handleECSDefinitions ($a_definition)
 handle ecs definitions
 showECSStart ($def)
 Show special form for ecs start.

Private Attributes

 $mode
 $obj_type
 $obj_id
 $form
 $values = array()
 $search_values = array()

Detailed Description

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

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

Constructor & Destructor Documentation

ilAdvancedMDRecordGUI::__construct (   $a_mode,
  $a_obj_type = '',
  $a_obj_id = '' 
)

Constructor.

public

Parameters
intmode either MODE_EDITOR or MODE_SEARCH
intobj_type

Definition at line 57 of file class.ilAdvancedMDRecordGUI.php.

References $lng.

{
global $lng;
$this->lng = $lng;
$this->mode = $a_mode;
$this->obj_type = $a_obj_type;
$this->obj_id = $a_obj_id;
}

Member Function Documentation

ilAdvancedMDRecordGUI::handleECSDefinitions (   $a_definition)
private

handle ecs definitions

private

Parameters
objectilAdvMDFieldDefinition
Returns

Definition at line 519 of file class.ilAdvancedMDRecordGUI.php.

References ilECSDataMappingSettings\_getInstance(), ilECSSettings\_getInstance(), and showECSStart().

Referenced by parseEditor().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
include_once('./Services/WebServices/ECS/classes/class.ilECSSettings.php');
if(!ilECSSettings::_getInstance()->isEnabled() or ($this->obj_type != 'crs' and $this->obj_type != 'rcrs'))
{
return false;
}
if($mapping->getMappingByECSName('begin') == $a_definition->getFieldId())
{
$this->showECSStart($a_definition);
return true;
}
if($mapping->getMappingByECSName('end') == $a_definition->getFieldId())
{
return true;
}
if($mapping->getMappingByECSName('cycle') == $a_definition->getFieldId())
{
return true;
}
if($mapping->getMappingByECSName('room') == $a_definition->getFieldId())
{
return true;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::loadECSDurationPost ( )
protected

load ecs duration post

protected

Parameters
@return

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

References $_POST, ilECSDataMappingSettings\_getInstance(), ilAdvancedMDValue\_getInstance(), ilECSSettings\_getInstance(), and toUnixTime().

Referenced by loadFromPost().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
include_once('./Services/WebServices/ECS/classes/class.ilECSSettings.php');
if(!ilECSSettings::_getInstance()->isEnabled())
{
return false;
}
if(!$start_id = $mapping->getMappingByECSName('begin'))
{
return false;
}
if(!$end_id = $mapping->getMappingByECSName('end'))
{
return false;
}
if(!$_POST['md_activated'][$start_id])
{
$end = 0;
}
else
{
$end = $this->toUnixTime($_POST['md'][$start_id]['date'],$_POST['md'][$start_id]['time']);
$end = $end + (60 * 60 * $_POST['ecs_duration']['hh']) + (60 * $_POST['ecs_duration']['mm']);
}
$val = ilAdvancedMDValue::_getInstance($this->obj_id,$end_id);
$val->setValue($end);
$this->values[] = $val;
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::loadFromPost ( )

Load values from post.

public

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

References $_POST, ilAdvancedMDValue\_getInstance(), ilAdvancedMDFieldDefinition\_getInstanceByFieldId(), IL_CAL_FKT_GETDATE, IL_CAL_UNIX, loadECSDurationPost(), ilUtil\stripSlashes(), ilAdvancedMDFieldDefinition\TYPE_DATE, and ilAdvancedMDFieldDefinition\TYPE_DATETIME.

Referenced by ilObjCategoryGUI\updateInfoObject(), ilObjCourseGUI\updateInfoObject(), and ilObjRemoteCourseGUI\updateObject().

{
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
if(!isset($_POST['md']))
{
return false;
}
foreach($_POST['md'] as $field_id => $value)
{
switch($def->getFieldType())
{
if(is_array($value) and $_POST['md_activated'][$field_id])
{
$dt['year'] = (int) $value['date']['y'];
$dt['mon'] = (int) $value['date']['m'];
$dt['mday'] = (int) $value['date']['d'];
$dt['hours'] = (int) 0;
$dt['minutes'] = (int) 0;
$dt['seconds'] = (int) 0;
$date = new ilDate($dt,IL_CAL_FKT_GETDATE);
$value = $date->get(IL_CAL_UNIX);
}
else
{
$value = 0;
}
break;
if(is_array($value) and $_POST['md_activated'][$field_id])
{
$dt['year'] = (int) $value['date']['y'];
$dt['mon'] = (int) $value['date']['m'];
$dt['mday'] = (int) $value['date']['d'];
$dt['hours'] = (int) $value['time']['h'];
$dt['minutes'] = (int) $value['time']['m'];
$dt['seconds'] = (int) 0;
$date = new ilDateTime($dt,IL_CAL_FKT_GETDATE);
$value = $date->get(IL_CAL_UNIX);
}
else
{
$value = 0;
}
break;
default:
$value = ilUtil::stripSlashes($value);
break;
}
$val = ilAdvancedMDValue::_getInstance($this->obj_id,$field_id);
$val->setValue($value);
$this->values[] = $val;
unset($value);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::parse ( )

Get HTML.

public

Parameters

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

References parseEditor(), parseInfoPage(), and parseSearch().

{
switch($this->mode)
{
case self::MODE_EDITOR:
return $this->parseEditor();
case self::MODE_SEARCH:
return $this->parseSearch();
case self::MODE_INFO:
return $this->parseInfoPage();
default:
die('Not implemented yet');
}
}

+ Here is the call graph for this function:

ilAdvancedMDRecordGUI::parseDuration (   $u_start,
  $u_end 
)
protected

parse hours and minutes from duration

protected

Parameters
@return

Definition at line 648 of file class.ilAdvancedMDRecordGUI.php.

Referenced by showECSStart().

{
if($u_start >= $u_end)
{
return array(0,0);
}
$diff = $u_end - $u_start;
$hours = (int) ($diff / (60 * 60));
$min = (int) (($diff % 3600) / 60);
return array($hours,$min);
}

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::parseEditor ( )
private

Parse property form in editor mode.

private

Definition at line 260 of file class.ilAdvancedMDRecordGUI.php.

References $section, ilAdvancedMDRecord\_getActivatedRecordsByObjectType(), ilAdvancedMDFieldDefinition\_getDefinitionsByRecordId(), ilAdvancedMDValue\_getInstance(), handleECSDefinitions(), IL_CAL_UNIX, ilAdvancedMDFieldDefinition\TYPE_DATE, ilAdvancedMDFieldDefinition\TYPE_DATETIME, ilAdvancedMDFieldDefinition\TYPE_SELECT, and ilAdvancedMDFieldDefinition\TYPE_TEXT.

Referenced by parse().

{
global $ilUser;
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
foreach(ilAdvancedMDRecord::_getActivatedRecordsByObjectType($this->obj_type) as $record_obj)
{
$section->setTitle($record_obj->getTitle());
$section->setInfo($record_obj->getDescription());
$this->form->addItem($section);
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record_obj->getRecordId()) as $def)
{
if($this->handleECSDefinitions($def))
{
continue;
}
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
$value = ilAdvancedMDValue::_getInstance($this->obj_id,$def->getFieldId());
switch($def->getFieldType())
{
$text = new ilTextInputGUI($def->getTitle(),'md['.$def->getFieldId().']');
$text->setValue($value->getValue());
$text->setSize(40);
$text->setMaxLength(512);
$text->setDisabled($value->isDisabled());
$text->setInfo($def->getDescription());
$this->form->addItem($text);
break;
$select = new ilSelectInputGUI($def->getTitle(),'md['.$def->getFieldId().']');
$select->setOptions($def->getFieldValuesForSelect());
$select->setValue($value->getValue());
$select->setDisabled($value->isDisabled());
$select->setInfo($def->getDescription());
$this->form->addItem($select);
break;
$unixtime = $value->getValue() ? $value->getValue() : mktime(8,0,0,date('m'),date('d'),date('Y'));
$time = new ilDateTimeInputGUI($def->getTitle(),'md['.$def->getFieldId().']');
$time->setShowTime(false);
$time->setDate(new ilDate($unixtime,IL_CAL_UNIX));
$time->enableDateActivation($this->lng->txt('enabled'),
'md_activated['.$def->getFieldId().']',
$value->getValue() ? true : false);
$time->setDisabled($value->isDisabled());
$time->setInfo($def->getDescription());
$this->form->addItem($time);
break;
$unixtime = $value->getValue() ? $value->getValue() : mktime(8,0,0,date('m'),date('d'),date('Y'));
$time = new ilDateTimeInputGUI($def->getTitle(),'md['.$def->getFieldId().']');
$time->setShowTime(true);
$time->setDate(new ilDateTime($unixtime,IL_CAL_UNIX,$ilUser->getTimeZone()));
$time->enableDateActivation($this->lng->txt('enabled'),
'md_activated['.$def->getFieldId().']',
$value->getValue() ? true : false);
$time->setDisabled($value->isDisabled());
$this->form->addItem($time);
break;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::parseInfoPage ( )
private

Definition at line 453 of file class.ilAdvancedMDRecordGUI.php.

References ilAdvancedMDRecord\_getActivatedRecordsByObjectType(), ilAdvancedMDFieldDefinition\_getDefinitionsByRecordId(), ilAdvancedMDValue\_getInstance(), ilDatePresentation\formatDate(), IL_CAL_UNIX, ilAdvancedMDFieldDefinition\TYPE_DATE, ilAdvancedMDFieldDefinition\TYPE_DATETIME, ilAdvancedMDFieldDefinition\TYPE_SELECT, and ilAdvancedMDFieldDefinition\TYPE_TEXT.

Referenced by parse().

{
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
foreach(ilAdvancedMDRecord::_getActivatedRecordsByObjectType($this->obj_type) as $record_obj)
{
$this->info->addSection($record_obj->getTitle());
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record_obj->getRecordId()) as $def)
{
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
$value = ilAdvancedMDValue::_getInstance($this->obj_id,$def->getFieldId());
switch($def->getFieldType())
{
if($value->getValue())
{
$this->info->addProperty($def->getTitle(),$value->getValue());
}
break;
if($value->getValue())
{
$this->info->addProperty($def->getTitle(),$value->getValue());
}
break;
if($value->getValue())
{
$this->info->addProperty($def->getTitle(),ilDatePresentation::formatDate(new ilDate($value->getValue(),IL_CAL_UNIX)));
}
break;
if($value->getValue())
{
$this->info->addProperty($def->getTitle(),ilDatePresentation::formatDate(new ilDateTime($value->getValue(),IL_CAL_UNIX)));
}
break;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::parseSearch ( )
private

Parse search.

private

Parameters

Definition at line 345 of file class.ilAdvancedMDRecordGUI.php.

References $section, ilAdvancedMDRecord\_getActiveSearchableRecords(), ilAdvancedMDFieldDefinition\_getDefinitionsByRecordId(), IL_CAL_UNIX, ilTextInputGUI\setValue(), ilCheckboxInputGUI\setValue(), ilSelectInputGUI\setValue(), ilRadioOption\setValue(), ilAdvancedMDFieldDefinition\TYPE_DATE, ilAdvancedMDFieldDefinition\TYPE_DATETIME, ilAdvancedMDFieldDefinition\TYPE_SELECT, and ilAdvancedMDFieldDefinition\TYPE_TEXT.

Referenced by parse().

{
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
{
$section->setTitle($record->getTitle());
$this->form->addItem($section);
foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $field)
{
if(!$field->isSearchable())
{
continue;
}
switch($field->getFieldType())
{
$group = new ilRadioGroupInputGUI('','boolean['.$field->getFieldId().']');
$group->setValue(isset($this->search_values['boolean'][$field->getFieldId()]) ?
$this->search_values['boolean'][$field->getFieldId()] : 0);
$radio_option = new ilRadioOption($this->lng->txt("search_any_word"),0);
$radio_option->setValue(0);
$group->addOption($radio_option);
$radio_option = new ilRadioOption($this->lng->txt("search_all_words"),1);
$radio_option->setValue(1);
$group->addOption($radio_option);
$text = new ilTextInputGUI($field->getTitle(),$field->getFieldId());
$text->setValue(isset($this->search_values[$field->getFieldId()]) ?
$this->search_values[$field->getFieldId()] :
'');
$text->setSize(30);
$text->setMaxLength(255);
$text->addSubItem($group);
$this->form->addItem($text);
break;
$select = new ilSelectInputGUI($field->getTitle(),$field->getFieldId());
$select->setValue(isset($this->search_values[$field->getFieldId()]) ?
$this->search_values[$field->getFieldId()] :
0);
$options = array(0 => $this->lng->txt('search_any'));
$counter = 1;
foreach($field->getFieldValues() as $key => $value)
{
$options[$counter++] = $value;
}
$select->setOptions($options);
$this->form->addItem($select);
break;
$check = new ilCheckboxInputGUI($field->getTitle(),$field->getFieldId());
$check->setValue(1);
$check->setChecked(isset($this->search_values[$field->getFieldId()]) ?
$this->search_values[$field->getFieldId()] : 0);
$time = new ilDateTimeInputGUI($this->lng->txt('from'),'date_start['.$field->getFieldId().']');
if($field->getFieldType() == ilAdvancedMDFieldDefinition::TYPE_DATE)
{
$time->setShowTime(false);
}
else
{
$time->setShowTime(true);
}
if(isset($this->search_values['date_start'][$field->getFieldId()]) and 0)
{
#$time->setUnixTime($this->toUnixTime($this->search_values['date_start'][$field->getFieldId()]['date'],$this->search_values['date_start'][$field->getFieldId()]['time']));
}
else
{
$time->setDate(new ilDateTime(mktime(8,0,0,date('m'),date('d'),date('Y')),IL_CAL_UNIX));
}
$check->addSubItem($time);
$time = new ilDateTimeInputGUI($this->lng->txt('until'),'date_end['.$field->getFieldId().']');
if($field->getFieldType() == ilAdvancedMDFieldDefinition::TYPE_DATE)
{
$time->setShowTime(false);
}
else
{
$time->setShowTime(true);
}
if(isset($this->search_values['date_end'][$field->getFieldId()]) and 0)
{
#$time->setUnixTime($this->toUnixTime($this->search_values['date_end'][$field->getFieldId()]['date'],$this->search_values['date_end'][$field->getFieldId()]['time']));
}
else
{
$time->setDate(new ilDateTime(mktime(16,0,0,date('m'),date('d'),date('Y')),IL_CAL_UNIX));
}
$check->addSubItem($time);
$this->form->addItem($check);
break;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::saveValues ( )

Save values.

public

Definition at line 245 of file class.ilAdvancedMDRecordGUI.php.

{
foreach($this->values as $value)
{
$value->save();
}
return true;
}
ilAdvancedMDRecordGUI::setInfoObject (   $info)

get info sections

public

Parameters
objectinstance of ilInfoScreenGUI

Definition at line 98 of file class.ilAdvancedMDRecordGUI.php.

Referenced by ilObjRemoteCourseGUI\infoScreen(), ilObjCourseGUI\infoScreen(), and ilObjCategoryGUI\infoScreen().

{
$this->info = $info;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::setPropertyForm (   $form)

set property form object

public

Parameters

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

References $form.

Referenced by ilObjRemoteCourseGUI\initEditTable(), ilObjCategoryGUI\initExtendedSettings(), and ilObjCourseGUI\initInfoEditor().

{
$this->form = $form;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::setSearchValues (   $a_values)

Set values for search form.

public

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

{
$this->search_values = $a_values;
}
ilAdvancedMDRecordGUI::showECSStart (   $def)
private

Show special form for ecs start.

private

Parameters
objectilAdvMDFieldDefinition

Definition at line 555 of file class.ilAdvancedMDRecordGUI.php.

References ilECSDataMappingSettings\_getInstance(), ilAdvancedMDValue\_getInstance(), IL_CAL_UNIX, parseDuration(), ilDurationInputGUI\setHours(), ilAdvancedMDFieldDefinition\TYPE_SELECT, and ilAdvancedMDFieldDefinition\TYPE_TEXT.

Referenced by handleECSDefinitions().

{
global $ilUser;
$this->lng->loadLanguageModule('ecs');
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
$value_start = ilAdvancedMDValue::_getInstance($this->obj_id,$def->getFieldId());
$unixtime = $value_start->getValue() ? $value_start->getValue() : mktime(8,0,0,date('m'),date('d'),date('Y'));
$time = new ilDateTimeInputGUI($this->lng->txt('ecs_event_appointment'),'md['.$def->getFieldId().']');
$time->setShowTime(true);
$time->setDate(new ilDateTime($unixtime,IL_CAL_UNIX));
$time->enableDateActivation($this->lng->txt('enabled'),
'md_activated['.$def->getFieldId().']',
$value_start->getValue() ? true : false);
$time->setDisabled($value_start->isDisabled());
if($field_id = $mapping->getMappingByECSName('end'))
{
$value_end = ilAdvancedMDValue::_getInstance($this->obj_id,$field_id);
list($hours,$minutes) = $this->parseDuration($value_start->getValue(),$value_end->getValue());
$duration = new ilDurationInputGUI($this->lng->txt('ecs_duration'),'ecs_duration');
$duration->setHours($hours);
$duration->setMinutes($minutes);
#$duration->setInfo($this->lng->txt('ecs_duration_info'));
$duration->setShowHours(true);
$duration->setShowMinutes(true);
$time->addSubItem($duration);
}
if($field_id = $mapping->getMappingByECSName('cycle'))
{
$value = ilAdvancedMDValue::_getInstance($this->obj_id,$field_id);
$cycle_def = new ilAdvancedMDFieldDefinition($field_id);
switch($cycle_def->getFieldType())
{
$text = new ilTextInputGUI($cycle_def->getTitle(),'md['.$cycle_def->getFieldId().']');
$text->setValue($value->getValue());
$text->setSize(20);
$text->setMaxLength(512);
$text->setDisabled($value->isDisabled());
$time->addSubItem($text);
break;
$select = new ilSelectInputGUI($cycle_def->getTitle(),'md['.$cycle_def->getFieldId().']');
$select->setOptions($cycle_def->getFieldValuesForSelect());
$select->setValue($value->getValue());
$select->setDisabled($value->isDisabled());
$time->addSubItem($select);
break;
}
}
if($field_id = $mapping->getMappingByECSName('room'))
{
$value = ilAdvancedMDValue::_getInstance($this->obj_id,$field_id);
$room_def = new ilAdvancedMDFieldDefinition($field_id);
switch($room_def->getFieldType())
{
$text = new ilTextInputGUI($room_def->getTitle(),'md['.$room_def->getFieldId().']');
$text->setValue($value->getValue());
$text->setSize(20);
$text->setMaxLength(512);
$text->setDisabled($value->isDisabled());
$time->addSubItem($text);
break;
$select = new ilSelectInputGUI($room_def->getTitle(),'md['.$room_def->getFieldId().']');
$select->setOptions($cycle_def->getFieldValuesForSelect());
$select->setValue($value->getValue());
$select->setDisabled($value->isDisabled());
$time->addSubItem($select);
break;
}
}
$this->form->addItem($time);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordGUI::toUnixTime (   $date,
  $time = array() 
)
private

convert input array to unix time

private

Parameters

Definition at line 507 of file class.ilAdvancedMDRecordGUI.php.

Referenced by loadECSDurationPost().

{
return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
}

+ Here is the caller graph for this function:

Field Documentation

ilAdvancedMDRecordGUI::$form
private

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

Referenced by setPropertyForm().

ilAdvancedMDRecordGUI::$lng
protected

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

Referenced by __construct().

ilAdvancedMDRecordGUI::$mode
private

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

ilAdvancedMDRecordGUI::$obj_id
private

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

ilAdvancedMDRecordGUI::$obj_type
private

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

ilAdvancedMDRecordGUI::$search_values = array()
private

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

ilAdvancedMDRecordGUI::$values = array()
private

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

const ilAdvancedMDRecordGUI::MODE_INFO = 3
const ilAdvancedMDRecordGUI::MODE_SEARCH = 2

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