29 $this->db =
$DIC->database();
41 $query =
'DELETE FROM adv_md_record_obj_ord ' .
42 'WHERE obj_id = ' . $this->db->quote($obj_id,
'integer');
43 $this->db->manipulate(
$query);
51 public function sortRecords(array $records,
int $obj_id =
null)
94 if (
$a->getGlobalPosition() ==
null) {
95 $a->setGlobalPosition(999);
97 if (
$b->getGlobalPosition() ==
null) {
98 $b->setGlobalPosition(999);
101 if (
$a->getGlobalPosition() ==
$b->getGlobalPosition()) {
104 if (
$a->getGlobalPosition() <
$b->getGlobalPosition()) {
107 if (
$a->getGlobalPosition() >
$b->getGlobalPosition()) {
119 $local_pos_a = isset($this->record_position_map[
$a->getRecordId()]) ?
120 $this->record_position_map[
$a->getRecordId()] :
122 $a->getGlobalPosition() ?
123 $a->getGlobalPosition() :
126 $local_pos_b = isset($this->record_position_map[
$b->getRecordId()]) ?
127 $this->record_position_map[
$b->getRecordId()] :
129 $b->getGlobalPosition() ?
130 $b->getGlobalPosition() :
133 if ($local_pos_a == $local_pos_b) {
136 if ($local_pos_a < $local_pos_b) {
139 if ($local_pos_a > $local_pos_b) {
151 $query =
'SELECT record_id, position FROM adv_md_record_obj_ord ' .
152 'WHERE obj_id = ' . $this->db->quote($obj_id,
'integer');
155 $this->record_position_map = [];
157 $this->record_position_map[$row->record_id] = $row->position;
An exception for terminatinating execution or to throw for unit testing.
sortRecords(array $records, int $obj_id=null)
readPositionsForObject(int $obj_id)
Read local positions for object.
compareRecords(\ilAdvancedMDRecord $a, \ilAdvancedMDRecord $b)
compareLocalRecords(\ilAdvancedMDRecord $a, \ilAdvancedMDRecord $b)
deleteByObjId(int $obj_id)
Delete entries by obj_id.
__construct()
ilAdvancedMDRecordObjectOrderings constructor.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
foreach($_POST as $key=> $value) $res