index.php 5.92 KB
<?php

use yii\helpers\Html;
use frontend\themes\defaults\assets\AppAsset;
use frontend\modules\map\Map;

/**
 * @author FilamentV <vortex.filament@gmail.com>
 * @author Alla Kuzmenko
 * @copyright (c), Thread
 *
 */
$asset = AppAsset::register($this);

$urlMapResource = Map::getUrlListByType('resource');
$urlMapProjects = Map::getUrlListByType('project');
$urlList = Map::getUrlList();
?>
    <div class="col-xs-12 text-center">
        <div class="main-map-container">
            <div class="static-btn-container">
                <?= Html::a(Yii::t('front', 'resource potential'), $urlMapResource, [
                    'class' => 'static-btn static-btn-resours'
                ])
                . Html::a(Yii::t('front', 'projects'), $urlMapProjects, [
                    'class' => 'static-btn static-btn-project'
                ])
                ?>
            </div>
            <div class="main-map">
                <?php
                echo Html::a(Html::img($asset->baseUrl . '/img/map.png', [
                    'class' => 'img-responsive',
                    'alt' => 'map'
                ]), $urlMapProjects, [
                    'class' => 'main-map-link'
                ]);
                //MAP MENU
                echo Html::a(Html::tag('span', Yii::t('front', 'hydro'), [
                    ]), $urlMapProjects . '?area=1', [
                        'class' => 'bubble hydro',
                    ])
                    . Html::a(Html::tag('span', Yii::t('front', 'solar'), [
                    ]), $urlMapProjects . '?area=4', [
                        'class' => 'bubble solar',
                    ])
                    . Html::a(Html::tag('span', Yii::t('front', 'wind'), [
                    ]), $urlMapProjects . '?area=5', [
                        'class' => 'bubble wind',
                    ])
                    . Html::a(Html::tag('span', Yii::t('front', 'efective'), [
                    ]), $urlMapProjects . '?area=6', [
                        'class' => 'bubble efective',
                    ])
                    . Html::a(Html::tag('span', Yii::t('front', 'bio'), [
                    ]), $urlMapProjects . '?area=15', [
                        'class' => 'bubble bio',
                    ]);
                ?>
            </div>
            <?php if (Yii::$app->getUser()->isGuest): ?>
                <div class="registration text-left hide-on-med-and-down">
                    <div class="registration-text">
                        <?= Yii::t('front', 'Register on the system to add your project to the map') ?>
                    </div>
                    <?= Html::button(Yii::t('front', 'Registration'),
                        ['class' => 'open-popup btn btn-default btn-sm',
                            'data-id' => 'registrationPopup']) ?>
                    <div class="registration-popap-info">
                        <?= \frontend\modules\page\models\StaticTextBlock::give_me('register_text') ?>
                    </div>
                </div>
            <?php endif; ?>
        </div>
    </div>
<?php
/*
$xml = simplexml_load_string(file_get_contents(Yii::getAlias('@frontend-web') . '/bio.kml'));
//
function xml2array($xml)
{
    $arr = array();

    foreach ($xml->children() as $r) {
        $t = array();
        if (count($r->children()) == 0) {
            $arr[$r->getName()] = strval($r);
        } else {
            $arr[$r->getName()][] = xml2array($r);
        }
    }
    return $arr;
}

//
$xmlarray = xml2array($xml);
//XMLToArrayFlat($xml, $xmlarray, '', true);
//var_dump($xmlarray);
foreach ($xmlarray as $document => $doc_array) {
    foreach ($doc_array as $folder => $f_array) {
        foreach ($f_array as $k => $data) {
            foreach ($data as $datum) {
                foreach ($datum['Placemark'] as $item) {
//                    var_dump($item);
                    $e_data = '<br>';
                    if (isset($item['ExtendedData'][0]['Data'])) {
                        foreach ($item['ExtendedData'][0]['Data'] as $key) {
                            $e_data .= $key['value'] . '<br>';
                        }
                    }
//                    var_dump($e_data);
//                    break;
                    $coords = [0 => '0', 1 => '0'];
                    if (isset($item['Point'][0]['coordinates'])) {
                        $coords = explode(',', trim($item['Point'][0]['coordinates']));
                    }
//
                    $obj = new \backend\modules\map\models\Item([
                        'scenario' => 'backend',
                        'alias' => mb_substr($item['name'], 0, 100) . '' . uniqid(),
                        'type' => 'resource',
                        'region_id' => '0',
                        'type_id' => '3',
                        'area_id' => '17',
                        'user_id' => '1',
                        'coordinates' => '(' . $coords[1] . ',' . $coords[0] . ')',
                        'published' => '1',
                        'heat_capacity' => '0',
                        'date_of_entry' => '',
                        'share_of_project_equity_offered' => '',
                    ]);
                    $obj->save(false);
//
                    $objL = new \backend\modules\map\models\ItemLang([
                        'scenario' => 'backend',
                        'rid' => $obj['id'],
                        'lang' => 'uk-UA',
                        'title' => mb_substr(trim($item['name']), 0, 255),
                        'address' => $item['address'] ?? '',
                        'description' => (isset($item['description']) ? trim($item['description']) : '') . $e_data,
                        'investment_schedule' => '',
                        'annual_power_production' => '',
                        'annual_heat_production' => '',
                        'power_price' => '',
                        'heat_price' => '',
                    ]);
                    $objL->save(false);
                }
            }
        }
    }
}
*/