xref: /plugin/struct/meta/RowColumn.php (revision 0ceefd5c55d49dcf9a9f59c8e57e60eaeea1c187)
1f107f479SAndreas Gohr<?php
2f107f479SAndreas Gohr
3f107f479SAndreas Gohrnamespace dokuwiki\plugin\struct\meta;
4f107f479SAndreas Gohr
5f107f479SAndreas Gohruse dokuwiki\plugin\struct\types\Decimal;
6f107f479SAndreas Gohr
7f107f479SAndreas Gohr/**
8f107f479SAndreas Gohr * Like a Page Column but for Lookups using a decimal type
9f107f479SAndreas Gohr */
10f107f479SAndreas Gohrclass RowColumn extends PageColumn {
11f107f479SAndreas Gohr
12f107f479SAndreas Gohr    /** @noinspection PhpMissingParentConstructorInspection
13f107f479SAndreas Gohr     * @param int $sort
14f107f479SAndreas Gohr     * @param Decimal $type
15f107f479SAndreas Gohr     * @param string $table
16f107f479SAndreas Gohr     */
17f107f479SAndreas Gohr    public function __construct($sort, Decimal $type, $table) {
18f107f479SAndreas Gohr        if($type->isMulti()) throw new StructException('RowColumns can not be multi value types!');
19f107f479SAndreas Gohr        Column::__construct($sort, $type, 0, true, $table);
20f107f479SAndreas Gohr    }
21f107f479SAndreas Gohr
22f107f479SAndreas Gohr    /**
23f107f479SAndreas Gohr     * @return string always '%rowid%'
24f107f479SAndreas Gohr     */
25f107f479SAndreas Gohr    public function getLabel() {
26f107f479SAndreas Gohr        return '%rowid%';
27f107f479SAndreas Gohr    }
28f107f479SAndreas Gohr
29f107f479SAndreas Gohr    /**
30*0ceefd5cSAnna Dabrowska     * @param bool $enforceSingleColumn ignored
31*0ceefd5cSAnna Dabrowska     * @return string
32*0ceefd5cSAnna Dabrowska     */
33*0ceefd5cSAnna Dabrowska    public function getColName($enforceSingleColumn = true) {
34*0ceefd5cSAnna Dabrowska        return 'rid';
35*0ceefd5cSAnna Dabrowska    }
36*0ceefd5cSAnna Dabrowska
37*0ceefd5cSAnna Dabrowska    /**
38f107f479SAndreas Gohr     * @return string preconfigured label
39f107f479SAndreas Gohr     */
40f107f479SAndreas Gohr    public function getTranslatedLabel() {
41f107f479SAndreas Gohr        /** @var \helper_plugin_struct_config $helper */
42f107f479SAndreas Gohr        $helper = plugin_load('helper', 'struct_config');
43f107f479SAndreas Gohr        return $helper->getLang('rowlabel');
44f107f479SAndreas Gohr    }
45f107f479SAndreas Gohr}
46