Your IP : 216.73.216.240


Current Path : /home/juvelize/www/administrator/components/com_zhgooglemap/models/
Upload File :
Current File : /home/juvelize/www/administrator/components/com_zhgooglemap/models/mapmap.php

<?php
/*------------------------------------------------------------------------
# com_zhgooglemap - Zh GoogleMap
# ------------------------------------------------------------------------
# author:    Dmitry Zhuk
# copyright: Copyright (C) 2011 zhuk.cc. All Rights Reserved.
# license:   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
# website:   http://zhuk.cc
# Technical Support Forum: http://forum.zhuk.cc/
-------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla modelform library
jimport('joomla.application.component.modeladmin');

/**
 * ZhGoogleMap Model
 */
class ZhGoogleMapModelMapMap extends JModelAdmin
{

        var $mapapikey;
        var $mapapiversion;
    
    var $mapDefLat;
    var $mapDefLng;

    var $mapStreetViewList;
    var $mapWeatherTypeList;

    var $infobubbleStyleList;
    
    var $mapTypeList;
    var $mapOverrideList;
    

    var $categoryList;
    var $categoryListType;
    
    var $httpsprotocol;
    
        var $map_height;
    

    /**
     * Returns a reference to the a Table object, always creating it.
     *
     * @param    type    The table type to instantiate
     * @param    string    A prefix for the table class name. Optional.
     * @param    array    Configuration array for model. Optional.
     * @return    JTable    A database object
     * @since    1.6
     */
    public function getTable($type = 'MapMap', $prefix = 'ZhGoogleMapTable', $config = array()) 
    {
        return JTable::getInstance($type, $prefix, $config);
    }
    /**
     * Method to get the record form.
     *
     * @param    array    $data        Data for the form.
     * @param    boolean    $loadData    True if the form is to load its own data (default case), false if not.
     * @return    mixed    A JForm object on success, false on failure
     * @since    1.6
     */
    public function getForm($data = array(), $loadData = true) 
    {
        // Get the form.
        $form = $this->loadForm('com_zhgooglemap.mapmap', 'mapmap', array('control' => 'jform', 'load_data' => $loadData));
        if (empty($form)) 
        {
            return false;
        }
        return $form;
    }
    /**
     * Method to get the script that have to be included on the form
     *
     * @return string    Script files
     */
    public function getScript() 
    {
        return 'administrator/components/com_zhgooglemap/models/forms/mapmap.js';
    }
    /**
     * Method to get the data that should be injected in the form.
     *
     * @return    mixed    The data for the form.
     * @since    1.6
     */
    protected function loadFormData() 
    {
        // Check the session for previously entered form data.
        $data = JFactory::getApplication()->getUserState('com_zhgooglemap.edit.mapmap.data', array());
        if (empty($data)) 
        {
            $data = $this->getItem();
        }
        return $data;
    }

    public function getAPIKey() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $mapapikey = $params->get( 'map_map_key', '' );
    }

    public function getAPIVersion() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $mapapiversion = $params->get( 'map_api_version', '' );
    }
    
    public function getDefLat() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $mapDefLat = $params->get( 'map_lat', '' );
    }

    public function getDefLng() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $mapDefLng = $params->get( 'map_lng', '' );
    }
    
    public function getMapTypeGoogle() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $mapMapTypeGoogle = $params->get( 'map_type_google', '' );
    }
    public function getMapTypeOSM() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $mapMapTypeOSM = $params->get( 'map_type_osm', '' );
    }
    public function getMapTypeCustom() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $mapMapTypeCustom = $params->get( 'map_type_custom', '' );
    }
    
    public function getHttpsProtocol() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $httpsprotocol = $params->get( 'httpsprotocol', '' );
    }
        
        public function getMapHeight() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        return $map_height = $params->get( 'map_height', '' );
    }
    
    public function getmapStreetViewList() 
    {
        if (!isset($this->mapStreetViewList)) 
        {       

            $this->_db->setQuery($this->_db->getQuery(true)
                ->select('h.title as text, h.id as value ')
                ->from('#__zhgooglemaps_streetviews as h')
                ->leftJoin('#__categories as c ON h.catid=c.id')
                ->where('1=1')
                ->order('h.title'));

            $this->mapStreetViewList = $this->_db->loadObjectList();

            // Custom Fields
            //if (!$this->mapStreetViewList = $this->_db->loadObjectList()) 
            //{
            //    $this->setError($this->_db->getError());
            //}

        }

        return $this->mapStreetViewList;
    }

    public function getmapWeatherTypeList() 
    {
        if (!isset($this->mapWeatherTypeList)) 
        {       

            $this->_db->setQuery($this->_db->getQuery(true)
                ->select('h.title as text, h.id as value ')
                ->from('#__zhgooglemaps_weathertypes as h')
                ->leftJoin('#__categories as c ON h.catid=c.id')
                ->where('1=1')
                ->order('h.title'));

            $this->mapWeatherTypeList = $this->_db->loadObjectList();

            // Custom Fields
            //if (!$this->mapWeatherTypeList = $this->_db->loadObjectList()) 
            //{
            //    $this->setError($this->_db->getError());
            //}

        }

        return $this->mapWeatherTypeList;
    }


    public function getmapTypeList() 
    {
        if (!isset($this->mapTypeList)) 
        {       

            $this->_db->setQuery($this->_db->getQuery(true)
                ->select('h.*, c.title as category ')
                ->from('#__zhgooglemaps_maptypes as h')
                ->leftJoin('#__categories as c ON h.catid=c.id')
                ->where('h.published=1')
                ->order('h.title'));

            $this->mapTypeList = $this->_db->loadObjectList();

            // Custom Fields
            //if (!$this->mapTypeList = $this->_db->loadObjectList()) 
            //{
            //    $this->setError($this->_db->getError());
            //}

        }

        return $this->mapTypeList;
    }

    public function getmapOverrideList() 
    {
        if (!isset($this->mapOverrideList)) 
        {       

            $this->_db->setQuery($this->_db->getQuery(true)
                ->select('h.title as text, h.id as value ')
                ->from('#__zhgooglemaps_text_overrides as h')
                ->leftJoin('#__categories as c ON h.catid=c.id')
                ->where('1=1')
                ->order('h.title'));


            $this->mapOverrideList = $this->_db->loadObjectList();

            // Custom Fields
            //if (!$this->mapOverrideList = $this->_db->loadObjectList()) 
            //{
            //    $this->setError($this->_db->getError());
            //}

        }

        return $this->mapOverrideList;
    }


    public function getinfobubbleStyleList() 
    {
        if (!isset($this->infobubbleStyleList)) 
        {       

            $this->_db->setQuery($this->_db->getQuery(true)
                ->select('h.title as text, h.id as value ')
                ->from('#__zhgooglemaps_infobubbles as h')
                ->leftJoin('#__categories as c ON h.catid=c.id')
                ->where('1=1')
                ->order('h.title'));

            $this->infobubbleStyleList = $this->_db->loadObjectList();

            // Custom Fields
            //if (!$this->infobubbleStyleList = $this->_db->loadObjectList()) 
            //{
            //    $this->setError($this->_db->getError());
            //}

        }

        return $this->infobubbleStyleList;
    }

    
    public function getCategoryList() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        $cat_list_type = $params->get( 'category_list_type', '' );
        if ($cat_list_type == "")
        {
            $cat_list_type = 0;
        }
        else
        {
            $cat_list_type = (int)$cat_list_type;
        }
        if ($cat_list_type == 1)
        {
            if (!isset($this->categoryList)) 
            {       

                $this->_db->setQuery($this->_db->getQuery(true)
                    ->select('h.title as text, h.id as value')
                    ->from('#__categories as h')
                    ->where('h.extension = \'com_zhgooglemap\' AND h.published IN (0,1)')
                    ->order('h.title'));

                $this->categoryList = $this->_db->loadObjectList();

                // Custom Fields
                //if (!$this->categoryList = $this->_db->loadObjectList()) 
                //{
                //    $this->setError($this->_db->getError());
                //}

            }
        }

        return $this->categoryList;        
    }

    public function getCategoryListType() 
    {
        // Get global params
        $params = JComponentHelper::getParams( 'com_zhgooglemap' );

        $cat_list_type = $params->get( 'category_list_type', '' );
        if ($cat_list_type == "")
        {
            $categoryListType = 0;
        }
        else
        {
            $categoryListType = (int)$cat_list_type;
        }

        return $categoryListType;        
    }
    
    
}