unset($arResult["ITEMS"][$key]); } $k++; } unset($arResult["ITEMS"]); /** * Create list date & channels with schedules */ $arResult["DATES"] = array(); //Получим все программы текущих каналов за выбранный день if (!isset($_REQUEST["date"])) { $arParams["CURRENT_DATE"] = date("d.m.Y"); } else { $arParams["CURRENT_DATE"] = $_REQUEST["date"]; } $arDate = \CTimeEx::getDateFilter($arParams["CURRENT_DATE"]); $dateStart = date("Y-m-d H:i:s", strtotime($arDate["DATE_FROM"])); $dateEnd = date("Y-m-d H:i:s", strtotime($arDate["DATE_TO"])); $arFilter = array("=UF_CHANNEL_ID" => $arChannelIds, ">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s'), "<UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateEnd, 'Y-m-d H:i:s')); $arSelect = array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_ID", "UF_PROG_ID", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_RATING" => "UF_PROG.UF_RATING", "UF_PROG_CODE" => "UF_PROG.UF_CODE"); $obCache = new \CPHPCache(); if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/index-schedules/")) { $arResult["DATES"] = $obCache->GetVars(); } elseif ($obCache->StartDataCache()) { $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_DATE_START" => "ASC"))); while ($arSchedule = $result->fetch()) { $channel = $arSchedule["UF_CHANNEL_ID"]; $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_START']->toString()); $arSchedule["UF_DATE_END"] = $arSchedule["DATE_END"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_END']->toString()); $arSchedule["UF_DATE"] = $arSchedule["DATE"] = substr($arSchedule["DATE_START"], 0, 10); $arSchedule["PROG_ID"] = $arSchedule["UF_PROG_ID"];
} return $arProgs; } $arResult["PROGS"] = array(); $countPerPage = intval($arParams["NEWS_COUNT"]); $count = 0; $offset = 0; $prog_ids = array(); $limit = intval($arParams["NEWS_COUNT"]); if ($_REQUEST["AJAX"] == "Y") { $offset = intval($_REQUEST["offset"]); $dateStart = substr($_REQUEST["date"], 0, 10) . date(" H:i:s"); $dateStart = date("Y-m-d H:i:s", strtotime($dateStart)); $dateEnd = date("Y-m-d H:i:s", strtotime("+1 day", strtotime($dateStart))); } else { $arDate = \CTimeEx::getDateFilter($arTime["SERVER_DATETIME"]); $dateStart = date("Y-m-d H:i:s"); $dateEnd = date("Y-m-d H:i:s", strtotime($arDate["DATE_TO"])); } $arFilter = array("=UF_PROG.UF_ACTIVE" => 1, ">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s'), "<UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateEnd, 'Y-m-d H:i:s'), "!UF_CATEGORY" => "Новости"); $arSelect = array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_ID", "UF_PROG_ID", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_CHANNEL_CODE" => "UF_CHANNEL.UF_BASE.UF_CODE", "UF_CATEGORY" => "UF_PROG.UF_CATEGORY", "UF_ID" => "UF_PROG.UF_EPG_ID", "UF_PROG_CODE" => "UF_PROG.UF_CODE"); if ($USER->IsAuthorized() && $_REQUEST["AJAX"] != "Y") { $arProgByUsers = array(); $arRecords = $APPLICATION->GetPageProperty("ar_record_status"); $arRecordsStatuses = json_decode($arRecords, true); $recording_ids = array(); foreach ($arRecordsStatuses["RECORDING"] as $schedule_id => $arRecord) { $recording_ids[] = $schedule_id; } $arFilter["=UF_CHANNEL_ID"] = \Hawkart\Megatv\ChannelTable::getActiveIdByCityByUser(); if (count($recording_ids) > 0) {
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $arResult["PROGS"] = array(); $arTime = \CTimeEx::getDatetime(); $prog_ids = array(); //get progs by rating $arDate = \CTimeEx::getDateFilter($arTime["SELECTED_DATE"]); $dateStart = date("Y-m-d H:i:s", strtotime($arDate["DATE_FROM"])); $dateEnd = date("Y-m-d H:i:s", strtotime($arDate["DATE_TO"])); $arFilter = array("UF_PROG.UF_ACTIVE" => 1, "UF_CHANNEL_ID" => \Hawkart\Megatv\ChannelTable::getActiveIdByCityByUser(), ">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s'), "<UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateEnd, 'Y-m-d H:i:s')); $arSelect = array("ID", "UF_CODE", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_ID", "UF_PROG_ID", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_ICON" => "UF_CHANNEL.UF_BASE.UF_ICON", "UF_CHANNEL_CODE" => "UF_CHANNEL.UF_BASE.UF_CODE", "UF_ID" => "UF_PROG.UF_EPG_ID"); $arOrder = array("UF_PROG.UF_RATING" => "DESC"); $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => $arOrder, 'limit' => 24)); while ($arSchedule = $result->fetch()) { if (in_array($arSchedule["UF_PROG_ID"], $prog_ids)) { continue; } $prog_ids[] = $arSchedule["UF_PROG_ID"]; //for unrepeat $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_START']->toString()); $arSchedule["UF_DATE_END"] = $arSchedule["DATE_END"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_END']->toString()); $arSchedule["UF_DATE"] = $arSchedule["DATE"] = substr($arSchedule["DATE_START"], 0, 10); $arSchedule["DETAIL_PAGE_URL"] = "/channels/" . $arSchedule["UF_CHANNEL_CODE"] . "/" . $arSchedule["UF_ID"] . "/?event=" . $arSchedule["ID"]; $arResult["PROGS"][] = $arSchedule; } if ($arParams["TEMPLATE"] == "MAIN_PAGE") { $arResult["PROGS"] = \Hawkart\Megatv\CScheduleView::setRecommendIndex(array("PROGS" => $arResult["PROGS"])); }