/** * {@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); }
/** * @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()); }
/** * @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) { $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); }
* (c) Kulichkin Denis (onEXHovia) <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } use Bitrix\Main\Application; use Bitrix\Main\Loader; use Citfact\Form\FormFactory; use Citfact\Form\Type\ParameterDictionary; Loader::includeModule('citfact.form'); $app = Application::getInstance(); $params = new ParameterDictionary($arParams); $result = new ParameterDictionary(); $formFactory = new FormFactory($params); $form = $formFactory->create(); // Builder saves data to reduce the number of requests if ($this->startResultCache()) { $arResult['BUILDER_DATA'] = $form->createBuilderData()->getBuilderData(); $this->endResultCache(); } $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);