本文整理汇总了PHP中CIBlock::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::Add方法的具体用法?PHP CIBlock::Add怎么用?PHP CIBlock::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAdd
public function testAdd()
{
$this->_injectDutyCollector();
$ibType = \CIBlockType::GetList()->Fetch();
$ib = new \CIBlock();
$ibId = $ib->Add(array('IBLOCK_TYPE_ID' => $ibType['ID'], 'NAME' => 'New Iblock', 'SITE_ID' => 's1'));
$this->assertNotEmpty($ibId, $this->errorMessage('not create iblock id', array(':lastError' => $ib->LAST_ERROR)));
$prop = new \CIBlockProperty();
$propId = $prop->Add(array('IBLOCK_ID' => $ibId, 'CODE' => 'propCode', 'NAME' => 'Property NAME'));
$this->assertNotEmpty($propId, $this->errorMessage('not create property iblock id', array(':lastError' => $ib->LAST_ERROR)));
$sec = new \CIBlockSection();
$secId = $sec->Add(array('IBLOCK_ID' => $ibId, 'NAME' => 'Iblock Section'));
$this->assertNotEmpty($secId, $this->errorMessage('not create section iblock id', array(':lastError' => $ib->LAST_ERROR)));
// ¬ итоге должны получитс¤
// данные по добавлению »Ѕ
$this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockHandler::className()));
// данные по добавлению свойства
$this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockPropertyHandler::className()));
// данные по добавлению секции
$this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockSectionHandler::className()));
$refFixes = $this->_getCollectorFixes('reference');
// фиксаци¤ изменений
Module::getInstance()->commitDutyChanges();
// добавлены записи журнала обновлений (в базу)
/** @var $logRecords AppliedChangesLogModel[] */
$logRecords = AppliedChangesLogModel::find(array('order' => array('id' => 'desc'), 'limit' => 10));
$this->assertTrue(count($logRecords) > 3);
$iterationsCount = 0;
foreach ($logRecords as $logRecord) {
if ($logRecord->processName == Module::SPECIAL_PROCESS_FIX_REFERENCE) {
continue;
}
if ($logRecord->processName != AddProcess::className()) {
$this->throwError($this->errorMessage('last log records need been update process'), $logRecord->processName);
}
if (++$iterationsCount > 3) {
break;
}
$data = $logRecord->updateData;
switch ($logRecord->subjectName) {
case IblockHandler::className():
(!$data['iblock'] || $data['iblock']['ID'] != $ibId) && $this->throwError($this->errorMessage('iblock not registered after update', array(':actual' => $data['iblock']['ID'], ':need' => $ibId)));
break;
case IblockPropertyHandler::className():
$data['ID'] != $propId && $this->throwError($this->errorMessage('property iblock not registered after update', array(':original' => $propId, ':actual' => $data['ID'])));
break;
case IblockSectionHandler::className():
$data['ID'] != $secId && $this->throwError($this->errorMessage('section iblock not registered after update', array(':original' => $secId, ':actual' => $data['ID'])));
break;
}
}
// добавлены три вида ссылок в фиксаци¤х
$this->assertEquals(3, count($refFixes), $this->errorMessage('links expected count', array(':count' => 3)));
$this->_iblockId = $ibId;
$this->_propertyId = $propId;
$this->_sectionId = $secId;
}
示例2: createIBlock
/**
* Создает инфоблок
*
* @param array $arFields
*
* @throws MigrationException
*/
protected function createIBlock(array $arFields)
{
if (empty($arFields['CODE'])) {
throw new MigrationException('Unknown code information block');
}
if ($this->isIBlockExists($arFields['CODE'])) {
throw new MigrationException(sprintf('IBlock with code "%s" already exists', $arFields['CODE']));
}
if (!($id = $this->iBlockGateway->Add($arFields))) {
throw new MigrationException($this->iBlockGateway->LAST_ERROR);
}
$this->iblockId = $id;
}
示例3: addIblockIfNotExists
public function addIblockIfNotExists($fields)
{
$this->checkRequiredKeys(__METHOD__, $fields, array('CODE'));
$iblockId = $this->getIblockId($fields['CODE']);
if ($iblockId) {
return $iblockId;
}
$default = array('ACTIVE' => 'Y', 'NAME' => '', 'CODE' => '', 'LIST_PAGE_URL' => '', 'DETAIL_PAGE_URL' => '', 'SECTION_PAGE_URL' => '', 'IBLOCK_TYPE_ID' => 'main', 'SITE_ID' => array('s1'), 'SORT' => 500, 'GROUP_ID' => array('2' => 'R'), 'VERSION' => 2, 'BIZPROC' => 'N', 'WORKFLOW' => 'N', 'INDEX_ELEMENT' => 'N', 'INDEX_SECTION' => 'N');
$fields = array_merge($default, $fields);
$ib = new \CIBlock();
$iblockId = $ib->Add($fields);
if ($iblockId) {
return $iblockId;
}
$this->throwException(__METHOD__, $ib->LAST_ERROR);
}
示例4: array
}
}
}
if ($catalog == "Y" && CheckIBlockType("catalog", "Y")) {
//This makes translation checker happy
//$MY_MESS['IBLOCK_INSTALL_CATALOG_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_SECTIONS_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_ELEMENTS_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_SECTION_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_ELEMENT_NAME']
$sites = CSite::GetList($by, $order, array("ACTIVE" => "Y"));
while ($site = $sites->Fetch()) {
$MY_MESS = IncludeModuleLangFile(__FILE__, $site["LANGUAGE_ID"], true);
$obBlock = new CIBlock();
$arFields = array("LID" => $site["LID"], "NAME" => GetMessage("IBLOCK_INSTALL_PRODUCTS"), "IBLOCK_TYPE_ID" => "catalog", "CODE" => "comp_catalog", "LIST_PAGE_URL" => "#SITE_DIR#/" . $catalog_dir . "/index.php", "DETAIL_PAGE_URL" => "#SITE_DIR#/" . $catalog_dir . "/index.php?ID=#ID#", "ELEMENTS_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_ELEMENTS_NAME"], "ELEMENT_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_ELEMENT_NAME"], "SECTIONS_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_SECTIONS_NAME"], "SECTION_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_SECTION_NAME"], "GROUP_ID" => array("2" => "R"));
if ($id = $obBlock->Add($arFields)) {
$obBlockProperty = new CIBlockProperty();
$arFields = array("IBLOCK_ID" => $id, "NAME" => GetMessage("IBLOCK_INSTALL_SIMILAR_PRODUCTS"), "CODE" => "ANALOG", "PROPERTY_TYPE" => "E", "MULTIPLE" => "Y", "LINK_IBLOCK_ID" => $id);
$obBlockProperty->Add($arFields);
}
if (strlen($catalog_dir) > 0) {
$source = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/iblock/install/public/catalog/";
$target = $site['ABS_DOC_ROOT'] . $site["DIR"] . $catalog_dir . "/";
if (file_exists($source)) {
CheckDirPath($target);
$dh = opendir($source);
while ($file = readdir($dh)) {
if ($file == "." || $file == "..") {
continue;
}
if ($bReWriteAdditionalFiles_c || !file_exists($target . $file)) {
示例5: CIBlock
$cib = new CIBlock();
$cibp = new CIBlockProperty();
foreach ($data as &$_iblock_data) {
$rsIBlock = $cib->GetList(false, array('CODE' => $_iblock_data['CODE'], 'TYPE' => $iBlockTypeID));
$arIBlock = $rsIBlock->Fetch();
if ($arIBlock['ID']) {
if ($_POST['overwrite'] == '1') {
// если инфоблоки перезаписываем, удалим имеющийся
$cib->Delete($arIBlock['ID']);
} else {
// если инфблоки не перезаписываем, то пропускаем этот
continue;
}
}
// создание инфоблоков
if (!$cib->Add(array('SITE_ID' => array($_iblock_data['LID']), 'CODE' => $_iblock_data['CODE'], 'EXTERNAL_ID' => $_iblock_data['EXTERNAL_ID'], 'XML_ID' => $_iblock_data['XML_ID'], 'IBLOCK_TYPE_ID' => $iBlockTypeID, 'NAME' => $_iblock_data['NAME'], 'ACTIVE' => $_iblock_data['ACTIVE'], 'SORT' => $_iblock_data['SORT'], 'LIST_PAGE_URL' => $_iblock_data['LIST_PAGE_URL'], 'SECTION_PAGE_URL' => $_iblock_data['SECTION_PAGE_URL'], 'DETAIL_PAGE_URL' => $_iblock_data['DETAIL_PAGE_URL'], 'PICTURE' => $_iblock_data['PICTURE'], 'DESCRIPTION' => $_iblock_data['DESCRIPTION'], 'DESCRIPTION_TYPE' => $_iblock_data['DESCRIPTION_TYPE'], 'RSS_ACTIVE' => $_iblock_data['RSS_ACTIVE'], 'RSS_TTL' => $_iblock_data['RSS_TTL'], 'RSS_FILE_ACTIVE' => $_iblock_data['RSS_FILE_ACTIVE'], 'RSS_FILE_LIMIT' => $_iblock_data['RSS_FILE_LIMIT'], 'RSS_FILE_DAYS' => $_iblock_data['RSS_FILE_DAYS'], 'RSS_YANDEX_ACTIVE' => $_iblock_data['RSS_YANDEX_ACTIVE'], 'INDEX_ELEMENT' => $_iblock_data['INDEX_ELEMENT'], 'INDEX_SECTION' => $_iblock_data['INDEX_SECTION'], 'WORKFLOW' => $_iblock_data['WORKFLOW'], 'SECTION_CHOOSER' => $_iblock_data['SECTION_CHOOSER'], 'VERSION' => $_iblock_data['VERSION'], 'EDIT_FILE_BEFORE' => $_iblock_data['EDIT_FILE_BEFORE'], 'EDIT_FILE_AFTER' => $_iblock_data['EDIT_FILE_AFTER']))) {
$DB->Rollback();
ShowError(GetMessage('GREENSIGHT_IBLOCK_IMPORT_ERROR_IBLOCK_CREATE'));
break 2;
}
$rsIBlock = $cib->GetList(false, array('CODE' => $_iblock_data['CODE'], 'TYPE' => $iBlockTypeID));
$arIBlock = $rsIBlock->Fetch();
// добавление свойств
if (sizeof($_iblock_data['properties'])) {
foreach ($_iblock_data['properties'] as &$_iblock_property) {
$_property = array('CODE' => $_iblock_property['CODE'], 'XML_ID' => $_iblock_property['XML_ID'], 'IBLOCK_ID' => $arIBlock['ID'], 'NAME' => $_iblock_property['NAME'], 'ACTIVE' => $_iblock_property['ACTIVE'], 'SORT' => $_iblock_property['SORT'], 'PROPERTY_TYPE' => $_iblock_property['PROPERTY_TYPE'], 'MULTIPLE' => $_iblock_property['MULTIPLE'], 'DEFAULT_VALUE' => $_iblock_property['DEFAULT_VALUE'], 'ROW_COUNT' => $_iblock_property['ROW_COUNT'], 'COL_COUNT' => $_iblock_property['COL_COUNT'], 'LIST_TYPE' => $_iblock_property['LIST_TYPE'], 'MULTIPLE_CNT' => $_iblock_property['MULTIPLE_CNT'], 'FILE_TYPE' => $_iblock_property['FILE_TYPE'], 'SEARCHABLE' => $_iblock_property['SEARCHABLE'], 'FILTRABLE' => $_iblock_property['FILTRABLE'], 'LINK_IBLOCK_ID' => $_iblock_property['LINK_IBLOCK_ID'], 'WITH_DESCRIPTION' => $_iblock_property['WITH_DESCRIPTION'], 'VERSION' => $_iblock_property['VERSION'], 'USER_TYPE' => $_iblock_property['USER_TYPE']);
// варианты значений свойств типа "список"
if (sizeof($_iblock_property['list_values'])) {
foreach ($_iblock_property['list_values'] as &$_list_value) {
$_property['VALUES'][] = array('VALUE' => $_list_value['VALUE'], 'DEF' => $_list_value['DEF'], 'SORT' => $_list_value['SORT'], 'XML_ID' => $_list_value['XML_ID'], 'EXTERNAL_ID' => $_list_value['EXTERNAL_ID']);
}
示例6: array
$SECTION_DETAIL_PICTURE_FILE_NAME = \Bitrix\Iblock\Template\Helper::convertArrayToModifiers($_POST["IPROPERTY_TEMPLATES"]["SECTION_DETAIL_PICTURE_FILE_NAME"]);
$ELEMENT_PREVIEW_PICTURE_FILE_NAME = \Bitrix\Iblock\Template\Helper::convertArrayToModifiers($_POST["IPROPERTY_TEMPLATES"]["ELEMENT_PREVIEW_PICTURE_FILE_NAME"]);
$ELEMENT_DETAIL_PICTURE_FILE_NAME = \Bitrix\Iblock\Template\Helper::convertArrayToModifiers($_POST["IPROPERTY_TEMPLATES"]["ELEMENT_DETAIL_PICTURE_FILE_NAME"]);
$arFields["IPROPERTY_TEMPLATES"] = array("SECTION_META_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_META_TITLE"]["TEMPLATE"], "SECTION_META_KEYWORDS" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_META_KEYWORDS"]["TEMPLATE"], "SECTION_META_DESCRIPTION" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_META_DESCRIPTION"]["TEMPLATE"], "SECTION_PAGE_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_PAGE_TITLE"]["TEMPLATE"], "ELEMENT_META_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_META_TITLE"]["TEMPLATE"], "ELEMENT_META_KEYWORDS" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_META_KEYWORDS"]["TEMPLATE"], "ELEMENT_META_DESCRIPTION" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_META_DESCRIPTION"]["TEMPLATE"], "ELEMENT_PAGE_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_PAGE_TITLE"]["TEMPLATE"], "SECTION_PICTURE_FILE_ALT" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_PICTURE_FILE_ALT"]["TEMPLATE"], "SECTION_PICTURE_FILE_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_PICTURE_FILE_TITLE"]["TEMPLATE"], "SECTION_PICTURE_FILE_NAME" => $SECTION_PICTURE_FILE_NAME, "SECTION_DETAIL_PICTURE_FILE_ALT" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_DETAIL_PICTURE_FILE_ALT"]["TEMPLATE"], "SECTION_DETAIL_PICTURE_FILE_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["SECTION_DETAIL_PICTURE_FILE_TITLE"]["TEMPLATE"], "SECTION_DETAIL_PICTURE_FILE_NAME" => $SECTION_DETAIL_PICTURE_FILE_NAME, "ELEMENT_PREVIEW_PICTURE_FILE_ALT" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_PREVIEW_PICTURE_FILE_ALT"]["TEMPLATE"], "ELEMENT_PREVIEW_PICTURE_FILE_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_PREVIEW_PICTURE_FILE_TITLE"]["TEMPLATE"], "ELEMENT_PREVIEW_PICTURE_FILE_NAME" => $ELEMENT_PREVIEW_PICTURE_FILE_NAME, "ELEMENT_DETAIL_PICTURE_FILE_ALT" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_DETAIL_PICTURE_FILE_ALT"]["TEMPLATE"], "ELEMENT_DETAIL_PICTURE_FILE_TITLE" => $_POST["IPROPERTY_TEMPLATES"]["ELEMENT_DETAIL_PICTURE_FILE_TITLE"]["TEMPLATE"], "ELEMENT_DETAIL_PICTURE_FILE_NAME" => $ELEMENT_DETAIL_PICTURE_FILE_NAME);
}
$bCreateRecord = $ID <= 0;
if (!$bVarsFromForm) {
$res_log["NAME"] = $NAME;
if ($ID > 0) {
$res = $ib->Update($ID, $arFields);
if (COption::GetOptionString("iblock", "event_log_iblock", "N") === "Y" && $res) {
CEventLog::Log("IBLOCK", "IBLOCK_EDIT", "iblock", $ID, serialize($res_log));
}
} else {
$arFields["VERSION"] = $VERSION;
$ID = $ib->Add($arFields);
$res = $ID > 0;
if (COption::GetOptionString("iblock", "event_log_iblock", "N") === "Y" && $res) {
CEventLog::Log("IBLOCK", "IBLOCK_ADD", "iblock", $ID, serialize($res_log));
}
}
if (!$res) {
$strWarning .= $ib->LAST_ERROR . "<br>";
$bVarsFromForm = true;
} else {
// RSS agent creation
if ($RSS_FILE_ACTIVE == "Y") {
CAgent::RemoveAgent("CIBlockRSS::PreGenerateRSS(" . $ID . ", false);", "iblock");
CAgent::AddAgent("CIBlockRSS::PreGenerateRSS(" . $ID . ", false);", "iblock", "N", IntVal($RSS_TTL) * 60 * 60, "", "Y");
} else {
CAgent::RemoveAgent("CIBlockRSS::PreGenerateRSS(" . $ID . ", false);", "iblock");
示例7: IblockCreate
/**
* @var array $data
* @var array $fields
* @var bool $deleteIfExists
*/
protected function IblockCreate(array $data, array $fields = null, $deleteIfExists = false)
{
global $DB;
if (empty(trim($data['CODE']))) {
throw new \Exception('You must set iblock CODE');
}
$name = trim($data['CODE']);
$fire = false;
$res = \CIBlock::GetList([], ['CODE' => $name, 'CHECK_PERMISSIONS' => 'N']);
if ($ob = $res->Fetch()) {
if ($deleteIfExists) {
$this->IblockDelete($name);
$fire = true;
} else {
$id = $ob['ID'];
}
} else {
$fire = true;
}
if ($fire) {
$rsSite = \CSite::GetList($by = 'sort', $order = 'desc', ['DEFAULT' => 'Y']);
$sites = [];
while ($obSite = $rsSite->Fetch()) {
$sites[] = $obSite['LID'];
}
$ib = new \CIBlock();
$id = $ib->Add(array_merge(['ACTIVE' => 'Y', 'CODE' => $name, 'XML_ID' => $name, 'LID' => $sites[0], 'LIST_PAGE_URL' => '', 'DETAIL_PAGE_URL' => '', 'SECTION_PAGE_URL' => '', 'CANONICAL_PAGE_URL' => '', 'SORT' => 500, 'INDEX_ELEMENT' => 'N', 'INDEX_SECTION' => 'N'], $data));
if ($id) {
echo "Add {$name} iblock\r\n";
if ($id && $fields) {
$this->IblockSetFields($name, $fields);
}
} else {
throw new \Exception("Can't create {$name} iblock type");
}
}
return $id;
}
示例8: addIblock
protected function addIblock($arIblock)
{
$res = \CIBlock::GetList(array("ID" => "ASC"), array('TYPE' => $arIblock['IBLOCK_TYPE_ID'], "CODE" => $arIblock['CODE']), true);
if ($arFindedIblock = $res->Fetch()) {
$this->addMessage('Инфоблока ' . $arIblock["CODE"] . ' уже есть.', true);
return $arFindedIblock['ID'];
} else {
$ib = new \CIBlock();
$iNewIblockId = false;
if ($iNewIblockId = $ib->Add($arIblock)) {
$this->addMessage("Инфоблок {$iNewIblockId} успешно добавлен.", true);
} else {
$this->addMessage($ib->LAST_ERROR);
}
unset($ib);
return $iNewIblockId;
}
}
示例9: array
}
$iblockCode = "car_photo_group_demo";
$photoGroupIBlockID = 0;
$dbIBlock = CIBlock::GetList(array(), array("SITE_ID" => $arSite["SITE_ID"], "TYPE" => $photoIBlockTypeID, "CODE" => $iblockCode));
if ($arIBlock = $dbIBlock->Fetch()) {
$photoGroupIBlockID = IntVal($arIBlock["ID"]);
} else {
$arFields = array("ACTIVE" => "Y", "NAME" => GetSocNetMessageLocal("SONET_I_IBLOCK_PHOTO_GROUP_NAME", $arSite["LANGUAGE_ID"]), "IBLOCK_TYPE_ID" => $photoIBlockTypeID, "CODE" => $iblockCode, "RSS_ACTIVE" => "N", "WORKFLOW" => "N", "INDEX_ELEMENT" => "N", "LID" => array($arSite["SITE_ID"]));
$iblock = new CIBlock();
$dbUGroups = CGroup::GetList($by = "c_sort", $order = "asc");
while ($arUGroups = $dbUGroups->Fetch()) {
if ($arUGroups["ANONYMOUS"] == "Y") {
$arFields["GROUP_ID"][$arUGroups["ID"]] = "R";
}
}
$photoGroupIBlockID = $iblock->Add($arFields);
if ($photoGroupIBlockID <= 0) {
$errorString .= $iblock->LAST_ERROR;
}
}
}
}
// ------------------ FILES -------------------------------
if (!function_exists("file_get_contents")) {
function file_get_contents($filename)
{
$fd = fopen("{$filename}", "rb");
$content = fread($fd, filesize($filename));
fclose($fd);
return $content;
}
示例10: CIBlock
$iblockID = false;
if ($arIBlock = $rsIBlock->Fetch())
{
$iblockID = $arIBlock["ID"];
if (WIZARD_INSTALL_DEMO_DATA)
{
CIBlock::Delete($arIBlock["ID"]);
$iblockID = false;
}
}
if ($iblockID === false)
{*/
$ob = new CIBlock();
$arFieldsL = array("NAME" => GetMessage("BIZPROC_DEMO1_ACCTS"), "IBLOCK_TYPE_ID" => "lists", "SORT" => 500, "WORKFLOW" => "N", "ELEMENTS_NAME" => GetMessage("BIZPROC_DEMO1_ELEMENTS_NAME"), "ELEMENT_NAME" => GetMessage("BIZPROC_DEMO1_ELEMENT_NAME"), "ELEMENT_ADD" => GetMessage("BIZPROC_DEMO1_ELEMENT_ADD"), "ELEMENT_EDIT" => GetMessage("BIZPROC_DEMO1_ELEMENT_EDIT"), "ELEMENT_DELETE" => GetMessage("BIZPROC_DEMO1_ELEMENT_DELETE"), "BIZPROC" => "Y", "SITE_ID" => array(WIZARD_SITE_ID), "RIGHTS_MODE" => "E", "RIGHTS" => array());
$resL = $ob->Add($arFieldsL);
if ($resL) {
$obList = new CList($resL);
$obList->Save();
$arFields = false;
$documentType = array("iblock", "CIBlockDocument", "iblock_" . $resL);
include $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/lists/install/bizproc/templates/acct.php';
if (is_array($arFields)) {
$arFields["DOCUMENT_TYPE"] = array("iblock", "CIBlockDocument", "iblock_" . $resL);
$arFields["SYSTEM_CODE"] = "acct.php";
if (is_object($GLOBALS['USER'])) {
$arFields["USER_ID"] = $GLOBALS['USER']->GetID();
}
$arFields["MODIFIER_USER"] = new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser);
try {
CBPWorkflowTemplateLoader::Add($arFields);
示例11: InstallIblock
private function InstallIblock()
{
if ($this->arResult["INSTALLATION"]["IBLOCK_INSTALL"]) {
$arFields = array("ACTIVE" => "Y", "INDEX_ELEMENT" => "N", "WORKFLOW" => "N", "NAME" => GetMessage("IDEA_CATEGORY_INFOBLOCK_NAME"), "IBLOCK_TYPE_ID" => $this->arResult["INSTALLATION"]["IBLOCK_TYPE_ID"], "LID" => array(), "CODE" => "idea", "FIELDS" => array("SECTION_CODE" => array("IS_REQUIRED" => "Y", "DEFAULT_VALUE" => array("UNIQUE" => "Y", "TRANSLITERATION" => "Y", "TRANS_LEN" => 50, "TRANS_CASE" => "L", "TRANS_SPACE" => "_", "TRANS_OTHER" => "_", "TRANS_EAT" => "Y", "USE_GOOGLE" => "Y"))), "GROUP_ID" => array("2" => "R"));
foreach ($this->arResult["SETTINGS"]["SITE"] as $lid => $arSite) {
$arFields["LID"][] = $lid;
}
$IB = new CIBlock();
if (!($IblockId = $IB->Add($arFields))) {
$this->arResult["ERRORS"][] = $IB->LAST_ERROR;
}
$this->arResult["INSTALLATION"]["IBLOCK_ID"] = $IblockId;
if (!$this->HaveError()) {
$this->InstallIblockSectionSettings();
$this->InstallIblockSection();
}
}
}
示例12: GetContent
function GetContent($arParams)
{
if (!CModule::IncludeModule('iblock')) {
return false;
}
if ($_POST['library_resource_type'] != "folder") {
//iblock
$iblock_type = '';
$iblock_id = 0;
if ($_POST['library_IBLOCK_TYPE'] != '') {
$res = CIBlockType::GetByID($_POST['library_IBLOCK_TYPE']);
if ($res_arr = $res->Fetch()) {
$iblock_type = $res_arr["ID"];
}
if ($iblock_type != '') {
if ($_POST['library_NEW_IBLOCK'] == 'Y') {
//new iblock
$ib = new CIBlock();
$arFields = array("ACTIVE" => "Y", "VERSION" => 1, "LIST_PAGE_URL" => $arParams['path'], "DETAIL_PAGE_URL" => $arParams['path'] . 'element/view/#ID#/', "NAME" => $_POST['library_TITLE'], "IBLOCK_TYPE_ID" => $iblock_type, "LID" => array($arParams['site']), "SORT" => "500", "WORKFLOW" => "N", "BIZPROC" => "N", "SECTION_CHOOSER" => "L");
if (is_array($_POST['library_PERMISSION'])) {
$arPerm = array();
foreach ($_POST['library_PERMISSION'] as $grp => $perm) {
if ($perm == 'R' || $perm == 'U' || $perm == 'W') {
$arPerm[$grp] = $perm;
}
if ($perm == 'U') {
$arFields['BIZPROC'] = 'Y';
}
}
$arFields["GROUP_ID"] = $arPerm;
}
$iblock_id = $ib->Add($arFields);
} elseif (intval($_POST['library_IBLOCK_ID']) > 0) {
//existing iblock: need check permissions
if (CIBlock::GetPermission($_POST['library_IBLOCK_ID']) >= "X") {
$iblock_id = intval($_POST['library_IBLOCK_ID']);
}
}
}
}
//forum for comments
$forum_id = 0;
if ($_POST['library_USE_COMMENTS'] == 'Y') {
if ($_POST['library_NEW_FORUM'] == 'Y') {
CModule::IncludeModule('forum');
//new forum
$arFields = array("NAME" => GetMessage("library_wizard_forum_name") . " \"" . $_POST['library_TITLE'] . "\"", "SITES" => array($arParams['site'] => $arParams["path"] . "element/view/#PARAM2#/"), "ACTIVE" => "Y", "INDEXATION" => "N", "SORT" => 150, "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_TOPIC_TITLED" => "Y");
if (is_array($_POST['library_FORUM_PERMISSION'])) {
$arPerm = array();
foreach ($_POST['library_FORUM_PERMISSION'] as $grp => $perm) {
if ($perm == 'E' || $perm == 'M') {
$arPerm[$grp] = $perm;
}
}
$arFields["GROUP_ID"] = $arPerm;
}
$forum_id = CForumNew::Add($arFields);
} elseif (intval($_POST['library_FORUM_ID']) > 0) {
$forum_id = intval($_POST['library_FORUM_ID']);
}
}
//file size
$iUploadMaxFilesize = intval(ini_get('upload_max_filesize'));
$iPostMaxSize = intval(ini_get('post_max_size'));
$iUploadMaxFilesize = min($iUploadMaxFilesize, $iPostMaxSize);
//bizproc templates
if ($_POST['library_NEW_IBLOCK'] == 'Y' && $iblock_id > 0 && CModule::IncludeModule("bizproc")) {
$documentType = array("webdav", "CIBlockDocumentWebdav", "iblock_" . $iblock_id);
if (!function_exists("__wd_replace_user_and_groups")) {
function __wd_replace_user_and_groups(&$val, $key, $params = array())
{
if ($key == "MailText") {
$val = str_replace("/company/personal/bizproc/{=Workflow:id}/", $params["path"], $val);
}
return true;
}
}
if ($handle = opendir($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/bizproc/templates')) {
$arr = array("path" => str_replace("//", "/", $arParams["path"] . "/webdav_bizproc_view/{=Document:ID}/"));
while (false !== ($file = readdir($handle))) {
if (!is_file($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/bizproc/templates/' . $file)) {
continue;
}
$arFields = false;
include $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/bizproc/templates/' . $file;
array_walk_recursive($arFields["TEMPLATE"], "__wd_replace_user_and_groups", $arr);
if ($file == "status.php") {
$arFields["AUTO_EXECUTE"] = CBPDocumentEventType::Create;
}
if (is_array($arFields)) {
$arFields["DOCUMENT_TYPE"] = $documentType;
$arFields["SYSTEM_CODE"] = $file;
if (is_object($GLOBALS['USER'])) {
$arFields["USER_ID"] = $GLOBALS['USER']->GetID();
}
try {
CBPWorkflowTemplateLoader::Add($arFields);
} catch (Exception $e) {
}
}
//.........这里部分代码省略.........
示例13: addIblock
protected function addIblock($arIblock)
{
$res = CIBlock::GetList(
Array(),
Array(
'TYPE'=>$arIblock['IBLOCK_TYPE_ID'],
"CODE"=>$arIblock['CODE']
), true
);
if($arFindedIblock = $res->Fetch() ){
$this->iblockIdByCode[$arFindedIblock['CODE']] = $arFindedIblock['ID'];
echo 'Инфоблока '.$arIblock["CODE"].' уже есть.';
}else {
echo 'Инфоблок не найден.';
$ib = new CIBlock;
if ($this->iblockIdByCode[$arIblock['CODE']] = $ib->Add($arIblock)) echo 'Инфоблок успешно добавлен.';
else echo $ib->LAST_ERROR;
unset($ib);
}
}
示例14: createIBlock
private static function createIBlock($iblockType, $iblock, $pictureType, $picture, $siteId = null)
{
if (is_null($siteId)) {
$siteId = \CSite::GetDefSite();
}
$db = \CIBlock::GetList(array(), array("IBLOCK_TYPE_ID" => $iblockType, "CODE" => $iblock["CODE"], "CHECK_PERMISSIONS" => "N", "SITE_ID" => $siteId));
if ($res = $db->Fetch()) {
return $res["ID"];
}
$fields = array("NAME" => $iblock["NAME"], "DESCRIPTION" => $iblock["DESCRIPTION"], "IBLOCK_TYPE_ID" => $iblockType, "SORT" => $iblock["SORT"], "CODE" => $iblock["CODE"], "WORKFLOW" => "N", "ELEMENTS_NAME" => $iblock["ELEMENTS_NAME"], "ELEMENT_NAME" => $iblock["ELEMENT_NAME"], "ELEMENT_ADD" => $iblock["ELEMENT_ADD"], "ELEMENT_EDIT" => $iblock["ELEMENT_EDIT"], "ELEMENT_DELETE" => $iblock["ELEMENT_DELETE"], "SECTIONS_NAME" => $iblock["SECTIONS_NAME"], "SECTION_NAME" => $iblock["SECTION_NAME"], "SECTION_ADD" => $iblock["SECTION_ADD"], "SECTION_EDIT" => $iblock["SECTION_EDIT"], "SECTION_DELETE" => $iblock["SECTION_DELETE"], "BIZPROC" => "Y", "SITE_ID" => array($siteId), "RIGHTS_MODE" => "E");
if ($iblock["SOCNET_GROUP_ID"]) {
$fields["SOCNET_GROUP_ID"] = $iblock["SOCNET_GROUP_ID"];
}
static $exts = array("image/jpeg" => "jpg", "image/png" => "png", "image/gif" => "gif");
if (!empty($picture) && isset($exts[$pictureType])) {
$fn = \CTempFile::GetFileName();
Main\IO\Directory::createDirectory($fn);
$fn .= md5(mt_rand()) . "." . $exts[$pictureType];
$f = fopen($fn, "wb");
fwrite($f, $picture);
fclose($f);
$fields["PICTURE"] = \CFile::MakeFileArray($fn);
}
$ob = new \CIBlock();
$res = $ob->Add($fields);
if ($res) {
self::createIBlockRights($res);
$list = new \CList($res);
if (isset($iblock["~NAME_FIELD"])) {
$list->UpdateField("NAME", $iblock["~NAME_FIELD"]);
}
$list->Save();
\CLists::setLiveFeed(1, $res);
return $res;
}
return 0;
}
示例15: installIblock
/**
* Add tables to the infoblock
*
* @return bool
*/
public function installIblock()
{
$db_iblock_type = CIBlockType::GetList(array(), array('=ID' => CODE_IBLOCK_TYPE));
if (!($ar_iblock_type = $db_iblock_type->Fetch())) {
global $DB;
$obBlocktype = new CIBlockType();
$DB->StartTransaction();
$res = $obBlocktype->Add(array('ID' => CODE_IBLOCK_TYPE, 'SECTIONS' => 'Y', 'IN_RSS' => 'N', 'SORT' => 500, 'LANG' => array('ru' => array('NAME' => 'Сервисы', 'SECTION_NAME' => 'Разделы', 'ELEMENT_NAME' => 'Страницы'), 'en' => array('NAME' => 'Servies', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Pages'))));
if (!$res) {
$DB->Rollback();
echo 'Error: ' . $obBlocktype->LAST_ERROR . '<br>';
} else {
$DB->Commit();
}
}
$idBlock = 0;
$res = CIBlock::GetList(array(), array('TYPE' => CODE_IBLOCK_TYPE, 'SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', "CODE" => CODE_IBLOCK_CODE), true);
if (!($ar_res = $res->Fetch())) {
$ib = new CIBlock();
$arFields = array("ACTIVE" => 'Y', "NAME" => 'СЕО страницы', "CODE" => CODE_IBLOCK_CODE, "LIST_PAGE_URL" => "", "DETAIL_PAGE_URL" => "", "IBLOCK_TYPE_ID" => CODE_IBLOCK_TYPE, "SITE_ID" => array(SITE_ID), "SORT" => '500', "GROUP_ID" => array("2" => "R"));
$idBlock = $ib->Add($arFields);
} else {
$idBlock = $ar_res['ID'];
}
$PropID = 0;
$properties = CIBlockProperty::GetList(array("sort" => "asc"), array("ACTIVE" => "Y", "IBLOCK_ID" => $idBlock, "CODE" => CODE_PROP_IBLOCK));
if (!($prop_fields = $properties->GetNext())) {
$arFieldsProps = array("NAME" => "URL копия", "ACTIVE" => "Y", "SORT" => "500", "CODE" => CODE_PROP_IBLOCK, "PROPERTY_TYPE" => "S", "IS_REQUIRED" => 'Y', "IBLOCK_ID" => $idBlock);
$ibp = new CIBlockProperty();
$PropID = $ibp->Add($arFieldsProps);
} else {
$PropID = $prop_fields['ID'];
}
global $DB;
$DB->PrepareFields("b_citfact_uservars_group");
$arFieldsDB = array('NAME' => "'СЕО Страницы'", 'CODE' => "'" . CODE_GROUP_USER_VARS . "'");
$IDGroup = $DB->Insert("b_citfact_uservars_group", $arFieldsDB, $err_mess . __LINE__);
$IDGroup = intval($IDGroup);
$arFieldsDB = array('GROUP_ID' => "'" . $IDGroup . "'", 'NAME' => "'ID свойства в SEO'", 'CODE' => "'" . CODE_PROPS_SEO_BLOCK_USER_VARS . "'", 'VALUE' => "'" . $PropID . "'", 'DESCRIPTION' => "'Символьный код свойства в инфоблоке SEO Страниц'");
$DB->Insert("b_citfact_uservars", $arFieldsDB, $err_mess . __LINE__);
$arFieldsDB = array('GROUP_ID' => "'" . $IDGroup . "'", 'NAME' => "'Инфоблок SEO'", 'CODE' => "'" . CODE_ID_SEO_BLOCK_USER_VARS . "'", 'VALUE' => "'" . $idBlock . "'", 'DESCRIPTION' => "'Инфоблок SEO'");
$DB->Insert("b_citfact_uservars", $arFieldsDB, $err_mess . __LINE__);
$arFieldsDB = array('GROUP_ID' => "'" . $IDGroup . "'", 'NAME' => "'Редирект'", 'CODE' => "'" . CODE_IS_REDIRECT_SEO . "'", 'VALUE' => "'N'", 'DESCRIPTION' => "'Если установлен данный параметр, будет работать редирект из обычной страницы на сео-страницу'");
$DB->Insert("b_citfact_uservars", $arFieldsDB, $err_mess . __LINE__);
return true;
}