9namespace Bitrix\Iblock;
12 Bitrix\Main\Localization\Loc;
14Loc::loadMessages(__FILE__);
26 $data[
'CONNECTOR'] =
'Bitrix\Iblock\SenderConnectorIblock';
39 public function getName()
41 return Loc::getMessage(
'sender_connector_iblock_name');
47 public function getCode()
55 public function requireConfigure()
61 public function getData()
63 $iblockId = $this->getFieldValue(
'IBLOCK',
null);
64 $propertyNameId = $this->getFieldValue(
'PROPERTY_NAME',
null);
65 $propertyEmailId = $this->getFieldValue(
'PROPERTY_EMAIL',
null);
70 $propertyNameValue =
null;
71 $propertyEmailValue =
null;
74 if(is_numeric($propertyEmailId))
76 $propertyEmailId =
"PROPERTY_" . $propertyEmailId;
77 $propertyEmailValue = $propertyEmailId.
"_VALUE";
81 $propertyEmailValue = $propertyEmailId;
88 if(is_numeric($propertyNameId))
90 $propertyNameId =
"PROPERTY_" . $propertyNameId;
91 $propertyNameValue = $propertyNameId .
"_VALUE";
95 $propertyNameValue = $propertyNameId;
105 $iblockElementDb =
new CDBResultSenderConnector($iblockElementListDb);
106 $iblockElementDb->senderConnectorFieldEmail = $propertyEmailValue;
107 $iblockElementDb->senderConnectorFieldName = $propertyNameValue;
111 $iblockElementDb = new \CDBResult();
112 $iblockElementDb->InitFromArray(
array());
116 return $iblockElementDb;
123 public function getForm()
129 $iblockDb = IblockTable::getList(
array(
130 'select' =>
array(
'ID',
'NAME'),
132 while(
$iblock = $iblockDb->fetch())
138 array(
array(
'ID' =>
'',
'NAME' => Loc::getMessage(
'sender_connector_iblock_select'))),
143 array(
array(
'ID' =>
'',
'NAME' => Loc::getMessage(
'sender_connector_iblock_empty'))),
150 $propertyToIblock =
array();
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'));
154 $iblockFieldsDb = PropertyTable::getList(
array(
155 'select' =>
array(
'ID',
'NAME',
'IBLOCK_ID'),
156 'filter' =>
array(
'=PROPERTY_TYPE' => PropertyTable::TYPE_STRING)
158 while($iblockFields = $iblockFieldsDb->fetch())
161 $propertyList[$iblockFields[
'IBLOCK_ID']][] =
array(
162 'ID' => $iblockFields[
'ID'],
163 'NAME' => $iblockFields[
'NAME']
167 $propertyToIblock[$iblockFields[
'ID']] = $iblockFields[
'IBLOCK_ID'];
171 $fieldList = static::getIblockFieldList();
173 $fieldList = array_merge(
174 array(
array(
'ID' =>
'',
'NAME' => Loc::getMessage(
'sender_connector_iblock_field_select'))),
184 if(!isset($propertyList[
$iblock[
'ID']]) || !is_array($propertyList[
$iblock[
'ID']]))
191 $propertyList[
$iblock[
'ID']] = array_merge(
192 array(
array(
'ID' =>
'------',
'NAME' =>
'-----------------',
'DISABLED' =>
true)),
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').
'()">';
207 $inputSelected = (
$iblock[
'ID'] == $this->getFieldValue(
'IBLOCK') ?
'selected' :
'');
208 $iblockInput .=
'<option value="'.$iblock[
'ID'].
'" '.$inputSelected.
'>';
209 $iblockInput .= Main\Text\HtmlFilter::encode(
$iblock[
'NAME']);
210 $iblockInput .=
'</option>';
212 $iblockInput .=
'</select>';
218 $iblockPropertyNameInput =
'<select name="'.$this->getFieldName(
'PROPERTY_NAME').
'" id="'.$this->getFieldId(
'PROPERTY_NAME').
'">';
219 if(array_key_exists($this->getFieldValue(
'PROPERTY_NAME', 0), $propertyToIblock))
221 $propSet = $propertyList[$propertyToIblock[$this->getFieldValue(
'PROPERTY_NAME', 0)]];
223 elseif(array_key_exists($this->getFieldValue(
'IBLOCK', 0), $propertyList))
225 $propSet = $propertyList[$this->getFieldValue(
'IBLOCK')];
229 $propSet = $propertyList[
''];
231 foreach($propSet as $property)
233 $inputSelected = $property[
'ID'] == $this->getFieldValue(
'PROPERTY_NAME') ?
'selected' :
'';
234 $inputDisabled = (isset($property[
'DISABLED']) && $property[
'DISABLED']) ?
'disabled' :
'';
235 $iblockPropertyNameInput .=
'<option value="'.$property[
'ID'].
'" '.$inputSelected.
' '.$inputDisabled.
'>';
236 $iblockPropertyNameInput .= Main\Text\HtmlFilter::encode($property[
'NAME']);
237 $iblockPropertyNameInput .=
'</option>';
239 $iblockPropertyNameInput .=
'</select>';
245 $iblockPropertyEmailInput =
'<select name="'.$this->getFieldName(
'PROPERTY_EMAIL').
'" id="'.$this->getFieldId(
'PROPERTY_EMAIL').
'">';
246 if(array_key_exists($this->getFieldValue(
'PROPERTY_EMAIL', 0), $propertyToIblock))
248 $propSet = $propertyList[$propertyToIblock[$this->getFieldValue(
'PROPERTY_EMAIL', 0)]];
250 elseif(array_key_exists($this->getFieldValue(
'IBLOCK', 0), $propertyList))
252 $propSet = $propertyList[$this->getFieldValue(
'IBLOCK')];
256 $propSet = $propertyList[
''];
258 foreach($propSet as $property)
260 $inputSelected = ($property[
'ID'] == $this->getFieldValue(
'PROPERTY_EMAIL') ?
'selected' :
'');
261 $inputDisabled = (isset($property[
'DISABLED']) && $property[
'DISABLED']) ?
'disabled' :
'';
262 $iblockPropertyEmailInput .=
'<option value="'.$property[
'ID'].
'" '.$inputSelected.
' '.$inputDisabled.
'>';
263 $iblockPropertyEmailInput .= Main\Text\HtmlFilter::encode($property[
'NAME']);
264 $iblockPropertyEmailInput .=
'</option>';
266 $iblockPropertyEmailInput .=
'</select>';
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').
'
317 <td>'.Loc::getMessage(
'sender_connector_iblock_field_iblock').
'</td>
318 <td>'.$iblockInput.
'</td>
321 <td>'.Loc::getMessage(
'sender_connector_iblock_field_name').
'</td>
322 <td>'.$iblockPropertyNameInput.
'</td>
325 <td>'.Loc::getMessage(
'sender_connector_iblock_field_email').
'</td>
326 <td>'.$iblockPropertyEmailInput.
'</td>
333 protected static function getIblockFieldList()
335 $fieldCodeList =
array(
'NAME',
'CODE',
'PREVIEW_TEXT',
'DETAIL_TEXT');
337 $resultList =
array();
338 $entity = ElementTable::getEntity();
339 foreach($fieldCodeList as $fieldCode)
341 $field =
$entity->getField($fieldCode);
342 $resultList[] =
array(
344 'NAME' => $field->getTitle()
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";
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";
399 if (
count($keysForUnset)>0)
401 $keysForUnset = array_unique($keysForUnset);
$senderConnectorFieldName
$senderConnectorFieldEmail
static onConnectorListIblock($data)
static includeModule($moduleName)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(! $catalogEdit->isSuccess()) $iblock
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"