/**
  * @param block_BlockContext $context
  * @param block_BlockRequest $request
  * @return String the view name
  */
 public function execute($context, $request)
 {
     if (!$request->hasNonEmptyParameter('id')) {
         return block_BlockView::NONE;
     }
     $id = $request->getParameter('id');
     $form = DocumentHelper::getDocumentInstance($id);
     $user = $context->getGlobalContext()->getUser();
     $attr = 'form_success_parameters_' . $form->getId();
     $parameters = $user->getAttribute($attr);
     if ($parameters === null) {
         return block_BlockView::NONE;
     }
     $user->removeAttribute($attr);
     $message = $form->getConfirmMessage();
     foreach ($parameters as $k => $v) {
         $message = str_replace('{' . $k . '}', htmlspecialchars($v), $message);
     }
     $this->setParameter('message', $message);
     if ($form->getUseBackLink()) {
         $this->setParameter('back', array('url' => $parameters[form_FormConstants::BACK_URL_PARAMETER], 'label' => f_Locale::translate('&modules.form.frontoffice.Back;')));
     } else {
         $this->setParameter('back', false);
     }
     $this->setParameter('form', $form);
     return block_BlockView::SUCCESS;
 }
 /**
  * @param block_BlockContext $context
  * @param block_BlockRequest $request
  */
 public function execute($context, $request)
 {
     $form = $this->getParameter('form');
     $confirmpage = $form->getConfirmpage();
     if ($confirmpage instanceof website_persistentdocument_page && $confirmpage->isPublished()) {
         HttpController::getInstance()->redirectToUrl(LinkHelper::getUrl($confirmpage, $context->getLang(), array('formParam[id]' => $form->getId())));
     }
     $this->setTemplateName('Form-Success');
     $user = $context->getGlobalContext()->getUser();
     $attr = 'form_success_parameters_' . $form->getId();
     $parameters = $user->getAttribute($attr);
     $user->removeAttribute($attr);
     $message = $form->getConfirmMessage();
     foreach ($parameters as $k => $v) {
         $message = str_replace('{' . $k . '}', htmlspecialchars($v), $message);
     }
     $this->setAttribute("receiverLabels", $this->getParameter("receiverLabels"));
     $this->setAttribute('message', $message);
     if ($form->getUseBackLink()) {
         $this->setAttribute('back', array('url' => $parameters[form_FormConstants::BACK_URL_PARAMETER], 'label' => f_Locale::translate('&modules.form.frontoffice.Back;')));
     } else {
         $this->setAttribute('back', false);
     }
     $this->setAttribute('form', $form);
 }
 /**
  * @param form_persistentdocument_mail $document
  * @param Integer $parentNodeId Parent node ID where to save the document (optionnal => can be null !).
  * @throws form_ReplyToFieldAlreadyExistsException
  * @return void
  */
 protected function preSave($document, $parentNodeId = null)
 {
     if ($document->getMultiline()) {
         $document->setValidators('emails:true');
     } else {
         $document->setValidators('email:true');
     }
     if ($parentNodeId !== NULL) {
         $form = DocumentHelper::getDocumentInstance($parentNodeId);
     } else {
         $form = $this->getFormOf($document);
     }
     if ($form === null) {
         if (Framework::isWarnEnabled()) {
             Framework::warn(__METHOD__ . ' the mail field document (' . $document->__toString() . ')is not in a form');
         }
     } else {
         if ($document->getUseAsReply()) {
             $oldReplyField = form_BaseFormService::getInstance()->getReplyToField($form);
             if ($oldReplyField !== null && $oldReplyField !== $document) {
                 Framework::error(__METHOD__ . ' Old reply field :' . $oldReplyField->__toString());
                 throw new form_ReplyToFieldAlreadyExistsException(f_Locale::translate('&modules.form.bo.errors.Mail-field-for-replyto-exists'));
             }
         }
     }
     parent::preSave($document, $parentNodeId);
 }
 /**
  * @param form_persistentdocument_date $field
  * @param DOMElement $fieldElm
  * @param mixed $rawValue
  * @return string
  */
 public function buildXmlElementResponse($field, $fieldElm, $rawValue)
 {
     $txtValue = parent::buildXmlElementResponse($field, $fieldElm, $rawValue);
     if (!empty($txtValue)) {
         $txtValue = date_Calendar::getInstanceFromFormat($txtValue, f_Locale::translate('&framework.date.date.default-date-format;'))->toString();
     }
     return $txtValue;
 }
 /**
  * @param string $moduleName
  * @param string $treeType
  * @param array<string, string> $nodeAttributes
  */
 protected function addTreeAttributes($moduleName, $treeType, &$nodeAttributes)
 {
     parent::addTreeAttributes($moduleName, $treeType, $nodeAttributes);
     if ($this->getMultiple()) {
         $nodeAttributes['fieldType'] = f_Locale::translate('&modules.form.bo.general.field.Recipient-multiple-selection-list;');
     } else {
         $nodeAttributes['fieldType'] = f_Locale::translate('&modules.form.bo.general.field.Recipient-single-selection-list;');
     }
 }
 /**
  * @param string $moduleName
  * @param string $treeType
  * @param array<string, string> $nodeAttributes
  */
 protected function addTreeAttributes($moduleName, $treeType, &$nodeAttributes)
 {
     if ($this->hasCondition()) {
         $nodeAttributes['conditioned'] = 'conditioned';
         $activationLabel = FormHelper::getActivationLabel($this->getId());
         $activationQuestionLabel = $this->getActivationquestion()->getLabel();
         $nodeAttributes['fieldConditioned'] = f_Locale::translate('&modules.form.bo.general.Activation;', array('value' => $activationLabel, 'question' => $activationQuestionLabel));
     }
 }
Esempio n. 7
0
 /**
  * @param string $moduleName
  * @param string $treeType
  * @param array<string, string> $nodeAttributes
  */
 protected function addTreeAttributes($moduleName, $treeType, &$nodeAttributes)
 {
     parent::addTreeAttributes($moduleName, $treeType, $nodeAttributes);
     if ($this->getMultiline()) {
         $nodeAttributes['fieldType'] = f_Locale::translate('&modules.form.bo.general.field.Multiline-text;');
     } else {
         $nodeAttributes['fieldType'] = f_Locale::translate('&modules.form.bo.general.field.Text;');
     }
 }
 public function _execute($context, $request)
 {
     $form = $request->getAttribute('form');
     $this->setAttribute('form', $form);
     $domDoc = new DOMDocument();
     $fieldNames = array('creationdate' => f_Locale::translate('&modules.form.bo.actions.SendDate;'));
     $query = f_persistentdocument_PersistentProvider::getInstance()->createQuery('modules_form/response')->add(Restrictions::eq('parentForm.id', $form->getId()))->addOrder(Order::desc('document_creationdate'));
     if ($request->getAttribute('all') != 'all') {
         $query->add(Restrictions::published());
     }
     $responses = $query->find();
     $responsesAttribute = array();
     foreach ($responses as $response) {
         $domDoc->loadXML($response->getContents());
         $xpath = new DOMXPath($domDoc);
         $fieldList = $xpath->query('/response/field');
         $fields = array('creationdate' => $response->getUICreationdate());
         for ($i = 0; $i < $fieldList->length; $i++) {
             $fieldNode = $fieldList->item($i);
             $fieldName = $fieldNode->getAttribute('name');
             $fieldLabel = $fieldNode->getAttribute('label');
             $fieldType = $fieldNode->getAttribute('type');
             $fieldValue = $fieldNode->nodeValue;
             if ($fieldType == 'file') {
                 $fieldValue = intval($fieldNode->nodeValue);
                 if ($fieldValue > 0) {
                     $fieldValue = MediaHelper::getUrl($fieldValue);
                 } else {
                     $fieldValue = '';
                 }
             } else {
                 if ($fieldType == 'list' && $fieldNode->hasAttribute('mailValue')) {
                     $fieldValue = $fieldNode->getAttribute('mailValue');
                 }
             }
             if (!isset($fieldNames[$fieldName])) {
                 $fieldNames[$fieldName] = $fieldLabel;
             }
             $fields[$fieldName] = $fieldValue;
         }
         $responsesAttribute[] = $fields;
     }
     $fileName = "export_formulaire_" . f_util_FileUtils::cleanFilename($form->getLabel()) . '_' . date('Ymd_His') . '.csv';
     $options = new f_util_CSVUtils_export_options();
     $options->separator = ";";
     $csv = f_util_CSVUtils::export($fieldNames, $responsesAttribute, $options);
     header("Content-type: text/comma-separated-values");
     header('Content-length: ' . strlen($csv));
     header('Content-disposition: attachment; filename="' . $fileName . '"');
     echo $csv;
     exit;
 }
 /**
  * @return array
  */
 public function getItems()
 {
     $items = array();
     $pathWhereToFindMarkupsArray = FileResolver::getInstance()->setPackageName('modules_form')->setDirectory('templates/markup')->getPaths('');
     foreach ($pathWhereToFindMarkupsArray as $pathWhereToFindMarkups) {
         $dir = dir($pathWhereToFindMarkups);
         while ($entry = $dir->read()) {
             if ($entry[0] != '.' && is_dir($pathWhereToFindMarkups . DIRECTORY_SEPARATOR . $entry)) {
                 $items[] = new list_Item(f_Locale::translateUI('&modules.form.bo.markup.' . $entry . ';'), $entry);
             }
         }
     }
     return $items;
 }
 /**
  * @param form_persistentdocument_file $field
  * @param block_BlockRequest $request
  * @param validation_Errors $errors
  * @return void
  */
 public function validate($field, $request, &$errors)
 {
     $fileInfo = $request->getUploadedFileInformation($field->getFieldName());
     $errCount = $errors->count();
     if ($field->getRequired() || !empty($fileInfo['name'])) {
         if ($field->getRequired()) {
             validation_ValidatorHelper::validate(new validation_Property($field->getLabel(), $fileInfo['name']), 'blank:false', $errors);
         }
         if ($errors->count() == $errCount) {
             $ext = strtolower(f_util_FileUtils::getFileExtension($fileInfo['name']));
             if ($field->getAllowedExtensions()) {
                 $allowedExt = explode(",", $field->getAllowedExtensions());
                 if (!empty($allowedExt) && !in_array($ext, $allowedExt)) {
                     $errors->append(f_Locale::translate('&modules.form.frontoffice.File-must-have-one-of-these-extensions;', array('file' => $field->getLabel(), 'extensions' => join(", ", $allowedExt))));
                 }
             }
         }
     }
 }
Esempio n. 11
0
 /**
  * @return String
  */
 public function getValidators()
 {
     $format = f_Locale::translate("&modules.form.document.date.validator.format;");
     if ('format' == $format) {
         return form_DateService::DEFAULT_VALIDATORS;
     }
     $validators = array('date:' . $format);
     if ($this->getStartDate()) {
         $validators[] = substr($this->getUIStartDate(), 0, 10);
     } else {
         $validators[] = '';
     }
     if ($this->getEndDate()) {
         $validators[] = substr($this->getUIEndDate(), 0, 10);
     } else {
         $validators[] = '';
     }
     return implode('|', $validators);
 }
Esempio n. 12
0
 /**
  * @param string $moduleName
  * @param string $treeType
  * @param array<string, string> $nodeAttributes
  */
 protected function addTreeAttributes($moduleName, $treeType, &$nodeAttributes)
 {
     if ($this->getIsLocked()) {
         $nodeAttributes['isLocked'] = 'isLocked';
     }
     if ($treeType == 'wlist') {
         $modelName = $this->getDocumentModelName();
         $nodeAttributes['fieldType'] = f_Locale::translate('&modules.form.bo.general.field.' . ucfirst(substr($modelName, strpos($modelName, '/') + 1)) . ';');
         if ($this->getRequired()) {
             $nodeAttributes['required'] = 'required';
             $nodeAttributes['fieldRequired'] = f_Locale::translate('&modules.uixul.bo.general.Yes;');
         }
         if ($this->hasCondition()) {
             $nodeAttributes['conditioned'] = 'conditioned';
             $activationLabel = FormHelper::getActivationLabel($this->getId());
             $activationQuestionLabel = $this->getActivationquestion()->getLabel();
             $nodeAttributes['fieldConditioned'] = f_Locale::translate('&modules.form.bo.general.Activation;', array('value' => $activationLabel, 'question' => $activationQuestionLabel));
         }
     }
 }
 /**
  * @see f_persistentdocument_PersistentDocumentImpl::getLabel()
  *
  * @return String
  */
 public function getLabel()
 {
     return f_Locale::translateUI(parent::getLabel());
 }
Esempio n. 14
0
 /**
  * @param string $moduleName
  * @param string $treeType
  * @param array<string, string> $nodeAttributes
  */
 protected function addTreeAttributes($moduleName, $treeType, &$nodeAttributes)
 {
     parent::addTreeAttributes($moduleName, $treeType, $nodeAttributes);
     $nodeAttributes['fieldType'] = f_Locale::translate('&modules.form.bo.general.field.Mail;');
 }
 /**
  * Return the localized value for a rootfolder
  * @return string
  */
 public function getLabel()
 {
     return f_Locale::translateUI('&modules.form.document.recipientgroupfolder.Document-name;');
 }
 /**
  * @param form_persistentdocument_list $field
  * @param string $value
  * @return string
  */
 private static function fromListFieldDocument($field, $value)
 {
     // build required attributes
     $attributes = array();
     $attributes['value'] = $value;
     $attributes['title'] = $field->getHelpText();
     // build items
     $listObject = $field->getDataSource();
     $items = array();
     if (!is_null($listObject)) {
         $itemObjects = $listObject->getItems();
         foreach ($itemObjects as $name => $itemObject) {
             $name = $itemObject->getValue();
             $items[$name] = $itemObject->getLabel();
         }
     }
     if ($field->getMultiple()) {
         if ($field->getDisplay() == self::DISPLAY_BUTTONS) {
             return self::listField($field->getFieldName(), $field->getId(), $value, $items, self::SELECTION_MULTIPLE_CHECKBOX, $attributes);
         } else {
             if ($field->getHasBlankOption()) {
                 $items = array_reverse($items, true);
                 $items[''] = f_Locale::translate("&modules.form.frontoffice.list.BlankOption;");
                 $items = array_reverse($items, true);
             }
             return self::listBox($field->getFieldName(), $field->getId(), $value, $items, $attributes);
         }
     } else {
         if ($field->getDisplay() == self::DISPLAY_BUTTONS) {
             return self::listField($field->getFieldName(), $field->getId(), $value, $items, self::SELECTION_SINGLE_RADIO, $attributes);
         } else {
             if ($field->getHasBlankOption()) {
                 $items = array_reverse($items, true);
                 $items[''] = f_Locale::translate("&modules.form.frontoffice.list.BlankOption;");
                 $items = array_reverse($items, true);
             }
             return self::comboBox($field->getFieldName(), $field->getId(), $value, $items, $attributes);
         }
     }
 }
 /**
  * @param notification_persistentdocument_notification $oldNotification
  * @param notification_persistentdocument_notification $newNotification
  */
 protected function duplicateNotificationInfo($oldNotification, $newNotification)
 {
     $requestContext = RequestContext::getInstance();
     foreach ($requestContext->getSupportedLanguages() as $lang) {
         try {
             $requestContext->beginI18nWork($lang);
             if ($newNotification->isContextLangAvailable()) {
                 if ($oldNotification->getLabel() != $oldNotification->getSubject()) {
                     $newNotification->setSubject(f_Locale::translate('&modules.generic.backoffice.Duplicate-prefix;') . ' ' . $oldNotification->getSubject());
                 }
                 $newNotification->setBody($oldNotification->getBody());
                 $newNotification->setHeader($oldNotification->getHeader());
                 $newNotification->setFooter($oldNotification->getFooter());
                 $newNotification->setFooter($oldNotification->getFooter());
                 $newNotification->setTemplate($oldNotification->getTemplate());
                 $newNotification->setSenderEmail($oldNotification->getSenderEmail());
             }
             $requestContext->endI18nWork();
         } catch (Exception $e) {
             $requestContext->endI18nWork($e);
         }
     }
 }
 /**
  * @param f_persistentdocument_PersistentDocument $document
  * @param string $forModuleName
  * @param array $allowedSections
  * @return array
  */
 public function getResume($document, $forModuleName, $allowedSections = null)
 {
     $resume = parent::getResume($document, $forModuleName, $allowedSections);
     $openNotificationUri = join(',', array('notification', 'openDocument', 'modules_notification_notification', $document->getNotification()->getId(), 'properties'));
     $backUri = join(',', array('form', 'openDocument', 'modules_form_form', $document->getId(), 'resume'));
     $resume["properties"]["notification"] = array("uri" => $openNotificationUri, "label" => f_Locale::translateUI("&modules.uixul.bo.doceditor.open;"), "backuri" => $backUri);
     return $resume;
 }
 /**
  * @param form_persistentdocument_form $form
  * @param f_mvc_Request $request
  * @return String
  */
 protected function getSuccessView($form, $request)
 {
     $confirmpage = $form->getConfirmpage();
     if ($confirmpage instanceof website_persistentdocument_page && $confirmpage->isPublished()) {
         HttpController::getInstance()->redirectToUrl(LinkHelper::getDocumentUrl($confirmpage, $this->getLang(), array('formParam[id]' => $form->getId())));
         return website_BlockView::NONE;
     }
     $user = $this->getContext()->getGlobalContext()->getUser();
     $attr = 'form_success_parameters_' . $form->getId();
     $parameters = $user->getAttribute($attr);
     $user->removeAttribute($attr);
     $message = $form->getConfirmMessage();
     foreach ($parameters as $key => $value) {
         $message = str_replace('{' . $key . '}', htmlspecialchars($value), $message);
     }
     $request->setAttribute('message', $message);
     if ($form->getUseBackLink()) {
         $request->setAttribute('back', array('url' => $parameters['backUrl'], 'label' => f_Locale::translate('&modules.form.frontoffice.Back;')));
     } else {
         $request->setAttribute('back', false);
     }
     return $this->getSuccessTemplateByFullName($form);
 }
Esempio n. 20
0
 public function renderInput($attributes)
 {
     $code = '<input type="text" class="textfield" name="formParam[' . CAPTCHA_SESSION_KEY . ']"';
     if (isset($attributes['name'])) {
         unset($attributes['name']);
     }
     if (!isset($attributes['maxlength'])) {
         $attributes['maxlength'] = '7';
     }
     if (!isset($attributes['size'])) {
         $attributes['size'] = '7';
     }
     if (!isset($attributes['title'])) {
         $attributes['title'] = f_Locale::translate("&modules.form.bo.general.Captcha-help;");
     }
     $attributes['id'] = CAPTCHA_SESSION_KEY;
     foreach ($attributes as $name => $value) {
         $code .= ' ' . $name . '="' . str_replace('"', '\\"', $value) . '"';
     }
     return $code . '/>';
 }
 /**
  * Moves $field into the destination node identified by $destId.
  * @param form_persistentdocument_field $field The field to move.
  * @param integer $destId ID of the destination node.
  * @param integer $beforeId
  * @param integer $afterId
  */
 public function moveTo($field, $destId, $beforeId = null, $afterId = null)
 {
     $fbs = form_BaseformService::getInstance();
     $fieldForm = $fbs->getAncestorFormByDocument($field);
     $destDocument = DocumentHelper::getDocumentInstance($destId);
     if ($destDocument instanceof form_persistentdocument_baseform) {
         $destForm = $destDocument;
     } else {
         $destForm = $fbs->getAncestorFormByDocument($destDocument);
     }
     if (!DocumentHelper::isEquals($destForm, $fieldForm)) {
         throw new form_FormException(f_Locale::translate('&modules.form.bo.errors.Cannot-move-a-field-from-a-form-to-another-form;'));
     }
     return parent::moveTo($field, $destId, $beforeId, $afterId);
 }