main.php 14 KB
<?php
    
    /**
     * @var View           $this
     * @var string         $content
     * @var SeoComponent   $seo
     * @var User           $user
     * @var PageCategory[] $pageCategories
     */
    
    use artbox\core\components\SeoComponent;
    use artbox\core\helpers\ImageHelper;
    use artbox\core\models\Feedback;
    use artbox\core\models\PageCategory;
    use artbox\core\models\User;
    use common\models\Settings;
    use frontend\assets\AppAsset;
    use artbox\core\components\imagemanager\models\ImageManager;
    use yii\bootstrap\ActiveForm;
    use yii\bootstrap\Nav;
    use yii\bootstrap\Html;
    use yii\db\ActiveQuery;
    use yii\helpers\Url;
    use yii\web\View;
    use yii\widgets\Breadcrumbs;
    
    AppAsset::register($this);
    $user = \Yii::$app->user->identity;
    $seo = Yii::$app->get('seo');
    $feedback = new Feedback();
    $settings = Settings::getInstance();
    $controller = Yii::$app->controller;
    $default_controller = Yii::$app->defaultRoute;
    $isHome = ( ( $controller->id === $default_controller ) && ( $controller->action->id === $controller->defaultAction ) ) ? true : false;
    
    $pageCategories = PageCategory::find()
                                  ->with(
                                      [
                                          'lang',
                                          'pages' => function (ActiveQuery $query) {
                                              $query->with('lang.alias')
                                                    ->where(['in_menu' => true])
                                                    ->orderBy([ 'sort' => SORT_ASC ]);
                                          },
                                      ]
                                  )
                                  ->where([ 'status' => true ])
                                  ->orderBy([ 'sort' => SORT_ASC ])
                                  ->all();
    $logo = null;
    if ($settings->logo) {
        $logo_img = ImageManager::findOne($settings->logo);
        if ($logo_img) {
            $logo = $logo_img->getImagePathPrivate() ?? $logo;
        }
    }
    
    $this->registerMetaTag(
        [
            'name'    => 'description',
            'content' => $seo->desc,
        ]
    )
?>

<?php $this->beginPage() ?>
  
  <!DOCTYPE html>
  <html lang="<?= \Yii::$app->language ?>">
    <head>
      <meta charset="<?= \Yii::$app->charset ?>">
      <meta name="viewport" content="width=device-width, initial-scale=1">
        <?= Html::csrfMetaTags() ?>
      <link type="image/x-icon" href="/img/favicon.ico" rel="icon">
      <title><?= Html::encode($seo->title) ?></title>
        <?php $this->head() ?>
    </head>
    <body>
        <?php $this->beginBody() ?>
      <!-- Google Analytics -->
      <?php if (!empty($settings->ga_code)) { ?>
      <script>
          (function(i, s, o, g, r, a, m) {
              i[ 'GoogleAnalyticsObject' ] = r;
              i[ r ] = i[ r ] || function() {
                      (i[ r ].q = i[ r ].q || []).push(arguments)
                  }, i[ r ].l = 1 * new Date();
              a = s.createElement(o), m = s.getElementsByTagName(o)[ 0 ];
              a.async = 1;
              a.src = g;
              m.parentNode.insertBefore(a, m)
          })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

          ga('create', '<?=$settings->ga_code?>', 'auto');
          ga('send', 'pageview');
      
      </script>
      <?php } ?>
      <div id="all">
        <header>
          
          <!-- *** NAVBAR ***
  _________________________________________________________ -->
          <div class="navbar-affixed-top" data-spy="affix" data-offset-top="200">
            
            <div class="navbar navbar-default yamm" role="navigation" id="navbar">
              
              <div class="container">
                <div class="navbar-header">
                  
                  <a class="navbar-brand home" href="<?php echo Url::home(); ?>">
                      <?php
                          echo ImageHelper::set($logo)
                                          ->setHeight(42)
                                          ->renderImage(
                                              [
                                                  'alt' => $settings->name,
                                              ]
                                          )
                      ?>
                  </a>
                  <div class="navbar-buttons">
                    <button type="button" class="navbar-toggle btn-template-main" data-toggle="collapse" data-target="#navigation">
                      <span class="sr-only">Toggle navigation</span>
                      <i class="fa fa-align-justify"></i>
                    </button>
                  </div>
                </div>
                
                <div class="navbar-collapse collapse" id="navigation">
                    <?php
                        $items = [];
                        $items[] = [
                            'label' => \Yii::t('app', 'Home'),
                            'url'   => [ 'site/index' ],
                        ];
                        foreach ($pageCategories as $category) {
                            if (empty($category->pages)) {
                              continue;
                            }
                            $pages = [];
                            foreach ($category->pages as $page) {
                              $pages[] = [
                                'label' => $page->lang->title,
                                'url' => Url::to(['page/view','alias' => $page->lang->alias]),
                              ];
                            }
                            $items[] = [
                              'label' => $category->lang->title,
                              'items' => $pages,
                            ];
                        }
                        $items[] = [
                            'label' => \Yii::t('app', 'Контакты'),
                            'url'   => [ 'site/contact' ],
                        ];
                        $items[] =  [
                            'label' => \Yii::t('app', 'О нас'),
                            'url'   => [ 'site/about' ],
                        ];
                        echo Nav::widget(
                            [
                                'items'   => $items,
                                'options' => [
                                    'class' => 'nav navbar-nav navbar-right',
                                ],
                            ]
                        );
                    ?>
                </div>
                
                
                <div class="collapse clearfix" id="search">
                  
                  <form class="navbar-form" role="search">
                    <div class="input-group">
                      <input type="text" class="form-control" placeholder="Search">
                      <span class="input-group-btn">

                    <button type="submit" class="btn btn-template-main"><i class="fa fa-search"></i></button>

                </span>
                    </div>
                  </form>
                
                </div>
                <!--/.nav-collapse -->
              
              </div>
            
            
            </div>
            <!-- /#navbar -->
          
          </div>
          
          <!-- *** NAVBAR END *** -->
        
        </header>
        
        <!-- *** FeedBack MODAL ***
_________________________________________________________ -->
        <div class="forms_" id="feedback-modal" aria-labelledby="Login" style="display:none;" aria-hidden="true">
            <div class="forms_wr_">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times</button>
                    <h3 class="modal-title" id="Login">Feedback</h3>
                </div>
                <div class="modal-body">

                    <?php $form = ActiveForm::begin(
                        [
                            'id'     => 'feedback-form',
                            'method' => 'POST',
                            'action' => '/site/feedback',
                        ]
                    ); ?>

                    <?= $form->field($feedback, 'name')
                        ->textInput(); ?>

                    <?= $form->field($feedback, 'email')
                        ->textInput(); ?>

                    <?= $form->field($feedback, 'phone')
                        ->textInput(); ?>

                    <?= $form->field($feedback, 'message')
                        ->textarea(
                            [
                                'rows' => 4,
                            ]
                        ); ?>

                    <p class="text-center">
                        <?= Html::submitButton(
                            'Отправить',
                            [
                                'class' => 'send-form btn btn-lg btn-template-primary',
                            ]
                        ) ?>
                    </p>

                    <?php ActiveForm::end(); ?>

                </div>
            </div>
            <div class="overlay-new"></div>
        </div>
        
        <!-- *** FeedBack MODAL END *** -->
        
        <!-- *** FeedBack MODAL ***
_________________________________________________________ -->
        <div class="success_" id="success-modal" aria-labelledby="Success" aria-hidden="true">
            <div class="forms_wr_">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times</button>
                    <h3 class="modal-title" id="Success">Отправлено</h3>
                </div>
                <div class="modal-body">

                    <p>Thank for your reply, we will call you, maybe.</p>
                    <p class="text-center">
                        <button type="button" class="btn btn-template-primary" data-dismiss="modal">Закрыть</button>
                    </p>
                </div>
            </div>
        </div>
        
        <!-- *** FeedBack MODAL END *** -->
        
        <!-- *** Breadcrumbs *** -->
          <?php
              if (!$isHome) {
                  ?>
                <div id="heading-breadcrumbs">
                  <div class="container">
                    <div class="row">
                      <div class="col-md-7">
                        <h1><?= $seo->h1 ?></h1>
                      </div>
                      <div class="col-md-5">
                          <?= Breadcrumbs::widget(
                              [
                                  'links' => isset($this->params[ 'breadcrumbs' ]) ? $this->params[ 'breadcrumbs' ] : [],
                              ]
                          ) ?>
                      
                      </div>
                    </div>
                  </div>
                </div>
                  <?php
              }
          ?>
        <!-- *** Breadcrumbs END *** -->
          
          <?= $content ?>
        
        <!-- *** FOOTER ***
_________________________________________________________ -->
        
        <footer id="footer">
          <div class="container">
            <div class="col-md-6 col-sm-12">
                <?php
                    if (!empty($settings->about)) {
                        ?>
                      <h4><?php echo \Yii::t('app', 'About us'); ?></h4>
                      <p><?php echo $settings->about; ?></p>
                        <?php
                    }
                ?>
              <a href="#" class="btn btn-template-transparent-primary modal-link" data-form="feedback-modal">Написать нам</a>
            </div>
            
            <div class="col-md-4 col-sm-12 col-md-offset-2">
              
              <h4><?php echo \Yii::t('app', 'Контакты'); ?></h4>
              
              <p>
                  <?php
                      if (!empty($settings->office)) {
                          echo \Yii::t(
                                  'app',
                                  'Офис {office}',
                                  [
                                      'office' => $settings->office,
                                  ]
                              ) . Html::tag('br');
                      }
                      if (!empty($settings->street)) {
                          echo $settings->street;
                          if (!empty($settings->house)) {
                              echo " " . $settings->house;
                          }
                          echo Html::tag('br');
                      }
                      if (!empty($settings->city)) {
                          echo $settings->city;
                          echo Html::tag('br');
                      }
                      if (!empty($settings->country)) {
                          echo Html::tag('strong', $settings->country);
                      }
                  ?>
              </p>
                
                <?= Html::a(
                    'На страницу контактов',
                    [ 'site/contact' ],
                    [
                        'class' => 'btn btn-small btn-template-transparent-primary',
                    ]
                ) ?>
              
              <hr class="hidden-md hidden-lg hidden-sm">
            
            </div>
            
            <div class="col-md-12">
              <p class="pull-left">&copy; <?= date('Y') ?>. <?= $settings->name; ?></p>
            </div>
          </div>
          <!-- /.container -->
        </footer>
        <!-- /#footer -->
        
        <!-- *** FOOTER END *** -->

        <span id="back-to-top" title="Back to top"><i class="fa fa-arrow-up"></i></span>
      
      </div>
      <div id="overlay" style="display:none;"></div>
      <!-- /#all -->
        <?php $this->endBody() ?>
    </body>
  </html>
<?php $this->endPage() ?>