static function isVirtualCategoryExist($categoryName) { $result = false; if ($categoryName == GetMessage("WIKI_CATEGORY_NOCAT") || $categoryName == GetMessage("WIKI_CATEGORY_ALL")) { $result = true; } else { $categories = new CWikiCategories(); $rsHandlers = GetModuleEvents("wiki", "OnCategoryListCreate"); while ($arHandler = $rsHandlers->Fetch()) { ExecuteModuleEventEx($arHandler, array(&$categories, '')); } $arCats = $categories->GetItems(); foreach ($arCats as $category) { if ($category["NAME"] == $categoryName) { $result = true; break; } } } return $result; }
$arFilter['IBLOCK_ID'] = $arParams['IBLOCK_ID']; $arFilter['CHECK_PERMISSIONS'] = 'N'; $arFilter['GLOBAL_ACTIVE'] = 'Y'; $arFilter['ELEMENT_SUBSECTIONS'] = 'Y'; //$arFilter['ACTIVE_DATE'] = ''; $arFilter['CNT_ACTIVE'] = 'Y'; if (CWikiSocnet::IsSocNet()) { $arFilter['>LEFT_BORDER'] = CWikiSocnet::$iCatLeftBorder; $arFilter['<RIGHT_BORDER'] = CWikiSocnet::$iCatRightBorder; } if (!empty($sCategoryName)) { $arFilter['NAME'] = $sCategoryName; } $dbList = CIBlockSection::GetList(array('NAME' => 'ASC'), $arFilter, true); $arResult['CATEGORIES'] = array(); $categories = new CWikiCategories(); $catParams = new CWikiCategoryParams(); $catParams->setPathTemplate($arParams['PATH_TO_CATEGORY']); while ($arCat = $dbList->GetNext()) { //fix: http://jabber.bx/view.php?id=26658 if ($arCat['ELEMENT_CNT'] <= 0) { CIBlockSection::Delete($arCat['ID'], false); continue; } $catParams->sName = $arCat['NAME']; $catParams->sTitle = $arCat['NAME']; $catParams->iItemsCount = $arCat['ELEMENT_CNT']; $catParams->bIsRed = 'Y'; $catParams->createLinkFromTemplate(); $categories->addItem($catParams); }