Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function send(array $data, array $attachFiles = array())
 {
     $eventName = $this->parameters->get('EVENT_NAME');
     $eventTemplate = is_numeric($this->parameters->get('EVENT_TEMPLATE')) ? $this->parameters->get('EVENT_TEMPLATE') : '';
     $eventType = $this->eventType->getList(array('EVENT_NAME' => $eventName))->getNext();
     if ($eventName && !is_array($eventType)) {
         return false;
     }
     if ($this->parameters->get('EVENT_TYPE') == 'IMMEDIATE') {
         return $this->sendImmediate($eventName, $eventTemplate, $data, $attachFiles);
     }
     return $this->sendDefault($eventName, $eventTemplate, $data, $attachFiles);
 }
Beispiel #2
0
 /**
  * @return Form
  */
 public function create()
 {
     if (!in_array($this->params->get('TYPE'), array('IBLOCK', 'HLBLOCK', 'CUSTOM'))) {
         $this->params->set('TYPE', 'CUSTOM');
     }
     switch ($this->params->get('TYPE')) {
         case 'IBLOCK':
             $builder = 'Citfact\\Form\\Builder\\IBlockBuilder';
             $storage = 'Citfact\\Form\\Storage\\IBlockStorage';
             $validator = 'Citfact\\Form\\Validator\\IBlockValidator';
             break;
         case 'HLBLOCK':
             $builder = 'Citfact\\Form\\Builder\\UserFieldBuilder';
             $storage = 'Citfact\\Form\\Storage\\HighLoadBlockStorage';
             $validator = 'Citfact\\Form\\Validator\\UserFieldValidator';
             break;
         case 'CUSTOM':
             $builder = $this->params->get('BUILDER') ?: Config\Option::get('citfact.form', 'BUILDER');
             $storage = $this->params->get('STORAGE') ?: Config\Option::get('citfact.form', 'STORAGE');
             $validator = $this->params->get('VALIDATOR') ?: Config\Option::get('citfact.form', 'VALIDATOR');
             break;
     }
     $mailer = new Mailer($this->params, new \CEventType(), new \CEvent());
     $form = new Form($this->params, new $builder(), new $validator(), new $storage());
     $form->setMailer($mailer);
     return $form;
 }
 /**
  * @inheritdoc
  */
 public function create(ParameterDictionary $parameters)
 {
     $highLoadBlockId = (int) $parameters->get('ID');
     $highLoadBlock = HL\HighloadBlockTable::getById($highLoadBlockId)->fetch();
     if (empty($highLoadBlock)) {
         throw new BuilderException(sprintf('Not found highloadblock with id = %d', $highLoadBlockId));
     }
     $highLoadBlockFields = $this->getUserFieldManager()->GetUserFields(sprintf('HLBLOCK_%d', $highLoadBlockId), 0, LANGUAGE_ID);
     $this->setHighLoadBlockFields($highLoadBlockFields);
     $this->setElementValue();
     $this->setSectionValue();
     $this->setEnumValue();
     return array('DATA' => $highLoadBlock, 'FIELDS' => $this->getHighLoadBlockFields());
 }
Beispiel #4
0
 /**
  * @inheritdoc
  */
 public function create(ParameterDictionary $parameters)
 {
     $iblockId = (int) $parameters->get('ID');
     $queryBuilder = new Entity\Query(Iblock\IblockTable::getEntity());
     $iblockData = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('ID' => $iblockId))->setOrder(array())->exec()->fetch();
     if (empty($iblockData)) {
         throw new BuilderException(sprintf('Not found iblock with id = %d', $iblockId));
     }
     // Get settings iblock
     $iblockDataFields = \CIBlock::GetArrayByID($iblockData['ID']);
     $queryBuilder = new Entity\Query(Iblock\PropertyTable::getEntity());
     $propertyResult = $queryBuilder->setSelect(array('*'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec();
     $propertyList = array();
     while ($property = $propertyResult->fetch()) {
         if (!empty($property['USER_TYPE_SETTINGS'])) {
             $property['USER_TYPE_SETTINGS'] = ($unserialize = @unserialize($property['USER_TYPE_SETTINGS'])) === false ? $property['USER_TYPE_SETTINGS'] : $unserialize;
         }
         $propertyList[$property['CODE']] = $property;
     }
     $this->iblockProperty = $propertyList;
     $this->setElementValue();
     $this->setSectionValue();
     $this->setEnumValue();
     $sectionValueList = array();
     if (in_array($iblockData['ID'], $this->getListByType('G'))) {
         foreach ($this->iblockProperty as $field) {
             if ($field['PROPERTY_TYPE'] == 'G' && $field['LINK_IBLOCK_ID'] == $iblockData['ID']) {
                 $sectionValueList = isset($field['VALUE_LIST']) ? $field['VALUE_LIST'] : array();
                 break;
             }
         }
     } else {
         $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
         $sectionValueList = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec()->fetchAll();
     }
     $upperLevel[] = array('ID' => 0, 'NAME' => GetMessage('IBLOCK_UPPER_LEVEL'));
     $sectionValueList = $upperLevel + $sectionValueList;
     return array('DATA' => $iblockData, 'DEFAULT_FIELDS' => $this->getDefaultFields($iblockDataFields, $sectionValueList), 'FIELDS' => $this->iblockProperty);
 }
Beispiel #5
0
$form->setBuilderData($arResult['BUILDER_DATA']);
$form->handleRequest($app->getContext()->getRequest());
if ($form->isValid()) {
    $form->save();
    // If the data is successfully preserved produce redirect
    if ($params->get('AJAX') != 'Y') {
        $redirectPath = $params->get('REDIRECT_PATH') ?: getenv('REQUEST_URI');
        LocalRedirect($redirectPath);
    }
}
$result->set('BUILDER', $form->getBuilderData());
$result->set('VIEW', $form->getViewData());
$result->set('SUCCESS', $form->isValid());
$result->set('ERRORS', $form->getErrors(false));
$result->set('CSRF', $form->getCsrfToken());
$result->set('CAPTCHA', $form->getCaptchaToken());
$result->set('FORM_NAME', $form->getFormName());
$result->set('IS_AJAX', getenv('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest');
if ($result->get('IS_AJAX') && $form->isSubmitted()) {
    $GLOBALS['APPLICATION']->restartBuffer();
    header('Content-Type: application/json');
    ob_start();
    $arResult = $result->toArray();
    $this->includeComponentTemplate();
    $bufferTemplate = ob_get_contents();
    ob_clean();
    $response = array('success' => $result->get('SUCCESS'), 'errors' => $result->get('ERRORS'), 'captcha' => $result->get('CAPTCHA'), 'html' => $bufferTemplate);
    exit(json_encode($response));
}
$arResult = $result->toArray();
$this->includeComponentTemplate();