<?php
$this->title = 'Tilda проекты на сайте';
$this->params['breadcrumbs'][] = ['label' => 'Tilda', 'url' => ['index'] ];
$this->params['breadcrumbs'][] = 'Загруженные проекты';
?>
<div class="row">
<?
	$curcat = $api->local->getProjectFullDir();
	$ucat = $api->local->getProjectDir();
	$cat = yii\helpers\FileHelper::findDirectories($curcat, ['recursive'=>false]);
	foreach( $cat as $url){
		$inx = $url.'/'.'index.html';
		if( file_exists( $inx ) ){
			if( $f = basename( @readlink( $url.'/'.'index.html') ) ){
				$fm = str_replace( '.html', '.php', $f );
				//echo $fm."<br>";
				if( file_exists( $url.'/meta/'.$fm ) ){
					$r = include($url.'/meta/'.$fm);
					$dname = basename($url);
					if( $r['img'] == '' || !file_exists($url.'/img/'.$r['img']) ){
						$txt = file_get_contents($url.'/'.'index.html');
						preg_match('|og\:image.*content="([^"]*)"|i',$txt, $a);
						$imga=$a[1];
					//	print_a( $a );
					}else{
						$imga='/'.$ucat.''.$dname.'/img/'.$r['img'];
					}
?>
<div class="col-md-12 col-lg-6 col-xl-4">
	<div class="card mb-2 bg-gradient-dark">
		<img class="card-img-top" src="<?=$imga?>" alt="img" style="aspect-ratio:16/9; object-fit: cover;" >
		<div class="card-img-overlay d-flex flex-column justify-content-end" style="background: linear-gradient(#00000026, #000000c4);">
			<h5 class="card-title text-primary text-white"><?=$r['title']?></h5>
			<p class="card-text text-white pb-2 pt-1"><?=$r['descr']?></p>
			<a href="https://www.amic.ru/<?=$ucat.$dname?>/" class="text-white" target="_blank">Открыть проект <i class="fas fa-arrow-circle-right"></i></a>
			<div><strong><i class="fas fa-pencil-alt mr-1"></i> Сылка для копирования</strong>
				<p class="tag tag-danger bg-gradient-warning px-2" style="opacity: 0.7;">https://www.amic.ru/<?=$ucat.$dname?>/</p>
			</div>
		</div>
	</div>
</div>
<?
				}
			}
		}
	}
?>
</div>
