<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

// load abstract library
include_once dirname(__DIR__).'/libraries/abstract_sitemap.php';

/**
 * Class of sitemap_site
 *
 * @author r.ratsun <r.ratsun@gmail.com>
 */
class sitemap_site extends MX_Controller
{

    /**
     * Construct
     */
    public function __construct()
    {
        parent::__construct();

        $this->load->driver('cache', $this->config->item('cache_init_config'));
        $this->load->model('sitemap/sitemap_model');
    }

    /**
     * Show sitemap
     */
    public function show_sitemap()
    {

//        $cache = $this->cache->get('sitemap_xml');
        if (empty($cache)) {
            $this->sitemap_model->generate();
            $cache = $this->cache->get('sitemap_xml');
        }

        header("Content-type: text/xml; charset=utf-8");
        die($cache);
    }
}
