Files
iTop/sources/Application/UI/Base/Component/Input/tInputLabel.php
Pierre Goiffon d437e2d662 Merge remote-tracking branch 'origin/support/3.0' into develop
# Conflicts:
#	application/displayblock.class.inc.php
#	core/config.class.inc.php
#	datamodels/2.x/authent-cas/module.authent-cas.php
#	datamodels/2.x/authent-external/module.authent-external.php
#	datamodels/2.x/authent-ldap/module.authent-ldap.php
#	datamodels/2.x/authent-local/module.authent-local.php
#	datamodels/2.x/combodo-backoffice-darkmoon-theme/module.combodo-backoffice-darkmoon-theme.php
#	datamodels/2.x/combodo-db-tools/module.combodo-db-tools.php
#	datamodels/2.x/itop-attachments/module.itop-attachments.php
#	datamodels/2.x/itop-backup/module.itop-backup.php
#	datamodels/2.x/itop-bridge-cmdb-ticket/module.itop-bridge-cmdb-ticket.php
#	datamodels/2.x/itop-bridge-virtualization-storage/module.itop-bridge-virtualization-storage.php
#	datamodels/2.x/itop-change-mgmt-itil/module.itop-change-mgmt-itil.php
#	datamodels/2.x/itop-change-mgmt/module.itop-change-mgmt.php
#	datamodels/2.x/itop-config-mgmt/module.itop-config-mgmt.php
#	datamodels/2.x/itop-config/module.itop-config.php
#	datamodels/2.x/itop-core-update/module.itop-core-update.php
#	datamodels/2.x/itop-datacenter-mgmt/module.itop-datacenter-mgmt.php
#	datamodels/2.x/itop-endusers-devices/module.itop-endusers-devices.php
#	datamodels/2.x/itop-faq-light/module.itop-faq-light.php
#	datamodels/2.x/itop-files-information/module.itop-files-information.php
#	datamodels/2.x/itop-full-itil/module.itop-full-itil.php
#	datamodels/2.x/itop-hub-connector/module.itop-hub-connector.php
#	datamodels/2.x/itop-incident-mgmt-itil/module.itop-incident-mgmt-itil.php
#	datamodels/2.x/itop-knownerror-mgmt/module.itop-knownerror-mgmt.php
#	datamodels/2.x/itop-portal-base/module.itop-portal-base.php
#	datamodels/2.x/itop-portal/module.itop-portal.php
#	datamodels/2.x/itop-problem-mgmt/module.itop-problem-mgmt.php
#	datamodels/2.x/itop-profiles-itil/module.itop-profiles-itil.php
#	datamodels/2.x/itop-request-mgmt-itil/module.itop-request-mgmt-itil.php
#	datamodels/2.x/itop-request-mgmt/module.itop-request-mgmt.php
#	datamodels/2.x/itop-service-mgmt-provider/module.itop-service-mgmt-provider.php
#	datamodels/2.x/itop-service-mgmt/module.itop-service-mgmt.php
#	datamodels/2.x/itop-sla-computation/module.itop-sla-computation.php
#	datamodels/2.x/itop-storage-mgmt/module.itop-storage-mgmt.php
#	datamodels/2.x/itop-structure/module.itop-structure.php
#	datamodels/2.x/itop-tickets/module.itop-tickets.php
#	datamodels/2.x/itop-virtualization-mgmt/module.itop-virtualization-mgmt.php
#	datamodels/2.x/itop-welcome-itil/module.itop-welcome-itil.php
#	datamodels/2.x/version.xml
2022-02-08 15:43:20 +01:00

122 lines
2.4 KiB
PHP

<?php
/**
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Input;
/**
* Trait tInputLabel Label for input
*
* @package Combodo\iTop\Application\UI\Base\Component\Input
*/
trait tInputLabel
{
/** @var bool If true the label will be positioned before the input */
protected $bIsLabelBefore = true;
/** @var string|null Label to display with the input (null for no label) */
protected $sLabel = null;
/**
* @var string|null $sDescription for tooltip
* @since 3.0.1
*/
protected $sDescription = null;
/**
* @return bool
*/
public function IsLabelBefore(): bool
{
return $this->bIsLabelBefore;
}
/**
* @param bool $bIsLabelBefore {@see tInputLabel::$bIsLabelBefore}
*
* @return $this
*/
public function SetIsLabelBefore(bool $bIsLabelBefore)
{
$this->bIsLabelBefore = $bIsLabelBefore;
if ($this->bIsLabelBefore) {
$this->AddCSSClass('ibo-input--label-left');
$this->RemoveCSSClass('ibo-input--label-right');
} else {
$this->AddCSSClass('ibo-input--label-right');
$this->RemoveCSSClass('ibo-input--label-left');
}
return $this;
}
/**
* @return string|null
*/
public function GetLabel(): ?string
{
return $this->sLabel;
}
/**
* @param string|null $sLabel {@see tInputLabel::$sLabel}
*
* @return $this
*/
public function SetLabel(?string $sLabel)
{
$this->sLabel = $sLabel;
if (!is_null($sLabel)) {
if ($this->bIsLabelBefore) {
$this->AddCSSClass('ibo-input--label-left');
$this->RemoveCSSClass('ibo-input--label-right');
} else {
$this->AddCSSClass('ibo-input--label-right');
$this->RemoveCSSClass('ibo-input--label-left');
}
} else {
$this->RemoveCSSClass('ibo-input--label-right');
$this->RemoveCSSClass('ibo-input--label-left');
}
return $this;
}
/**
* @return bool
*/
public function HasLabel(): bool
{
return strlen($this->sLabel) > 0;
}
/**
* @return string|null
* @since 3.0.1
*/
public function GetDescription(): ?string
{
return $this->sDescription;
}
/**
* @param string|null $sDescription
* @return $this
* @since 3.0.1
*/
public function SetDescription(?string $sDescription)
{
$this->sDescription = $sDescription;
return $this;
}
/**
* @return bool
* @since 3.0.1
*/
public function HasDescription(): bool
{
return strlen($this->sDescription) > 0;
}
}