/**
  * @param form_persistentdocument_baseform $form
  * @param block_BlockRequest $formRequest
  * @param validation_Errors $errors
  * @param array<String> $scriptArray
  * @return String
  * @deprecated
  */
 public function renderForm($form, $formRequest, $errors, &$scriptArray)
 {
     $scriptArray[] = 'modules.form.lib.js.date-picker.date';
     $scriptArray[] = 'modules.form.lib.js.date-picker.date_' . RequestContext::getInstance()->getLang();
     $scriptArray[] = 'modules.form.lib.js.date-picker.jquery-bgiframe';
     $scriptArray[] = 'modules.form.lib.js.date-picker.jquery-dimensions';
     $scriptArray[] = 'modules.form.lib.js.date-picker.jquery-datePicker';
     $scriptArray[] = 'modules.form.lib.js.form';
     $markup = $form->getMarkup();
     if (!$markup) {
         $markup = 'default';
     }
     try {
         $template = TemplateLoader::getInstance()->setMimeContentType(K::HTML)->setPackageName('modules_form')->setDirectory('templates/markup/' . $markup)->load('Form');
         $template->setAttribute('form', $form);
         $template->setAttribute('selfUrl', $_SERVER['REQUEST_URI']);
         if ($formRequest->hasParameter(form_FormConstants::BACK_URL_PARAMETER)) {
             $template->setAttribute('backUrl', $formRequest->getParameter(form_FormConstants::BACK_URL_PARAMETER));
         } else {
             $template->setAttribute('backUrl', $_SERVER['HTTP_REFERER']);
         }
         if (!is_null($errors)) {
             $template->setAttribute('errors', $errors);
         }
         $fieldContents = array();
         $this->buildContentsFromRequest($form->getDocumentNode()->getChildren(), $fieldContents, $formRequest, $form);
         $template->setAttribute('requestParameters', $formRequest->getParameters());
         $template->setAttribute('elements', $fieldContents);
         return $template->execute(true);
     } catch (Exception $e) {
         Framework::exception($e);
     }
     return null;
 }
 /**
  * @param block_BlockContext $context
  * @param block_BlockRequest $request
  * @return String the view name
  */
 public function execute($context, $request)
 {
     $id = $this->getFormId();
     if (empty($id)) {
         return block_BlockView::NONE;
     }
     $form = DocumentHelper::getDocumentInstance($id);
     if (!$form->isPublished()) {
         return block_BlockView::NONE;
     }
     $form->getDocumentNode()->getDescendents();
     $this->setParameter('form', $form);
     if ($context->inBackofficeMode()) {
         return block_BlockView::DUMMY;
     }
     if ($request->hasParameter("receiverIds")) {
         $receiverIds = explode(",", $request->getParameter("receiverIds"));
         $receiverLabels = array();
         foreach ($receiverIds as $receiverId) {
             if (is_numeric($receiverId)) {
                 try {
                     $receiver = DocumentHelper::getDocumentInstance($receiverId);
                     $receiverLabels[] = $receiver->getLabel();
                 } catch (Exception $e) {
                     Framework::exception($e);
                     $receiverLabels[] = $receiverId;
                 }
             } elseif (f_util_StringUtils::isNotEmpty($receiverId)) {
                 $receiverLabels[] = $receiverId;
             }
         }
         $this->setParameter("receiverLabels", $receiverLabels);
     }
     if ($this->isSuccess($context, $request)) {
         $view = block_BlockView::SUCCESS;
     } else {
         if ($this->isFormPosted($request)) {
             $fs = form_FormService::getInstance();
             try {
                 $fs->saveFormData($form, $request);
                 $user = $context->getGlobalContext()->getUser();
                 $user->setAttribute('form_success_parameters_' . $form->getId(), $request->getParameters());
                 $view = block_BlockView::SUCCESS;
             } catch (form_FormValidationException $e) {
                 $this->setParameter('errors', $e->getErrorCollection());
                 $view = block_BlockView::INPUT;
             }
         } else {
             $view = block_BlockView::INPUT;
         }
     }
     // Calls the BlockFormDecorator if present.
     $formId = $form->getFormid();
     $matches = null;
     if (preg_match('#^modules_([a-z]+)/([a-z]+)$#', $formId, $matches)) {
         $extendClassName = $matches[1] . '_BlockForm' . ucfirst($matches[2]) . 'Decorator';
         if (f_util_ClassUtils::classExists($extendClassName)) {
             $instance = new $extendClassName($this);
             if ($instance instanceof form_BlockFormDecorator) {
                 $instance->execute($context, $request);
             } else {
                 Framework::warn("\"{$extendClassName}\" is not an instance of \"block_BlockDecorator\": form \"{$formId}\" won't be decorated.");
             }
         }
     }
     return $view;
 }