<?php

namespace WPQT\Location;

if (!defined('ABSPATH')) {
    exit;
}

if (!class_exists('WPQT\Location\LocationService')) {
    class LocationService
    {
        /**
         * Checks if the current page is a WP Quick Tasks page.
         *
         * @return bool Returns true if the current page is a WP Quick Tasks page, false otherwise.
         */
        public function isWPQTPage()
        {
            if (isset($_GET['page']) && in_array($_GET['page'], ['wp-quicktasker', 'wp-quicktasker-my-tasks'], true)) {
                return true;
            }

            return false;
        }

        /**
         * Checks if the current page is the user page app.
         *
         * @return bool Returns true if the current page is the WP Quick Tasks public user page, false otherwise.
         */
        public function isWPQTPublicUserPage()
        {
            if (isset($_GET['page']) && WP_QUICKTASKER_PUBLIC_USER_PAGE_ID === $_GET['page']) {
                return true;
            }

            return false;
        }

        /**
         * Checks if the current page is the task PDF export page.
         *
         * @return bool Returns true if the current page is the WP Quick Tasks task PDF export page, false otherwise.
         */
        public function isWPQTTaskPDFExportPage()
        {
            if (isset($_GET['wpqt-page']) && WP_QUICKTASKER_TASK_PDF_EXPORT_PAGE_ID === $_GET['wpqt-page']) {
                return true;
            }

            return false;
        }

        /**
         * Checks if the current page is the task JSON export page.
         *
         * @return bool Returns true if the current page is the WP Quick Tasks task JSON export page, false otherwise.
         */
        public function isWPQTTaskJSONExportPage()
        {
            if (isset($_GET['wpqt-page']) && WP_QUICKTASKER_TASK_JSON_EXPORT_PAGE_ID === $_GET['wpqt-page']) {
                return true;
            }

            return false;
        }

        /**
         * Checks if the current page is a WP Quick Tasks task export page (either PDF or JSON).
         *
         * @return bool Returns true if the current page is a WP Quick Tasks task export page, false otherwise.
         */
        public function isWPQTTaskExportPage()
        {
            return $this->isWPQTTaskPDFExportPage() || $this->isWPQTTaskJSONExportPage();
        }
    }
}
