N°4621 Fix naming inconsistencies in sources/*

This commit is contained in:
Pierre Goiffon
2021-12-31 15:21:08 +01:00
parent 16142bd979
commit 5f575d524a
192 changed files with 384 additions and 380 deletions

View File

@@ -0,0 +1,98 @@
<?php
/**
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Input\Select;
use Combodo\iTop\Application\UI\Base\Component\Input\tInputLabel;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
class Select extends UIContentBlock
{
use tInputLabel;
// Overloaded constants
public const BLOCK_CODE = 'ibo-select';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/input/select/select';
/** @var string Input name for the form */
protected $sName;
/** @var bool if true submit the form as soon as a change is detected */
protected $bSubmitOnChange = false;
/** @var bool Allow multiple selection */
protected $bIsMultiple = false;
public function __construct(?string $sId = null)
{
parent::__construct($sId);
$this->bIsMultiple = false;
}
/**
* @param SelectOption $oOption Select option UIBlock
*/
public function AddOption(SelectOption $oOption)
{
$this->AddSubBlock($oOption);
}
public function GetName(): string
{
return $this->sName;
}
/**
* @param string $sName {@see Select::$sName}
*
* @return $this
*/
public function SetName(string $sName)
{
$this->sName = $sName;
return $this;
}
/**
* @return bool {@see Select::$bSubmitOnChange}
*/
public function GetSubmitOnChange(): bool
{
return $this->bSubmitOnChange;
}
/**
* @param bool $bSubmitOnChange {@see Select::$bSubmitOnChange}
*
* @return $this
*/
public function SetSubmitOnChange(bool $bSubmitOnChange)
{
$this->bSubmitOnChange = $bSubmitOnChange;
return $this;
}
/**
* @return bool {@see Select::$bIsMultiple}
*/
public function IsMultiple(): bool
{
return $this->bIsMultiple;
}
/**
* @param bool $bIsMultiple {@see Select::$bIsMultiple}
*/
public function SetIsMultiple(bool $bIsMultiple)
{
$this->bIsMultiple = $bIsMultiple;
return $this;
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Input\Select;
use Combodo\iTop\Application\UI\Base\UIBlock;
class SelectOption extends UIBlock
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-select-option';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/input/select/selectoption';
/** @var string */
protected $sValue;
/** @var string */
protected $sLabel;
/** @var bool */
protected $bSelected;
/** @var bool */
protected $bDisabled;
/**
* @return string
*/
public function GetValue(): string
{
return $this->sValue;
}
/**
* @param string $sValue
*
* @return SelectOption
*/
public function SetValue(string $sValue)
{
$this->sValue = $sValue;
return $this;
}
/**
* @return string
*/
public function GetLabel(): string
{
return $this->sLabel;
}
/**
* @param string $sLabel
*
* @return SelectOption
*/
public function SetLabel(string $sLabel)
{
$this->sLabel = $sLabel;
return $this;
}
/**
* @return bool
*/
public function IsSelected(): bool
{
return $this->bSelected;
}
/**
* @param bool $bSelected
*
* @return SelectOption
*/
public function SetSelected(bool $bSelected)
{
$this->bSelected = $bSelected;
return $this;
}
/**
* @return bool
*/
public function IsDisabled(): bool
{
return $this->bDisabled;
}
/**
* @param bool $bDisabled
*
* @return $this
*/
public function SetDisabled(bool $bDisabled)
{
$this->bDisabled = $bDisabled;
return $this;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Input\Select;
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
/**
* Class SelectOptionUIBlockFactory
*
* @author Eric Espie <eric.espie@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\Input\Select
* @since 3.0.0
* @internal
*/
class SelectOptionUIBlockFactory extends AbstractUIBlockFactory
{
/** @inheritDoc */
public const TWIG_TAG_NAME = 'UISelectOption';
/** @inheritDoc */
public const UI_BLOCK_CLASS_NAME = SelectOption::class;
public static function MakeForSelectOption(string $sValue, string $sLabel, bool $bSelected, ?string $sId = null)
{
$oInput = new SelectOption($sId);
$oInput->SetValue($sValue)
->SetLabel($sLabel)
->SetSelected($bSelected)
->SetDisabled(false);
return $oInput;
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Input;
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Input\Select\Select;
/**
* Class SelectUIBlockFactory
*
* @author Eric Espie <eric.espie@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\Input
* @since 3.0.0
* @internal
*/
class SelectUIBlockFactory extends AbstractUIBlockFactory
{
/** @inheritDoc */
public const TWIG_TAG_NAME = 'UISelect';
/** @inheritDoc */
public const UI_BLOCK_CLASS_NAME = Select::class;
/**
* Create a default Select input
*
* @param string $sName {@see Select::$sName}
* @param string|null $sId {@see UIBlock::$sId}
*
* @return \Combodo\iTop\Application\UI\Base\Component\Input\Select\Select
*/
public static function MakeForSelect(string $sName, ?string $sId = null)
{
$oInput = new Select($sId);
$oInput->SetName($sName);
return $oInput;
}
/**
* Create a Select input with a label
*
* If you need to have a real field with a label, you might use a {@link Field} component instead
*
* @param string $sName {@see Select::$sName}
* @param string $sLabel {@see Select::$sLabel}
* @param string|null $sId {@see UIBlock::$sId}
*
* @return \Combodo\iTop\Application\UI\Base\Component\Input\Select\Select
*/
public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null)
{
$oInput = new Select($sId);
$oInput->SetName($sName);
$oInput->SetLabel($sLabel);
return $oInput;
}
}