Exemplo n.º 1
0
 /**
  * import channel & city info connection
  */
 public static function import()
 {
     $arChannelCity = array();
     $arFilter = array();
     $arSelect = array("ID", "UF_CHANNEL_ID", "UF_CITY_ID");
     $result = ChannelCityTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
     while ($arItem = $result->fetch()) {
         $arChannelCity[$arItem["UF_CHANNEL_ID"] . "-" . $arItem["UF_CITY_ID"]] = $arItem["ID"];
     }
     $arCities = array();
     $arFilter = array("UF_COUNTRY.UF_TITLE" => "Россия", "UF_ACTIVE" => 1);
     $arSelect = array("ID", "UF_TITLE");
     $result = CityTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
     while ($arCity = $result->fetch()) {
         $arCities[$arCity["UF_TITLE"]] = $arCity["ID"];
     }
     $arChannels = array();
     $arFilter = array();
     $arSelect = array("ID", "UF_EPG_ID");
     $result = ChannelTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
     while ($arChannel = $result->fetch()) {
         $arChannels[$arChannel["UF_EPG_ID"]] = $arChannel["ID"];
     }
     $file = $_SERVER["DOCUMENT_ROOT"] . "/local/modules/hawkart.megatv/data/channel_city.csv";
     $lines = file($file);
     foreach ($lines as $line_num => $line) {
         $arItem = explode(";", $line);
         $city = trim($arItem[0]);
         foreach ($arItem as $value) {
             if (strpos($value, "channel_id=") !== false) {
                 $channel_epg_id = str_replace("channel_id=", "", $value);
                 $channel_epg_id = trim($channel_epg_id);
                 $city_id = $arCities[$city];
                 $channel_id = $arChannels[$channel_epg_id];
                 if (intval($arChannelCity[$channel_id . "-" . $city_id]) == 0 && intval($city_id) > 0 && intval($channel_id) > 0) {
                     //echo $city."   ".$channel_epg_id."<br />";
                     $arFields = array("UF_CITY_ID" => $city_id, "UF_CHANNEL_ID" => $channel_id);
                     //\CDev::pre($arFields);
                     $result = ChannelCityTable::add($arFields);
                     if ($result->isSuccess()) {
                         $id = $result->getId();
                         $arChannelCity[$channel_id . "-" . $city_id] = $id;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public function down()
 {
     global $APPLICATION;
     $arHlData = $this->arHlData;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\ChannelTable::getTableName())))->fetch();
     if ($arHlblock) {
         foreach ($arHlData as $fieldName => $fieldValue) {
             $oUserTypeEntity = new \CUserTypeEntity();
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $oUserTypeEntity->Delete($aUserHasField['ID']);
                 $this->outSuccess("Свойство удалено!");
             }
         }
     }
 }
Exemplo n.º 3
0
                    if ($count < $countPerPage) {
                        $arResult["PROGS"][] = $arSchedule;
                    }
                    $added = true;
                    $count++;
                }
                unset($arRecommendSorted[$by_what][0]);
                $arRecommendSorted[$by_what] = array_values($arRecommendSorted[$by_what]);
                if (count($arRecommendSorted[$by_what]) == 0) {
                    $added = true;
                }
            }
        }
    }
} else {
    $arFilter["=UF_CHANNEL_ID"] = \Hawkart\Megatv\ChannelTable::getActiveIdByCity();
    $arResult["PROGS"] = getRecommendForAll($arFilter, $arSelect, $limit, $offset);
}
$arResult["CATEGORIES"] = array();
if ($USER->IsAuthorized()) {
    $arStat = \Hawkart\Megatv\CStat::getByUser($USER->GetID());
    foreach ($arStat["CATS"] as $category => $id) {
        $str = \CDev::translit($category, "ru", array("replace_space" => "-", "replace_other" => "-"));
        $arResult["CATEGORIES"][$category] = $str;
    }
} else {
    foreach ($arResult["PROGS"] as $key => $arProg) {
        $category = $arProg["UF_CATEGORY"];
        $str = \CDev::translit($category, "ru", array("replace_space" => "-", "replace_other" => "-"));
        $arResult["CATEGORIES"][$category] = $str;
    }
Exemplo n.º 4
0
    /**
    * "RECORDING"
      "RECORDED"
      "VIEWED"
    */
    public static function status($arProg, $arRecordsStatuses = false)
    {
        global $APPLICATION, $USER;
        if (!$arRecordsStatuses) {
            $arRecordsStatuses = $APPLICATION->GetPageProperty("ar_record_status");
            $arRecordsStatuses = json_decode($arRecordsStatuses, true);
        }
        $arSubscriptionChannels = ChannelTable::getActiveIdByCityByUser();
        $schedule = $arProg["ID"];
        $arDatetime = \CTimeEx::getDatetime();
        $date_now = $arDatetime["SERVER_DATETIME_WITH_OFFSET"];
        $start = $arProg["DATE_START"];
        $end = $arProg["DATE_END"];
        $status = "";
        if (isset($arRecordsStatuses["VIEWED"][$schedule])) {
            $status = "viewed";
        } else {
            if (isset($arRecordsStatuses["RECORDING"][$schedule])) {
                $status = "recording";
            } else {
                if (isset($arRecordsStatuses["RECORDED"][$schedule])) {
                    $status = "recorded";
                } else {
                    if (in_array($arProg["UF_CHANNEL_ID"], $arSubscriptionChannels) && $USER->IsAuthorized() && \CTimeEx::dateDiff($date_now, $end) || !$USER->IsAuthorized()) {
                        $status = "recordable";
                    }
                }
            }
        }
        ob_start();
        if ($status == 'recording') {
            ?>
            <div class='item-status-icon'>
				<span data-icon='icon-recording'></span>
                <span class='status-desc'>В записи</span>
			</div>
        <?php 
        }
        ?>
        
        <?php 
        if ($status == 'recorded') {
            ?>
            <span class='item-status-icon' href='#'>
				<span data-icon='icon-recorded'></span>
				<span class='status-desc'>Смотреть</span>
			</span>
        <?php 
        }
        ?>
        
        <?php 
        if ($status == 'viewed') {
            ?>
            <span class='item-status-icon'>
				<span data-icon='icon-viewed'></span>
				<span class='status-desc'>Просмотрено</span>
			</span>
        <?php 
        }
        ?>
        
        <?php 
        if ($status == 'recordable') {
            ?>
            <?php 
            if ($USER->IsAuthorized()) {
                ?>
                <span class='item-status-icon'>
                    <span data-icon='icon-recordit'></span>
                    <span class='status-desc'>Записать</span>
    			</span>
            <?php 
            } else {
                ?>
                <span class='item-status-icon js-btnModalInit' data-module='modal' data-modal='authURL' data-type='openModal'>
                    <span data-icon='icon-recordit'></span>
                    <span class='status-desc'>Записать</span>
    			</span>     
            <?php 
            }
            ?>
        <?php 
        }
        $content = ob_get_contents();
        ob_end_clean();
        return array("status" => $status, "status-icon" => $content);
    }
Exemplo n.º 5
0
define('STOP_STATISTICS', true);
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
$GLOBALS['APPLICATION']->RestartBuffer();
global $USER;
if (!is_object($USER)) {
    $USER = new \CUser();
}
if (!$USER->IsAuthorized()) {
    return false;
}
/**
 * Показ прямого эфира канала
 */
if (isset($_REQUEST["channel_id"])) {
    $result = \Hawkart\Megatv\ChannelTable::getList(array('filter' => array("=ID" => intval($_REQUEST["channel_id"])), 'select' => array('ID', 'UF_TITLE' => 'UF_BASE.UF_TITLE', 'UF_STREAM_URL' => 'UF_BASE.UF_STREAM_URL'), 'limit' => 1));
    $arChannel = $result->fetch();
    ?>
    <div class="broadcast-player" data-module="broadcast-player">
    	<script type="text/x-config">
    		{
    			"seekTime": "0",
    			"broadcastID": "0",
    			"streamURL": "<?php 
    echo $arChannel["UF_STREAM_URL"];
    ?>
",
    			"posterURL": "<?php 
    echo $arChannel["UF_IMG_PATH"];
    ?>
",
Exemplo n.º 6
0
 /**
  * Download file xml from EPG service to server
  *
  */
 public function importChannels()
 {
     $arHrefChannels = array();
     $arBaseChannels = array();
     $result = ChannelBaseTable::getList(array('filter' => array(), 'select' => array("UF_EPG_ID", "ID", "UF_ACTIVE"), 'order' => array("ID" => "ASC")));
     while ($row = $result->fetch()) {
         if ($arBaseChannels[$row["UF_EPG_ID"]]["ID"] > 0) {
             ChannelBaseTable::delete($row["ID"]);
             //if dublicate exist
         } else {
             $arBaseChannels[$row["UF_EPG_ID"]] = $row;
         }
     }
     $arChannels = array();
     $result = ChannelTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("UF_EPG_ID", "ID", "UF_BASE_ID")));
     while ($row = $result->fetch()) {
         $arChannels[$row["UF_EPG_ID"]] = $row;
     }
     foreach ($this->xml->channel as $_arChannel) {
         $attr = $_arChannel->{'base-channel'}->attributes();
         $base_epg_id = trim((string) $attr["id"]);
         $json = json_encode($_arChannel);
         $arChannel = json_decode($json, TRUE);
         $epg_id = trim((string) $arChannel["@attributes"]["id"]);
         $name = trim((string) $arChannel["display-name"]);
         $base_title = trim((string) $arChannel["base-channel"]);
         $icon = (string) $arChannel["@attributes"]["src"];
         $href = trim((string) $arChannel["href"]);
         $arHrefChannels[$epg_id][] = $href;
         if (!empty($base_epg_id) && $base_epg_id != $epg_id) {
             ChannelBaseTable::delete($epg_id);
             unset($arBaseChannels[$epg_id]);
             if (!is_array($arBaseChannels[$base_epg_id])) {
                 $arFields = array("UF_ACTIVE" => 0, "UF_EPG_ID" => $base_epg_id, "UF_TITLE" => trim((string) $arChannel["base-channel"]));
                 $result = ChannelBaseTable::add($arFields);
                 if ($result->isSuccess()) {
                     $id = $result->getId();
                     $arFields["ID"] = $id;
                     $arBaseChannels[$base_epg_id] = $arFields;
                 } else {
                     $errors = $result->getErrorMessages();
                 }
             }
         } else {
             if (!is_array($arBaseChannels[$epg_id])) {
                 $arFields = array("UF_ACTIVE" => 0, "UF_EPG_ID" => $epg_id, "UF_TITLE" => $name);
                 $result = ChannelBaseTable::add($arFields);
                 if ($result->isSuccess()) {
                     $id = $result->getId();
                     $arFields["ID"] = $id;
                     $arBaseChannels[$epg_id] = $arFields;
                 } else {
                     $errors = $result->getErrorMessages();
                 }
             }
         }
         if (!is_array($arChannels[$epg_id])) {
             if (empty($base_epg_id)) {
                 $base_epg_id = $epg_id;
             }
             $arFields = array("UF_EPG_ID" => $epg_id, "UF_BASE_ID" => $arBaseChannels[$base_epg_id]["ID"]);
             $result = ChannelTable::add($arFields);
             if ($result->isSuccess()) {
                 $id = $result->getId();
                 $arFields["ID"] = $id;
                 $arChannels[$epg_id] = $arFields;
             } else {
                 $errors = $result->getErrorMessages();
             }
         }
         if (empty($base_epg_id)) {
             $base_epg_id = $epg_id;
         }
         $arChannels[$epg_id]["UF_BASE_EPG_ID"] = $base_epg_id;
     }
     $this->base_channels = $arBaseChannels;
     $this->channels = $arChannels;
     $this->href_channels = $arHrefChannels;
     return $arChannels;
 }
Exemplo n.º 7
0
$arTime = \CTimeEx::getDatetime();
//get channel by code
$arFilter = array("=UF_CODE" => $arParams["ELEMENT_CODE"]);
$arSelect = array("UF_CATEGORY", "UF_EPG_ID");
$result = \Hawkart\Megatv\ProgTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'limit' => 1));
if ($arResult = $result->fetch()) {
    $arResult["UF_SID"] = $arResult["UF_EPG_ID"];
}
//print_r($arResult);
//get channel by code
$arResult["PROGS"] = array();
$offset = 0;
if ($_REQUEST["AJAX"] == "Y") {
    $offset = $_REQUEST["offset"];
} else {
    $arChannelsActive = \Hawkart\Megatv\ChannelTable::getActiveIdByCityByUser();
    $arDate = \CTimeEx::getDateTimeFilter($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_EPG_ID" => $arResult["UF_SID"], "=UF_CHANNEL_ID" => $arChannelsActive, ">=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'));
    if (!empty($_REQUEST["event"])) {
        $arFilter["!=ID"] = $_REQUEST["event"];
    }
    $arSelect = array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_ID", "UF_PROG_ID", "UF_PROG_CODE" => "UF_PROG.UF_CODE", "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_CATEGORY" => "UF_PROG.UF_CATEGORY");
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'limit' => 6));
    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["PROG_ID"] = $arSchedule["UF_PROG_ID"];
        $arSchedule["DETAIL_PAGE_URL"] = "/channels/" . $arSchedule["UF_CHANNEL_CODE"] . "/" . $arSchedule["UF_PROG_CODE"] . "/?event=" . $arSchedule["ID"];
Exemplo n.º 8
0
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
ini_set('max_execution_time', 30);
global $USER, $APPLICATION;
$arParams = $arParams + array("DATETIME" => \CTimeEx::getDatetime(), "AJAX" => $_REQUEST["AJAX"], "LIST_URL" => $APPLICATION->GetCurDir());
//Get dates
$arResult["CONFIG_DATES"] = array();
$fisrt_date = date('d.m.Y', strtotime(\CTimeEx::getCurDate()));
for ($i = 0; $i < \CTimeEx::getCalendarDays() + 2; $i++) {
    $date_confing = date('d.m.Y', strtotime("+" . $i . " day", strtotime($fisrt_date)));
    $arResult["CONFIG_DATES"][] = $date_confing;
}
//Get channel list
$arChannels = array();
$arResult["ITEMS"] = \Hawkart\Megatv\ChannelTable::getActiveByCity();
foreach ($arResult["ITEMS"] as $arChannel) {
    $arChannels[$arChannel["UF_CHANNEL_BASE_ID"]] = $arChannel;
}
$arResult["ITEMS"] = $arChannels;
/**
 * sort channels for user according statistics
 */
if ($USER->IsAuthorized()) {
    $arItems = array();
    $arStatistic = \Hawkart\Megatv\CStat::getByUser();
    //sort channels by raiting
    uasort($arStatistic["CHANNELS"], function ($a, $b) {
        return strcmp($b, $a);
    });
    foreach ($arStatistic["CHANNELS"] as $channel_id => $rating) {
Exemplo n.º 9
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"]));
}