示例#1
0
文件: prog.php 项目: Hawkart/megatv
 public static function generateCodes()
 {
     $arProgs = array();
     $codes = array();
     $result = self::getList(array('filter' => array(), 'select' => array("ID", "UF_TITLE", "UF_CODE", "UF_EPG_ID")));
     while ($row = $result->fetch()) {
         $arParams = array("replace_space" => "-", "replace_other" => "-");
         $code = \CDev::translit(trim($row["UF_TITLE"]), "ru", $arParams);
         if (!empty($row["UF_CODE"])) {
             $codes[$row["UF_TITLE"]] = $row;
             continue;
         }
         $arCode = $codes[$row["UF_TITLE"]];
         if (!empty($arCode)) {
             if ($row["UF_EPG_ID"] != $arCode["UF_EPG_ID"]) {
                 $code .= "-" . $row["ID"];
             } else {
                 $code = $arCode["UF_CODE"];
             }
         }
         self::update($row["ID"], array("UF_CODE" => $code));
         $row["UF_CODE"] = $code;
         $codes[$row["UF_TITLE"]] = $row;
     }
 }
示例#2
0
 public function up()
 {
     global $APPLICATION;
     $arProgs = array();
     $codes = array();
     $result = \Hawkart\Megatv\ProgTable::getList(array('filter' => array(), 'select' => array("ID", "UF_TITLE", "UF_CODE", "UF_EPG_ID")));
     while ($row = $result->fetch()) {
         $arParams = array("replace_space" => "-", "replace_other" => "-");
         $code = \CDev::translit(trim($row["UF_TITLE"]), "ru", $arParams);
         if (!empty($row["UF_CODE"])) {
             $codes[$row["UF_TITLE"]] = $row;
             continue;
         }
         $arCode = $codes[$row["UF_TITLE"]];
         if (!empty($arCode)) {
             if ($row["UF_EPG_ID"] != $arCode["UF_EPG_ID"]) {
                 $code .= "-" . $row["ID"];
             } else {
                 $code = $arCode["UF_CODE"];
             }
         }
         \Hawkart\Megatv\ProgTable::update($row["ID"], array("UF_CODE" => $code));
         $row["UF_CODE"] = $code;
         $codes[$row["UF_TITLE"]] = $row;
     }
 }
示例#3
0
 /**
  * Change data before adding
  * 
  * @return object 
  */
 public static function onBeforeAdd(Entity\Event $event)
 {
     $result = new Entity\EventResult();
     $data = $event->getParameter("fields");
     if (isset($data['UF_TITLE'])) {
         $arParams = array("replace_space" => "-", "replace_other" => "-");
         $code = \CDev::translit(trim($data["UF_TITLE"]), "ru", $arParams);
         $result->modifyFields(array('UF_CODE' => $code));
     }
     return $result;
 }
示例#4
0
    }
} 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;
    }
}
if ($_REQUEST["AJAX"] == "Y") {
    $APPLICATION->RestartBuffer();
    /**
     * Get records statuses by user
     */
    $arRecordsStatuses = \Hawkart\Megatv\RecordTable::getListStatusesByUser();
    foreach ($arResult["PROGS"] as $key => $arProg) {
        $arProg["CAT_CODE"] = $arResult["CATEGORIES"][$arProg["UF_CATEGORY"]];
    }
    $arRecords = array();
    foreach ($arResult["PROGS"] as $arRecord) {
        $datetime = $arRecord['UF_DATE_START'];
示例#5
0
    if (!empty($arRecord["DATE_START"])) {
        $arRecord["DATE_START"] = \CTimeEx::dateOffset($arRecord["UF_DATE_START"]->toString());
        $minutes = intval(strtotime($date_now) - strtotime($arRecord["UF_DATE_START"])) / 60;
    }
    if ((!\CTimeEx::dateDiff($arRecord["DATE_START"], $date_now) || $minutes < 5) && !empty($arRecord["DATE_START"]) && !empty($arRecord["UF_URL"])) {
        $arRecord["STATUS"] = "status-recording";
    } elseif (!empty($arRecord["UF_URL"])) {
        $arRecord["STATUS"] = "status-recorded";
    }
    $arResult["RECORDS"][] = $arRecord;
}
$arResult["CATEGORIES"] = array();
$arStat = \Hawkart\Megatv\CStat::getByUser($USER->GetID());
foreach ($arStat["CATS"] as $category => $id) {
    $arParams = array("replace_space" => "-", "replace_other" => "-");
    $str = \CDev::translit($category, "ru", $arParams);
    $arResult["CATEGORIES"][$category] = $str;
}
if ($_REQUEST["AJAX"] == "Y") {
    $APPLICATION->RestartBuffer();
    /**
     * Get records statuses by user
     */
    $arRecords = array();
    foreach ($arResult["RECORDS"] as $arRecord) {
        $datetime = $arRecord['UF_DATE_START']->toString();
        $date = substr($datetime, 0, 10);
        $time = substr($datetime, 11, 5);
        if (strlen($arRecord["UF_NAME"]) > 25) {
            $arRecord["UF_NAME"] = substr($arRecord["UF_NAME"], 0, 25) . "...";
        }