<?php

/**
 * Implements hook_rate_templates
 *
 * @return array
 */
function mkbh_rate_widget_rate_templates()
{
    $templates = [];

    $templates['mkbh_chart_widget'] = new stdClass();
    $templates['mkbh_chart_widget']->value_type = 'percent';
    $templates['mkbh_chart_widget']->options = [
        [0, 'down'],
        [100, 'up'],
    ];
    $templates['mkbh_chart_widget']->theme = 'mkbh_rate_widget';
    //  $templates['mkbh_chart_widget']->css = drupal_get_path('module', 'mkbh_rate_widget') . '/assets/mkbh_rate_widget.css';
    //  $templates['mkbh_chart_widget']->js = drupal_get_path('module', 'mkbh_rate_widget') . '/assets/mkbh_rate_widget.js';
    $templates['mkbh_chart_widget']->customizable = FALSE;
    $templates['mkbh_chart_widget']->translate = FALSE;
    $templates['mkbh_chart_widget']->template_title = t('MKBH Chart Widget');

    return $templates;
}

/**
 * Implements hook_theme
 */
function mkbh_rate_widget_theme()
{
    return [
        'mkbh_rate_widget' => [
            'variables' => [],
            'file' => 'mkbh_rate_widget.theme.inc',
            'template' => 'templates/mkbh-rate-widget',
            'arguments' => [
                'links' => NULL,
                'results' => NULL,
                'mode' => NULL,
                'just_voted' => FALSE,
                'content_type' => NULL,
                'content_id' => NULL,
                'display_options' => NULL,
            ],
        ],
    ];
}

/**
 * Implements hook_init
 */
function mkbh_rate_widget_init()
{
    drupal_add_js(drupal_get_path('module', 'mkbh_rate_widget') . '/assets/js/mkbh_rate_widget.js');
    drupal_add_js(drupal_get_path('module', 'mkbh_rate_widget') . '/assets/js/highcharts.js');

    drupal_add_css(drupal_get_path('module', 'mkbh_rate_widget') . '/assets/less/mkbh_rate_widget.less');
}
