| @@ -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 |
| @@ -36,8 +31,31 @@ | ||
| 36 | 31 | 'yoga_class_registration_form' => YogaClassRegistrationFormTemplate::class, |
| 37 | 32 | 'cooking_class_registration_form' => CookingClassRegistrationFormTemplate::class, |
| 38 | 33 | 'conference_room_booking_form' => ConferenceRoomBookingFormTemplate::class, |
| 39 | 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, | |
| 40 | 58 | 'event_registration' => EventRegistrationTemplate::class, |
| 41 | 59 | 'event_tshirt_order_form' => EventTShirtOrderFormTemplate::class, |
| 42 | 60 | 'custom_tshirt_order_form' => CustomTShirtOrderFormTemplate::class, |
| 43 | 61 | 'custom_cake_order_form' => CustomCakeOrderFormTemplate::class, |
| @@ -102,8 +120,70 @@ | ||
| 102 | 120 | 'installation_work_order_form' => InstallationWorkOrderFormTemplate::class, |
| 103 | 121 | 'team_tshirt_order_form' => TeamTshirtOrderFormTemplate::class, |
| 104 | 122 | 'kitchen_upgrade_change_form' => KitchenUpgradeChangeFormTemplate::class, |
| 105 | 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, | |
| 106 | 186 | ]; |
| 107 | 187 | |
| 108 | 188 | /** |
| 109 | 189 | * Get the template map |
| @@ -131,9 +211,9 @@ | ||
| 131 | 211 | |
| 132 | 212 | /** |
| 133 | 213 | * Get template class by template ID |
| 134 | 214 | * |
| 135 | - * @param string $templateId | |
| 215 | + * @param string $templateId | |
| 136 | 216 | * @return string|null Template class name or null if not found |
| 137 | 217 | */ |
| 138 | 218 | public static function getTemplateClass(string $templateId): ?string |
| 139 | 219 | { |
| @@ -142,9 +222,9 @@ | ||
| 142 | 222 | |
| 143 | 223 | /** |
| 144 | 224 | * Get template data by template ID |
| 145 | 225 | * |
| 146 | - * @param string $templateId | |
| 226 | + * @param string $templateId | |
| 147 | 227 | * @return array<string, mixed>|null Template data or null if not found |
| 148 | 228 | */ |
| 149 | 229 | public static function getTemplate(string $templateId): ?array |
| 150 | 230 | { |
| @@ -169,9 +249,9 @@ | ||
| 169 | 249 | |
| 170 | 250 | /** |
| 171 | 251 | * Check if template ID exists |
| 172 | 252 | * |
| 173 | - * @param string $templateId | |
| 253 | + * @param string $templateId | |
| 174 | 254 | * @return bool |
| 175 | 255 | */ |
| 176 | 256 | public static function hasTemplate(string $templateId): bool |
| 177 | 257 | { |
| @@ -178,13 +258,17 @@ | ||
| 178 | 258 | return self::getTemplateClass($templateId) !== null; |
| 179 | 259 | } |
| 180 | 260 | |
| 181 | 261 | /** |
| 182 | - * Get all templates as associative array | |
| 262 | + * Get all templates metadata (without form_data) for listing purposes | |
| 183 | 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 | + * | |
| 184 | 268 | * @return array<string, array<string, mixed>> |
| 185 | 269 | */ |
| 186 | - public static function getAllTemplates(): array | |
| 270 | + public static function getAllTemplateMetas(): array | |
| 187 | 271 | { |
| 188 | 272 | $templates = []; |
| 189 | 273 | |
| 190 | 274 | foreach ((new TemplateMapper())->getTemplateMap() as $templateId => $templateClass) { |
| @@ -192,11 +276,10 @@ | ||
| 192 | 276 | if ($templateClass === BlankFormTemplate::class) { |
| 193 | 277 | continue; |
| 194 | 278 | } |
| 195 | 279 | |
| 196 | - if (class_exists($templateClass)) { | |
| 197 | - $templateData = $templateClass::getTemplate(); | |
| 198 | - $templates[$templateId] = $templateData; | |
| 280 | + if (class_exists($templateClass) && method_exists($templateClass, 'getTemplateMeta')) { | |
| 281 | + $templates[$templateId] = $templateClass::getTemplateMeta(); | |
| 199 | 282 | } |
| 200 | 283 | } |
| 201 | 284 | |
| 202 | 285 | return $templates; |