<?php

//Include the common file
require_once 'common.php';

$mix = $db->fetchRowAssoc("SELECT * FROM " . cfg('base', 'table_mixes') . " m, " . cfg('base', 'table_mix_translations') . " t  WHERE  m.mix_id = ". $_GET['id'] . " AND t.language_code = '" . $site_lang . "' AND m.mix_id = t.mix_id");

if ($mix['cover']) {
        $og_type = 'article';
        $og_image = cfg('base', 'site_url').'uploads/images/'.$mix['cover'];
        $og_video_url = '';
        $og_video_type = '';
        $og_video_width = '';
        $og_video_height = '';

        $tw_card = 'article';
        $tw_video_url = '';
        $tw_video_width = '';
        $tw_video_height= '';
    } else {
        $og_type = 'article';
        $og_image = cfg('base', 'site_url').'templates/assets/img/og_logo.png';
        $og_video_url = '';
        $og_video_type = '';
        $og_video_width = '';
        $og_video_height = '';

        $tw_card = 'article';
        $tw_video_url = '';
        $tw_video_width = '';
        $tw_video_height= '';
    }

$sql = "SELECT m.mix_id, m.cover, m.author, t.mix_title FROM " . cfg('base', 'table_mixes') . " m, " . cfg('base', 'table_mix_translations') . " t WHERE t.language_code = '" . $site_lang . "' AND m.mix_id = t.mix_id AND m.mix_status =1 ORDER BY m.mix_id DESC LIMIT 0, 3";

//Mixes
$mixes = array();

foreach ($db->query($sql) as $row) {

    $mixes[] = array(
        'mix_id'                   => $row['mix_id'],
        'mix_title'               => $row['mix_title'],
        'cover'                       => $row['cover'],
        'author'                     => $row['author']
    );

}

//Navigation class
$current_mixes = 'class="current"';

//Template values
$tpl->set('title', $mix['mix_title']);
$tpl->set('keywords', $mix['mix_meta_keywords']);
$tpl->set('description', $mix['mix_meta_description']);
$tpl->set('content', $mix['mix_description']);
$tpl->set('og_type', $og_type);
$tpl->set('og_image', $og_image);
$tpl->set('og_video_url', $og_video_url);
$tpl->set('og_video_type', $og_video_type);
$tpl->set('og_video_width', $og_video_width);
$tpl->set('og_video_height', $og_video_height);

$tpl->set('tw_card', $tw_card);
$tpl->set('tw_video_url', $tw_video_url);
$tpl->set('tw_video_width', $tw_video_width);
$tpl->set('tw_video_height', $tw_video_height);

$tpl->set('mix', $mix);
$tpl->set('mixes', $mixes);

//Display navigation current class
$tpl->set('current_mixes', $current_mixes);

//Display the template
$tpl->display('dj-mix');
