本文整理汇总了PHP中CIBlockSection::ReSort方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockSection::ReSort方法的具体用法?PHP CIBlockSection::ReSort怎么用?PHP CIBlockSection::ReSort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockSection
的用法示例。
在下文中一共展示了CIBlockSection::ReSort方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importSection
private function importSection($arItems, $IBLOCK_ID = 0, $event = 'section')
{
if (!$IBLOCK_ID)
{
$IBLOCK_ID = $this->CATALOG_ID;
}
static $arResult = array();
$arChild = array();
foreach ($arItems as $arItem)
{
if (!strlen($arItem['XML_ID']))
{
throw new \Exception('Empty section XML ID '.$arItem['name']);
}
if (!strlen($arItem['CODE']))
{
$arItem['CODE'] = \CUtil::translit($arItem['NAME'], 'ru', array(
"replace_space" => '-',
"replace_other" => '-'
));
}
$arFields = array(
'ACTIVE' => $arItem['ACTIVE'],
'CODE' => $arItem['CODE'],
'NAME' => $arItem['NAME'],
'XML_ID' => $arItem['XML_ID'],
'TIMESTAMP_X' => new DateTime
);
$arSection = $this->getSectionByXML($arItem['XML_ID'], $IBLOCK_ID);
if ($arSection['ID'] > 0)
{
// если раздел существует, сравним хэши
if (!App::compareHash($arItem) || $arItem['ACTIVE'] !== $arSection['ACTIVE'])
{
// если хэши не совпали, то проапдейтим найденый раздел
SectionTable::update($arSection['ID'], $arFields);
Report::update($event);
}
}
else
{
if (strlen($arItem['SECTION_XML_ID']) > 0)
{
$arParent = $this->getSectionByXML($arItem['SECTION_XML_ID'], $IBLOCK_ID);
if (!$arParent['ID'])
{
// тут хитрая штука, если дочерний раздел идет раньше родителя,
// то и создать его нужно позже, чуть ниже вызывается рекурсия
$arChild[] = $arItem;
continue;
}
// если он есть, то текущий раздел сделаем потомком
$arFields['IBLOCK_SECTION_ID'] = $arParent['ID'];
}
$arFields = array_merge($arFields, array(
'IBLOCK_ID' => $IBLOCK_ID,
'DESCRIPTION_TYPE' => 'text'
));
$arSection['ID'] = SectionTable::add($arFields)->getId();
App::compareHash($arItem);
Report::create($event);
}
// если раздел не нашли и не создали, выплюнем эксепшен
if (!$arSection['ID'])
{
throw new \Exception('Cant create sections');
}
$arResult[$arItem['XML_ID']] = $arSection['ID'];
}
if (!empty($arChild))
{
$this->importSection($arChild, $IBLOCK_ID, $event);
}
\CIBlockSection::ReSort($IBLOCK_ID);
return $arResult;
}
示例2: DeleteCategory
function DeleteCategory($ID)
{
$iblock_permission = CIBlock::GetPermission(IBLOCK_ID);
if ($iblock_permission < "W") {
$GLOBALS["USER"]->RequiredHTTPAuthBasic();
return new CSOAPFault('Server Error', 'Unable to authorize user.');
}
$ib_section = new CIBlockSection();
if ($ib_section->Delete($ID)) {
CIBlockSection::ReSort();
return 1;
}
return new CSOAPFault('Server Error', 'Error: ' . $ib_section->LAST_ERROR);
}
示例3: createAlbum
/**
* Creates new section in iblock
* @param $arParams
* @param $arResult
* @param $name
* @return bool|int
*/
public static function createAlbum($arParams, $arResult, &$name)
{
if (!CModule::IncludeModule("iblock")) {
return false;
}
$name = trim($name);
$name = strlen($name) > 0 ? $name : GetMessage("P_NEW_ALBUM");
$name = strlen($name) > 0 ? $name : "New album";
$arFields = array("ACTIVE" => "Y", "IBLOCK_ID" => $arParams["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $arParams["BEHAVIOUR"] == "USER" ? $arResult["GALLERY"]["ID"] : 0, "DATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset()), "UF_DATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset()), "NAME" => $name);
$GLOBALS["UF_DATE"] = $arFields["UF_DATE"];
$bs = new CIBlockSection();
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", $arFields);
$ID = $bs->Add($arFields);
if ($ID > 0) {
CIBlockSection::ReSort($arParams["IBLOCK_ID"]);
$arPropertiesNeed = array();
// Array of properties to create
foreach ($arParams['converters'] as $val) {
if ($val['code'] == "real_picture" || $val['code'] == "thumbnail") {
continue;
}
$db_res = CIBlock::GetProperties($arParams["IBLOCK_ID"], array(), array("CODE" => $val['code']));
if (!($db_res && ($res = $db_res->Fetch()))) {
$arPropertiesNeed[] = $val['code'];
}
}
if (count($arPropertiesNeed) > 0) {
$obProperty = new CIBlockProperty();
foreach ($arPropertiesNeed as $key) {
$res = $obProperty->Add(array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "PROPERTY_TYPE" => "F", "MULTIPLE" => "N", "NAME" => strLen(GetMessage("P_" . strToUpper($key))) > 0 ? GetMessage("P_" . strToUpper($key)) : strToUpper($key), "CODE" => strToUpper($key), "FILE_TYPE" => "jpg, gif, bmp, png, jpeg"));
}
}
// Check Public property
$arPropertiesNeed = array();
foreach (array("PUBLIC_ELEMENT", "APPROVE_ELEMENT") as $key) {
$db_res = CIBlock::GetProperties($arParams["IBLOCK_ID"], array(), array("CODE" => $key));
if (!$db_res || !($res = $db_res->Fetch())) {
$arPropertiesNeed[] = $key;
}
}
if (count($arPropertiesNeed) > 0) {
$obProperty = new CIBlockProperty();
foreach ($arPropertiesNeed as $key) {
$obProperty->Add(array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "PROPERTY_TYPE" => "S", "MULTIPLE" => "N", "NAME" => strLen(GetMessage("P_" . $key)) > 0 ? GetMessage("P_" . $key) : $key, "DEFAULT_VALUE" => "N", "CODE" => $key));
}
}
}
return $ID > 0 ? $ID : false;
}
示例4: SectionsResort
function SectionsResort()
{
CIBlockSection::ReSort($this->next_step["IBLOCK_ID"]);
}
示例5: array
if ($arParams["BEHAVIOUR"] == "USER" && intVal($arResult["SECTION"]["IBLOCK_SECTION_ID"]) == intVal($arResult["GALLERY"]["ID"])) {
$arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~GALLERY_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"]));
} elseif (intVal($arResult["SECTION"]["IBLOCK_SECTION_ID"]) > 0) {
$arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~SECTION_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $arResult["SECTION"]["IBLOCK_SECTION_ID"]));
} else {
$arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~INDEX_URL"], array());
}
$arResultFields = array("ID" => $arResult["SECTION"]["ID"], "error" => "", "url" => $arResult["URL"]);
} elseif ($e = $APPLICATION->GetException()) {
$strWarning .= $e->GetString();
} else {
$strWarning .= GetMessage("IBSEC_A_DELERR_REFERERS");
}
}
if (!$bVarsFromForm) {
CIBlockSection::ReSort($arParams["IBLOCK_ID"]);
PClearComponentCache(array("search.page", "search.tags.cloud", "photogallery.detail", "photogallery.detail.comment", "photogallery.detail.edit", "photogallery.detail.list", "photogallery.gallery.edit", "photogallery.gallery.list", "photogallery.section", "photogallery.section.edit", "photogallery.section.edit.icon", "photogallery.section.list", "photogallery.upload", "photogallery.user"));
if ($arParams["AJAX_CALL"] == "Y") {
$APPLICATION->RestartBuffer();
echo CUtil::PhpToJSObject($arResultFields);
die;
} else {
LocalRedirect($arResult["URL"]);
}
}
$arResult["ERROR_MESSAGE"] = $strWarning;
}
/********************************************************************
/Actions
********************************************************************/
/********************************************************************
示例6: ReSort
function ReSort($IBLOCK_ID, $ID = 0, $cnt = 0, $depth = 0, $ACTIVE = "Y")
{
global $DB;
$IBLOCK_ID = IntVal($IBLOCK_ID);
if ($ID > 0) {
$DB->Query("\n\t\t\t\tUPDATE\n\t\t\t\t\tb_iblock_section\n\t\t\t\tSET\n\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t,RIGHT_MARGIN=" . IntVal($cnt) . "\n\t\t\t\t\t,LEFT_MARGIN=" . IntVal($cnt) . "\n\t\t\t\tWHERE\n\t\t\t\t\tID=" . IntVal($ID));
}
$strSql = "\n\t\t\tSELECT BS.ID, BS.ACTIVE\n\t\t\tFROM b_iblock_section BS\n\t\t\tWHERE BS.IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t\tAND " . ($ID > 0 ? "BS.IBLOCK_SECTION_ID=" . IntVal($ID) : "BS.IBLOCK_SECTION_ID IS NULL") . "\n\t\t\tORDER BY BS.SORT, BS.NAME\n\t\t";
$cnt++;
$res = $DB->Query($strSql);
while ($arr = $res->Fetch()) {
$cnt = CIBlockSection::ReSort($IBLOCK_ID, $arr["ID"], $cnt, $depth + 1, $ACTIVE == "Y" && $arr["ACTIVE"] == "Y" ? "Y" : "N");
}
if ($ID == 0) {
$obIBlockRights = new CIBlockRights($IBLOCK_ID);
$obIBlockRights->Recalculate();
return true;
}
$DB->Query("\n\t\t\tUPDATE\n\t\t\t\tb_iblock_section\n\t\t\tSET\n\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t,RIGHT_MARGIN=" . IntVal($cnt) . "\n\t\t\t\t,DEPTH_LEVEL=" . IntVal($depth) . "\n\t\t\t\t,GLOBAL_ACTIVE='" . $ACTIVE . "'\n\t\t\tWHERE\n\t\t\t\tID=" . IntVal($ID));
return $cnt + 1;
}
示例7: GetAlbumId
function GetAlbumId($Params)
{
$arParams = $Params['arParams'];
$sectionId = false;
$savedData = CImageUploader::GetSavedData();
$arResult = $Params['~arResult'];
if ($savedData['SECTION_ID'] <= 0) {
// Upload photos to existing album
if ($Params['id'] !== 'new' && intVal($Params['id']) > 0) {
$sectionId = intVal($Params['id']);
} else {
if ($Params['id'] == 'new') {
$Params['name'] = trim($Params['name']);
if (empty($Params['name'])) {
$Params['name'] = strLen(GetMessage("P_NEW_ALBUM")) > 0 ? GetMessage("P_NEW_ALBUM") : "New album";
}
$arFields = array("ACTIVE" => "Y", "IBLOCK_ID" => $arParams["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $arParams["BEHAVIOUR"] == "USER" ? $arResult["GALLERY"]["ID"] : 0, "DATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset()), "UF_DATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset()), "NAME" => $Params['name']);
$GLOBALS["UF_DATE"] = $arFields["UF_DATE"];
$bs = new CIBlockSection();
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", $arFields);
$ID = $bs->Add($arFields);
if ($ID > 0) {
CIBlockSection::ReSort($arParams["IBLOCK_ID"]);
$sectionId = intVal($ID);
$arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "CODE" => $arParams["USER_ALIAS"], "SECTION_ID" => 0);
//$db_res = CIBlockSection::GetList(array(), $arFilter, false, array("ID", "NAME", "CREATED_BY", "RIGHT_MARGIN", "LEFT_MARGIN", "CODE", "UF_GALLERY_SIZE"));
//$arResult["GALLERY"] = $db_res->Fetch();
$savedData['NEW_SECTION_NAME'] = $Params['name'];
$savedData['NEW_SECTION_PICTURE'] = "";
} else {
CImageUploader::SaveError(array(array("id" => "BXPH_FUNC_001", "text" => $bs->LAST_ERROR)));
}
}
}
}
$savedData["SECTION_ID"] = $sectionId;
CImageUploader::SetSavedData($savedData);
return $sectionId;
}
示例8: Array
$xGroupNode = $groups[$j];
$GROUP_XML_ID = $xGroupNode->GetAttribute($nameUTF['ID']);
$GROUP_PARENT_XML_ID = $xGroupNode->GetAttribute($nameUTF['ParentCategory']);
$GROUP_NAME = $xGroupNode->GetAttribute($nameUTF['Name']);
$arGrTmp[$tmpid.$GROUP_PARENT_XML_ID][] = Array(
"GROUP_XML_ID"=>$GROUP_XML_ID,
"GROUP_PARENT_XML_ID"=>$GROUP_PARENT_XML_ID,
"GROUP_NAME"=>$GROUP_NAME
);
}
$arGroups = array();
AddSectionsRecursive();
CIBlockSection::ReSort($IBLOCK_ID);
$el = new CIBlockElement();
$arProducts = array();
$products = $xCatNode->select_nodes("/".$nameUTF['Product']);
for ($j = 0, $intProdCount = count($products); $j < $intProdCount; $j++)
{
$xProductNode = $products[$j];
$PRODUCT_XML_ID = $xProductNode->GetAttribute($nameUTF['ID']);
$PRODUCT_PARENT_XML_ID = $xProductNode->GetAttribute($nameUTF['ParentCategory']);
$PRODUCT_NAME = $xProductNode->GetAttribute($nameUTF['Name']);
$PROP = array();
$GROUPS_ID = array();
if(strlen($PRODUCT_PARENT_XML_ID)>0 && strlen($arGroups[$PRODUCT_PARENT_XML_ID])>0)
示例9: elseif
} elseif (intVal($arResult["SECTION"]["IBLOCK_SECTION_ID"]) > 0) {
$arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~SECTION_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $arResult["SECTION"]["IBLOCK_SECTION_ID"]));
} else {
$arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~INDEX_URL"], array());
}
$arResultFields = array("ID" => $arResult["SECTION"]["ID"], "error" => "", "url" => $arResult["URL"]);
} elseif ($e = $APPLICATION->GetException()) {
$strWarning .= $e->GetString();
$bVarsFromForm = true;
} else {
$strWarning .= GetMessage("IBSEC_A_DELERR_REFERERS");
$bVarsFromForm = true;
}
}
if (!$bVarsFromForm) {
CIBlockSection::ReSort($iblockId);
$sectionsIds = array(0);
$arGalleriesIds = array(0);
$arUsers = array();
if ($ID > 0) {
// Add
$sectionsIds[] = $ID;
}
if ($arParams['SECTION_ID']) {
// Del, edit
$sectionsIds[] = $arParams['SECTION_ID'];
}
if ($arFields && $arFields['IBLOCK_SECTION_ID']) {
$sectionsIds[] = $arFields['IBLOCK_SECTION_ID'];
}
if (isset($arResult) && isset($arResult['SECTION']['IBLOCK_SECTION_ID'])) {
示例10: __intr_process_action
//.........这里部分代码省略.........
}
if ($arSection && $arSectionTo) {
$ok = true;
$ob = new CIBlockSection();
if ($ob->Update($dpt, array('IBLOCK_SECTION_ID' => $dpt_to))) {
$mode = 'reload';
$arUndo[] = array('action' => 'move_department', 'dpt_id' => $dpt, 'dpt_to' => $arSection['IBLOCK_SECTION_ID']);
$undo_text = GetMessage('ISV_move_department', array("#DEPARTMENT#" => $arSection["NAME"], "#DEPARTMENT_TO#" => $arSectionTo["NAME"]));
} else {
$res = array('error' => trim(str_replace('<br>', "\n", $ob->LAST_ERROR)));
}
}
}
// we should resort departments in this case
if (is_array($res) || !$_REQUEST['dpt_parent']) {
break;
}
case 'sort_department':
$dpt_id = intval($_REQUEST['dpt_id']);
$dpt_before = intval($_REQUEST['dpt_before']);
$dpt_after = intval($_REQUEST['dpt_after']);
$dpt_parent = intval($_REQUEST['dpt_parent']);
$ok = false;
if ($dpt_id > 0 && $dpt_parent > 0 && ($dpt_before > 0 || $dpt_after > 0)) {
$arSections = array();
$dbRes = CIBlockSection::GetList(array('left_margin' => asc), array('IBLOCK_ID' => $IBLOCK_ID, 'SECTION_ID' => $dpt_parent));
$arCurrentSection = array();
$arSections = array();
$sortAfter = 0;
$sortBefore = 0;
while ($arSection = $dbRes->GetNext()) {
if ($arSection['ID'] != $dpt_id) {
$arSections[] = $arSection;
} else {
$arCurrentSection = $arSection;
}
if ($arSection['ID'] == $dpt_after) {
$sortAfter = $arSection['SORT'];
} elseif ($arSection['ID'] == $dpt_before) {
$sortBefore = $arSection['SORT'];
}
}
$GLOBALS['APPLICATION']->RestartBuffer();
$new_sort = -1;
if (!$dpt_before && $sortAfter > 0) {
$new_sort = $sortAfter + 100;
} elseif (!$dpt_after && $sortBefore > 1) {
$new_sort = round($sortBefore / 2);
} elseif ($dpt_before && $dpt_after && abs($sortBefore - $sortAfter) > 2) {
$new_sort = round(abs($sortBefore + $sortAfter) / 2);
}
$obSection = new CIBlockSection();
if ($new_sort > 0) {
// simple variant: update just one section
$ok = true;
if (!$obSection->Update($dpt_id, array('SORT' => $new_sort))) {
$res = array('error' => trim(str_replace('<br>', "\n", $ob->LAST_ERROR)));
}
} else {
if ($dpt_before && $dpt_after) {
foreach ($arSections as $key => $arSection) {
if ($arSection['ID'] == $dpt_before || $arSection['ID'] == $dpt_after) {
$arSections = array_merge(array_slice($arSections, 0, $key + 1), array($arCurrentSection), array_slice($arSections, $key + 1));
break;
}
}
} else {
if (!$dpt_after) {
array_unshift($arSections, $arCurrentSection);
} else {
$arSections[] = $arCurrentSection;
}
}
$GLOBALS['DB']->StartTransaction();
$sort = 0;
foreach ($arSections as $arSection) {
$sort += 100;
if (!$obSection->Update($arSection['ID'], array('SORT' => $sort), false)) {
$res = array('error' => trim(str_replace('<br>', "\n", $ob->LAST_ERROR)));
$GLOBALS['DB']->Rollback();
break;
}
}
if (!is_array($res)) {
CIBlockSection::ReSort($IBLOCK_ID);
$GLOBALS['DB']->Commit();
$ok = true;
}
}
}
if (!is_array($res)) {
if (!$ok) {
$res = array('error' => 'Wrong data');
} else {
$mode = 'reload';
}
}
break;
}
}