Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Nov 15, 2019
1 parent 6a3317d commit 74d0188
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
26 changes: 26 additions & 0 deletions src/UnifyTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ static public function initBeforeRender()

$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);

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

Expand Down Expand Up @@ -301,6 +310,23 @@ static public function initBeforeRender()

}

/**
* @param $hex
* @param bool $alpha
* @return mixed
*/
static public function hexToRgb($hex, $alpha = false) {
$hex = str_replace('#', '', $hex);
$length = strlen($hex);
$rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
$rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
$rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
if ( $alpha ) {
$rgb['a'] = $alpha;
}
return $rgb;
}

/**
* Показывать копирайты?
* @var bool
Expand Down
36 changes: 26 additions & 10 deletions src/views/widgets/TreeMenuCmsWidget/_one-menu-top.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,45 @@
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\cmsWidgets\treeMenu\TreeMenuCmsWidget */
/* @var $model \skeeks\cms\models\Tree */

$hasChildrens = $model->activeChildren;
$activeClass = '';
if (strpos(\Yii::$app->request->pathInfo, $model->dir) !== false)
{
if (strpos(\Yii::$app->request->pathInfo, $model->dir) !== false) {
$activeClass = ' active';
}
?>
<li class="nav-item g-mx-20--lg <?= $activeClass; ?> <?= ($hasChildrens) ?' hs-has-sub-menu':''; ?>" data-animation-in="fadeIn" data-animation-out="fadeOut">
<li class="nav-item g-mx-20--lg <?= $activeClass; ?> <?= ($hasChildrens) ? ' hs-has-sub-menu' : ''; ?>" data-animation-in="fadeIn" data-animation-out="fadeOut">
<? if ($hasChildrens) : ?>
<a href="<?= $model->url; ?>" title="<?= $model->name; ?>" id="nav-link-<?= $model->id; ?>" class="nav-link px-0" aria-haspopup="true" aria-expanded="false" aria-controls="nav-submenu-<?= $model->id; ?>">
<?= $model->name; ?>
</a>

<ul class="hs-sub-menu list-unstyled u-shadow-v11 g-min-width-220 g-mt-18 g-mt-8--lg--scrolling" id="nav-submenu-<?= $model->id; ?>" aria-labelledby="nav-link-<?= $model->id; ?>">
<? foreach($model->getChildren()
->andWhere(['active' => $widget->active])
->orderBy([$widget->orderBy => $widget->order])
->all() as $childTree) : ?>
<li class="dropdown-item">
<? foreach ($model->getActiveChildren()
->orderBy([$widget->orderBy => $widget->order])
->all() as $childTree) : ?>
<?
$subChilds = $childTree->getActiveChildren()->orderBy([$widget->orderBy => $widget->order])->all();
?>

<li class="dropdown-item <?= $subChilds ? "hs-has-sub-menu" : "" ?>">
<a href="<?= $childTree->url; ?>" title="<?= $childTree->name; ?>" class="nav-link"><?= $childTree->name; ?></a>



<? if ($subChilds) : ?>
<ul class="hs-sub-menu list-unstyled u-shadow-v11 g-brd-top g-brd-primary g-brd-top-2 g-min-width-220 g-mt-minus-2" id="nav-submenu--features--sliders" aria-labelledby="nav-link--features--sliders">

<? foreach ($subChilds as $subChild) : ?>
<li class="dropdown-item ">
<a class="nav-link" href="<?= $subChild->url; ?>" title="<?= $subChild->name; ?>"><?= $subChild->name; ?></a>
</li>
<? endforeach; ?>
</ul>
<? endif; ?>
</li>
<? endforeach; ?>
</ul>
<? endforeach; ?>
</ul>
<? else: ?>
<a href="<?= $model->url; ?>" class="nav-link px-0" title="<?= $model->name; ?>" class="nav-link"><?= $model->name; ?></a>
<? endif; ?>
Expand Down

0 comments on commit 74d0188

Please sign in to comment.