Exemplo n.º 1
0
 /**
  * Import countries from xml EPG
  *
  * @return array
  */
 public static function importCountry()
 {
     $file = "http://xmldata.epgservice.ru/EPGService/hs/xmldata/saturn/country_list";
     $xml = simplexml_load_file($file);
     $arList = array();
     $result = CountryTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("UF_EPG_ID", "ID", "UF_TITLE")));
     while ($row = $result->fetch()) {
         $arList[$row["UF_EPG_ID"]] = $row;
     }
     foreach ($xml->element as $arElement) {
         $json = json_encode($arElement);
         $arElement = json_decode($json, TRUE);
         $epg_id = (string) $arElement["@attributes"]["id"];
         $title = (string) $arElement["name"];
         $iso = (string) $arElement["@attributes"]["ISO"];
         if (!is_array($arList[$epg_id])) {
             $arFields = array("UF_EPG_ID" => $epg_id, "UF_TITLE" => $title, "UF_ISO" => $iso, "UF_ACTIVE" => 0, "UF_EXIST" => 1);
             $result = CountryTable::add($arFields);
             if ($result->isSuccess()) {
                 $id = $result->getId();
                 $arFields["ID"] = $id;
                 $arList[$epg_id] = $arFields;
             } else {
                 $errors = $result->getErrorMessages();
             }
         }
     }
     return $arCategories;
 }
Exemplo n.º 2
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
global $APPLICATION;
$arResult = array();
$arResult["URL"] = $APPLICATION->GetCurDir();
$arResult["GEO"] = \Hawkart\Megatv\CityTable::getGeoCity();
$arResult["ITEMS"] = array();
$arResult["CUR_CITY"] = array();
$arFilter = array("=UF_ACTIVE" => 1);
$arSelect = array("ID", "UF_TITLE", "UF_ISO");
$obCache = new \CPHPCache();
if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/langList/")) {
    $arResult["ITEMS"] = $obCache->GetVars();
} elseif ($obCache->StartDataCache()) {
    $result = \Hawkart\Megatv\CountryTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_TITLE" => "ASC")));
    while ($arLang = $result->fetch()) {
        $arResult["ITEMS"][] = $arLang;
    }
    $obCache->EndDataCache($arResult["ITEMS"]);
}
foreach ($arResult["ITEMS"] as $arLang) {
    if ($arResult["GEO"]["UF_COUNTRY_ID"] == $arLang["ID"]) {
        $arResult["CUR_LANG"] = $arLang;
    }
}
$this->IncludeComponentTemplate();
Exemplo n.º 3
0
} else {
    if (isset($_POST["lang-id"]) && intval($_POST["lang-id"]) > 0 && check_bitrix_sessid()) {
        $arGeo = \Hawkart\Megatv\CountryTable::setCountry(intval($_POST["lang-id"]));
        if (strtoupper($arGeo["COUNTRY_ISO"]) == LANGUAGE_DEFAULT) {
            $redirect_url = "http://" . $site;
        } else {
            $redirect_url = "http://" . strtolower($arGeo["COUNTRY_ISO"]) . "." . $site;
        }
        if (strtolower(LANGUAGE_ID) != strtolower($arGeo["COUNTRY_ISO"])) {
            LocalRedirect($redirect_url . $APPLICATION->GetCurPage());
            die;
        }
    } else {
        $arGeo = \Hawkart\Megatv\CityTable::getGeoCity();
        if (strtolower(LANGUAGE_ID) != strtolower($arGeo["COUNTRY_ISO"])) {
            \Hawkart\Megatv\CountryTable::setCountryByIso(LANGUAGE_ID);
        }
    }
}
if ($USER->IsAuthorized()) {
    /**
     * Get records statuses by user
     */
    $arRecordStatus = \Hawkart\Megatv\RecordTable::getListStatusesByUser();
    /**
     * User subscribe channel list. Add global property
     */
    $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"];