| @@ -3,13 +3,8 @@ | ||
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | 5 | namespace IvyForms\Services\Template; |
| 6 | 6 | |
| 7 | -// phpcs:disable PSR1.Files.SideEffects | |
| 8 | -if (!defined('ABSPATH')) { | |
| 9 | - exit; // Exit if accessed directly | |
| 10 | -} | |
| 11 | - | |
| 12 | 7 | /** |
| 13 | 8 | * Class TemplateMapper |
| 14 | 9 | * |
| 15 | 10 | * Maps template IDs to their corresponding template classes |
| @@ -26,9 +21,41 @@ | ||
| 26 | 21 | private static array $templateMap = [ |
| 27 | 22 | 'contact_form' => ContactFormTemplate::class, |
| 28 | 23 | 'blank_form' => BlankFormTemplate::class, |
| 29 | 24 | 'wedding_rsvp' => WeddingRsvpTemplate::class, |
| 25 | + 'anniversary_dinner_reservation_form' => AnniversaryDinnerReservationFormTemplate::class, | |
| 26 | + 'birthday_dinner_reservation_form' => BirthdayDinnerReservationFormTemplate::class, | |
| 27 | + 'private_dining_reservation_form' => PrivateDiningReservationFormTemplate::class, | |
| 28 | + 'craft_vendor_registration_form' => CraftVendorRegistrationFormTemplate::class, | |
| 29 | + 'food_vendor_registration_form' => FoodVendorRegistrationFormTemplate::class, | |
| 30 | + 'fitness_class_registration_form' => FitnessClassRegistrationFormTemplate::class, | |
| 31 | + 'yoga_class_registration_form' => YogaClassRegistrationFormTemplate::class, | |
| 32 | + 'cooking_class_registration_form' => CookingClassRegistrationFormTemplate::class, | |
| 33 | + 'conference_room_booking_form' => ConferenceRoomBookingFormTemplate::class, | |
| 30 | 34 | 'product_order_form' => ProductOrderFormTemplate::class, |
| 35 | + 'b2b_product_order_form' => B2bProductOrderFormTemplate::class, | |
| 36 | + 'corporate_office_supplies_procurement_form' => CorporateOfficeSuppliesProcurementFormTemplate::class, | |
| 37 | + 'product_customization_form' => ProductCustomizationFormTemplate::class, | |
| 38 | + 'technology_innovation_summit_registration_form' => TechnologyInnovationSummitRegistrationFormTemplate::class, | |
| 39 | + 'healthcare_medical_conference_registration_form' => HealthcareMedicalConferenceRegistrationFormTemplate::class, | |
| 40 | + 'marketing_growth_leadership_conference_registration_form' | |
| 41 | + => MarketingGrowthLeadershipConferenceRegistrationFormTemplate::class, | |
| 42 | + 'financial_services_fintech_leadership_conference_registration_form' | |
| 43 | + => FinancialServicesFintechLeadershipConferenceRegistrationFormTemplate::class, | |
| 44 | + 'education_academic_research_conference_registration_form' | |
| 45 | + => EducationAcademicResearchConferenceRegistrationFormTemplate::class, | |
| 46 | + 'cybersecurity_data_protection_conference_registration_form' | |
| 47 | + => CybersecurityDataProtectionConferenceRegistrationFormTemplate::class, | |
| 48 | + 'technology_conference_event_feedback_form' => TechnologyConferenceEventFeedbackFormTemplate::class, | |
| 49 | + 'healthcare_seminar_medical_event_feedback_form' => HealthcareSeminarMedicalEventFeedbackFormTemplate::class, | |
| 50 | + 'marketing_networking_event_feedback_form' => MarketingNetworkingEventFeedbackFormTemplate::class, | |
| 51 | + 'corporate_employee_training_feedback_form' => CorporateEmployeeTrainingFeedbackFormTemplate::class, | |
| 52 | + 'technical_skills_workshop_feedback_form' => TechnicalSkillsWorkshopFeedbackFormTemplate::class, | |
| 53 | + 'online_course_elearning_feedback_form' => OnlineCourseElearningFeedbackFormTemplate::class, | |
| 54 | + 'medical_specialist_appointment_booking_form' => MedicalSpecialistAppointmentBookingFormTemplate::class, | |
| 55 | + 'beauty_salon_personal_care_appointment_form' => BeautySalonPersonalCareAppointmentFormTemplate::class, | |
| 56 | + 'business_consultation_strategy_session_booking_form' | |
| 57 | + => BusinessConsultationStrategySessionBookingFormTemplate::class, | |
| 31 | 58 | 'event_registration' => EventRegistrationTemplate::class, |
| 32 | 59 | 'event_tshirt_order_form' => EventTShirtOrderFormTemplate::class, |
| 33 | 60 | 'custom_tshirt_order_form' => CustomTShirtOrderFormTemplate::class, |
| 34 | 61 | 'custom_cake_order_form' => CustomCakeOrderFormTemplate::class, |
| @@ -78,8 +105,85 @@ | ||
| 78 | 105 | 'tech_conference_registration_form' => TechConferenceRegistrationFormTemplate::class, |
| 79 | 106 | 'blood_transfusion_consent_form' => BloodTransfusionConsentFormTemplate::class, |
| 80 | 107 | 'vaccination_consent_form' => VaccinationConsentFormTemplate::class, |
| 81 | 108 | 'anesthesia_consent_form' => AnesthesiaConsentFormTemplate::class, |
| 109 | + 'garden_wedding_rsvp_form' => GardenWeddingRSVPFormTemplate::class, | |
| 110 | + 'beach_wedding_rsvp_form' => BeachWeddingRSVPFormTemplate::class, | |
| 111 | + 'destination_wedding_rsvp_form' => DestinationWeddingRSVPFormTemplate::class, | |
| 112 | + 'traditional_wedding_rsvp_form' => TraditionalWeddingRSVPFormTemplate::class, | |
| 113 | + 'wedding_registration_form' => WeddingRegistrationFormTemplate::class, | |
| 114 | + 'software_purchase_order_form' => SoftwarePurchaseOrderFormTemplate::class, | |
| 115 | + 'office_supplies_purchase_order_form' => OfficeSuppliesPurchaseOrderFormTemplate::class, | |
| 116 | + 'equipment_purchase_order_form' => EquipmentPurchaseOrderFormTemplate::class, | |
| 117 | + 'material_purchase_order_form' => MaterialPurchaseOrderFormTemplate::class, | |
| 118 | + 'education_conference_registration_form' => EducationConferenceRegistrationFormTemplate::class, | |
| 119 | + 'repair_work_order_form' => RepairWorkOrderFormTemplate::class, | |
| 120 | + 'installation_work_order_form' => InstallationWorkOrderFormTemplate::class, | |
| 121 | + 'team_tshirt_order_form' => TeamTshirtOrderFormTemplate::class, | |
| 122 | + 'kitchen_upgrade_change_form' => KitchenUpgradeChangeFormTemplate::class, | |
| 123 | + 'commercial_construction_change_form' => CommercialConstructionChangeFormTemplate::class, | |
| 124 | + 'hr_interview_feedback_form' => HRInterviewFeedbackFormTemplate::class, | |
| 125 | + 'technical_role_interview_feedback_form' => TechnicalRoleInterviewFeedbackFormTemplate::class, | |
| 126 | + 'candidate_evaluation_form' => CandidateEvaluationFormTemplate::class, | |
| 127 | + 'technical_interview_feedback_form' => TechnicalInterviewFeedbackFormTemplate::class, | |
| 128 | + 'course_content_feedback_form' => CourseContentFeedbackFormTemplate::class, | |
| 129 | + 'trainer_feedback_form' => TrainerFeedbackFormTemplate::class, | |
| 130 | + 'online_training_feedback_form' => OnlineTrainingFeedbackFormTemplate::class, | |
| 131 | + 'employee_training_feedback_form' => EmployeeTrainingFeedbackFormTemplate::class, | |
| 132 | + 'client_loyalty_testimonial_readiness_form' => ClientLoyaltyTestimonialReadinessFormTemplate::class, | |
| 133 | + 'client_relationship_communication_feedback' => ClientRelationshipCommunicationFeedbackTemplate::class, | |
| 134 | + 'general_client_feedback_form' => GeneralClientFeedbackFormTemplate::class, | |
| 135 | + 'service_specific_client_feedback_form' => ServiceSpecificClientFeedbackFormTemplate::class, | |
| 136 | + 'ongoing_client_feedback_form' => OngoingClientFeedbackFormTemplate::class, | |
| 137 | + 'training_event_feedback_form' => TrainingEventFeedbackFormTemplate::class, | |
| 138 | + 'networking_event_feedback_form' => NetworkingEventFeedbackFormTemplate::class, | |
| 139 | + 'workshop_feedback_form' => WorkshopFeedbackFormTemplate::class, | |
| 140 | + 'customer_loyalty_recommendation_form' => CustomerLoyaltyRecommendationFormTemplate::class, | |
| 141 | + 'webinar_feedback_form' => WebinarFeedbackFormTemplate::class, | |
| 142 | + 'conference_feedback_form' => ConferenceFeedbackFormTemplate::class, | |
| 143 | + 'event_feedback_form' => EventFeedbackFormTemplate::class, | |
| 144 | + 'post_purchase_feedback_form' => PostPurchaseFeedbackFormTemplate::class, | |
| 145 | + 'website_experience_feedback_form' => WebsiteExperienceFeedbackFormTemplate::class, | |
| 146 | + 'customer_support_feedback_form' => CustomerSupportFeedbackFormTemplate::class, | |
| 147 | + 'product_feedback_form' => ProductFeedbackFormTemplate::class, | |
| 148 | + 'project_completion_feedback_form' => ProjectCompletionFeedbackFormTemplate::class, | |
| 149 | + 'digital_marketing_internship_application_form' => DigitalMarketingInternshipApplicationFormTemplate::class, | |
| 150 | + 'software_engineering_internship_application_form' | |
| 151 | + => SoftwareEngineeringInternshipApplicationFormTemplate::class, | |
| 152 | + 'warehouse_logistics_worker_application_form' => WarehouseLogisticsWorkerApplicationFormTemplate::class, | |
| 153 | + 'marketing_specialist_job_application_form' => MarketingSpecialistJobApplicationFormTemplate::class, | |
| 154 | + 'software_developer_job_application_form' => SoftwareDeveloperJobApplicationFormTemplate::class, | |
| 155 | + 'commercial_rental_application_form' => CommercialRentalApplicationFormTemplate::class, | |
| 156 | + 'student_housing_application_form' => StudentHousingApplicationFormTemplate::class, | |
| 157 | + 'rental_application_form' => RentalApplicationFormTemplate::class, | |
| 158 | + 'technical_contractor_application_form' => TechnicalContractorApplicationFormTemplate::class, | |
| 159 | + 'creative_contractor_application_form' => CreativeContractorApplicationFormTemplate::class, | |
| 160 | + 'freelancer_application_form' => FreelancerApplicationFormTemplate::class, | |
| 161 | + 'remote_internship_application_form' => RemoteInternshipApplicationFormTemplate::class, | |
| 162 | + 'corporate_internship_application_form' => CorporateInternshipApplicationFormTemplate::class, | |
| 163 | + 'university_internship_application_form' => UniversityInternshipApplicationFormTemplate::class, | |
| 164 | + 'skilled_trade_employment_application_form' => SkilledTradeEmploymentApplicationFormTemplate::class, | |
| 165 | + 'retail_employment_application_form' => RetailEmploymentApplicationFormTemplate::class, | |
| 166 | + 'corporate_employment_application_form' => CorporateEmploymentApplicationFormTemplate::class, | |
| 167 | + 'skilled_professional_job_application_form' => SkilledProfessionalJobApplicationFormTemplate::class, | |
| 168 | + 'entry_level_job_application_form' => EntryLevelJobApplicationFormTemplate::class, | |
| 169 | + 'general_job_application_form' => GeneralJobApplicationFormTemplate::class, | |
| 170 | + 'office_space_rental_application_form' => OfficeSpaceRentalApplicationFormTemplate::class, | |
| 171 | + 'apartment_rental_application_form' => ApartmentRentalApplicationFormTemplate::class, | |
| 172 | + 'ui_ux_designer_freelancer_application_form' => UiUxDesignerFreelancerApplicationFormTemplate::class, | |
| 173 | + 'video_editor_freelancer_application_form' => VideoEditorFreelancerApplicationFormTemplate::class, | |
| 174 | + 'custom_event_tshirt_bulk_order_form' => CustomEventTShirtBulkOrderFormTemplate::class, | |
| 175 | + 'fashion_brand_custom_apparel_order_form' => FashionBrandCustomApparelOrderFormTemplate::class, | |
| 176 | + 'sports_team_custom_jersey_tshirt_order_form' => SportsTeamCustomJerseyTShirtOrderFormTemplate::class, | |
| 177 | + 'facility_maintenance_issue_report_form' => FacilityMaintenanceIssueReportFormTemplate::class, | |
| 178 | + 'it_support_equipment_maintenance_form' => ItSupportEquipmentMaintenanceFormTemplate::class, | |
| 179 | + 'property_maintenance_repair_request_form' => PropertyMaintenanceRepairRequestFormTemplate::class, | |
| 180 | + 'corporate_event_sponsorship_application_form' => CorporateEventSponsorshipApplicationFormTemplate::class, | |
| 181 | + 'startup_sponsorship_application_form' => StartupSponsorshipApplicationFormTemplate::class, | |
| 182 | + 'media_influencer_sponsorship_application_form' => MediaInfluencerSponsorshipApplicationFormTemplate::class, | |
| 183 | + 'business_vendor_onboarding_form' => BusinessVendorOnboardingFormTemplate::class, | |
| 184 | + 'wholesale_supplier_application_form' => WholesaleSupplierApplicationFormTemplate::class, | |
| 185 | + 'service_provider_partnership_application_form' => ServiceProviderPartnershipApplicationFormTemplate::class, | |
| 82 | 186 | ]; |
| 83 | 187 | |
| 84 | 188 | /** |
| 85 | 189 | * Get the template map |
| @@ -107,9 +211,9 @@ | ||
| 107 | 211 | |
| 108 | 212 | /** |
| 109 | 213 | * Get template class by template ID |
| 110 | 214 | * |
| 111 | - * @param string $templateId | |
| 215 | + * @param string $templateId | |
| 112 | 216 | * @return string|null Template class name or null if not found |
| 113 | 217 | */ |
| 114 | 218 | public static function getTemplateClass(string $templateId): ?string |
| 115 | 219 | { |
| @@ -118,9 +222,9 @@ | ||
| 118 | 222 | |
| 119 | 223 | /** |
| 120 | 224 | * Get template data by template ID |
| 121 | 225 | * |
| 122 | - * @param string $templateId | |
| 226 | + * @param string $templateId | |
| 123 | 227 | * @return array<string, mixed>|null Template data or null if not found |
| 124 | 228 | */ |
| 125 | 229 | public static function getTemplate(string $templateId): ?array |
| 126 | 230 | { |
| @@ -145,9 +249,9 @@ | ||
| 145 | 249 | |
| 146 | 250 | /** |
| 147 | 251 | * Check if template ID exists |
| 148 | 252 | * |
| 149 | - * @param string $templateId | |
| 253 | + * @param string $templateId | |
| 150 | 254 | * @return bool |
| 151 | 255 | */ |
| 152 | 256 | public static function hasTemplate(string $templateId): bool |
| 153 | 257 | { |
| @@ -154,13 +258,17 @@ | ||
| 154 | 258 | return self::getTemplateClass($templateId) !== null; |
| 155 | 259 | } |
| 156 | 260 | |
| 157 | 261 | /** |
| 158 | - * Get all templates as associative array | |
| 262 | + * Get all templates metadata (without form_data) for listing purposes | |
| 159 | 263 | * |
| 264 | + * Returns only: id, name, description, category, subcategory, is_pro, screenshot | |
| 265 | + * This avoids loading heavy form_data (fields, settings) for every template | |
| 266 | + * when only metadata is needed for browsing/searching. | |
| 267 | + * | |
| 160 | 268 | * @return array<string, array<string, mixed>> |
| 161 | 269 | */ |
| 162 | - public static function getAllTemplates(): array | |
| 270 | + public static function getAllTemplateMetas(): array | |
| 163 | 271 | { |
| 164 | 272 | $templates = []; |
| 165 | 273 | |
| 166 | 274 | foreach ((new TemplateMapper())->getTemplateMap() as $templateId => $templateClass) { |
| @@ -168,11 +276,10 @@ | ||
| 168 | 276 | if ($templateClass === BlankFormTemplate::class) { |
| 169 | 277 | continue; |
| 170 | 278 | } |
| 171 | 279 | |
| 172 | - if (class_exists($templateClass)) { | |
| 173 | - $templateData = $templateClass::getTemplate(); | |
| 174 | - $templates[$templateId] = $templateData; | |
| 280 | + if (class_exists($templateClass) && method_exists($templateClass, 'getTemplateMeta')) { | |
| 281 | + $templates[$templateId] = $templateClass::getTemplateMeta(); | |
| 175 | 282 | } |
| 176 | 283 | } |
| 177 | 284 | |
| 178 | 285 | return $templates; |