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/mappath.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');

/**
 * ZhGooglePath Model
 */
class ZhGoogleMapModelMapPath extends JModelAdmin
{
    var $mapList;
        var $mapapikey;
        var $mapapiversion;

    var $mapDefLat;
    var $mapDefLng;

    var $markerGroupList;
    var $mapTypeList;
    
    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 = 'MapPath', $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.mappath', 'mappath', 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/mappath.js';
    }
    
    /**
     * Method to get a single record.
     *
     * @param   integer  $pk  The id of the primary key.
     *
     * @return  mixed  Object on success, false on failure.
     */
    public function getItem($pk = null)
    {
        if ($item = parent::getItem($pk))
        {

            if (!empty($item->id))
            {
                $item->tags = new JHelperTags;
                $item->tags->getTagIds($item->id, 'com_zhgooglemap.mappath');
            }
        }

        return $item;
    }
    
    /**
     * 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.mappath.data', array());
        if (empty($data)) 
        {
            $data = $this->getItem();
        }
        return $data;
    }

    public function getmapList() 
    {
        if (!isset($this->mapList)) 
        {       

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

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

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

        }

        return $this->mapList;
    }

    public function getmarkerGroupList() 
    {
        if (!isset($this->markerGroupList)) 
        {       

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

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

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


        }

        return $this->markerGroupList;
    }
    
    
    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 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 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;        
    }
    
    
}