diff --git a/config/routes/easyadmin.yaml b/config/routes/easyadmin.yaml new file mode 100644 index 0000000..7275307 --- /dev/null +++ b/config/routes/easyadmin.yaml @@ -0,0 +1,4 @@ +# config/routes/easyadmin.yaml +easyadmin: + resource: . + type: easyadmin.routes \ No newline at end of file diff --git a/public/img/versions.webp b/public/img/versions.webp new file mode 100644 index 0000000..c656c28 Binary files /dev/null and b/public/img/versions.webp differ diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index e15ca4c..f7ccf72 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -2,19 +2,22 @@ namespace App\Controller\Admin; +use App\Entity\Post; +use App\Entity\Tree; +use App\Entity\User; use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; +use EasyCorp\Bundle\EasyAdminBundle\Config\Locale; use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; -use EasyCorp\Bundle\EasyAdminBundle\Dto\LocaleDto; class DashboardController extends AbstractDashboardController { - #[Route('/admin', name: 'admin')] - public function index(): Response + #[Route('/admin/{_locale}', name: 'admin')] + public function index($_locale = 'fa'): Response { - return parent::index(); + //return parent::index(); // Option 1. You can make your dashboard redirect to some common page of your backend // @@ -30,43 +33,28 @@ class DashboardController extends AbstractDashboardController // Option 3. You can render some custom template to display a proper dashboard with widgets, etc. // (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig) // - // return $this->render('some/path/my-dashboard.html.twig'); + return $this->render('admin/dashboard.html.twig'); } public function configureDashboard(): Dashboard { return Dashboard::new() - // the name visible to end users - ->setTitle('ACME Corp.') // you can include HTML contents too (e.g. to link to an image) - ->setTitle(' ACME Corp.') + ->setTitle('پیشخوان') // by default EasyAdmin displays a black square as its default favicon; // use this method to display a custom favicon: the given path is passed // "as is" to the Twig asset() function: // - ->setFaviconPath('favicon.svg') + ->setFaviconPath('favicon/favicon.ico') // the domain used by default is 'messages' - ->setTranslationDomain('my-custom-domain') - - // there's no need to define the "text direction" explicitly because - // its default value is inferred dynamically from the user locale - ->setTextDirection('ltr') + ->setTranslationDomain('admin') // set this option if you prefer the page content to span the entire // browser width, instead of the default design which sets a max width ->renderContentMaximized() - // set this option if you prefer the sidebar (which contains the main menu) - // to be displayed as a narrow column instead of the default expanded design - ->renderSidebarMinimized() - - // by default, users can select between a "light" and "dark" mode for the - // backend interface. Call this method if you prefer to disable the "dark" - // mode for any reason (e.g. if your interface customizations are not ready for it) - ->disableDarkMode() - // by default, the UI color scheme is 'auto', which means that the backend // will use the same mode (light/dark) as the operating system and will // change in sync when the OS mode changes. @@ -79,12 +67,25 @@ class DashboardController extends AbstractDashboardController // by default, all backend URLs are generated as absolute URLs. If you // need to generate relative URLs instead, call this method ->generateRelativeUrls() + + ->setLocales(['en','fa']) + // to further customize the locale option, pass an instance of + // EasyCorp\Bundle\EasyAdminBundle\Config\Locale ; } public function configureMenuItems(): iterable { - yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home'); - // yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class); + return [ + MenuItem::linkToDashboard('پیشخوان', 'fa fa-home'), + + MenuItem::section('پست بلاگ'), + MenuItem::linkToCrud('دسته بندی', 'fa fa-tags', Tree::class), + MenuItem::linkToCrud('محتوا', 'fa fa-file-text', Post::class), + + MenuItem::section('کاربران'), + MenuItem::linkToCrud('کاربران', 'fa fa-user', User::class), + ]; } + } diff --git a/src/Controller/Admin/PostCrudController.php b/src/Controller/Admin/PostCrudController.php index e126abc..4ffed31 100644 --- a/src/Controller/Admin/PostCrudController.php +++ b/src/Controller/Admin/PostCrudController.php @@ -3,8 +3,10 @@ namespace App\Controller\Admin; use App\Entity\Post; +use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; @@ -15,14 +17,22 @@ class PostCrudController extends AbstractCrudController return Post::class; } - /* public function configureFields(string $pageName): iterable { return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), + TextField::new('title', 'عنوان'), + TextareaField::new('intro', 'خلاصه مطلب'), + TextEditorField::new('body', 'متن'), ]; } - */ + + public function configureCrud(Crud $crud): Crud + { + return $crud + // the labels used to refer to this entity in titles, buttons, etc. + ->setEntityLabelInSingular('محتوا') + ->setEntityLabelInPlural('محتواها') + ; + } + } diff --git a/src/Controller/Admin/TreeCrudController.php b/src/Controller/Admin/TreeCrudController.php new file mode 100644 index 0000000..7b3600b --- /dev/null +++ b/src/Controller/Admin/TreeCrudController.php @@ -0,0 +1,28 @@ + $tress, ]); } + + #[Route('/changes', name: 'app_changes')] + public function app_changes(EntityManagerInterface $entityManagerInterface): Response + { + $posts = $entityManagerInterface->getRepository(Post::class)->findAllByCat('changelog'); + return $this->render('post/versions.html.twig', [ + 'items' => $posts, + ]); + } } diff --git a/src/Repository/PostRepository.php b/src/Repository/PostRepository.php index 8552650..5dc430f 100644 --- a/src/Repository/PostRepository.php +++ b/src/Repository/PostRepository.php @@ -58,4 +58,16 @@ class PostRepository extends ServiceEntityRepository ->getResult() ; } + + public function findAllBycat($cat = 'blog'): array + { + return $this->createQueryBuilder('p') + ->innerJoin('p.cat', 'c') + ->where('c.code = :cat') + ->setParameter('cat', $cat) + ->orderBy('p.dateSubmit', 'DESC') + ->getQuery() + ->getResult() + ; + } } diff --git a/templates/admin/dashboard.html.twig b/templates/admin/dashboard.html.twig new file mode 100644 index 0000000..a6f721e --- /dev/null +++ b/templates/admin/dashboard.html.twig @@ -0,0 +1 @@ +{% extends '@EasyAdmin/layout.html.twig' %} \ No newline at end of file diff --git a/templates/base.html.twig b/templates/base.html.twig index 018ba04..4e197fd 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -78,6 +78,9 @@ + diff --git a/templates/general/sitemap.html.twig b/templates/general/sitemap.html.twig index da2519b..209ecef 100644 --- a/templates/general/sitemap.html.twig +++ b/templates/general/sitemap.html.twig @@ -2,12 +2,21 @@ - {{ absolute_url(path('app_home')) }} 2025-01-09T06:58:03+00:00 1.00 + + {{ absolute_url(path('app_changes')) }} + 2025-01-09T06:58:03+00:00 + 1.00 + + + {{ absolute_url(path('app_blog_home')) }} + 2025-01-09T06:58:03+00:00 + 1.00 + {% for post in posts %} {% if post.cat.code == 'plain' %} @@ -21,6 +30,18 @@ {{ twigFunctions.getctime(post.dateSubmit) }} 1.00 + {% elseif post.cat.code == 'guide' %} + + {{ absolute_url(path('app_guide',{'url':post.url})) }} + {{ twigFunctions.getctime(post.dateSubmit) }} + 1.00 + + {% elseif post.cat.code == 'api' %} + + {{ absolute_url(path('app_api_docs',{'url':post.url})) }} + {{ twigFunctions.getctime(post.dateSubmit) }} + 1.00 + {% endif %} {% endfor %} diff --git a/templates/post/versions.html.twig b/templates/post/versions.html.twig new file mode 100644 index 0000000..ad107da --- /dev/null +++ b/templates/post/versions.html.twig @@ -0,0 +1,26 @@ +{% extends 'base.html.twig' %} +{% block keywords %}item.keywords +{% endblock %} +{% block title %} + تاریخچه تغییرات حسابیکس +{% endblock %} + +{% block des %} + تاریخچه تغییرات حسابیکس +{% endblock %} + +{% block body %} +
+
+
+ +
+ {% for item in items %} +
+

{{ item.title }}

+

{{ item.body | raw }}

+
+ {% endfor %} +
+
+{% endblock %}