You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.2 KiB
62 lines
1.2 KiB
6 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by Error202
|
||
|
* Date: 21.08.2018
|
||
|
*/
|
||
|
|
||
|
namespace common\modules\banners\helpers;
|
||
|
|
||
|
|
||
|
use common\modules\banners\entities\Banner;
|
||
|
use yii\helpers\ArrayHelper;
|
||
|
use yii\helpers\Html;
|
||
|
use yii\helpers\Url;
|
||
|
use Yii;
|
||
|
|
||
|
class BannerHelper
|
||
|
{
|
||
|
public static function targetList(): array
|
||
|
{
|
||
|
return [
|
||
|
Banner::TARGET_SELF => Yii::t('banners', 'Self window'),
|
||
|
Banner::TARGET_BLANK => Yii::t('banners', 'Blank window'),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public static function targetName($target): string
|
||
|
{
|
||
|
return ArrayHelper::getValue(self::targetList(), $target);
|
||
|
}
|
||
|
|
||
|
public static function statusList(): array
|
||
|
{
|
||
|
return [
|
||
|
Banner::STATUS_DRAFT => Yii::t('banners', 'Draft'),
|
||
|
Banner::STATUS_ACTIVE => Yii::t('banners', 'Active'),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public static function statusName($status): string
|
||
|
{
|
||
|
return ArrayHelper::getValue(self::statusList(), $status);
|
||
|
}
|
||
|
|
||
|
public static function statusLabel($status): string
|
||
|
{
|
||
|
switch ($status) {
|
||
|
case Banner::STATUS_DRAFT:
|
||
|
$class = 'label label-default';
|
||
|
break;
|
||
|
case Banner::STATUS_ACTIVE:
|
||
|
$class = 'label label-success';
|
||
|
break;
|
||
|
default:
|
||
|
$class = 'label label-default';
|
||
|
}
|
||
|
|
||
|
return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [
|
||
|
'class' => $class,
|
||
|
]);
|
||
|
}
|
||
|
}
|