xref: /plugin/struct/meta/RowColumn.php (revision 0549dcc5bc88d4f9d923acdd09931d8d51be7097)
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 */
10*d6d97f60SAnna Dabrowskaclass RowColumn extends PageColumn
11*d6d97f60SAnna Dabrowska{
12f107f479SAndreas Gohr    /** @noinspection PhpMissingParentConstructorInspection
13f107f479SAndreas Gohr     * @param int $sort
14f107f479SAndreas Gohr     * @param Decimal $type
15f107f479SAndreas Gohr     * @param string $table
16f107f479SAndreas Gohr     */
17*d6d97f60SAnna Dabrowska    public function __construct($sort, Decimal $type, $table)
18*d6d97f60SAnna Dabrowska    {
19f107f479SAndreas Gohr        if ($type->isMulti()) throw new StructException('RowColumns can not be multi value types!');
20f107f479SAndreas Gohr        Column::__construct($sort, $type, 0, true, $table);
21f107f479SAndreas Gohr    }
22f107f479SAndreas Gohr
23f107f479SAndreas Gohr    /**
24f107f479SAndreas Gohr     * @return string always '%rowid%'
25f107f479SAndreas Gohr     */
26*d6d97f60SAnna Dabrowska    public function getLabel()
27*d6d97f60SAnna Dabrowska    {
28f107f479SAndreas Gohr        return '%rowid%';
29f107f479SAndreas Gohr    }
30f107f479SAndreas Gohr
31f107f479SAndreas Gohr    /**
320ceefd5cSAnna Dabrowska     * @param bool $enforceSingleColumn ignored
330ceefd5cSAnna Dabrowska     * @return string
340ceefd5cSAnna Dabrowska     */
35*d6d97f60SAnna Dabrowska    public function getColName($enforceSingleColumn = true)
36*d6d97f60SAnna Dabrowska    {
370ceefd5cSAnna Dabrowska        return 'rid';
380ceefd5cSAnna Dabrowska    }
390ceefd5cSAnna Dabrowska
400ceefd5cSAnna Dabrowska    /**
41f107f479SAndreas Gohr     * @return string preconfigured label
42f107f479SAndreas Gohr     */
43*d6d97f60SAnna Dabrowska    public function getTranslatedLabel()
44*d6d97f60SAnna Dabrowska    {
45f107f479SAndreas Gohr        /** @var \helper_plugin_struct_config $helper */
46f107f479SAndreas Gohr        $helper = plugin_load('helper', 'struct_config');
47f107f479SAndreas Gohr        return $helper->getLang('rowlabel');
48f107f479SAndreas Gohr    }
49f107f479SAndreas Gohr}
50