mirror of
https://github.com/Combodo/iTop.git
synced 2026-09-01 02:48:19 +02:00
--------- Co-authored-by: Molkobain <lajarige.guillaume@free.fr> Co-authored-by: Benjamin DALSASS <benjamin.dalsass@combodo.com>
93 lines
2.5 KiB
PHP
93 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Copyright (C) 2013-2026 Combodo SAS
|
|
*
|
|
* This file is part of iTop.
|
|
*
|
|
* iTop is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* iTop is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
*/
|
|
|
|
namespace Combodo\iTop\Application\UI\Base\Layout\TopBar\TopBarAction;
|
|
|
|
use Combodo\iTop\Application\UI\Base\Common\Action\tActionCommon;
|
|
use Combodo\iTop\Application\UI\Base\UIBlock;
|
|
use utils;
|
|
|
|
/**
|
|
* Class TopBarAction
|
|
*
|
|
* @package Combodo\iTop\Application\UI\Base\Layout\TopBar\TopBarAction
|
|
* @internal
|
|
* @since 3.3.0
|
|
*/
|
|
abstract class TopBarQuickAction extends UIBlock
|
|
{
|
|
use tActionCommon;
|
|
|
|
// Overloaded constants
|
|
public const BLOCK_CODE = 'ibo-top-bar-quick-action';
|
|
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/top-bar/top-bar-quick-action/layout';
|
|
public const DEFAULT_JS_FILES_REL_PATH = [
|
|
];
|
|
public const DEFAULT_CSS_FILES_REL_PATH = [
|
|
];
|
|
|
|
/**
|
|
* TopBarAction constructor.
|
|
*
|
|
* @param string $sLabel
|
|
* @param string $sIconClass
|
|
* @param string|null $sTooltip
|
|
* @param string $sUid
|
|
*
|
|
* @throws \CoreException
|
|
* @throws \DictExceptionMissingString
|
|
*/
|
|
public function __construct(string $sLabel, string $sIconClass, ?string $sTooltip, string $sUid)
|
|
{
|
|
// UID is necessary for parent ID generation, we set it first
|
|
$this->sUid = $sUid;
|
|
parent::__construct();
|
|
$this->sLabel = $sLabel;
|
|
$this->sIconClass = $sIconClass;
|
|
$this->sTooltip = $sTooltip;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
protected function GenerateId(): string
|
|
{
|
|
return parent::GenerateId().'--'.utils::GetSafeId($this->sUid, true);
|
|
}
|
|
|
|
public function GetAriaAttributes(): array
|
|
{
|
|
$aDefaultValues = [];
|
|
// Keep the label as the default accessible name, falling back to the tooltip
|
|
if (utils::IsNotNullOrEmptyString($this->sLabel)) {
|
|
$aDefaultValues['label'] = $this->sLabel;
|
|
} elseif (utils::IsNotNullOrEmptyString($this->sTooltip)) {
|
|
$aDefaultValues['label'] = $this->sTooltip;
|
|
}
|
|
|
|
return array_merge($aDefaultValues, parent::GetAriaAttributes());
|
|
}
|
|
|
|
public function HasAriaAttributes(): bool
|
|
{
|
|
return !empty($this->GetAriaAttributes());
|
|
}
|
|
}
|