<?php
namespace App\Controller\BaseSite\Site;
use App\Entity\LeadNumbers;
use App\Form\BaseSite\Site\LeadSupportFormType;
use App\Repository\BaseSite\Plan\FeatureRepository;
use App\Repository\BaseSite\Plan\PlanRepository;
use App\Repository\Website\Product\ProductRepository;
use App\Repository\Website\Website\WebsiteRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
#[Route(path: '/', name: 'base_home', host: 'poooshe.com')]
public function index(Request $request, WebsiteRepository $shopRepository, ProductRepository $productRepository, PlanRepository $planRepository, FeatureRepository $featureRepository)
{
$themes = [];
$path = getcwd() . '/themes';
$directories = [];
foreach (scandir($path) as $item) {
if ($item === '.' || $item === '..') {
continue;
}
if (is_dir($path . DIRECTORY_SEPARATOR . $item)) {
$directories[] = $item;
}
}
foreach ($directories as $directory) {
$themes[$directory] = [
'data' => json_decode(file_get_contents($path . '/' . $directory . '/data.json'
// . DIRECTORY_SEPARATOR . $directory
), true),
'screenshotDir' => 'themes/' . $directory . '/screenshot.png',
];
}
$allFeatures = array_map(function ($feature) {
return [
'title' => $feature->getName(),
'icon' => $feature->getIcon(), // یا فیلد واقعی
];
}, $featureRepository->findBy(['active' => 1]));
$groups = [];
$total = count($allFeatures);
// اول ۶ تای اول → دوتا ۳تایی
if ($total >= 3) {
$groups[] = array_slice($allFeatures, 0, 3);
}
if ($total >= 6) {
$groups[] = array_slice($allFeatures, 3, 3);
}
// بعدش → ۸تایی ۸تایی
$offset = 6;
while ($offset < $total) {
$groups[] = array_slice($allFeatures, $offset, 8);
$offset += 8;
}
return $this->render('base_site/site/v3/index.html.twig', [
'themes' => $themes,
'featuresBoxed' => $groups,
'features' => $allFeatures,
'latestBlogs' => []
]);
}
#[Route(path: '/', name: 'redorectCloudfolder_IR', host: 'cloudfolder.ir')]
public function redorectCloudfolder_IR(Request $request, WebsiteRepository $shopRepository, ProductRepository $productRepository)
{
return $this->redirect('https://poooshe.com', 308);
}
#[Route(path: '/', name: 'redorectPoooshe_IR', host: 'poooshe.ir')]
public function redorectPoooshe_IR(Request $request, WebsiteRepository $shopRepository, ProductRepository $productRepository)
{
return $this->redirect('https://poooshe.com', 308);
}
#[Route(path: '/check', name: 'check')]
public function check(Request $request, WebsiteRepository $shopRepository, ProductRepository $productRepository)
{
return $this->render('check.html.twig', []);
}
#[Route(path: '/beta', name: 'beta')]
public function beta(Request $request,
FeatureRepository $featureRepository,
WebsiteRepository $shopRepository, ProductRepository $productRepository)
{
$themes = [];
$path = getcwd() . '/themes';
$directories = [];
foreach (scandir($path) as $item) {
if ($item === '.' || $item === '..') {
continue;
}
if (is_dir($path . DIRECTORY_SEPARATOR . $item)) {
$directories[] = $item;
}
}
foreach ($directories as $directory) {
$themes[$directory] = [
'data' => json_decode(file_get_contents($path . '/' . $directory . '/data.json'
// . DIRECTORY_SEPARATOR . $directory
), true),
'screenshotDir' => 'themes/' . $directory . '/screenshot.png',
];
}
$allFeatures = array_map(function ($feature) {
return [
'title' => $feature->getName(),
'icon' => $feature->getIcon(), // یا فیلد واقعی
];
}, $featureRepository->findBy(['active' => 1]));
$groups = [];
$total = count($allFeatures);
// اول ۶ تای اول → دوتا ۳تایی
if ($total >= 3) {
$groups[] = array_slice($allFeatures, 0, 3);
}
if ($total >= 6) {
$groups[] = array_slice($allFeatures, 3, 3);
}
// بعدش → ۸تایی ۸تایی
$offset = 6;
while ($offset < $total) {
$groups[] = array_slice($allFeatures, $offset, 8);
$offset += 8;
}
return $this->render('base_site/site/v3/index.html.twig', [
'themes' => $themes,
'featuresBoxed' => $groups,
'features' => $allFeatures,
'latestBlogs' => []
]);
}
}