diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 554c56c..160ddfb 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -35,6 +35,10 @@ $routes->post('del/(:num)', 'Url::delUrl/$1', ['filter' => 'session']); // json del url }); +$routes->group('urltags', static function ($routes) { + $routes->get('/', 'Urltags::index', ['as' => 'url-tags', 'filter' => 'session']); +}); + // Users $routes->group('users', static function ($routes) { $routes->get('/', 'Users::index', ['filter' => 'session']); diff --git a/app/Controllers/Urltags.php b/app/Controllers/Urltags.php new file mode 100644 index 0000000..5b13a5f --- /dev/null +++ b/app/Controllers/Urltags.php @@ -0,0 +1,38 @@ +user()->can('url.access')) { + return smarty_permission_error(); + } + + $urltagsModel = new UrltagsModel(); + $tags = $urltagsModel->getTagsWithUrlCount(); + + // Format the created_at datetime field + foreach ($tags as &$tag) { + // Convert to Time object + $createdAt = Time::createFromFormat('Y-m-d H:i:s', $tag['created_at']); + + // Format as desired (e.g., 'F j, Y, g:i a') + $tag['created_at'] = lang('Common.CreatedAt') . ' ' . $createdAt->format('F j, Y, g:i a'); + } + + $data['tags'] = $tags; + + return view(smarty_view('url/tags'), $data); + } +} diff --git a/app/Language/ar/Common.php b/app/Language/ar/Common.php index 4c5f7e8..b3704ad 100644 --- a/app/Language/ar/Common.php +++ b/app/Language/ar/Common.php @@ -33,4 +33,6 @@ 'MyURLsHitCountAllTime' => 'اجمالي زيارات روابطي', 'MyURLsHitCountThisMonth' => 'زيارات روابطي هذا الشهر', 'MyURLsHitCountToday' => 'زيارات روابطي اليوم', + + 'CreatedAt' => 'في تاريخ', ]; diff --git a/app/Language/ar/Url.php b/app/Language/ar/Url.php index 15104d9..aed5077 100644 --- a/app/Language/ar/Url.php +++ b/app/Language/ar/Url.php @@ -99,4 +99,7 @@ 'ThisMonth' => 'هذا الشهر', 'AllTime' => 'كل الوقت', 'MyUrls' => 'روابطي', + + 'TagsCloud' => 'سحابة هاشتاق الروابط', + 'TagCreator' => 'منشئ الهاشتاق', ]; diff --git a/app/Language/en/Common.php b/app/Language/en/Common.php index 3d254fb..c42156e 100644 --- a/app/Language/en/Common.php +++ b/app/Language/en/Common.php @@ -33,4 +33,6 @@ 'MyURLsHitCountAllTime' => 'Total visits of my URLs', 'MyURLsHitCountThisMonth' => 'My URLs visits this month', 'MyURLsHitCountToday' => 'My URLs visits today', + + 'CreatedAt' => 'At', ]; diff --git a/app/Language/en/Url.php b/app/Language/en/Url.php index da50282..b03b9a9 100644 --- a/app/Language/en/Url.php +++ b/app/Language/en/Url.php @@ -99,4 +99,7 @@ 'ThisMonth' => 'This Month', 'AllTime' => 'All Time', 'MyUrls' => 'My URLs', + + 'TagsCloud' => 'URL Tags Cloud', + 'TagCreator' => 'Tag Creator', ]; diff --git a/app/Models/UrlTagsModel.php b/app/Models/UrlTagsModel.php index f4fb171..0731eca 100644 --- a/app/Models/UrlTagsModel.php +++ b/app/Models/UrlTagsModel.php @@ -100,4 +100,18 @@ public function findTagNo(string $tag, int $userId, bool $shared = false) return $this->countAllResults(); } + + /** + * This function return tags cloud with url count for each tag + */ + public function getTagsWithUrlCount() + { + return $this->db->table($this->table) + ->select('urltags.*, COUNT(urltagsdata.url_id) AS url_count, users.username AS creator_username') + ->join('urltagsdata', 'urltags.tag_id = urltagsdata.tag_id', 'left') + ->join('users', 'urltags.tag_user_id = users.id', 'left') + ->groupBy('urltags.tag_id') + ->get() + ->getResultArray(); + } } diff --git a/app/Views/basic/layout.php b/app/Views/basic/layout.php index e9d994c..bee6980 100644 --- a/app/Views/basic/layout.php +++ b/app/Views/basic/layout.php @@ -4,29 +4,31 @@ - <?= $this->renderSection('title') ?> + + <?= $this->renderSection('title') ?> + + content="AdminLTE is a Free Bootstrap 5 Admin Dashboard, 30 example pages using Vanilla JS."> + content="bootstrap 5, bootstrap, bootstrap 5 admin dashboard, bootstrap 5 dashboard, bootstrap 5 charts, bootstrap 5 calendar, bootstrap 5 datepicker, bootstrap 5 tables, bootstrap 5 datatable, vanilla js datatable, colorlibhq, colorlibhq dashboard, colorlibhq admin dashboard"> + rel="stylesheet"> + integrity="sha256-LWLZPJ7X1jJLI5OG5695qDemW1qQ7lNdbTfQ64ylbUY=" crossorigin="anonymous"> + integrity="sha256-BicZsQAhkGHIoR//IB2amPN5SrRb3fHB8tFsnqRAwnk=" crossorigin="anonymous"> @@ -41,314 +43,344 @@ - -
- - - - -
+ + + + + - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - -renderSection('jsfooterarea') ?> - - - + + + + + + + + + + + renderSection('jsfooterarea') ?> + + + - + \ No newline at end of file diff --git a/app/Views/basic/url/tags.php b/app/Views/basic/url/tags.php new file mode 100644 index 0000000..3d9a4d2 --- /dev/null +++ b/app/Views/basic/url/tags.php @@ -0,0 +1,170 @@ +extend(smarty_view('layout')); ?> + +section('title') ?> + +endSection() ?> + +section('cssheaderarea') ?> + +endSection() ?> + + +section('main') ?> +
+ +
+ +
+ +
+
+

+ +

+
+
+ +
+
+ +
+ +
+ +
+ + + +
+ +
+
+
+ +
+ +
+ +
+
+

+ +

+
+
+ + + + +
+
+ + +
+ +
+ + + +
+ + + + +
+
+ + + + +
+ + + + "> + + 0): ?> + + + + + + + + + + + + + +
+
+
+ + + + + + + + +
+ +
+ + +
+
+
+
+ +
+ +endSection(); ?> \ No newline at end of file