19declare(strict_types=1);
33 $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): array
93 if (
$a->getGlobalPosition() ==
null) {
94 $a->setGlobalPosition(999);
96 if (
$b->getGlobalPosition() ==
null) {
97 $b->setGlobalPosition(999);
100 if (
$a->getGlobalPosition() <
$b->getGlobalPosition()) {
103 if (
$a->getGlobalPosition() >
$b->getGlobalPosition()) {
116 $local_pos_a = $this->record_position_map[
$a->getRecordId()] ??
117 (
$a->getGlobalPosition() ?: 999);
118 $local_pos_b = $this->record_position_map[
$b->getRecordId()] ??
119 (
$b->getGlobalPosition() ?: 999);
120 if ($local_pos_a < $local_pos_b) {
123 if ($local_pos_a > $local_pos_b) {
134 $query =
'SELECT record_id, position FROM adv_md_record_obj_ord ' .
135 'WHERE obj_id = ' . $this->db->quote($obj_id,
'integer');
136 $res = $this->db->query($query);
138 $this->record_position_map = [];
140 $this->record_position_map[(
int) $row->record_id] = (
int) $row->position;
readPositionsForObject(int $obj_id)
Read local positions for object.
compareRecords(ilAdvancedMDRecord $a, ilAdvancedMDRecord $b)
deleteByObjId(int $obj_id)
Delete entries by obj_id.
sortRecords(array $records, ?int $obj_id=null)
array $record_position_map
compareLocalRecords(ilAdvancedMDRecord $a, ilAdvancedMDRecord $b)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples