public function up() { global $APPLICATION; $arProgs = array(); $codes = array(); $result = \Hawkart\Megatv\ProgTable::getList(array('filter' => array(), 'select' => array("ID", "UF_TITLE", "UF_CODE", "UF_EPG_ID"))); while ($row = $result->fetch()) { $arParams = array("replace_space" => "-", "replace_other" => "-"); $code = \CDev::translit(trim($row["UF_TITLE"]), "ru", $arParams); if (!empty($row["UF_CODE"])) { $codes[$row["UF_TITLE"]] = $row; continue; } $arCode = $codes[$row["UF_TITLE"]]; if (!empty($arCode)) { if ($row["UF_EPG_ID"] != $arCode["UF_EPG_ID"]) { $code .= "-" . $row["ID"]; } else { $code = $arCode["UF_CODE"]; } } \Hawkart\Megatv\ProgTable::update($row["ID"], array("UF_CODE" => $code)); $row["UF_CODE"] = $code; $codes[$row["UF_TITLE"]] = $row; } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } global $USER, $APPLICATION, $arSite; $arResult = array(); $arParams = $arParams + array("DATETIME" => \CTimeEx::getDatetime(), "LIST_URL" => $APPLICATION->GetCurDir(), "BACK_URL" => $_SERVER['HTTP_REFERER']); //Get prog detail $arFilter = array("=UF_CODE" => $arParams["ELEMENT_CODE"]); $arSelect = array("ID", "UF_TITLE", "UF_SUB_TITLE", "UF_IMG_PATH" => "UF_IMG.UF_PATH", "UF_RATING", "UF_DESC", "UF_SUB_DESC", "UF_GANRE", "UF_YEAR_LIMIT", "UF_COUNTRY", "UF_YEAR", "UF_DIRECTOR", "UF_PRESENTER", "UF_ACTOR", "UF_CATEGORY"); $obCache = new \CPHPCache(); if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/prog-detail/")) { $arResult = $obCache->GetVars(); } elseif ($obCache->StartDataCache()) { $result = \Hawkart\Megatv\ProgTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'limit' => 1)); if ($arResult = $result->fetch()) { $arResult["UF_PROG_ID"] = $arResult["ID"]; $arResult["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arResult["UF_IMG_PATH"], array(600, 600)); $arResult["KEYWORDS"] = array($arResult["UF_CATEGORY"], $arResult["UF_GANRE"]); } $obCache->EndDataCache($arResult); } //Get Shedule inform for prog if (empty($_REQUEST["event"])) { $arDate = \CTimeEx::getDateTimeFilter($arParams["DATETIME"]["SERVER_DATETIME"]); $dateStart = date("Y-m-d H:i:s"); $arFilter = array("=UF_PROG.UF_CODE" => $arParams["ELEMENT_CODE"], ">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s')); } else { $arFilter = array("=UF_PROG.UF_CODE" => $arParams["ELEMENT_CODE"], "=ID" => $_REQUEST["event"]); }
/** * Add new serials to the table Serials */ public static function guessSerials() { /** * Get serials list */ $arSerials = array(); $result = SerialTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("UF_EPG_ID", "ID", "UF_CHANNEL_ID"))); while ($row = $result->fetch()) { $arSerials[$row["UF_EPG_ID"]] = $row; } /** * Get prog's list */ $arProgs = array(); $result = ProgTable::getList(array('filter' => array(), 'select' => array("UF_EPG_SUB_ID", "ID", "UF_TITLE", "UF_EPG_ID"))); while ($row = $result->fetch()) { if (!empty($row["UF_EPG_SUB_ID"])) { $arProgs[$row["UF_EPG_ID"]] = $row["UF_TITLE"]; } } foreach ($arProgs as $epg_id => $serial_title) { if (empty($arSerials[$epg_id])) { $arFields = array("UF_EPG_ID" => $epg_id, "UF_TITLE" => $serial_title); $result = SerialTable::add($arFields); if ($result->isSuccess()) { $serial_id = $result->getId(); $arSerials[$epg_id] = array("ID" => $serial_id); } } } }
public static function getProgsByRating() { $ids = array(); $arProgs = array(); $result = \Hawkart\Megatv\ProgTable::getList(array('filter' => array("=UF_ACTIVE" => 1), 'select' => array("ID", "UF_EPG_ID", "UF_GANRE"), 'order' => array("UF_RATING" => "DESC"))); while ($arSchedule = $result->fetch()) { if (in_array($arSchedule["UF_EPG_ID"], $ids)) { continue; } $ids[] = $arSchedule["UF_EPG_ID"]; $arSchedule["UF_GANRE"] = explode(",", $arSchedule["UF_GANRE"]); $arProgs[] = $arSchedule; } unset($ids); return $arProgs; }
* Delete script */ $DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"] = realpath(dirname(__FILE__) . '/../'); define("NO_KEEP_STATISTIC", true); define("NOT_CHECK_PERMISSIONS", true); set_time_limit(0); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; header('Content-Type: text/html; charset=utf-8'); ini_set('mbstring.func_overload', '2'); ini_set('mbstring.internal_encoding', 'UTF-8'); global $USER, $APPLICATION; if (!is_object($USER)) { $USER = new \CUser(); } $arSerials = array(); $result = \Hawkart\Megatv\ProgTable::getList(array('filter' => array("!UF_EPG_SUB_ID" => false), 'select' => array("ID", "UF_TITLE", "UF_SERIA", "UF_SEASON", "UF_SOCIAL_VIDEO", "UF_EPG_ID"))); while ($arProg = $result->fetch()) { $arVideos = json_decode($arProg["UF_SOCIAL_VIDEO"], true); if (empty($arVideos["RUTUBE"])) { if ($rutube = \Hawkart\Megatv\Social\RutubeClient::search($arProg["UF_TITLE"], $arProg["UF_SEASON"], $arProg["UF_SERIA"])) { $arVideos["RUTUBE"] = $rutube; } } if (empty($arVideos["VK"])) { $title = $arProg["UF_TITLE"]; if (!empty($arProg["UF_SEASON"])) { $title .= ": сезон " . $arProg["UF_SEASON"]; } if (!empty($arProg["UF_SERIA"])) { $title .= " серия " . $arProg["UF_SERIA"]; }