mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -19,7 +20,6 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Button;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\UIBlock;
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ class Button extends UIBlock
|
||||
'js/components/button.js',
|
||||
];
|
||||
public const REQUIRES_ANCESTORS_DEFAULT_JS_FILES = true;
|
||||
|
||||
|
||||
// Specific constants
|
||||
/** @var string ENUM_ACTION_TYPE_REGULAR */
|
||||
public const ENUM_ACTION_TYPE_REGULAR = 'regular';
|
||||
@@ -271,4 +271,4 @@ class Button extends UIBlock
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -19,7 +20,6 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Button;
|
||||
|
||||
|
||||
/**
|
||||
* Class Button
|
||||
*
|
||||
@@ -66,19 +66,34 @@ class ButtonJS extends Button
|
||||
* @param string $sOnClickJsCode
|
||||
*/
|
||||
public function __construct(
|
||||
string $sLabel, string $sId = null, string $sName = '', string $sValue = '', string $sType = self::DEFAULT_TYPE,
|
||||
string $sTooltip = '', string $sIconClass = '',
|
||||
string $sActionType = self::DEFAULT_ACTION_TYPE, string $sColor = self::DEFAULT_COLOR_SCHEME, string $sJsCode = '',
|
||||
string $sLabel,
|
||||
string $sId = null,
|
||||
string $sName = '',
|
||||
string $sValue = '',
|
||||
string $sType = self::DEFAULT_TYPE,
|
||||
string $sTooltip = '',
|
||||
string $sIconClass = '',
|
||||
string $sActionType = self::DEFAULT_ACTION_TYPE,
|
||||
string $sColor = self::DEFAULT_COLOR_SCHEME,
|
||||
string $sJsCode = '',
|
||||
string $sOnClickJsCode = ''
|
||||
) {
|
||||
parent::__construct( $sLabel,$sId, $sTooltip, $sIconClass,
|
||||
$sActionType, $sColor, $sJsCode, $sOnClickJsCode);
|
||||
parent::__construct(
|
||||
$sLabel,
|
||||
$sId,
|
||||
$sTooltip,
|
||||
$sIconClass,
|
||||
$sActionType,
|
||||
$sColor,
|
||||
$sJsCode,
|
||||
$sOnClickJsCode
|
||||
);
|
||||
|
||||
$this->sName = $sName;
|
||||
$this->sValue = $sValue;
|
||||
$this->sType = $sType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -135,4 +150,4 @@ class ButtonJS extends Button
|
||||
$this->sValue = $sValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -149,8 +150,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SCHEME_DESTRUCTIVE, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
return static::MakeForAction(
|
||||
$sLabel,
|
||||
Button::ENUM_COLOR_SCHEME_DESTRUCTIVE,
|
||||
Button::ENUM_ACTION_TYPE_REGULAR,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@@ -175,8 +183,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SCHEME_NEUTRAL, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
return static::MakeForAction(
|
||||
$sLabel,
|
||||
Button::ENUM_COLOR_SCHEME_NEUTRAL,
|
||||
Button::ENUM_ACTION_TYPE_ALTERNATIVE,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,8 +213,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SCHEME_PRIMARY, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
return static::MakeForAction(
|
||||
$sLabel,
|
||||
Button::ENUM_COLOR_SCHEME_PRIMARY,
|
||||
Button::ENUM_ACTION_TYPE_ALTERNATIVE,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,8 +242,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SCHEME_SECONDARY, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
return static::MakeForAction(
|
||||
$sLabel,
|
||||
Button::ENUM_COLOR_SCHEME_SECONDARY,
|
||||
Button::ENUM_ACTION_TYPE_ALTERNATIVE,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,8 +271,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SCHEME_VALIDATION, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
return static::MakeForAction(
|
||||
$sLabel,
|
||||
Button::ENUM_COLOR_SCHEME_VALIDATION,
|
||||
Button::ENUM_ACTION_TYPE_ALTERNATIVE,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,8 +300,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SCHEME_DESTRUCTIVE, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
return static::MakeForAction(
|
||||
$sLabel,
|
||||
Button::ENUM_COLOR_SCHEME_DESTRUCTIVE,
|
||||
Button::ENUM_ACTION_TYPE_ALTERNATIVE,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,8 +332,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
$sLabel = $sLabel ?? Dict::S('UI:Button:Cancel');
|
||||
$sName = $sName ?? 'cancel';
|
||||
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SCHEME_NEUTRAL, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
return static::MakeForAction(
|
||||
$sLabel,
|
||||
Button::ENUM_COLOR_SCHEME_NEUTRAL,
|
||||
Button::ENUM_ACTION_TYPE_ALTERNATIVE,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,8 +361,15 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
$oButton = static::MakeForAction('', Button::ENUM_COLOR_SCHEME_NEUTRAL, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit, $sId);
|
||||
$oButton = static::MakeForAction(
|
||||
'',
|
||||
Button::ENUM_COLOR_SCHEME_NEUTRAL,
|
||||
Button::ENUM_ACTION_TYPE_ALTERNATIVE,
|
||||
$sValue,
|
||||
$sName,
|
||||
$bIsSubmit,
|
||||
$sId
|
||||
);
|
||||
$oButton->SetIconClass($sIconClasses);
|
||||
$oButton->SetTooltip($sTooltipText);
|
||||
|
||||
@@ -335,14 +392,17 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Button\Button
|
||||
*/
|
||||
public static function MakeLinkNeutral(
|
||||
string $sURL, ?string $sLabel = '', ?string $sIconClasses = null, ?string $sTarget = null,
|
||||
string $sURL,
|
||||
?string $sLabel = '',
|
||||
?string $sIconClasses = null,
|
||||
?string $sTarget = null,
|
||||
?string $sId = null
|
||||
) {
|
||||
if (empty($sTarget)) {
|
||||
$sTarget = ButtonURL::DEFAULT_TARGET;
|
||||
}
|
||||
$sType = empty($sIconClasses) ? Button::ENUM_ACTION_TYPE_REGULAR : Button::ENUM_ACTION_TYPE_ALTERNATIVE;
|
||||
$oButton = static::MakeForLink($sLabel, $sURL,Button::ENUM_COLOR_SCHEME_NEUTRAL, $sType, $sTarget, $sId);
|
||||
$oButton = static::MakeForLink($sLabel, $sURL, Button::ENUM_COLOR_SCHEME_NEUTRAL, $sType, $sTarget, $sId);
|
||||
|
||||
if (!empty($sIconClasses)) {
|
||||
$oButton->SetIconClass($sIconClasses);
|
||||
@@ -361,19 +421,22 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Button\ButtonURL
|
||||
*/
|
||||
public static function MakeIconLink(
|
||||
string $sIconClasses, string $sTooltipText, ?string $sURL = '', ?string $sTarget = null,
|
||||
string $sIconClasses,
|
||||
string $sTooltipText,
|
||||
?string $sURL = '',
|
||||
?string $sTarget = null,
|
||||
?string $sId = null
|
||||
) {
|
||||
if (empty($sTarget)) {
|
||||
$sTarget = ButtonURL::DEFAULT_TARGET;
|
||||
}
|
||||
$oButton = static::MakeForLink('', $sURL,Button::ENUM_COLOR_SCHEME_NEUTRAL, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sTarget, $sId);
|
||||
$oButton = static::MakeForLink('', $sURL, Button::ENUM_COLOR_SCHEME_NEUTRAL, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sTarget, $sId);
|
||||
$oButton->SetIconClass($sIconClasses);
|
||||
$oButton->SetTooltip($sTooltipText);
|
||||
|
||||
return $oButton;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $sIconClasses
|
||||
* @param string $sTooltipText
|
||||
@@ -385,10 +448,14 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Button\Button
|
||||
*/
|
||||
public static function MakeDestructiveIconLink(
|
||||
string $sIconClasses, string $sTooltipText, ?string $sURL = null, ?string $sName = null, ?string $sTarget = null,
|
||||
string $sIconClasses,
|
||||
string $sTooltipText,
|
||||
?string $sURL = null,
|
||||
?string $sName = null,
|
||||
?string $sTarget = null,
|
||||
?string $sId = null
|
||||
) {
|
||||
$oButton = static::MakeIconLink($sIconClasses, $sTooltipText, $sURL, $sTarget, $sId);
|
||||
$oButton = static::MakeIconLink($sIconClasses, $sTooltipText, $sURL, $sTarget, $sId);
|
||||
$oButton->SetColor(Button::ENUM_COLOR_SCHEME_DESTRUCTIVE);
|
||||
$oButton->SetTooltip($sTooltipText);
|
||||
return $oButton;
|
||||
@@ -467,7 +534,7 @@ class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
$oButton = new ButtonURL($sLabel, $sURL, $sId, $sTarget);
|
||||
$oButton->SetActionType($sActionType)
|
||||
->SetColor($sColor);
|
||||
|
||||
|
||||
return $oButton;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -19,7 +20,6 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Button;
|
||||
|
||||
|
||||
/**
|
||||
* Class Button
|
||||
*
|
||||
@@ -37,15 +37,14 @@ class ButtonURL extends Button
|
||||
/** @var string ENUM_TARGET_BLANK */
|
||||
public const ENUM_TARGET_BLANK = '_blank';
|
||||
/** @var string ENUM_TARGET_SELF */
|
||||
public const ENUM_TARGET_SELF= '_self';
|
||||
public const ENUM_TARGET_SELF = '_self';
|
||||
/** @var string ENUM_TARGET_PARENT */
|
||||
public const ENUM_TARGET_PARENT= '_parent';
|
||||
public const ENUM_TARGET_PARENT = '_parent';
|
||||
/** @var string ENUM_TARGET_TOP */
|
||||
public const ENUM_TARGET_TOP= '_top';
|
||||
public const ENUM_TARGET_TOP = '_top';
|
||||
/** @var string DEFAULT_TARGET */
|
||||
public const DEFAULT_TARGET = self::ENUM_TARGET_SELF;
|
||||
|
||||
|
||||
/** @var string */
|
||||
protected $sURL;
|
||||
/** @var string */
|
||||
@@ -66,12 +65,27 @@ class ButtonURL extends Button
|
||||
* @param string $sOnClickJsCode
|
||||
*/
|
||||
public function __construct(
|
||||
string $sLabel, string $sURL, string $sId = null, string $sTarget = self::DEFAULT_TARGET, string $sTooltip = '', string $sIconClass = '',
|
||||
string $sActionType = self::DEFAULT_ACTION_TYPE, string $sColor = self::DEFAULT_COLOR_SCHEME, string $sJsCode = '',
|
||||
string $sOnClickJsCode = '')
|
||||
{
|
||||
parent::__construct($sLabel, $sId, $sTooltip, $sIconClass,
|
||||
$sActionType, $sColor, $sJsCode, $sOnClickJsCode);
|
||||
string $sLabel,
|
||||
string $sURL,
|
||||
string $sId = null,
|
||||
string $sTarget = self::DEFAULT_TARGET,
|
||||
string $sTooltip = '',
|
||||
string $sIconClass = '',
|
||||
string $sActionType = self::DEFAULT_ACTION_TYPE,
|
||||
string $sColor = self::DEFAULT_COLOR_SCHEME,
|
||||
string $sJsCode = '',
|
||||
string $sOnClickJsCode = ''
|
||||
) {
|
||||
parent::__construct(
|
||||
$sLabel,
|
||||
$sId,
|
||||
$sTooltip,
|
||||
$sIconClass,
|
||||
$sActionType,
|
||||
$sColor,
|
||||
$sJsCode,
|
||||
$sOnClickJsCode
|
||||
);
|
||||
$this->sURL = $sURL;
|
||||
$this->sTarget = $sTarget;
|
||||
}
|
||||
@@ -86,7 +100,7 @@ class ButtonURL extends Button
|
||||
|
||||
/**
|
||||
* @param string $sURL
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetURL(string $sURL)
|
||||
@@ -105,7 +119,7 @@ class ButtonURL extends Button
|
||||
|
||||
/**
|
||||
* @param string $sTarget
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetTarget(string $sTarget)
|
||||
@@ -113,4 +127,4 @@ class ButtonURL extends Button
|
||||
$this->sTarget = $sTarget;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user