| @@ -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, |
| @@ -34,8 +61,9 @@ | ||
| 34 | 61 | 'custom_cake_order_form' => CustomCakeOrderFormTemplate::class, |
| 35 | 62 | 'wedding_cake_order_form' => WeddingCakeOrderFormTemplate::class, |
| 36 | 63 | 'birthday_cake_order_form' => BirthdayCakeOrderFormTemplate::class, |
| 37 | 64 | 'doctor_appointment_booking_form' => DoctorAppointmentBookingFormTemplate::class, |
| 65 | + 'dinner_reservation_form' => DinnerReservationFormTemplate::class, | |
| 38 | 66 | 'hair_salon_appointment_form' => HairSalonAppointmentFormTemplate::class, |
| 39 | 67 | 'nail_salon_appointment_form' => NailSalonAppointmentFormTemplate::class, |
| 40 | 68 | 'spa_appointment_booking_form' => SpaAppointmentBookingFormTemplate::class, |
| 41 | 69 | 'consultation_appointment_form' => ConsultationAppointmentFormTemplate::class, |
| @@ -56,8 +84,9 @@ | ||
| 56 | 84 | 'maintenance_work_order_form' => MaintenanceWorkOrderFormTemplate::class, |
| 57 | 85 | 'vacation_leave_request_form' => VacationLeaveRequestFormTemplate::class, |
| 58 | 86 | 'sick_leave_request_form' => SickLeaveRequestFormTemplate::class, |
| 59 | 87 | 'annual_leave_request_form' => AnnualLeaveRequestFormTemplate::class, |
| 88 | + 'maternity_leave_request_form' => MaternityLeaveRequestFormTemplate::class, | |
| 60 | 89 | 'conference_registration_form' => ConferenceRegistrationFormTemplate::class, |
| 61 | 90 | 'webinar_registration_form' => WebinarRegistrationFormTemplate::class, |
| 62 | 91 | 'corporate_photo_consent_form' => CorporatePhotoConsentFormTemplate::class, |
| 63 | 92 | 'conference_photo_consent_form' => ConferencePhotoConsentFormTemplate::class, |
| @@ -75,8 +104,86 @@ | ||
| 75 | 104 | 'medical_conference_registration_form' => MedicalConferenceRegistrationFormTemplate::class, |
| 76 | 105 | 'tech_conference_registration_form' => TechConferenceRegistrationFormTemplate::class, |
| 77 | 106 | 'blood_transfusion_consent_form' => BloodTransfusionConsentFormTemplate::class, |
| 78 | 107 | 'vaccination_consent_form' => VaccinationConsentFormTemplate::class, |
| 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, | |
| 79 | 186 | ]; |
| 80 | 187 | |
| 81 | 188 | /** |
| 82 | 189 | * Get the template map |
| @@ -104,9 +211,9 @@ | ||
| 104 | 211 | |
| 105 | 212 | /** |
| 106 | 213 | * Get template class by template ID |
| 107 | 214 | * |
| 108 | - * @param string $templateId | |
| 215 | + * @param string $templateId | |
| 109 | 216 | * @return string|null Template class name or null if not found |
| 110 | 217 | */ |
| 111 | 218 | public static function getTemplateClass(string $templateId): ?string |
| 112 | 219 | { |
| @@ -115,9 +222,9 @@ | ||
| 115 | 222 | |
| 116 | 223 | /** |
| 117 | 224 | * Get template data by template ID |
| 118 | 225 | * |
| 119 | - * @param string $templateId | |
| 226 | + * @param string $templateId | |
| 120 | 227 | * @return array<string, mixed>|null Template data or null if not found |
| 121 | 228 | */ |
| 122 | 229 | public static function getTemplate(string $templateId): ?array |
| 123 | 230 | { |
| @@ -142,9 +249,9 @@ | ||
| 142 | 249 | |
| 143 | 250 | /** |
| 144 | 251 | * Check if template ID exists |
| 145 | 252 | * |
| 146 | - * @param string $templateId | |
| 253 | + * @param string $templateId | |
| 147 | 254 | * @return bool |
| 148 | 255 | */ |
| 149 | 256 | public static function hasTemplate(string $templateId): bool |
| 150 | 257 | { |
| @@ -151,13 +258,17 @@ | ||
| 151 | 258 | return self::getTemplateClass($templateId) !== null; |
| 152 | 259 | } |
| 153 | 260 | |
| 154 | 261 | /** |
| 155 | - * Get all templates as associative array | |
| 262 | + * Get all templates metadata (without form_data) for listing purposes | |
| 156 | 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 | + * | |
| 157 | 268 | * @return array<string, array<string, mixed>> |
| 158 | 269 | */ |
| 159 | - public static function getAllTemplates(): array | |
| 270 | + public static function getAllTemplateMetas(): array | |
| 160 | 271 | { |
| 161 | 272 | $templates = []; |
| 162 | 273 | |
| 163 | 274 | foreach ((new TemplateMapper())->getTemplateMap() as $templateId => $templateClass) { |
| @@ -165,11 +276,10 @@ | ||
| 165 | 276 | if ($templateClass === BlankFormTemplate::class) { |
| 166 | 277 | continue; |
| 167 | 278 | } |
| 168 | 279 | |
| 169 | - if (class_exists($templateClass)) { | |
| 170 | - $templateData = $templateClass::getTemplate(); | |
| 171 | - $templates[$templateId] = $templateData; | |
| 280 | + if (class_exists($templateClass) && method_exists($templateClass, 'getTemplateMeta')) { | |
| 281 | + $templates[$templateId] = $templateClass::getTemplateMeta(); | |
| 172 | 282 | } |
| 173 | 283 | } |
| 174 | 284 | |
| 175 | 285 | return $templates; |