<?php

#
# XiVO Web-Interface
# Copyright (C) 2006-2014  Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

class dwho_i18n_timezone
{
    var $_attrib    = array();
    var $_conf    = array();

    function dwho_i18n_timezone()
    {
        $file = dwho_file::joinpath(DWHO_PATH_ROOT,'i18n','timezones','timezones');

        if(($this->_conf = dwho_gat::get_file($file)) === false)
            trigger_error('Failed to load timezones listing',E_USER_ERROR);
    }

    function set_attrib($name,$value)
    {
        $name = (string) $name;

        $this->_attrib[$name] = $value;
    }

    function get_attrib($name)
    {
        $name = (string) $name;

        if(isset($this->_attrib[$name]) === true)
            return($this->_attrib[$name]);
        else
            return(null);
    }

    function is_valid($tz)
    {
        $tz = (string) $tz;

        if(dwho_issa($tz,$this->_conf) === false)
            return(false);

        return($tz);
    }

    function get_info($tz)
    {
        if(($tz = $this->is_valid($tz)) === false)
            return(false);

        $r = $this->_conf[$tz];
        $r['tz'] = $tz;

        return($r);
    }

    function get_territory($tz)
    {
        if($this->is_valid($tz) === false)
            return(false);

        return($this->_conf[$tz]['territo']);
    }

    function get_list()
    {
        return($this->_conf);
    }
}

?>
