0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: state.php.tar
home/academiac/www/administrator/components/com_virtuemart/models/state.php 0000604 00000007763 15137216345 0023450 0 ustar 00 <?php /** * * Data module for shop countries * * @package VirtueMart * @subpackage Country * @author RickG, Max Milbers, jseros * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: state.php 6383 2012-08-27 16:53:06Z alatak $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); if(!class_exists('VmModel'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmmodel.php'); /** * Model class for shop countries * * @package VirtueMart * @subpackage State * @author RickG, Max Milbers */ class VirtueMartModelState extends VmModel { /** * constructs a VmModel * setMainTable defines the maintable of the model * @author Max Milbers */ function __construct() { parent::__construct('virtuemart_state_id'); $this->setMainTable('states'); $this->_selectedOrderingDir = 'ASC'; } /** * Retrieve the detail record for the current $id if the data has not already been loaded. * * Renamed to getSingleState to avoid overwriting by jseros * * @author Max Milbers */ function getSingleState(){ if (empty($this->_data)) { $this->_data = $this->getTable('states'); $this->_data->load((int)$this->_id); } return $this->_data; } /** * Retireve a list of countries from the database. * * @author RickG, Max Milbers * @return object List of state objects */ public function getStates($countryId, $noLimit=false, $published = false) { $quer= 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.(int)$countryId.'" '; if($published){ $quer .= 'AND `published`="1" '; } $quer .= 'ORDER BY `#__virtuemart_states`.`state_name`'; if ($noLimit) { $this->_data = $this->_getList($quer); } else { $this->_data = $this->_getList($quer, $this->getState('limitstart'), $this->getState('limit')); } if(count($this->_data) >0){ $this->_total = $this->_getListCount($quer); } return $this->_data; } /** * Tests if a state and country fits together and if they are published * * @author Max Milbers * @return String Attention, this function gives a 0=false back in case of success */ public static function testStateCountry($countryId,$stateId) { $countryId = (int)$countryId; $stateId = (int)$stateId; vmdebug('testStateCountry country '.$countryId.' $stateId '.$stateId); $db = JFactory::getDBO(); $q = 'SELECT * FROM `#__virtuemart_countries` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `published`="1" '; $db->setQuery($q); if($db->loadResult()){ //Test if country has states $q = 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `published`="1" '; $db->setQuery($q); if($res = $db->loadResult()){ vmdebug('testStateCountry country has states ',$res); //Test if virtuemart_state_id fits to virtuemart_country_id $q = 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `virtuemart_state_id`="'.$stateId.'" and `published`="1"'; $db->setQuery($q); if($db->loadResult()){ return true; } else { //There is a country, but the state does not exist or is unlisted return false; } } else { vmdebug('testStateCountry country has no states listed'); //This country has no states listed return true; } } else { //The given country does not exist, this can happen, when no country was chosen, which maybe valid. return true; } } } // pure php no closing tag home/academiac/www/administrator/components/com_virtuemart/controllers/state.php 0000604 00000003164 15137243264 0024522 0 ustar 00 <?php /** * * State controller * * @package VirtueMart * @subpackage State * @author RickG, Max Milbers * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: state.php 5399 2012-02-08 19:29:45Z Milbo $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); // Load the controller framework jimport('joomla.application.component.controller'); if(!class_exists('VmController'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmcontroller.php'); /** * Product Controller * * @package VirtueMart * @subpackage State * @author RickG, Max Milbers */ class VirtuemartControllerState extends VmController { /** * Method to display the view * * @access public * @author RickG, Max Milbers */ function __construct() { parent::__construct('virtuemart_state_id'); $country = JRequest::getInt('virtuemart_country_id', 0); $this->redirectPath .= ($country > 0) ? '&virtuemart_country_id=' . $country : ''; } /** * Retrieve full statelist */ function getList() { /* Create the view object. */ $view = $this->getView('state', 'json'); /* Now display the view. */ $view->display(null); } } home/academiac/www/components/com_virtuemart/controllers/state.php 0000604 00000003035 15137453531 0021637 0 ustar 00 <?php /** * * State controller * * @package VirtueMart * @subpackage State * @author jseros, RickG, Max Milbers * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: state.php 5399 2012-02-08 19:29:45Z Milbo $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); // Load the controller framework jimport('joomla.application.component.controller'); if(!class_exists('VirtueMartModelState')) require( JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'state.php' ); class VirtueMartControllerState extends JController { /** * Method to display the view * * @access public * @author RickG, Max Milbers */ public function __construct() { parent::__construct(); $stateModel = VmModel::getModel('state'); $states = array(); //retrieving countries id $countries = JRequest::getString('virtuemart_country_id'); $countries = explode(',', $countries); foreach($countries as $country){ $states[$country] = $stateModel->getStates( JFilterInput::clean($country, 'INTEGER'),true,true ); } echo json_encode($states); jExit(); } }
©
2018.