<?php

/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * extension menu created by Mike Gusev (migus)
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

namespace BlackSheepResearch\Component\UserPoints\Site\Controllers;

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use BlackSheepResearch\Component\UserPoints\Site\UserController;

/**
 * @package UserPoints
 */
class RulesControl extends UserController {

    /**
     * Custom Constructor
     */
    public function __construct() {
        parent::__construct();
    }

    public function display($cachable = false, $urlparams = false) {

        $model = $this->getModel('rules');
        $view = $this->getView('rules', 'html');

        $lang = Factory::getLanguage();
        $lang->load('com_userpoints', JPATH_ADMINISTRATOR);

        $app = Factory::getApplication();
        $menus = $app->getMenu();
        $menu = $menus->getActive();
        $menuid = $menu->id;

        $params = $menus->getParams($menuid);

        $_rules = $model->_getRulesList();

        $this->viewdata['params'] = $params;
        $this->viewdata['rules'] = $_rules[0];
        $this->viewdata['total'] = $_rules[1];
        $this->viewdata['limit'] = $_rules[2];
        $this->viewdata['limitstart'] = $_rules[3];

        $view->_displaylist();
    }

}
