本文整理匯總了PHP中CIBlock::SetMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP CIBlock::SetMessages方法的具體用法?PHP CIBlock::SetMessages怎麽用?PHP CIBlock::SetMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CIBlock
的用法示例。
在下文中一共展示了CIBlock::SetMessages方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
/**
*
*/
public function process()
{
if ($this->processed) {
return;
}
$this->processed = true;
foreach ($this->generateData() as $k => $v) {
$this->data[$k] = $v;
}
$this->update();
$o = new \CIBlock();
$mesages = $this->messages();
$o->SetMessages($this->getId(), $mesages);
$fields = $this->fields();
$o->SetFields($this->getId(), $fields);
$props = $this->loadProperties();
$newProps = $this->properties();
foreach ($this->urlsProps() as $key => $data) {
$newProps[$key] = $data;
}
$o = new \CIBlockProperty();
foreach ($props as $prop => $data) {
if (!isset($newProps[$prop])) {
$o->Delete($data['ID']);
}
}
foreach ($newProps as $prop => $data) {
$data['CODE'] = $prop;
if ($data['PROPERTY_TYPE'] == 'E' || $data['PROPERTY_TYPE'] == 'G') {
if (!isset($data['LINK_IBLOCK_ID'])) {
if (isset($data['LINK_IBLOCK_CODE'])) {
$data['LINK_IBLOCK_ID'] = self::codeToId($data['LINK_IBLOCK_CODE']);
}
}
}
if (isset($props[$prop])) {
$id = $props[$prop]['ID'];
$o->Update($id, $data);
} else {
$data['IBLOCK_ID'] = $this->getId();
$id = $o->Add($data);
}
if ($data['PROPERTY_TYPE'] == 'L' && isset($data['ITEMS']) && is_array($data['ITEMS'])) {
$items = array();
$newItems = $data['ITEMS'];
$res = \CIBlockPropertyEnum::GetList(array(), array('PROPERTY_ID' => $id, 'CHECK_PERMISSIONS' => 'N'));
while ($row = $res->Fetch()) {
$iid = $row['ID'];
$eid = $row['EXTERNAL_ID'];
if (!isset($newItems[$eid])) {
\CIBlockPropertyEnum::Delete($iid);
} else {
$items[$eid] = $row;
}
}
$eo = new \CIBlockPropertyEnum();
foreach ($newItems as $eid => $edata) {
if (is_string($edata)) {
$edata = array('VALUE' => $edata);
}
$edata['PROPERTY_ID'] = $id;
$edata['EXTERNAL_ID'] = $eid;
$edata['XML_ID'] = $eid;
if (isset($items[$eid])) {
$eo->Update($items[$eid]['ID'], $edata);
} else {
$eo->Add($edata);
}
}
}
}
}