本文整理汇总了PHP中CIBlockElement类的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElement类的具体用法?PHP CIBlockElement怎么用?PHP CIBlockElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CIBlockElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trackStartedTask
function trackStartedTask($stopStartedTask = true)
{
CModule::IncludeModule('iblock');
$res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => TASKS_IBLOCK_ID, 'ACTIVE' => 'Y', "PROPERTY_PROGRAMMER" => CUser::GetID(), "PROPERTY_STATUS" => STATUS_LIST_WORK), false, false, array('ID', 'NAME', 'PROPERTY_PROJECT', 'PROPERTY_STATUS_DATE'));
if ($taskArr = $res->Fetch()) {
if ($stopStartedTask) {
CIBlockElement::SetPropertyValuesEx($taskArr['ID'], TASKS_IBLOCK_ID, array('STATUS' => STATUS_LIST_PAUSE));
}
$link = TASKS_LIST_URL . $taskArr["PROPERTY_PROJECT_VALUE"] . '/' . $taskArr['ID'] . '/';
$date = new DateTime($taskArr["PROPERTY_STATUS_DATE_VALUE"]);
$curdate = new DateTime();
$diff = $date->diff($curdate);
$h = $diff->format('%h');
$i = $diff->format('%i');
if ($h || $i) {
$timingText = '';
if ($h) {
$timingText = "{$h} ч, ";
}
if ($i) {
$timingText = $timingText . "{$i} мин. ";
}
$decTime = $h + $i / 60;
$decTime = round($decTime, 2);
$el = new CIBlockElement();
if ($el->Add(array("DATE_ACTIVE_FROM" => ConvertTimeStamp(time(), "SHORT"), "MODIFIED_BY" => CUser::GetID(), "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => TRACKING_IBLOCK_ID, "NAME" => 'Без названия' . ' (' . $decTime . 'ч.)', "ACTIVE" => "Y", "PROPERTY_VALUES" => array("HOURS" => $decTime, "TASK" => $taskArr['ID'])))) {
crmEntitiesHelper::recalcTaskTracking($taskArr['ID']);
ToolTip::Add("+ {$timingText} в трекер задачи \"<a target=\"_blank\" href=\"{$link}\">{$taskArr['ID']} {$taskArr['NAME']}</a>\"");
} else {
ToolTip::AddError($el->LAST_ERROR);
}
}
}
}
示例2: executeComponent
function executeComponent()
{
$arFilter = array('IBLOCK_ID' => $this->arParams['IBLOCK_ID'], 'ACTIVE' => 'Y');
if (true || $this->StartResultCache()) {
$CIBlockElement = new CIBlockElement();
$CFile = new \CFile();
$aElts = array();
$eltsSelectFields = array_merge(array('ID', 'NAME', 'CODE', 'PREVIEW_PICTURE', 'DETAIL_PICTURE', 'DETAIL_PAGE_URL'), $this->getIBlockProperties($this->arParams['IBLOCK_ID']));
$rsElts = $CIBlockElement->GetList(array('SORT' => 'asc', 'date_active_from' => 'DESC'), $arFilter, false, false, array('ID', 'NAME'));
if (intval($rsElts->SelectedRowsCount())) {
while ($arElt = $rsElts->Fetch()) {
$aElts[] = array('ID' => $arElt['ID'], 'NAME' => $arElt['NAME']);
}
$arElt = $CIBlockElement->GetList(array('SORT' => 'asc', 'ID' => 'DESC'), array_merge($arFilter, array('ID' => $aElts[0]['ID'])), false, false, $eltsSelectFields)->GetNext();
if ($arElt['DETAIL_PICTURE']) {
$arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['DETAIL_PICTURE']);
} elseif ($arElt['PREVIEW_PICTURE']) {
$arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['PREVIEW_PICTURE']);
}
$arPrice = CPrice::GetList(array(), array("PRODUCT_ID" => $arElt['ID']))->Fetch();
$arElt['PRICE'] = $arPrice['PRICE'];
$this->arResult['ITEMS'] = $aElts;
$this->arResult['ITEM'] = $arElt;
$this->IncludeComponentTemplate();
}
}
}
示例3: transformTags
public function transformTags($aOldTags, $aNewTags, $bSaveOldTags = false, $sOperation = false)
{
$aElements = $this->getMaterialsByTags($aOldTags);
$mResult = array('iTotalElements' => count($aElements), 'iProcessedElements' => 0, 'aErrorElementID' => array());
if (!empty($aElements)) {
$oElement = new CIBlockElement();
foreach ($aElements as $aElement) {
$aTags = explode(',', $aElement['TAGS']);
$aNewTags = array_map('trim', array_unique(array_merge($aTags, $aNewTags)));
if (!$bSaveOldTags) {
foreach ($aNewTags as $iKey => &$sTag) {
$sTag = trim($sTag);
if (in_array($sTag, $aOldTags)) {
unset($aNewTags[$iKey]);
}
}
}
//var_dump($aElement['TAGS'],implode( ', ', $aNewTags ) );
$bResult = $oElement->Update($aElement['ID'], array('TAGS' => implode(', ', $aNewTags)));
if ($bResult) {
$mResult['iProcessedElements']++;
} else {
$mResult['aErrorElementID'][] = array('ID' => $aElement['ID'], 'IBLOCK_ID' => $aElement['IBLOCK_ID'], 'FORMATTED_LINK' => $this->getElementLink($aElement));
}
}
}
return $mResult;
}
示例4: storeResult
function storeResult($arResult, $arParams) {
$iblock = CIBlock::GetList(
array(),
array(
'TYPE' => $arParams['IBLOCK_TYPE'],
'CODE' => $arParams['IBLOCK_CODE'],
)
);
$iblock = $iblock->Fetch();
$el = new CIBlockElement;
$props = array();
foreach ($arResult['FIELDS_LIST'] as $arField) {
if ($arField['FIELD_TYPE'] == 'TEXT' || $arField['FIELD_TYPE'] == 'NUMBER') {
$props[$arField['CODE']] = array(
'VALUE' => $arResult['POST_DATA']['~'.$arField['CODE']],
);
} elseif ($arField['FIELD_TYPE'] == 'TEXTAREA') {
$props[$arField['CODE']] = array(
'VALUE' => array(
'TYPE' => 'text',
'TEXT' => $arResult['POST_DATA']['~'.$arField['CODE']],
),
);
} elseif ($arField['FIELD_TYPE'] == 'LIST') {
$propEnum = CIBlockPropertyEnum::GetList(
array(),
array(
'XML_ID' => $arResult['POST_DATA']['~'.$arField['CODE']],
'CODE' => $arField['CODE'],
'IBLOCK_ID' => $iblock['ID'],
)
);
$propEnum = $propEnum->Fetch();
if ( ! $propEnum) return false;
$props[$arField['CODE']] = array(
'VALUE' => $propEnum['ID'],
);
}
}
$res = $el->Add(array(
'IBLOCK_TYPE' => $arParams['IBLOCK_TYPE'],
'IBLOCK_ID' => $iblock['ID'],
'ACTIVE' => 'Y',
'PROPERTY_VALUES' => $props,
'ACTIVE_FROM' => ConvertTimeStamp(time()+CTimeZone::GetOffset(), 'FULL'),
'NAME' => 'Form result', # !!! NEED TO REPLACE TO DEFAULT VALUE
));
if (!$res) {
return array(
'MESSAGE' => $el->LAST_ERROR,
);
}
return true;
}
示例5: AddProduct
function AddProduct($NAME)
{
$iblock_permission = CIBlock::GetPermission(IBLOCK_ID);
if ($iblock_permission < "W") {
$GLOBALS["USER"]->RequiredHTTPAuthBasic();
return new CSOAPFault('Server Error', 'Unable to authorize user.');
}
$code = self::translit($NAME);
$i = 1;
while (true) {
$res = CIBlockElement::Getlist(array(), array("CODE" => $code), false, array("CODE"));
if ($res->Fetch()) {
$code = self::translit($NAME) . $i;
} else {
break;
}
$i++;
}
$arFields = array("IBLOCK_ID" => IBLOCK_ID, "NAME" => $NAME);
$ib_element = new CIBlockElement();
$result = $ib_element->Add($arFields);
if ($result > 0) {
return $result;
}
return new CSOAPFault('Server Error', 'Error: ' . $ib_element->LAST_ERROR);
}
示例6: Execute
public function Execute()
{
if (!CModule::IncludeModule("intranet")) {
return CBPActivityExecutionStatus::Closed;
}
$absenceIblockId = COption::GetOptionInt("intranet", 'iblock_absence', 0);
if ($absenceIblockId <= 0) {
return CBPActivityExecutionStatus::Closed;
}
$rootActivity = $this->GetRootActivity();
$documentId = $rootActivity->GetDocumentId();
$documentService = $this->workflow->GetService("DocumentService");
$arAbsenceUserTmp = $this->AbsenceUser;
$arAbsenceUser = CBPHelper::ExtractUsers($arAbsenceUserTmp, $documentId, false);
$arAbsenceTypes = array();
$dbTypeRes = CIBlockPropertyEnum::GetList(array("SORT" => "ASC", "VALUE" => "ASC"), array('IBLOCK_ID' => $absenceIblockId, 'PROPERTY_ID' => 'ABSENCE_TYPE'));
while ($arTypeValue = $dbTypeRes->GetNext()) {
$arAbsenceTypes[$arTypeValue['XML_ID']] = $arTypeValue['ID'];
}
foreach ($arAbsenceUser as $absenceUser) {
$arFields = array("ACTIVE" => "Y", "IBLOCK_ID" => $absenceIblockId, 'ACTIVE_FROM' => $this->AbsenceFrom, 'ACTIVE_TO' => $this->AbsenceTo, "NAME" => $this->AbsenceName, "PREVIEW_TEXT" => $this->AbsenceDesrc, "PREVIEW_TEXT_TYPE" => "text", "PROPERTY_VALUES" => array("USER" => $absenceUser, "STATE" => $this->AbsenceState, "FINISH_STATE" => $this->AbsenceFinishState, "ABSENCE_TYPE" => $arAbsenceTypes[$this->AbsenceType]));
$el = new CIBlockElement();
$el->Add($arFields);
}
return CBPActivityExecutionStatus::Closed;
}
示例7: getFiles
/**
* {@inheritdoc}
*/
public function getFiles($insertId, array $attachFields)
{
$filesList = array();
$iblockElement = new \CIBlockElement();
$builderData = $this->builder->getBuilderData();
$filter = array('ID' => $insertId, 'IBLOCK_ID' => $builderData['DATA']['ID']);
$elementDb = $iblockElement->getList(array(), $filter, false, false, array());
if (!($element = $elementDb->getNextElement())) {
return $filesList;
}
$fields = $element->getFields();
foreach ($fields as $key => $value) {
if (in_array($key, $attachFields) && is_numeric($value)) {
$filesList[] = $value;
}
}
$propertyList = $element->getProperties();
foreach ($propertyList as $key => $property) {
if (!in_array($key, $attachFields)) {
continue;
}
if (is_numeric($property['VALUE'])) {
$filesList[] = $property['VALUE'];
} elseif (is_array($property['VALUE'])) {
$filesList = array_merge_recursive($filesList, $property['VALUE']);
}
}
return $filesList;
}
示例8: taskInsertElement
/**
* TASK performs with ACTION = INSERT
*
* @param int $limit
* @return string
*/
public static function taskInsertElement($limit = 500)
{
if (($limit = (int) $limit) < 0) {
return;
}
$iblockElement = new \CIBlockElement();
$connection = \Bitrix\Main\Application::getConnection();
$sqlHelper = $connection->getSqlHelper();
// We get a task with the `ACTION` of `INSERT`
$sql = "\n SELECT t1.ID as TASK_ID, t1.PARAMS, t1.FILTER_USER_ID, t3.*\n FROM b_citfact_filter_subscribe_stack as t1\n LEFT JOIN b_citfact_filter_subscribe_user as t2 ON t2.ID = t1.FILTER_USER_ID\n LEFT JOIN b_citfact_filter_subscribe as t3 ON t3.ID = t2.FILTER_USER\n WHERE t1.ACTION = 'INSERT' AND t3.ACTIVE = 'N'\n LIMIT 1\n ";
$task = (array) $connection->query($sql)->fetch();
if (!empty($task)) {
$filter['IBLOCK_ID'] = $task['IBLOCK_ID'];
if ($task['SECTION_ID'] > 0) {
$filter['SECTION_ID'] = $task['SECTION_ID'];
}
$filter = array_merge($filter, unserialize($task['FILTER']));
$elementResult = $iblockElement->GetList(array('ID' => 'ASC'), $filter, false, array('nTopCount' => $limit), array('ID'));
while ($element = $elementResult->fetch()) {
Model\SubscribeNotifyTable::add(array('FILTER_USER_ID' => $task['FILTER_USER_ID'], 'ELEMENT_ID' => $element['ID']));
}
Model\SubscribeStackTable::delete(array('ID' => $task['TASK_ID']));
}
return "Citfact\\FilterSubscribe\\Agent::taskInsertElement({$limit})";
}
示例9: agent_kingcoupon_pars
/**
* Created by JetBrains PhpStorm.
* User: oleg
* Date: 01.10.12
* Time: 21:06
* To change this template use File | Settings | File Templates.
*/
function agent_kingcoupon_pars()
{
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
CModule::IncludeModule("mytb");
$content = file_get_contents("http://kingcoupon.ru/offer/category/Food/");
preg_match_all("#kingcoupon\\.ru/offer/([0-9]+)/#is", $content, $arr);
$xml = file_get_contents("http://kingcoupon.ru/offer/export/?refId=100132540459877345");
$svg = new SimpleXMLElement($xml);
$clubListID = array();
foreach ($arr[1] as $var) {
$clubListID[$var] = $var;
}
foreach ($svg->offers->offer as $var) {
$R = array();
if (in_array($var->id, $arr[1])) {
$R['clubName'] = (string) $var->supplier->name;
foreach ((array) $var->supplier->addresses as $address) {
if (is_array($address)) {
foreach ((array) $address as $var1) {
$R['clubAdress'][] = (string) $var1->name;
}
} else {
$R['clubAdress'][] = $address->name;
}
}
foreach ((array) $var->supplier->tel as $tel) {
$R['clubPhone'][] = $tel;
}
$id = $var->id;
$url = preg_replace("#http://#i", "", $var->supplier->url);
$url = preg_replace("#^([^/]+)/.*#i", "\\1", $url);
$url = str_replace("www.", "", $url);
$R['url'] = $url;
$arSelect = array("ID", "NAME");
$arFilter = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_SITE" => "%" . $url . "%");
$res = CIBlockElement::GetList(array("SORT" => "DESC"), $arFilter, FALSE, FALSE, $arSelect);
if (!$res->Fetch()) {
$PROP = array();
// $PROP["PHONE"] = $R['clubPhone'];
// $PROP["ADDRESS"] = $R['clubAdress'];
$PROP["SITE"] = $R['url'];
$PROP["LIST"] = array(54);
$el = new CIBlockElement();
$arLoadProductArray = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_VALUES" => $PROP, "NAME" => $R['clubName'], "TAGS" => "kingcoupon", "ACTIVE" => "Y", "SORT" => "0");
if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
foreach ($R['clubAdress'] as $addressItem) {
MyTbCore::Add(array("CLUB_ID" => $PRODUCT_ID, "SITY_ID" => 1, "ADDRESS" => $addressItem, "PHONE" => serialize($R['clubPhone'])), "address");
printAr($addressItem);
}
} else {
echo "Error: " . $el->LAST_ERROR;
}
}
}
}
return "agent_kingcoupon_pars();";
}
示例10: executeDown
function executeDown()
{
CModule::IncludeModule('iblock');
$obj_ib_element = new CIBlockElement();
$r = $obj_ib_element->Delete(2);
if (!$r) {
throw new \Exception('Fail do remove element with id = 1');
}
return true;
}
示例11: connectToUser
public static function connectToUser($userID, $providerName, $userProfile)
{
CModule::IncludeModule("iblock");
$el = new \CIBlockElement();
$PROP = array();
$PROP["USER_ID"] = $userID;
$PROP["SOCIAL_PROVIDER"] = $providerName;
$PROP["SOCIAL_ID"] = $userProfile["identifier"];
$arLoadProductArray = array("IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => USER_SOCIAL_IB, "PROPERTY_VALUES" => $PROP, "NAME" => trim("Пользователь №" . $userID), "ACTIVE" => "Y");
$el->Add($arLoadProductArray);
\CUserEx::capacityAdd($userID, 1);
}
示例12: save
public function save()
{
\Bitrix\Main\Loader::includeModule("iblock");
$errors =& $this->arResult["forms"][$this->request->getPost("id")]["errors"];
$el = new CIBlockElement();
$this->element_id = $el->Add(array("IBLOCK_ID" => 4, "NAME" => "({$this->arResult["forms"][$this->request->getPost("id")]["title"]})Обращение от {$this->request->getPost("first_name")} {$this->request->getPost("last_name")}", "PREVIEW_TEXT" => $this->request->getPost("comment"), "PROPERTY_VALUES" => array("TREATMENT_REASON" => $this->request->getPost("reason_for_treatment"), "PHONE" => $this->request->getPost("phone"), "EMAIL" => $this->request->getPost("email"), "FILE" => $this->request->getFile("file"))));
if ($this->element_id !== false) {
return true;
}
$errors[] = $res->LAST_ERROR;
return false;
}
示例13: getOptions
/**
* Метод вернет массив параметров из инфоблока "Параметры Автонаценки".
*
* @return array
*/
function getOptions()
{
$filterParams = array('ACTIVE' => 'Y', 'IBLOCK_CODE' => 'autoprice_options');
$orderParams = array('SORT' => 'ASC');
$selectParams = array('ID', 'IBLOCK_SECTION_ID', 'NAME', 'CODE', 'PROPERTY_PARAM', 'PROPERTY_MARKUP');
$result = array();
$iBlockElement = new CIBlockElement();
$dbElements = $iBlockElement->GetList($orderParams, $filterParams, false, false, $selectParams);
while ($element = $dbElements->GetNext()) {
$result[] = $element;
}
return $result;
}
示例14: addElementReview
function addElementReview($arResult, $ID_SECTION, $IBLOCK_ID)
{
CModule::IncludeModule('iblock');
$property_enums = CIBlockPropertyEnum::GetList(array("DEF" => "DESC", "SORT" => "ASC"), array("IBLOCK_ID" => $IBLOCK_ID, "CODE" => "RATING", "VALUE" => $arResult['RATING']));
while ($rating = $property_enums->GetNext()) {
$arRating = $rating["ID"];
}
$current_date = dateActiveFrom(date('d.m.Y'));
$NAME = $current_date . ' ' . $arResult['NAME'];
$arFields = array("ACTIVE" => "N", "IBLOCK_ID" => $IBLOCK_ID, "IBLOCK_SECTION_ID" => $ID_SECTION, "NAME" => $NAME, "DETAIL_TEXT" => "Описание элемента", "PROPERTY_VALUES" => array("NAME" => $arResult['NAME'], "EMAIL" => $arResult['EMAIL'], "RATING" => array('VALUE' => $arRating), "BENEFITS" => $arResult['BENEFITS'], "DISADVANTAGES" => $arResult['DISADVANTAGES'], "COMMENT" => $arResult['COMMENT']));
$oElement = new CIBlockElement();
$idElement = $oElement->Add($arFields, false, false, true);
return $idElement;
}
示例15: no_active_stock
/**
* Выключает прошедшие акции
* User: Tabota Oleg (sForge.ru)
* Date: 18.11.12 16:20
* File name: no_active_stock.php
*/
function no_active_stock()
{
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
$sort = array("SORT" => "ASC");
$filter = array("ACTIVE" => "Y", "IBLOCK_ID" => IB_SUB_STOCK_ID, "<DATE_ACTIVE_TO" => date("d.m.Y"));
$select = array("ID", "IBLOCK_ID");
$ob = CIBlockElement::GetList($sort, $filter, FALSE, FALSE, $select);
while ($row = $ob->Fetch()) {
$el = new CIBlockElement();
$el->Update(intval($row['ID']), array("ACTIVE" => "N"));
}
return "no_active_stock();";
}