<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class Post_install extends \Ciext\Controller\AbstractInstallController
{

    public function __construct()
    {
        parent::__construct();

        // Set acl module name
        $this->module_config['module_acl_name'] = 'post';

        // Set title in english
        $this->module_config['module_title'] = 'Posts';

        // Set module image
        $this->module_config['module_image'] = 'fa fa-thumb-tack';

        // Set actions
        $this->module_config['module_actions'] = [
            // 'acl_action' => 'description'
            'view_post'     => $this->lang->line('View posts'),
            'edit_post'     => $this->lang->line('Edit posts'),
            'edit_category' => $this->lang->line('Edit categories'),
        ];

        // Set menu items
        $this->module_config['module_menu_items'] = [
//            ['method in admin controller', 'title in menu', 'path to the image. empty - default image', 'acl_action']
            ['categories', $this->lang->line('Categories <small>(settings)</small>'), '', 'edit_category'],
        ];
    }

    public function install($options = [])
    {
        if (empty($options)) {
            $options = [
                'shemaFile' => dirname(__DIR__) . '/data/install.sql',
            ];
        }

        return parent::install($options);
    }

    public function uninstall($options = [])
    {
        if (empty($options)) {
            $options = [
                'dropTables' => [
                    'post_categories',
                    'post',
                ],
            ];
        }

        return parent::uninstall($options);
    }

}
