3declare(strict_types=1);
19 $this->db =
$DIC->database();
27 $query =
'DELETE FROM adv_md_record_obj_ord ' .
28 'WHERE obj_id = ' . $this->db->quote($obj_id,
'integer');
29 $this->db->manipulate(
$query);
37 public function sortRecords(array $records,
int $obj_id =
null): array
79 if (
$a->getGlobalPosition() ==
null) {
80 $a->setGlobalPosition(999);
82 if (
$b->getGlobalPosition() ==
null) {
83 $b->setGlobalPosition(999);
86 if (
$a->getGlobalPosition() <
$b->getGlobalPosition()) {
89 if (
$a->getGlobalPosition() >
$b->getGlobalPosition()) {
102 $local_pos_a = $this->record_position_map[
$a->getRecordId()] ??
103 (
$a->getGlobalPosition() ?: 999);
104 $local_pos_b = $this->record_position_map[
$b->getRecordId()] ??
105 (
$b->getGlobalPosition() ?: 999);
106 if ($local_pos_a < $local_pos_b) {
109 if ($local_pos_a > $local_pos_b) {
120 $query =
'SELECT record_id, position FROM adv_md_record_obj_ord ' .
121 'WHERE obj_id = ' . $this->db->quote($obj_id,
'integer');
124 $this->record_position_map = [];
126 $this->record_position_map[(
int) $row->record_id] = (
int) $row->position;
sortRecords(array $records, int $obj_id=null)
readPositionsForObject(int $obj_id)
Read local positions for object.
compareRecords(ilAdvancedMDRecord $a, ilAdvancedMDRecord $b)
deleteByObjId(int $obj_id)
Delete entries by obj_id.
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