LibraryManager = new LibraryManager($Loader); $this->StatusList = array(); $this->Loader = $Loader; $this->EditOptions = new stdClass(); $this->EditOptions->AllowEdition = true; } public function SetAllowEdition($allowEdition) { $this->EditOptions->AllowEdition = $allowEdition; } public function SetAllowStatusEdition() { $settingsRepository = new SettingsRepository($this->Loader); $this->VarData['StatusList'] = $settingsRepository->GetFormStatusList(); $this->EditOptions->AllowStatusEdition = true; } public function SetEditNonce($editNonce) { $this->EditOptions->EditNonce = $editNonce; } public function LoadForm($options) { require_once $this->Loader->DIR . 'core/Managers/FormLoader/ServerDependencyHooks.php'; $this->Options = $options; $this->FormId = $options->Id; if(isset($this->Options->FormBuilder->ExtensionsUsed)) { foreach($this->Options->FormBuilder->ExtensionsUsed as $extension) { self::$Dependencies = \apply_filters('rednao-calculated-field-get-extension-runnable-' . $extension, self::$Dependencies); } } $this->Id = \uniqid(); $settingsRepository = new SettingsRepository($this->Loader); $userIntegration = new UserIntegration($this->Loader); $options = array( 'FormId' => $this->Options->Id, 'SubmitNonce' => wp_create_nonce('rnsusbmit_form_' . $this->Options->Id), 'FormContainerId' => $this->Id, 'Options' => $this->Options->FormBuilder, "URL" => $this->Loader->URL, 'Currency' => $this->GetCurrency(), 'ajaxurl' => IntegrationURL::AjaxURL(), 'PreviousData' => null, 'GoogleMapsApiKey' => $settingsRepository->GetGoogleMapsApiKey(), 'Recaptcha' => $settingsRepository->GetRecaptchaPublicSettings(), 'EditOptions' => $this->EditOptions, 'UserRoles' => $userIntegration->GetCurrentUserRoles(), 'Extra' => [], 'AdditionalStyles' => '' ); if(count($this->Options->ServerOptions->ServerDependencies) > 0) { foreach($this->Options->ServerOptions->ServerDependencies as $currentDependency) { $options = apply_filters('allinoneforms_get_server_dependency_' . $currentDependency->Type, $options, $currentDependency); } $options['Attributes'] = $this->GetAttributes(); }else $options['Attributes'] = []; $this->VarData = $options; $this->MaybeIncludeUserInfo(); $this->MaybeAddAdditionalOptions(); } public function GetCurrency() { if(self::$Currency == null) { $settingsRepository = new SettingsRepository($this->Loader); self::$Currency = $settingsRepository->GetCurrency(); } return self::$Currency; } /** * @return FormBuilderOptionsDTO */ public function GetOptions() { return $this->Options->FormBuilder; } public function GetClientExtensionById($id) { $options = $this->GetOptions(); foreach ($options->ClientOptions->Extensions as $extension) { if($extension->Id == $id) return $extension; } return null; } public function GetServerExtensionById($id) { if(!isset($this->Options->ServerOptions)) return null; foreach ($this->Options->ServerOptions->Extensions as $extension) { if($extension->Id == $id) return $extension; } return null; } public function Load() { $this->LibraryManager->AddCoreUI(); $this->LibraryManager->AddFormBuilderCore(); $this->LibraryManager->AddSpinner(); if(!$this->IsPreview && $this->Options->ServerOptions != null) { $errorMessage = $this->ValidateRestrictions($this->Options->ServerOptions); if($errorMessage != '') { echo "
$errorMessage
"; return false; } } $options = $this->GetOptions(); if(isset($options->ClientOptions) && $options->ClientOptions->MultipleSteps != null) { $this->Loader->AddScript('MultipleSteps', 'js/dist/RNMainRunnableMultipleSteps_bundle.js', array('@FormBuilderCore')); $this->Loader->AddStyle('MultipleSteps', 'js/dist/RNMainRunnableMultipleSteps_bundle.css'); self::$Dependencies[] = '@MultipleSteps'; } if(isset($options->ClientOptions->MultipleSteps->IncludeStepImage) && $options->ClientOptions->MultipleSteps->IncludeStepImage) { do_action('rness_multiple_steps_include_step_image'); } if(Sanitizer::GetValueFromPath($options->ClientOptions, ['Theme']) != '') { $this->Loader->AddStyle('theme_' . $options->ClientOptions->Theme, 'styles/themes/' . $options->ClientOptions->Theme . '.css'); } self::$Translations = []; if(isset($options->Dependencies)) { foreach ($options->Dependencies as $currentDynamicField) { $field = FieldsDictionary::GetFieldByName($currentDynamicField); if($field == null) { $loaded = false; $loaded = apply_filters('allinoneforms_load_dependency', $loaded, $currentDynamicField, $this); if($loaded) continue; } if($currentDynamicField == 'DatePickerField' || $currentDynamicField == 'DateRangeField') { $this->LibraryManager->AddDate(); $this->VarData['TCal'] = $this->LibraryManager->GetCalendarTranslations(); } if($currentDynamicField == 'TermOfServiceField') { $this->LibraryManager->AddDialog(); } if($currentDynamicField == 'TooltipLib') { $this->LibraryManager->AddTooltip(); continue; } self::$Dependencies[] = '@' . $currentDynamicField; $this->Loader->AddScript($currentDynamicField, 'js/dist/RNMain' . $currentDynamicField . '_bundle.js', array('@FormBuilderCore')); if ($field != null && $field->HasStyles) $this->Loader->AddStyle($currentDynamicField, 'js/dist/RNMain' . $currentDynamicField . '_bundle.css'); if($field != null && isset($field->HasTranslations) && $field->HasTranslations) self::$Translations[] = $field->Name; } } $additionalStyles = ''; $fontManager = new FontManager(); if(isset($this->Options->ServerOptions)) { foreach ($this->Options->ServerOptions->ServerDependencies as $currentDependency) { if($currentDependency->Type == 'Font') { $additionalStyles .= $fontManager->GetFontFace($currentDependency->Id); } } } $codeToReturn = ''; if($additionalStyles != '') { $codeToReturn = ''; } $this->VarData = \apply_filters('rednao-calculated-field-load-vars', $this->VarData); $this->Loader->AddRNTranslator(self::$Translations); $this->Loader->RemoveScript('runnable-form-builder'); self::$Dependencies = \apply_filters('allinoneforms_loading_runnable_addons', self::$Dependencies, $this); $this->Loader->AddScript('runnable-form-builder', 'js/dist/RNMainRunnableForm_bundle.js', \array_merge(self::$Dependencies, $this->LibraryManager->dependencies)); $this->Loader->LocalizeScript('FormOptions_' . $this->Id, 'FormBuilderCore', 'Submission', $this->VarData); return $codeToReturn . '
'; } private function MaybeAddAdditionalOptions() { /* $options=$this->GetOptions(); if(isset($options->ClientOptions->ConfirmationOptions->ConfirmationItem)&&\is_array($options->ClientOptions->ConfirmationOptions->ConfirmationItem)&&count($options->ClientOptions->ConfirmationOptions->ConfirmationItem)>0) { foreach($options->ClientOptions->ConfirmationOptions->ConfirmationItem as $item) { if($item->ConfirmationType=='page') { $pageIntegration=new PageIntegration($this->Loader); if(isset($item->PageId)&&$item->PageId!=''&&$item->PageId>0) { try { $url = $pageIntegration->GetPageURLById($item->PageId); if(!isset($this->VarData['Pages'])) $this->VarData['Pages']=array(); if(!ArrayUtils::Some($this->VarData['Pages'],function ($item){return $item["Id"]==$item->PageId;})) { $this->VarData['Pages'][]=array("Id"=>$item->PageId,"URL"=>$url); } } catch (Exception $e) { LogManager::Log(LogManager::TYPE_ERROR,"Page with id {$item->PageId} was not found, redirection to that page is not possible"); } } } } }*/ } public function SetAsQuickPreview($nonce) { $this->IsPreview = true; $previewUrl = IntegrationURL::PreviewURL(); $previewItem = ''; if($this->Options->Id > 0) { $previewUrl .= '&formid=' . $this->Options->Id; $previewUrl .= '&_nonce=' . $nonce; $previewItem = "
  • " . \esc_html("Use this link") . "
  • "; } $this->VarData['FormDesignNonce'] = wp_create_nonce('rndesign_form_' . $this->FormId); $this->VarData['QuickPreviewNonce'] = $nonce; $this->VarData['QuickPreview'] = true; $this->VarData['QuickPreviewTitle'] = "Submission is not supported in quick preview"; $this->VarData['QuickPreviewMessage'] = "

    " . \esc_html(__("To submit a form please do one of the following:")) . "

    " . "