/** * Set country & default city by country's iso * * @return array */ public static function setCountryByIso($iso) { global $currentGeo; $arSelect = array("ID", "UF_TITLE", "UF_TIMEZONE", "UF_COUNTRY_ID", "COUNTRY_ISO" => "UF_COUNTRY.UF_ISO"); $result = CityTable::getList(array('filter' => array("=UF_COUNTRY.UF_ISO" => $iso, "=UF_ACTIVE" => 1, "=UF_DEFAULT" => 1), 'select' => $arSelect, 'limit' => 1)); $currentGeo = $_SESSION["USER_GEO"] = $result->fetch(); return $_SESSION["USER_GEO"]; }
public static function exportChannelCity() { $arRows = array(); $fp = fopen($_SERVER["DOCUMENT_ROOT"] . "/upload/channel_city.csv", 'w'); $firstStr = array("Субъект федерации" . "\t", "Город/Канал" . "\t"); $arChannelCity = array(); $arSelect = array("ID", "UF_CHANNEL_ID", "UF_CITY_ID", "UF_BASE_ID" => "UF_CHANNEL.UF_BASE_ID", "UF_EPG_ID" => "UF_CHANNEL.UF_EPG_ID"); $result = ChannelCityTable::getList(array('filter' => array(), 'select' => $arSelect)); while ($arItem = $result->fetch()) { $arChannelCity[$arItem["UF_CITY_ID"]][$arItem["UF_BASE_ID"]] = $arItem["UF_EPG_ID"]; } $arCities = array(); $arFilter = array("UF_COUNTRY.UF_TITLE" => "Россия", "UF_ACTIVE" => 1); $arSelect = array("ID", "UF_TITLE", "UF_REGION"); $result = CityTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_TITLE" => "ASC"))); while ($arCity = $result->fetch()) { $arCities[$arCity["ID"]] = $arCity; } $arChannels = array(); $arFilter = array("UF_ACTIVE" => 1); $arSelect = array("ID", "UF_TITLE"); $result = ChannelBaseTable::getList(array('filter' => $arFilter, 'select' => $arSelect)); while ($arChannel = $result->fetch()) { $arChannels[$arChannel["ID"]] = $arChannel["UF_TITLE"]; $firstStr[] = $arChannel["UF_TITLE"] . "\t"; } $arRows[] = $firstStr; fputcsv($fp, $firstStr, ";"); foreach ($arCities as $city_id => $arCity) { $arStr = array($arCity["UF_REGION"], $arCity["UF_TITLE"]); foreach ($arChannels as $channel_id => $channel_title) { $arStr[] = (string) $arChannelCity[$city_id][$channel_id] . "\t"; } $arRows[] = $arStr; fputcsv($fp, $arStr); } fclose($fp); $fileName = 'channel_city.csv'; header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-Description: File Transfer'); header("Content-type: text/csv"); header("Content-Disposition: attachment; filename={$fileName}"); header("Expires: 0"); header("Pragma: public"); $fh = @fopen('php://output', 'w'); foreach ($arRows as $data) { fputcsv($fh, $data, ";"); } fclose($fh); exit; }
public function down() { global $APPLICATION; \Bitrix\Main\Loader::includeModule("highloadblock"); $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\CityTable::getTableName())))->fetch(); if ($arHlblock) { $oUserTypeEntity = new \CUserTypeEntity(); $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => "UF_DEFAULT")); if ($aUserHasField = $resProperty->Fetch()) { $oUserTypeEntity->Delete($aUserHasField['ID']); $this->outSuccess("Свойство 'Дата добавления' удалено!"); } } }
/** * 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; } } } } } }
<?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_COUNTRY_ID" => $arResult["GEO"]["UF_COUNTRY_ID"], "=UF_ACTIVE" => 1); $arSelect = array("ID", "UF_TITLE"); $obCache = new \CPHPCache(); if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/cityList/")) { $arResult["ITEMS"] = $obCache->GetVars(); } elseif ($obCache->StartDataCache()) { $result = \Hawkart\Megatv\CityTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_TITLE" => "ASC"))); while ($arCity = $result->fetch()) { $arResult["ITEMS"][] = $arCity; } $obCache->EndDataCache($arResult["ITEMS"]); } foreach ($arResult["ITEMS"] as $arCity) { if ($arResult["GEO"]["ID"] == $arCity["ID"]) { $arResult["CUR_CITY"] = $arCity; } } $this->IncludeComponentTemplate();
<?php require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php"; $APPLICATION->SetTitle("Персональные данные"); global $USER; ?> <div class="flex-row user-profile-top-row"> <?php $APPLICATION->IncludeComponent("hawkart:user.profile", "", array("CITY_GEO" => \Hawkart\Megatv\CityTable::getGeoCity()), false); ?> <section class="user-info-subscriptions" data-module="user-info-subscriptions"> <script type="text/x-config"> { "url": "/server/" } </script> <div class="block-header"> <h3 class="block-title">УПРАВЛЕНИЕ АНОНСАМИ И РЕКОМЕНДАЦИЯМИ</h3> </div> <div class="block-body"> <ul class="user-info-subscriptions-list"> <li class="status-active" data-type="info-subscription-item" data-subscription-id="01"> <a href="#">Рекомендации МЕГА ТВ <span data-icon="icon-round-checkbox-mark"></span></a> </li> <li class="status-active" data-type="info-subscription-item" data-subscription-id="02"> <a href="#">Рекомендации Ваших друзей <span data-icon="icon-round-checkbox-mark"></span></a> </li> <li data-type="info-subscription-item" data-subscription-id="03">
<?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();
public static function getArDateTimeOffset($date = false, $offset = 0) { if (!$offset) { $arCity = \Hawkart\Megatv\CityTable::getGeoCity(); $offset = intval($arCity["UF_TIMEZONE"]) - intval(self::$defaultTimezone) / 100; } if (!$date) { $date = self::getCurDate(); } $date = substr($date, 0, 10) . date(" 00:00:00"); $next_date = date('d.m.Y 00:00:00', strtotime("+1 day", strtotime($date))); $arDate = array("DATE_FROM" => self::dateOffset($date, $offset), "DATE_TO" => self::dateOffset($next_date, $offset), "OFFSET" => $offset); return $arDate; }
<?php $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"; global $USER, $APPLICATION; if (!is_object($USER)) { $USER = new CUser(); } \Hawkart\Megatv\GeoCity::download(); \Hawkart\Megatv\CityTable::getTimezoneByCity(); die;
$arGeo = \Hawkart\Megatv\CityTable::setGeoCity(intval($_POST["city-id"])); header("Location: " . $APPLICATION->GetCurPage()); } 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")));
public static function getByFilterSelect($arFilter) { $arSelect = array("ID", "UF_TITLE", "UF_TIMEZONE", "UF_COUNTRY_ID", "COUNTRY_ISO" => "UF_COUNTRY.UF_ISO"); $result = CityTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'limit' => 1)); return $result->fetch(); }