Exemple #1
0
function getRecommendForAll($arFilter, $arSelect, $limit, $offset)
{
    $arProgs = array();
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_PROG.UF_RATING" => "DESC"), 'limit' => 12, 'offset' => $offset));
    while ($arSchedule = $result->fetch()) {
        $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_PROG_CODE"] . "/?event=" . $arSchedule["ID"];
        $arProgs[] = $arSchedule;
    }
    return $arProgs;
}
Exemple #2
0
 /**
  * Connect serials & channels by prog schedules
  */
 public static function connectToChannels()
 {
     $arSerials = array();
     $result = self::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;
     }
     $arSerialChannels = array();
     $result = ScheduleTable::getList(array('filter' => array("=UF_CHANNEL.UF_BASE.UF_ACTIVE" => 1, "=UF_PROG.UF_ACTIVE" => 1), 'select' => array("SID" => "UF_PROG.UF_EPG_ID", "CHANNEL_BASE_ID" => "UF_CHANNEL.UF_BASE_ID")));
     while ($arSchedule = $result->fetch()) {
         $arSerialChannels[$arSchedule["SID"]][] = $arSchedule["CHANNEL_BASE_ID"];
     }
     foreach ($arSerialChannels as $epg_id => $arChannels) {
         $arSerial = $arSerials[$epg_id];
         if (intval($arSerial["ID"]) > 0) {
             $channel_ids = array_merge((array) $arSerial["UF_CHANNEL_ID"], $arChannels);
             $channel_ids = array_unique($channel_ids);
             self::update($arSerial["ID"], array("UF_CHANNEL_ID" => $channel_ids));
         }
     }
 }
Exemple #3
0
}
global $USER, $APPLICATION;
$arResult = array();
$arParams = $arParams + array("DATETIME" => \CTimeEx::getDatetime(), "LIST_URL" => $APPLICATION->GetCurDir(), "BACK_URL" => $_SERVER['HTTP_REFERER']);
if (empty($_REQUEST["event"])) {
    $arFilter = array("=UF_PROG.UF_CODE" => $arParams["ELEMENT_CODE"]);
} else {
    $arFilter = array("=ID" => $_REQUEST["event"]);
}
$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_DESC" => "UF_PROG.UF_DESC", "UF_SUB_DESC" => "UF_PROG.UF_SUB_DESC", "UF_TOPIC" => "UF_PROG.UF_GANRE", "UF_YEAR_LIMIT" => "UF_PROG.UF_YEAR_LIMIT", "UF_COUNTRY" => "UF_PROG.UF_COUNTRY", "UF_YEAR" => "UF_PROG.UF_YEAR", "UF_DIRECTOR" => "UF_PROG.UF_DIRECTOR", "UF_PRESENTER" => "UF_PROG.UF_PRESENTER", "UF_ACTOR" => "UF_PROG.UF_ACTOR", "UF_ICON" => "UF_CHANNEL.UF_BASE.UF_ICON", "UF_CATEGORY" => "UF_PROG.UF_CATEGORY");
$obCache = new \CPHPCache();
if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/schedule-detail/")) {
    $arResult = $obCache->GetVars();
} elseif ($obCache->StartDataCache()) {
    //get channel by code
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'limit' => 1));
    if ($arResult = $result->fetch()) {
        $arResult["UF_DATE_START"] = $arResult["DATE_START"] = \CTimeEx::dateOffset($arResult['UF_DATE_START']->toString());
        $arResult["UF_DATE_END"] = $arResult["DATE_END"] = \CTimeEx::dateOffset($arResult['UF_DATE_END']->toString());
        $arResult["UF_DATE"] = $arResult["DATE"] = substr($arResult["DATE_START"], 0, 10);
        $arResult["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arResult["UF_IMG_PATH"], array(600, 600));
        $sec = strtotime($arResult["DATE_END"]) - strtotime($arResult["DATE_START"]);
        $arResult["DURATION"] = \CTimeEx::secToStr($sec);
        $arResult["KEYWORDS"] = array($arResult["UF_CATEGORY"], $arResult["UF_TOPIC"]);
    }
    $obCache->EndDataCache($arResult);
}
//redirect if error
if (intval($arResult["ID"]) == 0) {
    if (!empty($arFilter["=UF_PROG.UF_CODE"])) {
        CHTTP::SetStatus("404 Not Found");
Exemple #4
0
$query = htmlspecialcharsbx($_REQUEST["query"]);
$dateStart = date("Y-m-d H:00:00");
$arFilter = array("=UF_PROG.UF_ACTIVE" => 1, ">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s'), '%UF_PROG.UF_TITLE' => strtolower($query));
//User subscribe channel list
if ($USER->IsAuthorized()) {
    $arFilter["=UF_CHANNEL_ID"] = \Hawkart\Megatv\ChannelTable::getActiveIdByCityByUser();
} else {
    $arFilter["=UF_CHANNEL_ID"] = \Hawkart\Megatv\ChannelTable::getActiveIdByCity();
}
$arSelect = array("ID", "UF_CODE", "UF_DATE_START", "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_ID" => "UF_PROG.UF_EPG_ID", "UF_PROG_CODE" => "UF_PROG.UF_CODE");
$obCache = new \CPHPCache();
if ($obCache->InitCache(3600, serialize($arFilter) . serialize($arSelect), "/search-ajax/")) {
    $arResult = $obCache->GetVars();
} elseif ($obCache->StartDataCache()) {
    $arExclude = array();
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_PROG.UF_RATING" => "DESC")));
    while ($arSchedule = $result->fetch()) {
        if (in_array($arSchedule["UF_ID"], $arExclude)) {
            continue;
        } else {
            $arExclude[] = $arSchedule["UF_ID"];
        }
        $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = $arSchedule['UF_DATE_START']->toString();
        $arJson = array();
        $arJson["date"] = substr($arSchedule["UF_DATE_START"], 11, 5) . " | " . substr($arSchedule["UF_DATE_START"], 0, 10);
        $arJson["title"] = $arSchedule["UF_TITLE"];
        if ($arSchedule["UF_IMG_PATH"]) {
            $src = \Hawkart\Megatv\CFile::getCropedPath($arSchedule["UF_IMG_PATH"], array(300, 300));
            //$renderImage = CFile::ResizeImageGet($src, Array("width"=>60, "height"=>60));
            $arJson["thumbnail"] = $src;
        } else {
Exemple #5
0
 /**
  * Import Epg file 
  */
 public function import()
 {
     $arProgCropIds = array();
     //prog id list to crop image
     $arScheduleIdsNotDelete = array();
     $arProgTimeDelete = array();
     //Расписание, которое нужно удалить
     $arCategories = self::importCategory();
     $arGanres = self::importGanre();
     $arTopics = self::importTopic();
     $arCountries = self::importCountry();
     //$arProductions = self::importProduction();
     $arRoles = self::importRole();
     $arPeople = self::importPeople($arRoles);
     $arBaseChannels = $this->base_channels;
     $arChannels = $this->channels;
     //Delete cropped images
     //\CDev::deleteOldFiles($_SERVER["DOCUMENT_ROOT"]. self::$cut_dir, 0);
     //Delete schedule before prev day
     ScheduleTable::deleteOld();
     /**
      * Get prog's list
      */
     $arProgs = array();
     $result = ProgTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("UF_EPG_ID", "UF_EPG_SUB_ID", "ID", "UF_IMG_ID")));
     while ($row = $result->fetch()) {
         $arProgs[$row["UF_EPG_ID"] . $row["UF_EPG_SUB_ID"]] = $row;
     }
     /**
      * Get schedule's list
      */
     $arSchedules = array();
     $result = ScheduleTable::getList(array('filter' => array(), 'select' => array("UF_EPG_ID", "ID")));
     while ($row = $result->fetch()) {
         $arSchedules[$row["UF_EPG_ID"]] = $row["ID"];
     }
     foreach ($this->href_channels as $channel_epg_id => $xml_urls) {
         $arChannel = $arChannels[$channel_epg_id];
         $active = intval($arBaseChannels[$arChannel["UF_BASE_EPG_ID"]]["UF_ACTIVE"]);
         if (intval($arChannel["ID"]) <= 0 || empty($arChannel["ID"]) || $active != 1 || empty($channel_epg_id)) {
             continue;
         }
         foreach ($xml_urls as $xml_url) {
             $xml = simplexml_load_file($xml_url);
             //$attr = $xml->channel->attributes();
             //$channel_epg_id = (string)$attr["id"];
             /**
              * Update Progs
              */
             foreach ($xml->programme as $arProg) {
                 $_arProg = $arProg;
                 $json = json_encode($arProg);
                 $arProg = json_decode($json, TRUE);
                 $arFields = array("UF_ACTIVE" => 1, "UF_TITLE" => trim((string) $arProg["title"]), "UF_DESC" => (string) $_arProg->desc, "UF_YEAR_LIMIT" => (int) $arProg["rating"]["value"], "UF_YEAR" => (string) $arProg["year"]);
                 if (isset($arProg["title"])) {
                     $attr = $_arProg->title->attributes();
                     $arFields["UF_EPG_ID"] = (string) $attr["id"];
                     $prog_epg_id = (string) $attr["id"];
                 }
                 if (isset($arProg["sub-title"]) && !empty($arProg["sub-title"])) {
                     $arFields["UF_SUB_TITLE"] = trim($arProg["sub-title"]);
                     $attr = $_arProg->{'sub-title'}->attributes();
                     $arFields["UF_EPG_SUB_ID"] = (string) $attr["id"];
                     $prog_epg_id .= $arFields["UF_EPG_SUB_ID"];
                 } else {
                     //get sub_epg_id from full id if no sub-title
                     $full_epg_id = (string) $arProg["@attributes"]["id"];
                     $pos = strripos($full_epg_id, $prog_epg_id) + strlen($prog_epg_id);
                     if ($pos != strlen($full_epg_id)) {
                         $epg_sub_id = substr($full_epg_id, $pos);
                         if (!empty($epg_sub_id)) {
                             $arFields["UF_EPG_SUB_ID"] = $epg_sub_id;
                             $prog_epg_id .= $arFields["UF_EPG_SUB_ID"];
                         }
                     }
                 }
                 if (!array_key_exists($prog_epg_id, $arProgs)) {
                     if (!empty($_arProg->{"desc-sub-title"})) {
                         $arFields["UF_SUB_DESC"] = (string) $_arProg->{"desc-sub-title"};
                     }
                     if (!empty($_arProg->{"episode-number"})) {
                         $arFields["UF_SERIA"] = (string) $_arProg->{"episode-number"};
                     }
                     if (!empty($_arProg->season)) {
                         $arFields["UF_SEASON"] = (string) $_arProg->season;
                     }
                     if (!is_array($arProg["category"])) {
                         $arProg["category"] = array($arProg["category"]);
                     }
                     $arFields["UF_CATEGORY"] = implode(", ", $arProg["category"]);
                     if (!is_array($arProg["topic"])) {
                         $arProg["topic"] = array($arProg["topic"]);
                     }
                     $arFields["UF_TOPIC"] = implode(", ", $arProg["topic"]);
                     if (!is_array($arProg["ganre"])) {
                         $arProg["ganre"] = array($arProg["ganre"]);
                     }
                     $arFields["UF_GANRE"] = implode(", ", $arProg["ganre"]);
                     if (!is_array($arProg["country"])) {
                         $arProg["country"] = array($arProg["country"]);
                     }
                     $arFields["UF_COUNTRY"] = implode(", ", $arProg["country"]);
                     if (!is_array($arProg["credits"]["director"])) {
                         $arProg["credits"]["director"] = array($arProg["credits"]["director"]);
                     }
                     $arFields["UF_DIRECTOR"] = implode(", ", $arProg["credits"]["director"]);
                     if (!is_array($arProg["credits"]["actor"])) {
                         $arProg["credits"]["actor"] = array($arProg["credits"]["actor"]);
                     }
                     $arFields["UF_ACTOR"] = implode(", ", $arProg["credits"]["actor"]);
                     if (!is_array($arProg["credits"]["presenter"])) {
                         $arProg["credits"]["presenter"] = array($arProg["credits"]["presenter"]);
                     }
                     $arFields["UF_PRESENTER"] = implode(", ", $arProg["credits"]["presenter"]);
                     /**
                      * Bugfix: Problem with sub-title id.
                      * If no sub-title id, but it's serial, update previous prog
                      */
                     if (array_key_exists($arFields["UF_EPG_ID"], $arProgs) && $prog_epg_id != $arFields["UF_EPG_ID"]) {
                         $arProgs[$prog_epg_id] = $arProgs[$arFields["UF_EPG_ID"]];
                         unset($arProgs[$arFields["UF_EPG_ID"]]);
                         $prog_id = $arProgs[$prog_epg_id]["ID"];
                         ProgTable::Update($prog_id, $arFields);
                     } else {
                         $result = ProgTable::add($arFields);
                         if ($result->isSuccess()) {
                             $prog_id = $result->getId();
                             $arProgs[$prog_epg_id] = array("ID" => $prog_id, "UF_IMG_ID" => 0);
                         } else {
                             $errors = $result->getErrorMessages();
                         }
                     }
                 } else {
                     $prog_id = $arProgs[$prog_epg_id]["ID"];
                 }
                 $image_id = intval($arProgs[$prog_epg_id]["UF_IMG_ID"]);
                 //--------------Add original image----------------
                 if ($image_id == 0) {
                     $arFields = array();
                     $icons = array();
                     if (!is_array($arProg["icon"])) {
                         $arProg["icon"] = array($arProg["icon"]);
                     }
                     $ar_src = self::addImage($arProg["icon"]);
                     if ($ar_src) {
                         $result = ImageTable::getList(array('filter' => array("=UF_EXTERNAL_ID" => md5($ar_src["origin_path"])), 'select' => array("ID")));
                         if ($row = $result->fetch()) {
                             $arFields["UF_IMG_ID"] = (int) $row["ID"];
                         } else {
                             $resultImg = ImageTable::add(array("UF_PATH" => $ar_src["server_path"], "UF_EXTERNAL_ID" => md5($ar_src["origin_path"]), "UF_WIDTH" => intval($ar_src["width"]), "UF_HEIGHT" => intval($ar_src["height"])));
                             if ($resultImg->isSuccess()) {
                                 $arFields["UF_IMG_ID"] = (int) $resultImg->getId();
                             }
                         }
                     }
                     ProgTable::Update($prog_id, $arFields);
                 }
                 //------------------------------------------------
                 /**
                  * Adding schedules
                  */
                 $schedule_epg_id = trim((string) $arProg["@attributes"]["id"]);
                 $dateStart = new \Bitrix\Main\Type\DateTime(date("Y-m-d H:i:s", strtotime($arProg["@attributes"]["start"])), 'Y-m-d H:i:s');
                 $dateEnd = new \Bitrix\Main\Type\DateTime(date("Y-m-d H:i:s", strtotime($arProg["@attributes"]["stop"])), 'Y-m-d H:i:s');
                 $date = new \Bitrix\Main\Type\Date(date("Y-m-d", strtotime($arProg["date"])), 'Y-m-d');
                 if (!array_key_exists($schedule_epg_id, $arSchedules)) {
                     $title = (string) $arProg["title"];
                     if (!empty($arProg["sub-title"])) {
                         $title .= " | " . trim($arProg["sub-title"]);
                     }
                     $arFields = array("UF_ACTIVE" => 1, "UF_DATE_START" => $dateStart, "UF_DATE_END" => $dateEnd, "UF_DATE" => $date, "UF_CHANNEL_ID" => (int) $arChannel["ID"], "UF_PROG_ID" => (int) $prog_id, "UF_EPG_ID" => $schedule_epg_id, "UF_CODE" => $title . " - " . $arProg["@attributes"]["start"], "UF_DATETIME_CREATE" => new \Bitrix\Main\Type\Date(date("Y-m-d H:i:s"), 'Y-m-d H:i:s'));
                     $result = ScheduleTable::add($arFields);
                     if ($result->isSuccess()) {
                         $schedule_id = $result->getId();
                         $arSchedules[$schedule_epg_id] = $schedule_id;
                     } else {
                         $errors = $result->getErrorMessages();
                     }
                 } else {
                     $schedule_id = (int) $arSchedules[$schedule_epg_id];
                     $arFields = array("UF_DATE_START" => $dateStart, "UF_DATE_END" => $dateEnd, "UF_DATE" => $date, "UF_DATETIME_EDIT" => new \Bitrix\Main\Type\Date(date("Y-m-d H:i:s"), 'Y-m-d H:i:s'));
                     ScheduleTable::Update($schedule_id, $arFields);
                 }
                 $arScheduleIdsNotDelete[] = $schedule_id;
                 $arProgCropIds[] = $prog_id;
             }
         }
     }
     /**
      * Delete not exist schedule
      */
     if (!empty($arScheduleIdsNotDelete)) {
         $result = ScheduleTable::getList(array('filter' => array(">=UF_DATE" => new \Bitrix\Main\Type\Date(date("Y-m-d"), 'Y-m-d')), 'select' => array("ID")));
         while ($row = $result->fetch()) {
             if (!in_array($row["ID"], $arScheduleIdsNotDelete)) {
                 ScheduleTable::delete($row["ID"]);
             }
         }
     }
     //Make cut images for imported progs
     self::addCropFiles($arProgCropIds);
     ProgTable::generateCodes();
     unset($arScheduleIdsNotDelete);
     unset($arProgCropIds);
     self::guessSerials();
 }
Exemple #6
0
 /**
  * Import all serials href from resource to db 
  */
 public static function importSerials()
 {
     $arToFile = array();
     $file_50_60 = $_SERVER['DOCUMENT_ROOT'] . "/upload/serials_50_60.txt";
     /**
      * Get all prog which are serials
      */
     $arSerials = array();
     $date_prevprev = date('Y-m-d', strtotime("-2 day"));
     $arFilter = array(">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($date_prevprev . " 00:00:00", 'Y-m-d H:i:s'), "<UF_DATE_START" => new \Bitrix\Main\Type\DateTime($date_prevprev . " 23:59:59", 'Y-m-d H:i:s'), "!UF_PROG.UF_EPG_SUB_ID" => false);
     $arSelect = array("ID", "SID" => "UF_PROG.UF_EPG_ID", "TITLE" => "UF_PROG.UF_TITLE", "SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "SERIA" => "UF_PROG.UF_SERIA", "SEASON" => "UF_PROG.UF_SEASON", "UF_DATE_START", "UF_DATE_END");
     $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
     while ($arSchedule = $result->fetch()) {
         $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = $arSchedule['UF_DATE_START']->toString();
         $arSchedule["UF_DATE_END"] = $arSchedule["DATE_END"] = $arSchedule['UF_DATE_END']->toString();
         $arSerials[] = $arSchedule;
     }
     /**
      * Get all serials with epg_id
      */
     $arTableSerials = array();
     $result = \Hawkart\Megatv\SerialTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("ID", "UF_EPG_ID", "UF_CHANNEL_ID")));
     while ($row = $result->fetch()) {
         $arTableSerials[$row["UF_EPG_ID"]] = $row;
     }
     foreach ($arSerials as $arProg) {
         $title = $arProg["TITLE"];
         if (!empty($arProg["SUB_TITLE"])) {
             $title = $arProg["SUB_TITLE"] . ". " . $title;
         } else {
             if (!empty($arProg["SEASON"])) {
                 $title .= ": сезон " . $arProg["SEASON"];
             }
             if (!empty($arProg["SERIA"])) {
                 $title .= " серия " . $arProg["SERIA"];
             }
         }
         $seria_secs = strtotime($arProg["DATE_END"]) - strtotime($arProg["DATE_START"]);
         $youtube = new \Hawkart\Megatv\Social\YoutubeClient();
         $arVideos = $youtube->search($title);
         $arSerial = $arTableSerials[$arProg["SID"]];
         if (empty($arSerial)) {
             continue;
         }
         //Progs in table by serial_id
         $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"];
         }
         foreach ($arVideos as $arItem) {
             //secs from youtube
             $time_parts = explode(":", $arItem["TIME"]);
             $secs = 60 * $time_parts[count($time_parts) - 2] + $time_parts[count($time_parts) - 1];
             if (count($time_parts) == 3) {
                 $secs = 60 * intval($time_parts[0]) + intval($time_parts[1]);
             } else {
                 $secs = 3600 * intval($time_parts[0]) + 60 * intval($time_parts[1]) + intval($time_parts[2]);
             }
             $time_perc = $secs / $seria_secs * 100;
             similar_text($title, $arItem["TITLE"], $perc);
             similar_text($arItem["TITLE"], $title, $perc_2);
             if (floatval($perc) < 60 && floatval($perc) >= 40) {
                 $arToFile[] = array("ORIGINAL_TITLE" => $title, "SOCIAL_TITLE" => $arItem["TITLE"], "PERCENT" => $perc, "EXTERNAL_ID" => $arItem["ID"], "TIME" => $arItem["TIME"], "UF_SERIAL_ID" => $arSerial["ID"]);
             }
             if (floatval($perc) > 60 && floatval($perc_2) > 40 && $time_perc > 70) {
                 if (!in_array($arItem["ID"], $arTableItems)) {
                     $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" => $arSerial["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();
                     }
                 }
                 break;
             }
         }
     }
     file_put_contents($file_50_60, json_encode($arToFile));
 }
Exemple #7
0
//Получим все программы текущих каналов за выбранный день
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"];
        $arSchedule["DETAIL_PAGE_URL"] = $arResult["CHANNELS"][$channel]["DETAIL_PAGE_URL"] . $arSchedule["UF_PROG_CODE"] . "/?event=" . $arSchedule["ID"];
        $arResult["DATES"][$arSchedule["UF_DATE"]][$channel][] = $arSchedule;
    }
    $obCache->EndDataCache($arResult["DATES"]);
}
unset($arChannelIds);
/**
 * Create json view for future algorithm
 */
Exemple #8
0
    $USER = new CUser();
}
$status = false;
$prog_time = intval($_REQUEST["broadcastID"]);
if ($USER->IsAuthorized() && $prog_time > 0) {
    //get subsribe channel list
    $selectedChannels = array();
    $result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("=UF_ACTIVE" => 1, "=UF_USER_ID" => $USER->GetID(), ">UF_CHANNEL_ID" => 0), 'select' => array("UF_CHANNEL_ID")));
    while ($arSub = $result->fetch()) {
        $selectedChannels[] = $arSub["UF_CHANNEL_ID"];
    }
    $USER_ID = $USER->GetID();
    $rsUser = \CUser::GetByID($USER_ID);
    $arUser = $rsUser->Fetch();
    //get inform about schedule
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => array("=ID" => $prog_time), 'select' => array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_BASE_ID" => "UF_CHANNEL.UF_BASE_ID", "UF_PROG_ID", "UF_CHANNEL_EPG_ID" => "UF_CHANNEL.UF_BASE.UF_EPG_ID", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_PROG_EPG_ID" => "UF_PROG.UF_EPG_ID", "UF_EPG_ID", "UF_CHANNEL_ID"), 'limit' => 1));
    if ($arSchedule = $result->fetch()) {
        $arSchedule["UF_DATE_START"] = $arSchedule['UF_DATE_START']->toString();
        $arSchedule["UF_DATE_END"] = $arSchedule['UF_DATE_END']->toString();
    }
    //check if schedule in recording yet. Deleted to recordable
    $update = false;
    $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("=UF_USER_ID" => $USER_ID, "=UF_SCHEDULE_ID" => $prog_time), 'select' => array("ID", "UF_DELETED"), 'limit' => 1));
    if ($arRecord = $result->fetch()) {
        if (intval($arRecord["UF_DELETED"]) == 1) {
            $update = true;
            $update_id = $arRecord["ID"];
        } else {
            exit(json_encode(array("status" => "error", "error" => "Такая запись уже есть.")));
        }
    }
Exemple #9
0
              "UF_NAME" => "UF_PROG.UF_TITLE", "UF_SUB_NAME" => "UF_PROG.UF_SUB_TITLE",
          )
      ));
      while ($arSchedule = $result_sh->fetch())
      {   
          if(!in_array($arSchedule["UF_ID"], $ids))
              $html.='<li><a href="http://tvguru.com/channels/'.$arChannel["UF_CODE"].'/'.$arSchedule["UF_ID"].'/">'.trim($arSchedule["UF_NAME"].' '.$arSchedule["UF_SUB_NAME"]).'</a></li>';
          
          $ids[] = $arSchedule["UF_ID"];
      }
      unset($ids);*/
    $html .= "</ul></li>";
}
$urls = array();
$count = 1;
$result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => array("UF_CHANNEL.UF_BASE.UF_ACTIVE" => 1, "UF_PROG.UF_ACTIVE" => 1), 'select' => array("ID", "UF_ID" => "UF_PROG.UF_EPG_ID", "UF_CHANNEL_CODE" => "UF_CHANNEL.UF_BASE.UF_CODE")));
while ($arSchedule = $result->fetch()) {
    $url = "http://tvguru.com/channels/" . $arSchedule["UF_CHANNEL_CODE"] . "/" . $arSchedule["UF_ID"] . "/";
    $urls[] = $url;
}
$urls = array_unique($urls);
foreach ($urls as $url) {
    $xml .= "<url>\r\n      <loc>" . $url . "</loc>\r\n      <lastmod>" . $date . "</lastmod>\r\n      <changefreq>daily</changefreq>\r\n    </url>";
}
unset($urls);
$xml .= "</urlset>";
$file = $_SERVER["DOCUMENT_ROOT"] . "/sitemap.xml";
file_put_contents($file, $xml);
$html .= '
        </ul></li>
    </ul>