<?php

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

class resmng_sitemap_api extends sitemap {

    protected $module_name = 'resmng';
    protected $changefreq = 'weekly';
    protected $priority = '0.5';

    public function __construct() {

        $this->get_static();
        $this->get_data();
    }

    protected function get_data() {

        $CI = & get_instance();
        $query = $CI->db->
                        select('alias')->
                        where('route', '')->
                        order_by('id_resource_type_page', 'DESC')->
                        get('resource_type_page')->result_array();
        
        
        foreach ($query as $k => $v) {
            $this->map[] = new sitemap_item('http://' . $_SERVER['SERVER_NAME'] . '/' . $v['alias'], date("Y-m-d"), $this->changefreq, $this->priority);
        }
    }

    protected function get_static() {

        $CI = & get_instance();
        $static_val = $CI->db->
                        select('changefreq,priority')->
                        where('module_name', $this->module_name)->
                        get('sitemap_config')->row_array();

        if (!empty($static_val['changefreq'])) {
            $this->changefreq = $static_val['changefreq'];
        }

        if (!empty($static_val['priority'])) {
            $this->priority = $static_val['priority'];
        }
    }

}