/** * Индексация всех страниц в базу поиска по сайту. * * @param string $section Полный строковой идентификатор раздела. */ function pages_searchIndexAll($section) { $idsec = getSectionId($section); A::$DB->query("SELECT * FROM {$section} WHERE type='page'"); while ($row = A::$DB->fetchRow()) { $name = getTreePath($section, $row['level'] == 0 || $row['urlname'] != 'index' ? $row['id'] : $row['idker'], " - "); A_SearchEngine::getInstance()->updateIndex($idsec, $row['id'], $name, $row['content'], $row['tags']); } A::$DB->free(); }
/** * Формирование данных доступных в шаблоне. */ function createData() { $this->Assign("categories_count", A::$DB->getOne("SELECT COUNT(*) FROM {$this->section}_categories")); $this->Assign("items_count", A::$DB->getOne("SELECT COUNT(*) FROM {$this->section}_catalog")); if ($usecomments = getOption($this->section, "usecomments")) { $idsec = getSectionId($this->section); $this->Assign("usecomments", $usecomments); $this->Assign("comments_count", A::$DB->getOne("SELECT COUNT(*) FROM " . DOMAIN . "_comments WHERE idsec={$idsec}")); } }
/** * Получение полных данных записи каталога. * * @param integer $id Идентификатор материала. * @param string $section Полный строковой идентификатор раздела. * @param integer $idsec=0 Числовой идентификатор раздела. * @return array */ function catalog_getItem($id, $section, $idsec = 0) { static $cache = array(); if (isset($cache[$section][$id])) { return $cache[$section][$id]; } if ($row = A::$DB->getRow("SELECT * FROM {$section}_catalog WHERE id=?i AND active='Y'", $id)) { if (!$idsec) { $idsec = getSectionId($section); } $row['link'] = catalog_createItemLink($row['id'], $section); $row['vote'] = round($row['vote'], 2); if ($row['idcat'] > 0) { $row['category'] = getTreePath("{$section}_categories", $row['idcat']); } $row['images'] = A::$DB->getAll("SELECT * FROM " . A::$DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($idsec, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); prepareValues($section, $row); $row = A::$OBSERVER->Modifier('catalog_prepareValues', $section, $row); return $cache[$section][$id] = $row; } else { return $cache[$section][$id] = false; } }
} else { $arUpdateValues["PROPERTY_VALUES"][$arPropV["ID"]] = array("VALUE" => $arPropV["VALUE"], "DESCRIPTION" => $arPropV["DESCRIPTION"]); } } } if (!($res = $oElement->Update($arParams["ID"], $arUpdateValues, $bWorkflowIncluded, true, $arParams["RESIZE_IMAGES"]))) { $arResult["ERRORS"][] = $oElement->LAST_ERROR; } } else { $arUpdateValues["IBLOCK_ID"] = $arParams["IBLOCK_ID"]; // set activity start date for new element to current date. Change it, if ya want ;-) if (strlen($arUpdateValues["DATE_ACTIVE_FROM"]) <= 0) { $arUpdateValues["DATE_ACTIVE_FROM"] = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"); } if ($arParams['SECTION_CODE']) { $arUpdateValues['IBLOCK_SECTION_ID'] = getSectionId($arParams['SECTION_CODE']); } $sAction = "ADD"; if (!($arParams["ID"] = $oElement->Add($arUpdateValues, $bWorkflowIncluded, true, $arParams["RESIZE_IMAGES"]))) { $arResult["ERRORS"][] = $oElement->LAST_ERROR; } else { foreach ($arUpdateValues['PROPERTY_VALUES'] as $key => $val) { $temp = findCode($key, $val); if ($temp['VALUE']) { $arProps[$temp['CODE']] = $temp['VALUE']; } else { $arProps[$temp['CODE']] = $val; } unset($temp); } $arFields = array("NAME" => $arUpdateValues['NAME'], "PREVIEW_TEXT" => $arUpdateValues['PREVIEW_TEXT']);
/** * Индексация страницы в базу поиска по сайту. * * @param string $section Полный строковой идентификатор раздела. */ function feedback_searchIndexAll($section) { $idsec = getSectionId($section); $name = A::$DB->getOne("SELECT caption_" . A::$LANG . " FROM " . DOMAIN . "_sections WHERE id=" . $idsec); A_SearchEngine::getInstance()->updateIndex($idsec, 0, $name, getTextOption($section, 'content')); }
/** * Обработчик события "Удаление элемента из базы поиска по сайту". * * @param string $section Полный строковой идентификатор раздела. * @param array $params Параметры события. */ function search_delete($section, $params) { $idsec = getSectionId($section); A_SearchEngine::getInstance()->deleteIndex($idsec, $params['id']); }
function fcategory_prepareValues($section, $data) { static $structure = null; static $fields = array(); static $sections = array(); if (is_null($structure)) { $structure = getStructureByPlugin('fcategory'); } if (!$structure) { return $data; } if (isset($sections[$section])) { $idsec = $sections[$section]; } else { $idsec = $sections[$section] = getSectionId($section); } if (!isset($fields[$idsec])) { $fields[$idsec] = A::$DB->getAssoc("SELECT f.field,f.* FROM {$structure} AS f WHERE f.idsec={$idsec} ORDER BY sort"); foreach ($fields[$idsec] as $field => $row) { if ($row['type'] == "select" || $row['type'] == "mselect") { $fields[$idsec][$field]['options'] = loadList($row['property']); } } } $data['fields'] = array(); foreach ($fields[$idsec] as $field => $row) { if (isset($data[$field])) { switch ($row['type']) { case 'select': $data[$field . '_id'] = $data[$field]; $data[$field] = isset($row['options'][$data[$field]]) ? $row['options'][$data[$field]] : ""; break; case 'mselect': $values = explode(",", $data[$field]); $options = array(); foreach ($values as $i => $value) { $value = (int) $value; if (isset($row['options'][$value])) { $options[$value] = $row['options'][$value]; $values[$i] = is_array($row['options'][$value]) ? $row['options'][$value]['name'] : $row['options'][$value]; } else { $values[$i] = ""; } } $data[$field] = implode(", ", $values); $data[$field . '_options'] = $options; break; case 'bool': $data[$field . '_id'] = $data[$field]; switch ($data[$field]) { case 'Y': $data[$field] = "Да"; break; case 'N': $data[$field] = "Нет"; break; default: $data[$field] = ""; } } $data['fields'][] = array('field' => $field, 'name' => $row['name'], 'value' => is_array($data[$field]) ? $data[$field]['name'] : $data[$field]); } } return $data; }