Beispiel #1
0
// возможные варианты сортировок
$orderBy = array('D' => 'date', 'N' => 'name', 'P' => 'price', 'Y' => 'year', 'M' => 'distance');
if (!array_key_exists($arParams['ORDER_BY'], $orderBy)) {
    $arParams['ORDER_BY'] = false;
} else {
    $arParams['ORDER_BY'] = $orderBy[$arParams['ORDER_BY']];
}
if (!in_array($arParams['ORDER_DIRECTION'], array('asc', 'desc'))) {
    $arParams['ORDER_DIRECTION'] = false;
}
$filterParams = array_key_exists('FS', $_REQUEST) ? $_REQUEST['FS'] : array();
/************************** клиент, запрос к сервису **************************/
// Параметры запроса
$client = new maxCacheXmlClient(array('api_version' => 1, 'dealer_id' => $dealerId, 'password' => $password, 'cache_dir' => $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . '/cache/maxposter/'));
// Запрос к сервису / кешу
$client->setRequestThemeName($arParams['REQUEST_THEME']);
// TODO: настройки и параметры
$client->setGetParameters(array('page' => $arParams['PAGE'], 'page_size' => COption::GetOptionString($moduleId, 'MAX_PAGE_SIZE')));
// TODO: ловить входящие данные
$searchParams = array();
if ($arParams['ORDER_BY']) {
    $searchParams['order_by'] = $arParams['ORDER_BY'];
}
if ($arParams['ORDER_DIRECTION']) {
    $searchParams['order_direction'] = $arParams['ORDER_DIRECTION'];
}
$searchParams = array_merge($searchParams, $filterParams);
$client->setRequestParams(array('search' => $searchParams));
$domXml = $client->getXml()->saveXML();
// при ошибке запроса
if ($client->getResponseThemeName() == 'error') {
Beispiel #2
0
    $password = $arParams['MAX_API_PASSWORD'];
}
$arParams['VEHICLE_ID'] = ctype_digit($arParams['VEHICLE_ID']) && 0 < $arParams['VEHICLE_ID'] ? intval($arParams['VEHICLE_ID']) : $_REQUEST['VEHICLE_ID'];
#var_dump($arParams);
$arUrlDefault = array('URL_TEMPLATES_INDEX' => '', 'URL_TEMPLATES_VEHICLE' => 'VEHICLE_ID=#VEHICLE_ID#');
foreach ($arUrlDefault as $urlKey => $url) {
    if (!array_key_exists($urlKey, $arParams) || 0 >= strlen($arParams[$urlKey])) {
        $arParams[$urlKey] = $APPLICATION->GetCurPage() . '?' . htmlspecialcharsbx($url);
    }
}
/************************** клиент, запрос к сервису **************************/
// Параметры запроса
$client = new maxCacheXmlClient(array('api_version' => 1, 'dealer_id' => $dealerId, 'password' => $password, 'cache_dir' => $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . '/cache/maxposter/'));
// Запрос к сервису / кешу
try {
    $client->setRequestThemeName($arParams['VEHICLE_ID']);
} catch (maxException $e) {
    CHTTP::SetStatus("404 Not Found");
    @define("ERROR_404", "Y");
    ShowError(GetMessage('MAX_NOT_FOUND'));
    return;
}
$domXml = $client->getXml()->saveXML();
// при ошибке запроса
if ($client->getResponseThemeName() == 'error') {
    CHTTP::SetStatus("404 Not Found");
    ShowError(GetMessage('MAX_VEHICLE_NOT_FOUND'));
    return;
}
if (mb_strtolower(SITE_CHARSET) != 'utf-8') {
    $data = iconv('utf-8', SITE_CHARSET, $domXml);