)\];'\"!?]#",'\\0', $text); $text = preg_replace("%(^|\s|\A|\b|>)#(\S+)%",'$1#$2', $text); $img = ''; if(isset($r["attachment"]) && $r["attachment"]['type'] == 'photo') $img = $r["attachment"]['photo']["src_big"]; else if(isset($r["attachment"]) && $r["attachment"]['type'] == 'link') $img = $r["attachment"]['link']["image_src"]; else if(isset($r["attachments"]) && $r["attachments"][0]['type'] == 'link') { $img = $r["attachments"][0]['link']["image_src"]; if(!$text) $text = $r["attachments"][0]['link']["title"]; } else if(isset($r["attachment"]) && $r["attachment"]['type'] == 'video') $img = $r["attachment"]['video']["image"]; else if(isset($r["attachments"])) { foreach($r["attachments"] as $a) if($a['type'] == 'photo') { $img = $a['photo']["src_big"]; if($img) break; } } $arResult['res'][] = ['id' => $r["id"], 'img' => $img, 'text' => $text, 'date' => ($r['date'] + 60*60*2), 'url' => 'https://vk.com/ttepla45?w=wall-' . $arParams['group_id'] . '_' . $r["id"]]; } if(isset($arParams['save']) && $arParams['save'] && count($arResult['res'])) { $all = array_reverse($arResult['res']); foreach($all as $r) { $row = CIBlockElement::GetList(['SORT' => 'ASC'], ['IBLOCK_ID' => 14, 'NAME' => $r['url']], false)->GetNext(); if(!$row) { $el = new CIBlockElement; $arLoadProductArray = Array( "IBLOCK_ID" => 14, "PROPERTY_VALUES"=> [1092 => $r['url']], "NAME" => $r['url'], "CODE" => $r['url'], "ACTIVE" => "Y", "DETAIL_TEXT" => $r['text'], "DETAIL_PICTURE" => CFile::MakeFileArray($r['img']) ); if($PRODUCT_ID = $el->Add($arLoadProductArray)) echo "New ID: ".$PRODUCT_ID . '
'; else echo "Error: ".$el->LAST_ERROR . '
'; } } } } $this->IncludeComponentTemplate();