Skip to content

Commit

Permalink
fix for php8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Jun 8, 2023
1 parent 281013e commit 5c9e1e0
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 77 deletions.
152 changes: 76 additions & 76 deletions src/UnifyTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ public function getConfigFormModelData()
}


public static $is_ready = false;
protected $_is_ready = false;
/**
* @return bool
*/
Expand All @@ -911,7 +911,7 @@ public function init()
parent::init();

$this->on(\yii\base\View::EVENT_BEFORE_RENDER, function() {
self::initBeforeRender();
$this->initBeforeRender();
});

/*if (isset(\Yii::$app->unifyThemeSettings)) {
Expand All @@ -925,12 +925,13 @@ public function init()
/**
*
*/
static public function initThemeSettings()
public function initThemeSettings()
{

//Показывать заглушку?
if (\Yii::$app->view->theme->is_cap) {
if ($this->is_cap) {
$enableCap = true;
if (\Yii::$app->view->theme->is_cap_only_guests) {
if ($this->is_cap_only_guests) {
$enableCap = false;
if (\Yii::$app->user->isGuest) {
$enableCap = true;
Expand All @@ -947,9 +948,9 @@ static public function initThemeSettings()
}

//Предустановленные шрифты
if (\Yii::$app->view->theme->include_font_assets) {
foreach ((array)\Yii::$app->view->theme->include_font_assets as $id) {
$assetClass = ArrayHelper::getValue((array)\Yii::$app->view->theme->available_font_assets, [$id, 'class']);
if ($this->include_font_assets) {
foreach ((array)$this->include_font_assets as $id) {
$assetClass = ArrayHelper::getValue((array)$this->available_font_assets, [$id, 'class']);
if (class_exists($assetClass)) {
$assetClass::register(\Yii::$app->view);
} else {
Expand All @@ -960,8 +961,8 @@ static public function initThemeSettings()

if (!\Yii::$app->mobileDetect->isMobile) {
//Дополнительные компоненты верстки
if (\Yii::$app->view->theme->include_assets) {
foreach ((array)\Yii::$app->view->theme->include_assets as $assetClass) {
if ($this->include_assets) {
foreach ((array)$this->include_assets as $assetClass) {
if (class_exists($assetClass)) {
$assetClass::register(\Yii::$app->view);
} else {
Expand All @@ -971,8 +972,8 @@ static public function initThemeSettings()
}
} else {
//Дополнительные компоненты верстки
if (\Yii::$app->view->theme->include_mobile_assets) {
foreach ((array)\Yii::$app->view->theme->include_mobile_assets as $assetClass) {
if ($this->include_mobile_assets) {
foreach ((array)$this->include_mobile_assets as $assetClass) {
if (class_exists($assetClass)) {
$assetClass::register(\Yii::$app->view);
} else {
Expand All @@ -985,57 +986,57 @@ static public function initThemeSettings()

$content = file_get_contents(\Yii::getAlias("@skeeks/cms/themes/unify/assets/src/css/unify-default-template.css"));

$content = str_replace("#72c02c", \Yii::$app->view->theme->main_theme_color1, $content);
$content = str_replace("114, 192, 44, 0.8", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.8)), $content);
$content = str_replace("114, 192, 44, 0.6", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.6)), $content);
$content = str_replace("114, 192, 44, 0.4", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.4)), $content);
$content = str_replace("114, 192, 44, 0.2", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.2)), $content);
$content = str_replace("114, 192, 44, 0.9", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.9)), $content);
$content = str_replace("114, 192, 44, 0.3", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.3)), $content);
$content = str_replace("114, 192, 44, 0.95", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.95)), $content);
$content = str_replace("114, 192, 44, 0.5", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.5)), $content);
$content = str_replace("114, 192, 44, 0.1", implode(", ", self::hexToRgb(\Yii::$app->view->theme->main_theme_color1, 0.1)), $content);

$content = str_replace("{footer_bg_color}", \Yii::$app->view->theme->footer_bg_color, $content);
$content = str_replace("{footer_color}", \Yii::$app->view->theme->footer_color, $content);
$content = str_replace("{footer_copyright_bg_color}", \Yii::$app->view->theme->footer_copyright_bg_color, $content);
$content = str_replace("{footer_copyright_color}", \Yii::$app->view->theme->footer_copyright_color, $content);


$content = str_replace("{second_theme_bg_color}", \Yii::$app->view->theme->second_theme_bg_color, $content);
$content = str_replace("{second_theme_text_color}", \Yii::$app->view->theme->second_theme_text_color, $content);

$content = str_replace("{base_padding}", \Yii::$app->view->theme->base_padding, $content);
$content = str_replace("{base_radius}", \Yii::$app->view->theme->base_radius, $content);

$content = str_replace("#0185c8", \Yii::$app->view->theme->main_theme_color1, $content);
$content = str_replace("#e1082c", \Yii::$app->view->theme->main_theme_color2, $content);
$content = str_replace("{font_headers}", \Yii::$app->view->theme->font_headers, $content);
$content = str_replace("{font_texts}", \Yii::$app->view->theme->font_texts, $content);
$content = str_replace("{text_color}", \Yii::$app->view->theme->text_color, $content);

$content = str_replace("{second_bg_color}", \Yii::$app->view->theme->second_bg_color, $content);
$content = str_replace("{bg_color}", \Yii::$app->view->theme->bg_color, $content);
$content = str_replace("#72c02c", $this->main_theme_color1, $content);
$content = str_replace("114, 192, 44, 0.8", implode(", ", self::hexToRgb($this->main_theme_color1, 0.8)), $content);
$content = str_replace("114, 192, 44, 0.6", implode(", ", self::hexToRgb($this->main_theme_color1, 0.6)), $content);
$content = str_replace("114, 192, 44, 0.4", implode(", ", self::hexToRgb($this->main_theme_color1, 0.4)), $content);
$content = str_replace("114, 192, 44, 0.2", implode(", ", self::hexToRgb($this->main_theme_color1, 0.2)), $content);
$content = str_replace("114, 192, 44, 0.9", implode(", ", self::hexToRgb($this->main_theme_color1, 0.9)), $content);
$content = str_replace("114, 192, 44, 0.3", implode(", ", self::hexToRgb($this->main_theme_color1, 0.3)), $content);
$content = str_replace("114, 192, 44, 0.95", implode(", ", self::hexToRgb($this->main_theme_color1, 0.95)), $content);
$content = str_replace("114, 192, 44, 0.5", implode(", ", self::hexToRgb($this->main_theme_color1, 0.5)), $content);
$content = str_replace("114, 192, 44, 0.1", implode(", ", self::hexToRgb($this->main_theme_color1, 0.1)), $content);

$content = str_replace("{footer_bg_color}", $this->footer_bg_color, $content);
$content = str_replace("{footer_color}", $this->footer_color, $content);
$content = str_replace("{footer_copyright_bg_color}", $this->footer_copyright_bg_color, $content);
$content = str_replace("{footer_copyright_color}", $this->footer_copyright_color, $content);


$content = str_replace("{second_theme_bg_color}", $this->second_theme_bg_color, $content);
$content = str_replace("{second_theme_text_color}", $this->second_theme_text_color, $content);

$content = str_replace("{base_padding}", $this->base_padding, $content);
$content = str_replace("{base_radius}", $this->base_radius, $content);

$content = str_replace("#0185c8", $this->main_theme_color1, $content);
$content = str_replace("#e1082c", $this->main_theme_color2, $content);
$content = str_replace("{font_headers}", $this->font_headers, $content);
$content = str_replace("{font_texts}", $this->font_texts, $content);
$content = str_replace("{text_color}", $this->text_color, $content);

$content = str_replace("{second_bg_color}", $this->second_bg_color, $content);
$content = str_replace("{bg_color}", $this->bg_color, $content);
//\Yii::$app->view->registerCss($content);

if (\Yii::$app->view->theme->menu_color1) {
$bgColor1 = \Yii::$app->view->theme->menu_color1;
$bgColor2 = \Yii::$app->view->theme->menu_color2;
if ($this->menu_color1) {
$bgColor1 = $this->menu_color1;
$bgColor2 = $this->menu_color2;
$content = str_replace("{menuBgColor1}", $bgColor1, $content);
$content = str_replace("{menuBgColor2}", $bgColor2, $content);
}

$color = \Yii::$app->view->theme->menu_font_color;
$fz = \Yii::$app->view->theme->menu_font_size;
$color = $this->menu_font_color;
$fz = $this->menu_font_size;

$content = str_replace("{menuColor}", $color, $content);
$content = str_replace("{menuFz}", $fz, $content);


$css_content = '';

if (\Yii::$app->view->theme->sx_container_width) {
$maxWidth = \Yii::$app->view->theme->sx_container_width;
if ($this->sx_container_width) {
$maxWidth = $this->sx_container_width;
$css_content .= <<<CSS
.sx-container {
max-width: {$maxWidth};
Expand All @@ -1044,7 +1045,7 @@ static public function initThemeSettings()

}

if (\Yii::$app->view->theme->menu_align == 'left') {
if ($this->menu_align == 'left') {
$css_content .= <<<CSS
ul.sx-menu-top {
margin-left: 0 !important;
Expand All @@ -1055,15 +1056,15 @@ static public function initThemeSettings()
CSS;

}
if (\Yii::$app->view->theme->menu_align == 'right') {
if ($this->menu_align == 'right') {
$css_content .= <<<CSS
ul.sx-menu-top {
margin-left: auto !important;
}
CSS;

}
if (\Yii::$app->view->theme->menu_align == 'center') {
if ($this->menu_align == 'center') {
$css_content .= <<<CSS
ul.sx-menu-top {
margin-left: auto !important;
Expand All @@ -1072,8 +1073,8 @@ static public function initThemeSettings()
CSS;

}
if (\Yii::$app->view->theme->body_bg_image) {
$bgImage = \Yii::$app->view->theme->body_bg_image;
if ($this->body_bg_image) {
$bgImage = $this->body_bg_image;
$css_content .= <<<CSS
body {
background: url('{$bgImage}') fixed;
Expand All @@ -1083,8 +1084,8 @@ static public function initThemeSettings()
}


if (\Yii::$app->view->theme->col_left_width) {
$leftCol = \Yii::$app->view->theme->col_left_width;
if ($this->col_left_width) {
$leftCol = $this->col_left_width;
$css_content .= <<<CSS
@media (min-width: 768px) {
.sx-content-col-main {
Expand All @@ -1104,7 +1105,7 @@ static public function initThemeSettings()
$content = str_replace("{css_content}", $css_content, $content);


$cache = md5(serialize(ArrayHelper::toArray(\Yii::$app->view->theme)))."-v18";
$cache = md5(serialize(ArrayHelper::toArray($this)))."-v18";

$newDir = \Yii::getAlias("@webroot/assets/unify");
$newFile = \Yii::getAlias("@webroot/assets/unify/unify-default-template-".$cache.".css");
Expand All @@ -1118,44 +1119,45 @@ static public function initThemeSettings()
fclose($fp);
}

if (!\Yii::$app->view->theme->logo) {
if (!$this->logo) {

if (\Yii::$app->skeeks->site->image) {
\Yii::$app->view->theme->logo = \Yii::$app->skeeks->site->image->src;
$this->logo = \Yii::$app->skeeks->site->image->src;
}
}

if (!\Yii::$app->view->theme->footer_logo && \Yii::$app->view->theme->logo) {
\Yii::$app->view->theme->footer_logo = \Yii::$app->view->theme->logo;
if (!$this->footer_logo && $this->logo) {
$this->footer_logo = $this->logo;
}

if (!\Yii::$app->view->theme->mobile_logo && \Yii::$app->view->theme->logo) {
\Yii::$app->view->theme->mobile_logo = \Yii::$app->view->theme->logo;
if (!$this->mobile_logo && $this->logo) {
$this->mobile_logo = $this->logo;
}

\Yii::$app->view->on(View::EVENT_BEGIN_PAGE, function () use ($newFilePublic) {
if (\Yii::$app->request->isPjax) {
return false;
}

if (\Yii::$app->view->theme->font_css) {
\Yii::$app->view->registerCssFile(\Yii::$app->view->theme->font_css);
if ($this->font_css) {
\Yii::$app->view->registerCssFile($this->font_css);
}

\Yii::$app->view->registerCssFile($newFilePublic, [
'depends' => [
UnifyThemeAsset::class,
//\Yii::$app->view->theme->themeAssetClass
//$this->themeAssetClass
],
]);
});


if (\Yii::$app->view->theme->css_code && !\Yii::$app->request->isPjax) {
\Yii::$app->view->registerCss(\Yii::$app->view->theme->css_code);
if ($this->css_code && !\Yii::$app->request->isPjax) {
\Yii::$app->view->registerCss($this->css_code);
}


$assetClass = \Yii::$app->view->theme->themeAssetClass;
$assetClass = $this->themeAssetClass;
\Yii::$app->view->on(View::EVENT_END_BODY, function () use ($assetClass) {
if (\Yii::$app->request->isPjax) {
return false;
Expand All @@ -1165,13 +1167,13 @@ static public function initThemeSettings()

}

static public function initBeforeRender()
public function initBeforeRender()
{
if (self::$is_ready === true) {
if ($this->_is_ready === true) {
return true;
}

self::$is_ready = true;
$this->_is_ready = true;
/**
* Для виджетов выбора времени
*/
Expand Down Expand Up @@ -1260,9 +1262,7 @@ static public function initBeforeRender()
]
));

static::initThemeSettings();


$this->initThemeSettings();
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/views/headers/header-v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
});
JS
);

?>

<!-- Header -->
Expand Down

0 comments on commit 5c9e1e0

Please sign in to comment.