26 $data[
'CONNECTOR'] =
'Bitrix\Iblock\SenderConnectorIblock';
32if (Main\Loader::includeModule(
'sender'))
34 class SenderConnectorIblock
extends \Bitrix\Sender\Connector
39 public function getName()
47 public function getCode()
55 public function requireConfigure()
61 public function getData()
63 $iblockId = $this->getFieldValue(
'IBLOCK',
null);
123 public function getForm()
128 $iblockList =
array();
130 'select' =>
array(
'ID',
'NAME'),
134 $iblockList[] = $iblock;
136 if(!
empty($iblockList))
151 $propertyList =
array();
152 $propertyList[
''][] =
array(
'ID' =>
'',
'NAME' =>
Loc::getMessage(
'sender_connector_iblock_select'));
153 $propertyList[
'EMPTY'][] =
array(
'ID' =>
'',
'NAME' =>
Loc::getMessage(
'sender_connector_iblock_prop_empty'));
155 'select' =>
array(
'ID',
'NAME',
'IBLOCK_ID'),
156 'filter' =>
array(
'=PROPERTY_TYPE' => PropertyTable::TYPE_STRING)
161 $propertyList[$iblockFields[
'IBLOCK_ID']][] =
array(
162 'ID' => $iblockFields[
'ID'],
163 'NAME' => $iblockFields[
'NAME']
171 $fieldList = static::getIblockFieldList();
177 foreach($iblockList
as $iblock)
184 if(!
isset($propertyList[$iblock[
'ID']]) || !
is_array($propertyList[$iblock[
'ID']]))
186 $propertyList[$iblock[
'ID']] =
array();
192 array(
array(
'ID' =>
'------',
'NAME' =>
'-----------------',
'DISABLED' =>
true)),
193 $propertyList[$iblock[
'ID']]
197 $propertyList[$iblock[
'ID']] =
array_merge($fieldList, $propertyList[$iblock[
'ID']]);
204 $iblockInput =
'<select name="'.$this->getFieldName(
'IBLOCK').
'" id="'.$this->getFieldId(
'IBLOCK').
'" onChange="IblockSelect'.$this->getFieldId(
'IBLOCK').
'()">';
205 foreach($iblockList
as $iblock)
207 $inputSelected = ($iblock[
'ID'] == $this->getFieldValue(
'IBLOCK') ?
'selected' :
'');
209 $iblockInput .= Main\Text\HtmlFilter::encode($iblock[
'NAME']);
218 $iblockPropertyNameInput =
'<select name="'.$this->getFieldName(
'PROPERTY_NAME').
'" id="'.$this->getFieldId(
'PROPERTY_NAME').
'">';
225 $propSet = $propertyList[$this->getFieldValue(
'IBLOCK')];
233 $inputSelected = $property[
'ID'] == $this->getFieldValue(
'PROPERTY_NAME') ?
'selected' :
'';
234 $inputDisabled = (
isset($property[
'DISABLED']) && $property[
'DISABLED']) ?
'disabled' :
'';
245 $iblockPropertyEmailInput =
'<select name="'.$this->getFieldName(
'PROPERTY_EMAIL').
'" id="'.$this->getFieldId(
'PROPERTY_EMAIL').
'">';
252 $propSet = $propertyList[$this->getFieldValue(
'IBLOCK')];
260 $inputSelected = ($property[
'ID'] == $this->getFieldValue(
'PROPERTY_EMAIL') ?
'selected' :
'');
261 $inputDisabled = (
isset($property[
'DISABLED']) && $property[
'DISABLED']) ?
'disabled' :
'';
271 function IblockSelect".$this->getFieldId(
'IBLOCK').
"()
273 var iblock = BX('".$this->getFieldId(
'IBLOCK').
"');
274 IblockPropertyAdd(iblock, BX('".$this->getFieldId(
'PROPERTY_NAME').
"'));
275 IblockPropertyAdd(iblock, BX('".$this->getFieldId(
'PROPERTY_EMAIL').
"'));
277 function IblockPropertyAdd(iblock, iblockProperty)
279 if(iblockProperty.length>0)
281 for (var j in iblockProperty.options)
283 iblockProperty.options.remove(j);
287 if(iblockProperties[iblock.value] && iblockProperties[iblock.value].length>0)
288 propList = iblockProperties[iblock.value];
290 propList = iblockProperties['EMPTY'];
291 for(var i in propList)
293 var optionName = propList[i]['NAME'];
294 var optionValue = propList[i]['ID'];
295 var optionDisabled = propList[i]['DISABLED'];
296 var newOption = new Option(optionName, optionValue);
299 newOption.disabled = true;
301 iblockProperty.options.add(newOption);
306 var iblockProperties = ".\CUtil::PhpToJSObject($propertyList).
";
313 '.Loc::getMessage(
'sender_connector_iblock_required_settings').
'
338 $entity = ElementTable::getEntity();
341 $field = $entity->getField($fieldCode);
344 'NAME' => $field->getTitle()
364 $fields = parent::Fetch();
367 $keysForUnset = array();
368 if ($this->senderConnectorFieldName)
370 if(isset($fields[$this->senderConnectorFieldName.
"_VALUE"]))
372 $fields[
'NAME'] = $fields[$this->senderConnectorFieldName.
"_VALUE"];
373 $keysForUnset[] = $this->senderConnectorFieldName.
"_VALUE";
374 $keysForUnset[] = $this->senderConnectorFieldName.
"_VALUE".
"_ID";
376 elseif(isset($fields[$this->senderConnectorFieldName]))
379 if($this->senderConnectorFieldName !=
'NAME')
384 if ($this->senderConnectorFieldEmail)
386 if(isset($fields[$this->senderConnectorFieldEmail.
"_VALUE"]))
388 $fields[
'EMAIL'] = $fields[$this->senderConnectorFieldEmail.
"_VALUE"];
389 $keysForUnset[] = $this->senderConnectorFieldEmail.
"_VALUE";
390 $keysForUnset[] = $this->senderConnectorFieldEmail.
"_VALUE".
"_ID";
392 elseif(isset($fields[$this->senderConnectorFieldEmail]))
399 if (count($keysForUnset)>0)
401 $keysForUnset = array_unique($keysForUnset);
402 foreach($keysForUnset as $key) unset($fields[$key]);
$senderConnectorFieldName
$senderConnectorFieldEmail
static onConnectorListIblock($data)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)