本文整理汇总了PHP中Bitrix\Main\Type\Collection类的典型用法代码示例。如果您正苦于以下问题:PHP Collection类的具体用法?PHP Collection怎么用?PHP Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processActionShowSubFolders
protected function processActionShowSubFolders()
{
if (!$this->checkRequiredPostParams(array('objectId'))) {
$this->sendJsonErrorResponse();
}
$showOnlyDeleted = (bool) $this->request->getPost('showOnlyDeleted');
$isRoot = (bool) $this->request->getPost('isRoot');
/** @var Folder $folder */
$folder = Folder::loadById((int) $this->request->getPost('objectId'), array('STORAGE'));
if (!$folder) {
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_BREADCRUMBS_ERROR_COULD_NOT_FIND_FOLDER'), self::ERROR_COULD_NOT_FIND_FOLDER)));
$this->sendJsonErrorResponse();
}
$securityContext = $folder->getStorage()->getCurrentUserSecurityContext();
$subFolders = array();
$filter = array('TYPE' => ObjectTable::TYPE_FOLDER);
if ($showOnlyDeleted) {
$filter['!=DELETED_TYPE'] = ObjectTable::DELETED_TYPE_NONE;
}
if ($showOnlyDeleted && $isRoot) {
$filter['DELETED_TYPE'] = ObjectTable::DELETED_TYPE_ROOT;
$children = $folder->getDescendants($securityContext, array('filter' => $filter));
} else {
$children = $folder->getChildren($securityContext, array('filter' => $filter));
}
foreach ($children as $subFolder) {
/** @var Folder $subFolder */
$subFolders[] = array('id' => $subFolder->getId(), 'name' => $subFolder->getName(), 'isLink' => $subFolder->isLink());
}
unset($subFolder);
\Bitrix\Main\Type\Collection::sortByColumn($subFolders, 'name');
$this->sendJsonSuccessResponse(array('items' => $subFolders));
}
示例2: getCurrentRatio
/**
* Return ratio for product list.
*
* @param array|int $product Product id list.
* @return array|bool
* @throws Main\ArgumentException
*/
public static function getCurrentRatio($product)
{
if (!is_array($product)) {
$product = array($product);
}
Main\Type\Collection::normalizeArrayValuesByInt($product, true);
if (empty($product)) {
return false;
}
$result = array_fill_keys($product, 1);
$ratioRows = array_chunk($product, 500);
foreach ($ratioRows as &$row) {
$ratioIterator = self::getList(array('select' => array('PRODUCT_ID', 'RATIO'), 'filter' => array('@PRODUCT_ID' => $row)));
while ($ratio = $ratioIterator->fetch()) {
$ratio['PRODUCT_ID'] = (int) $ratio['PRODUCT_ID'];
$ratioInt = (int) $ratio['RATIO'];
$ratioFloat = (double) $ratio['RATIO'];
$ratioResult = $ratioFloat > $ratioInt ? $ratioFloat : $ratioInt;
if (abs($ratioResult) < CATALOG_VALUE_EPSILON || $ratioResult < 0) {
continue;
}
$result[$ratio['PRODUCT_ID']] = $ratioResult;
}
unset($module, $moduleIterator);
}
unset($row, $ratioRows);
return $result;
}
示例3: getGridData
private function getGridData($gridId)
{
$grid = array('ID' => $gridId);
$securityContext = $this->storage->getCurrentUserSecurityContext();
$parameters = array('with' => array('FILE', 'CREATE_USER'), 'filter' => array('IS_EXPIRED' => false, 'OBJECT.STORAGE_ID' => $this->storage->getId(), 'CREATED_BY' => $this->getUser()->getId()));
$parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('OBJECT_ID', 'OBJECT.CREATED_BY'));
$items = ExternalLink::getModelList($parameters);
Collection::sortByColumn($items, array('CREATE_TIME' => array(SORT_NUMERIC, SORT_ASC)));
$urlManager = Driver::getInstance()->getUrlManager();
$rows = array();
foreach ($items as $externalLink) {
/** @var ExternalLink $externalLink */
$exportData = $externalLink->toArray();
$nameSpecialChars = htmlspecialcharsbx($externalLink->getFile()->getName());
$createDateText = htmlspecialcharsbx((string) $externalLink->getCreateTime());
$columnName = "\n\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$externalLink->getId()}\" class=\"draggable bx-file-icon-container-small bx-disk-file-icon\"></div></td>\n\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$externalLink->getId()}\" href=\"\" data-bx-dateModify=\"{$createDateText}\">{$nameSpecialChars}</a></td>\n\t\t\t\t</tr></table>\n\t\t\t";
$createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $externalLink->getCreatedBy()));
$rows[] = array('data' => $exportData, 'columns' => array('CREATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'UPDATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'NAME' => $columnName, 'FORMATTED_SIZE' => CFile::formatSize($externalLink->getFile()->getSize()), 'CREATE_USER' => "\n\t\t\t\t\t\t<div class=\"bx-disk-user-link\"><a target='_blank' href=\"{$createdByLink}\" id=\"\">" . htmlspecialcharsbx($externalLink->getCreateUser()->getFormattedName()) . "</a></div>\n\t\t\t\t\t"), 'actions' => array(array("PSEUDO_NAME" => "download", "DEFAULT" => true, "ICONCLASS" => "download", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DOWNLOAD'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $urlManager->getUrlForDownloadFile($externalLink->getFile()) . "')"), array("PSEUDO_NAME" => "disable_external_link", "ICONCLASS" => "disable_external_link", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK'), "SHORT_TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK_SHORT'), "ONCLICK" => "BX.Disk['ExternalLinkListClass_{$this->getComponentId()}'].disableExternalLink({$externalLink->getId()}, {$externalLink->getObjectId()})")));
}
unset($externalLink);
$grid['MODE'] = 'list';
$grid['HEADERS'] = array(array('id' => 'ID', 'name' => 'ID', 'default' => false, 'show_checkbox' => true), array('id' => 'NAME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_NAME'), 'default' => true), array('id' => 'CREATE_TIME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_TIME'), 'default' => true), array('id' => 'CREATE_USER', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_USER'), 'default' => false), array('id' => 'FORMATTED_SIZE', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_FORMATTED_SIZE'), 'default' => true));
$grid['ROWS'] = $rows;
$grid['ROWS_COUNT'] = count($rows);
$grid['FOOTER'] = array();
return $grid;
}
示例4: processActionGetListStorage
protected function processActionGetListStorage()
{
$this->checkRequiredPostParams(array('proxyType'));
if ($this->errorCollection->hasErrors()) {
$this->sendJsonErrorResponse();
}
$proxyTypePost = $this->request->getPost('proxyType');
$diskSecurityContext = $this->getSecurityContextByUser($this->getUser());
$siteId = null;
$siteDir = null;
if ($this->request->getPost('siteId')) {
$siteId = $this->request->getPost('siteId');
}
if ($this->request->getPost('siteDir')) {
$siteDir = rtrim($this->request->getPost('siteDir'), '/');
}
$result = array();
$filterReadableList = array();
$checkSiteId = false;
if ($proxyTypePost == 'user') {
$result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_USER_TITLE');
$filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\User::className());
} elseif ($proxyTypePost == 'group') {
$checkSiteId = true;
$result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_GROUP_TITLE');
$filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className());
}
foreach (Storage::getReadableList($diskSecurityContext, array('filter' => $filterReadableList)) as $storage) {
if ($checkSiteId) {
$groupObject = CSocNetGroup::getList(array(), array('ID' => $storage->getEntityId()), false, false, array('SITE_ID'));
$group = $groupObject->fetch();
if (!empty($group) && $group['SITE_ID'] != $siteId) {
continue;
}
}
$proxyType = $storage->getProxyType();
$result['DATA'][] = array("TITLE" => $proxyType->getEntityTitle(), "URL" => $siteDir . $proxyType->getBaseUrlFolderList(), "ICON" => $proxyType->getEntityImageSrc(64, 64));
}
if (!empty($result['DATA'])) {
Collection::sortByColumn($result['DATA'], array('TITLE' => SORT_ASC));
$this->sendJsonSuccessResponse(array('listStorage' => $result['DATA'], 'title' => $result['TITLE']));
} else {
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_AGGREGATOR_ERROR_COULD_NOT_FIND_DATA'))));
$this->sendJsonErrorResponse();
}
}
示例5: AppyUserSettings
protected static function AppyUserSettings($suffix)
{
$arAuthServices = self::$arAuthServices;
//user settings: sorting, active
$arServices = unserialize(COption::GetOptionString("socialservices", "auth_services" . $suffix, ""));
if (is_array($arServices)) {
$i = 0;
foreach ($arServices as $serv => $active) {
if (isset($arAuthServices[$serv])) {
$arAuthServices[$serv]["__sort"] = $i++;
$arAuthServices[$serv]["__active"] = $active == "Y";
}
}
\Bitrix\Main\Type\Collection::sortByColumn($arAuthServices, "__sort");
}
return $arAuthServices;
}
示例6: __construct
protected function __construct()
{
$event = new Main\Event("main", "OnApplicationsBuildList");
$event->send();
foreach ($event->getResults() as $eventResult) {
$result = $eventResult->getParameters();
if (is_array($result)) {
if (!is_array($result[0])) {
$result = array($result);
}
foreach ($result as $app) {
$this->applications[$app["ID"]] = $app;
}
}
}
Main\Type\Collection::sortByColumn($this->applications, "SORT");
}
示例7: fixColdStart
/**
* Fixes cold start, when we don't have any data in RecentlyUsedTable.
* @param mixed|int|User|\CAllUser $user User.
* @return bool
* @throws \Bitrix\Main\ArgumentException
*/
private function fixColdStart($user)
{
$userId = User::resolveUserId($user);
if (!$userId) {
$this->errorCollection->addOne(new Error('Could not get user id.'));
return false;
}
$storage = Driver::getInstance()->getStorageByUserId($userId);
if (!$storage) {
$this->errorCollection->addOne(new Error('Could not get storage by user id.'));
return false;
}
$fromDate = DateTime::createFromTimestamp(time() - 14 * 24 * 3600);
$objects = array();
$query = FileTable::getList(array('select' => array('ID', 'UPDATE_TIME'), 'filter' => array('STORAGE_ID' => $storage->getId(), 'TYPE' => ObjectTable::TYPE_FILE, 'DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE, '>UPDATE_TIME' => $fromDate, array('LOGIC' => 'OR', array('CREATED_BY' => $userId), array('UPDATED_BY' => $userId))), 'order' => array('UPDATE_TIME' => 'DESC'), 'limit' => RecentlyUsedTable::MAX_COUNT_FOR_USER));
while ($row = $query->fetch()) {
$objects[] = array('USER_ID' => $userId, 'OBJECT_ID' => $row['ID'], 'CREATE_TIME' => $row['UPDATE_TIME']);
}
unset($row, $query, $fromDate);
Collection::sortByColumn($objects, array('CREATE_TIME' => SORT_ASC));
RecentlyUsedTable::insertBatch($objects);
return true;
}
示例8: __AddPropCellType
function __AddPropCellType($intOFPropID, $strPrefix, $arPropInfo)
{
static $arUserTypeList = null;
if ($arUserTypeList === null) {
$arUserTypeList = CIBlockProperty::GetUserType();
\Bitrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
}
$boolUserPropExist = !empty($arUserTypeList);
ob_start();
?>
<select name="<?php
echo $strPrefix . $intOFPropID;
?>
_PROPERTY_TYPE" id="<?php
echo $strPrefix . $intOFPropID;
?>
_PROPERTY_TYPE" style="width:150px"><?php
if ($boolUserPropExist) {
?>
<optgroup label="<?php
echo GetMessage('IB_E_PROP_BASE_TYPE_GROUP');
?>
"><?php
}
?>
<option value="S" <?php
if ($arPropInfo['PROPERTY_TYPE'] == "S" && !$arPropInfo['USER_TYPE']) {
echo " selected";
}
?>
><?php
echo GetMessage("IB_E_PROP_TYPE_S");
?>
</option>
<option value="N" <?php
if ($arPropInfo['PROPERTY_TYPE'] == "N" && !$arPropInfo['USER_TYPE']) {
echo " selected";
}
?>
><?php
echo GetMessage("IB_E_PROP_TYPE_N");
?>
</option>
<option value="L" <?php
if ($arPropInfo['PROPERTY_TYPE'] == "L" && !$arPropInfo['USER_TYPE']) {
echo " selected";
}
?>
><?php
echo GetMessage("IB_E_PROP_TYPE_L");
?>
</option>
<option value="F" <?php
if ($arPropInfo['PROPERTY_TYPE'] == "F" && !$arPropInfo['USER_TYPE']) {
echo " selected";
}
?>
><?php
echo GetMessage("IB_E_PROP_TYPE_F");
?>
</option>
<option value="G" <?php
if ($arPropInfo['PROPERTY_TYPE'] == "G" && !$arPropInfo['USER_TYPE']) {
echo " selected";
}
?>
><?php
echo GetMessage("IB_E_PROP_TYPE_G");
?>
</option>
<option value="E" <?php
if ($arPropInfo['PROPERTY_TYPE'] == "E" && !$arPropInfo['USER_TYPE']) {
echo " selected";
}
?>
><?php
echo GetMessage("IB_E_PROP_TYPE_E");
?>
</option>
<?php
if ($boolUserPropExist) {
?>
</optgroup><optgroup label="<?php
echo GetMessage('IB_E_PROP_USER_TYPE_GROUP');
?>
"><?php
}
foreach ($arUserTypeList as $ar) {
?>
<option value="<?php
echo htmlspecialcharsbx($ar["PROPERTY_TYPE"] . ":" . $ar["USER_TYPE"]);
?>
" <?php
if ($arPropInfo['PROPERTY_TYPE'] == $ar["PROPERTY_TYPE"] && $arPropInfo['USER_TYPE'] == $ar["USER_TYPE"]) {
echo " selected";
}
?>
><?php
echo htmlspecialcharsbx($ar["DESCRIPTION"]);
?>
//.........这里部分代码省略.........
示例9: array
$arItem['OFFERS'][$keyOffer]['TREE'] = array();
$arItem['OFFERS'][$keyOffer]['TREE']['PROP_'.$arSKUPropList[$strOneCode]['ID']] = $arMatrix[$keyOffer][$strOneCode]['VALUE'];
$arItem['OFFERS'][$keyOffer]['SKU_SORT_'.$strOneCode] = $arMatrix[$keyOffer][$strOneCode]['SORT'];
$arUsedFields[$strOneCode] = true;
$arSortFields['SKU_SORT_'.$strOneCode] = SORT_NUMERIC;
}
else
{
unset($arMatrix[$keyOffer][$strOneCode]);
}
}
}
$arItem['OFFERS_PROP'] = $arUsedFields;
$arItem['OFFERS_PROP_CODES'] = (!empty($arUsedFields) ? base64_encode(serialize(array_keys($arUsedFields))) : '');
Collection::sortByColumn($arItem['OFFERS'], $arSortFields);
$arMatrix = array();
$intSelected = -1;
$arItem['MIN_PRICE'] = false;
$arItem['MIN_BASIS_PRICE'] = false;
foreach ($arItem['OFFERS'] as $keyOffer => $arOffer)
{
if (empty($arItem['MIN_PRICE']) && $arOffer['CAN_BUY'])
{
$intSelected = $keyOffer;
$arItem['MIN_PRICE'] = (isset($arOffer['RATIO_PRICE']) ? $arOffer['RATIO_PRICE'] : $arOffer['MIN_PRICE']);
$arItem['MIN_BASIS_PRICE'] = $arOffer['MIN_PRICE'];
}
$arSKUProps = false;
if (!empty($arOffer['DISPLAY_PROPERTIES']))
示例10: CheckFields
//.........这里部分代码省略.........
if (!self::prepareDiscountConditions($discountInfo['CONDITIONS'], $discountInfo['UNPACK'], $conditionData, self::PREPARE_CONDITIONS, $discountInfo['LID'])) {
return false;
}
} else {
return false;
}
}
if (!$useActions) {
$rsDiscounts = CSaleDiscount::GetList(array(), array('ID' => $discountID), false, false, array('ID', 'ACTIONS', 'LID'));
if ($discountInfo = $rsDiscounts->Fetch()) {
$discountInfo['APPLICATION'] = '';
if (!self::prepareDiscountConditions($discountInfo['ACTIONS'], $discountInfo['APPLICATION'], $actionData, self::PREPARE_ACTIONS, $discountInfo['LID'])) {
return false;
}
} else {
return false;
}
}
if (!empty($conditionData['HANDLERS']) || !empty($actionData['HANDLERS'])) {
if (!empty($conditionData['HANDLERS'])) {
$usedHandlers = $conditionData['HANDLERS'];
}
if (!empty($actionData['HANDLERS'])) {
if (empty($usedHandlers)) {
$usedHandlers = $actionData['HANDLERS'];
} else {
$usedHandlers['MODULES'] = array_unique(array_merge($usedHandlers['MODULES'], $actionData['HANDLERS']['MODULES']));
$usedHandlers['EXT_FILES'] = array_unique(array_merge($usedHandlers['EXT_FILES'], $actionData['HANDLERS']['EXT_FILES']));
}
}
}
if (!empty($conditionData['EXECUTE_MODULE']) || !empty($actionData['EXECUTE_MODULE'])) {
$executeModuleList = array();
if (!empty($conditionData['EXECUTE_MODULE'])) {
$executeModuleList = $conditionData['EXECUTE_MODULE'];
}
if (!empty($actionData['EXECUTE_MODULE'])) {
$executeModuleList = empty($executeModuleList) ? $actionData['EXECUTE_MODULE'] : array_merge($executeModuleList, $actionData['EXECUTE_MODULE']);
}
$executeModuleList = array_unique($executeModuleList);
if (count($executeModuleList) > 1) {
$APPLICATION->ThrowException(Loc::getMessage('BX_SALE_DISC_ERR_MULTIPLE_EXECUTE_MODULE'), 'DISCOUNT');
return false;
}
$executeModule = current($executeModuleList);
unset($executeModuleList);
}
if (!empty($conditionData['ENTITY']) || !empty($actionData['ENTITY'])) {
if (!empty($conditionData['ENTITY'])) {
$usedEntities = $conditionData['ENTITY'];
}
if (!empty($actionData['ENTITY'])) {
$usedEntities = empty($usedEntities) ? $actionData['ENTITY'] : array_merge($usedEntities, $actionData['ENTITY']);
}
}
}
if ($ACTION == 'ADD' && $executeModule == '') {
$executeModule = 'all';
}
if ($executeModule != '') {
$arFields['EXECUTE_MODULE'] = $executeModule;
}
if (!empty($usedHandlers)) {
$arFields['HANDLERS'] = $usedHandlers;
}
if (!empty($usedEntities)) {
$arFields['ENTITIES'] = $usedEntities;
}
if ((is_set($arFields, 'USE_COUPONS') || $ACTION == 'ADD') && 'Y' != $arFields['USE_COUPONS']) {
$arFields['USE_COUPONS'] = 'N';
}
if (array_key_exists('USER_GROUPS', $arFields) || $ACTION == "ADD") {
Collection::normalizeArrayValuesByInt($arFields['USER_GROUPS']);
if (empty($arFields['USER_GROUPS']) || !is_array($arFields['USER_GROUPS'])) {
$APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_USER_GROUPS_ABSENT_SHORT"), "USER_GROUPS");
return false;
}
}
$intUserID = 0;
$boolUserExist = isset($USER) && $USER instanceof CUser;
if ($boolUserExist) {
$intUserID = (int) $USER->GetID();
}
$strDateFunction = $DB->GetNowFunction();
$arFields['~TIMESTAMP_X'] = $strDateFunction;
if ($boolUserExist) {
if (!array_key_exists('MODIFIED_BY', $arFields) || (int) $arFields["MODIFIED_BY"] <= 0) {
$arFields["MODIFIED_BY"] = $intUserID;
}
}
if ($ACTION == 'ADD') {
$arFields['~DATE_CREATE'] = $strDateFunction;
if ($boolUserExist) {
if (!array_key_exists('CREATED_BY', $arFields) || (int) $arFields["CREATED_BY"] <= 0) {
$arFields["CREATED_BY"] = $intUserID;
}
}
}
return true;
}
示例11: intval
<tr>
<td width="40%">ID:</td>
<td width="60%"><?php
echo 0 < intval($arProperty['ID']) ? $arProperty['ID'] : GetMessage("BT_ADM_IEP_PROP_NEW");
?>
</td>
</tr>
<tr>
<td width="40%"><?php
echo GetMessage('BT_ADM_IEP_PROPERTY_TYPE');
?>
</td>
<td width="60%">
<?php
$arUserTypeList = CIBlockProperty::GetUserType();
\Bitrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
$boolUserPropExist = !empty($arUserTypeList);
?>
<select name="PROPERTY_PROPERTY_TYPE" onchange="reloadForm();">
<?php
if ($boolUserPropExist) {
?>
<optgroup label="<?php
echo GetMessage('BT_ADM_IEP_PROPERTY_BASE_TYPE_GROUP');
?>
"><?php
}
?>
<option value="S" <?php
if ($PROPERTY_TYPE == "S") {
echo " selected";
示例12: foreach
foreach ($arMatrix as $keyOffer => $arRow) {
if ($boolExist) {
if (!isset($arItem['OFFERS'][$keyOffer]['TREE'])) {
$arItem['OFFERS'][$keyOffer]['TREE'] = array();
}
$arItem['OFFERS'][$keyOffer]['TREE']['PROP_' . $arSKUPropList[$strOneCode]['ID']] = $arMatrix[$keyOffer][$strOneCode]['VALUE'];
$arItem['OFFERS'][$keyOffer]['SKU_SORT_' . $strOneCode] = $arMatrix[$keyOffer][$strOneCode]['SORT'];
$arUsedFields[$strOneCode] = true;
$arSortFields['SKU_SORT_' . $strOneCode] = SORT_NUMERIC;
} else {
unset($arMatrix[$keyOffer][$strOneCode]);
}
}
}
$arItem['OFFERS_PROP'] = $arUsedFields;
\Bitrix\Main\Type\Collection::sortByColumn($arItem['OFFERS'], $arSortFields);
// Find Selected offer
foreach ($arItem['OFFERS'] as $ind => $offer) {
if ($offer['SELECTED']) {
$arItem['OFFERS_SELECTED'] = $ind;
break;
}
}
$arMatrix = array();
$intSelected = -1;
$arItem['MIN_PRICE'] = false;
/*foreach ($arItem['OFFERS'] as $keyOffer => $arOffer)
{
if (empty($arItem['MIN_PRICE']) && $arOffer['CAN_BUY'])
{
$intSelected = $keyOffer;
示例13: ImportTemplate
public static function ImportTemplate($id, $documentType, $autoExecute, $name, $description, $datum, $systemCode = null, $systemImport = false)
{
$id = intval($id);
if ($id <= 0) {
$id = 0;
}
$datumTmp = CheckSerializedData($datum) ? @unserialize($datum) : null;
if (!is_array($datumTmp) || is_array($datumTmp) && !array_key_exists("TEMPLATE", $datumTmp)) {
if (function_exists("gzcompress")) {
$datumTmp = @gzuncompress($datum);
$datumTmp = CheckSerializedData($datumTmp) ? @unserialize($datumTmp) : null;
}
}
if (!is_array($datumTmp) || is_array($datumTmp) && !array_key_exists("TEMPLATE", $datumTmp)) {
throw new Exception(GetMessage("BPCGWTL_WRONG_TEMPLATE"));
}
if (array_key_exists("VERSION", $datumTmp) && $datumTmp["VERSION"] == 2) {
$datumTmp["TEMPLATE"] = self::ConvertArrayCharset($datumTmp["TEMPLATE"], BP_EI_DIRECTION_IMPORT);
$datumTmp["PARAMETERS"] = self::ConvertArrayCharset($datumTmp["PARAMETERS"], BP_EI_DIRECTION_IMPORT);
$datumTmp["VARIABLES"] = self::ConvertArrayCharset($datumTmp["VARIABLES"], BP_EI_DIRECTION_IMPORT);
$datumTmp["CONSTANTS"] = isset($datumTmp["CONSTANTS"]) ? self::ConvertArrayCharset($datumTmp["CONSTANTS"], BP_EI_DIRECTION_IMPORT) : array();
$datumTmp["DOCUMENT_FIELDS"] = self::ConvertArrayCharset($datumTmp["DOCUMENT_FIELDS"], BP_EI_DIRECTION_IMPORT);
}
if (!$systemImport) {
if (!self::WalkThroughWorkflowTemplate($datumTmp["TEMPLATE"], array("CBPWorkflowTemplateLoader", "ImportTemplateChecker"), new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser))) {
return false;
}
} elseif ($id > 0 && !empty($datumTmp["CONSTANTS"])) {
$userConstants = self::getTemplateConstants($id);
if (!empty($userConstants)) {
foreach ($userConstants as $constantName => $constantData) {
if (isset($datumTmp["CONSTANTS"][$constantName])) {
$datumTmp["CONSTANTS"][$constantName]['Default'] = $constantData['Default'];
}
}
}
}
$templateData = array("DOCUMENT_TYPE" => $documentType, "AUTO_EXECUTE" => $autoExecute, "NAME" => $name, "DESCRIPTION" => $description, "TEMPLATE" => $datumTmp["TEMPLATE"], "PARAMETERS" => $datumTmp["PARAMETERS"], "VARIABLES" => $datumTmp["VARIABLES"], "CONSTANTS" => $datumTmp["CONSTANTS"], "USER_ID" => $systemImport ? 1 : $GLOBALS["USER"]->GetID(), "MODIFIER_USER" => new CBPWorkflowTemplateUser($systemImport ? 1 : CBPWorkflowTemplateUser::CurrentUser));
if (!is_null($systemCode)) {
$templateData["SYSTEM_CODE"] = $systemCode;
}
if ($id <= 0) {
$templateData['ACTIVE'] = 'Y';
}
if ($id > 0) {
self::Update($id, $templateData, $systemImport);
} else {
$id = self::Add($templateData, $systemImport);
}
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
$documentService = $runtime->GetService("DocumentService");
$arDocumentFields = $documentService->GetDocumentFields($documentType);
if (is_array($datumTmp["DOCUMENT_FIELDS"])) {
$len = strlen("_PRINTABLE");
$arFieldsTmp = array();
foreach ($datumTmp["DOCUMENT_FIELDS"] as $code => $field) {
if (!array_key_exists($code, $arDocumentFields) && strtoupper(substr($code, -$len)) != "_PRINTABLE") {
$arFieldsTmp[$code] = array("name" => $field["Name"], "code" => $code, "type" => $field["Type"], "multiple" => $field["Multiple"], "required" => $field["Required"]);
if (is_array($field["Options"]) && count($field["Options"]) > 0) {
foreach ($field["Options"] as $k => $v) {
$arFieldsTmp[$code]["options"] .= "[" . $k . "]" . $v . "\n";
}
}
unset($field["Name"], $field["Type"], $field["Multiple"], $field["Required"], $field["Options"]);
$arFieldsTmp[$code] = array_merge($arFieldsTmp[$code], $field);
}
}
if (!empty($arFieldsTmp)) {
\Bitrix\Main\Type\Collection::sortByColumn($arFieldsTmp, "sort");
foreach ($arFieldsTmp as $fieldTmp) {
$documentService->AddDocumentField($documentType, $fieldTmp);
}
}
}
return $id;
}
示例14: saveApplied
/**
* Save coupons applyed info.
*
* @param array $coupons Coupons list.
* @param int $userId User id.
* @param Main\Type\DateTime $currentTime Current datetime.
* @return array|bool
*/
public static function saveApplied($coupons, $userId, Main\Type\DateTime $currentTime)
{
$currentTimestamp = $currentTime->getTimestamp();
if ($userId === null || (int) $userId == 0) {
return false;
}
$userId = (int) $userId;
if (!is_array($coupons)) {
$coupons = array($coupons);
}
if (empty($coupons)) {
return false;
}
Main\Type\Collection::normalizeArrayValuesByInt($coupons);
if (empty($coupons)) {
return false;
}
$deactivateCoupons = array();
$incrementalCoupons = array();
$limitedCoupons = array();
$couponIterator = self::getList(array('select' => array('ID', 'COUPON', 'DISCOUNT_ID', 'TYPE', 'ACTIVE', 'MAX_USE', 'USE_COUNT', 'USER_ID', 'ACTIVE_TO', 'ACTIVE_FROM', 'DISCOUNT_ACTIVE' => 'DISCOUNT.ACTIVE', 'DISCOUNT_ACTIVE_FROM' => 'DISCOUNT.ACTIVE_FROM', 'DISCOUNT_ACTIVE_TO' => 'DISCOUNT.ACTIVE_TO'), 'filter' => array('@ID' => $coupons, '=ACTIVE' => 'Y'), 'order' => array('ID' => 'ASC')));
while ($existCoupon = $couponIterator->fetch()) {
if ($existCoupon['DISCOUNT_ACTIVE'] != 'Y') {
continue;
}
if ($existCoupon['DISCOUNT_ACTIVE_FROM'] instanceof Main\Type\DateTime && $existCoupon['DISCOUNT_ACTIVE_FROM']->getTimestamp() > $currentTimestamp || $existCoupon['DISCOUNT_ACTIVE_TO'] instanceof Main\Type\DateTime && $existCoupon['DISCOUNT_ACTIVE_TO']->getTimestamp() < $currentTimestamp) {
continue;
}
$existCoupon['USER_ID'] = (int) $existCoupon['USER_ID'];
if ($existCoupon['USER_ID'] > 0 && $existCoupon['USER_ID'] != $userId) {
continue;
}
if ($existCoupon['ACTIVE_FROM'] instanceof Main\Type\DateTime && $existCoupon['ACTIVE_FROM']->getTimestamp() > $currentTimestamp || $existCoupon['ACTIVE_TO'] instanceof Main\Type\DateTime && $existCoupon['ACTIVE_TO']->getTimestamp() < $currentTimestamp) {
continue;
}
if ($existCoupon['TYPE'] == self::TYPE_BASKET_ROW || $existCoupon['TYPE'] == self::TYPE_ONE_ORDER) {
$deactivateCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
} elseif ($existCoupon['TYPE'] == self::TYPE_MULTI_ORDER) {
$existCoupon['MAX_USE'] = (int) $existCoupon['MAX_USE'];
$existCoupon['USE_COUNT'] = (int) $existCoupon['USE_COUNT'];
if ($existCoupon['MAX_USE'] > 0 && $existCoupon['USE_COUNT'] >= $existCoupon['MAX_USE']) {
continue;
}
if ($existCoupon['MAX_USE'] > 0 && $existCoupon['USE_COUNT'] >= $existCoupon['MAX_USE'] - 1) {
$limitedCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
} else {
$incrementalCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
}
}
}
unset($existCoupon, $couponIterator, $coupons);
if (!empty($deactivateCoupons) || !empty($limitedCoupons) || !empty($incrementalCoupons)) {
$conn = Application::getConnection();
$helper = $conn->getSqlHelper();
$tableName = $helper->quote(self::getTableName());
if (!empty($deactivateCoupons)) {
$conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('ACTIVE') . ' = \'N\', ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $deactivateCoupons) . ')');
}
if (!empty($incrementalCoupons)) {
$conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ', ' . $helper->quote('USE_COUNT') . ' = ' . $helper->quote('USE_COUNT') . ' + 1' . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $incrementalCoupons) . ')');
}
if (!empty($limitedCoupons)) {
$conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ', ' . $helper->quote('ACTIVE') . ' = \'N\', ' . $helper->quote('USE_COUNT') . ' = ' . $helper->quote('USE_COUNT') . ' + 1' . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $limitedCoupons) . ')');
}
unset($tableName, $helper);
}
return array('DEACTIVATE' => $deactivateCoupons, 'LIMITED' => $limitedCoupons, 'INCREMENT' => $incrementalCoupons);
}
示例15: array
if ($arParams["SET_META_KEYWORDS"] === 'Y')
{
$metaKeywords = Collection::firstNotEmpty(
$arResult["PROPERTIES"], array($arParams["META_KEYWORDS"], "VALUE")
,$arResult["IPROPERTY_VALUES"], "ELEMENT_META_KEYWORDS"
);
if (is_array($metaKeywords))
$APPLICATION->SetPageProperty("keywords", implode(" ", $metaKeywords), $arTitleOptions);
elseif ($metaKeywords != "")
$APPLICATION->SetPageProperty("keywords", $metaKeywords, $arTitleOptions);
}
if ($arParams["SET_META_DESCRIPTION"] === 'Y')
{
$metaDescription = Collection::firstNotEmpty(
$arResult["PROPERTIES"], array($arParams["META_DESCRIPTION"], "VALUE")
,$arResult["IPROPERTY_VALUES"], "ELEMENT_META_DESCRIPTION"
);
if (is_array($metaDescription))
$APPLICATION->SetPageProperty("description", implode(" ", $metaDescription), $arTitleOptions);
elseif ($metaDescription != "")
$APPLICATION->SetPageProperty("description", $metaDescription, $arTitleOptions);
}
if ($arParams["ADD_SECTIONS_CHAIN"] && !empty($arResult["SECTION"]["PATH"]) && is_array($arResult["SECTION"]["PATH"]))
{
foreach($arResult["SECTION"]["PATH"] as $arPath)
{
if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "")
$APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
else
$APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);