Beispiel #1
0
    $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");
        @define("ERROR_404", "Y");
    } else {
        LocalRedirect($APPLICATION->GetCurDir(), false, "301 Moved Permanently");
    }
} else {
    //FOR SEO
    $url_params = parse_url($_SERVER["REQUEST_URI"]);
Beispiel #2
0
    /**
    *  [ID] => 2
       [UF_CODE] => pena-dney-20160409004500-0300
       [UF_DATE_START] => 09.04.2016 00:45:00
       [UF_DATE_END] => 09.04.2016 03:10:00
       [UF_DATE] => 09.04.2016
       [UF_CHANNEL_ID] => 30
       [UF_PROG_ID] => 2
       [UF_TITLE] => Пена дней
       [UF_SUB_TITLE] => 
       [UF_IMG_PATH] => /upload/epg_original/48870.jpg
       [UF_RATING] => 
       [DATE_START] => 09.04.2016 00:45:00
       [DATE_END] => 09.04.2016 03:10:00
       [DATE] => 09.04.2016
       [PROG_ID] => 2
       [DETAIL_PAGE_URL] => /channels/1tv/pena-dney-20160409004500-0300/
       [UF_HD] => 1
    */
    public static function getProgInfoChannel($arProg, $arParams)
    {
        if ($arProg["CLASS"] == "one") {
            $arProg["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arProg["UF_IMG_PATH"], array(600, 550));
        }
        if ($arProg["CLASS"] == "half") {
            $arProg["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arProg["UF_IMG_PATH"], array(300, 550));
        }
        $start = $arProg["DATE_START"];
        $end = $arProg["DATE_END"];
        $arStatus = self::status($arProg);
        $status = $arStatus["status"];
        $status_icon = $arStatus["status-icon"];
        $datetime = $arParams["DATETIME"]["SERVER_DATETIME_WITH_OFFSET"];
        $time_pointer = false;
        if (\CTimeEx::dateDiff($start, $datetime) && \CTimeEx::dateDiff($datetime, $end)) {
            $time_pointer = true;
        }
        ob_start();
        ?>
        <div class="item<?php 
        if ($status) {
            ?>
 status-<?php 
            echo $status;
        }
        if ($time_pointer && $arParams["NEED_POINTER"]) {
            ?>
 js-time-pointer<?php 
        }
        if (empty($arProg["PICTURE"]["SRC"])) {
            ?>
 is-noimage<?php 
        }
        if ($arProg["CLASS"] == "double") {
            ?>
 double-item<?php 
        }
        ?>
"
            data-type="broadcast" data-broadcast-id="<?php 
        echo $arProg["ID"];
        ?>
"
        >
            <div class="item-image-holder">
				<img data-src="<?php 
        echo $arProg["PICTURE"]["SRC"];
        ?>
" alt="">
			</div>
            
            <?php 
        if ($time_pointer) {
            ?>
                <span class="badge" data-channel-id="<?php 
            echo $arProg["UF_CHANNEL_ID"];
            ?>
">в эфире</span>
            <?php 
        }
        ?>
            
            <?php 
        echo $status_icon;
        ?>
            <?php 
        echo self::driveNotifyMessage();
        ?>
            
        	<div class="item-header">
        		<time><?php 
        echo substr($arProg["DATE_START"], 11, 5);
        ?>
</time>
        		<a href="<?php 
        echo $arProg["DETAIL_PAGE_URL"];
        ?>
">
                    <?php 
        echo self::cutName(\Hawkart\Megatv\ProgTable::getName($arProg));
        ?>
                </a>
        	</div>

			<div class="item-header">
                <?php 
        if (\CTimeEx::dateDiff($start, $datetime) && \CTimeEx::dateDiff($datetime, $end)) {
            ?>
                    <?php 
            $allSecs = strtotime($end) - strtotime($start);
            $secs = strtotime($datetime) - strtotime($start);
            $proc = ceil($secs / ($allSecs / 100));
            $duration = \CTimeEx::secToStr($secs);
            ?>
    				<div class="timeline" data-progress="<?php 
            echo $proc;
            ?>
">
    					<span class="progress-bg"></span>
    					<span>прошло <?php 
            echo $duration;
            ?>
</span>
    				</div>
                <?php 
        }
        ?>
				<span class="descr-trigger" data-type="descr-trigger"><span>&times;</span></span>
				<time><?php 
        echo substr($arProg["DATE_START"], 11, 5);
        ?>
</time>
				<a href="<?php 
        echo $arProg["DETAIL_PAGE_URL"];
        ?>
">
                    <?php 
        echo self::cutName(\Hawkart\Megatv\ProgTable::getName($arProg));
        ?>
                </a>
				<div class="item-descr">
                    <?php 
        $obParser = new \CTextParser();
        ?>
					<p><?php 
        echo $obParser->html_cut($arProg["UF_DESC"], 600);
        ?>
</p>
				</div>
			</div>
		</div>
        <?php 
        $content = ob_get_contents();
        ob_end_clean();
        return $content;
    }