protected function checkForIblock(&$listIblock) { if (!empty($listIblock)) { $filter = array(); foreach ($listIblock as $iblockData) { $filter['CODE'][] = $iblockData['CODE']; $filter['IBLOCK_TYPE_ID'][] = $iblockData['IBLOCK_TYPE_ID']; $filter['NAME'][] = $iblockData['NAME']; } $iblockObject = CIBlock::getList(array(), array('IBLOCK_TYPE_ID' => $filter['IBLOCK_TYPE_ID'], 'CODE' => $filter['CODE'], 'NAME' => $filter['NAME'], 'CHECK_PERMISSIONS' => 'N', 'SITE_ID' => SITE_ID)); while ($iblock = $iblockObject->fetch()) { if (array_key_exists($iblock['CODE'], $listIblock)) { $listIblock[$iblock['CODE']]['NAME'] .= Loc::getMessage('CC_LCP_PROCESS_INSTALLED'); $listIblock[$iblock['CODE']]['PICK_OUT'] = true; } } } }
protected function processActionShowProcesses() { $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id"); $this->checkPermission(); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $siteDir = '/'; $siteId = true; if ($this->request->getPost('siteDir')) { $siteDir = $this->request->getPost('siteDir'); } if ($this->request->getPost('siteId')) { $siteId = $this->request->getPost('siteId'); } $path = rtrim($siteDir, '/'); $listData = array(); $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", "TYPE" => $this->iblockTypeId, "SITE_ID" => $siteId)); while ($list = $lists->fetch()) { if (CLists::getLiveFeed($list['ID'])) { $listData[$list['ID']]['name'] = $list['NAME']; $listData[$list['ID']]['url'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $list["ID"] . '&element_id=0'; if ($list['PICTURE'] > 0) { $imageFile = CFile::GetFileArray($list['PICTURE']); if ($imageFile !== false) { $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false); $listData[$list['ID']]['picture'] = '<img src="' . $imageFile["src"] . '" width="19" height="16" border="0" />'; } } else { $listData[$list['ID']]['picture'] = '<img src="/bitrix/images/lists/default.png" width="19" height="16" border="0" />'; } } } if (!empty($listData)) { $this->sendJsonSuccessResponse(array('lists' => $listData)); } else { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_NOT_PROCESSES')))); $this->sendJsonErrorResponse(); } }
protected function getIblockData() { $this->arResult['LIST_DATA'] = array(); $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array('ACTIVE' => 'Y', 'ID' => $this->arResult['IBLOCK_ID'])); while ($list = $lists->fetch()) { if (CLists::getLiveFeed($list['ID'])) { $this->arResult['LIST_DATA']['ID'] = $list['ID']; $this->arResult['LIST_DATA']['NAME'] = $list['NAME']; $this->arResult['LIST_DATA']['DESCRIPTION'] = $list['DESCRIPTION']; $this->arResult['LIST_DATA']['CODE'] = $list['CODE']; if ($list['PICTURE'] > 0) { $imageFile = CFile::GetFileArray($list['PICTURE']); if ($imageFile !== false) { $this->arResult['LIST_DATA']['PICTURE'] = '<img src="' . $imageFile["SRC"] . '" width="36" height="30" border="0" />'; $this->arResult['LIST_DATA']['PICTURE_SMALL'] = '<img src="' . $imageFile["SRC"] . '" width="19" height="16" border="0" />'; } } else { $this->arResult['LIST_DATA']['PICTURE'] = "<img src=\"/bitrix/images/lists/default.png\" width=\"36\" height=\"30\" border=\"0\" />"; $this->arResult['LIST_DATA']['PICTURE_SMALL'] = "<img src=\"/bitrix/images/lists/default.png\" width=\"19\" height=\"16\" border=\"0\" />"; } } } }
/** * @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; }
$admin = false; if ($listsPerm >= CListPermissions::IS_ADMIN) { $permissions['new'] = GetMessage("CC_BLL_TITLE_NEW_LIST"); $permissions['market'] = GetMessage("CC_BLL_TITLE_MARKETPLACE_NEW"); $permissions['settings'] = GetMessage("CC_BLL_TITLE_SETTINGS"); $admin = true; } elseif ($listsPerm >= CListPermissions::CAN_READ) { $permissions['market'] = GetMessage("CC_BLL_TITLE_MARKETPLACE_NEW"); $permissions['settings'] = GetMessage("CC_BLL_TITLE_SETTINGS"); } $listData = array(); $siteId = true; if ($_POST['siteId']) { $siteId = $_POST['siteId']; } $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", "TYPE" => COption::GetOptionString("lists", "livefeed_iblock_type_id"), 'SITE_ID' => $siteId)); while ($list = $lists->fetch()) { if (CLists::getLiveFeed($list['ID'])) { $listData[$list['ID']]['ID'] = $list['ID']; $shortName = substr($list['NAME'], 0, 50); if ($shortName == $list['NAME']) { $listData[$list['ID']]['NAME'] = $list['NAME']; } else { $listData[$list['ID']]['NAME'] = $shortName . '...'; } $listData[$list['ID']]['DESCRIPTION'] = $list['DESCRIPTION']; $listData[$list['ID']]['CODE'] = $list['CODE']; if ($list['PICTURE'] > 0) { $imageFile = CFile::GetFileArray($list['PICTURE']); if ($imageFile !== false) { $listData[$list['ID']]['PICTURE'] = '<img src="' . $imageFile["SRC"] . '" width="36" height="30" border="0" />';
/** * @after testDelete */ public function testRollbackDelete() { /** @var $list AppliedChangesLogModel[] */ $list = AppliedChangesLogModel::find(array('limit' => 3, 'order' => array('id' => 'DESC'))); $this->assertCount($list, 3, $this->errorMessage('should be in an amount of writable', array(':count' => 3))); foreach ($list as $lItem) { $this->assertTrue($lItem->processName == DeleteProcess::className(), $this->errorMessage('logging process should be - Disposal')); } $rsIblock = \CIBlock::getList(); $countIbBefore = $rsIblock->SelectedRowsCount(); $iblocksBefore = array(); while ($arIb = $rsIblock->Fetch()) { $iblocksBefore[] = $arIb['ID']; } Module::getInstance()->rollbackByLogs($list ?: array()); $rsIblock = \CIBlock::getList(); $countIbAfter = $rsIblock->SelectedRowsCount(); $iblocksAfter = array(); while ($arIb = $rsIblock->Fetch()) { $iblocksAfter[] = $arIb['ID']; } $rebuildIblockId = array_diff($iblocksAfter, $iblocksBefore); $rebuildIblockId = array_shift($rebuildIblockId); $this->assertEquals($countIbAfter, $countIbBefore + 1, $this->errorMessage('information block data to be restored')); $this->assertEquals($rebuildIblockId, $this->_iblockId, $this->errorMessage('iblock restored identifier changed')); $rsProp = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId))); $this->assertTrue($rsProp->getSelectedRowsCount() > 0, $this->errorMessage('must present properties of reduced information iblock'), array(':iblockId' => $rebuildIblockId)); $rsSections = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId))); $this->assertTrue($rsSections->getSelectedRowsCount() > 0, $this->errorMessage('must present sections of reduced information iblock', array(':iblockId' => $rebuildIblockId))); }
public static function getFieldInputControlOptions($documentType, &$fieldType, $functionNameJs, &$value) { $result = ""; static $documentFieldTypes = array(); if (!array_key_exists($documentType, $documentFieldTypes)) { $documentFieldTypes[$documentType] = self::getDocumentFieldTypes($documentType); } if (!array_key_exists($fieldType["Type"], $documentFieldTypes[$documentType]) || !$documentFieldTypes[$documentType][$fieldType["Type"]]["Complex"]) { return ""; } if ($fieldType["Type"] == "E:EList") { if (is_array($value)) { reset($value); $valueTmp = intval(current($value)); } else { $valueTmp = intval($value); } $iblockId = 0; if ($valueTmp > 0) { $queryResult = \CIBlockElement::getList(array(), array("ID" => $valueTmp), false, false, array("ID", "IBLOCK_ID")); if ($fetchResult = $queryResult->fetch()) { $iblockId = $fetchResult["IBLOCK_ID"]; } } if ($iblockId <= 0 && intval($fieldType["Options"]) > 0) { $iblockId = intval($fieldType["Options"]); } $defaultIBlockId = 0; $result .= '<select id="WFSFormOptionsX" onchange="' . htmlspecialcharsbx($functionNameJs) . '(this.options[this.selectedIndex].value)">'; $iblockType = \CIBlockParameters::getIBlockTypes(); foreach ($iblockType as $iblockTypeId => $iblockTypeName) { $result .= '<optgroup label="' . $iblockTypeName . '">'; $dbIBlock = \CIBlock::getList(array("SORT" => "ASC"), array("TYPE" => $iblockTypeId, "ACTIVE" => "Y")); while ($iblock = $dbIBlock->getNext()) { $result .= '<option value="' . $iblock["ID"] . '"' . ($iblock["ID"] == $iblockId ? " selected" : "") . '>' . $iblock["NAME"] . '</option>'; if ($defaultIBlockId <= 0 || $iblock["ID"] == $iblockId) { $defaultIBlockId = $iblock["ID"]; } } $result .= '</optgroup>'; } $result .= '</select><!--__defaultOptionsValue:' . $defaultIBlockId . '--><!--__modifyOptionsPromt:' . GetMessage("IBD_DOCUMENT_MOPROMT") . '-->'; $fieldType["Options"] = $defaultIBlockId; } elseif ($fieldType["Type"] == "select") { $valueTmp = $fieldType["Options"]; if (!is_array($valueTmp)) { $valueTmp = array($valueTmp => $valueTmp); } $str = ''; foreach ($valueTmp as $k => $v) { if (is_array($v) && count($v) == 2) { $v1 = array_values($v); $k = $v1[0]; $v = $v1[1]; } if ($k != $v) { $str .= '[' . $k . ']' . $v; } else { $str .= $v; } $str .= "\n"; } $result .= '<textarea id="WFSFormOptionsX" rows="5" cols="30">' . htmlspecialcharsbx($str) . '</textarea><br />'; $result .= Loc::getMessage("DISK_IBD_DOCUMENT_XFORMOPTIONS1") . '<br />'; $result .= Loc::getMessage("DISK_IBD_DOCUMENT_XFORMOPTIONS2") . '<br />'; $result .= '<script type="text/javascript"> function WFSFormOptionsXFunction() { var result = {}; var i, id, val, str = document.getElementById("WFSFormOptionsX").value; var arr = str.split(/[\\r\\n]+/); var p, re = /\\[([^\\]]+)\\].+/; for (i in arr) { str = arr[i].replace(/^\\s+|\\s+$/g, \'\'); if (str.length > 0) { id = str.match(re); if (id) { p = str.indexOf(\']\'); id = id[1]; val = str.substr(p + 1); } else { val = str; id = val; } result[id] = val; } } return result; } </script>'; $result .= '<input type="button" onclick="' . htmlspecialcharsbx($functionNameJs) . '(WFSFormOptionsXFunction())" value="' . Loc::getMessage("DISK_IBD_DOCUMENT_XFORMOPTIONS3") . '">'; } return $result; }
/** * <p>Метод удаляет Wiki-страницу. Динамичный метод.</p> * * * @param int $ID Идентификатор Wiki-страницы * * @param int $IBLOCK_ID Идентификатор Инфо.блока. <br> До версии 10.0.0 назывался <b>BLOCK_ID</b>. * * @return bool * * <h4>Example</h4> * <pre> * <?<br>// Удалим Wiki-страницу с идентификатором 13 в инфо.блоке с идентификатором 2<br>$ID = 13;<br>$IBLOCK_ID = 2;<br><br>$CWiki = new CWiki();<br>if (!$CWiki->Delete($ID, $IBLOCK_ID))<br> echo 'Ошибка. Страница не удалена.';<br>?> * </pre> * * * @static * @link http://dev.1c-bitrix.ru/api_help/wiki/classes/cwiki/Delete.php * @author Bitrix */ public function Delete($ID, $IBLOCK_ID) { $rIBlock = CIBlock::getList(array(), array('ID' => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N')); $arIBlock = $rIBlock->GetNext(); // erase the history of changes if ($arIBlock['BIZPROC'] == 'Y' && CModule::IncludeModule('bizproc')) { $historyService = new CBPHistoryService(); $historyService->DeleteHistoryByDocument(array('iblock', 'CWikiDocument', $ID)); } $this->CleanCacheById($ID, $IBLOCK_ID); // delete item $bResult = $this->cIB_E->Delete($ID); return $bResult; }
public function OnAfterIBlockElementDelete($fields) { if (CModule::includeModule('bizproc')) { $errors = array(); $iblockType = COption::getOptionString("lists", "livefeed_iblock_type_id"); $iblockQuery = CIBlock::getList(array(), array('ID' => $fields['IBLOCK_ID'])); if ($iblock = $iblockQuery->fetch()) { $iblockType = $iblock["IBLOCK_TYPE_ID"]; } $states = CBPStateService::getDocumentStates(BizprocDocument::getDocumentComplexId($iblockType, $fields['ID'])); $listWorkflowId = array(); foreach ($states as $workflowId => $state) { $listWorkflowId[] = $workflowId; } self::deleteSocnetLog($listWorkflowId); CBPDocument::onDocumentDelete(BizprocDocument::getDocumentComplexId($iblockType, $fields['ID']), $errors); } $propertyQuery = CIBlockElement::getProperty($fields['IBLOCK_ID'], $fields['ID'], 'sort', 'asc', array('ACTIVE' => 'Y')); while ($property = $propertyQuery->fetch()) { $userType = \CIBlockProperty::getUserType($property['USER_TYPE']); if (array_key_exists('DeleteAllAttachedFiles', $userType)) { call_user_func_array($userType['DeleteAllAttachedFiles'], array($fields['ID'])); } } }