本文整理汇总了PHP中CIBlockElement::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElement::getList方法的具体用法?PHP CIBlockElement::getList怎么用?PHP CIBlockElement::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElement
的用法示例。
在下文中一共展示了CIBlockElement::getList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
/** @return \CDBResult */
public function getData()
{
$iblockId = $this->getFieldValue('IBLOCK', null);
$propertyNameId = $this->getFieldValue('PROPERTY_NAME', null);
$propertyEmailId = $this->getFieldValue('PROPERTY_EMAIL', null);
if ($iblockId && $propertyEmailId) {
// if property is property with code like '123'
$propertyNameValue = null;
$propertyEmailValue = null;
if (is_numeric($propertyEmailId)) {
$propertyEmailId = "PROPERTY_" . $propertyEmailId;
$propertyEmailValue = $propertyEmailId . "_VALUE";
}
$selectFields = array($propertyEmailValue);
if ($propertyNameId) {
if (is_numeric($propertyNameId)) {
$propertyNameId = "PROPERTY_" . $propertyNameId;
$propertyNameValue = $propertyNameId . "_VALUE";
}
$selectFields[] = $propertyNameValue;
}
$filter = array('IBLOCK_ID' => $iblockId, '!' . $propertyEmailId => false);
$iblockElementListDb = \CIBlockElement::getList(array('id' => 'asc'), $filter, false, false, $selectFields);
// replace property names from PROPERTY_123_VALUE to EMAIL, NAME
$iblockElementDb = new CDBResultSenderConnector($iblockElementListDb);
$iblockElementDb->senderConnectorFieldEmail = $propertyEmailValue;
$iblockElementDb->senderConnectorFieldName = $propertyNameValue;
} else {
$iblockElementDb = new \CDBResult();
$iblockElementDb->InitFromArray(array());
}
return $iblockElementDb;
}
示例2: 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;
}
示例3: getMaterialsByTags
/**
* Получение элементов инфоблока по тегам
* @param unknown_type $aTags
*/
public function getMaterialsByTags($aTags)
{
$mResult = array();
if (!is_array($aTags)) {
$aTags = (array) $aTags;
}
$aFilter = $this->getTagsFilter();
if (isset($this->aOptions['FILTER'])) {
$aFilter = array_merge($this->aOptions['FILTER'], $aFilter);
}
$aTagFilter = array();
foreach ($aTags as $sTag) {
$aTagFilter[] = array('TAGS' => '%' . $sTag . '%');
}
$aFilter[] = $aTagFilter;
$oElements = CIBlockElement::getList(array('NAME' => 'ASC'), array($aFilter), false, false, array('ID', 'NAME', 'IBLOCK_ID', 'TAGS'));
while ($aElement = $oElements->Fetch()) {
$aElemTags = array_map('trim', explode(',', $aElement['TAGS']));
$bGood = true;
foreach ($aTags as $sTag) {
$sTag = trim($sTag);
if (!in_array($sTag, $aElemTags)) {
$bGood = false;
}
}
if ($bGood) {
$aElement['FORMATTED_LINK'] = $this->getElementLink($aElement);
$mResult[] = $aElement;
}
}
return $mResult;
}
示例4: fetch
public function fetch($filter, $params = array())
{
// ����������� ������
// ksort($filter);
// ��������� � id ���� ��� ��������� ���������
$cacheId = serialize($filter);
// if (isset($params['count'])) {
// $cacheId .= '+cnt'.$params['count'];
// }
//
// if (isset($params['pageSize'])) {
// $cacheId .= '+ps'.$params['pageSize'].'-'.\CDBResult::navStringForCache($params['pageSize']);
// }
//
// if (isset($params['sort'])) {
// $cacheId .= '+s'. serialize($params['sort']);
// } else {
// $params['sort'] = array('id'=> 'desc');
// }
//
// // ��������� ���
$cache = new \CPhpCache();
// if (false && $cache->initCache($this->_cacheTime, $cacheId, $this->_cacheDir)) {
//
// $vars = $cache->getVars();
//
// // ��� ����, ����� ������������ ����������� ���������, ��������� CDBResult
// $this->_dbResult = new \CDBResult;
// if (isset($params['pageSize'])) {
// $this->_dbResult->InitFromArray(
// (int)$vars['total'] > 0 ? array_fill(0, $vars['total'], 0) : array()
// );
// if (isset($params['pageSize'])) {
// $this->_dbResult->navStart($params['pageSize'], true, $vars['page']);
// }
// }
// return $vars['items'];
// }
// � ���� ���
\CMOdule::includeModule('iblock');
//$filter['IBLOCK_ID'] = isset($filter['IBLOCK_ID']) ? $filter['IBLOCK_ID'] : $this->_iblockId;
// $filter['ACTIVE'] = 'Y';
$this->_dbResult = \CIBlockElement::getList($params['sort'], $filter, false, isset($params['count']) ? array('nTopCount' => $params['count']) : false, $this->_commonSelect);
if (isset($params['pageSize'])) {
$this->_dbResult->navStart($params['pageSize']);
}
$result = array();
while ($row = $this->_dbResult->fetch()) {
$result[$row['ID']] = $row;
}
if ($cache->startDataCache()) {
$cache->endDataCache(array('items' => $result, 'total' => $this->_dbResult->NavRecordCount, 'page' => $this->_dbResult->NavPageNomer));
}
return $result;
}
示例5: refresh
/**
* Common function, used to update/insert any product.
*
* @param int $productId Id of product.
* @param int $fuserId User basket id.
* @param string $siteId Site id.
* @param int $elementId Parent id.
* @param string $recommendationId Bigdata recommendation id.
*
* @return int
*/
public static function refresh($productId, $fuserId, $siteId = SITE_ID, $elementId = 0, $recommendationId = '')
{
$productId = (int) $productId;
if ($productId <= 0) {
return -1;
}
$fuserId = (int) $fuserId;
if ($fuserId <= 0) {
return -1;
}
$siteId = (string) $siteId;
if ($siteId == '') {
return -1;
}
$elementId = (int) $elementId;
$filter = array('FUSER_ID' => $fuserId, '=SITE_ID' => $siteId);
$connection = Application::getConnection();
$helper = $connection->getSqlHelper();
$sqlSiteId = $helper->forSql($siteId);
if ($elementId > 0) {
$filter["ELEMENT_ID"] = $elementId;
// Delete parent product id (for capability)
if ($elementId != $productId) {
$connection->query("delete from b_catalog_viewed_product\n\t\t\t\t\t\t\t\t\twhere PRODUCT_ID = " . $elementId . " and FUSER_ID = " . $fuserId . " and SITE_ID = '" . $sqlSiteId . "'");
}
} else {
$productInfo = \CCatalogSKU::getProductInfo($productId);
// Real SKU ID
if (!empty($productInfo)) {
$elementId = $productInfo['ID'];
$siblings = array();
// Delete parent product id (for capability)
$connection->query("delete from b_catalog_viewed_product\n\t\t\t\t\t\t\t\t\twhere PRODUCT_ID = " . $productInfo['ID'] . " and FUSER_ID = " . $fuserId . " and SITE_ID = '" . $sqlSiteId . "'");
$skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $productInfo['OFFER_IBLOCK_ID'], 'PROPERTY_' . $productInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID'));
while ($oneSku = $skus->fetch()) {
$siblings[] = $oneSku['ID'];
}
$filter['PRODUCT_ID'] = $siblings;
} else {
$elementId = $productId;
$filter['PRODUCT_ID'] = $productId;
}
}
$iterator = static::getList(array('select' => array('ID', 'FUSER_ID', 'DATE_VISIT', 'PRODUCT_ID', 'SITE_ID', 'VIEW_COUNT'), 'filter' => $filter));
if ($row = $iterator->fetch()) {
static::update($row['ID'], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1, "ELEMENT_ID" => $elementId, "RECOMMENDATION" => $recommendationId));
return $row['ID'];
} else {
$result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new Main\Type\DateTime(), "PRODUCT_ID" => $productId, "ELEMENT_ID" => $elementId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1, "RECOMMENDATION" => $recommendationId));
return $result->getId();
}
}
示例6: canRead
public function canRead($userId)
{
if (!Loader::includeModule("iblock")) {
return false;
}
$elementId = $this->entityId;
$elementQuery = \CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('IBLOCK_ID'));
$element = $elementQuery->fetch();
if (!$element['IBLOCK_ID']) {
return false;
}
return \CIBlockElementRights::userHasRightTo($element['IBLOCK_ID'], $elementId, "element_read");
}
示例7: canRead
public function canRead($userId)
{
if (!Loader::includeModule("lists")) {
return false;
}
$elementId = $this->entityId;
$elementQuery = \CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('IBLOCK_TYPE_ID', 'IBLOCK_ID'));
$element = $elementQuery->fetch();
$listPerm = \CListPermissions::checkAccess($this->getUser(), $element['IBLOCK_TYPE_ID'], $element['IBLOCK_ID']);
if ($listPerm < 0) {
return false;
} elseif ($listPerm < \CListPermissions::CAN_READ && !\CIBlockElementRights::userHasRightTo($element['IBLOCK_ID'], $elementId, "element_read")) {
return false;
} else {
return true;
}
}
示例8: _determineModules
protected function _determineModules(array $ids)
{
sort($ids);
$cache = new CPhpCache();
if ($cache->initCache($this->_cacheTime, serialize($ids), $this->_cacheDir)) {
return $cache->getVars();
}
CModule::includeModule('iblock');
$res = CIBlockElement::getList(array(), array('ID' => $ids), false, array('nTopCount' => count($ids)), array('ID', 'IBLOCK_ID'));
$result = array();
while ($row = $res->fetch()) {
$module = $this->_getModule($row['IBLOCK_ID']);
if (!array_key_exists($module, $result)) {
$result[$module] = array();
}
$result[$module][] = $row['ID'];
}
if ($cache->startDataCache()) {
$cache->endDataCache($result);
}
return $result;
}
示例9: loadFromDatabase
public function loadFromDatabase()
{
if (!isset($this->fields)) {
$this->fields = array();
$select = array_values($this->fieldMap);
$elementList = \Freetrix\Iblock\ElementTable::getList(array("select" => $select, "filter" => array("=ID" => $this->id)));
$this->elementFields = $elementList->fetch();
if ($this->elementFields) {
$arCatalog = \CCatalogSKU::getInfoByProductIBlock($this->elementFields["IBLOCK_ID"]);
if (is_array($arCatalog)) {
$this->skuIblockId = $arCatalog["IBLOCK_ID"];
$skuList = \CIBlockElement::getList(array(), array("IBLOCK_ID" => $arCatalog["IBLOCK_ID"], "=PROPERTY_" . $arCatalog["SKU_PROPERTY_ID"] => $this->id), false, false, $select);
while ($sku = $skuList->fetch()) {
$this->skuList[] = $sku;
foreach ($sku as $fieldName => $fieldValue) {
$this->fields[$fieldName][] = $fieldValue;
}
}
}
}
}
return is_array($this->fields);
}
示例10: renderControlOptions
/**
* @param FieldType $fieldType
* @param string $callbackFunctionName
* @param mixed $value
* @return string
*/
public static function renderControlOptions(FieldType $fieldType, $callbackFunctionName, $value)
{
if (is_array($value)) {
reset($value);
$valueTmp = (int) current($value);
} else {
$valueTmp = (int) $value;
}
$iblockId = 0;
if ($valueTmp > 0) {
$elementIterator = \CIBlockElement::getList(array(), array('ID' => $valueTmp), false, false, array('ID', 'IBLOCK_ID'));
if ($element = $elementIterator->fetch()) {
$iblockId = $element['IBLOCK_ID'];
}
}
if ($iblockId <= 0 && (int) $fieldType->getOptions() > 0) {
$iblockId = (int) $fieldType->getOptions();
}
$defaultIBlockId = 0;
$result = '<select id="WFSFormOptionsX" onchange="' . htmlspecialcharsbx($callbackFunctionName) . '(this.options[this.selectedIndex].value)">';
$iblockTypeIterator = \CIBlockParameters::getIBlockTypes();
foreach ($iblockTypeIterator as $iblockTypeId => $iblockTypeName) {
$result .= '<optgroup label="' . htmlspecialcharsbx($iblockTypeName) . '">';
$iblockIterator = \CIBlock::getList(array('SORT' => 'ASC'), array('TYPE' => $iblockTypeId, 'ACTIVE' => 'Y'));
while ($iblock = $iblockIterator->fetch()) {
$result .= '<option value="' . $iblock['ID'] . '"' . ($iblock['ID'] == $iblockId ? ' selected' : '') . '>' . htmlspecialcharsbx($iblock['NAME']) . '</option>';
if ($defaultIBlockId <= 0 || $iblock['ID'] == $iblockId) {
$defaultIBlockId = $iblock['ID'];
}
}
$result .= '</optgroup>';
}
$result .= '</select><!--__defaultOptionsValue:' . $defaultIBlockId . '--><!--__modifyOptionsPromt:' . Loc::getMessage('UTP_ELIST_DOCUMENT_MOPROMT') . '-->';
$fieldType->setOptions($defaultIBlockId);
return $result;
}
示例11: array
if ($res) {
$arResult["ELEMENT_ID"] = $res;
} else {
$strError = $obElement->LAST_ERROR;
}
}
}
if ($bBizproc) {
if (!$strError) {
/* Find the new or modified field. */
if ($ELEMENT_ID && $templatesOnStartup) {
$modifiedFields = array();
/* We get the new data element. */
$elementNewData = array();
$elementOldData = array();
$elementQuery = CIBlockElement::getList(array(), array("IBLOCK_ID" => $arResult["IBLOCK_ID"], "=ID" => $arResult["ELEMENT_ID"]), false, false, $arSelect);
$elementObject = $elementQuery->getNextElement();
if (is_object($elementObject)) {
$elementNewData = $elementObject->getFields();
}
$elementOldData = $arResult["ELEMENT_FIELDS"];
unset($elementNewData["TIMESTAMP_X"]);
unset($elementOldData["TIMESTAMP_X"]);
$elementNewData["PROPERTY_VALUES"] = array();
if (is_object($elementObject)) {
$propertyQuery = CIBlockElement::getProperty($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc"), array("ACTIVE" => "Y", "EMPTY" => "N"));
while ($property = $propertyQuery->fetch()) {
$propertyId = $property["ID"];
if (!array_key_exists($propertyId, $elementNewData["PROPERTY_VALUES"])) {
$elementNewData["PROPERTY_VALUES"][$propertyId] = $property;
unset($elementNewData["PROPERTY_VALUES"][$propertyId]["DESCRIPTION"]);
示例12: setMessageLiveFeed
public static function setMessageLiveFeed($users, $elementId, $workflowId, $flagCompleteProcess)
{
$elementId = intval($elementId);
$elementObject = CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('ID', 'CREATED_BY', 'IBLOCK_NAME', 'NAME', 'IBLOCK_ID', 'LANG_DIR'));
$element = $elementObject->fetch();
if (!CLists::getLiveFeed($element["IBLOCK_ID"])) {
return false;
}
$params = serialize(array("ELEMENT_NAME" => $element['NAME']));
$element['NAME'] = preg_replace_callback('#^[^\\[\\]]+?\\[(\\d+)\\]#i', function ($matches) {
$userId = $matches[1];
$db = CUser::GetByID($userId);
if ($ar = $db->GetNext()) {
$ix = randString(5);
return '<a class="feed-post-user-name" id="bp_' . $userId . '_' . $ix . '" href="/company/personal/user/' . $userId . '/"
bx-post-author-id="' . $userId . '">' . CUser::FormatName(CSite::GetNameFormat(false), $ar, false, false) . '</a>
<script type="text/javascript">if (BX.tooltip) BX.tooltip(\'' . $userId . '\', "bp_' . $userId . '_' . $ix . '", "");</script>';
}
return $matches[0];
}, $element['NAME']);
$path = rtrim($element['LANG_DIR'], '/');
$urlElement = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $elementId;
$createdBy = $element['CREATED_BY'];
if (!Loader::includeModule('socialnetwork') || $createdBy <= 0) {
return false;
}
$sourceId = CBPStateService::getWorkflowIntegerId($workflowId);
$logId = 0;
$userObject = CUser::getByID($createdBy);
$siteId = array();
$siteObject = CSite::getList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
while ($site = $siteObject->fetch()) {
$siteId[] = $site['LID'];
}
if ($userObject->fetch()) {
global $DB;
$soFields = array('ENTITY_TYPE' => SONET_LISTS_NEW_POST_ENTITY, 'EVENT_ID' => 'lists_new_element', 'ENTITY_ID' => 1, '=LOG_UPDATE' => $DB->currentTimeFunction(), 'SOURCE_ID' => $sourceId, 'USER_ID' => $createdBy, 'MODULE_ID' => 'lists', 'TITLE_TEMPLATE' => $urlElement, 'TITLE' => $element['IBLOCK_NAME'], 'PARAMS' => $params, 'MESSAGE' => $workflowId, 'CALLBACK_FUNC' => false, 'SITE_ID' => $siteId, 'ENABLE_COMMENTS' => 'Y', 'RATING_TYPE_ID' => 'LISTS_NEW_ELEMENT', 'RATING_ENTITY_ID' => $sourceId, 'URL' => '#SITE_DIR#' . COption::GetOptionString('socialnetwork', 'user_page', false, SITE_ID) . 'log/');
$logObject = CSocNetLog::getList(array(), array('ENTITY_TYPE' => $soFields['ENTITY_TYPE'], 'ENTITY_ID' => $soFields['ENTITY_ID'], 'EVENT_ID' => $soFields['EVENT_ID'], 'SOURCE_ID' => $soFields['SOURCE_ID']));
$iblockPicture = CIBlock::getArrayByID($element['IBLOCK_ID'], 'PICTURE');
$imageFile = CFile::getFileArray($iblockPicture);
if ($imageFile !== false) {
$imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
}
if (empty($imageFile['src'])) {
$imageFile['src'] = '/bitrix/images/lists/default.png';
}
$soFields['TEXT_MESSAGE'] = '
<span class="bp-title-desc">
<span class="bp-title-desc-icon">
<img src="' . $imageFile['src'] . '" width="36" height="30" border="0" />
</span>
' . $element['NAME'] . '
</span>
';
if ($log = $logObject->fetch()) {
if (intval($log['ID']) > 0) {
if (empty($users)) {
CSocNetLog::update($log['ID'], $soFields);
} else {
$activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
$rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post');
$usersRight = self::getUserIdForRight($rights);
self::setSocnetFollow($usersRight, $log['ID'], 'Y', true);
/* Recipients tasks bp */
CSocNetLog::update($log['ID'], $soFields);
/* Increment the counter for participants */
CSocNetLogRights::deleteByLogID($log['ID']);
$rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter');
CSocNetLogRights::add($log['ID'], $rightsCounter, false, false);
CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false);
/* Return previous state rights */
CSocNetLogRights::deleteByLogID($log['ID']);
CSocNetLogRights::add($log['ID'], $rights, false, false);
self::setSocnetFollow($users, $log['ID'], 'Y');
self::setSocnetFollow($users, $log['ID'], 'N');
}
/* Completion of the process for the author */
if ($flagCompleteProcess) {
$activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
$rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post');
$usersRight = self::getUserIdForRight($rights);
/* Increment the counter for author */
$users[] = $createdBy;
CSocNetLogRights::deleteByLogID($log['ID']);
$rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter');
CSocNetLogRights::add($log['ID'], $rightsCounter, false, false);
CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false);
/* Return previous state rights */
CSocNetLogRights::deleteByLogID($log['ID']);
CSocNetLogRights::add($log['ID'], $rights, false, false);
self::setSocnetFollow($users, $log['ID'], 'Y');
self::setSocnetFollow($usersRight, $log['ID'], 'N');
}
}
} else {
$activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
$soFields['=LOG_DATE'] = $DB->currentTimeFunction();
$logId = CSocNetLog::add($soFields, false);
if (intval($logId) > 0) {
$rights = self::getRights($activeUsers, $logId, $createdBy, 'post');
//.........这里部分代码省略.........
示例13: getElementFields
protected function getElementFields($iblockId, $elementId)
{
$totalResult = array();
$list = new CList($iblockId);
$listFields = $list->getFields();
foreach ($listFields as $fieldId => $field) {
$totalResult[$fieldId] = $field;
}
$elementQuery = CIBlockElement::getList(array(), array("IBLOCK_ID" => $iblockId, "=ID" => $elementId), false, false, array('*'));
$elementObject = $elementQuery->getNextElement();
$elementNewData = $elementObject->getFields();
if (is_array($elementNewData)) {
foreach ($elementNewData as $fieldId => $fieldValue) {
if (!$list->is_field($fieldId)) {
continue;
}
if (isset($totalResult[$fieldId]["NAME"])) {
$totalResult[$fieldId]["VALUE"] = $fieldValue;
}
}
}
$query = \CIblockElement::getPropertyValues($iblockId, array('ID' => $elementId));
if ($propertyValues = $query->fetch()) {
foreach ($propertyValues as $id => $values) {
if ($id == "IBLOCK_ELEMENT_ID") {
continue;
}
$fieldId = "PROPERTY_" . $id;
$totalResult[$fieldId]["VALUE"] = $values;
}
}
return $totalResult;
}
示例14: executeComponent
public function executeComponent()
{
if (!empty($this->arParams['ERROR'])) {
ShowError(array_shift($this->arParams['ERROR']));
return;
}
$this->arResult['USER_ID'] = $this->arParams['USER_ID'];
$this->arResult['GRID_ID'] = 'lists_processes';
$selectFields = array('ID', 'IBLOCK_TYPE_ID', 'IBLOCK_ID', 'NAME');
$gridOptions = new CGridOptions($this->arResult['GRID_ID']);
$gridColumns = $gridOptions->getVisibleColumns();
$gridSort = $gridOptions->getSorting(array('sort' => array('ID' => 'desc')));
$this->arResult['HEADERS'] = array(array("id" => "ID", "name" => "ID", "default" => false, "sort" => "ID"), array('id' => 'DOCUMENT_NAME', 'name' => Loc::getMessage('CC_BLL_DOCUMENT_NAME'), 'default' => true, 'sort' => 'DOCUMENT_NAME'), array('id' => 'COMMENTS', 'name' => Loc::getMessage('CC_BLL_COMMENTS'), 'default' => true, 'sort' => '', 'hideName' => true, 'iconCls' => 'bp-comments-icon'), array('id' => 'WORKFLOW_PROGRESS', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_PROGRESS'), 'default' => true, 'sort' => ''), array('id' => 'WORKFLOW_STATE', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_STATE'), 'default' => false, 'sort' => ''));
$this->arResult['FILTER'] = array(array("id" => "NAME", "name" => GetMessage("BPATL_NAME"), "type" => "string"), array('id' => 'TIMESTAMP_X', 'name' => Loc::getMessage('CC_BLL_MODIFIED'), 'type' => 'date'), array('id' => 'DATE_CREATE', 'name' => Loc::getMessage('CC_BLL_CREATED'), 'type' => 'date', 'default' => true));
$gridFilter = $gridOptions->getFilter($this->arResult['FILTER']);
foreach ($gridFilter as $key => $value) {
if (substr($key, -5) == "_from") {
$op = ">=";
$newKey = substr($key, 0, -5);
} elseif (substr($key, -3) == "_to") {
$op = "<=";
$newKey = substr($key, 0, -3);
if (in_array($newKey, array("TIMESTAMP_X", 'DATE_CREATE'))) {
if (!preg_match("/\\d\\d:\\d\\d:\\d\\d\$/", $value)) {
$value .= " 23:59:59";
}
}
} else {
$op = "";
$newKey = $key;
}
$filter[$op . $newKey] = $value;
}
$this->arResult['SORT'] = $gridSort['sort'];
$useComments = (bool) CModule::includeModule("forum");
$workflows = array();
$this->arResult['DATA'] = array();
$this->arResult["COMMENTS_COUNT"] = array();
$filter['CREATED_BY'] = $this->arParams['USER_ID'];
$iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
$filter['IBLOCK_TYPE'] = $iblockTypeId;
$filter['CHECK_PERMISSIONS'] = $this->arParams['LIST_PERM'] >= CListPermissions::CAN_READ ? "N" : "Y";
$elementObject = CIBlockElement::getList($gridSort['sort'], $filter, false, $gridOptions->getNavParams(), $selectFields);
$documentState = true;
$path = rtrim(SITE_DIR, '/');
while ($element = $elementObject->fetch()) {
$documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($iblockTypeId, $element['IBLOCK_ID']), BizprocDocument::getDocumentComplexId($iblockTypeId, $element['ID']));
$this->arResult['DATA'][$element['ID']]['ID'] = $element['ID'];
$this->arResult['DATA'][$element['ID']]['DOCUMENT_NAME'] = $element['NAME'];
$this->arResult['DATA'][$element['ID']]['DOCUMENT_URL'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $element['ID'];
if (!empty($documentState)) {
$this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = true;
$documentState = current($documentState);
$this->arResult['DATA'][$element['ID']]['WORKFLOW_ID'] = $documentState['ID'];
$this->arResult['DATA'][$element['ID']]["WORKFLOW_NAME"] = $documentState["TEMPLATE_NAME"];
$this->arResult['DATA'][$element['ID']]["WORKFLOW_STATE"] = $documentState["STATE_TITLE"];
$this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED"] = FormatDateFromDB($documentState["STARTED_FORMATTED"]);
$this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = "";
if (intval($documentState["STARTED_BY"]) > 0) {
$dbUserTmp = CUser::getByID($documentState["STARTED_BY"]);
$arUserTmp = $dbUserTmp->fetch();
$this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = CUser::FormatName($this->arParams["NAME_TEMPLATE"], $arUserTmp, true);
$this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] .= " [" . $documentState["STARTED_BY"] . "]";
}
$this->arResult['DATA'][$element['ID']]['MODULE_ID'] = $documentState["DOCUMENT_ID"][0];
$this->arResult['DATA'][$element['ID']]['ENTITY'] = $documentState["DOCUMENT_ID"][1];
$this->arResult['DATA'][$element['ID']]['DOCUMENT_ID'] = $documentState["DOCUMENT_ID"][2];
} else {
$documentState = false;
$this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = false;
}
}
foreach ($this->arResult['DATA'] as $data) {
if ($documentState) {
if ($useComments) {
$workflows[] = 'WF_' . $data['WORKFLOW_ID'];
}
}
$actions = array();
if (strlen($data["DOCUMENT_URL"]) > 0) {
$actions[] = array('ICONCLASS' => '', 'DEFAULT' => false, 'TEXT' => Loc::getMessage('CC_BLL_C_DOCUMENT'), 'ONCLICK' => 'window.open("' . $data["DOCUMENT_URL"] . '");');
}
$this->arResult['RECORDS'][] = array('data' => $data, 'actions' => $actions);
}
if ($useComments && $documentState) {
$workflows = array_unique($workflows);
if ($workflows) {
$iterator = CForumTopic::getList(array(), array("@XML_ID" => $workflows));
while ($row = $iterator->fetch()) {
$this->arResult["COMMENTS_COUNT"][$row['XML_ID']] = $row['POSTS'];
}
}
}
$this->arResult['COUNTERS'] = array('all' => 0);
$this->arResult["ROWS_COUNT"] = $elementObject->selectedRowsCount();
$this->arResult["NAV_RESULT"] = $elementObject;
if ($this->arParams['SET_TITLE'] == 'Y') {
$this->getApplication()->setTitle(Loc::getMessage('CC_BLL_TITLE'));
}
$this->includeComponentTemplate();
//.........这里部分代码省略.........
示例15: getProductIdsMap
/**
* Return converted product ids map. Additionally creates sku tree from input products.
* (see description form above).
*
* @param array $ids source product ids
*
* @return mixed[] array("MAP" => array(...), "TREE" => array(...))
*/
private function getProductIdsMap(array $ids = array())
{
if (empty($ids)) {
return array(array(), array());
}
$newIds = array();
$skuTree = array();
$catalogs = $this->data['CATALOG'];
foreach ($catalogs as $catalog) {
if ($catalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_OFFERS) {
$elementIterator = CIBlockElement::getList(array(), array("ID" => $ids, "IBLOCK_ID" => $catalog['IBLOCK_ID']), false, false, array("ID", "IBLOCK_ID", "PROPERTY_" . $catalog['SKU_PROPERTY_ID']));
while ($item = $elementIterator->fetch()) {
$propertyName = "PROPERTY_" . $catalog['SKU_PROPERTY_ID'] . "_VALUE";
$parentId = $item[$propertyName];
if (!empty($parentId)) {
$newIds[$item['ID']] = $parentId;
if (!isset($skuTree[$parentId])) {
$skuTree[$parentId] = array();
}
$skuTree[$parentId][] = $item['ID'];
} else {
$newIds[$item['ID']] = $item['ID'];
}
}
}
}
// Push missing
foreach ($ids as $id) {
if (!isset($newIds[$id])) {
$newIds[$id] = $id;
}
}
// Resort map
$tmpMap = array();
foreach ($ids as $id) {
$tmpMap[$id . ""] = $newIds[$id];
}
return array($tmpMap, $skuTree);
}