<h3 class="block-title"><?php echo $arChannel["UF_TITLE"]; ?> </h3> </div> <div class="block-body"> <a href="#" class="close-link" data-dismiss="modal"><span data-icon="icon-times"></span></a> <div class="player-holder"> <div id="player"></div> </div> </div> </div> <?php } else { if (!preg_match("/^[\\d\\+]+\$/", $_GET["broadcastID"])) { $result = \Hawkart\Megatv\ProgExternalTable::getList(array('filter' => array("=UF_EXTERNAL_ID" => $_GET["broadcastID"]), 'select' => array("ID", "UF_TITLE", "UF_EXTERNAL_ID", "UF_THUMBNAIL_URL", "UF_VIDEO_URL", "UF_JSON"))); if ($row = $result->fetch()) { $arVideo["VIDEO_URL"] = $row["UF_VIDEO_URL"]; if (strpos($arVideo["VIDEO_URL"], "rutube") !== false && !empty($arVideo["VIDEO_URL"])) { $arVideo["VIDEO_URL"] = str_replace("play", "video", $arVideo["VIDEO_URL"]) . "?sTitle=false&sAuthor=false"; } else { $doc = new DOMDocument(); $doc->loadHTML($row["UF_JSON"]["html"]); $arVideo["VIDEO_URL"] = $doc->getElementsByTagName('iframe')->item(0)->getAttribute('src'); } $arVideo["NAME"] = $row["UF_TITLE"]; } ?> <div class="broadcast-player" data-module="broadcast-player"> <script type="text/x-config"> {
$arFilter = array("=UF_EPG_ID" => $_REQUEST["EPG_ID"]); $arSelect = array("ID", "UF_TITLE", "UF_DESC"); $obCache = new \CPHPCache(); if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/serialByEpgID/")) { $arResult["SERIAL"] = $obCache->GetVars(); } elseif ($obCache->StartDataCache()) { $result = \Hawkart\Megatv\SerialTable::getList(array('filter' => $arFilter, 'select' => $arSelect)); if ($row = $result->fetch()) { $arResult["SERIAL"] = $row; } $obCache->EndDataCache($arResult["SERIAL"]); } $arFilter = array("=UF_SERIAL.UF_EPG_ID" => $_REQUEST["EPG_ID"]); $arSelect = array("ID", "UF_TITLE", "UF_EXTERNAL_ID", "UF_THUMBNAIL_URL"); $obCache = new \CPHPCache(); if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/serialProgExList/")) { $arResult["ITEMS"] = $obCache->GetVars(); } elseif ($obCache->StartDataCache()) { $result = \Hawkart\Megatv\ProgExternalTable::getList(array('filter' => $arFilter, 'select' => $arSelect)); while ($row = $result->fetch()) { if (strpos($row["UF_THUMBNAIL_URL"], "rutube") !== false) { $row["UF_THUMBNAIL_URL"] .= "?size=m"; } $arResult["ITEMS"][] = $row; } $obCache->EndDataCache($arResult["ITEMS"]); } $APPLICATION->SetTitle($arResult["SERIAL"]["UF_TITLE"]); $APPLICATION->SetPageProperty($arResult["SERIAL"]["UF_TITLE"]); $APPLICATION->SetPageProperty("description", TruncateText($arResult["SERIAL"]["UF_DESC"], 256)); $this->IncludeComponentTemplate();
/** * Import all serials href from resource to db */ public static function importSerialsByWeek() { $arTableSerials = array(); $result = \Hawkart\Megatv\SerialTable::getList(array('filter' => array("!UF_EPG_ID" => false, "UF_EXTERNAL_URL" => "%rutube%"), 'select' => array("ID", "UF_TITLE", "UF_EXTERNAL_URL"))); while ($row = $result->fetch()) { $serial_id = preg_replace("/[^0-9]/", "", $row["UF_EXTERNAL_URL"]); $arTableSerials[$serial_id] = $row; } foreach ($arTableSerials as $serial_id => $arSerial) { $arTableItems = array(); $result = \Hawkart\Megatv\ProgExternalTable::getList(array('filter' => array("=UF_SERIAL_ID" => $arSerial["ID"]), 'select' => array("ID", "UF_SERIAL_ID", "UF_EXTERNAL_ID"))); while ($row = $result->fetch()) { $arTableItems[] = $row["UF_EXTERNAL_ID"]; } $arItems = self::search($arSerial["UF_TITLE"], "week", $serial_id); /** * Add items for serials in db table */ foreach ($arItems as $arItem) { if (!in_array($arItem["ID"], $arTableItems)) { $arFields = array("UF_TITLE" => $arItem["TITLE"], "UF_EXTERNAL_ID" => $arItem["ID"], "UF_SERIAL_ID" => $arSerial["ID"], "UF_THUMBNAIL_URL" => $arItem["THUMBNAIL_URL"], "UF_VIDEO_URL" => $arItem["VIDEO_URL"], "UF_JSON" => $arItem["JSON"]); $result = \Hawkart\Megatv\ProgExternalTable::add($arFields); if ($result->isSuccess()) { $arTableItems[] = $arItem["ID"]; } else { $errors = $result->getErrorMessages(); } } } } }
} else { $APPLICATION->SetTitle($arResult["PAGE_TITLE"]); $APPLICATION->SetPageProperty("description", TruncateText($arResult["UF_DESCRIPTION"], 256)); $APPLICATION->SetDirProperty("h1", $arResult["UF_H1"] ? $arResult["UF_H1"] : $arResult["UF_TITLE"]); //FOR SEO $url_params = parse_url($_SERVER["REQUEST_URI"]); if (substr($url_params["path"], -1) != "/") { $url = $url_params["path"] . "/"; if (!empty($url_params["query"])) { $url .= "?" . $url_params["query"]; } LocalRedirect($url, false, "301 Moved permanently"); } } $offset = 0; if ($_REQUEST["AJAX"] == "Y") { $offset = $_REQUEST["offset"]; } $arResult["PROGS"] = array(); $result = \Hawkart\Megatv\ProgExternalTable::getList(array('filter' => array("UF_SERIAL.UF_CHANNEL_ID" => '%"' . $arResult['UF_CHANNEL_BASE_ID'] . '"%'), 'select' => array("ID", "UF_TITLE", "UF_EXTERNAL_ID", "UF_THUMBNAIL_URL", "UF_JSON"), 'order' => array("UF_DATETIME" => "DESC"), 'limit' => $arParams["NEWS_COUNT"], 'offset' => $offset)); while ($row = $result->fetch()) { if (strpos($row["UF_THUMBNAIL_URL"], "rutube") !== false) { $row["UF_THUMBNAIL_URL"] .= "?size=m"; } $arResult["ITEMS"][] = $row; } /** * Add data to statistics */ //\Hawkart\Megatv\CStat::channelAdd($arResult["ID"]); $this->IncludeComponentTemplate();
public static function importByExternalID($id, $serial_id = false) { $arVideos = self::getVideosByIds(array($id => " ")); $arItem = $arVideos[0]; print_r($arItem); if (!empty($arItem)) { $datetime = new \Bitrix\Main\Type\DateTime(date("Y-m-d H:i:s", strtotime($arItem["JSON"]["publishedAt"])), 'Y-m-d H:i:s'); $arFields = array("UF_TITLE" => $arItem["TITLE"], "UF_EXTERNAL_ID" => $arItem["ID"], "UF_SERIAL_ID" => $serial_id, "UF_THUMBNAIL_URL" => $arItem["THUMBNAIL_URL"], "UF_VIDEO_URL" => $arItem["VIDEO_URL"], "UF_JSON" => $arItem["JSON"], "UF_DATETIME" => $datetime); $result = \Hawkart\Megatv\ProgExternalTable::add($arFields); if ($result->isSuccess()) { $arTableItems[] = $arItem["ID"]; } else { $errors = $result->getErrorMessages(); } $arItems = array(); $file = $_SERVER['DOCUMENT_ROOT'] . "/upload/serials_50_60.txt"; $json = file_get_contents($file); $arProgs = json_decode($json, true); foreach ($arProgs as $arProg) { if ($arProg["EXTERNAL_ID"] != $id) { $arItems[] = $arProg; } } file_put_contents($file, json_encode($arItems)); } }
public function down() { global $APPLICATION; \Bitrix\Main\Loader::includeModule("highloadblock"); $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\ProgExternalTable::getTableName())))->fetch(); if ($arHlblock) { $oUserTypeEntity = new \CUserTypeEntity(); $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => "UF_DATETIME")); if ($aUserHasField = $resProperty->Fetch()) { $oUserTypeEntity->Delete($aUserHasField['ID']); $this->outSuccess("Свойство 'Дата добавления' удалено!"); } } }